gishur.x
Class XObject

java.lang.Object
  |
  +--gishur.x.XObject
All Implemented Interfaces:
java.lang.Cloneable, Cloneable, java.io.Serializable
Direct Known Subclasses:
XBaseline, XCircle, XParabola, XPoint, XPolyline

public abstract class XObject
extends java.lang.Object
implements Cloneable, java.io.Serializable

A generic planar object. A concrete planar object should represent some sort of a planar primitive like point, line, polygon.

All planar objects should implement transform enabling affine transformations. XObject provides some shortcut methods like #scale, #rotate and translate for special affine transformations This class is just a 'light' version of XObject to extend the 'old' planar geometric classes. Some of this classes methods are useless (e.g. mutability methods) but used by DisplayObjects in order visualize gishur.x classes in a similar way to the newer gishur.x2.core classes.

Version:
1.0
Author:
Thomas Wolf
See Also:
Serialized Form

Constructor Summary
XObject()
           
 
Method Summary
 java.lang.Object clone()
          Creates a new object of the same class as this object.
 XObject copy()
          This method creates a clone of this object instance like clone with a little difference: if this is immutable, the clone won't be till the first modification.
 XObject getMutable()
          This method returns either this XObject or a temporary mutable clone of this XObject, depending on its mutability.
 XObject inverseTransform_XObject(double m00, double m01, double m02, double m10, double m11, double m12)
          Inverse transforms this XObject by the given affine transformation matrix.
 boolean mutable()
          Checks, if this XObject is mutable.
 void restoreMutability()
          Restores the mutability information to the information of the original of this clone.
 XObject rotate_XObject(XPoint center, double angle)
          Rotates this XObject around the rotation center center by angle.
 XObject scale_XObject(XPoint center, double xscale, double yscale)
          Scales this XObject with xscale and yscale scale factors and with center point center.
 java.lang.String toString()
          Returns a string representation of the object.
 XObject transform_XObject(AffineTransformation t)
          Transforms this XObject by the given affine transformation matrix.
abstract  XObject transform_XObject(double m00, double m01, double m02, double m10, double m11, double m12)
          Transforms this XObject by the given affine transformation matrix.
 XObject translate_XObject(double dx, double dy)
          Translates this XObject by the given Vector (dx,dy).
 XObject translate_XObject(XPoint v)
          Translates this XObject by the given Vector v.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XObject

public XObject()
Method Detail

mutable

public boolean mutable()
Checks, if this XObject is mutable.
Returns:
true, if mutable (#STATE_MUTABLE is set)

getMutable

public XObject getMutable()
This method returns either this XObject or a temporary mutable clone of this XObject, depending on its mutability. If this XObject is immutable, a clone will be created and returned that is mutable until a call to restoreMutability(). This gives one the possibility to write code like this without knowing something about the mutability of the used XObject:
XObject a=...;
 a=getMutable();         // get a mutable version of a
 a.transform(...);       // change a
 ... (can be more transformations)
 a.restoreMutability();  // restore the old mutability information of the original
 
Returns:
either this or a mutable clone.
See Also:
copy(), #restorMutability

restoreMutability

public void restoreMutability()
Restores the mutability information to the information of the original of this clone. If this is a normal mutable (or immutable) XObject, nothing happens.

copy

public XObject copy()
This method creates a clone of this object instance like clone with a little difference: if this is immutable, the clone won't be till the first modification. This is usefull if you like to create a modified version of an object instance and you don't know, if this object is mutable. With copy you can assure, there will be created a new instance; you can write code as this:
XObject a=...;
 XObject b=a.copy().translate(x,y);
If a is mutable, copy assures that a new instance is created and #translate works on that copy. If a is immutable, copy creates a new instance of a and lets modify #translate this instance exactly one time.
Returns:
Clone of this object, that is modifyable at least one time (depending on the immutable-flag of this).

transform_XObject

public abstract XObject transform_XObject(double m00,
                                          double m01,
                                          double m02,
                                          double m10,
                                          double m11,
                                          double m12)
Transforms this XObject by the given affine transformation matrix.
Parameters:
m00,m01,m02 - first row of the transformation matrix
m10,m11,m12 - second row of the transformation matrix
Returns:
Transformed XObject (this, only if it is mutable, otherwise a new XObject represeting the transformed object).

inverseTransform_XObject

public XObject inverseTransform_XObject(double m00,
                                        double m01,
                                        double m02,
                                        double m10,
                                        double m11,
                                        double m12)
Inverse transforms this XObject by the given affine transformation matrix.
Parameters:
m00,m01,m02 - first row of the transformation matrix
m10,m11,m12 - second row of the transformation matrix
Returns:
Inverse transformed XObject (this, only if it is mutable, otherwise a new XObject represeting the transformed object).

transform_XObject

public XObject transform_XObject(AffineTransformation t)
Transforms this XObject by the given affine transformation matrix.
Parameters:
t - the transformation matrix
Returns:
Transformed XObject (this, only if it is mutable)

scale_XObject

public XObject scale_XObject(XPoint center,
                             double xscale,
                             double yscale)
Scales this XObject with xscale and yscale scale factors and with center point center.
Parameters:
center - immutable scaling center point
xscale - scale factor for x-axis
yscale - scale factor for y-axis
Returns:
transformed XObject (this, only if it is mutable)

rotate_XObject

public XObject rotate_XObject(XPoint center,
                              double angle)
Rotates this XObject around the rotation center center by angle.
Parameters:
center - rotation center
angle - rotation angle
Returns:
transformed XObject (this, only if it is mutable)

translate_XObject

public XObject translate_XObject(double dx,
                                 double dy)
Translates this XObject by the given Vector (dx,dy).
Parameters:
(dx,dy) - translation vector
Returns:
transformed XObject (this, only if it is mutable)

translate_XObject

public XObject translate_XObject(XPoint v)
Translates this XObject by the given Vector v.
Parameters:
(dx,dy) - translation vector
Returns:
transformed XObject (this, only if it is mutable)

clone

public java.lang.Object clone()
Creates a new object of the same class as this object.
Specified by:
clone in interface Cloneable
Overrides:
clone in class java.lang.Object
Returns:
a clone of this instance.
Throws:
OutOfMemoryError - if there is not enough memory.
See Also:
Cloneable

toString

public java.lang.String toString()
Returns a string representation of the object.
Overrides:
toString in class java.lang.Object
Returns:
a string representation of the object.