PlanarSurface, Surfacepublic class PlaneSurface extends java.lang.Object implements Surface, PlanarSurface
| Constructor | Description |
|---|---|
PlaneSurface(int gxlo,
int gxhi,
int gylo,
int gyhi,
double dxlo,
double dxhi,
double dylo,
double dyhi,
boolean xlog,
boolean ylog,
boolean xflip,
boolean yflip,
Tick[] xticks,
Tick[] yticks,
java.lang.String xlabel,
java.lang.String ylabel,
Captioner captioner,
java.awt.Color gridcolor,
java.awt.Color axlabelcolor) |
Constructor.
|
| Modifier and Type | Method | Description |
|---|---|---|
static PlaneSurface |
createSurface(java.awt.Rectangle plotBounds,
PlaneAspect aspect,
boolean xlog,
boolean ylog,
boolean xflip,
boolean yflip,
java.lang.String xlabel,
java.lang.String ylabel,
Captioner captioner,
double xyfactor,
boolean grid,
double xcrowd,
double ycrowd,
boolean minor,
java.awt.Color gridcolor,
java.awt.Color axlabelcolor) |
Utility method to create a PlaneSurface from available requirements.
|
boolean |
dataToGraphics(double[] dpos,
boolean visibleOnly,
java.awt.geom.Point2D.Double gp) |
Converts a data space position to a graphics position.
|
boolean |
dataToGraphicsOffset(double[] dpos0,
java.awt.geom.Point2D.Double gpos0,
double[] dpos1,
boolean visibleOnly,
java.awt.geom.Point2D.Double gpos1) |
Converts an offset data space position to a graphics position.
|
boolean |
equals(java.lang.Object o) |
|
java.lang.String |
formatPosition(double[] dpos) |
Formats the given data space position as a coordinate string.
|
static java.lang.String |
formatPosition(Axis axis,
double dpos) |
Formats a coordinate value for presentation to the user.
|
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.
|
java.awt.Rectangle |
getPlotBounds() |
Returns the rectangle within which all of the plot data will appear.
|
java.awt.Insets |
getPlotInsets(boolean withScroll) |
Returns the insets that this surface would like to reserve outside
the plot bounds.
|
boolean[] |
getTimeFlags() |
Indicates which axes represent time values.
|
double[] |
graphicsToData(java.awt.geom.Point2D gp,
java.lang.Iterable<double[]> dposIt) |
Attempst to turn a graphics position into a data position.
|
int |
hashCode() |
|
void |
paintBackground(java.awt.Graphics g) |
Paints the plot surface background.
|
void |
paintForeground(java.awt.Graphics g) |
Paints the plot surface foreground.
|
public PlaneSurface(int gxlo,
int gxhi,
int gylo,
int gyhi,
double dxlo,
double dxhi,
double dylo,
double dyhi,
boolean xlog,
boolean ylog,
boolean xflip,
boolean yflip,
Tick[] xticks,
Tick[] yticks,
java.lang.String xlabel,
java.lang.String ylabel,
Captioner captioner,
java.awt.Color gridcolor,
java.awt.Color axlabelcolor)
gxlo - graphics X coordinate lower boundgxhi - graphics X coordinate upper boundgylo - graphics Y coordinate lower boundgyhi - graphics Y coordinate upper bounddxlo - data X coordinate lower bounddxhi - data X coordinate upper bounddylo - data Y coordinate lower bounddyhi - data Y coordinate upper boundxlog - whether to use logarithmic scaling on X axisylog - whether to use logarithmic scaling on Y axisxflip - whether to invert direction of X axisyflip - whether to invert direction of Y axisxticks - array of tickmark objects for X axisyticks - array of tickmark objects for Y axisxlabel - text for labelling X axisylabel - text for labelling Y axiscaptioner - text renderer for axis labels etc, or null if absentgridcolor - colour of grid lines, or null if not plottedaxlabelcolor - colour of axis labelspublic java.awt.Rectangle getPlotBounds()
SurfacegetPlotBounds in interface Surfacepublic java.awt.Insets getPlotInsets(boolean withScroll)
SurfaceSurface.getPlotBounds()
to be used for axis labels etc.
If the withScroll parameter is set, then an attempt
will be made to return insets 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.
getPlotInsets in interface SurfacewithScroll - true to reserve space for nicer scrollingpublic int getDataDimCount()
getDataDimCount in interface Surfacepublic boolean dataToGraphics(double[] dpos,
boolean visibleOnly,
java.awt.geom.Point2D.Double gp)
SurfacevisibleOnly 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 Surfacedpos - 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,
java.awt.geom.Point2D.Double gpos0,
double[] dpos1,
boolean visibleOnly,
java.awt.geom.Point2D.Double gpos1)
SurfaceThis (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 Surfacedpos0 - 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(java.awt.geom.Point2D gp,
java.lang.Iterable<double[]> dposIt)
SurfacedposIt 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 Surfacegp - graphics pointdposIt - iterable over dataDimCount-element arrays
representing all the data space positions plotted,
or nullgPos, or null if it cannot be determinedpublic java.lang.String formatPosition(double[] dpos)
SurfaceformatPosition in interface Surfacedpos - dataDimCount-element array giving data space positionpublic Captioner getCaptioner()
SurfacegetCaptioner in interface Surfacepublic void paintBackground(java.awt.Graphics g)
SurfacepaintBackground in interface Surfaceg - graphics contextpublic void paintForeground(java.awt.Graphics g)
SurfacepaintForeground in interface Surfaceg - graphics contextpublic double[][] getDataLimits()
PlanarSurfacegetDataLimits in interface PlanarSurface{{xlo, xhi}, {ylo, yhi}}public boolean[] getLogFlags()
PlanarSurfacegetLogFlags in interface PlanarSurfacepublic boolean[] getFlipFlags()
PlanarSurfacegetFlipFlags in interface PlanarSurfacepublic boolean[] getTimeFlags()
PlanarSurfacegetTimeFlags in interface PlanarSurfacepublic Axis[] getAxes()
PlanarSurfacegetAxes in interface PlanarSurfacepublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic static PlaneSurface createSurface(java.awt.Rectangle plotBounds, PlaneAspect aspect, boolean xlog, boolean ylog, boolean xflip, boolean yflip, java.lang.String xlabel, java.lang.String ylabel, Captioner captioner, double xyfactor, boolean grid, double xcrowd, double ycrowd, boolean minor, java.awt.Color gridcolor, java.awt.Color axlabelcolor)
plotBounds - rectangle which the plot data should occupyaspect - surface view configurationxlog - whether to use logarithmic scaling on X axisylog - whether to use logarithmic scaling on Y axisxflip - whether to invert direction of X axisyflip - whether to invert direction of Y axisxlabel - text for labelling X axisylabel - text for labelling Y axiscaptioner - text renderer for axis labels etcxyfactor - ratio (X axis unit length)/(Y axis unit length),
or NaN to use whatever bounds shape and
axis limits give yougrid - whether to draw grid linesxcrowd - crowding factor for tick marks on X axis;
1 is normalycrowd - crowding factor for tick marks on Y axis;
1 is normalminor - whether to paint minor tick marks on axesgridcolor - colour of grid lines, if plottedaxlabelcolor - colour of axis labelspublic static java.lang.String formatPosition(Axis axis, double dpos)
axis - axis on which value appearsdpos - data coordinate valueCopyright © 2018 Central Laboratory of the Research Councils. All Rights Reserved.