PDF Clown
0.0.8

it.stefanochizzolini.clown.documents.contents.composition
Class PrimitiveFilter

java.lang.Object
  extended by it.stefanochizzolini.clown.documents.contents.composition.PrimitiveFilter

public class PrimitiveFilter
extends Object

Content stream primitive filter.

It provides the basic (primitive) operations described by the PDF specification for graphics content composition.

Remarks

This class leverages the object-oriented content stream modelling infrastructure, which encompasses 1st-level content stream objects (operations), 2nd-level content stream objects (graphics objects) and full graphics state support.

Since:
0.0.4
Version:
0.0.8
Author:
Stefano Chizzolini (http://www.stefanochizzolini.it)

Constructor Summary
PrimitiveFilter(ContentScanner scanner)
           
PrimitiveFilter(IContentContext context)
           
 
Method Summary
 ContentObject add(ContentObject object)
          Adds a content object.
 void applyMatrix(double a, double b, double c, double d, double e, double f)
          Applies a transformation to the coordinate system from user space to device space [PDF:1.6:4.3.3].
 CompositeObject begin(CompositeObject object)
          Adds a composite object beginning it.
 LocalGraphicsState beginLocalState()
          Begins a new nested graphics state context [PDF:1.6:4.3.1].
 MarkedContent beginMarkedContent(PdfName tag)
          Begins a new marked-content sequence [PDF:1.6:10.5].
 void clip()
          Modifies the current clipping path by intersecting it with the current path [PDF:1.6:4.4.1].
 void closePath()
          Closes the current subpath by appending a straight line segment from the current point to the starting point of the subpath [PDF:1.6:4.4.1].
 void drawArc(RectangularShape location, double startAngle, double endAngle)
          Draws a circular arc.
 void drawArc(RectangularShape location, double startAngle, double endAngle, double branchWidth, double branchRatio)
          Draws an arc.
 void drawCurve(Point2D endPoint, Point2D startControl, Point2D endControl)
          Draws a cubic Bezier curve from the current point [PDF:1.6:4.4.1].
 void drawCurve(Point2D startPoint, Point2D endPoint, Point2D startControl, Point2D endControl)
          Draws a cubic Bezier curve [PDF:1.6:4.4.1].
 void drawEllipse(RectangularShape location)
          Draws an ellipse.
 void drawLine(Point2D endPoint)
          Draws a line from the current point [PDF:1.6:4.4.1].
 void drawLine(Point2D startPoint, Point2D endPoint)
          Draws a line [PDF:1.6:4.4.1].
 void drawPolygon(Point2D[] points)
          Draws a polygon.
 void drawPolyline(Point2D[] points)
          Draws a multiple line.
 void drawRectangle(RectangularShape location)
          Draws a rectangle [PDF:1.6:4.4.1].
 void drawRectangle(RectangularShape location, double radius)
          Draws a rounded rectangle.
 void drawSpiral(Point2D center, double startAngle, double endAngle, double branchWidth, double branchRatio)
          Draws a spiral.
 void end()
          Ends the current (innermostly-nested) composite object.
 void fill()
          Fills the path using the current color [PDF:1.6:4.4.2].
 void fillStroke()
          Fills and then strokes the path using the current colors [PDF:1.6:4.4.2].
 void flush()
          Serializes the contents into the content stream.
 ContentScanner getScanner()
          Gets the content stream scanner.
 ContentScanner.GraphicsState getState()
          Gets the current graphics state [PDF:1.6:4.3].
 void rotate(double angle)
          Applies a rotation to the coordinate system from user space to device space [PDF:1.6:4.2.2].
 void rotate(double angle, Point2D origin)
          Applies a rotation to the coordinate system from user space to device space [PDF:1.6:4.2.2].
 void scale(double ratioX, double ratioY)
          Applies a scaling to the coordinate system from user space to device space [PDF:1.6:4.2.2].
 void setCharSpace(double value)
          Sets the character spacing parameter [PDF:1.6:5.2.1].
 void setFillColor(Color value)
          Sets the nonstroking color value [PDF:1.6:4.5.7].
 void setFont(Font value, double size)
          Sets the font [PDF:1.6:5.2].
 void setFont(PdfName name, double size)
          Sets the font [PDF:1.6:5.2].
 void setLineCap(LineCapEnum value)
          Sets the line cap style [PDF:1.6:4.3.2].
 void setLineDash(int phase, int unitsOn)
          Sets the line dash pattern [PDF:1.6:4.3.2].
 void setLineDash(int phase, int unitsOn, int unitsOff)
          Sets the line dash pattern [PDF:1.6:4.3.2].
 void setLineJoin(LineJoinEnum value)
          Sets the line join style [PDF:1.6:4.3.2].
 void setLineWidth(double value)
          Sets the line width [PDF:1.6:4.3.2].
 void setMatrix(double a, double b, double c, double d, double e, double f)
          Sets the transformation of the coordinate system from user space to device space [PDF:1.6:4.3.3].
 void setMiterLimit(double value)
          Sets the miter limit [PDF:1.6:4.3.2].
 void setScanner(ContentScanner value)
           
 void setStrokeColor(Color value)
          Sets the stroking color value [PDF:1.6:4.5.7].
 void setTextLead(double value)
          Sets the text leading [PDF:1.6:5.2.4].
 void setTextRenderMode(TextRenderModeEnum value)
          Sets the text rendering mode [PDF:1.6:5.2.5].
 void setTextRise(double value)
          Sets the text rise [PDF:1.6:5.2.6].
 void setTextScale(double value)
          Sets the text horizontal scaling [PDF:1.6:5.2.3].
 void setWordSpace(double value)
          Sets the word spacing [PDF:1.6:5.2.2].
 Point2D[] showText(String value)
          Shows the specified text on the page at the current location [PDF:1.6:5.3.2].
 Link showText(String value, Action action)
          Shows the link associated to the specified text on the page at the current location.
 Point2D[] showText(String value, Point2D location)
          Shows the specified text on the page at the specified location [PDF:1.6:5.3.2].
 Link showText(String value, Point2D location, Action action)
          Shows the link associated to the specified text on the page at the specified location.
 Point2D[] showText(String value, Point2D location, AlignmentXEnum alignmentX, AlignmentYEnum alignmentY, double rotation)
          Shows the specified text on the page at the specified location [PDF:1.6:5.3.2].
 Link showText(String value, Point2D location, AlignmentXEnum alignmentX, AlignmentYEnum alignmentY, double rotation, Action action)
          Shows the link associated to the specified text on the page at the specified location.
 void showXObject(PdfName name)
          Shows the specified external object [PDF:1.6:4.7].
 void showXObject(PdfName name, Point2D location)
          Shows the specified external object at the specified position [PDF:1.6:4.7].
 void showXObject(PdfName name, Point2D location, Dimension2D size)
          Shows the specified external object at the specified position [PDF:1.6:4.7].
 void showXObject(PdfName name, Point2D location, Dimension2D size, AlignmentXEnum alignmentX, AlignmentYEnum alignmentY, double rotation)
          Shows the specified external object at the specified position [PDF:1.6:4.7].
 void showXObject(XObject value)
          Shows the specified external object [PDF:1.6:4.7].
 void showXObject(XObject value, Point2D location)
          Shows the specified external object at the specified position [PDF:1.6:4.7].
 void showXObject(XObject value, Point2D location, Dimension2D size)
          Shows the specified external object at the specified position [PDF:1.6:4.7].
 void showXObject(XObject value, Point2D location, Dimension2D size, AlignmentXEnum alignmentX, AlignmentYEnum alignmentY, double rotation)
          Shows the specified external object at the specified position [PDF:1.6:4.7].
 void stroke()
          Strokes the path using the current color [PDF:1.6:4.4.2].
 void translate(double distanceX, double distanceY)
          Applies a translation to the coordinate system from user space to device space [PDF:1.6:4.2.2].
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrimitiveFilter

public PrimitiveFilter(ContentScanner scanner)

PrimitiveFilter

public PrimitiveFilter(IContentContext context)
Method Detail

add

public ContentObject add(ContentObject object)
Adds a content object.

Returns:
The added content object.

applyMatrix

public void applyMatrix(double a,
                        double b,
                        double c,
                        double d,
                        double e,
                        double f)
Applies a transformation to the coordinate system from user space to device space [PDF:1.6:4.3.3].

Remarks

The transformation is applied to the current transformation matrix (CTM) by concatenation, i.e. it doesn't replace it.

Parameters:
a - Item 0,0 of the matrix.
b - Item 0,1 of the matrix.
c - Item 1,0 of the matrix.
d - Item 1,1 of the matrix.
e - Item 2,0 of the matrix.
f - Item 2,1 of the matrix.
See Also:
setMatrix(double,double,double,double,double,double)

begin

public CompositeObject begin(CompositeObject object)
Adds a composite object beginning it.

Returns:
The added composite object.
See Also:
end()

beginLocalState

public LocalGraphicsState beginLocalState()
Begins a new nested graphics state context [PDF:1.6:4.3.1].

Returns:
The added local graphics state object.
See Also:
end()

beginMarkedContent

public MarkedContent beginMarkedContent(PdfName tag)
Begins a new marked-content sequence [PDF:1.6:10.5].

Returns:
The added marked-content sequence.
See Also:
end()

clip

public void clip()
Modifies the current clipping path by intersecting it with the current path [PDF:1.6:4.4.1].

Remarks

It can be validly called only just before painting the current path.


closePath

public void closePath()
Closes the current subpath by appending a straight line segment from the current point to the starting point of the subpath [PDF:1.6:4.4.1].


drawArc

public void drawArc(RectangularShape location,
                    double startAngle,
                    double endAngle)
Draws a circular arc.

Parameters:
location - Arc location.
startAngle - Starting angle.
endAngle - Ending angle.
Since:
0.0.7
See Also:
stroke()

drawArc

public void drawArc(RectangularShape location,
                    double startAngle,
                    double endAngle,
                    double branchWidth,
                    double branchRatio)
Draws an arc.

Parameters:
location - Arc location.
startAngle - Starting angle.
endAngle - Ending angle.
branchWidth - Distance between the spiral branches. '0' value degrades to a circular arc.
branchRatio - Linear coefficient applied to the branch width. '1' value degrades to a constant branch width.
Since:
0.0.7
See Also:
stroke()

drawCurve

public void drawCurve(Point2D endPoint,
                      Point2D startControl,
                      Point2D endControl)
Draws a cubic Bezier curve from the current point [PDF:1.6:4.4.1].

Parameters:
endPoint - Ending point.
startControl - Starting control point.
endControl - Ending control point.
Since:
0.0.7
See Also:
stroke()

drawCurve

public void drawCurve(Point2D startPoint,
                      Point2D endPoint,
                      Point2D startControl,
                      Point2D endControl)
Draws a cubic Bezier curve [PDF:1.6:4.4.1].

Parameters:
startPoint - Starting point.
endPoint - Ending point.
startControl - Starting control point.
endControl - Ending control point.
Since:
0.0.7
See Also:
stroke()

drawEllipse

public void drawEllipse(RectangularShape location)
Draws an ellipse.

Parameters:
location - Ellipse location.
Since:
0.0.7
See Also:
fill(), fillStroke(), stroke()

drawLine

public void drawLine(Point2D endPoint)
Draws a line from the current point [PDF:1.6:4.4.1].

Parameters:
endPoint - Ending point.
Since:
0.0.7
See Also:
stroke()

drawLine

public void drawLine(Point2D startPoint,
                     Point2D endPoint)
Draws a line [PDF:1.6:4.4.1].

Parameters:
startPoint - Starting point.
endPoint - Ending point.
Since:
0.0.7
See Also:
stroke()

drawPolygon

public void drawPolygon(Point2D[] points)
Draws a polygon.

Remarks

A polygon is the same as a multiple line except that it's a closed path.

Parameters:
points - Points.
Since:
0.0.7
See Also:
fill(), fillStroke(), stroke()

drawPolyline

public void drawPolyline(Point2D[] points)
Draws a multiple line.

Parameters:
points - Points.
Since:
0.0.7
See Also:
stroke()

drawRectangle

public void drawRectangle(RectangularShape location)
Draws a rectangle [PDF:1.6:4.4.1].

Parameters:
location - Rectangle location.
See Also:
fill(), fillStroke(), stroke()

drawRectangle

public void drawRectangle(RectangularShape location,
                          double radius)
Draws a rounded rectangle.

Parameters:
location - Rectangle location.
radius - Vertex radius, '0' value degrades to squared vertices.
See Also:
fill(), fillStroke(), stroke()

drawSpiral

public void drawSpiral(Point2D center,
                       double startAngle,
                       double endAngle,
                       double branchWidth,
                       double branchRatio)
Draws a spiral.

Parameters:
center - Spiral center.
startAngle - Starting angle.
endAngle - Ending angle.
branchWidth - Distance between the spiral branches.
branchRatio - Linear coefficient applied to the branch width.
Since:
0.0.7
See Also:
stroke()

end

public void end()
Ends the current (innermostly-nested) composite object.

See Also:
begin(CompositeObject)

fill

public void fill()
Fills the path using the current color [PDF:1.6:4.4.2].

See Also:
setFillColor(Color)

fillStroke

public void fillStroke()
Fills and then strokes the path using the current colors [PDF:1.6:4.4.2].

See Also:
setFillColor(Color), setStrokeColor(Color)

flush

public void flush()
Serializes the contents into the content stream.


getScanner

public ContentScanner getScanner()
Gets the content stream scanner.


getState

public ContentScanner.GraphicsState getState()
Gets the current graphics state [PDF:1.6:4.3].


rotate

public void rotate(double angle)
Applies a rotation to the coordinate system from user space to device space [PDF:1.6:4.2.2].

Parameters:
angle - Rotational counterclockwise angle.
See Also:
applyMatrix(double,double,double,double,double,double)

rotate

public void rotate(double angle,
                   Point2D origin)
Applies a rotation to the coordinate system from user space to device space [PDF:1.6:4.2.2].

Parameters:
angle - Rotational counterclockwise angle.
origin - Rotational pivot point; it becomes the new coordinates origin.
See Also:
applyMatrix(double,double,double,double,double,double)

scale

public void scale(double ratioX,
                  double ratioY)
Applies a scaling to the coordinate system from user space to device space [PDF:1.6:4.2.2].

Parameters:
ratioX - Horizontal scaling ratio.
ratioY - Vertical scaling ratio.
See Also:
applyMatrix(double,double,double,double,double,double)

setCharSpace

public void setCharSpace(double value)
Sets the character spacing parameter [PDF:1.6:5.2.1].


setFillColor

public void setFillColor(Color value)
Sets the nonstroking color value [PDF:1.6:4.5.7].

See Also:
setStrokeColor(Color)

setFont

public void setFont(PdfName name,
                    double size)
Sets the font [PDF:1.6:5.2].

Parameters:
name - Resource identifier of the font.
size - Scaling factor (points).

setFont

public void setFont(Font value,
                    double size)
Sets the font [PDF:1.6:5.2].

Remarks

The value is checked for presence in the current resource dictionary: if it isn't available, it's automatically added. If you need to avoid such a behavior, use setFont(PdfName,double).

Parameters:
value - Font.
size - Scaling factor (points).

setTextScale

public void setTextScale(double value)
Sets the text horizontal scaling [PDF:1.6:5.2.3].


setTextLead

public void setTextLead(double value)
Sets the text leading [PDF:1.6:5.2.4].


setLineCap

public void setLineCap(LineCapEnum value)
Sets the line cap style [PDF:1.6:4.3.2].


setLineDash

public void setLineDash(int phase,
                        int unitsOn)
Sets the line dash pattern [PDF:1.6:4.3.2].

Parameters:
phase - Distance into the dash pattern at which to start the dash.
unitsOn - Length of evenly alternating dashes and gaps.

setLineDash

public void setLineDash(int phase,
                        int unitsOn,
                        int unitsOff)
Sets the line dash pattern [PDF:1.6:4.3.2].

Parameters:
phase - Distance into the dash pattern at which to start the dash.
unitsOn - Length of dashes.
unitsOff - Length of gaps.

setLineJoin

public void setLineJoin(LineJoinEnum value)
Sets the line join style [PDF:1.6:4.3.2].


setLineWidth

public void setLineWidth(double value)
Sets the line width [PDF:1.6:4.3.2].


setMatrix

public void setMatrix(double a,
                      double b,
                      double c,
                      double d,
                      double e,
                      double f)
Sets the transformation of the coordinate system from user space to device space [PDF:1.6:4.3.3].

Remarks

The transformation replaces the current transformation matrix (CTM).

Parameters:
a - Item 0,0 of the matrix.
b - Item 0,1 of the matrix.
c - Item 1,0 of the matrix.
d - Item 1,1 of the matrix.
e - Item 2,0 of the matrix.
f - Item 2,1 of the matrix.
See Also:
applyMatrix(double,double,double,double,double,double)

setMiterLimit

public void setMiterLimit(double value)
Sets the miter limit [PDF:1.6:4.3.2].


setScanner

public void setScanner(ContentScanner value)
See Also:
getScanner()

setStrokeColor

public void setStrokeColor(Color value)
Sets the stroking color value [PDF:1.6:4.5.7].

See Also:
setFillColor(Color)

setTextRenderMode

public void setTextRenderMode(TextRenderModeEnum value)
Sets the text rendering mode [PDF:1.6:5.2.5].


setTextRise

public void setTextRise(double value)
Sets the text rise [PDF:1.6:5.2.6].


setWordSpace

public void setWordSpace(double value)
Sets the word spacing [PDF:1.6:5.2.2].


showText

public Point2D[] showText(String value)
Shows the specified text on the page at the current location [PDF:1.6:5.3.2].

Parameters:
value - Text to show.
Returns:
Bounding box vertices in default user space units.

showText

public Link showText(String value,
                     Action action)
Shows the link associated to the specified text on the page at the current location.

Parameters:
value - Text to show.
action - Action to apply when the link is activated.
Returns:
Link.
Since:
0.0.7

showText

public Point2D[] showText(String value,
                          Point2D location)
Shows the specified text on the page at the specified location [PDF:1.6:5.3.2].

Parameters:
value - Text to show.
location - Position at which showing the text.
Returns:
Bounding box vertices in default user space units.

showText

public Link showText(String value,
                     Point2D location,
                     Action action)
Shows the link associated to the specified text on the page at the specified location.

Parameters:
value - Text to show.
location - Position at which showing the text.
action - Action to apply when the link is activated.
Returns:
Link.
Since:
0.0.7

showText

public Point2D[] showText(String value,
                          Point2D location,
                          AlignmentXEnum alignmentX,
                          AlignmentYEnum alignmentY,
                          double rotation)
Shows the specified text on the page at the specified location [PDF:1.6:5.3.2].

Parameters:
value - Text to show.
location - Anchor position at which showing the text.
alignmentX - Horizontal alignment.
alignmentY - Vertical alignment.
rotation - Rotational counterclockwise angle.
Returns:
Bounding box vertices in default user space units.

showText

public Link showText(String value,
                     Point2D location,
                     AlignmentXEnum alignmentX,
                     AlignmentYEnum alignmentY,
                     double rotation,
                     Action action)
Shows the link associated to the specified text on the page at the specified location.

Parameters:
value - Text to show.
location - Anchor position at which showing the text.
alignmentX - Horizontal alignment.
alignmentY - Vertical alignment.
rotation - Rotational counterclockwise angle.
action - Action to apply when the link is activated.
Returns:
Link.
Since:
0.0.7

showXObject

public void showXObject(PdfName name)
Shows the specified external object [PDF:1.6:4.7].

Parameters:
name - Resource identifier of the external object.

showXObject

public void showXObject(XObject value)
Shows the specified external object [PDF:1.6:4.7].

Remarks

The value is checked for presence in the current resource dictionary: if it isn't available, it's automatically added. If you need to avoid such a behavior, use #showXObject(PdfName).

Parameters:
value - External object.
Since:
0.0.5

showXObject

public void showXObject(PdfName name,
                        Point2D location)
Shows the specified external object at the specified position [PDF:1.6:4.7].

Parameters:
name - Resource identifier of the external object.
location - Position at which showing the external object.

showXObject

public void showXObject(XObject value,
                        Point2D location)
Shows the specified external object at the specified position [PDF:1.6:4.7].

Remarks

The value is checked for presence in the current resource dictionary: if it isn't available, it's automatically added. If you need to avoid such a behavior, use #showXObject(PdfName,Point2D).

Parameters:
value - External object.
location - Position at which showing the external object.
Since:
0.0.5

showXObject

public void showXObject(PdfName name,
                        Point2D location,
                        Dimension2D size)
Shows the specified external object at the specified position [PDF:1.6:4.7].

Parameters:
name - Resource identifier of the external object.
location - Position at which showing the external object.
size - Size of the external object.
Since:
0.0.5

showXObject

public void showXObject(XObject value,
                        Point2D location,
                        Dimension2D size)
Shows the specified external object at the specified position [PDF:1.6:4.7].

Remarks

The value is checked for presence in the current resource dictionary: if it isn't available, it's automatically added. If you need to avoid such a behavior, use #showXObject(PdfName,Point2D,Dimension2D).

Parameters:
value - External object.
location - Position at which showing the external object.
size - Size of the external object.
Since:
0.0.5

showXObject

public void showXObject(PdfName name,
                        Point2D location,
                        Dimension2D size,
                        AlignmentXEnum alignmentX,
                        AlignmentYEnum alignmentY,
                        double rotation)
Shows the specified external object at the specified position [PDF:1.6:4.7].

Parameters:
name - Resource identifier of the external object.
location - Position at which showing the external object.
size - Size of the external object.
alignmentX - Horizontal alignment.
alignmentY - Vertical alignment.
rotation - Rotational counterclockwise angle.

showXObject

public void showXObject(XObject value,
                        Point2D location,
                        Dimension2D size,
                        AlignmentXEnum alignmentX,
                        AlignmentYEnum alignmentY,
                        double rotation)
Shows the specified external object at the specified position [PDF:1.6:4.7].

Remarks

The value is checked for presence in the current resource dictionary: if it isn't available, it's automatically added. If you need to avoid such a behavior, use #showXObject(PdfName,Point2D,Dimension2D,AlignmentXEnum,AlignmentYEnum,double).

Parameters:
value - External object.
location - Position at which showing the external object.
size - Size of the external object.
alignmentX - Horizontal alignment.
alignmentY - Vertical alignment.
rotation - Rotational counterclockwise angle.
Since:
0.0.5

stroke

public void stroke()
Strokes the path using the current color [PDF:1.6:4.4.2].

See Also:
setStrokeColor(Color)

translate

public void translate(double distanceX,
                      double distanceY)
Applies a translation to the coordinate system from user space to device space [PDF:1.6:4.2.2].

Parameters:
distanceX - Horizontal distance.
distanceY - Vertical distance.
See Also:
applyMatrix(double,double,double,double,double,double)

PDF Clown
0.0.8

Project home page

Copyright © 2006-2010 Stefano Chizzolini. Some Rights Reserved.
This documentation is available under the terms of the GNU Free Documentation License.