Search this API

y.view
Class MutableGeneralPath

java.lang.Object
  extended by y.view.MutableGeneralPath
All Implemented Interfaces:
java.awt.Shape

public class MutableGeneralPath
extends java.lang.Object
implements java.awt.Shape

A flexible mutable version of GeneralPath using doubles. The flexibility of this class must be weighed against its higher memory consumption.

 
Your browser does not support SVG content.

Nested Class Summary
static interface MutableGeneralPath.Segment
          The interface used by all Segments / Operations in the MutableGeneralPath class
 
Constructor Summary
MutableGeneralPath()
          Create a new instance with no transform (identity).
MutableGeneralPath(java.awt.geom.AffineTransform trans)
          Creates a new instance using the given transform.
MutableGeneralPath(java.awt.geom.PathIterator pi)
          Creates a new instance using the given path iterator to initialize this instance from.
 
Method Summary
 void append(java.awt.geom.PathIterator pi)
          Appends the result of iterating over the given PathIterator to this instance
 void appendAndClear(MutableGeneralPath gp)
          Appends the given MutableGeneralPath instance to this instance and destroys the given instance O(1) operation.
 void clear()
          Clears the current path.
 MutableGeneralPath.Segment close()
          Appends a close operation to the end of this path.
 boolean contains(double x, double y)
           
 boolean contains(double x, double y, double w, double h)
           
 boolean contains(java.awt.geom.Point2D p)
           
 boolean contains(java.awt.geom.Rectangle2D r)
           
 MutableGeneralPath.Segment cubicTo(double x1, double y1, double x2, double y2, double x3, double y3)
          Appends a cubicTo operation to the end of this path using the given coordinates.
 MutableGeneralPath.Segment cubicTo(double x1, double y1, double x2, double y2, double x3, double y3, MutableGeneralPath.Segment nextSegment)
          Appends a cubicTo operation before the given segment using the given coordinates.
 MutableGeneralPath.Segment cubicTo(MutableGeneralPath.Segment prevSegment, double x1, double y1, double x2, double y2, double x3, double y3)
          Appends a cubicTo operation after the given segment using the given coordinates.
 MutableGeneralPath.Segment firstSegment()
          Returns the first Segment element in the path.
 java.awt.Rectangle getBounds()
           
 java.awt.geom.Rectangle2D getBounds2D()
           
 double getLastX()
          Returns the last x position added to this path.
 double getLastY()
          Returns the last y position added to this path.
 java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform a)
           
 java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform a, double flatness)
           
 int getWindingRule()
          See Path2D.getWindingRule()
 boolean intersects(double x, double y, double w, double h)
           
 boolean intersects(java.awt.geom.Rectangle2D r)
           
 boolean isClosed()
          Returns whether the last element is a close element.
 boolean isFlat()
          Returns whether this path is already flat, i.e. whether it does not contain any curves, but only moveTo, lineTo and close elements
 MutableGeneralPath.Segment lastSegment()
          Returns the last Segment element in the path.
 MutableGeneralPath.Segment lineTo(double x, double y)
          Appends a lineTo operation to the end of this path using the given coordinates.
 MutableGeneralPath.Segment lineTo(double x, double y, MutableGeneralPath.Segment nextSegment)
          Appends a lineTo operation before the given segment using the given coordinates.
 MutableGeneralPath.Segment lineTo(MutableGeneralPath.Segment prevSegment, double x, double y)
          Appends a lineTo operation after the given segment using the given coordinates.
 MutableGeneralPath.Segment moveTo(double x, double y)
          Appends a moveTo operation to the end of this path using the given coordinates.
 MutableGeneralPath.Segment moveTo(double x, double y, MutableGeneralPath.Segment nextSegment)
          Appends a moveTo operation before the given segment using the given coordinates.
 MutableGeneralPath.Segment moveTo(MutableGeneralPath.Segment prevSegment, double x, double y)
          Appends a moveTo operation after the given segment using the given coordinates.
 MutableGeneralPath.Segment quadTo(double x1, double y1, double x2, double y2)
          Appends a quadTo operation to the end of this path using the given coordinates.
 MutableGeneralPath.Segment quadTo(double x1, double y1, double x2, double y2, MutableGeneralPath.Segment nextSegment)
          Appends a quadTo operation before the given segment using the given coordinates.
 MutableGeneralPath.Segment quadTo(MutableGeneralPath.Segment prevSegment, double x1, double y1, double x2, double y2)
          Appends a quadTo operation after the given segment using the given coordinates.
 void remove(MutableGeneralPath.Segment s)
          Removes a given segment from the list of segments.
 void setWindingRule(int windingRule)
          See Path2D.setWindingRule(int)
 int size()
          Returns the number of elements this instance uses
 java.awt.geom.GeneralPath toGeneralPath()
          Creates a GeneralPath instance from this instance.
 java.awt.geom.GeneralPath toGeneralPath(java.awt.geom.AffineTransform a)
          Creates a GeneralPath instance from this instance using the given transform to transform.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MutableGeneralPath

public MutableGeneralPath()
Create a new instance with no transform (identity).


MutableGeneralPath

public MutableGeneralPath(java.awt.geom.AffineTransform trans)
Creates a new instance using the given transform.

Parameters:
trans - the transform to use for the pathIterators.

MutableGeneralPath

public MutableGeneralPath(java.awt.geom.PathIterator pi)
Creates a new instance using the given path iterator to initialize this instance from.

Parameters:
pi -
Method Detail

firstSegment

public MutableGeneralPath.Segment firstSegment()
Returns the first Segment element in the path.

Returns:
the first element or null if the path is empty.

lastSegment

public MutableGeneralPath.Segment lastSegment()
Returns the last Segment element in the path.

Returns:
the last element or null if the path is empty.

getLastX

public double getLastX()
Returns the last x position added to this path.

Returns:
the last x coordinate

getLastY

public double getLastY()
Returns the last y position added to this path.

Returns:
the last y coordinate

append

public void append(java.awt.geom.PathIterator pi)
Appends the result of iterating over the given PathIterator to this instance

Parameters:
pi -

size

public int size()
Returns the number of elements this instance uses

Returns:
the number of Segments

isFlat

public boolean isFlat()
Returns whether this path is already flat, i.e. whether it does not contain any curves, but only moveTo, lineTo and close elements

Returns:
whether the path is already flat

isClosed

public boolean isClosed()
Returns whether the last element is a close element.

Returns:
whether the last element is a close operation

appendAndClear

public void appendAndClear(MutableGeneralPath gp)
Appends the given MutableGeneralPath instance to this instance and destroys the given instance O(1) operation.

Parameters:
gp -

moveTo

public MutableGeneralPath.Segment moveTo(MutableGeneralPath.Segment prevSegment,
                                         double x,
                                         double y)
Appends a moveTo operation after the given segment using the given coordinates.

Parameters:
prevSegment - the segment after which the new segment should be added, if this is null the new segment will become the first segment.
Returns:
the newly created segment

lineTo

public MutableGeneralPath.Segment lineTo(MutableGeneralPath.Segment prevSegment,
                                         double x,
                                         double y)
Appends a lineTo operation after the given segment using the given coordinates.

Parameters:
prevSegment - the segment after which the new segment should be added, if this is null the new segment will become the first segment.
Returns:
the newly created segment

quadTo

public MutableGeneralPath.Segment quadTo(MutableGeneralPath.Segment prevSegment,
                                         double x1,
                                         double y1,
                                         double x2,
                                         double y2)
Appends a quadTo operation after the given segment using the given coordinates.

Parameters:
prevSegment - the segment after which the new segment should be added, if this is null the new segment will become the first segment.
Returns:
the newly created segment

cubicTo

public MutableGeneralPath.Segment cubicTo(MutableGeneralPath.Segment prevSegment,
                                          double x1,
                                          double y1,
                                          double x2,
                                          double y2,
                                          double x3,
                                          double y3)
Appends a cubicTo operation after the given segment using the given coordinates.

Parameters:
prevSegment - the segment after which the new segment should be added, if this is null the new segment will become the first segment.
Returns:
the newly created segment

quadTo

public MutableGeneralPath.Segment quadTo(double x1,
                                         double y1,
                                         double x2,
                                         double y2,
                                         MutableGeneralPath.Segment nextSegment)
Appends a quadTo operation before the given segment using the given coordinates.

Parameters:
nextSegment - the segment before which the new segment should be added, if this is null the new segment will become the last segment.
Returns:
the newly created segment

cubicTo

public MutableGeneralPath.Segment cubicTo(double x1,
                                          double y1,
                                          double x2,
                                          double y2,
                                          double x3,
                                          double y3,
                                          MutableGeneralPath.Segment nextSegment)
Appends a cubicTo operation before the given segment using the given coordinates.

Parameters:
nextSegment - the segment before which the new segment should be added, if this is null the new segment will become the last segment.
Returns:
the newly created segment

moveTo

public MutableGeneralPath.Segment moveTo(double x,
                                         double y,
                                         MutableGeneralPath.Segment nextSegment)
Appends a moveTo operation before the given segment using the given coordinates.

Parameters:
nextSegment - the segment before which the new segment should be added, if this is null the new segment will become the last segment.
Returns:
the newly created segment

lineTo

public MutableGeneralPath.Segment lineTo(double x,
                                         double y,
                                         MutableGeneralPath.Segment nextSegment)
Appends a lineTo operation before the given segment using the given coordinates.

Parameters:
nextSegment - the segment before which the new segment should be added, if this is null the new segment will become the last segment.
Returns:
the newly created segment

moveTo

public MutableGeneralPath.Segment moveTo(double x,
                                         double y)
Appends a moveTo operation to the end of this path using the given coordinates.

Returns:
the newly created segment

lineTo

public MutableGeneralPath.Segment lineTo(double x,
                                         double y)
Appends a lineTo operation to the end of this path using the given coordinates.

Returns:
the newly created segment

close

public MutableGeneralPath.Segment close()
Appends a close operation to the end of this path.

Returns:
the newly created segment

cubicTo

public MutableGeneralPath.Segment cubicTo(double x1,
                                          double y1,
                                          double x2,
                                          double y2,
                                          double x3,
                                          double y3)
Appends a cubicTo operation to the end of this path using the given coordinates.

Returns:
the newly created segment

quadTo

public MutableGeneralPath.Segment quadTo(double x1,
                                         double y1,
                                         double x2,
                                         double y2)
Appends a quadTo operation to the end of this path using the given coordinates.

Returns:
the newly created segment

remove

public void remove(MutableGeneralPath.Segment s)
Removes a given segment from the list of segments.


clear

public void clear()
Clears the current path.


getWindingRule

public int getWindingRule()
See Path2D.getWindingRule()


setWindingRule

public void setWindingRule(int windingRule)
See Path2D.setWindingRule(int)


toGeneralPath

public java.awt.geom.GeneralPath toGeneralPath(java.awt.geom.AffineTransform a)
Creates a GeneralPath instance from this instance using the given transform to transform.

Parameters:
a - the transform to apply before creating the GeneralPath instance.
Returns:
a newly created GeneralPath

toGeneralPath

public java.awt.geom.GeneralPath toGeneralPath()
Creates a GeneralPath instance from this instance.

Returns:
a newly created GeneralPath

getPathIterator

public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform a)
Specified by:
getPathIterator in interface java.awt.Shape

getPathIterator

public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform a,
                                                  double flatness)
Specified by:
getPathIterator in interface java.awt.Shape

contains

public boolean contains(java.awt.geom.Rectangle2D r)
Specified by:
contains in interface java.awt.Shape

contains

public boolean contains(java.awt.geom.Point2D p)
Specified by:
contains in interface java.awt.Shape

contains

public boolean contains(double x,
                        double y)
Specified by:
contains in interface java.awt.Shape

contains

public boolean contains(double x,
                        double y,
                        double w,
                        double h)
Specified by:
contains in interface java.awt.Shape

getBounds

public java.awt.Rectangle getBounds()
Specified by:
getBounds in interface java.awt.Shape

getBounds2D

public java.awt.geom.Rectangle2D getBounds2D()
Specified by:
getBounds2D in interface java.awt.Shape

intersects

public boolean intersects(java.awt.geom.Rectangle2D r)
Specified by:
intersects in interface java.awt.Shape

intersects

public boolean intersects(double x,
                          double y,
                          double w,
                          double h)
Specified by:
intersects in interface java.awt.Shape

© Copyright 2000-2022,
yWorks GmbH.
All rights reserved.