sgtplot
Class CartesianGraph
- java.lang.Object
-
- sgtplot.Graph
-
- sgtplot.CartesianGraph
-
- All Implemented Interfaces:
- java.beans.PropertyChangeListener, java.util.EventListener
public class CartesianGraph extends Graph
TheCartesianGraphprovides 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 aCartesianGraphand their mapping of user to physical coordinates is based on theAxisTransforms used. TheCartesianGraphalso provide the support for the rendering of data. The specific renderer is chosen based on the type ofSGTDataand the dataAttributeused.The following demonstrates how a
CartesianGraphmay 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);- Since:
- 1.0
-
-
Constructor Summary
Constructors Constructor and Description CartesianGraph()Default constructor.CartesianGraph(java.lang.String id)CartesianGraphconstructor.CartesianGraph(java.lang.String id, AxisTransform xt, AxisTransform yt)Create a newCartesianGraph.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddXAxis(Axis axis)Add a X axis (Axis.HORIZONTAL) to the graph.voidaddXAxis(java.lang.String id, Axis axis)Add a X axis (Axis.HORIZONTAL) to the graph.voidaddYAxis(Axis axis)Add a Y axis (Axis.VERTICAL) to the graph.voidaddYAxis(java.lang.String id, Axis axis)Add a Y axis (Axis.VERTICAL) to the graph.Graphcopy()Create a copy of theCartesianGraphvoiddraw(org.freehep.graphics2d.VectorGraphics g)Draw the graph, axes, and render the data.SGTDatagetDataAt(java.awt.Point pt)Find data at pointintgetNumberXAxis()Get the number of X axes associated with the graph.intgetNumberYAxis()Get the number of Y axes associated with the graph.SoTPointgetPtoU(Point2D.Double loc)Transform physical coordinate to aSoTPointCartesianRenderergetRenderer()Get the renderer instance being used by the graph.AxisgetXAxis(java.lang.String id)Get a reference to an X axis.longgetXPtoLongTime(double p)Transform physical X coordinate to time.SoTValuegetXPtoSoT(double p)Transform physical X coordinate to user coordinate usingSoTValueGeoDategetXPtoTime(double p)Transform physical X coordinate to time.doublegetXPtoU(double p)Transform physical X coordinate to user coordinate.AxisTransformgetXTransform()Get the current XAxisTransform.intgetXUtoD(double u)Transform user X coordinate to device coordinate.intgetXUtoD(GeoDate t)TransformGeoDateto device coordinate.intgetXUtoD(long t)Transformlongto device coordinate.intgetXUtoD(SoTValue val)Transform XSoTValueto device coordinate.doublegetXUtoD2(double u)Transform user X coordinate to device coordinate.doublegetXUtoD2(GeoDate t)TransformGeoDateto device coordinate.doublegetXUtoD2(long t)Transformlongto device coordinate.doublegetXUtoD2(SoTValue val)Transform XSoTValueto device coordinate.doublegetXUtoP(double u)Transform user X coordinate to physical coordinate.doublegetXUtoP(GeoDate t)TransformGeoDateto physical coordinate.doublegetXUtoP(long t)Transformlongto physical coordinate.doublegetXUtoP(SoTValue val)Transform XSoTValueto physical coordinate.AxisgetYAxis(java.lang.String id)Get a reference to an Y axis.longgetYPtoLongTime(double p)Transform physical Y coordinate to time.SoTValuegetYPtoSoT(double p)Transform physical Y coordinate to user coordinate usingSoTValueGeoDategetYPtoTime(double p)Transform physical Y coordinate to time.doublegetYPtoU(double p)Transform physical Y coordinate to user coordinate.AxisTransformgetYTransform()Get the current YAxisTransform.intgetYUtoD(double u)Transform user Y coordinate to device coordinateintgetYUtoD(GeoDate t)Transform time to device coordinate.intgetYUtoD(long t)Transform time to device coordinate.intgetYUtoD(SoTValue val)Transform YSoTValueto device coordinate.doublegetYUtoD2(double u)Transform user Y coordinate to device coordinatedoublegetYUtoD2(GeoDate t)Transform time to device coordinate.doublegetYUtoD2(long t)Transform time to device coordinate.doublegetYUtoD2(SoTValue val)Transform YSoTValueto device coordinate.doublegetYUtoP(double u)Transoform user Y coordinate to physical coordinate.doublegetYUtoP(GeoDate t)Transform time to physical coordinate.doublegetYUtoP(long t)Transform time to physical coordinate.doublegetYUtoP(SoTValue val)Transform YSoTValueto physical coordinate.booleanisClipping()Test the clipping property.voidpropertyChange(java.beans.PropertyChangeEvent evt)voidremoveAllXAxes()Remove all X axes from the graph.voidremoveAllYAxes()Remove all Y axes from the graph.voidremoveXAxis(Axis axis)Remove an X axis from the graph.voidremoveXAxis(java.lang.String id)Remove an X axis from the graph.voidremoveYAxis(Axis axis)Remove an Y axis from the graph.voidremoveYAxis(java.lang.String id)Remove an Y axis from the graph.voidsetClip(double xmin, double xmax, double ymin, double ymax)Set the clipping rectangle in user coordinates.voidsetClip(GeoDate tmin, GeoDate tmax, double min, double max)Set the clipping rectangle in user coordinates.voidsetClip(long tmin, long tmax, double min, double max)Set the clipping rectangle in user coordinates.voidsetClip(SoTRange xr, SoTRange yr)Set the clipping rectangle in user coordinates.voidsetClipping(boolean clip)Set the clipping property.voidsetData(SGTData data, Attribute attr)AssociatesSGTDataandAttributewith theCartesianGraph.voidsetRenderer(CartesianRenderer rend)Set the renderer used by the graph.voidsetXTransform(AxisTransform xfrm)Set the XAxisTransform.voidsetYTransform(AxisTransform xfrm)Set the YAxisTransform.java.util.EnumerationxAxisElements()Get anEnumerationobject for the X axes.java.util.EnumerationyAxisElements()Get anEnumerationobject for the Y axes.-
Methods inherited from class sgtplot.Graph
computeRange, computeRange, computeRange, getId, getLayer, getPane, modified, toString
-
-
-
-
Constructor Detail
-
CartesianGraph
public CartesianGraph()
Default constructor.
-
CartesianGraph
public CartesianGraph(java.lang.String id)
CartesianGraphconstructor. Creates default unity transforms.- Parameters:
id- CartesianGraph identifier
-
CartesianGraph
public CartesianGraph(java.lang.String id, AxisTransform xt, AxisTransform yt)Create a newCartesianGraph. Sets the identifier and sets the x and y transforms.- Parameters:
id- identifierxt- x transformyt- y transform
-
-
Method Detail
-
setData
public void setData(SGTData data, Attribute attr)
AssociatesSGTDataandAttributewith theCartesianGraph. 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 - Parameters:
data- data to be renderedattr- rendering style information- See Also:
CartesianRenderer.getRenderer(sgtplot.CartesianGraph, sgtplot.dm.SGTData, sgtplot.Attribute)
-
getRenderer
public CartesianRenderer getRenderer()
Get the renderer instance being used by the graph.- Returns:
- renderer
-
setRenderer
public void setRenderer(CartesianRenderer rend)
Set the renderer used by the graph.- Parameters:
rend- a renderer object
-
draw
public void draw(org.freehep.graphics2d.VectorGraphics g)
Draw the graph, axes, and render the data. This method should not be directly called.
-
setClip
public void setClip(double xmin, double xmax, double ymin, double ymax)Set the clipping rectangle in user coordinates.- Parameters:
xmin- minimum horizontal coordinatexmax- maximum horizontal coordinateymin- minimum vertical coordinateymax- maximum vertical coordinate
-
setClip
public void setClip(GeoDate tmin, GeoDate tmax, double min, double max)
Set the clipping rectangle in user coordinates.- Parameters:
tmin- mimimum timetmax- maximum timemin- miminum user coordinatemax- maximum user coordinate
-
setClip
public void setClip(long tmin, long tmax, double min, double max)Set the clipping rectangle in user coordinates.- Parameters:
tmin- mimimum timetmax- maximum timemin- miminum user coordinatemax- maximum user coordinate- Since:
- 3.0
-
setClip
public void setClip(SoTRange xr, SoTRange yr)
Set the clipping rectangle in user coordinates.- Since:
- 2.0
-
setClipping
public void setClipping(boolean clip)
Set the clipping property.- Parameters:
clip- clipping
-
isClipping
public boolean isClipping()
Test the clipping property.- Returns:
- true if clipping is active
-
addXAxis
public void addXAxis(java.lang.String id, Axis axis)Add a X axis (Axis.HORIZONTAL) to the graph.
-
addXAxis
public void addXAxis(Axis axis)
Add a X axis (Axis.HORIZONTAL) to the graph. Uses the existing axis identifier.
-
getXAxis
public Axis getXAxis(java.lang.String id) throws AxisNotFoundException
Get a reference to an X axis.- Parameters:
id- axis identifier- Returns:
- axis found
- Throws:
AxisNotFoundException- An axis was not found with the correct identifier.- See Also:
Axis,PlainAxis
-
removeXAxis
public void removeXAxis(java.lang.String id) throws AxisNotFoundExceptionRemove an X axis from the graph.- Parameters:
id- axis identifier- Throws:
AxisNotFoundException- An axis was not found with the correct identifier.- See Also:
Axis,PlainAxis
-
removeXAxis
public void removeXAxis(Axis axis) throws AxisNotFoundException
Remove an X axis from the graph.- Throws:
AxisNotFoundException- An axis was not found with the correct identifier.- See Also:
Axis,PlainAxis
-
removeAllXAxes
public void removeAllXAxes()
Remove all X axes from the graph.
-
getNumberXAxis
public int getNumberXAxis()
Get the number of X axes associated with the graph.
-
xAxisElements
public java.util.Enumeration xAxisElements()
Get anEnumerationobject for the X axes.- Returns:
- enumeration
-
addYAxis
public void addYAxis(java.lang.String id, Axis axis)Add a Y axis (Axis.VERTICAL) to the graph.
-
addYAxis
public void addYAxis(Axis axis)
Add a Y axis (Axis.VERTICAL) to the graph. Uses the existing axis identifier.
-
getYAxis
public Axis getYAxis(java.lang.String id) throws AxisNotFoundException
Get a reference to an Y axis.- Parameters:
id- axis identifier- Returns:
- axis found
- Throws:
AxisNotFoundException- An axis was not found with the correct identifier.- See Also:
Axis,PlainAxis
-
removeYAxis
public void removeYAxis(java.lang.String id) throws AxisNotFoundExceptionRemove an Y axis from the graph.- Parameters:
id- axis identifier- Throws:
AxisNotFoundException- An axis was not found with the correct identifier.- See Also:
Axis,PlainAxis
-
removeYAxis
public void removeYAxis(Axis axis) throws AxisNotFoundException
Remove an Y axis from the graph.- Throws:
AxisNotFoundException- An axis was not found with the correct identifier.- See Also:
Axis,PlainAxis
-
removeAllYAxes
public void removeAllYAxes()
Remove all Y axes from the graph.
-
getNumberYAxis
public int getNumberYAxis()
Get the number of Y axes associated with the graph.
-
yAxisElements
public java.util.Enumeration yAxisElements()
Get anEnumerationobject for the Y axes.- Returns:
- enumeration
-
setXTransform
public void setXTransform(AxisTransform xfrm)
Set the XAxisTransform. This transform is used to convert to and from user to physical coordinates.- Parameters:
xfrm- X transform- See Also:
AxisTransform,LinearTransform
-
getXTransform
public AxisTransform getXTransform()
Get the current XAxisTransform.- Returns:
- X Transform
- See Also:
AxisTransform,LinearTransform
-
setYTransform
public void setYTransform(AxisTransform xfrm)
Set the YAxisTransform. This transform is used to convert to and from user to physical coordinates.- Parameters:
xfrm- Y transform- See Also:
AxisTransform,LinearTransform
-
getYTransform
public AxisTransform getYTransform()
Get the current YAxisTransform.- Returns:
- Y Transform
- See Also:
AxisTransform,LinearTransform
-
getXUtoP
public double getXUtoP(double u)
Transform user X coordinate to physical coordinate.- Since:
- 2.0
-
getXUtoD
public int getXUtoD(double u)
Transform user X coordinate to device coordinate.- Since:
- 2.0
-
getXUtoD2
public double getXUtoD2(double u)
Transform user X coordinate to device coordinate.- Since:
- 3.0
-
getXUtoP
public double getXUtoP(GeoDate t)
TransformGeoDateto physical coordinate.- Since:
- 2.0
-
getXUtoP
public double getXUtoP(long t)
Transformlongto physical coordinate.- Since:
- 3.0
-
getXUtoD
public int getXUtoD(GeoDate t)
TransformGeoDateto device coordinate.- Since:
- 2.0
-
getXUtoD
public int getXUtoD(long t)
Transformlongto device coordinate.- Since:
- 3.0
-
getXUtoD2
public double getXUtoD2(GeoDate t)
TransformGeoDateto device coordinate.- Since:
- 3.0
-
getXUtoD2
public double getXUtoD2(long t)
Transformlongto device coordinate.- Since:
- 3.0
-
getXUtoD
public int getXUtoD(SoTValue val)
Transform XSoTValueto device coordinate.- Since:
- 3.0
-
getYUtoD
public int getYUtoD(SoTValue val)
Transform YSoTValueto device coordinate.- Since:
- 3.0
-
getXUtoD2
public double getXUtoD2(SoTValue val)
Transform XSoTValueto device coordinate.- Since:
- 3.0
-
getYUtoD2
public double getYUtoD2(SoTValue val)
Transform YSoTValueto device coordinate.- Since:
- 3.0
-
getXUtoP
public double getXUtoP(SoTValue val)
Transform XSoTValueto physical coordinate.- Since:
- 3.0
-
getYUtoP
public double getYUtoP(SoTValue val)
Transform YSoTValueto physical coordinate.- Since:
- 3.0
-
getXPtoSoT
public SoTValue getXPtoSoT(double p)
Transform physical X coordinate to user coordinate usingSoTValue- Parameters:
p- physical coordinate- Returns:
- user coorindinate
- Since:
- 3.0
-
getXPtoU
public double getXPtoU(double p)
Transform physical X coordinate to user coordinate.- Parameters:
p- physical coorindate- Returns:
- user coordinate
-
getXPtoTime
public GeoDate getXPtoTime(double p)
Transform physical X coordinate to time.- Parameters:
p- physical coordinate- Returns:
- time
-
getXPtoLongTime
public long getXPtoLongTime(double p)
Transform physical X coordinate to time.- Parameters:
p- physical coordinate- Returns:
- time
- Since:
- 3.0
-
getPtoU
public SoTPoint getPtoU(Point2D.Double loc)
Transform physical coordinate to aSoTPoint- Parameters:
p- physical coordinate- Returns:
SoTPoint- Since:
- 3.0
-
getYUtoP
public double getYUtoP(double u)
Transoform user Y coordinate to physical coordinate.- Since:
- 2.0
-
getYUtoD
public int getYUtoD(double u)
Transform user Y coordinate to device coordinate- Since:
- 2.0
-
getYUtoD2
public double getYUtoD2(double u)
Transform user Y coordinate to device coordinate- Since:
- 3.0
-
getYUtoP
public double getYUtoP(GeoDate t)
Transform time to physical coordinate.- Since:
- 2.0
-
getYUtoP
public double getYUtoP(long t)
Transform time to physical coordinate.- Since:
- 3.0
-
getYUtoD
public int getYUtoD(GeoDate t)
Transform time to device coordinate.- Since:
- 2.0
-
getYUtoD
public int getYUtoD(long t)
Transform time to device coordinate.- Since:
- 3.0
-
getYUtoD2
public double getYUtoD2(GeoDate t)
Transform time to device coordinate.- Since:
- 3.0
-
getYUtoD2
public double getYUtoD2(long t)
Transform time to device coordinate.- Since:
- 3.0
-
getYPtoSoT
public SoTValue getYPtoSoT(double p)
Transform physical Y coordinate to user coordinate usingSoTValue- Parameters:
p- physical coordinate- Returns:
- user coorindinate
- Since:
- 3.0
-
getYPtoU
public double getYPtoU(double p)
Transform physical Y coordinate to user coordinate.- Parameters:
p- physical coorindate- Returns:
- user coordinate
-
getYPtoTime
public GeoDate getYPtoTime(double p)
Transform physical Y coordinate to time.- Parameters:
p- physical coordinate- Returns:
- time
-
getYPtoLongTime
public long getYPtoLongTime(double p)
Transform physical Y coordinate to time.- Parameters:
p- physical coordinate- Returns:
- time
- Since:
- 3.0
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent evt)
-
-
DMelt 3.0 © DataMelt by jWork.ORG