|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgov.noaa.pmel.sgt.Graph
gov.noaa.pmel.sgt.CartesianGraph
public class CartesianGraph
The CartesianGraph
provides the transformation from user to
physical coordinates. A Cartesian graph has
horizontal and vertical transforms, from user to physical
coordinates, that are independent.
For example, yp = f(yu) and xp = g(xu), where
f() and g() are the vertical and horizontal transformations.
Multiple horizontal and vertical, X and Y, axes can be associated with
a CartesianGraph
and their mapping of user to physical
coordinates is based on the AxisTransform
s used.
The CartesianGraph
also provide the support for
the rendering of data. The specific renderer is chosen based on
the type of SGTData
and the data Attribute
used.
The following demonstrates how a CartesianGraph
may be
used.
// Create a CartesianGraph and transforms. CartesianGraph graph; LinearTransform xt, yt; Range2D xPhysRange, xUserRange; Range2D yPhysRange, yUserRange; Point2D.Double origin; graph = new CartesianGraph("Point Graph"); layer.setGraph(graph); xt = new LinearTransform(xPhysRange, xUserRange); yt = new LinearTransform(yPhysRange, yUserRange); graph.setXTransform(xt); graph.setYTransform(yt); origin = new Point2D.Double(xUserRange.start, yUserRange.start); // Create the bottom axis, set its range in user units // and its origin. Add the axis to the graph. PlainAxis xbot; xbot = new PlainAxis("Botton Axis"); xbot.setRangeU(xUserRange); xbot.setLocationU(origin); graph.addXAxis(xbot); // Create the left axis, set its range in user units // and its origin. Add the axis to the graph. PlainAxis yleft; yleft = new PlainAxis("Left Axis"); yleft.setRangeU(yUserRange); yleft.setLocationU(origin); graph.addYAxis(yleft); // Create a PointAttribute for the display of the // Collection of points. The points will be marked // with a red triangle and labelled at the NE corner // in blue. PointAttribute pattr; pattr = new PointAttribute(10, Color.red); // Associate the attribute and the point Collection // with the graph. graph.setData(col, pattr);
Field Summary | |
---|---|
protected boolean |
clipping_
|
protected SoTRange.Time |
tClipRange_
|
protected java.util.Vector |
xAxis_
|
protected Range2D |
xClipRange_
|
protected AxisTransform |
xTransform_
|
protected java.util.Vector |
yAxis_
|
protected Range2D |
yClipRange_
|
protected AxisTransform |
yTransform_
|
Fields inherited from class gov.noaa.pmel.sgt.Graph |
---|
layer_ |
Constructor Summary | |
---|---|
CartesianGraph()
Default constructor. |
|
CartesianGraph(java.lang.String id)
CartesianGraph constructor. |
|
CartesianGraph(java.lang.String id,
AxisTransform xt,
AxisTransform yt)
Create a new CartesianGraph . |
Method Summary | |
---|---|
void |
addXAxis(Axis axis)
Add a X axis ( Axis.HORIZONTAL ) to the graph. |
void |
addXAxis(java.lang.String id,
Axis axis)
Add a X axis ( Axis.HORIZONTAL ) to the graph. |
void |
addYAxis(Axis axis)
Add a Y axis ( Axis.VERTICAL ) to the graph. |
void |
addYAxis(java.lang.String id,
Axis axis)
Add a Y axis ( Axis.VERTICAL ) to the graph. |
Graph |
copy()
Create a copy of the CartesianGraph |
void |
draw(java.awt.Graphics g)
Draw the graph, axes, and render the data. |
SGTData |
getDataAt(java.awt.Point pt)
Find data at point |
int |
getNumberXAxis()
Get the number of X axes associated with the graph. |
int |
getNumberYAxis()
Get the number of Y axes associated with the graph. |
SoTPoint |
getPtoU(Point2D.Double loc)
Transform physical coordinate to a SoTPoint |
CartesianRenderer |
getRenderer()
Get the renderer instance being used by the graph. |
Axis |
getXAxis(java.lang.String id)
Get a reference to an X axis. |
long |
getXPtoLongTime(double p)
Transform physical X coordinate to time. |
SoTValue |
getXPtoSoT(double p)
Transform physical X coordinate to user coordinate using SoTValue |
GeoDate |
getXPtoTime(double p)
Transform physical X coordinate to time. |
double |
getXPtoU(double p)
Transform physical X coordinate to user coordinate. |
AxisTransform |
getXTransform()
Get the current X AxisTransform . |
int |
getXUtoD(double u)
Transform user X coordinate to device coordinate. |
int |
getXUtoD(GeoDate t)
Transform GeoDate to device coordinate. |
int |
getXUtoD(long t)
Transform long to device coordinate. |
int |
getXUtoD(SoTValue val)
Transform X SoTValue to device coordinate. |
double |
getXUtoD2(double u)
Transform user X coordinate to device coordinate. |
double |
getXUtoD2(GeoDate t)
Transform GeoDate to device coordinate. |
double |
getXUtoD2(long t)
Transform long to device coordinate. |
double |
getXUtoD2(SoTValue val)
Transform X SoTValue to device coordinate. |
double |
getXUtoP(double u)
Transform user X coordinate to physical coordinate. |
double |
getXUtoP(GeoDate t)
Transform GeoDate to physical coordinate. |
double |
getXUtoP(long t)
Transform long to physical coordinate. |
double |
getXUtoP(SoTValue val)
Transform X SoTValue to physical coordinate. |
Axis |
getYAxis(java.lang.String id)
Get a reference to an Y axis. |
long |
getYPtoLongTime(double p)
Transform physical Y coordinate to time. |
SoTValue |
getYPtoSoT(double p)
Transform physical Y coordinate to user coordinate using SoTValue |
GeoDate |
getYPtoTime(double p)
Transform physical Y coordinate to time. |
double |
getYPtoU(double p)
Transform physical Y coordinate to user coordinate. |
AxisTransform |
getYTransform()
Get the current Y AxisTransform . |
int |
getYUtoD(double u)
Transform user Y coordinate to device coordinate |
int |
getYUtoD(GeoDate t)
Transform time to device coordinate. |
int |
getYUtoD(long t)
Transform time to device coordinate. |
int |
getYUtoD(SoTValue val)
Transform Y SoTValue to device coordinate. |
double |
getYUtoD2(double u)
Transform user Y coordinate to device coordinate |
double |
getYUtoD2(GeoDate t)
Transform time to device coordinate. |
double |
getYUtoD2(long t)
Transform time to device coordinate. |
double |
getYUtoD2(SoTValue val)
Transform Y SoTValue to device coordinate. |
double |
getYUtoP(double u)
Transoform user Y coordinate to physical coordinate. |
double |
getYUtoP(GeoDate t)
Transform time to physical coordinate. |
double |
getYUtoP(long t)
Transform time to physical coordinate. |
double |
getYUtoP(SoTValue val)
Transform Y SoTValue to physical coordinate. |
boolean |
isClipping()
Test the clipping property. |
void |
propertyChange(java.beans.PropertyChangeEvent evt)
|
void |
removeAllXAxes()
Remove all X axes from the graph. |
void |
removeAllYAxes()
Remove all Y axes from the graph. |
void |
removeXAxis(Axis axis)
Remove an X axis from the graph. |
void |
removeXAxis(java.lang.String id)
Remove an X axis from the graph. |
void |
removeYAxis(Axis axis)
Remove an Y axis from the graph. |
void |
removeYAxis(java.lang.String id)
Remove an Y axis from the graph. |
void |
setClip(double xmin,
double xmax,
double ymin,
double ymax)
Set the clipping rectangle in user coordinates. |
void |
setClip(GeoDate tmin,
GeoDate tmax,
double min,
double max)
Set the clipping rectangle in user coordinates. |
void |
setClip(long tmin,
long tmax,
double min,
double max)
Set the clipping rectangle in user coordinates. |
void |
setClip(SoTRange xr,
SoTRange yr)
Set the clipping rectangle in user coordinates. |
void |
setClipping(boolean clip)
Set the clipping property. |
void |
setData(SGTData data,
Attribute attr)
Associates SGTData and Attribute with the
CartesianGraph . |
void |
setRenderer(CartesianRenderer rend)
Set the renderer used by the graph. |
void |
setXTransform(AxisTransform xfrm)
Set the X AxisTransform . |
void |
setYTransform(AxisTransform xfrm)
Set the Y AxisTransform . |
java.util.Enumeration |
xAxisElements()
Get an Enumeration object for the X axes. |
java.util.Enumeration |
yAxisElements()
Get an Enumeration object for the Y axes. |
Methods inherited from class gov.noaa.pmel.sgt.Graph |
---|
computeRange, computeRange, computeRange, getId, getLayer, getPane, modified, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.util.Vector xAxis_
protected java.util.Vector yAxis_
protected AxisTransform xTransform_
protected AxisTransform yTransform_
protected boolean clipping_
protected Range2D xClipRange_
protected Range2D yClipRange_
protected SoTRange.Time tClipRange_
Constructor Detail |
---|
public CartesianGraph()
public CartesianGraph(java.lang.String id)
CartesianGraph
constructor.
Creates default unity transforms.
id
- CartesianGraph identifierpublic CartesianGraph(java.lang.String id, AxisTransform xt, AxisTransform yt)
CartesianGraph
. Sets the identifier
and sets the x and y transforms.
id
- identifierxt
- x transformyt
- y transformMethod Detail |
---|
public Graph copy()
CartesianGraph
copy
in class Graph
public void setData(SGTData data, Attribute attr)
SGTData
and Attribute
with the
CartesianGraph
.
A renderer is constucted based on the two arguements.
SGTData |
Attribute |
CartesianRenderer |
---|---|---|
SGTPoint | PontAttribute | PointCartesianRenderer |
SGTLine | LineAttribute | LineCartesianRenderer |
SGTGrid | GridAttribute | GridCartesianRenderer |
SGTVector | VectorAttribute | VectorCartesianRenderer |
Collection | PointAttribute | PointCartesianRenderer |
Collection | LineAttribute | LineCartesianRenderer |
Collection | VectorAttribute | VectorCartesianRenderer |
Annotation | n/a | AnnotationCartesianRenderer |
data
- data to be renderedattr
- rendering style informationCartesianRenderer.getRenderer(gov.noaa.pmel.sgt.CartesianGraph, gov.noaa.pmel.sgt.dm.SGTData, gov.noaa.pmel.sgt.Attribute)
public CartesianRenderer getRenderer()
public void setRenderer(CartesianRenderer rend)
rend
- a renderer objectpublic void draw(java.awt.Graphics g)
Pane.draw()
public void setClip(double xmin, double xmax, double ymin, double ymax)
xmin
- minimum horizontal coordinatexmax
- maximum horizontal coordinateymin
- minimum vertical coordinateymax
- maximum vertical coordinatepublic void setClip(GeoDate tmin, GeoDate tmax, double min, double max)
tmin
- mimimum timetmax
- maximum timemin
- miminum user coordinatemax
- maximum user coordinatepublic void setClip(long tmin, long tmax, double min, double max)
tmin
- mimimum timetmax
- maximum timemin
- miminum user coordinatemax
- maximum user coordinatepublic void setClip(SoTRange xr, SoTRange yr)
public void setClipping(boolean clip)
clip
- clippingpublic boolean isClipping()
public void addXAxis(java.lang.String id, Axis axis)
Axis.HORIZONTAL
) to the graph.
id
- axis identifieraxis
- X axisAxis
,
PlainAxis
public void addXAxis(Axis axis)
Axis.HORIZONTAL
) to the graph.
Uses the existing axis identifier.
axis
- X axisAxis
,
PlainAxis
public Axis getXAxis(java.lang.String id) throws AxisNotFoundException
id
- axis identifier
AxisNotFoundException
- An axis was not found with the correct identifier.Axis
,
PlainAxis
public void removeXAxis(java.lang.String id) throws AxisNotFoundException
id
- axis identifier
AxisNotFoundException
- An axis was not found with the correct identifier.Axis
,
PlainAxis
public void removeXAxis(Axis axis) throws AxisNotFoundException
AxisNotFoundException
- An axis was not found with the correct identifier.Axis
,
PlainAxis
public void removeAllXAxes()
public int getNumberXAxis()
Axis
,
PlainAxis
public java.util.Enumeration xAxisElements()
Enumeration
object for the X axes.
public void addYAxis(java.lang.String id, Axis axis)
Axis.VERTICAL
) to the graph.
id
- axis identifieraxis
- Y axisAxis
,
PlainAxis
public void addYAxis(Axis axis)
Axis.VERTICAL
) to the graph.
Uses the existing axis identifier.
axis
- Y axisAxis
,
PlainAxis
public Axis getYAxis(java.lang.String id) throws AxisNotFoundException
id
- axis identifier
AxisNotFoundException
- An axis was not found with the correct identifier.Axis
,
PlainAxis
public void removeYAxis(java.lang.String id) throws AxisNotFoundException
id
- axis identifier
AxisNotFoundException
- An axis was not found with the correct identifier.Axis
,
PlainAxis
public void removeYAxis(Axis axis) throws AxisNotFoundException
AxisNotFoundException
- An axis was not found with the correct identifier.Axis
,
PlainAxis
public void removeAllYAxes()
public int getNumberYAxis()
Axis
,
PlainAxis
public java.util.Enumeration yAxisElements()
Enumeration
object for the Y axes.
public void setXTransform(AxisTransform xfrm)
AxisTransform
. This transform is used to convert
to and from user to physical coordinates.
xfrm
- X transformAxisTransform
,
LinearTransform
public AxisTransform getXTransform()
AxisTransform
.
AxisTransform
,
LinearTransform
public void setYTransform(AxisTransform xfrm)
AxisTransform
. This transform is used to convert
to and from user to physical coordinates.
xfrm
- Y transformAxisTransform
,
LinearTransform
public AxisTransform getYTransform()
AxisTransform
.
AxisTransform
,
LinearTransform
public double getXUtoP(double u)
public int getXUtoD(double u)
public double getXUtoD2(double u)
public double getXUtoP(GeoDate t)
GeoDate
to physical coordinate.
public double getXUtoP(long t)
long
to physical coordinate.
public int getXUtoD(GeoDate t)
GeoDate
to device coordinate.
public int getXUtoD(long t)
long
to device coordinate.
public double getXUtoD2(GeoDate t)
GeoDate
to device coordinate.
public double getXUtoD2(long t)
long
to device coordinate.
public int getXUtoD(SoTValue val)
SoTValue
to device coordinate.
public int getYUtoD(SoTValue val)
SoTValue
to device coordinate.
public double getXUtoD2(SoTValue val)
SoTValue
to device coordinate.
public double getYUtoD2(SoTValue val)
SoTValue
to device coordinate.
public double getXUtoP(SoTValue val)
SoTValue
to physical coordinate.
public double getYUtoP(SoTValue val)
SoTValue
to physical coordinate.
public SoTValue getXPtoSoT(double p)
SoTValue
p
- physical coordinate
public double getXPtoU(double p)
p
- physical coorindate
public GeoDate getXPtoTime(double p)
p
- physical coordinate
public long getXPtoLongTime(double p)
p
- physical coordinate
public SoTPoint getPtoU(Point2D.Double loc)
SoTPoint
p
- physical coordinate
SoTPoint
public double getYUtoP(double u)
public int getYUtoD(double u)
public double getYUtoD2(double u)
public double getYUtoP(GeoDate t)
public double getYUtoP(long t)
public int getYUtoD(GeoDate t)
public int getYUtoD(long t)
public double getYUtoD2(GeoDate t)
public double getYUtoD2(long t)
public SoTValue getYPtoSoT(double p)
SoTValue
p
- physical coordinate
public double getYPtoU(double p)
p
- physical coorindate
public GeoDate getYPtoTime(double p)
p
- physical coordinate
public long getYPtoLongTime(double p)
p
- physical coordinate
public void propertyChange(java.beans.PropertyChangeEvent evt)
public SGTData getDataAt(java.awt.Point pt)
getDataAt
in class Graph
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |