public class PEToolKit
extends java.lang.Object
Constructor and Description |
---|
PEToolKit() |
Modifier and Type | Method and Description |
---|---|
static PicVector |
computeTangentToPath(java.awt.Shape s,
PicPoint pt,
double maxDist)
Returns the tangent to the given path, computed at
the path-point which is closest to the given point "pt" than the given maximum distance
Return null otherwise (ie if pt is too far from the given shape).
|
static java.awt.geom.QuadCurve2D[] |
convertCubicBezierToQuad(java.awt.geom.CubicCurve2D cubic)
Converts the given cubic curve to a quad curve
|
static PicPoint[] |
convertCubicBezierToQuad(java.awt.geom.Point2D p1,
java.awt.geom.Point2D pCtrl1,
java.awt.geom.Point2D pCtrl2,
java.awt.geom.Point2D p2)
Given four specification points of a cubic bezier spline, returns an array of five PicPoint's containing
the specification points of two quad bezier splines having the same geometry as the given curve.
|
static PicPoint[] |
convertQuadBezierToCubic(java.awt.geom.Point2D p1,
java.awt.geom.Point2D pCtrl,
java.awt.geom.Point2D p2)
Given the three specification points of a quad bezier spline, returns an array of PicPoint's
containing the four specification points of a cubic spline having the same geometry.
|
static java.awt.geom.CubicCurve2D |
convertQuadBezierToCubic(java.awt.geom.QuadCurve2D quad)
Converts the given quad curve to a cubic curve
|
static javax.swing.JComboBox |
createComboBox(java.lang.Object[] items)
creates a JComboBox
|
static java.awt.geom.Line2D[] |
createFlattenedPath(java.awt.Shape s,
double flatness)
Return an array of Line2D's representing the (visible part of the) flattened path
of the given shape.
|
static javax.swing.ImageIcon |
createImageIcon(java.lang.String icon)
create an ImageIcon built from "/jpicedt/images/"+icon+".gif"
|
static javax.swing.JLabel |
createJLabel(java.lang.String icon)
create a JLabel with an Icon built from "/jpicedt/images/"+icon+".gif"
|
static java.awt.Shape[] |
createPath(java.awt.Shape s)
Return an array of Line2D, Quad2D and Cubic2D, representing the (visible part of the) path
of the given shape.
|
static java.lang.String |
doubleToString(double x)
Returns a string representation of the given double.
|
static java.lang.String |
doubleToString(java.lang.Double x) |
static PicPoint |
getDirector(double startPtX,
double startPtY,
double endPtX,
double endPtY,
PicPoint dest)
Deprecated.
|
static PicPoint |
getDirector(PicPoint startPt,
PicPoint endPt)
Deprecated.
|
static PicPoint |
getDirector(PicPoint startPt,
PicPoint endPt,
PicPoint dest)
Deprecated.
|
static PicPoint |
getOrthogonal(PicPoint startPt,
PicPoint endPt)
Deprecated.
|
static java.lang.String |
intToString(double x) |
static double[] |
minMaxArray(double[] array)
Return an array of length 2 containing the minimum and the maximum of the given array, in that order.
|
static void |
setMaximumFractionDigits(int n)
Set the maximum number of fraction digits to be used when formatting doubles using
the
doubleToString() method. |
static int |
testDistanceToPath(java.awt.Shape s,
PicPoint pt,
double maxDist)
Return a positive integer if the given point "pt" lies closer to the given shape path (= stroke)
than the given maximum distance ; this integer indicates which segment/quad/cubic of the path,
starting from 0 (ie according to getPathIterator numbering scheme),
lies at the closest distance from "pt" ; -1 otherwise.
|
public static void setMaximumFractionDigits(int n)
doubleToString()
method.n
- set to a negative number to retrieve the default behaviourpublic static java.lang.String doubleToString(double x)
setMaximumFractionDigits
beforehands.public static java.lang.String doubleToString(java.lang.Double x)
public static java.lang.String intToString(double x)
public static double[] minMaxArray(double[] array)
array
- an array of length greater than 0public static PicPoint getDirector(PicPoint startPt, PicPoint endPt)
public static PicPoint getDirector(PicPoint startPt, PicPoint endPt, PicPoint dest)
public static PicPoint getDirector(double startPtX, double startPtY, double endPtX, double endPtY, PicPoint dest)
public static PicPoint getOrthogonal(PicPoint startPt, PicPoint endPt)
public static PicVector computeTangentToPath(java.awt.Shape s, PicPoint pt, double maxDist)
This implementation relies on FlatteningPathIterator, hence the smaller the "maxDist" parameter, the better the return result.
shape
- basically this would rather be a quadratic or a cubic bezier segment, but Arc2D should work as well..maxDist
- the maximum distance allowed between the given PicPoint and the stroke of the given Shape before
null is returned ; may be Double.POSITIVE_INFINITY, in which case a tangent is always returned.public static int testDistanceToPath(java.awt.Shape s, PicPoint pt, double maxDist)
This may be used by the UI to determine if a mouse-click occured on a stroke path, especially
for complex shapes like Bezier curves, or arcs (although the returned integer only really makes
sense for shape which are made of bezier curves or segments). This uses
FlatteningPathIterator
, with
the given maxDist parameter also used as the flatness parameter, since it's the value which gives the
best results.
public static java.awt.Shape[] createPath(java.awt.Shape s)
Shape.getPathIterator()
This may be used, for instance,
by formaters willing to express a given shape only in terms of Bezier curves and segments,
if these are the only shapes available in the given target language (e.g. this is the
case with LaTeX's picture environment, where ellipses are not available).public static java.awt.geom.Line2D[] createFlattenedPath(java.awt.Shape s, double flatness)
flatness
- the flatness used to build the FlattenedPathIterator (max. dist. b/w shape
and segments of the flattened path).public static PicPoint[] convertCubicBezierToQuad(java.awt.geom.Point2D p1, java.awt.geom.Point2D pCtrl1, java.awt.geom.Point2D pCtrl2, java.awt.geom.Point2D p2)
p1
- first cubic spline end-pointp2
- second cubic spline end-pointpCtrl1
- first cubic spline control-pointpCtrl2
- second cubic spline control-pointCubicCurve2D
,
QuadCurve2D
public static PicPoint[] convertQuadBezierToCubic(java.awt.geom.Point2D p1, java.awt.geom.Point2D pCtrl, java.awt.geom.Point2D p2)
The following algorith is being used (xQ and xC refer to quad and cubic spline resp.) :
p1
- first quad end-pointp2
- second quad end-pointpCtrl
- quad control-pointpublic static java.awt.geom.CubicCurve2D convertQuadBezierToCubic(java.awt.geom.QuadCurve2D quad)
public static java.awt.geom.QuadCurve2D[] convertCubicBezierToQuad(java.awt.geom.CubicCurve2D cubic)
public static javax.swing.ImageIcon createImageIcon(java.lang.String icon)
public static javax.swing.JLabel createJLabel(java.lang.String icon)
public static javax.swing.JComboBox createComboBox(java.lang.Object[] items)
Submit a bug : syd@jpicedt.org