org.foray.ps
Class PsGraphicsState

java.lang.Object
  extended by org.foray.ps.PsObjectComposite
      extended by org.foray.ps.PsGraphicsState
All Implemented Interfaces:
Cloneable, PsObject

public class PsGraphicsState
extends PsObjectComposite
implements Cloneable

Represents a PostScript Graphics State. According to PSLRM 2nd Edition, Section 4.2, the Graphics State is not itself an object. However, gstate is an object, and can be placed on the operand stack. Until we see a need to keep the two separate, we will treat the Graphics State and gstate as equivalent, and PsGraphicsState will extend PsObject.


Constructor Summary
PsGraphicsState()
          Constructor.
 
Method Summary
 PsGraphicsState clone()
           
 void closepath()
          Closes the current sub-path.
protected  void copy(PsGraphicsState copyFrom)
          Copies the contents of copyFrom into this, in conformity with the requirements of the copy operator.
 void curveto(PsNumber control1X, PsNumber control1Y, PsNumber control2X, PsNumber control2Y, PsNumber control3X, PsNumber control3Y)
          Marks the control points in a new Bezier curve segment in the current path.
 PsGraphicsState duplicate()
          This is a shallow copy.
 Color getColor()
          Returns the color.
 PsColorSpace getColorSpace()
          Return the colorspace.
 PsMatrix getCTM()
          Returns the current transformation matrix (CTM).
 float getDashOffset()
          Returns the dash offset.
 PsArray getDashPattern()
          Returns the dash pattern.
 BigDecimal getFlatness()
          Returns the flatness.
 PsDictionary getFont()
          Returns the font.
 PsInteger getLineCap()
          Returns the line cap value.
 PsInteger getLineJoin()
          Returns the line join value.
 PsNumber getLineWidth()
          Returns the line width.
 PsNumber getMiterLimit()
          Returns the miter limit.
 PsNumber getPositionX()
          Returns the current "x" position, that is, the horizontal position of the "cursor" in user space units.
 PsNumber getPositionY()
          Returns the current "y" position, that is, the vertical position of the "cursor" in user space units.
 PsName getTypeName()
          Needed for the "type" operator.
 boolean isComparable(PsObject object)
          Test the comparability of two PSObjects.
 boolean isComposite()
          The method should be overridden by composite objects.
 boolean isExecutable()
          Indicates whether this object is executable.
 void lineto(PsNumber x, PsNumber y)
          Marks the end-point of a new line segment in the current path.
 void moveto(PsNumber x, PsNumber y)
          Starts a new sub-path in the current path.
 void newpath()
          Sets the current path to null.
 void setColor(Color newColor)
          Sets the color.
 void setColorSpace(int colorSpace)
          Sets the color space.
 void setCTM(PsMatrix ctm)
          Sets the current transformation matrix (CTM).
 void setDash(PsArray dashPattern, float dashOffset)
          Set the dash pattern and offset.
 void setFlatness(BigDecimal flatness)
          Sets the flatness.
 void setFont(PsDictionary font)
          Sets the font.
 void setLineCap(PsInteger lineCap)
          Sets the line cap value.
 void setLineJoin(PsInteger lineJoin)
          Sets the line join value.
 void setLineWidth(PsNumber lineWidth)
          Sets the line width.
 void setMiterLimit(PsNumber miterLimit)
          Sets the miter limit.
 
Methods inherited from class org.foray.ps.PsObjectComposite
getAccess, setAccess
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PsGraphicsState

public PsGraphicsState()
Constructor.

Method Detail

clone

public PsGraphicsState clone()
Overrides:
clone in class Object

setColorSpace

public void setColorSpace(int colorSpace)
Sets the color space.

Parameters:
colorSpace - The new colorspace.

setColor

public void setColor(Color newColor)
Sets the color.

Parameters:
newColor - The new color.

getColor

public Color getColor()
Returns the color.

Returns:
The color.

getColorSpace

public PsColorSpace getColorSpace()
Return the colorspace.

Returns:
the colorspace.

setDash

public void setDash(PsArray dashPattern,
                    float dashOffset)
Set the dash pattern and offset.

Parameters:
dashPattern - The dash pattern to set.
dashOffset - The dash offset to set.

getDashPattern

public PsArray getDashPattern()
Returns the dash pattern.

Returns:
The dash pattern.

getDashOffset

public float getDashOffset()
Returns the dash offset.

Returns:
The dash offset.

setFlatness

public void setFlatness(BigDecimal flatness)
Sets the flatness.

Parameters:
flatness - The new flatness.

getFlatness

public BigDecimal getFlatness()
Returns the flatness.

Returns:
The flatness.

getLineJoin

public PsInteger getLineJoin()
Returns the line join value.

Returns:
The line join value.

setLineJoin

public void setLineJoin(PsInteger lineJoin)
Sets the line join value.

Parameters:
lineJoin - The line join value to set.

getLineCap

public PsInteger getLineCap()
Returns the line cap value.

Returns:
The line cap value.

setLineCap

public void setLineCap(PsInteger lineCap)
Sets the line cap value.

Parameters:
lineCap - The line cap value to set.

getLineWidth

public PsNumber getLineWidth()
Returns the line width.

Returns:
The line width.

setLineWidth

public void setLineWidth(PsNumber lineWidth)
Sets the line width.

Parameters:
lineWidth - The line width to set.

getMiterLimit

public PsNumber getMiterLimit()
Returns the miter limit.

Returns:
The miter limit.

setMiterLimit

public void setMiterLimit(PsNumber miterLimit)
Sets the miter limit.

Parameters:
miterLimit - The miter limit to set.

getCTM

public PsMatrix getCTM()
Returns the current transformation matrix (CTM).

Returns:
The CTM.

setCTM

public void setCTM(PsMatrix ctm)
Sets the current transformation matrix (CTM).

Parameters:
ctm - The ctm to set.

getFont

public PsDictionary getFont()
Returns the font.

Returns:
The font.

setFont

public void setFont(PsDictionary font)
Sets the font.

Parameters:
font - The font to set.

getPositionX

public PsNumber getPositionX()
Returns the current "x" position, that is, the horizontal position of the "cursor" in user space units.

Returns:
The current "x" position, or null if undefined.

getPositionY

public PsNumber getPositionY()
Returns the current "y" position, that is, the vertical position of the "cursor" in user space units.

Returns:
The current "y" position, or null if undefined.

newpath

public void newpath()
Sets the current path to null.


closepath

public void closepath()
Closes the current sub-path.


moveto

public void moveto(PsNumber x,
                   PsNumber y)
Starts a new sub-path in the current path.

Parameters:
x - The x value of the start of the new sub-path.
y - The y value of the start of the new sub-path.

lineto

public void lineto(PsNumber x,
                   PsNumber y)
Marks the end-point of a new line segment in the current path.

Parameters:
x - The x value of the line segment end-point.
y - The y value of the line segment end-point.

curveto

public void curveto(PsNumber control1X,
                    PsNumber control1Y,
                    PsNumber control2X,
                    PsNumber control2Y,
                    PsNumber control3X,
                    PsNumber control3Y)
Marks the control points in a new Bezier curve segment in the current path.

Parameters:
control1X - The x value of control point 1 in the curve segment.
control1Y - The y value of control point 1 in the curve segment.
control2X - The x value of control point 2 in the curve segment.
control2Y - The y value of control point 2 in the curve segment.
control3X - The x value of control point 3 in the curve segment.
control3Y - The y value of control point 3 in the curve segment.

duplicate

public PsGraphicsState duplicate()
Description copied from interface: PsObject
This is a shallow copy. Specifically, composite objects should generally return themselves. Simple objects should return copies of themselves.

Specified by:
duplicate in interface PsObject
Returns:
A duplicate of this that conforms to what is expected by the "dup" operator.

isExecutable

public boolean isExecutable()
Description copied from interface: PsObject
Indicates whether this object is executable.

Specified by:
isExecutable in interface PsObject
Returns:
True iff this object is executable.

isComparable

public boolean isComparable(PsObject object)
Description copied from interface: PsObject
Test the comparability of two PSObjects. Used in the eq, ne, lt, etc. operators.

Specified by:
isComparable in interface PsObject
Parameters:
object - The object that should be tested for comparability.
Returns:
True if this is comparable to object, false otherwise.

getTypeName

public PsName getTypeName()
Description copied from interface: PsObject
Needed for the "type" operator.

Specified by:
getTypeName in interface PsObject
Returns:
The type name as defined in PSRM2, Chapter 8, "type" operator.

copy

protected void copy(PsGraphicsState copyFrom)
Copies the contents of copyFrom into this, in conformity with the requirements of the copy operator.

Parameters:
copyFrom - The PsGraphicsState instance which should be copied.

isComposite

public boolean isComposite()
Description copied from interface: PsObject
The method should be overridden by composite objects.

Specified by:
isComposite in interface PsObject
Returns:
True iff this object is a composite PostScript object.


Copyright © 2017. All rights reserved.