|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.ac.starlink.ttools.plot2.geom.CubeSurface
public class CubeSurface
Surface implementation for 3-d plotting.
Part of the surface definition involves a rotation matrix by which the data positions are rotated before being plotted to the screen. If the rotation matrix is a unit matrix, the data X coord is screen X increasing left to right (graphics positive), the data Z coord is screen Y increasing bottom to top (graphics negative), and the data Y coord is into the screen increasing front to back.
Constructor Summary | |
---|---|
CubeSurface(int gxlo,
int gxhi,
int gylo,
int gyhi,
double[] dlos,
double[] dhis,
boolean[] logFlags,
boolean[] flipFlags,
double[] rotmat,
double zoom,
double xoff,
double yoff,
Tick[][] ticks,
String[] labels,
Captioner captioner,
boolean frame,
boolean antialias)
Constructor. |
Method Summary | |
---|---|
static CubeSurface |
createSurface(Rectangle plotBounds,
CubeAspect aspect,
boolean[] logFlags,
boolean[] flipFlags,
String[] labels,
double[] crowdFactors,
Captioner captioner,
boolean frame,
boolean minor,
boolean antialias)
Utility method to create a CubeSurface from available requirements. |
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. |
boolean |
dataToGraphicZ(double[] dataPos,
boolean visibleOnly,
Point2D.Double gPos,
double[] zloc)
Returns graphics position plus Z coordinate for a data point. |
boolean |
equals(Object o)
|
String |
formatPosition(double[] dataPos)
Returns null. |
Captioner |
getCaptioner()
Returns a captioner suitable for drawing general purpose labels annotating the plot. |
int |
getDataDimCount()
Returns 3. |
Rectangle |
getPlotBounds()
Returns the rectangle within which all of the plot data will appear. |
Insets |
getPlotInsets(boolean withScroll)
Returns the insets that this surface would like to reserve outside the plot bounds. |
int[] |
getScreenDirections()
Identifies which data space axes are closest to the screen horizontal, vertical and normal directions in the current state of rotation. |
double[] |
graphicsToData(Point2D gpos0,
Iterable<double[]> dposIt)
Only works if a point iterator is supplied, because of degeneracy in mapping a cube to a plane. |
int |
hashCode()
|
boolean |
inRange(double[] dataPos)
Determines whether a given data position is within the data space cube represented by this surface. |
void |
paintBackground(Graphics g)
Paints the plot surface background. |
void |
paintForeground(Graphics g)
Paints the plot surface foreground. |
Point2D.Double |
projectNormalisedPos(double[] nPos)
Determines the graphics position to which a normalised space point will map. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CubeSurface(int gxlo, int gxhi, int gylo, int gyhi, double[] dlos, double[] dhis, boolean[] logFlags, boolean[] flipFlags, double[] rotmat, double zoom, double xoff, double yoff, Tick[][] ticks, String[] labels, Captioner captioner, boolean frame, boolean antialias)
gxlo
- graphics X coordinate lower boundgxhi
- graphics X coordinate upper boundgylo
- graphics Y coordinate lower boundgyhi
- graphics Y coordinate upper bounddlos
- 3-element array giving X,Y,Z data coordinate lower boundsdhis
- 3-element array giving X,Y,Z data coordinate upper boundslogFlags
- 3-element array flagging log scaling on X,Y,Z axisflipFlags
- 3-element array flagging axis inversion for X,Y,Zrotmat
- 9-element array giving graphics space rotation matrixzoom
- zoom factor, 1 means cube roughly fills plot boundsxoff
- graphics X offset in pixels, 0 means centred in plot boundsyoff
- graphics Y offset in pixels, 0 means centred in plot boundsticks
- 3-element array X,Y,Z tickmark arrayslabels
- 3-element array of X,Y,Z axis label stringscaptioner
- text rendererframe
- whether to draw wire frameantialias
- whether to antialias grid linesMethod Detail |
---|
public int getDataDimCount()
getDataDimCount
in interface Surface
public Rectangle getPlotBounds()
Surface
getPlotBounds
in interface Surface
public Insets getPlotInsets(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 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.
getPlotInsets
in interface Surface
withScroll
- true to reserve space for nicer scrolling
public Captioner getCaptioner()
Surface
getCaptioner
in interface Surface
public boolean dataToGraphics(double[] dataPos, boolean visibleOnly, Point2D.Double gPos)
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
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 success
public boolean dataToGraphicsOffset(double[] dataPos0, Point2D.Double gPos0, double[] dataPos1, 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
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 success
public boolean dataToGraphicZ(double[] dataPos, boolean visibleOnly, Point2D.Double gPos, double[] zloc)
dataPos
- 3-element X,Y,Z position in data coordinatesvisibleOnly
- true if only data points that will be visible
on this surface are of interestgPos
- the graphics position will be written into this point
on successzloc
- the Z coordinate of the result will be written into the
first element of this array on success
dataToGraphics(double[], boolean, java.awt.geom.Point2D.Double)
public boolean inRange(double[] dataPos)
dataPos
- 3-element array of non-normalised data coordinates
public Point2D.Double projectNormalisedPos(double[] nPos)
nPos
- 3-element coordinate array in normalised space
public String formatPosition(double[] dataPos)
formatPosition
in interface Surface
dataPos
- dataDimCount-element array giving data space position
public double[] graphicsToData(Point2D gpos0, Iterable<double[]> dposIt)
graphicsToData
in interface Surface
gpos0
- graphics pointdposIt
- iterable over dataDimCount-element arrays
representing all the data space positions plotted,
or null
gPos
, or null if it cannot be determinedpublic void paintBackground(Graphics g)
Surface
paintBackground
in interface Surface
g
- graphics contextpublic void paintForeground(Graphics g)
Surface
paintForeground
in interface Surface
g
- graphics contextpublic int[] getScreenDirections()
public boolean equals(Object o)
equals
in class Object
public int hashCode()
hashCode
in class Object
public static CubeSurface createSurface(Rectangle plotBounds, CubeAspect aspect, boolean[] logFlags, boolean[] flipFlags, String[] labels, double[] crowdFactors, Captioner captioner, boolean frame, boolean minor, boolean antialias)
plotBounds
- rectangle within which the plot should be drawnaspect
- surface view configurationlogFlags
- 3-element array flagging log scaling on X,Y,Z axisflipFlags
- 3-element array flagging axis inversion for X,Y,Zlabels
- 3-element array of X,Y,Z axis label stringscrowdFactors
- 3-element array giving tick mark crowding factors
for X,Y,Z axes; 1 is normalcaptioner
- text rendererframe
- whether to draw wire frameminor
- whether to draw minor tickmarksantialias
- whether to antialias grid lines
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |