public class TimeSurface extends Object implements Surface, PlanarSurface
Constructor and Description |
---|
TimeSurface(int gxlo,
int gxhi,
int gylo,
int gyhi,
double dtlo,
double dthi,
double dylo,
double dyhi,
boolean ylog,
boolean yflip,
Tick[] tticks,
Tick[] yticks,
String tlabel,
String ylabel,
Tick[] t2ticks,
Tick[] y2ticks,
String t2label,
String y2label,
Captioner captioner,
Color gridcolor,
TimeFormat tformat,
SideFlags annotateflags)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static TimeSurface |
createSurface(Rectangle plotBounds,
TimeAspect aspect,
boolean ylog,
boolean yflip,
String tlabel,
String ylabel,
java.util.function.DoubleUnaryOperator t2func,
java.util.function.DoubleUnaryOperator y2func,
String t2label,
String y2label,
Captioner captioner,
Color gridcolor,
TimeFormat tformat,
double tcrowd,
double ycrowd,
boolean minor,
boolean shadow,
SideFlags annotateflags)
Utility method to create a TimeSurface from available requirements.
|
boolean |
dataToGraphics(double[] dpos,
boolean visibleOnly,
Point2D.Double gp)
Converts a data space position to a graphics position.
|
boolean |
dataToGraphicsOffset(double[] dpos0,
Point2D.Double gpos0,
double[] dpos1,
boolean visibleOnly,
Point2D.Double gpos1)
Converts an offset data space position to a graphics position.
|
boolean |
equals(Object o) |
String |
formatPosition(double[] dpos)
Formats the given data space position as a coordinate string.
|
Axis[] |
getAxes()
Returns the axis objects used by this surface.
|
Captioner |
getCaptioner()
Returns a captioner suitable for drawing general purpose labels
annotating the plot.
|
int |
getDataDimCount()
Returns 2.
|
double[][] |
getDataLimits()
Returns the limits in data coordinates of the plot region.
|
boolean[] |
getFlipFlags()
Indicates which axes are reversed.
|
boolean[] |
getLogFlags()
Indicates the scaling along the two axes.
|
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.
|
boolean[] |
getTimeFlags()
Indicates which axes represent time values.
|
double[] |
graphicsToData(Point2D gp,
java.util.function.Supplier<CoordSequence> dposSupplier)
Attempts to turn a graphics position into a data position.
|
int |
hashCode() |
boolean |
isContinuousLine(double[] dpos0,
double[] dpos1)
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.
|
public TimeSurface(int gxlo, int gxhi, int gylo, int gyhi, double dtlo, double dthi, double dylo, double dyhi, boolean ylog, boolean yflip, Tick[] tticks, Tick[] yticks, String tlabel, String ylabel, Tick[] t2ticks, Tick[] y2ticks, String t2label, String y2label, Captioner captioner, Color gridcolor, TimeFormat tformat, SideFlags annotateflags)
gxlo
- graphics X coordinate lower boundgxhi
- graphics X coordinate upper boundgylo
- graphics Y coordinate lower boundgyhi
- graphics Y coordinate upper bounddtlo
- data time coordinate lower bound in unix secondsdthi
- data time coordinate upper bound in unix secondsdylo
- data Y coordinate lower bounddyhi
- data Y coordinate upper boundylog
- whether to use logarithmic scaling on Y axisyflip
- whether to invert direction of Y axistticks
- array of tickmark objects for time axisyticks
- array of tickmark objects for Y axistlabel
- text for labelling time axisylabel
- text for labelling Y axist2ticks
- array of tickmark objects for secondary time axisy2ticks
- array of tickmark objects for secondary Y axist2label
- text for labelling secondary time axisy2label
- text for labelling secondary Y axiscaptioner
- text renderer for axis labels etcgridcolor
- grid line colour, or null for nonetformat
- time labelling formatannotateflags
- which sides to annotatepublic Rectangle getPlotBounds()
Surface
getPlotBounds
in interface Surface
public Surround getSurround(boolean withScroll)
Surface
Surface.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.
getSurround
in interface Surface
withScroll
- true to reserve space for nicer scrollingpublic int getDataDimCount()
getDataDimCount
in interface Surface
public boolean dataToGraphics(double[] dpos, boolean visibleOnly, Point2D.Double gp)
Surface
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
.
dataToGraphics
in interface Surface
dpos
- 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 surfacegp
- point object into which the graphics position will
be written on successpublic boolean dataToGraphicsOffset(double[] dpos0, Point2D.Double gpos0, double[] dpos1, boolean visibleOnly, Point2D.Double gpos1)
Surface
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 Surface.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.
dataToGraphicsOffset
in interface Surface
dpos0
- context position in data spacegpos0
- context position in graphics space
(result of calling dataToGraphics on dpos0)dpos1
- 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 successpublic double[] graphicsToData(Point2D gp, java.util.function.Supplier<CoordSequence> dposSupplier)
Surface
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.graphicsToData
in interface Surface
gp
- graphics pointdposSupplier
- iterable over dataDimCount-element arrays
representing all the data space positions plotted,
or nullgPos
, or null if it cannot be determinedpublic boolean isContinuousLine(double[] dpos0, double[] dpos1)
Surface
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.
isContinuousLine
in interface Surface
dpos0
- first dataDimCount-element array containing
data space coordinatesdpos1
- second dataDimCount-element array containing
data space coordinatespublic String formatPosition(double[] dpos)
Surface
formatPosition
in interface Surface
dpos
- dataDimCount-element array giving data space positionpublic void paintBackground(Graphics g)
Surface
paintBackground
in interface Surface
g
- graphics contextpublic void paintForeground(Graphics g)
Surface
paintForeground
in interface Surface
g
- graphics contextpublic Captioner getCaptioner()
Surface
getCaptioner
in interface Surface
public boolean[] getLogFlags()
PlanarSurface
getLogFlags
in interface PlanarSurface
public boolean[] getFlipFlags()
PlanarSurface
getFlipFlags
in interface PlanarSurface
public boolean[] getTimeFlags()
PlanarSurface
getTimeFlags
in interface PlanarSurface
public double[][] getDataLimits()
PlanarSurface
getDataLimits
in interface PlanarSurface
{{xlo, xhi}, {ylo, yhi}}
public Axis[] getAxes()
PlanarSurface
getAxes
in interface PlanarSurface
public static TimeSurface createSurface(Rectangle plotBounds, TimeAspect aspect, boolean ylog, boolean yflip, String tlabel, String ylabel, java.util.function.DoubleUnaryOperator t2func, java.util.function.DoubleUnaryOperator y2func, String t2label, String y2label, Captioner captioner, Color gridcolor, TimeFormat tformat, double tcrowd, double ycrowd, boolean minor, boolean shadow, SideFlags annotateflags)
plotBounds
- rectangle which the plot data should occupyaspect
- surface view configurationylog
- whether to use logarithmic scaling on Y axisyflip
- whether to invert direction of Y axistlabel
- text for labelling time axisylabel
- text for labelling Y axist2func
- function mapping unix seconds to secondary time axis
data coord, null for no secondary time axisy2func
- function mapping primary to secondary Y axis data coord,
null for no secondary Y axist2label
- secondary time axis labely2label
- secondary Y axis labelcaptioner
- text renderer for axis labels etcgridcolor
- colour of grid lines, or null for nonetformat
- time labelling formattcrowd
- crowding factor for tick marks on time axis;
1 is normalycrowd
- crowding factor for tick marks on Y axis;
1 is normalminor
- whether to paint minor tick marks on axesshadow
- whether to paint shadow ticks on opposite axes
if no secondary axisannotateflags
- which axes to annotateCopyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.