|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectJLogView_.datastructs.LGGraph
public class LGGraph
LGGraph is a class representing the data structure of a graph. It contains a set of columns, all the columns being used in all different plots. It can contains any number of plots, any number of shapes and any numer of annotations. labels to be used for axis are also stored here.
Constructor Summary | |
---|---|
LGGraph(java.lang.String n,
int ncol,
int nplots,
int scaletype)
This is the constructor for LGGraph. |
Method Summary | |
---|---|
void |
addAnnotation(LGAnnotation note)
This method adds a new annotation to be drawn on this graph |
void |
addColumn(java.lang.String n)
This method adds a new column to this graph. |
void |
addDataInColumn(int index,
float data)
This method returns add the given data into the specified column. |
void |
addPlot(int x,
int y)
This method adds a new plot definition to this graph. |
void |
addShape(LGShape shap)
This method adds a new shape to be drawn on this graph |
void |
clearAnnotations()
This method deletes all existing annotations. |
void |
concatGraph(LGGraph g)
This method concatenates the given graph with this graph. |
void |
deleteAnnotation(int delindex)
This method deletes an existing annotation. |
int[] |
draw(java.awt.Graphics2D g,
int w,
int h,
LGAxis X,
LGAxis Y,
boolean useColours,
boolean useLineStyles,
boolean useSymbols)
This method the big drawing method. |
LGAnnotation[] |
getAnnotations()
This method returns all the existing annotations from this graph. |
LGColumn[] |
getColumns()
This method returns all the columns from this graph. |
LGLegend |
getLegend()
This method returns the legend for this graph. |
java.lang.String |
getName()
This method returns the name of this graph |
java.awt.Color |
getNameColour()
This method returns the colour that is to be used to display the name of the graph. |
java.awt.Font |
getNameFont()
This method returns the font details that are to be used to display the name of the graph. |
java.lang.String |
getNameOf(float x,
float y)
This method returns the name of the plot (which is also the y column name) associated with these coordinates. |
float[] |
getNearestSpot(float X,
float Y,
float xrad,
float yrad)
This method returns the nearest data point to the given coordinates within the given radii. |
int |
getNPlot()
This method returns the number of plots within this graph. |
LGPlot[] |
getPlots()
This method returns all the plots definitions from this graph. |
LGShape[] |
getShapes()
This method returns all the shape defintions from this graph. |
javax.swing.JLabel |
getXLabel()
This method returns the label for the X axis. |
javax.swing.JLabel |
getYLabel()
This method returns the label for the Y axis. |
boolean |
isEmpty()
This methods performs a safety check to see if the graph is empty. |
boolean |
isScatterPlot()
This method tells whether or not this graph behaves as a scatter. |
void |
setAnnotation(int index,
LGAnnotation note)
This method updates/sets the value of an existing annotation. |
void |
setAxesRange(LGAxis X,
LGAxis Y)
This method sets the axis range for the physical axis objects. |
void |
setLegend(LGLegend newlegend)
This method sets the legend for this graph. |
void |
setName(java.lang.String newname)
This method sets the name of this graph |
void |
setNameColour(java.awt.Color c)
This method sets the colour that is to be used to display the name of the graph. |
void |
setNameFont(java.awt.Font f)
This method sets the font details that are to be used to display the name of the graph. |
void |
setScaling(float xmin,
float xmax,
float ymin,
float ymax)
This method sets the scale, or axis ranges to be more precise, for this graph. |
void |
setScatterPlot(boolean scatter)
This method tells this graph to behave as a scatter plot or not. |
void |
setXLabel(javax.swing.JLabel newlabel)
This method extract the label information for the X axis from the given object. |
void |
setYLabel(javax.swing.JLabel newlabel)
This method extract the label information for the Y axis from the given object. |
void |
switchPlot(int index,
boolean onoff)
This method switches one particular plot on or off. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LGGraph(java.lang.String n, int ncol, int nplots, int scaletype)
n
- a String representing the graph namencol
- the number of columnsnplots
- the number of plotsscaletype
- the type of scaling (0 -> NOUGHT, 1 -> AUTO, 2 -> specified)Method Detail |
---|
public void addPlot(int x, int y)
x
- the index of the column to be use for x coordinatey
- the index of the column to be use for y coordinatepublic void setScatterPlot(boolean scatter)
scatter
- a boolean, true -> only draw data points, false -> draw data points and linespublic boolean isScatterPlot()
public int getNPlot()
public boolean isEmpty()
public void switchPlot(int index, boolean onoff)
index
- the index of the plot (starting from 0)onoff
- a boolean, true -> draw the plot, false -> skip itpublic void addColumn(java.lang.String n)
n
- a String representing the column nameString
public void addShape(LGShape shap)
shap
- an LGShape object representing the shape to be drawnLGShape
public void addAnnotation(LGAnnotation note)
note
- an LGAnnotation object representing the annotation to be drawnLGAnnotation
public void setAnnotation(int index, LGAnnotation note)
index
- the index of the annotation in the list of annotation (starting from 0)note
- an LGAnnotation object representing the annotation to be drawnLGAnnotation
public void deleteAnnotation(int delindex)
delindex
- the index of the annotation in the list of annotation (starting from 0)public LGAnnotation[] getAnnotations()
LGAnnotation
public void clearAnnotations()
public float[] getNearestSpot(float X, float Y, float xrad, float yrad)
X
- the x coordinate of the point we are searching fromY
- the y coordinate of the point we are searching fromxrad
- the radius along the x axis within we are accepting data pointsyrad
- the radius along the y axis within we are accepting data points
public java.lang.String getNameOf(float x, float y)
x
- the x coordinate of the pointy
- the y coordinate of the point
String
public void addDataInColumn(int index, float data)
index
- the column index (starting from 0)data
- the data valuepublic LGColumn[] getColumns()
LGColumn
public LGPlot[] getPlots()
LGPlot
public LGShape[] getShapes()
LGShape
public java.lang.String getName()
String
public java.awt.Font getNameFont()
Font
public java.awt.Color getNameColour()
Color
public void setName(java.lang.String newname)
newname
- a String representing the name of this graphString
public void setNameFont(java.awt.Font f)
f
- a Font object containing the font details (face+style+size)Font
public void setNameColour(java.awt.Color c)
c
- a Color object represeting the colour for the nameColor
public void concatGraph(LGGraph g)
g
- the LGGraph object to be concatenated with this graphLGGraph
public void setScaling(float xmin, float xmax, float ymin, float ymax)
xmin
- the minimum value for the x axisxmax
- the maximum value for the x axisymin
- the minimum value for the y axisymax
- the maximum value for the y axispublic void setAxesRange(LGAxis X, LGAxis Y)
X
- the LGAxis object representing the x axisY
- the LGAxis object representing the y axisLGAxis
public javax.swing.JLabel getXLabel()
JLabel
public javax.swing.JLabel getYLabel()
JLabel
public void setYLabel(javax.swing.JLabel newlabel)
newlabel
- a JLabel object containing the text, font details and colour for the labelJLabel
public void setXLabel(javax.swing.JLabel newlabel)
newlabel
- a JLabel object containing the text, font details and colour for the labelJLabel
public int[] draw(java.awt.Graphics2D g, int w, int h, LGAxis X, LGAxis Y, boolean useColours, boolean useLineStyles, boolean useSymbols)
One important trick to know here, we are drawing considering the y axis of the canvas as going upwards (it actually goes downwards). This makes things more intuitive. The whole thing gets flipped back by the canvas widget so no worries here.
it also returns the canvas coordinates of the quadrant in which the least number of data points were draw (helps find out the best start point for legend).
g
- the graphics context on which we are drawingw
- the width of the canvas in pixelsh
- the height of the canvas in pixelsX
- an LGAxis object representing the x axisY
- an LGAxis object representing the y axisuseColours
- a boolean, true -> use colours, false -> blackuseLineStyles
- a boolean, true -> use line styles, false -> plain lineuseSymbols
- a boolean, true -> use symbols, false -> use discs onlyLGAxis
,
Graphics2D
public void setLegend(LGLegend newlegend)
newlegend
- the LGLegend object representing the legend for this graphLGLegend
public LGLegend getLegend()
LGLegend
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |