org.das2.graph
Class GraphUtil

java.lang.Object
  extended by org.das2.graph.GraphUtil

public class GraphUtil
extends java.lang.Object


Constructor Summary
GraphUtil()
           
 
Method Summary
static java.awt.geom.AffineTransform calculateAT(DasAxis xaxis0, DasAxis yaxis0, DasAxis xaxis1, DasAxis yaxis1)
          calculates the AffineTransform between two sets of x and y axes, if possible.
static java.awt.geom.AffineTransform calculateAT(DatumRange xaxis0, DatumRange yaxis0, DasAxis xaxis1, DasAxis yaxis1)
           
static javax.swing.Icon colorIcon(java.awt.Color iconColor, int w, int h)
          return a block with the color and size.
static java.lang.String describe(java.awt.geom.GeneralPath path, boolean enumeratePoints)
           
static java.lang.String getATScaleTranslateString(java.awt.geom.AffineTransform at)
           
static java.awt.geom.GeneralPath getPath(DasAxis xAxis, DasAxis yAxis, VectorDataSet xds, boolean histogram)
           
static java.awt.geom.GeneralPath getPath(DasAxis xAxis, DasAxis yAxis, VectorDataSet xds, VectorDataSet yds, boolean histogram)
           
static java.awt.Color getRicePaperColor()
           
static double[] getSlopeIntercept(double x0, double y0, double x1, double y1)
          calculates the slope and intercept of a line going through two points.
static DasPlot guessPlot(DataSet ds)
           
static Renderer guessRenderer(DataSet ds)
           
static DasAxis guessXAxis(DataSet ds)
           
static DasAxis guessYAxis(DataSet dsz)
           
static DasAxis guessZAxis(DataSet dsz)
           
static DatumRange invTransformRange(DasAxis axis, double x1, double x2)
           
static java.awt.geom.Point2D lineIntersection(java.awt.geom.Line2D line1, java.awt.geom.Line2D line2, boolean noBoundsCheck)
          returns the point where the two line segments intersect, or null.
static java.awt.geom.Point2D lineRectangleIntersection(java.awt.geom.Point2D p0, java.awt.geom.Point2D p1, java.awt.geom.Rectangle2D r0)
           
static javax.swing.JTabbedPane loadCanvas(java.io.InputStream in)
           
static DasPlot newDasPlot(DasCanvas canvas, DatumRange x, DatumRange y)
           
static double pointsAlongCurve(java.awt.geom.PathIterator it, double[] pathlen, java.awt.geom.Point2D.Double[] result, double[] orientation, boolean stopAtMoveTo)
          return the points along a curve.
static java.awt.geom.GeneralPath reducePath(java.awt.geom.PathIterator it, java.awt.geom.GeneralPath result)
          Returns the input GeneralPath filled with new points which will be rendered identically to the input path, but contains a minimal number of points.
static void serializeCanvas(DasCanvas canvas, java.io.OutputStream out)
           
static double[] transformRange(DasAxis axis, DatumRange range)
          returns pixel range of the datum range, guarenteeing that the first element will be less than or equal to the second.
static DasPlot visualize(DataSet ds)
           
static DasPlot visualize(DataSet ds, boolean ylog)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphUtil

public GraphUtil()
Method Detail

newDasPlot

public static DasPlot newDasPlot(DasCanvas canvas,
                                 DatumRange x,
                                 DatumRange y)

serializeCanvas

public static void serializeCanvas(DasCanvas canvas,
                                   java.io.OutputStream out)

loadCanvas

public static javax.swing.JTabbedPane loadCanvas(java.io.InputStream in)
                                          throws java.lang.Exception
Throws:
java.lang.Exception

getPath

public static java.awt.geom.GeneralPath getPath(DasAxis xAxis,
                                                DasAxis yAxis,
                                                VectorDataSet xds,
                                                boolean histogram)

getPath

public static java.awt.geom.GeneralPath getPath(DasAxis xAxis,
                                                DasAxis yAxis,
                                                VectorDataSet xds,
                                                VectorDataSet yds,
                                                boolean histogram)

calculateAT

public static java.awt.geom.AffineTransform calculateAT(DasAxis xaxis0,
                                                        DasAxis yaxis0,
                                                        DasAxis xaxis1,
                                                        DasAxis yaxis1)
calculates the AffineTransform between two sets of x and y axes, if possible.

Parameters:
xaxis0 - the original reference frame x axis
yaxis0 - the original reference frame y axis
xaxis1 - the new reference frame x axis
yaxis1 - the new reference frame y axis
Returns:
an AffineTransform that transforms data positioned with xaxis0 and yaxis0 on xaxis1 and yaxis1, or null if no such transform exists.

calculateAT

public static java.awt.geom.AffineTransform calculateAT(DatumRange xaxis0,
                                                        DatumRange yaxis0,
                                                        DasAxis xaxis1,
                                                        DasAxis yaxis1)

guessYAxis

public static DasAxis guessYAxis(DataSet dsz)

guessXAxis

public static DasAxis guessXAxis(DataSet ds)

guessZAxis

public static DasAxis guessZAxis(DataSet dsz)

guessRenderer

public static Renderer guessRenderer(DataSet ds)

guessPlot

public static DasPlot guessPlot(DataSet ds)

visualize

public static DasPlot visualize(DataSet ds)

visualize

public static DasPlot visualize(DataSet ds,
                                boolean ylog)

reducePath

public static java.awt.geom.GeneralPath reducePath(java.awt.geom.PathIterator it,
                                                   java.awt.geom.GeneralPath result)
Returns the input GeneralPath filled with new points which will be rendered identically to the input path, but contains a minimal number of points. Successive points occupying the same pixel are culled. TODO: bin average the points within a cell. The descretization messes up the label orientation in contour plotting.

Parameters:
it - A path iterator with minute details that will be lost when rendering.
result - A GeneralPath to put the result into.
Returns:
a new GeneralPath which will be rendered identically to the input path, but contains a minimal number of points.

pointsAlongCurve

public static double pointsAlongCurve(java.awt.geom.PathIterator it,
                                      double[] pathlen,
                                      java.awt.geom.Point2D.Double[] result,
                                      double[] orientation,
                                      boolean stopAtMoveTo)
return the points along a curve. Used by ContourRenderer. The returned result is the remaining path length. Elements of pathlen that are beyond the total path length are not computed, and the result points will be null.

Parameters:
pathlen - monotonically increasing path lengths at which the position is to be located. May be null if only the total path length is desired.
result - the resultant points will be put into this array. This array should have the same number of elements as pathlen
orientation - the local orientation, in radians, of the point at will be put into this array. This array should have the same number of elements as pathlen
it - PathIterator first point is used to start the length.
stopAtMoveTo - treat SEG_MOVETO as the end of the path. The pathIterator will be left at this point.
Returns:
the remaining length. Note null may be used for pathlen, result, and orientation and this will simply return the total path length.

getATScaleTranslateString

public static java.lang.String getATScaleTranslateString(java.awt.geom.AffineTransform at)
Returns:
a string representation of the affine transforms used in DasPlot for debugging.

getSlopeIntercept

public static double[] getSlopeIntercept(double x0,
                                         double y0,
                                         double x1,
                                         double y1)
calculates the slope and intercept of a line going through two points.

Returns:
a double array with two elements [ slope, intercept ].

getRicePaperColor

public static java.awt.Color getRicePaperColor()

describe

public static java.lang.String describe(java.awt.geom.GeneralPath path,
                                        boolean enumeratePoints)

lineIntersection

public static java.awt.geom.Point2D lineIntersection(java.awt.geom.Line2D line1,
                                                     java.awt.geom.Line2D line2,
                                                     boolean noBoundsCheck)
returns the point where the two line segments intersect, or null.

Parameters:
line1 -
line2 -
noBoundsCheck - if true, then do not check the segment bounds.
Returns:

lineRectangleIntersection

public static java.awt.geom.Point2D lineRectangleIntersection(java.awt.geom.Point2D p0,
                                                              java.awt.geom.Point2D p1,
                                                              java.awt.geom.Rectangle2D r0)

transformRange

public static double[] transformRange(DasAxis axis,
                                      DatumRange range)
returns pixel range of the datum range, guarenteeing that the first element will be less than or equal to the second.

Parameters:
axis -
range -
Returns:

invTransformRange

public static DatumRange invTransformRange(DasAxis axis,
                                           double x1,
                                           double x2)

colorIcon

public static javax.swing.Icon colorIcon(java.awt.Color iconColor,
                                         int w,
                                         int h)
return a block with the color and size.

Parameters:
w -
h -
Returns: