public interface Surface
SurfaceFactory
Modifier and Type | Method and Description |
---|---|
boolean |
dataToGraphics(double[] dataPos,
boolean visibleOnly,
Point2D.Double gPos)
Converts a data space position to a graphics position.
|
boolean |
dataToGraphicsOffset(double[] dataPos0,
Point2D.Double gpos0,
double[] dataPos1,
boolean visibleOnly,
Point2D.Double gPos1)
Converts an offset data space position to a graphics position.
|
String |
formatPosition(double[] dataPos)
Formats the given data space position as a coordinate string.
|
Captioner |
getCaptioner()
Returns a captioner suitable for drawing general purpose labels
annotating the plot.
|
int |
getDataDimCount()
Returns the dimensionality of the data space used by this plot surface.
|
Rectangle |
getPlotBounds()
Returns the rectangle within which all of the plot data will appear.
|
Surround |
getSurround(boolean withScroll)
Returns the surround that this surface would like to reserve outside
the plot bounds.
|
double[] |
graphicsToData(Point2D gPos,
java.util.function.Supplier<CoordSequence> dposSupplier)
Attempts to turn a graphics position into a data position.
|
boolean |
isContinuousLine(double[] dataPos0,
double[] dataPos1)
Indicates whether a line in graphics space between
two given data space positions is continuous.
|
void |
paintBackground(Graphics g)
Paints the plot surface background.
|
void |
paintForeground(Graphics g)
Paints the plot surface foreground.
|
Rectangle getPlotBounds()
Surround getSurround(boolean withScroll)
getPlotBounds()
to be used for axis labels etc.
If the withScroll
parameter is set, then an attempt
will be made to return a surround that will not alter if the current
plot is scrolled around a moderate amount.
For a one-time plot that's not important, but for an interactive
plot it prevents the actual plot position jumping around to
accommodate more or less space on the axes according to exactly
where ticks happen to fall on the axes.
This method is supposed to return only the space that may actually be touched by the plot. The calling code may wish to apply additional padding on top of this for cosmetic reasons.
withScroll
- true to reserve space for nicer scrollingvoid paintBackground(Graphics g)
g
- graphics contextvoid paintForeground(Graphics g)
g
- graphics contextint getDataDimCount()
boolean dataToGraphics(double[] dataPos, boolean visibleOnly, Point2D.Double gPos)
visibleOnly
is true, then if the return value
is true, the exit value of gPos
is guaranteed
to be within the plot bounds of this surface.
If visibleOnly
is false, there are no guarantees
about the exit value of gPos
, and its coordinates
could be infinite or NaN. In this case you might want to perform
additional checking, for instance with the utility methods
PlotUtil.isPointFinite
or
isPointReal
.
dataPos
- dataDimCount-element array containing data space
coordinatesvisibleOnly
- if true, then the conversion will only succeed
when the result falls within the plot bounds
of this surfacegPos
- point object into which the graphics position will
be written on successboolean dataToGraphicsOffset(double[] dataPos0, Point2D.Double gpos0, double[] dataPos1, boolean visibleOnly, Point2D.Double gPos1)
This (somewhat hacky) method is required for surfaces in which a
data position may map to more than one position in graphics space,
for instance sky surfaces with discontinuous longitude.
The result does not need to be the same as the result of
calling dataToGraphics(double[], boolean, java.awt.geom.Point2D.Double)
, and is not required to be a legal
graphics position, but it must make visual sense, for instance
when plotting error bars.
The semantics of a "nearby point" is not very well defined.
There are probably situations in which calling this will not
give the result that's wanted, but they will probably be rare.
dataPos0
- context position in data spacegpos0
- context position in graphics space
(result of calling dataToGraphics on dpos0)dataPos1
- query position in data spacevisibleOnly
- if true, the call only succeeds if the result is
within the plot bounds of this surfacegPos1
- point object to which the graphics position of
dpos1 will be written on successdouble[] graphicsToData(Point2D gPos, java.util.function.Supplier<CoordSequence> dposSupplier)
dposIt
argument can optionally
be supplied to cope with such instances. If a data pos cannot be
determined, null is returned. If dposIt
is absent,
the method will run quickly. If it's present, it may or may
not run slowly.gPos
- graphics pointdposSupplier
- iterable over dataDimCount-element arrays
representing all the data space positions plotted,
or nullgPos
, or null if it cannot be determinedboolean isContinuousLine(double[] dataPos0, double[] dataPos1)
This is not very well-defined, but if drawing a line in graphics coordinates between the graphics coordinates corresponding to the two data coordinates is likely to do something badly wrong, this method should return false. It is intended to deal with the case where a short offset in data coordinates would lead to a line going the wrong way round the sky when it crosses the longitude=+/-PI boundary in an Aitoff projection.
dataPos0
- first dataDimCount-element array containing
data space coordinatesdataPos1
- second dataDimCount-element array containing
data space coordinatesString formatPosition(double[] dataPos)
dataPos
- dataDimCount-element array giving data space positionCaptioner getCaptioner()
Copyright © 2025 Central Laboratory of the Research Councils. All Rights Reserved.