kcl.waterloo.graphics.plots2D
Class GJAbstractPlot
- java.lang.Object
-
- kcl.waterloo.observable.GJAbstractObservable
-
- kcl.waterloo.graphics.plots2D.GJAbstractPlotModelImpl
-
- kcl.waterloo.graphics.plots2D.GJAbstractPlot
-
- All Implemented Interfaces:
- java.beans.PropertyChangeListener, java.util.EventListener, GJEffectorInterface, GJFastPlotInterface, GJPlotInterface, GJLinkableInterface, GJObservableInterface, GJDataModelInterface<java.awt.geom.Rectangle2D,GJGraphInterface>, GJFillableInterface<java.awt.Shape,java.awt.Paint>, GJScreenDataInterface<java.awt.Shape>, GJVisualsInterface<GJMarker,java.awt.Paint,java.awt.BasicStroke,java.awt.Dimension,java.awt.Shape>
- Direct Known Subclasses:
- GJAbstractPolarPlot, GJBar, GJBox, GJCloud, GJComponentPlot, GJContour, GJErrorBar, GJFastLine, GJFeather, GJLine, GJPathPlot, GJPie, GJQuiver, GJScatter, GJStairs, GJStem
public abstract class GJAbstractPlot extends GJAbstractPlotModelImpl implements GJFillableInterface<java.awt.Shape,java.awt.Paint>, GJFastPlotInterface
Abstract superclass for the individual plot types. GJAbstractPlot defines methods and properties common to each of them. Some subclasses will override the methods in the abstract class. Most plot sub-classes support multiplexed data. For these sub-classes, isMultiplexible returns true and properties such as the Marker, EdgeColor, Fill etc should be an array of values that will be cycled through during plotting.Required methods are defined in the GJPlotInterface interface. Among these, subclasses must implement the following methods:
a public createInstance method that calls the constructor
paintPlot
In addition, if multiplexed plots are not supported <@code isMultiplexible> should be overridden to return <@code false>.This code is part of the Waterloo Scientific Graphics package from King's College London
-
-
Field Summary
-
Fields inherited from class kcl.waterloo.graphics.plots2D.GJAbstractPlotModelImpl
screenDataArray
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description GJPlotInterfaceadd(GJPlotInterface plot)Adds a plot as a child plot of this plot.GCFramecreateFrame()java.util.ArrayList<GJPlotInterface>findPlotBelow(double x, double y)Returns an ArrayList of plots located beneath [x,y] in the coordinate space of the parent plot.java.util.ArrayList<GJPlotInterface>findPlotBelow(java.awt.geom.Point2D p)Returns an ArrayList of plots located beneathjava.awt.Pointin the coordinate space of the parent plot.GJFillableInterface<java.awt.Shape,java.awt.Paint>getAreaFill()java.awt.PaintgetAreaPaint()Returns the object used to paint the area e.g.java.awt.geom.Rectangle2DgetDataRange()getDataRange returns the range on the X and Y axes that can potentially be filled by the data points given the current contents of the XData and YData properties.org.jdesktop.swingx.painter.effects.AreaEffectgetEffect()java.awt.ShapegetFillable()getFillable provides the Area instance to fill.floatgetFillAlpha()java.awt.AlphaCompositegetFillComposite()java.util.ArrayList<GJPlotInterface>getNode()Returns an ArrayList of plots that are descendant plots of this plot.GJPlotInterfacegetParentPlot()Returns a reference to parent plot.java.util.ArrayList<GJPlotInterface>getPlots()Deprecated.GJPlotInterfacegetTopPlot()Returns the ancestor plot that is the TopPlot in this plot's hierarchy.java.awt.geom.Rectangle2DgetVisualRange()booleanintersects(double x, double y)Determines whether the specified point intersects the data in the ScreenDataArray.booleanintersects(java.awt.geom.Point2D p)Determines whether the specified point intersects the data in the ScreenDataArray.booleanisMultiplexible()booleanisOnEDT()booleanisSelected()Returns true if this plot is presently selectedbooleanisShowing()Returns true if this plot is visible and in a host container that returns isVisible==true.booleanisTopPlot()Returns true if this is a top plot, i.e.booleanisVisible()Returns true if painting of this plot is enabledvoidpaintPlot(java.awt.Graphics2D g2)Note that this method is overloaded by all concrete sub-classes which should call this super-class method.voidpaintPlotEntry(java.awt.Graphics2D g2)Entry point for plotting called from the graph methods.voidplotRedraw()plotRedraw repaints this plot without re-painting the container hierarchy and, therefore, without erasing the previous copy of the plot on screen.voidplotRedraw(java.awt.Graphics2D g)Performs a plot redraw using the supplied Graphics instancebooleanplotUpdate()In this abstract class implementations, plotUpdate will generally just call plotRedraw.booleanplotUpdate(java.awt.Graphics2D g)Performs a plot append using the supplied Graphics instanceGJPlotInterfaceplus(GJPlotInterface p2)Simply callsadd.voidpropertyChange(java.beans.PropertyChangeEvent pce)voidsaveAsXML(java.lang.String fileName)voidsetAntialiasing(boolean flag)voidsetAreaFill(GJFillableInterface<java.awt.Shape,java.awt.Paint> areaFill)voidsetAreaPaint(java.awt.Paint p)Sets the object used to paint the area e.g.voidsetEffect(org.jdesktop.swingx.painter.effects.AreaEffect effect)voidsetFillAlpha(float alpha)voidsetFillComposite(java.awt.AlphaComposite composite)voidsetParentPlot(GJPlotInterface p)Sets the parent plot for this plot.voidsetSelected(boolean flag)Sets or clears the selected flag for this plot, together with its ancestors and descendant plotsvoidsetSelectionFlag(boolean flag)Sets or clears the selected flag for this plot, together with its descendant plots but not ancestorsvoidsetVisible(boolean flag)Enables/disables painting of this plot.java.lang.StringtoString()java.lang.StringtoString(boolean flag)-
Methods inherited from class kcl.waterloo.graphics.plots2D.GJAbstractPlotModelImpl
getAlpha, getCompositeMode, getDataModel, getDynamicMarkerSize, getEdgeColor, getEdgeStroke, getFill, getLineColor, getLineStroke, getMarker, getMarkerArray, getMultiplexLength, getName, getParentGraph, getPlotList, getRenderHintState, getScreenDataArray, getScreenDataArrayAsCopy, getTextHintState, getVisualModel, getXData, getXDataValues, getXTransform, getYData, getYDataValues, getYTransform, isMultiplexed, setAlpha, setCompositeMode, setData, setDataModel, setDynamicMarkerSize, setEdgeColor, setEdgeColor, setEdgeColor, setEdgeColor, setEdgeColor, setEdgeStroke, setEdgeStroke, setEdgeStroke, setEdgeStroke, setEdgeStroke, setExtraData0, setExtraData1, setExtraData2, setExtraData3, setFill, setFill, setFill, setFill, setFill, setLineColor, setLineColor, setLineColor, setLineColor, setLineStroke, setLineStroke, setLineStroke, setLineStroke, setLineStroke, setMarker, setMarker, setMarkerArray, setMarkerArray, setMarkerArray, setName, setName, setParentGraph, setPlotList, setRenderHintState, setScreenDataArray, setTextHintState, setVisualModel, setXData, setXData, setXData, setXData, setXData, setYData, setYData, setYData, setYData, setYData
-
Methods inherited from class kcl.waterloo.observable.GJAbstractObservable
addLink, addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, getLinks, getPCS, getPropertyChangeListeners, getPropertyChangeListeners, hasListeners, hasSelfListener, removeLink, removePropertyChangeListener, removePropertyChangeListener, setLinks
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
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
-
isMultiplexible
public boolean isMultiplexible()
- Specified by:
isMultiplexiblein interfaceGJDataModelInterface<java.awt.geom.Rectangle2D,GJGraphInterface>
-
isTopPlot
public final boolean isTopPlot()
Returns true if this is a top plot, i.e. a plot that is not a descendant of another plot- Specified by:
isTopPlotin interfaceGJPlotInterface- Returns:
- true/false
-
setVisible
public final void setVisible(boolean flag)
Description copied from interface:GJPlotInterfaceEnables/disables painting of this plot. This can be useful when updating the data model for the plot if the there is a risk that the transient state of the plot will cause the paintPlot method to throw exceptions. When visible is set false, the paintPlot method will not be called. You can therefore avoid the need for conditional statements in the the paintPlot method that might slow down rendering when it is being called frequently.- Specified by:
setVisiblein interfaceGJPlotInterface- Parameters:
flag- true so enable painting
-
isVisible
public final boolean isVisible()
Description copied from interface:GJPlotInterfaceReturns true if painting of this plot is enabled- Specified by:
isVisiblein interfaceGJPlotInterface- Returns:
- the flag
-
isShowing
public final boolean isShowing()
Returns true if this plot is visible and in a host container that returns isVisible==true.- Returns:
- the flag
-
setSelected
public final void setSelected(boolean flag)
Description copied from interface:GJPlotInterfaceSets or clears the selected flag for this plot, together with its ancestors and descendant plots- Specified by:
setSelectedin interfaceGJPlotInterface
-
setSelectionFlag
public final void setSelectionFlag(boolean flag)
Description copied from interface:GJPlotInterfaceSets or clears the selected flag for this plot, together with its descendant plots but not ancestors- Specified by:
setSelectionFlagin interfaceGJPlotInterface
-
isSelected
public final boolean isSelected()
Description copied from interface:GJPlotInterfaceReturns true if this plot is presently selected- Specified by:
isSelectedin interfaceGJPlotInterface- Returns:
- the selection state
-
plus
public final GJPlotInterface plus(GJPlotInterface p2)
Description copied from interface:GJPlotInterfaceSimply callsadd. Provided for use in systems that allow addition via a "+" operator.- Specified by:
plusin interfaceGJPlotInterface- Returns:
- this instance after addition of plot
-
add
public final GJPlotInterface add(GJPlotInterface plot)
Description copied from interface:GJPlotInterfaceAdds a plot as a child plot of this plot.- Specified by:
addin interfaceGJPlotInterface- Returns:
- this GJPlotInterface instance after the addition.
-
getParentPlot
public final GJPlotInterface getParentPlot()
Description copied from interface:GJPlotInterfaceReturns a reference to parent plot. If this plot is a "TopPlot", it has no plot ancestor and returns null.- Specified by:
getParentPlotin interfaceGJPlotInterface- Returns:
- the parent GJPlotInterface if one exists
-
setParentPlot
public final void setParentPlot(GJPlotInterface p)
Description copied from interface:GJPlotInterfaceSets the parent plot for this plot. This will be called from other methods when required and should not normally need to be called from user-code.- Specified by:
setParentPlotin interfaceGJPlotInterface- Parameters:
p- the parent plot
-
intersects
public final boolean intersects(java.awt.geom.Point2D p)
Description copied from interface:GJPlotInterfaceDetermines whether the specified point intersects the data in the ScreenDataArray. Note: this method calls the Path2D intersect method on the elements of the ScreenDataArray.- Specified by:
intersectsin interfaceGJPlotInterface- Parameters:
p- the Point- Returns:
- true if the Point intesects the ScreenDataArray.
-
intersects
public final boolean intersects(double x, double y)Description copied from interface:GJPlotInterfaceDetermines whether the specified point intersects the data in the ScreenDataArray. Note: this method calls the Path2D intersect method on the elements of the ScreenDataArray.- Specified by:
intersectsin interfaceGJPlotInterface- Parameters:
x- the x locationy- the y location- Returns:
- true if the Point intesects the ScreenDataArray.
-
findPlotBelow
public final java.util.ArrayList<GJPlotInterface> findPlotBelow(java.awt.geom.Point2D p)
Description copied from interface:GJPlotInterfaceReturns an ArrayList of plots located beneathjava.awt.Pointin the coordinate space of the parent plot.- Specified by:
findPlotBelowin interfaceGJPlotInterface- Returns:
- an ArrayList
-
findPlotBelow
public final java.util.ArrayList<GJPlotInterface> findPlotBelow(double x, double y)
Description copied from interface:GJPlotInterfaceReturns an ArrayList of plots located beneath [x,y] in the coordinate space of the parent plot.- Specified by:
findPlotBelowin interfaceGJPlotInterface- Returns:
- an ArrayList
-
getPlots
@Deprecated public final java.util.ArrayList<GJPlotInterface> getPlots()
Deprecated.Description copied from interface:GJPlotInterfaceReturns an ArrayList of plots that are child plots of this plot.- Specified by:
getPlotsin interfaceGJPlotInterface- Returns:
- an ArrayList
-
getNode
public final java.util.ArrayList<GJPlotInterface> getNode()
Description copied from interface:GJPlotInterfaceReturns an ArrayList of plots that are descendant plots of this plot.- Specified by:
getNodein interfaceGJPlotInterface- Returns:
- a ArrayList
-
getDataRange
public java.awt.geom.Rectangle2D getDataRange()
getDataRange returns the range on the X and Y axes that can potentially be filled by the data points given the current contents of the XData and YData properties. Note that this is not necessarily the same as the range of the data contained in the XData and YData properties (although it often will be for a simple Cartesian plot). getVisualRange can be used instead to assess the required axes limits needed to render the data given e.g. the set marker size etc. However, getVisualRange can only be used to update the display: it requires that data have already been rendered to screen at least once.- Specified by:
getDataRangein interfaceGJDataModelInterface<java.awt.geom.Rectangle2D,GJGraphInterface>- Returns:
- a Rectangle2D instance
-
getTopPlot
public GJPlotInterface getTopPlot()
Description copied from interface:GJPlotInterfaceReturns the ancestor plot that is the TopPlot in this plot's hierarchy.- Specified by:
getTopPlotin interfaceGJPlotInterface- Returns:
- the GJPlotInterface
-
getVisualRange
public final java.awt.geom.Rectangle2D getVisualRange()
- Specified by:
getVisualRangein interfaceGJDataModelInterface<java.awt.geom.Rectangle2D,GJGraphInterface>
-
paintPlotEntry
public final void paintPlotEntry(java.awt.Graphics2D g2)
Entry point for plotting called from the graph methods.- Specified by:
paintPlotEntryin interfaceGJPlotInterface- Parameters:
g2-
-
paintPlot
public void paintPlot(java.awt.Graphics2D g2)
Note that this method is overloaded by all concrete sub-classes which should call this super-class method.- Specified by:
paintPlotin interfaceGJPlotInterface- Parameters:
g2-
-
plotRedraw
public void plotRedraw()
Description copied from interface:GJFastPlotInterfaceplotRedraw repaints this plot without re-painting the container hierarchy and, therefore, without erasing the previous copy of the plot on screen.- Specified by:
plotRedrawin interfaceGJFastPlotInterface
-
plotRedraw
public void plotRedraw(java.awt.Graphics2D g)
Description copied from interface:GJFastPlotInterfacePerforms a plot redraw using the supplied Graphics instance- Specified by:
plotRedrawin interfaceGJFastPlotInterface
-
plotUpdate
public boolean plotUpdate()
Description copied from interface:GJFastPlotInterfaceIn this abstract class implementations, plotUpdate will generally just call plotRedraw. In concrete plot classes, plotUpdate may be overridden to paint only points that have been added to end of a plot since the last plot.- Specified by:
plotUpdatein interfaceGJFastPlotInterface- Returns:
- true if this method has been overloaded, false if not so that it just calls plotRedraw.
-
plotUpdate
public boolean plotUpdate(java.awt.Graphics2D g)
Description copied from interface:GJFastPlotInterfacePerforms a plot append using the supplied Graphics instance- Specified by:
plotUpdatein interfaceGJFastPlotInterface
-
getFillable
public java.awt.Shape getFillable()
getFillable provides the Area instance to fill. This method can be overridden in custom-classes to return a different Area instance.- Specified by:
getFillablein interfaceGJFillableInterface<java.awt.Shape,java.awt.Paint>- Returns:
- the Area to fill when painting the plot.
-
setAntialiasing
public final void setAntialiasing(boolean flag)
- Specified by:
setAntialiasingin interfaceGJPlotInterface
-
saveAsXML
public void saveAsXML(java.lang.String fileName)
- Specified by:
saveAsXMLin interfaceGJPlotInterface
-
createFrame
public GCFrame createFrame()
- Specified by:
createFramein interfaceGJPlotInterface
-
isOnEDT
public boolean isOnEDT()
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent pce)
- Specified by:
propertyChangein interfacejava.beans.PropertyChangeListener
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toString
public java.lang.String toString(boolean flag)
-
setEffect
public void setEffect(org.jdesktop.swingx.painter.effects.AreaEffect effect)
- Specified by:
setEffectin interfaceGJEffectorInterface
-
getEffect
public org.jdesktop.swingx.painter.effects.AreaEffect getEffect()
- Specified by:
getEffectin interfaceGJEffectorInterface
-
getAreaFill
public GJFillableInterface<java.awt.Shape,java.awt.Paint> getAreaFill()
- Returns:
- the areaFill
-
setAreaFill
public void setAreaFill(GJFillableInterface<java.awt.Shape,java.awt.Paint> areaFill)
- Parameters:
areaFill- the areaFill to set
-
getAreaPaint
public java.awt.Paint getAreaPaint()
Description copied from interface:GJFillableInterfaceReturns the object used to paint the area e.g. an AWT paint instance.- Specified by:
getAreaPaintin interfaceGJFillableInterface<java.awt.Shape,java.awt.Paint>- Returns:
- U
-
setAreaPaint
public void setAreaPaint(java.awt.Paint p)
Description copied from interface:GJFillableInterfaceSets the object used to paint the area e.g. an AWT paint instance.- Specified by:
setAreaPaintin interfaceGJFillableInterface<java.awt.Shape,java.awt.Paint>
-
getFillComposite
public java.awt.AlphaComposite getFillComposite()
- Specified by:
getFillCompositein interfaceGJFillableInterface<java.awt.Shape,java.awt.Paint>- Returns:
- the composite
-
setFillComposite
public void setFillComposite(java.awt.AlphaComposite composite)
- Specified by:
setFillCompositein interfaceGJFillableInterface<java.awt.Shape,java.awt.Paint>- Parameters:
composite- the composite to set
-
getFillAlpha
public float getFillAlpha()
- Specified by:
getFillAlphain interfaceGJFillableInterface<java.awt.Shape,java.awt.Paint>
-
setFillAlpha
public void setFillAlpha(float alpha)
- Specified by:
setFillAlphain interfaceGJFillableInterface<java.awt.Shape,java.awt.Paint>
-
-
DMelt 3.0 © DataMelt by jWork.ORG