The AffineTransform class represents a 2D affine transform that performs a linear mapping from 2D coordinates to other 2D coordinates that preserves the "straightness" and "parallelness" of lines. Affine transformations can be constructed using sequences of translations, scales, flips, rotations, and shears.
Such a coordinate transformation can be represented by a 3 row by 3 column matrix with an implied last row of [ 0 0 1 ]. This matrix transforms source coordinates (x,y) into destination coordinates (x',y') by considering them to be a column vector and multiplying the coordinate vector by the matrix according to the following process:
[ x'] [ m00 m01 m02 ] [ x ] [ m00x m01y m02 ]
[ y'] = [ m10 m11 m12 ] [ y ] = [ m10x m11y m12 ]
[ 1 ] [ 0 0 1 ] [ 1 ] [ 1 ]
Handling 90-Degree Rotations
In some variations of the rotate methods in the AffineTransform class, a double-precision argument specifies the angle of rotation in radians. These methods have special handling for rotations of approximately 90 degrees (including multiples such as 180, 270, and 360 degrees), so that the common case of quadrant rotation is handled more efficiently. This special handling can cause angles very close to multiples of 90 degrees to be treated as if they were exact multiples of 90 degrees. For small multiples of 90 degrees the range of angles treated as a quadrant rotation is approximately 0.00000121 degrees wide. This section explains why such special care is needed and how it is implemented.
Since 90 degrees is represented as PI/2 in radians, and since PI is a transcendental (and therefore irrational) number, it is not possible to exactly represent a multiple of 90 degrees as an exact double precision value measured in radians. As a result it is theoretically impossible to describe quadrant rotations (90, 180, 270 or 360 degrees) using these values. Double precision floating point values can get very close to non-zero multiples of PI/2 but never close enough for the sine or cosine to be exactly 0.0, 1.0 or -1.0. The implementations of Math.sin() and Math.cos() correspondingly never return 0.0 for any case other than Math.sin(0.0). These same implementations do, however, return exactly 1.0 and -1.0 for some range of numbers around each multiple of 90 degrees since the correct answer is so close to 1.0 or -1.0 that the double precision significand cannot represent the difference as accurately as it can for numbers that are near 0.0.
The net result of these issues is that if the Math.sin() and Math.cos() methods are used to directly generate the values for the matrix modifications during these radian-based rotation operations then the resulting transform is never strictly classifiable as a quadrant rotation even for a simple case like rotate(Math.PI/2.0), due to minor variations in the matrix caused by the non-0.0 values obtained for the sine and cosine. If these transforms are not classified as quadrant rotations then subsequent code which attempts to optimize further operations based upon the type of the transform will be relegated to its most general implementation.
Because quadrant rotations are fairly common, this class should handle these cases reasonably quickly, both in applying the rotations to the transform and in applying the resulting transform to the coordinates. To facilitate this optimal handling, the methods which take an angle of rotation measured in radians attempt to detect angles that are intended to be quadrant rotations and treat them as such. These methods therefore treat an angle theta as a quadrant rotation if either Math.sin(theta) or Math.cos(theta) returns exactly 1.0 or -1.0. As a rule of thumb, this property holds true for a range of approximately 0.0000000211 radians (or 0.00000121 degrees) around small multiples of Math.PI/2.0.
The AffineTransform class represents a 2D affine transform that performs a linear mapping from 2D coordinates to other 2D coordinates that preserves the "straightness" and "parallelness" of lines. Affine transformations can be constructed using sequences of translations, scales, flips, rotations, and shears. Such a coordinate transformation can be represented by a 3 row by 3 column matrix with an implied last row of [ 0 0 1 ]. This matrix transforms source coordinates (x,y) into destination coordinates (x',y') by considering them to be a column vector and multiplying the coordinate vector by the matrix according to the following process: [ x'] [ m00 m01 m02 ] [ x ] [ m00x m01y m02 ] [ y'] = [ m10 m11 m12 ] [ y ] = [ m10x m11y m12 ] [ 1 ] [ 0 0 1 ] [ 1 ] [ 1 ] Handling 90-Degree Rotations In some variations of the rotate methods in the AffineTransform class, a double-precision argument specifies the angle of rotation in radians. These methods have special handling for rotations of approximately 90 degrees (including multiples such as 180, 270, and 360 degrees), so that the common case of quadrant rotation is handled more efficiently. This special handling can cause angles very close to multiples of 90 degrees to be treated as if they were exact multiples of 90 degrees. For small multiples of 90 degrees the range of angles treated as a quadrant rotation is approximately 0.00000121 degrees wide. This section explains why such special care is needed and how it is implemented. Since 90 degrees is represented as PI/2 in radians, and since PI is a transcendental (and therefore irrational) number, it is not possible to exactly represent a multiple of 90 degrees as an exact double precision value measured in radians. As a result it is theoretically impossible to describe quadrant rotations (90, 180, 270 or 360 degrees) using these values. Double precision floating point values can get very close to non-zero multiples of PI/2 but never close enough for the sine or cosine to be exactly 0.0, 1.0 or -1.0. The implementations of Math.sin() and Math.cos() correspondingly never return 0.0 for any case other than Math.sin(0.0). These same implementations do, however, return exactly 1.0 and -1.0 for some range of numbers around each multiple of 90 degrees since the correct answer is so close to 1.0 or -1.0 that the double precision significand cannot represent the difference as accurately as it can for numbers that are near 0.0. The net result of these issues is that if the Math.sin() and Math.cos() methods are used to directly generate the values for the matrix modifications during these radian-based rotation operations then the resulting transform is never strictly classifiable as a quadrant rotation even for a simple case like rotate(Math.PI/2.0), due to minor variations in the matrix caused by the non-0.0 values obtained for the sine and cosine. If these transforms are not classified as quadrant rotations then subsequent code which attempts to optimize further operations based upon the type of the transform will be relegated to its most general implementation. Because quadrant rotations are fairly common, this class should handle these cases reasonably quickly, both in applying the rotations to the transform and in applying the resulting transform to the coordinates. To facilitate this optimal handling, the methods which take an angle of rotation measured in radians attempt to detect angles that are intended to be quadrant rotations and treat them as such. These methods therefore treat an angle theta as a quadrant rotation if either Math.sin(theta) or Math.cos(theta) returns exactly 1.0 or -1.0. As a rule of thumb, this property holds true for a range of approximately 0.0000000211 radians (or 0.00000121 degrees) around small multiples of Math.PI/2.0.
Arc2D is the abstract superclass for all objects that store a 2D arc defined by a framing rectangle, start angle, angular extent (length of the arc), and a closure type (OPEN, CHORD, or PIE).
The arc is a partial section of a full ellipse which inscribes the framing rectangle of its parent RectangularShape.
The angles are specified relative to the non-square framing rectangle such that 45 degrees always falls on the line from the center of the ellipse to the upper right corner of the framing rectangle. As a result, if the framing rectangle is noticeably longer along one axis than the other, the angles to the start and end of the arc segment will be skewed farther along the longer axis of the frame.
The actual storage representation of the coordinates is left to the subclass.
Arc2D is the abstract superclass for all objects that store a 2D arc defined by a framing rectangle, start angle, angular extent (length of the arc), and a closure type (OPEN, CHORD, or PIE). The arc is a partial section of a full ellipse which inscribes the framing rectangle of its parent RectangularShape. The angles are specified relative to the non-square framing rectangle such that 45 degrees always falls on the line from the center of the ellipse to the upper right corner of the framing rectangle. As a result, if the framing rectangle is noticeably longer along one axis than the other, the angles to the start and end of the arc segment will be skewed farther along the longer axis of the frame. The actual storage representation of the coordinates is left to the subclass.
This class defines an arc specified in double precision.
This class defines an arc specified in double precision.
This class defines an arc specified in float precision.
This class defines an arc specified in float precision.
An Area object stores and manipulates a resolution-independent description of an enclosed area of 2-dimensional space. Area objects can be transformed and can perform various Constructive Area Geometry (CAG) operations when combined with other Area objects. The CAG operations include area addition, subtraction, intersection, and exclusive or. See the linked method documentation for examples of the various operations.
The Area class implements the Shape interface and provides full support for all of its hit-testing and path iteration facilities, but an Area is more specific than a generalized path in a number of ways:
Only closed paths and sub-paths are stored. Area objects constructed from unclosed paths are implicitly closed during construction as if those paths had been filled by the Graphics2D.fill method. The interiors of the individual stored sub-paths are all non-empty and non-overlapping. Paths are decomposed during construction into separate component non-overlapping parts, empty pieces of the path are discarded, and then these non-empty and non-overlapping properties are maintained through all subsequent CAG operations. Outlines of different component sub-paths may touch each other, as long as they do not cross so that their enclosed areas overlap. The geometry of the path describing the outline of the Area resembles the path from which it was constructed only in that it describes the same enclosed 2-dimensional area, but may use entirely different types and ordering of the path segments to do so.
Interesting issues which are not always obvious when using the Area include:
Creating an Area from an unclosed (open) Shape results in a closed outline in the Area object. Creating an Area from a Shape which encloses no area (even when "closed") produces an empty Area. A common example of this issue is that producing an Area from a line will be empty since the line encloses no area. An empty Area will iterate no geometry in its PathIterator objects. A self-intersecting Shape may be split into two (or more) sub-paths each enclosing one of the non-intersecting portions of the original path. An Area may take more path segments to describe the same geometry even when the original outline is simple and obvious. The analysis that the Area class must perform on the path may not reflect the same concepts of "simple and obvious" as a human being perceives.
An Area object stores and manipulates a resolution-independent description of an enclosed area of 2-dimensional space. Area objects can be transformed and can perform various Constructive Area Geometry (CAG) operations when combined with other Area objects. The CAG operations include area addition, subtraction, intersection, and exclusive or. See the linked method documentation for examples of the various operations. The Area class implements the Shape interface and provides full support for all of its hit-testing and path iteration facilities, but an Area is more specific than a generalized path in a number of ways: Only closed paths and sub-paths are stored. Area objects constructed from unclosed paths are implicitly closed during construction as if those paths had been filled by the Graphics2D.fill method. The interiors of the individual stored sub-paths are all non-empty and non-overlapping. Paths are decomposed during construction into separate component non-overlapping parts, empty pieces of the path are discarded, and then these non-empty and non-overlapping properties are maintained through all subsequent CAG operations. Outlines of different component sub-paths may touch each other, as long as they do not cross so that their enclosed areas overlap. The geometry of the path describing the outline of the Area resembles the path from which it was constructed only in that it describes the same enclosed 2-dimensional area, but may use entirely different types and ordering of the path segments to do so. Interesting issues which are not always obvious when using the Area include: Creating an Area from an unclosed (open) Shape results in a closed outline in the Area object. Creating an Area from a Shape which encloses no area (even when "closed") produces an empty Area. A common example of this issue is that producing an Area from a line will be empty since the line encloses no area. An empty Area will iterate no geometry in its PathIterator objects. A self-intersecting Shape may be split into two (or more) sub-paths each enclosing one of the non-intersecting portions of the original path. An Area may take more path segments to describe the same geometry even when the original outline is simple and obvious. The analysis that the Area class must perform on the path may not reflect the same concepts of "simple and obvious" as a human being perceives.
No vars found in this namespace.
The CubicCurve2D class defines a cubic parametric curve segment in (x,y) coordinate space.
This class is only the abstract superclass for all objects which store a 2D cubic curve segment. The actual storage representation of the coordinates is left to the subclass.
The CubicCurve2D class defines a cubic parametric curve segment in (x,y) coordinate space. This class is only the abstract superclass for all objects which store a 2D cubic curve segment. The actual storage representation of the coordinates is left to the subclass.
A cubic parametric curve segment specified with double coordinates.
A cubic parametric curve segment specified with double coordinates.
A cubic parametric curve segment specified with float coordinates.
A cubic parametric curve segment specified with float coordinates.
The Dimension2D class is to encapsulate a width and a height dimension.
This class is only the abstract superclass for all objects that store a 2D dimension. The actual storage representation of the sizes is left to the subclass.
The Dimension2D class is to encapsulate a width and a height dimension. This class is only the abstract superclass for all objects that store a 2D dimension. The actual storage representation of the sizes is left to the subclass.
The Ellipse2D class describes an ellipse that is defined by a framing rectangle.
This class is only the abstract superclass for all objects which store a 2D ellipse. The actual storage representation of the coordinates is left to the subclass.
The Ellipse2D class describes an ellipse that is defined by a framing rectangle. This class is only the abstract superclass for all objects which store a 2D ellipse. The actual storage representation of the coordinates is left to the subclass.
The Double class defines an ellipse specified in double precision.
The Double class defines an ellipse specified in double precision.
The Float class defines an ellipse specified in float precision.
The Float class defines an ellipse specified in float precision.
The FlatteningPathIterator class returns a flattened view of another PathIterator object. Other Shape classes can use this class to provide flattening behavior for their paths without having to perform the interpolation calculations themselves.
The FlatteningPathIterator class returns a flattened view of another PathIterator object. Other Shape classes can use this class to provide flattening behavior for their paths without having to perform the interpolation calculations themselves.
The GeneralPath class represents a geometric path constructed from straight lines, and quadratic and cubic (Bézier) curves. It can contain multiple subpaths.
GeneralPath is a legacy final class which exactly implements the behavior of its superclass Path2D.Float. Together with Path2D.Double, the Path2D classes provide full implementations of a general geometric path that support all of the functionality of the Shape and PathIterator interfaces with the ability to explicitly select different levels of internal coordinate precision.
Use Path2D.Float (or this legacy GeneralPath subclass) when dealing with data that can be represented and used with floating point precision. Use Path2D.Double for data that requires the accuracy or range of double precision.
The GeneralPath class represents a geometric path constructed from straight lines, and quadratic and cubic (Bézier) curves. It can contain multiple subpaths. GeneralPath is a legacy final class which exactly implements the behavior of its superclass Path2D.Float. Together with Path2D.Double, the Path2D classes provide full implementations of a general geometric path that support all of the functionality of the Shape and PathIterator interfaces with the ability to explicitly select different levels of internal coordinate precision. Use Path2D.Float (or this legacy GeneralPath subclass) when dealing with data that can be represented and used with floating point precision. Use Path2D.Double for data that requires the accuracy or range of double precision.
The IllegalPathStateException represents an exception that is thrown if an operation is performed on a path that is in an illegal state with respect to the particular operation being performed, such as appending a path segment to a GeneralPath without an initial moveto.
The IllegalPathStateException represents an exception that is thrown if an operation is performed on a path that is in an illegal state with respect to the particular operation being performed, such as appending a path segment to a GeneralPath without an initial moveto.
This Line2D represents a line segment in (x,y) coordinate space. This class, like all of the Java 2D API, uses a default coordinate system called user space in which the y-axis values increase downward and x-axis values increase to the right. For more information on the user space coordinate system, see the
Coordinate Systems section of the Java 2D Programmer's Guide.
This class is only the abstract superclass for all objects that store a 2D line segment. The actual storage representation of the coordinates is left to the subclass.
This Line2D represents a line segment in (x,y) coordinate space. This class, like all of the Java 2D API, uses a default coordinate system called user space in which the y-axis values increase downward and x-axis values increase to the right. For more information on the user space coordinate system, see the Coordinate Systems section of the Java 2D Programmer's Guide. This class is only the abstract superclass for all objects that store a 2D line segment. The actual storage representation of the coordinates is left to the subclass.
A line segment specified with double coordinates.
A line segment specified with double coordinates.
A line segment specified with float coordinates.
A line segment specified with float coordinates.
The NoninvertibleTransformException class represents an exception that is thrown if an operation is performed requiring the inverse of an AffineTransform object but the AffineTransform is in a non-invertible state.
The NoninvertibleTransformException class represents an exception that is thrown if an operation is performed requiring the inverse of an AffineTransform object but the AffineTransform is in a non-invertible state.
The Path2D class provides a simple, yet flexible shape which represents an arbitrary geometric path. It can fully represent any path which can be iterated by the PathIterator interface including all of its segment types and winding rules and it implements all of the basic hit testing methods of the Shape interface.
Use Path2D.Float when dealing with data that can be represented and used with floating point precision. Use Path2D.Double for data that requires the accuracy or range of double precision.
Path2D provides exactly those facilities required for basic construction and management of a geometric path and implementation of the above interfaces with little added interpretation. If it is useful to manipulate the interiors of closed geometric shapes beyond simple hit testing then the Area class provides additional capabilities specifically targeted at closed figures. While both classes nominally implement the Shape interface, they differ in purpose and together they provide two useful views of a geometric shape where Path2D deals primarily with a trajectory formed by path segments and Area deals more with interpretation and manipulation of enclosed regions of 2D geometric space.
The PathIterator interface has more detailed descriptions of the types of segments that make up a path and the winding rules that control how to determine which regions are inside or outside the path.
The Path2D class provides a simple, yet flexible shape which represents an arbitrary geometric path. It can fully represent any path which can be iterated by the PathIterator interface including all of its segment types and winding rules and it implements all of the basic hit testing methods of the Shape interface. Use Path2D.Float when dealing with data that can be represented and used with floating point precision. Use Path2D.Double for data that requires the accuracy or range of double precision. Path2D provides exactly those facilities required for basic construction and management of a geometric path and implementation of the above interfaces with little added interpretation. If it is useful to manipulate the interiors of closed geometric shapes beyond simple hit testing then the Area class provides additional capabilities specifically targeted at closed figures. While both classes nominally implement the Shape interface, they differ in purpose and together they provide two useful views of a geometric shape where Path2D deals primarily with a trajectory formed by path segments and Area deals more with interpretation and manipulation of enclosed regions of 2D geometric space. The PathIterator interface has more detailed descriptions of the types of segments that make up a path and the winding rules that control how to determine which regions are inside or outside the path.
The Double class defines a geometric path with coordinates stored in double precision floating point.
The Double class defines a geometric path with coordinates stored in double precision floating point.
The Float class defines a geometric path with coordinates stored in single precision floating point.
The Float class defines a geometric path with coordinates stored in single precision floating point.
The PathIterator interface provides the mechanism for objects that implement the Shape interface to return the geometry of their boundary by allowing a caller to retrieve the path of that boundary a segment at a time. This interface allows these objects to retrieve the path of their boundary a segment at a time by using 1st through 3rd order Bézier curves, which are lines and quadratic or cubic Bézier splines.
Multiple subpaths can be expressed by using a "MOVETO" segment to create a discontinuity in the geometry to move from the end of one subpath to the beginning of the next.
Each subpath can be closed manually by ending the last segment in the subpath on the same coordinate as the beginning "MOVETO" segment for that subpath or by using a "CLOSE" segment to append a line segment from the last point back to the first. Be aware that manually closing an outline as opposed to using a "CLOSE" segment to close the path might result in different line style decorations being used at the end points of the subpath. For example, the BasicStroke object uses a line "JOIN" decoration to connect the first and last points if a "CLOSE" segment is encountered, whereas simply ending the path on the same coordinate as the beginning coordinate results in line "CAP" decorations being used at the ends.
The PathIterator interface provides the mechanism for objects that implement the Shape interface to return the geometry of their boundary by allowing a caller to retrieve the path of that boundary a segment at a time. This interface allows these objects to retrieve the path of their boundary a segment at a time by using 1st through 3rd order Bézier curves, which are lines and quadratic or cubic Bézier splines. Multiple subpaths can be expressed by using a "MOVETO" segment to create a discontinuity in the geometry to move from the end of one subpath to the beginning of the next. Each subpath can be closed manually by ending the last segment in the subpath on the same coordinate as the beginning "MOVETO" segment for that subpath or by using a "CLOSE" segment to append a line segment from the last point back to the first. Be aware that manually closing an outline as opposed to using a "CLOSE" segment to close the path might result in different line style decorations being used at the end points of the subpath. For example, the BasicStroke object uses a line "JOIN" decoration to connect the first and last points if a "CLOSE" segment is encountered, whereas simply ending the path on the same coordinate as the beginning coordinate results in line "CAP" decorations being used at the ends.
The Point2D class defines a point representing a location in (x,y) coordinate space.
This class is only the abstract superclass for all objects that store a 2D coordinate. The actual storage representation of the coordinates is left to the subclass.
The Point2D class defines a point representing a location in (x,y) coordinate space. This class is only the abstract superclass for all objects that store a 2D coordinate. The actual storage representation of the coordinates is left to the subclass.
The Double class defines a point specified in double precision.
The Double class defines a point specified in double precision.
The Float class defines a point specified in float precision.
The Float class defines a point specified in float precision.
The QuadCurve2D class defines a quadratic parametric curve segment in (x,y) coordinate space.
This class is only the abstract superclass for all objects that store a 2D quadratic curve segment. The actual storage representation of the coordinates is left to the subclass.
The QuadCurve2D class defines a quadratic parametric curve segment in (x,y) coordinate space. This class is only the abstract superclass for all objects that store a 2D quadratic curve segment. The actual storage representation of the coordinates is left to the subclass.
A quadratic parametric curve segment specified with double coordinates.
A quadratic parametric curve segment specified with double coordinates.
A quadratic parametric curve segment specified with float coordinates.
A quadratic parametric curve segment specified with float coordinates.
The Rectangle2D class describes a rectangle defined by a location (x,y) and dimension (w x h).
This class is only the abstract superclass for all objects that store a 2D rectangle. The actual storage representation of the coordinates is left to the subclass.
The Rectangle2D class describes a rectangle defined by a location (x,y) and dimension (w x h). This class is only the abstract superclass for all objects that store a 2D rectangle. The actual storage representation of the coordinates is left to the subclass.
The Double class defines a rectangle specified in double coordinates.
The Double class defines a rectangle specified in double coordinates.
The Float class defines a rectangle specified in float coordinates.
The Float class defines a rectangle specified in float coordinates.
RectangularShape is the base class for a number of Shape objects whose geometry is defined by a rectangular frame. This class does not directly specify any specific geometry by itself, but merely provides manipulation methods inherited by a whole category of Shape objects. The manipulation methods provided by this class can be used to query and modify the rectangular frame, which provides a reference for the subclasses to define their geometry.
RectangularShape is the base class for a number of Shape objects whose geometry is defined by a rectangular frame. This class does not directly specify any specific geometry by itself, but merely provides manipulation methods inherited by a whole category of Shape objects. The manipulation methods provided by this class can be used to query and modify the rectangular frame, which provides a reference for the subclasses to define their geometry.
The RoundRectangle2D class defines a rectangle with rounded corners defined by a location (x,y), a dimension (w x h), and the width and height of an arc with which to round the corners.
This class is the abstract superclass for all objects that store a 2D rounded rectangle. The actual storage representation of the coordinates is left to the subclass.
The RoundRectangle2D class defines a rectangle with rounded corners defined by a location (x,y), a dimension (w x h), and the width and height of an arc with which to round the corners. This class is the abstract superclass for all objects that store a 2D rounded rectangle. The actual storage representation of the coordinates is left to the subclass.
The Double class defines a rectangle with rounded corners all specified in double coordinates.
The Double class defines a rectangle with rounded corners all specified in double coordinates.
The Float class defines a rectangle with rounded corners all specified in float coordinates.
The Float class defines a rectangle with rounded corners all specified in float coordinates.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close