public class SkySurface extends Object implements Surface
Constructor and Description |
---|
SkySurface(Rectangle plotBounds,
Projection projection,
double[] rotmat,
double zoom,
double xoff,
double yoff,
SkySys viewSystem,
SkyAxisLabeller axLabeller,
Color gridColor,
Color axlabelColor,
Color scalebarColor,
boolean sexagesimal,
double crowd,
Captioner captioner,
boolean antialias)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
GridLiner |
createGridder(Rotation rotation,
boolean sexagesimal,
double loncrowd,
double latcrowd)
Attempts to construct a GridLiner object to draw grid lines on
this plot.
|
LabelledLine |
createLine(Point2D gp1,
Point2D gp2)
Returns a labelled line corresponding to the (shorter) great circle
arc between two graphics points.
|
boolean |
dataToGraphics(double[] dpos,
boolean visibleOnly,
Point2D.Double gpos)
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) |
SkyAspect |
flatPan(Point2D pos0,
Point2D pos1)
Pan gesture which just translates the entire graphics plane.
|
SkyAspect |
flatZoom(Point2D pos,
double factor)
Zoom gesture which just magnifies the entire graphics plane.
|
String |
formatPosition(double[] dpos)
Formats the given data space position as a coordinate string.
|
static String |
formatPositionDec(double lonRad,
double latRad,
double pixRad)
Formats a lon/lat position as decimal given the approximate size
of a screen pixel.
|
static String |
formatPositionSex(double lonRad,
double latRad,
double pixRad)
Formats a lon/lat position as sexagesimal given the approximate size
of a screen pixel.
|
Captioner |
getCaptioner()
Returns a captioner suitable for drawing general purpose labels
annotating the plot.
|
int |
getDataDimCount()
Returns 3.
|
double |
getOffsetX()
Returns the dimensionless X offset of the plot centre from the
plot bounds centre.
|
double |
getOffsetY()
Returns the dimensionless Y offset of the plot centre from the
plot bounds centre.
|
Rectangle |
getPlotBounds()
Returns the rectangle within which all of the plot data will appear.
|
Projection |
getProjection()
Returns the projection used by this sky surface.
|
double[] |
getRotation()
Returns the rotation matrix corresponding to this view of the sky.
|
Point |
getSkyCenter()
Returns the screen position corresponding to the center of the
projection used by this surface.
|
Shape |
getSkyShape()
Returns a shape that gives the boundary of the sky projection
in graphics coordinates.
|
Surround |
getSurround(boolean withScroll)
Returns the surround that this surface would like to reserve outside
the plot bounds.
|
SkySys |
getViewSystem()
Returns the sky system into which coordinates are projected.
|
double |
getZoom()
Returns the zoom factor; 1 means the sky is approximately the
same size as the plot bounds.
|
double[] |
graphicsToData(Point2D gpos)
Attempts to turn a graphics position into a sky position.
|
double[] |
graphicsToData(Point2D gpos,
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.
|
double |
pixelAreaSteradians()
Returns the approximate solid angle covered by a screen pixel
in steradians.
|
double |
pixelAreaSteradians(Point2D gpos)
Returns the solid angle covered by a given graphics pixel
in steradians.
|
SkyAspect |
projPan(Point2D pos0,
Point2D pos1)
Pan gesture which attempts to rotate the sky while leaving the
size and location of the graphics plane unchanged.
|
SkyAspect |
projZoom(Point2D pos,
double factor)
Zoom gesture which attempts to zoom the sky, with the cursor staying
at the same sky position, while leaving the size and location of
the graphics plane unchanged.
|
SkyAspect |
reframe(Point2D center,
double factor)
Returns a plot aspect giving the data region defined by a
graphics position and zoom factor adjustment.
|
double |
screenDistanceRadians(Point2D gp1,
Point2D gp2)
Returns the distance along a great circle in radians between two
graphics positions.
|
public SkySurface(Rectangle plotBounds, Projection projection, double[] rotmat, double zoom, double xoff, double yoff, SkySys viewSystem, SkyAxisLabeller axLabeller, Color gridColor, Color axlabelColor, Color scalebarColor, boolean sexagesimal, double crowd, Captioner captioner, boolean antialias)
plotBounds
- graphics region within which the plot must fallprojection
- sky projectionrotmat
- 9-element rotation matrixzoom
- zoom factor; 1 means the sky is approximately
the same size as plot boundsxoff
- x offset of plot centre from plot bounds centre
in dimensionless units; 0 is centredyoff
- y offset of plot centre from plot bounds centre
in dimensionless units; 0 is centredviewSystem
- sky system into which coordinates are projectedaxLabeller
- sky axis labelling objectgridColor
- colour for grid drawing, or null if no gridaxlabelColor
- colour for axis labels, or null if no labelsscalebarColor
- colour for scale bar, or null if not drawnsexagesimal
- whether to use sexagesimal coordinatescrowd
- tick mark crowding factor, 1 is normalcaptioner
- text rendering objectantialias
- whether to antialias grid linespublic int getDataDimCount()
getDataDimCount
in interface Surface
public 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 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 Projection getProjection()
public double[] getRotation()
public double getZoom()
public double getOffsetX()
public double getOffsetY()
public SkySys getViewSystem()
public GridLiner createGridder(Rotation rotation, boolean sexagesimal, double loncrowd, double latcrowd)
The work is done by classes from the SkyView package.
rotation
- additional rotation to apply to sky system
before grid lines are plotted;
may be null for no additional rotationsexagesimal
- true for sexagesimal labels, false for decimalloncrowd
- longitude tick mark crowding factor, 1 is normallatcrowd
- latitude tick mark crowding factor, 1 is normalpublic boolean dataToGraphics(double[] dpos, 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
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 surfacegpos
- 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 gpos, 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
gpos
- graphics pointdposSupplier
- iterable over dataDimCount-element arrays
representing all the data space positions plotted,
or nullgPos
, or null if it cannot be determinedpublic double[] graphicsToData(Point2D gpos)
graphicsToData(gpos,null)
,
since the iterable argument is ignored for the SkySurface.gpos
- graphics positionpublic 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 double pixelAreaSteradians()
public double pixelAreaSteradians(Point2D gpos)
gpos
- position of graphics pixel centerpublic double screenDistanceRadians(Point2D gp1, Point2D gp2)
gp1
- first positiongp2
- second positionpublic LabelledLine createLine(Point2D gp1, Point2D gp2)
gp1
- start point in graphics spacegp2
- end point in graphics spacepublic static String formatPositionSex(double lonRad, double latRad, double pixRad)
lonRad
- longitude in radianslatRad
- latitude in radianspixRad
- approximate size of a screen pixel in radianspublic static String formatPositionDec(double lonRad, double latRad, double pixRad)
lonRad
- longitude in radianslatRad
- latitude in radianspixRad
- approximate size of a screen pixel in radianspublic SkyAspect flatPan(Point2D pos0, Point2D pos1)
pos0
- source graphics positionpos1
- destination graphics positionpublic SkyAspect flatZoom(Point2D pos, double factor)
pos
- reference graphics positionfactor
- zoom factorpublic SkyAspect projPan(Point2D pos0, Point2D pos1)
pos0
- source graphics positionpos1
- destination graphics positionpublic SkyAspect projZoom(Point2D pos, double factor)
pos
- reference graphics positionfactor
- zoom factorpublic SkyAspect reframe(Point2D center, double factor)
center
- position in current graphics coordinates of the
sky position requested as the new centerfactor
- zoom factor (from current)public Point getSkyCenter()
public Shape getSkyShape()
Copyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.