|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jpicedt.graphic.PEToolKit
public class PEToolKit
A collection of static “utilities” methods targetting number formatting, Swing's widget creation, computation of geometrical properties,…
Constructor Summary | |
---|---|
PEToolKit()
|
Method Summary | ||
---|---|---|
static PicVector |
computeTangentToPath(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 QuadCurve2D[] |
convertCubicBezierToQuad(CubicCurve2D cubic)
Converts the given cubic curve to a quad curve |
|
static PicPoint[] |
convertCubicBezierToQuad(Point2D p1,
Point2D pCtrl1,
Point2D pCtrl2,
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(Point2D p1,
Point2D pCtrl,
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 CubicCurve2D |
convertQuadBezierToCubic(QuadCurve2D quad)
Converts the given quad curve to a cubic curve |
|
static
|
createComboBox(Map<T,?> map)
creates a PEComboBox (aka JComboBox) from an EnumMap. |
|
static JComboBox |
createComboBox(Object[] items)
creates a JComboBox |
|
static Line2D[] |
createFlattenedPath(Shape s,
double flatness)
Return an array of Line2D's representing the (visible part of the) flattened path of the given shape. |
|
static ImageIcon |
createImageIcon(String icon)
create an ImageIcon built from "/jpicedt/images/"+icon+".png" |
|
static JLabel |
createJLabel(String icon)
create a JLabel with an Icon built from "/jpicedt/images/"+icon+".png" |
|
static Shape[] |
createPath(Shape s)
Return an array of Line2D, Quad2D and Cubic2D, representing the (visible part of the) path of the given shape. |
|
static String |
doubleToString(double x)
Returns a string representation of the given double. |
|
static String |
doubleToString(Double x)
|
|
static String |
getIconLocation(String icon)
|
|
static 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 |
setAppIconToDefault(JFrame frame)
|
|
static int |
setImageIcon(JFrame frame,
String icon)
Configure l'icône du cadre frame à l'icône identifiée icon s'il est
possible de la trouver, ou sinon ne fait rien. |
|
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(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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PEToolKit()
Method Detail |
---|
public static void setMaximumFractionDigits(int n)
doubleToString()
method.
n
- set to a negative number to retrieve the default behaviourpublic static String doubleToString(double x)
setMaximumFractionDigits
beforehands.
public static String doubleToString(Double x)
public static String intToString(double x)
public static double[] minMaxArray(double[] array)
array
- an array of length greater than 0public static PicVector computeTangentToPath(Shape s, PicPoint pt, double maxDist)
This implementation relies on FlatteningPathIterator, hence the smaller the "maxDist" parameter, the better the return result.
s
- 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(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 Shape[] createPath(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 Line2D[] createFlattenedPath(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(Point2D p1, Point2D pCtrl1, Point2D pCtrl2, Point2D p2)
p1
- first cubic spline end-pointp2
- second cubic spline end-pointpCtrl1
- first cubic spline control-pointpCtrl2
- second cubic spline control-point
CubicCurve2D
,
QuadCurve2D
public static PicPoint[] convertQuadBezierToCubic(Point2D p1, Point2D pCtrl, 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-point
public static CubicCurve2D convertQuadBezierToCubic(QuadCurve2D quad)
public static QuadCurve2D[] convertCubicBezierToQuad(CubicCurve2D cubic)
public static String getIconLocation(String icon)
icon
- Le nom de base de la ressouce image contenant l'icône, sans l'extension .png
.
public static ImageIcon createImageIcon(String icon)
ImageIcon
built from "/jpicedt/images/"+icon+".png"
public static int setImageIcon(JFrame frame, String icon)
frame
à l'icône identifiée icon
s'il est
possible de la trouver, ou sinon ne fait rien.
public static void setAppIconToDefault(JFrame frame)
public static JLabel createJLabel(String icon)
public static JComboBox createComboBox(Object[] items)
public static <T> PEComboBox<T> createComboBox(Map<T,?> map)
|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |