intarsys PDF library API

de.intarsys.pdf.cds
Class CDSMatrix

java.lang.Object
  extended by de.intarsys.pdf.cos.COSBasedObject
      extended by de.intarsys.pdf.cds.CDSBase
          extended by de.intarsys.pdf.cds.CDSMatrix
All Implemented Interfaces:
ICOSObjectListener, IAttributeSupport

public class CDSMatrix
extends CDSBase

The implementation of the pdf transformation matrix.

Each matrix is represented as an array.

       The transformation matrix:
 
                    +       +
                    | a b 0 |
                    | c d 0 |
                    | e f 1 |
                    +       +
                    
       is written as a COSArray in the form:
  
                    [ a b c d e f ]
 
       The identity transformation has the form:
 
                    [ 1 0 0 1 0 0 ]
 

Coordinates could be transformed by a matrix.

       A coordinate transformation is defined as:
                                             +       +
                                             | a b 0 |
                    [ x' y' 1 ] = [ x y 1] * | c d 0 |
                                             | e f 1 |
                                             +       +
                                             
       so that
 
                      x' = x*a + y*c + e
                      y' = x*b + y*d + f
 


Nested Class Summary
 
Nested classes/interfaces inherited from class de.intarsys.pdf.cos.COSBasedObject
COSBasedObject.MetaClass
 
Field Summary
static float[] MATRIX_0
          Static information needed for rotation: rotate 0 degress (identity matrix)
static float[] MATRIX_180
          Static information needed for rotation: rotate 180 degrees
static float[] MATRIX_270
          Static information needed for rotation: rotate 270 degrees
static float[] MATRIX_90
          Static information needed for rotation: rotate 90 degrees
 
Fields inherited from class de.intarsys.pdf.cos.COSBasedObject
META
 
Constructor Summary
CDSMatrix()
          CDSMatrix constructor.
CDSMatrix(float[] data)
          Create a CDSMatrix based on the array in the parameter.
 
Method Summary
 CDSMatrix copy()
          Create a copy of the receiver
static CDSMatrix createFromCOS(COSArray array)
          Create a CDSMatrix from an array holding the transformation parameters.
 float getA()
          Return the matrix element "a".
 float getB()
          Return the matrix element "b".
 float getC()
          Return the matrix element "c".
 float getD()
          Return the matrix element "d".
 float getE()
          Return the matrix element "e".
 float getF()
          Return the matrix element "f".
 void invalidateCaches()
          Invalidate all local caches as the base object may have changed.
 void rotate(float angle)
          Concatenate this transformation with a rotation transformation.
 void scale(float[] v)
          Concatenate this transformation with a scaling transformation.
 void setA(float num)
          Set the matrix element "a".
 void setB(float num)
          Set the matrix element "b".
 void setC(float num)
          Set the matrix element "c".
 void setD(float num)
          Set the matrix element "d".
 void setE(float num)
          Set the matrix element "e".
 void setF(float num)
          Set the matrix element "f".
 void setTransformation(AffineTransform transform)
          Set all matrix elements "a" - "f"
 void setTransformation(float[] data)
          Set all matrix elements "a" - "f"
 void setTransformation(float a, float b, float c, float d, float e, float f)
          Set all matrix elements "a" - "f"
 AffineTransform toTransform()
          Create an AffineTransform that corresponds to this.
 float[] transform(float[] v)
          Transform a vector v using this.
 void translate(float[] v)
          Concatenate this transformation with a translation transformation.
 void translate(float x, float y)
          Concatenate this transformation with a translation transformation.
 
Methods inherited from class de.intarsys.pdf.cos.COSBasedObject
changed, cosGetArray, cosGetDict, cosGetDoc, cosGetField, cosGetObject, cosGetStream, cosHasField, cosRemoveField, cosSetField, getAttribute, getFieldBoolean, getFieldDate, getFieldFixed, getFieldFixedArray, getFieldInt, getFieldMLString, getFieldString, removeAttribute, setAttribute, setFieldBoolean, setFieldFixed, setFieldInt, setFieldMLString, setFieldName, setFieldObject, setFieldString, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MATRIX_0

public static float[] MATRIX_0
Static information needed for rotation: rotate 0 degress (identity matrix)


MATRIX_90

public static float[] MATRIX_90
Static information needed for rotation: rotate 90 degrees


MATRIX_180

public static float[] MATRIX_180
Static information needed for rotation: rotate 180 degrees


MATRIX_270

public static float[] MATRIX_270
Static information needed for rotation: rotate 270 degrees

Constructor Detail

CDSMatrix

public CDSMatrix()
CDSMatrix constructor.

Create a new identity matrix


CDSMatrix

public CDSMatrix(float[] data)
Create a CDSMatrix based on the array in the parameter. The array must have 6 elements.

Parameters:
data - The array defining the matrix.
Method Detail

createFromCOS

public static CDSMatrix createFromCOS(COSArray array)
Create a CDSMatrix from an array holding the transformation parameters.

Parameters:
array - The base COSArray
Returns:
Create a CDSMatrix from array

invalidateCaches

public void invalidateCaches()
Description copied from class: COSBasedObject
Invalidate all local caches as the base object may have changed.

Overrides:
invalidateCaches in class COSBasedObject

setA

public void setA(float num)
Set the matrix element "a".

Parameters:
num - The new matrix element "a".

getA

public float getA()
Return the matrix element "a".

Returns:
The matrix element "a".

setB

public void setB(float num)
Set the matrix element "b".

Parameters:
num - The new matrix element "b".

getB

public float getB()
Return the matrix element "b".

Returns:
The matrix element "b".

setC

public void setC(float num)
Set the matrix element "c".

Parameters:
num - The new matrix element "c".

getC

public float getC()
Return the matrix element "c".

Returns:
The matrix element "c".

setD

public void setD(float num)
Set the matrix element "d".

Parameters:
num - The new matrix element "d".

getD

public float getD()
Return the matrix element "d".

Returns:
The matrix element "d".

setE

public void setE(float num)
Set the matrix element "e".

Parameters:
num - The new matrix element "e".

getE

public float getE()
Return the matrix element "e".

Returns:
The matrix element "e".

setF

public void setF(float num)
Set the matrix element "f".

Parameters:
num - The new matrix element "f".

getF

public float getF()
Return the matrix element "f".

Returns:
The matrix element "f".

setTransformation

public void setTransformation(float a,
                              float b,
                              float c,
                              float d,
                              float e,
                              float f)
Set all matrix elements "a" - "f"

Parameters:
a - The new matrix element "a".
b - The new matrix element "b".
c - The new matrix element "c".
d - The new matrix element "d".
e - The new matrix element "e".
f - The new matrix element "f".

setTransformation

public void setTransformation(float[] data)
Set all matrix elements "a" - "f"

Parameters:
data - The array defining the new parameters

setTransformation

public void setTransformation(AffineTransform transform)
Set all matrix elements "a" - "f"

Parameters:
transform - The matrix defining the new parameters

copy

public CDSMatrix copy()
Create a copy of the receiver

Returns:
a new copy of the receiver

rotate

public void rotate(float angle)
Concatenate this transformation with a rotation transformation.

Parameters:
angle - Rotation angle in radians

scale

public void scale(float[] v)
Concatenate this transformation with a scaling transformation.

Parameters:
v - The scale factor.

transform

public float[] transform(float[] v)
Transform a vector v using this.

Parameters:
v - The vector that will be transformed.
Returns:
The transformed vector.

translate

public void translate(float[] v)
Concatenate this transformation with a translation transformation.

Parameters:
v - The transaltion definition

translate

public void translate(float x,
                      float y)
Concatenate this transformation with a translation transformation.

Parameters:
x - The translation in x direction
y - The translation in y direction

toTransform

public AffineTransform toTransform()
Create an AffineTransform that corresponds to this.

Returns:
Create an AffineTransform that corresponds to this.

intarsys PDF library API

Copyright © 2006 intarsys consulting GmbH. All Rights Reserved.