org.foray.pdf
Class PDFGraphicsState

java.lang.Object
  extended by org.foray.pdf.PDFGraphicsState

public class PDFGraphicsState
extends Object

Represents a PDF Graphics State object. The Graphics State is ordinarily used by PDF viewer applications. Our application is instead a PDF writing application. However keeping track of the Graphics State is useful because it allows us to avoid writing operators that change the Graphics State unnecessarily.


Field Summary
static float INITIAL_HORIZONTAL_SCALING
          Constant for the initial horizontal scaling percentage, that is 100%.
 
Constructor Summary
PDFGraphicsState()
          Create a PDFGraphicsState instance.
PDFGraphicsState(PDFGraphicsState existingState)
          Creates a new PDFGraphicsState instance, initilializing its values to those of an existing instance.
 
Method Summary
 Color getFillColor()
          Returns the "non-stroke" or "other" color.
 org.axsl.pdf.PdfFont getFont()
          Returns the font.
 float getFontSize()
          Return the font-size.
 Color getStrokeColor()
          Returns the "stroke" color.
 void reset()
          Resets the Graphics State to its original state, as documented in PDF Reference, 3rd Edition, Section 4.3.
 boolean setCharacterSpacing(float newCharacterSpacing)
          Sets the character spacing.
 boolean setFillColor(Color newFillColor)
          Sets the "non-stroke" or "other" color (Graphics State holds two colors, one for stroke operations and one for all other operations).
 boolean setFont(org.axsl.pdf.PdfFont newFont)
          Sets the font.
 boolean setFontSize(float newFontSize)
          Sets the font-size.
 boolean setHorizontalScaling(float newHorizontalScaling)
          Sets the horizontal scaling.
 boolean setLeading(float newLeading)
          Sets the text leading.
 boolean setLineCapStyle(org.axsl.pdf.PdfLineCapStyle newLineCapStyle)
          Sets the line cap style.
 boolean setLineDashPattern(float[] newDashArray, float newDashPhase)
          Sets the line dash pattern.
 boolean setStrokeColor(Color newStrokeColor)
          Sets the stroke color (Graphics State holds two colors, one for stroke operations and one for all other operations).
 boolean setTextKnockout(boolean newTextKnockout)
          Sets the text knockout flag.
 boolean setTextRenderingMode(org.axsl.pdf.PdfTextRenderingMode newTextRenderingMode)
          Sets the text rendering mode.
 boolean setTextRise(float newTextRise)
          Sets the text rise.
 boolean setWordSpacing(float newWordSpacing)
          Sets the word spacing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INITIAL_HORIZONTAL_SCALING

public static final float INITIAL_HORIZONTAL_SCALING
Constant for the initial horizontal scaling percentage, that is 100%.

See Also:
Constant Field Values
Constructor Detail

PDFGraphicsState

public PDFGraphicsState()
Create a PDFGraphicsState instance.


PDFGraphicsState

public PDFGraphicsState(PDFGraphicsState existingState)
Creates a new PDFGraphicsState instance, initilializing its values to those of an existing instance.

Parameters:
existingState - The instance whose values should be copied into the new instance.
Method Detail

reset

public void reset()
Resets the Graphics State to its original state, as documented in PDF Reference, 3rd Edition, Section 4.3.


setStrokeColor

public boolean setStrokeColor(Color newStrokeColor)
Sets the stroke color (Graphics State holds two colors, one for stroke operations and one for all other operations).

Parameters:
newStrokeColor - The color that stroke operations should now use.
Returns:
True if the Graphics State was changed by this operation.

getStrokeColor

public Color getStrokeColor()
Returns the "stroke" color.

Returns:
The stroke color.

setFillColor

public boolean setFillColor(Color newFillColor)
Sets the "non-stroke" or "other" color (Graphics State holds two colors, one for stroke operations and one for all other operations). This is the one for all other operations. The name "fill" was chosen because that is the common use for this color.

Parameters:
newFillColor - The color that non-stroke operations should now use.
Returns:
True if the Graphics State was changed by this operation.

getFillColor

public Color getFillColor()
Returns the "non-stroke" or "other" color.

Returns:
The fill color.

setCharacterSpacing

public boolean setCharacterSpacing(float newCharacterSpacing)
Sets the character spacing.

Parameters:
newCharacterSpacing - The new character spacing, in points.
Returns:
True iff the character spacing was changed.

setWordSpacing

public boolean setWordSpacing(float newWordSpacing)
Sets the word spacing.

Parameters:
newWordSpacing - The new word spacing, in points.
Returns:
True iff the word spacing was changed.

setFont

public boolean setFont(org.axsl.pdf.PdfFont newFont)
Sets the font.

Parameters:
newFont - The new font.
Returns:
True iff the font was changed.

getFont

public org.axsl.pdf.PdfFont getFont()
Returns the font.

Returns:
The font.

setFontSize

public boolean setFontSize(float newFontSize)
Sets the font-size.

Parameters:
newFontSize - The new font-size, in points.
Returns:
True iff the font-size was changed.

getFontSize

public float getFontSize()
Return the font-size.

Returns:
The font-size.

setLineDashPattern

public boolean setLineDashPattern(float[] newDashArray,
                                  float newDashPhase)
Sets the line dash pattern. See PDF Reference, 3rd Edition, Section 4.3.

Parameters:
newDashArray - The new dash array.
newDashPhase - The new dash phase.
Returns:
True iff the Graphics State was changed by this operation.

setLineCapStyle

public boolean setLineCapStyle(org.axsl.pdf.PdfLineCapStyle newLineCapStyle)
Sets the line cap style. See PDF Reference, 3rd Edition, Section 4.3.

Parameters:
newLineCapStyle - The new line cap style.
Returns:
True iff the Graphics State was changed by this operation.

setHorizontalScaling

public boolean setHorizontalScaling(float newHorizontalScaling)
Sets the horizontal scaling. See PDF Reference, 3rd Edition, Section 5.2.3.

Parameters:
newHorizontalScaling - The new horizontal scaling percentage.
Returns:
True iff the Graphics State was changed by this operation.

setLeading

public boolean setLeading(float newLeading)
Sets the text leading. See PDF Reference, 3rd Edition, Section 5.2.4.

Parameters:
newLeading - The new leading value.
Returns:
True iff the Graphics State was changed by this operation.

setTextRenderingMode

public boolean setTextRenderingMode(org.axsl.pdf.PdfTextRenderingMode newTextRenderingMode)
Sets the text rendering mode. See PDF Reference, 3rd Edition, Section 5.2.5.

Parameters:
newTextRenderingMode - The new text rendering mode.
Returns:
True iff the Graphics State was changed by this operation.

setTextRise

public boolean setTextRise(float newTextRise)
Sets the text rise. See PDF Reference, 3rd Edition, Section 5.2.6.

Parameters:
newTextRise - The new text rise value.
Returns:
True iff the Graphics State was changed by this operation.

setTextKnockout

public boolean setTextKnockout(boolean newTextKnockout)
Sets the text knockout flag. See PDF Reference, 3rd Edition, Section 5.2.7.

Parameters:
newTextKnockout - The new text rise value.
Returns:
True iff the Graphics State was changed by this operation.


Copyright © 2017. All rights reserved.