| The Essential JViews Framework > Graphic Objects > Geometric Properties > Moving and Resizing a Graphic Object |
Moving and Resizing a Graphic Object |
INDEX
PREVIOUS
NEXT
|
The class IlvGraphic provides many methods for moving and resizing a graphic object:
public void move(float x, float y)
public void move(IlvPoint p)
public void moveResize(IlvRect size)
public void translate(float dx, float dy)
public void rotate(IlvPoint center, double angle)
public void scale(double scalex, double scaley)
public void resize(float neww, float newh)
All the above methods call applyTransform to modify the bounding rectangle of the graphic object.
public void applyTransform(IlvTransformer t)
This is the only method that needs to be overridden in order to handle the transformation of an object correctly. The following code example shows how the applyTransform method may be used in our example class, MyRectangle:
class MyRectangle extends IlvGraphic { // The rectangle that defines the object. final IlvRect drawrect = new IlvRect(); ... public void applyTransform(IlvTransformer t) { t.apply(drawrect); } } |
The method simply applies the transformation to the rectangle.
| Note |
Graphic objects stored in a manager (class IlvManager and its subclasses) are located in a quadtree. This means that you cannot simply call move on a graphic object because the quadtree must be notified of the modification of the graphic object. Every method that modifies the bounding rectangle of the object must call IlvManager.applyToObject. This method applies a function to an object and notifies the quadtree of the modification to the bounding rectangle. The class IlvManager also includes several convenient methods to move and reshape a graphic object managed by this manager. They are shown below: public void moveObject(IlvGraphic, float, float, boolean) |
For more information, see Modifying Geometric Properties of Objects.
| Copyright © 1987-2007 ILOG S.A. All rights reserved. Documentation homepage. Legal terms. | PREVIOUS NEXT |