Package com.twelvemonkeys.imageio.path
Class AdobePathWriter
- java.lang.Object
-
- com.twelvemonkeys.imageio.path.AdobePathWriter
-
public final class AdobePathWriter extends java.lang.Object
Writes aShape
object to an Adobe Photoshop Path or Path resource.- See Also:
- Adobe Photoshop Path resource format
-
-
Field Summary
Fields Modifier and Type Field Description private static double
COLLINEARITY_THRESHOLD
private java.util.List<AdobePathSegment>
segments
-
Constructor Summary
Constructors Constructor Description AdobePathWriter(java.awt.Shape path)
Creates an AdobePathWriter for the given path.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static void
close(AdobePathSegment initial, AdobePathSegment prev, java.util.List<AdobePathSegment> subpath, java.util.List<AdobePathSegment> segments)
private static boolean
isCollinear(double x1, double y1, double x2, double y2, double x3, double y3)
private static java.util.List<AdobePathSegment>
pathToSegments(java.awt.geom.PathIterator pathIterator)
byte[]
writePath()
Transforms the path to a byte array, containing a set of Adobe Photoshop path segments.void
writePath(java.io.DataOutput output)
Writes the path as a set of Adobe Photoshop path segments to the given stream.byte[]
writePathResource(int resourceId)
Transforms the path to a byte array, containing a complete Adobe Photoshop path resource.void
writePathResource(int resourceId, java.io.DataOutput output)
Writes the path as a complete Adobe Photoshop clipping path resource to the given stream.
-
-
-
Field Detail
-
COLLINEARITY_THRESHOLD
private static final double COLLINEARITY_THRESHOLD
- See Also:
- Constant Field Values
-
segments
private final java.util.List<AdobePathSegment> segments
-
-
Constructor Detail
-
AdobePathWriter
public AdobePathWriter(java.awt.Shape path)
Creates an AdobePathWriter for the given path.NOTE: Photoshop paths are stored with the coordinates (0,0) representing the top left corner of the image, and (1,1) representing the bottom right corner, regardless of image dimensions.
- Parameters:
path
- AShape
instance that hasWIND_EVEN_ODD
rule, is contained within the rectangle [x=0.0,y=0.0,w=1.0,h=1.0], and is closed.- Throws:
java.lang.IllegalArgumentException
- ifpath
isnull
, the paths winding rule is not @link Path2D#WIND_EVEN_ODD} or the paths bounding box is outside [x=0.0,y=0.0,w=1.0,h=1.0] or the path is not closed.
-
-
Method Detail
-
pathToSegments
private static java.util.List<AdobePathSegment> pathToSegments(java.awt.geom.PathIterator pathIterator)
-
close
private static void close(AdobePathSegment initial, AdobePathSegment prev, java.util.List<AdobePathSegment> subpath, java.util.List<AdobePathSegment> segments)
-
isCollinear
private static boolean isCollinear(double x1, double y1, double x2, double y2, double x3, double y3)
-
writePathResource
public void writePathResource(int resourceId, java.io.DataOutput output) throws java.io.IOException
Writes the path as a complete Adobe Photoshop clipping path resource to the given stream.- Parameters:
resourceId
- the resource id, typicallyPSD.RES_CLIPPING_PATH
(0x07D0).output
- the stream to write to.- Throws:
java.io.IOException
- if an I/O exception happens during writing.
-
writePath
public void writePath(java.io.DataOutput output) throws java.io.IOException
Writes the path as a set of Adobe Photoshop path segments to the given stream.- Parameters:
output
- the stream to write to.- Throws:
java.io.IOException
- if an I/O exception happens during writing.
-
writePathResource
public byte[] writePathResource(int resourceId)
Transforms the path to a byte array, containing a complete Adobe Photoshop path resource.- Parameters:
resourceId
- the resource id, typicallyPSD.RES_CLIPPING_PATH
(0x07D0).- Returns:
- a new byte array, containing the clipping path resource.
-
writePath
public byte[] writePath()
Transforms the path to a byte array, containing a set of Adobe Photoshop path segments.- Returns:
- a new byte array, containing the path segments.
-
-