Package uk.ac.starlink.ttools.plot
Class GraphSurface
java.lang.Object
uk.ac.starlink.ttools.plot.GraphSurface
- All Implemented Interfaces:
PlotSurface
Plotting surface for drawing graphs on.
- Since:
- 3 Mar 2006
- Author:
- Mark Taylor
-
Field Summary
Fields inherited from interface uk.ac.starlink.ttools.plot.PlotSurface
MAX_COORD -
Constructor Summary
ConstructorsConstructorDescriptionGraphSurface(JComponent component, boolean xLog, boolean yLog, boolean xFlip, boolean yFlip) Constructor. -
Method Summary
Modifier and TypeMethodDescriptiondataToGraphics(double x, double y, boolean insideOnly) Converts a point in data space to graphics space.getClip()Returns the clip region in which points may be plotted.Returns the graphical component on which the plotting surface is displayed.double[]graphicsToData(int px, int py, boolean insideOnly) Converts a point in graphics space to data space.voidPaints the plotting surface.voidSets the rectangle within which data points may be plotted.voidsetDataRange(double xlo, double ylo, double xhi, double yhi) Requests a range of data space values to be visible on this plotting surface.voidSignals to the plot the characteristics of the plot which will be performed.toString()
-
Constructor Details
-
GraphSurface
Constructor.- Parameters:
component- the component on which this surface will drawxLog- true iff X axis is logarithmically scaledyLog- true iff Y axis is logarithmically scaledxFlip- true iff X axis is invertedyFlip- true iff Y axis is inverted
-
-
Method Details
-
getClip
Description copied from interface:PlotSurfaceReturns the clip region in which points may be plotted. The returned shape should be the sort which can be passed toGraphics.setClip(java.awt.Shape)- i.e. probably aRectangle.- Specified by:
getClipin interfacePlotSurface- Returns:
- clip region representing data zone
-
getComponent
Description copied from interface:PlotSurfaceReturns the graphical component on which the plotting surface is displayed. This will contain things like axes, grids, labels etc. This component will normally overrideJComponent.paintComponent(java.awt.Graphics)to give a plotting background in accordance with the most recently setPlotState.- Specified by:
getComponentin interfacePlotSurface- Returns:
- plot surface display component
-
setDataRange
public void setDataRange(double xlo, double ylo, double xhi, double yhi) Description copied from interface:PlotSurfaceRequests a range of data space values to be visible on this plotting surface.- Specified by:
setDataRangein interfacePlotSurface- Parameters:
xlo- (approximate) lower bound of X coordinateylo- (approximate) lower bound of Y coordinatexhi- (approximate) upper bound of X coordinateyhi- (approximate) upper bound of Y coordinate
-
setBounds
Sets the rectangle within which data points may be plotted. Additional annotations (such as axis labels) may be drawn outside this region.- Parameters:
bounds- the region of the component which represents the target for data points; annotations may be drawn outside this region
-
dataToGraphics
Description copied from interface:PlotSurfaceConverts a point in data space to graphics space. If theinsideOnlyflag is true, thennullwill be returned in place of any result which would give a point lying outside the visible plotting area.The coordinates of the returned point must have absolute values no greater than
PlotSurface.MAX_COORD.- Specified by:
dataToGraphicsin interfacePlotSurface- Parameters:
x- data space X coordinatey- data space Y coordinateinsideOnly- true to restrict non-null results to those within the plotting surface- Returns:
- point in graphics space corresponding to (x,y),
or
null
-
graphicsToData
public double[] graphicsToData(int px, int py, boolean insideOnly) Description copied from interface:PlotSurfaceConverts a point in graphics space to data space. If theinsideOnlyflag is true, thennullwill be returned in place of any result which would give a point lying outside the visible plotting area.- Specified by:
graphicsToDatain interfacePlotSurface- Parameters:
px- graphics space X coordinatepy- graphics space Y coordinateinsideOnly- true to restrict non-null results to those within the plotting surface- Returns:
- a 2-element array giving x and y data space coordinates,
or
null
-
setState
Description copied from interface:PlotSurfaceSignals to the plot the characteristics of the plot which will be performed. Setting this has no immediate effect, but when the component supplied byPlotSurface.getComponent()next paints itself it should do so following the specifications made here.- Specified by:
setStatein interfacePlotSurface- Parameters:
state- plot characteristics
-
paintSurface
Description copied from interface:PlotSurfacePaints the plotting surface. This should do roughly the same asgetComponent.paintComponent, except that it's public.Requiring this here isn't very tidy, but following quite a bit of experimentation I can't work out any other way to do scatter plot image caching while still drawing to a potentially hardware-accelerated graphics context (see
ScatterPlotimplementation).- Specified by:
paintSurfacein interfacePlotSurface- Parameters:
g- graphics context
-
toString
-