public class GraphUtil
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
GraphUtil.Copyable<T>
Classes that implement this interface provide their instances with
the ability to copy themselves in a manner similar to Cloneable objects,
but without the drawbacks of Cloneable.
|
static class |
GraphUtil.DebuggingGeneralPath |
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CONNECT_MODE_HISTOGRAM
draw the lines in histogram mode, horizontal to the half-way point, then vertical, then horizontal the rest of the way.
|
static java.lang.String |
CONNECT_MODE_SCATTER
don't draw connecting lines.
|
static java.lang.String |
CONNECT_MODE_SERIES
the normal connecting mode from point-to-point in a series.
|
| Constructor and Description |
|---|
GraphUtil() |
| Modifier and Type | Method and Description |
|---|---|
static java.awt.image.BufferedImage |
blurImage(java.awt.image.BufferedImage im,
int size)
blur the image with a Guassian blur.
|
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 an icon block with the color and size.
|
static DasAxis |
copyAxis(DasAxis a)
return a copy of the plot.
|
static DasColorBar |
copyColorBar(DasColorBar a)
return a copy of the plot.
|
static DasPlot |
copyPlot(DasPlot p)
return a copy of the plot.
|
static java.lang.String |
describe(java.awt.geom.GeneralPath path,
boolean enumeratePoints)
describe the path for debugging.
|
static java.lang.String |
getATScaleTranslateString(java.awt.geom.AffineTransform at)
return a string representation of the affine transforms used in DasPlot for
debugging.
|
static Converter |
getFontConverter(DasCanvasComponent dcc,
java.lang.String fallbackFont)
converts forward from relative font spec to point size, used by
the annotation and axis nodes.
|
static java.awt.image.ConvolveOp |
getGaussianBlurFilter(int radius,
boolean horizontal)
return a Gaussian filter for blurring images.
|
static java.awt.geom.GeneralPath |
getPath(DasAxis xAxis,
DasAxis yAxis,
QDataSet ds,
boolean histogram,
boolean clip)
get the path for the points, checking for breaks in the data from fill values.
|
static java.awt.geom.GeneralPath |
getPath(DasAxis xAxis,
DasAxis yAxis,
QDataSet xds,
QDataSet yds,
boolean histogram,
boolean clip)
get the path for the points, checking for breaks in the data from fill values.
|
static java.awt.geom.GeneralPath |
getPath(DasAxis xAxis,
DasAxis yAxis,
QDataSet xds,
QDataSet yds,
java.lang.String mode,
boolean clip)
get the path for the points, checking for breaks in the data from fill values.
|
static java.awt.Color |
getRicePaperColor()
return translucent white color for indicating the application is busy.
|
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(QDataSet ds)
get a plot and renderer for the dataset.
|
static Renderer |
guessRenderer(QDataSet ds)
legacy guess that is used who-knows-where.
|
static DasAxis |
guessXAxis(QDataSet ds) |
static DasAxis |
guessYAxis(QDataSet dsz) |
static DasAxis |
guessZAxis(QDataSet 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 DasPlot |
newDasPlot(DasCanvas canvas,
DatumRange x,
DatumRange y)
create a plot for the canvas, along with the row and column for layout.
|
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 int |
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 int |
reducePath(java.awt.geom.PathIterator it,
java.awt.geom.GeneralPath result,
int res)
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 int |
reducePath20140622(java.awt.geom.PathIterator it,
java.awt.geom.GeneralPath result,
int resn,
int resd)
New ReducePath reduces a path by keeping track of vertically collinear points, and reducing them to an entry
point, an exit point, min and max.
|
static java.awt.Rectangle |
shrinkRectangle(java.awt.Rectangle bounds,
int percent)
return rectangle with same center that is percent/100 of the
original width and height.
|
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(QDataSet ds)
get a plot and add it to a JFrame.
|
public static final java.lang.String CONNECT_MODE_HISTOGRAM
public static final java.lang.String CONNECT_MODE_SCATTER
public static final java.lang.String CONNECT_MODE_SERIES
public static DasPlot newDasPlot(DasCanvas canvas, DatumRange x, DatumRange y)
canvas - the canvas parent for the plot.x - the x rangey - the y rangepublic static java.awt.geom.GeneralPath getPath(DasAxis xAxis, DasAxis yAxis, QDataSet ds, boolean histogram, boolean clip)
xAxis - the x axis.yAxis - the y axis.ds - the y values. SemanticOps.xtagsDataSet is used to extract the x values.histogram - if true, use histogram (stair-step) modeclip - limit path to what's visible for each axis.public static java.awt.geom.GeneralPath getPath(DasAxis xAxis, DasAxis yAxis, QDataSet xds, QDataSet yds, boolean histogram, boolean clip)
xAxis - the x axis.yAxis - the y axis.xds - the x values.yds - the y values.histogram - if true, use histogram (stair-step) modeclip - limit path to what's visible for each axis.public static java.awt.geom.GeneralPath getPath(DasAxis xAxis, DasAxis yAxis, QDataSet xds, QDataSet yds, java.lang.String mode, boolean clip)
xAxis - the x axis.yAxis - the y axis.xds - the x values.yds - the y values.mode - one of CONNECT_MODE_SERIES, CONNECT_MODE_SCATTER, or CONNECT_MODE_HISTOGRAMclip - limit path to what's visible for each axis.CONNECT_MODE_SERIES,
CONNECT_MODE_SCATTER,
CONNECT_MODE_HISTOGRAMpublic static java.awt.geom.AffineTransform calculateAT(DasAxis xaxis0, DasAxis yaxis0, DasAxis xaxis1, DasAxis yaxis1)
xaxis0 - the original reference frame x axisyaxis0 - the original reference frame y axisxaxis1 - the new reference frame x axisyaxis1 - the new reference frame y axispublic static java.awt.geom.AffineTransform calculateAT(DatumRange xaxis0, DatumRange yaxis0, DasAxis xaxis1, DasAxis yaxis1)
public static Renderer guessRenderer(QDataSet ds)
ds - public static DasPlot guessPlot(QDataSet ds)
ds - the datasetpublic static DasAxis copyAxis(DasAxis a)
a - public static DasColorBar copyColorBar(DasColorBar a)
a - public static DasPlot copyPlot(DasPlot p)
cnvsNew= new DasCanvas(500,500);
row= new DasRow(cnvsNew,0.2,0.8);
column= new DasColumn(cnvsNew,0.2,0.8);
p= GraphUtil.copyPlot(dp);
cnvsNew.add(p,row,column);
p - public static DasPlot visualize(QDataSet ds)
ds - public static int reducePath20140622(java.awt.geom.PathIterator it,
java.awt.geom.GeneralPath result,
int resn,
int resd)
it - input path.result - output path.resn - the resolution numerator (e.g. 1)resd - the resolution denominator (e.g. 5)public static int reducePath(java.awt.geom.PathIterator it,
java.awt.geom.GeneralPath result)
it - A path iterator with minute details that will be lost when rendering.result - A GeneralPath to put the result into.public static int reducePath(java.awt.geom.PathIterator it,
java.awt.geom.GeneralPath result,
int res)
it - A path iterator with minute details that will be lost when rendering.result - A GeneralPath to put the result into.res - limit the resolution in pixelspublic static double pointsAlongCurve(java.awt.geom.PathIterator it,
double[] pathlen,
java.awt.geom.Point2D.Double[] result,
double[] orientation,
boolean stopAtMoveTo)
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 pathlenorientation - 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 pathlenit - 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.public static java.lang.String getATScaleTranslateString(java.awt.geom.AffineTransform at)
at - the affine transformpublic static double[] getSlopeIntercept(double x0,
double y0,
double x1,
double y1)
x0 - the first point xy0 - the first point yx1 - the second point xy1 - the second point ypublic static java.awt.Color getRicePaperColor()
public static java.awt.image.ConvolveOp getGaussianBlurFilter(int radius,
boolean horizontal)
radius - the radius filter in pixels.horizontal - true if horizontal blur.public static java.awt.image.BufferedImage blurImage(java.awt.image.BufferedImage im,
int size)
im - size - the size of the blur, roughly in pixels.public static java.lang.String describe(java.awt.geom.GeneralPath path,
boolean enumeratePoints)
path - the Path to describeenumeratePoints - if true, print all the points as well.public static java.awt.geom.Point2D lineIntersection(java.awt.geom.Line2D line1,
java.awt.geom.Line2D line2,
boolean noBoundsCheck)
line1 - line2 - noBoundsCheck - if true, then do not check the segment bounds.public static java.awt.geom.Point2D lineRectangleIntersection(java.awt.geom.Point2D p0,
java.awt.geom.Point2D p1,
java.awt.geom.Rectangle2D r0)
public static double[] transformRange(DasAxis axis, DatumRange range)
axis - range - public static DatumRange invTransformRange(DasAxis axis, double x1, double x2)
public static javax.swing.Icon colorIcon(java.awt.Color iconColor,
int w,
int h)
iconColor - the colorw - the width in pixelsh - the height in pixelspublic static java.awt.Rectangle shrinkRectangle(java.awt.Rectangle bounds,
int percent)
bounds - the original rectangle.percent - the percent to increase (110% is 10% bigger)public static Converter getFontConverter(DasCanvasComponent dcc, java.lang.String fallbackFont)
dcc - the canvas component.fallbackFont - the font to use when a font is not available, like "sans-8"