public class GraphSurface extends Object implements PlotSurface
MAX_COORD
Constructor and Description |
---|
GraphSurface(JComponent component,
boolean xLog,
boolean yLog,
boolean xFlip,
boolean yFlip)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
Point |
dataToGraphics(double x,
double y,
boolean insideOnly)
Converts a point in data space to graphics space.
|
Shape |
getClip()
Returns the clip region in which points may be plotted.
|
JComponent |
getComponent()
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.
|
void |
paintSurface(Graphics g)
Paints the plotting surface.
|
void |
setBounds(Rectangle bounds)
Sets the rectangle within which data points may be plotted.
|
void |
setDataRange(double xlo,
double ylo,
double xhi,
double yhi)
Requests a range of data space values to be visible on
this plotting surface.
|
void |
setState(PlotState state)
Signals to the plot the characteristics of the plot which will
be performed.
|
String |
toString() |
public GraphSurface(JComponent component, boolean xLog, boolean yLog, boolean xFlip, boolean yFlip)
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 invertedpublic Shape getClip()
PlotSurface
Graphics.setClip(java.awt.Shape)
- i.e. probably
a Rectangle.getClip
in interface PlotSurface
public JComponent getComponent()
PlotSurface
JComponent.paintComponent(java.awt.Graphics)
to give a plotting background in accordance with the most recently
set PlotState.getComponent
in interface PlotSurface
public void setDataRange(double xlo, double ylo, double xhi, double yhi)
PlotSurface
setDataRange
in interface PlotSurface
xlo
- (approximate) lower bound of X coordinateylo
- (approximate) lower bound of Y coordinatexhi
- (approximate) upper bound of X coordinateyhi
- (approximate) upper bound of Y coordinatepublic void setBounds(Rectangle bounds)
bounds
- the region of the component which represents the
target for data points; annotations may be drawn outside
this regionpublic Point dataToGraphics(double x, double y, boolean insideOnly)
PlotSurface
The coordinates of the returned point must have absolute values
no greater than PlotSurface.MAX_COORD
.
dataToGraphics
in interface PlotSurface
x
- data space X coordinatey
- data space Y coordinateinsideOnly
- true to restrict non-null results to those
within the plotting surfacepublic double[] graphicsToData(int px, int py, boolean insideOnly)
PlotSurface
graphicsToData
in interface PlotSurface
px
- graphics space X coordinatepy
- graphics space Y coordinateinsideOnly
- true to restrict non-null results to those
within the plotting surfacepublic void setState(PlotState state)
PlotSurface
PlotSurface.getComponent()
next paints itself it should do so following the specifications
made here.setState
in interface PlotSurface
state
- plot characteristicspublic void paintSurface(Graphics g)
PlotSurface
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 ScatterPlot
implementation).
paintSurface
in interface PlotSurface
g
- graphics contextCopyright © 2023 Central Laboratory of the Research Councils. All Rights Reserved.