|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.davisor.graphics.BetterPath
BetterPath implements an improved serializable general path shape. These better paths have also a well-defined string representation, and there is a parser that can read such path definition strings.
Path representation conversions between shapes and segments occur in lazy and cached fashion. This minimizes memory and processors resource consumption overhead.
createSegments(String,ParsePosition),
toString(),
Serialized Form
| Nested Class Summary | |
protected class |
BetterPath.Iterator
BetterPath.Iterator implements a path iterator for the principal shape path storage mechanism. |
protected class |
BetterPath.Segment
BetterPath.Segment implements a path segment for the principal shape path storage mechanism. |
| Field Summary | |
static char |
ARCABSOLUTE
Segment absolute arc code character ('A'). |
static char |
ARCRELATIVE
Segment relative arc code character ('a'). |
static char |
CARRIAGERETURN
Carriage return character. |
static char |
CLOSEABSOLUTE
Segment absolute close code character ('Z'). |
static char |
CLOSERELATIVE
Segment relative close code character ('z'). |
static char |
COMMA
Comma character. |
static char |
CURVEABSOLUTE
Segment absolute curve code character ('C'). |
static char |
CURVERELATIVE
Segment relative curve code character ('c'). |
static char |
EVENODD
EvenOdd winding rule code character ('%'). |
static char |
HORIZONTALLINEABSOLUTE
Segment absolute horizontal line character ('H') |
static char |
HORIZONTALLINERELATIVE
Segment relative horizontal line character ('h') |
static char |
LINEABSOLUTE
Segment absolute line code character ('L'). |
static char |
LINERELATIVE
Segment relative line code character ('l'). |
protected int |
M_character
Current character in parsing. |
protected double |
M_currentX
Current X-coordinate. |
protected double |
M_currentY
Current Y-coordinate. |
protected double |
M_lastMoveToX
Last moveTo X-coordinate. |
protected double |
M_lastMoveToY
Last moveTo Y-coordinate. |
protected java.io.Reader |
M_reader
Reader for character parsing. |
protected java.util.List |
M_segments
Principal shape path storage. |
protected java.awt.Shape |
M_shape
Secondary shape path storage. |
protected double |
M_smoothX
Reference X-coordinate for smooth curves. |
protected double |
M_smoothY
Reference Y-coordinate for smooth curves. |
protected int |
M_windingRule
Shape winding rule. |
static char |
MOVEABSOLUTE
Segment absolute move code character ('M'). |
static char |
MOVERELATIVE
Segment relative move code character ('m'). |
static char |
NEWLINE
Newline character. |
static char |
NONZERO
NonZero winding rule code character ('/'). |
static char |
QUADABSOLUTE
Segment absolute quad code character ('Q'). |
static char |
QUADRELATIVE
Segment relative quad code character ('q'). |
static char |
SMOOTHCURVEABSOLUTE
Segment absolute smooth curve code character ('S'). |
static char |
SMOOTHCURVERELATIVE
Segment relative smooth curve code character ('s'). |
static char |
SMOOTHQUADABSOLUTE
Segment absolute smooth quad code character ('T'). |
static char |
SMOOTHQUADRELATIVE
Segment relative smooth quad code character ('t'). |
static char |
SPACE
Space character. |
static char |
TAB
Tab character. |
static char |
VERTICALLINEABSOLUTE
Segment absolute vertical line character ('V') |
static char |
VERTICALLINERELATIVE
Segment relative vertical line character ('v') |
| Fields inherited from interface com.davisor.graphics.ParameterConstants |
ANNOTATIONADDRESS, ANNOTATIONCOORDS, ANNOTATIONDESCRIPTION, ANNOTATIONDESCRIPTION_MOZILLA, ANNOTATIONONMOUSEOUT, ANNOTATIONONMOUSEOVER, ANNOTATIONSEPARATOR, ANNOTATIONSHAPE, ANNOTATIONTARGET, CENTER, DOWN, FIELDSEPARATOR, LEFT, RIGHT, TAILSEPARATOR, TERMINAL, UNSET, UP, VALUESEPARATOR |
| Constructor Summary | |
BetterPath(java.awt.geom.PathIterator iterator)
Extracts path information from a path iterator. |
|
BetterPath(java.awt.Shape shape)
Creates a better path from given shape. |
|
BetterPath(java.lang.String parameters,
java.text.ParsePosition status)
Extracts path information from a path specification string. |
|
| Method Summary | |
protected void |
closePath()
Closes the current path. |
boolean |
contains(double x,
double y)
Tests if the specified coordinates are inside the boundary of the Shape. |
boolean |
contains(double x,
double y,
double w,
double h)
Tests if the interior of the Shape entirely contains the specified rectangular area. |
boolean |
contains(java.awt.geom.Point2D p)
Tests if a specified Point2D is inside the boundary of the Shape. |
boolean |
contains(java.awt.geom.Rectangle2D r)
Tests if the interior of the Shape entirely contains the specified Rectangle2D. |
protected void |
createSegments(java.awt.geom.PathIterator iterator)
Extracts path information from a path iterator. |
protected void |
createSegments(java.awt.Shape shape)
Extracts path information from a shape. |
protected void |
createSegments(java.lang.String path,
java.text.ParsePosition status)
Extracts path information from a path specification string. |
protected double |
determineNumber()
Parses a number. |
boolean |
equals(java.lang.Object object)
Tests if this path buffer is equal to given path buffer. |
java.awt.Rectangle |
getBounds()
Returns an integer Rectangle that completely encloses the Shape. |
java.awt.geom.Rectangle2D |
getBounds2D()
Returns a high precision and more accurate bounding box of the Shape than the getBounds method. |
java.awt.geom.PathIterator |
getPathIterator(java.awt.geom.AffineTransform at)
Returns an iterator object that iterates along the Shape boundary and provides access to the geometry of the Shape outline. |
java.awt.geom.PathIterator |
getPathIterator(java.awt.geom.AffineTransform at,
double flatness)
Returns an iterator object that iterates along the Shape boundary and provides access to a flattened view of the Shape outline geometry. |
java.awt.geom.PathIterator |
getPathIterator(boolean reverse)
Returns an iterator object that iterates along the Shape boundary and provides access to the geometry of the Shape outline. |
protected java.util.List |
getSegments()
Gets path segments representing the current path. |
java.awt.Shape |
getShape()
Gets a shape representing the current path. |
boolean |
intersects(double x,
double y,
double w,
double h)
Tests if the interior of the Shape intersects the interior of a specified rectangular area. |
boolean |
intersects(java.awt.geom.Rectangle2D r)
Tests if the interior of the Shape intersects the interior of a specified Rectangle2D. |
protected void |
parseArcAbsolute()
Parses an absolute arc command. |
protected void |
parseArcRelative()
Parses a relative arc command. |
protected void |
parseCurveAbsolute()
Parses an absolute curve command. |
protected void |
parseCurveRelative()
Parses a relative curve command. |
protected void |
parseHorizontalLineAbsolute()
Parses an absolute horizontal line command. |
protected void |
parseHorizontalLineRelative()
Parses a relative horizontal line command. |
protected void |
parseLineAbsolute()
Parses an absolute line command. |
protected void |
parseLineRelative()
Parses a relative line command. |
protected void |
parseMoveAbsolute()
Parses an absolute move command. |
protected void |
parseMoveRelative()
Parses a relative move command. |
protected void |
parseQuadAbsolute()
Parses an absolute quad command. |
protected void |
parseQuadRelative()
Parses a relative quad command. |
protected void |
parseSmoothCurveAbsolute()
Parses an absolute smooth curve command. |
protected void |
parseSmoothCurveRelative()
Parses a relative smooth curve command. |
protected void |
parseSmoothQuadAbsolute()
Parses an absolute smooth quad command. |
protected void |
parseSmoothQuadRelative()
Parses a relative smooth quad command. |
protected void |
parseVerticalLineAbsolute()
Parses an absolute vertical line command. |
protected void |
parseVerticalLineRelative()
Parses a relative vertical line command. |
protected static int |
points(int type)
Gets the number of points associated to a path iterator segment. |
protected static char |
prefix(int type)
Gets the prefix character associated to a path iterator segment type. |
protected void |
skipSpaces()
Skips the following characters: 0x9 - tab 0xA - newline 0xD - carriage return 0x20 - space |
protected void |
skipSpacesAndComma()
Skips a sequence of characters. |
java.lang.String |
toString()
Gets the string representatin of the current path. |
protected static int |
toWinding(char ruleCharacter)
Gets the winding rule code for given winding rule code character. |
protected static char |
toWinding(int ruleCode)
Gets the winding rule code character for given winding rule code. |
protected static int |
type(char prefix)
Gets the segment type associated to a path specification segment prefix character . |
protected java.lang.Object |
writeReplace()
Ensures the presense of a serializable segment representation of the current shape. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected java.util.List M_segments
protected int M_windingRule
protected int M_character
protected java.io.Reader M_reader
protected double M_currentX
protected double M_currentY
protected double M_smoothX
protected double M_smoothY
protected double M_lastMoveToX
protected double M_lastMoveToY
public static final char ARCABSOLUTE
public static final char ARCRELATIVE
public static final char CLOSEABSOLUTE
public static final char CLOSERELATIVE
public static final char CURVEABSOLUTE
public static final char CURVERELATIVE
public static final char HORIZONTALLINEABSOLUTE
public static final char HORIZONTALLINERELATIVE
public static final char LINEABSOLUTE
public static final char LINERELATIVE
public static final char MOVEABSOLUTE
public static final char MOVERELATIVE
public static final char QUADABSOLUTE
public static final char QUADRELATIVE
public static final char SMOOTHCURVEABSOLUTE
public static final char SMOOTHCURVERELATIVE
public static final char SMOOTHQUADABSOLUTE
public static final char SMOOTHQUADRELATIVE
public static final char VERTICALLINEABSOLUTE
public static final char VERTICALLINERELATIVE
public static final char SPACE
public static final char CARRIAGERETURN
public static final char NEWLINE
public static final char TAB
public static final char COMMA
public static final char EVENODD
public static final char NONZERO
protected transient java.awt.Shape M_shape
| Constructor Detail |
public BetterPath(java.awt.Shape shape)
shape - the shape to create a better path from (may be null)BetterPath(PathIterator)public BetterPath(java.awt.geom.PathIterator iterator)
iterator - the iterator to extract path information from
(may be null)createSegments(PathIterator)
public BetterPath(java.lang.String parameters,
java.text.ParsePosition status)
throws InvalidDataException
createSegments(String,ParsePosition)| Method Detail |
public boolean equals(java.lang.Object object)
public java.lang.String toString()
getSegments(),
toWinding(int),
BetterPath.Segment.toString()
protected void closePath()
throws java.io.IOException
java.io.IOExceptionprotected void createSegments(java.awt.geom.PathIterator iterator)
null
or empty, the current path will be, too.
iterator - the iterator to extract path information from
(may be null)createSegments(String,ParsePosition)protected void createSegments(java.awt.Shape shape)
null or empty, the
current path will be, too.
shape - the shape to extract path information from
(may be null)createSegments(PathIterator)
protected void createSegments(java.lang.String path,
java.text.ParsePosition status)
throws java.io.IOException,
InvalidDataException
null or
empty, the current path will be, too.
Please see class description for more information about shape string syntax.
path - path specification string (may be null)status - parse status (may be null)
java.io.IOException
InvalidDataExceptioncreateSegments(PathIterator),
toString()
protected double determineNumber()
throws java.io.IOException,
InvalidDataException
java.io.IOException
InvalidDataExceptionprotected java.util.List getSegments()
null if not definedcreateSegments(PathIterator),
getShape()
protected void parseArcAbsolute()
throws java.io.IOException,
InvalidDataException
java.io.IOException
InvalidDataException
protected void parseArcRelative()
throws java.io.IOException,
InvalidDataException
java.io.IOException
InvalidDataException
protected void parseCurveAbsolute()
throws java.io.IOException,
InvalidDataException
java.io.IOException
InvalidDataException
protected void parseCurveRelative()
throws java.io.IOException,
InvalidDataException
java.io.IOException
InvalidDataException
protected void parseHorizontalLineAbsolute()
throws java.io.IOException,
InvalidDataException
java.io.IOException
InvalidDataException
protected void parseHorizontalLineRelative()
throws java.io.IOException,
InvalidDataException
java.io.IOException
InvalidDataException
protected void parseLineAbsolute()
throws java.io.IOException,
InvalidDataException
java.io.IOException
InvalidDataException
protected void parseLineRelative()
throws java.io.IOException,
InvalidDataException
java.io.IOException
InvalidDataException
protected void parseMoveAbsolute()
throws java.io.IOException,
InvalidDataException
Line command is considered to be relative if given without a command character and after a move, absolute or relative, command.
java.io.IOException
InvalidDataException
protected void parseMoveRelative()
throws java.io.IOException,
InvalidDataException
Line command is considered to be relative if given without a command character and after a move, absolute or relative, command.
java.io.IOException
InvalidDataException
protected void parseQuadAbsolute()
throws java.io.IOException,
InvalidDataException
java.io.IOException
InvalidDataException
protected void parseQuadRelative()
throws java.io.IOException,
InvalidDataException
java.io.IOException
InvalidDataException
protected void parseSmoothCurveAbsolute()
throws java.io.IOException,
InvalidDataException
java.io.IOException
InvalidDataException
protected void parseSmoothCurveRelative()
throws java.io.IOException,
InvalidDataException
java.io.IOException
InvalidDataException
protected void parseSmoothQuadAbsolute()
throws java.io.IOException,
InvalidDataException
java.io.IOException
InvalidDataException
protected void parseSmoothQuadRelative()
throws java.io.IOException,
InvalidDataException
java.io.IOException
InvalidDataException
protected void parseVerticalLineAbsolute()
throws java.io.IOException,
InvalidDataException
java.io.IOException
InvalidDataException
protected void parseVerticalLineRelative()
throws java.io.IOException,
InvalidDataException
java.io.IOException
InvalidDataExceptionprotected static int points(int type)
type - path iterator segment typeprotected static char prefix(int type)
PathIterator.SEG_MOVETO (M)
PathIterator.SEG_LINETO (L)
PathIterator.SEG_QUADTO (Q)
PathIterator.SEG_CUBICTO (C)
PathIterator.CLOSE (Z)
type - path iterator segment typetype(char)
protected void skipSpaces()
throws java.io.IOException
java.io.IOException
protected void skipSpacesAndComma()
throws java.io.IOException
Characters that are skipped within spaces are the ones
skipped with skipSpaces() method.
java.io.IOException
protected static int toWinding(char ruleCharacter)
throws com.davisor.core.InvalidParameterException
ruleCharacter - winding rule code character
com.davisor.core.InvalidParameterException - if rule character is invalidtoWinding(int)protected static char toWinding(int ruleCode)
PathIterator.WIND_EVEN_ODD
PathIterator.WIND_NON_ZERO
ruleCode - winding rule code
toWinding(char)protected static int type(char prefix)
C (PathIterator.SEG_CUBICTO)
L (PathIterator.SEG_LINETO)
M (PathIterator.SEG_MOVETO)
Q (PathIterator.SEG_QUADTO)
Z (PathIterator.CLOSE)
prefix - path specification segment prefix charactertype(char)public java.awt.geom.PathIterator getPathIterator(boolean reverse)
Reverse iteration is currently only partially implemented: in particular, paths that contain curved segments are not guaranteed to work properly.
reverse - reverse iteration direction, or notpublic java.awt.Shape getShape()
null if not definedgetPathIterator(AffineTransform),
getSegments()
protected java.lang.Object writeReplace()
throws java.io.ObjectStreamException
java.io.ObjectStreamExceptioncreateSegments(java.awt.geom.PathIterator)
public boolean contains(double x,
double y)
contains in interface java.awt.ShapegetShape()
public boolean contains(double x,
double y,
double w,
double h)
contains in interface java.awt.ShapegetShape()public boolean contains(java.awt.geom.Point2D p)
contains in interface java.awt.ShapegetShape()public boolean contains(java.awt.geom.Rectangle2D r)
contains in interface java.awt.ShapegetShape()public java.awt.Rectangle getBounds()
getBounds in interface java.awt.ShapegetShape()public java.awt.geom.Rectangle2D getBounds2D()
getBounds2D in interface java.awt.ShapegetShape()public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at)
getPathIterator in interface java.awt.ShapegetShape()
public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at,
double flatness)
getPathIterator in interface java.awt.ShapegetShape()
public boolean intersects(double x,
double y,
double w,
double h)
intersects in interface java.awt.ShapegetShape()public boolean intersects(java.awt.geom.Rectangle2D r)
intersects in interface java.awt.ShapegetShape()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||