kcl.waterloo.graphics
Interface GJGraphInterface
-
- All Superinterfaces:
- java.util.EventListener, GJAxisSupportInterface, GJLayerInterface<GJGraphInterface>, GJLinkableInterface, GJObservableInterface, java.beans.PropertyChangeListener
- All Known Implementing Classes:
- GJAbstractGraph, GJAbstractGraph0, GJAbstractGraph1, GJGraph
public interface GJGraphInterface extends GJLayerInterface<GJGraphInterface>, GJAxisSupportInterface, GJObservableInterface, GJLinkableInterface
Defines the set of methods to be exposed as public in graph classes.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description java.awt.Componentadd(java.awt.Component c, double x, double y)Add a component at the specified axis locationjava.awt.Componentadd(java.awt.Component c, double x, double y, int alignX, int alignY)Add a component at the specified axis location with the specified alignmentvoidadd(GJAnnotationInterface<java.awt.geom.Path2D,GJGraphInterface,java.awt.Stroke,java.awt.Paint,java.awt.Font> a)Adds an annotation to the container for the graph.GJPlotInterfaceadd(GJPlotInterface plot)Adds a plot to the graph.GJPlotInterfaceadd(GJPlotInterface plot, boolean flag)Adds a plot to a graphvoidaddListeners()Adds listeners or registers the mouse handle to be returned bygetMouseHandler.voidautoScale()Auto-scales the graph's axesjava.awt.geom.Rectangle2DconvertPixelsToPosition(java.awt.geom.Rectangle2D r)Returns a rectangle defined in axes units from a rectangle defined in pixels.voidcreateAxes()Creates the objects for drawing axes for this graph.GJEditorInterfacefetchEditor()Returns the editor.GJAbstractGraphContainergetGraphContainer()Returns the container for this graph.java.awt.event.MouseAdaptergetMouseHandler()Returns a MouseAdapter for this component.javax.swing.JLabelgetMousePositionTextField()Returns a reference to a JLabel that will be updated with the mouse position (unless null).doublegetPixelHeight()Returns the height of a pixel in graph coordinates.doublegetPixelWidth()Returns the width of a pixel in graph coordinates.java.util.ArrayList<GJPlotInterface>getPlots()Returns the list of top plots associated with this graph.java.util.ArrayList<GJPlotInterface>getSelectedPlots()Returns a list of plot that are currently selected (e.g.GJDataTransformInterfacegetXTransform()Get the transform for the x-dataGJDataTransformInterfacegetYTransform()Get the transform for the y-databooleanisPolar()booleanisTextAsInverse()Returns true if the data shown in themousePositionTextFieldare inverse transformed.voidremove(GJPlotInterface plot)Removes a plot from this graph's hierarchy.voidsaveAsXML(java.lang.String s)Convenience method to save a graph to a "kclf" file.voidsetBackgroundPainted(boolean flag)Determines whether the background is painted.voidsetEditor(GJEditorInterface editor)Sets the editor to be activated when this graph is double-clicked.voidsetGraphContainer(GJAbstractGraphContainer c)Sets theGJAbstractGraphContainerfor this graph.voidsetGraphContainer(GJAbstractGraphContainer c, java.awt.Insets insets)voidsetKeyAntialiasing(java.lang.Object o)Sets the anti-aliasing key for rendering this graph.voidsetMousePositionTextField(javax.swing.JLabel t)Sets a reference to a JLabel that will be updated with the mouse position (unless null).voidsetPlots(java.util.ArrayList<GJPlotInterface> list)Replaces the internal plot list (or its contents) with the suppliedArrayList(or its contents).voidsetSelectedPlots(java.util.ArrayList<GJPlotInterface> p)Programmatically selects plots.voidsetTextAntialiasing(java.lang.Object o)Sets the text anti-aliasing key for rendering this graph.voidsetTextAsInverse(boolean flag)Sets the textAsInverse flag.voidsetXTransform(GJDataTransformInterface tr)Sets the transform for the x-datavoidsetYTransform(GJDataTransformInterface tr)Sets the transform for the y-datadoublexPixelToPosition(double pixel)Convert a pixel location to a graph coordinate on the x-axis.double[]xPixelToPosition(double[] pixel)Convert an array of pixel locations to graph coordinates on the x-axis.double[]xPixelToPositioni(double[] pixel)Convert an array of pixel locations to graph coordinates on the x-axis.doublexPositionToPixel(double position)Convert an axis location to a pixel value This method does not compensate for rotation or zoom.double[]xPositionToPixel(double[] positions)Convert an array of axis locations to a pixel values.double[]xPositionToPixeli(double[] positions)Convert an array of axis locations to a pixel values.doubleyPixelToPosition(double pixel)Convert a pixel location to a graph coordinate on the y-axis.double[]yPixelToPosition(double[] pixel)Convert an array of pixel locations to graph coordinates on the y-axis.double[]yPixelToPositioni(double[] pixel)Convert an array of pixel locations to graph coordinates on the y-axis.doubleyPositionToPixel(double position)Convert an array of axis locations to a pixel values.double[]yPositionToPixel(double[] positions)Convert an array of axis locations to a pixel values.double[]yPositionToPixeli(double[] positions)Convert an array of axis locations to a pixel values.-
Methods inherited from interface kcl.waterloo.graphics.GJLayerInterface
add, getAncestorGraph, getCurrentLayer, getCurrentLayerIndex, getLayer, getLayers, indexOf, setCurrentLayer, setCurrentLayerIndex
-
Methods inherited from interface kcl.waterloo.graphics.GJAxisSupportInterface
format, formatXAxisLabel, formatYAxisLabel, getAxesBounds, getAxisColor, getAxisMouseHandler, getAxisStrokeWeight, getBottomAxisPanel, getCategoricalLabels, getLeftAxisPanel, getMajorGridColor, getMajorGridStrokeWeight, getMajorXHint, getMajorYHint, getMinorCountXHint, getMinorCountYHint, getMinorGridColor, getMinorGridStrokeWeight, getOrigin, getOriginX, getOriginY, getRightAxisPanel, getTopAxisPanel, getXAxisLabelRotation, getXLabel, getXLeft, getXMax, getXMin, getXRight, getYAxisLabelRotation, getYBottom, getYLabel, getYMax, getYMin, getYTop, isBottomAxisLabelled, isBottomAxisPainted, isCategorical, isInnerAxisLabelled, isInnerAxisPainted, isLeftAxisLabelled, isLeftAxisPainted, isMajorGridPainted, isMinorGridPainted, isRightAxisLabelled, isRightAxisPainted, isTopAxisLabelled, isTopAxisPainted, isXReversed, isYReversed, setAxesBounds, setAxisColor, setAxisStrokeWeight, setBottomAxisLabelled, setBottomAxisPainted, setInnerAxisLabelled, setInnerAxisPainted, setLeftAxisLabelled, setLeftAxisPainted, setMajorGridColor, setMajorGridPainted, setMajorGridStrokeWeight, setMajorXHint, setMajorXHint, setMajorYHint, setMajorYHint, setMinorCountXHint, setMinorCountYHint, setMinorGridColor, setMinorGridPainted, setMinorGridStrokeWeight, setOrigin, setOriginX, setOriginY, setReverseX, setReverseY, setRightAxisLabelled, setRightAxisPainted, setTopAxisLabelled, setTopAxisPainted, setXLabel, setXLeft, setXRight, setYBottom, setYLabel, setYTop
-
Methods inherited from interface kcl.waterloo.observable.GJObservableInterface
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, hasListeners, hasSelfListener, removePropertyChangeListener, removePropertyChangeListener
-
Methods inherited from interface kcl.waterloo.observable.GJLinkableInterface
addLink, getLinks, removeLink, setLinks
-
-
-
-
Method Detail
-
setGraphContainer
void setGraphContainer(GJAbstractGraphContainer c)
Sets theGJAbstractGraphContainerfor this graph.- Parameters:
c- the Container to add this GJAbstractGraph to
-
add
GJPlotInterface add(GJPlotInterface plot)
Adds a plot to the graph. Equivalent toadd(plot, true);- Parameters:
plot- the plot to add to the graph- Returns:
- a reference to the added plot
-
add
GJPlotInterface add(GJPlotInterface plot, boolean flag)
Adds a plot to a graph- Parameters:
plot- the plot to addflag- if true, the graph will be rescaled to accomodate the added plot.- Returns:
- a reference to the added plot
-
remove
void remove(GJPlotInterface plot)
Removes a plot from this graph's hierarchy.- Parameters:
plot- the plot to remove.
-
add
java.awt.Component add(java.awt.Component c, double x, double y)Add a component at the specified axis location- Parameters:
c- The component to addx- The x-axis positiony- The y-axis position- Returns:
- the added component
-
add
java.awt.Component add(java.awt.Component c, double x, double y, int alignX, int alignY)Add a component at the specified axis location with the specified alignment- Parameters:
c- The component to addx- The x-axis positiony- The y-axis positionalignX- The X-alignment of the component on x,yalignY- The Y-alignment of the component on x,y- Returns:
- the added component
-
add
void add(GJAnnotationInterface<java.awt.geom.Path2D,GJGraphInterface,java.awt.Stroke,java.awt.Paint,java.awt.Font> a)
Adds an annotation to the container for the graph. The annotation setGraph method is used to reference this graph in the annotation instance.- Parameters:
a- theGJAnnotationInterfaceto add
-
setGraphContainer
void setGraphContainer(GJAbstractGraphContainer c, java.awt.Insets insets)
- Parameters:
c- theGJAbstractGraphContainerto add this GJAbstractGraph toinsets- an Insets object specifying the margins
-
getGraphContainer
GJAbstractGraphContainer getGraphContainer()
Returns the container for this graph. Null if the graph has no container.- Returns:
- the GJAbstractGraphContainer
-
createAxes
void createAxes()
Creates the objects for drawing axes for this graph.
-
xPixelToPosition
double xPixelToPosition(double pixel)
Convert a pixel location to a graph coordinate on the x-axis. This method does not compensate for rotation or zoom.- Parameters:
pixel- location on x- Returns:
- the position on the x-axis
-
xPixelToPosition
double[] xPixelToPosition(double[] pixel)
Convert an array of pixel locations to graph coordinates on the x-axis. This method does not compensate for rotation or zoom.- Parameters:
pixel- location on x- Returns:
- the positions on the x-axis
-
xPixelToPositioni
double[] xPixelToPositioni(double[] pixel)
Convert an array of pixel locations to graph coordinates on the x-axis. The conversion may be done in-place, so the input data are destroyed in the process. This method does not compensate for rotation or zoom.- Parameters:
pixel- location on x- Returns:
- the positions on the x-axis
-
yPixelToPosition
double yPixelToPosition(double pixel)
Convert a pixel location to a graph coordinate on the y-axis. This method does not compensate for rotation or zoom.- Parameters:
pixel- location on y- Returns:
- the position on the y-axis
-
yPixelToPosition
double[] yPixelToPosition(double[] pixel)
Convert an array of pixel locations to graph coordinates on the y-axis. This method does not compensate for rotation or zoom.- Parameters:
pixel- location on y- Returns:
- the positions on the y-axis
-
yPixelToPositioni
double[] yPixelToPositioni(double[] pixel)
Convert an array of pixel locations to graph coordinates on the y-axis. The conversion may be done in-place, so the input data are destroyed in the process. This method does not compensate for rotation or zoom.- Parameters:
pixel- location on y- Returns:
- the positions on the y-axis
-
getPixelWidth
double getPixelWidth()
Returns the width of a pixel in graph coordinates. This method does not compensate for rotation or zoom.- Returns:
- the value
-
getPixelHeight
double getPixelHeight()
Returns the height of a pixel in graph coordinates. This method does not compensate for rotation or zoom.- Returns:
- the value
-
xPositionToPixel
double xPositionToPixel(double position)
Convert an axis location to a pixel value This method does not compensate for rotation or zoom.- Parameters:
position- on x-axis- Returns:
- pixel location on x
-
xPositionToPixel
double[] xPositionToPixel(double[] positions)
Convert an array of axis locations to a pixel values. This method does not compensate for rotation or zoom.- Parameters:
positions- on x-axis- Returns:
- pixel locations on x
-
xPositionToPixeli
double[] xPositionToPixeli(double[] positions)
Convert an array of axis locations to a pixel values. The conversion may be done in-place, thus destroying the input values. This method does not compensate for rotation or zoom.- Parameters:
positions- on x-axis- Returns:
- pixel locations on x
-
yPositionToPixel
double yPositionToPixel(double position)
Convert an array of axis locations to a pixel values. This method does not compensate for rotation or zoom.- Parameters:
position- on y-axis- Returns:
- pixel locations on y
-
yPositionToPixel
double[] yPositionToPixel(double[] positions)
Convert an array of axis locations to a pixel values. This method does not compensate for rotation or zoom.- Parameters:
positions- on y-axis- Returns:
- pixel locations on y
-
yPositionToPixeli
double[] yPositionToPixeli(double[] positions)
Convert an array of axis locations to a pixel values. The conversion may be done in-place, thus destroying the input values. This method does not compensate for rotation or zoom.- Parameters:
positions- on y-axis- Returns:
- pixel locations on y
-
convertPixelsToPosition
java.awt.geom.Rectangle2D convertPixelsToPosition(java.awt.geom.Rectangle2D r)
Returns a rectangle defined in axes units from a rectangle defined in pixels.- Parameters:
r- a Rectangle2D in pixels- Returns:
- a Rectangle2D in axes units
-
getXTransform
GJDataTransformInterface getXTransform()
Get the transform for the x-data- Returns:
- a
GJDataTransformInterface
-
setXTransform
void setXTransform(GJDataTransformInterface tr)
Sets the transform for the x-data- Parameters:
tr- aGJDataTransformInterface
-
getYTransform
GJDataTransformInterface getYTransform()
Get the transform for the y-data- Returns:
- a
GJDataTransformInterface
-
setYTransform
void setYTransform(GJDataTransformInterface tr)
Sets the transform for the y-data- Parameters:
tr- aGJDataTransformInterface
-
getPlots
java.util.ArrayList<GJPlotInterface> getPlots()
Returns the list of top plots associated with this graph. It is recommended that this should be a clone of the internal ArrayList.- Returns:
- a ArrayList
-
setPlots
void setPlots(java.util.ArrayList<GJPlotInterface> list)
Replaces the internal plot list (or its contents) with the suppliedArrayList(or its contents). Copying the contents is recommended. This method is called during de-serialization of xml files. It is public for that reason only and is not intended for use elsewhere.- Parameters:
list- aArrayList<GJPlotInterface>
-
getSelectedPlots
java.util.ArrayList<GJPlotInterface> getSelectedPlots()
Returns a list of plot that are currently selected (e.g. by mouse click).- Returns:
- a
ArrayList<GJPlotInterface>
-
setSelectedPlots
void setSelectedPlots(java.util.ArrayList<GJPlotInterface> p)
Programmatically selects plots.- Parameters:
p- aArrayList<GJPlotInterface>
-
setEditor
void setEditor(GJEditorInterface editor)
Sets the editor to be activated when this graph is double-clicked.- Parameters:
editor- an object implementing theGJEditorInterface.
-
fetchEditor
GJEditorInterface fetchEditor()
Returns the editor.- Returns:
- a
GJEditorInterface.
-
saveAsXML
void saveAsXML(java.lang.String s)
Convenience method to save a graph to a "kclf" file.- Parameters:
s- String description of the file.
-
setKeyAntialiasing
void setKeyAntialiasing(java.lang.Object o)
Sets the anti-aliasing key for rendering this graph. Note this setting will be overriden while rendering plots.- Parameters:
o- a rendering key value
-
setTextAntialiasing
void setTextAntialiasing(java.lang.Object o)
Sets the text anti-aliasing key for rendering this graph. Note this setting will be overriden while rendering plots.- Parameters:
o- a rendering key value
-
getMousePositionTextField
javax.swing.JLabel getMousePositionTextField()
Returns a reference to a JLabel that will be updated with the mouse position (unless null).- Returns:
- a JLabel
-
setMousePositionTextField
void setMousePositionTextField(javax.swing.JLabel t)
Sets a reference to a JLabel that will be updated with the mouse position (unless null).- Parameters:
t- a JLabel
-
isPolar
boolean isPolar()
-
isTextAsInverse
boolean isTextAsInverse()
Returns true if the data shown in themousePositionTextFieldare inverse transformed.- Returns:
- the flag
-
setTextAsInverse
void setTextAsInverse(boolean flag)
Sets the textAsInverse flag. When set true, mouse position values shown in the mousePositionTextField will be inverse transformed.- Parameters:
flag- the textAsInverse to set
-
setBackgroundPainted
void setBackgroundPainted(boolean flag)
Determines whether the background is painted. Background painting needs to be turned off to support multi-layered graphs so that graphs at the top of the z-order does not obscure those below.- Parameters:
flag- boolean value
-
getMouseHandler
java.awt.event.MouseAdapter getMouseHandler()
Returns a MouseAdapter for this component. The methods of the handler can then be called by the mouse listeners of components that are higher in the Swing hierarchy. This is used in Waterloo e.g. by theGJAddedComponentMouseHandlerto support rotated and zoomed graphs. Instead of adding mouse listeners directly to graphs, they are located by reflection and the methods called after on the target graph after accounting for any rotation/zoom of the graphics output.- Returns:
- the MouseAdapter
-
addListeners
void addListeners()
Adds listeners or registers the mouse handle to be returned bygetMouseHandler.
-
autoScale
void autoScale()
Auto-scales the graph's axes
-
-
DMelt 3.0 © DataMelt by jWork.ORG