ilog.views
Class IlvGraphic

java.lang.Object
  extended by ilog.views.IlvGraphic
All Implemented Interfaces:
IlvPersistentObject, Transferable, Serializable
Direct Known Subclasses:
IlvAbstractCrossingGraphic, IlvArc, IlvBalloon, IlvBracket, IlvComponentGraphic, IlvDiamond, IlvEllipse, IlvGeneralPath, IlvGraphicHandle, IlvGraphicPath, IlvGraphicSet, IlvGroupFrame, IlvIcon, IlvJComponentGraphic, IlvLabel, IlvLine, IlvLinkImage, IlvManager, IlvMarker, IlvPolyPoints, IlvRectangle, IlvScale, IlvSelection, IlvText, IlvZoomableLabel

public abstract class IlvGraphic
extends Object
implements Serializable, Transferable, IlvPersistentObject

IlvGraphic is the abstract base class for all graphic objects managed by an IlvManager instance.

Overview

All standard graphical objects inherit from IlvGraphic, examples of this are IlvRectangle, IlvLine, IlvText and IlvLinkImage. A collection of graphic objects is managed using a graphic bag, that is, a class that implements the IlvGraphicBag interface. An example of a graphic bag is the IlvManager class. IlvGraphic is used as the base object for specialized graphic objects.

Potentially persistent properties are stored in IlvGraphic instances using implementations of the IlvNamedProperty abstract class.

Creating Custom Graphic Objects

The following methods have to be overridden to create a customized graphic object:

Note: these methods are called frequently, custom overrides must be optimized to ensure maximum performance.

Although not mandatory, it is often necessary to override the following methods:

The following code example shows a very simple customized graphic object.

 public class SimpleRectangle extends IlvGraphic {
   protected final IlvRect drawrect = new IlvRect();
 
   public SimpleRectangle(){
     this(new IlvRect(10, 10, 30, 20));
   }
   
   public SimpleRectangle(IlvRect rect) {  
     super();
     drawrect.reshape(rect.x, rect.y, rect.width, rect.height);
   }
   
   public SimpleRectangle(SimpleRectangle source){
     super(source);
     drawrect.reshape(source.drawrect.x, source.drawrect.y, 
                      source.drawrect.width, source.drawrect.height);
   }
   
   public IlvGraphic copy() {
     return new SimpleRectangle(this);
   }
   
   public void draw(Graphics graphic, IlvTransformer trans) {
     graphic.setColor(Color.GREEN);
     IlvRect tmprect = new IlvRect();
     tmprect.reshape(drawrect.x, drawrect.y, 
                     drawrect.width, drawrect.height);
     trans.applyFloor(tmprect);
     graphic.fillRect((int)tmprect.x, 
                 (int)tmprect.y, 
                 (int)tmprect.width+1, 
                 (int)tmprect.height+1);
   }
   
   public IlvRect boundingBox(IlvTransformer trans) {
     IlvRect rect = new IlvRect(drawrect);
     if (!(trans == null || trans.isIdentity())) 
       trans.apply(rect);  
     return rect;
   }
 
   public void applyTransform(IlvTransformer trans) {
     if (trans == null || trans.isIdentity())
       return;
     trans.apply(drawrect);
   }
 }
 

Using Graphic Objects

The following code example shows how to integrate the SimpleRectangle custom graphic object into a Java application.
 public class FrameworkTest extends JFrame {
 
   IlvManager manager;
   IlvManagerView mgrview;
 
   public FrameworkTest()
   {
     manager = new IlvManager();
     mgrview = new IlvManagerView(manager);
     mgrview.setBackground(Color.white);      
     getContentPane().setLayout(new BorderLayout(0,0));
     getContentPane().add(new IlvJScrollManagerView(mgrview),
                      BorderLayout.CENTER);  
     IlvGraphic obj  = new SimpleRectangle();  
     manager.addObject(obj, 1, false);     
   }
   
   public static void main(String[] args) {
     JFrame frame = new FrameworkTest();
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     frame.setSize(200,200);
     frame.setVisible(true);
   }
 }
 
See IlvManager for a more complete explanation of how to integrate graphic objects into graphic application.

Moving and Transforming Graphic Objects

The bounding box is the rectangle that encompasses the entire drawing area of a graphic object, that is, the smallest rectangle encompassing all elements in the graphic object. The bounding box is used in calculations when an object is moved, resized or transformed inside an IlvManager instance.

A transformation defines the area of a manager that the current view is displaying. It also defines the zoom level and rotation applied to graphic objects inside a manager. Transformation is controlled using an IlvTransformer instance. A transformation that does not translate, rotate or zoom any object is called the identity transformation.

The rectangle returned by the boundingBox(IlvTransformer) method follows the zoom factor of the transformation. If it does not, calls to zoomable() for this manager return false.

IlvGraphic methods that modify the bounding box of a graphic object must only be used by calling the applyToObject method from its manager. For some operations, best practice is to call the corresponding method from the manager. For example, call IlvManager.moveObject instead of IlvGraphic.move. The following examples show equivalent code:

  obj.getGraphicBag().applyToObject(obj, new IlvApplyObject() {
    public void apply(IlvGraphic obj, Object arg) {
      IlvPoint p = (IlvPoint)arg;
      obj.move(p.x, p.y);
   }
  }, point, redraw);
 
The applyToObject implementation above corresponds to:
   manager.moveObject(obj, point.x, point.y, redraw);
 

Controlling Object Behavior Using Interactors

Interactive behavior is controlled either by using view interactors such as IlvSelectInteractor associated to the entire manager view or by object interactors associated to each individual graphic object. An object interactor is an instance of IlvObjectInteractor, it is associated to graphic object using setObjectInteractor. For details, see IlvObjectInteractor.

Serializing Graphic Objects

The recommended way to serialize a graphic object is using IVL serialization and not standard Java serialization. This is done by calling methods such as IlvManager.write(String, boolean). Java serialization cannot work for graphic objects such as IlvIcon, these classes manage JDK objects that are not serializable.

Setting Interactive User Information

The IlvGraphic class enables you to add interactive content to you application in the form of tool tips and pop-up menus. The following code example shows how to set the tool tip for an instance of the SimpleRectangle class shown earlier:

First, you need to register the manager view that displays the tool tip:

  IlvToolTipManager.registerView(mgrview);    
 
Then, you assign your tool tip to the graphic objects displayed in mgrview:
  IlvGraphic obj = new SimpleRectangle();
  obj.setToolTipText("Simple Rectangle");
 

Pop-up menus appear when the pop-up trigger interaction is performed. This occurs when the user right-clicks a graphic object. A pop-up menu allows the user to select actions that are associated with the graphic object. Pop-up menus work like tool tips, that is, your have to register the manager view and associate the pop-up menu at each graphic object.

Pop-up menus use a lot of memory. To optimize your application the ILOG JViews API enables you to share menus among multiple graphic objects. This is done by registering menus directly with the static pop-up menu manager IlvPopupMenuManager. Once a pop-up menu is registered globally, you can allocate it to one or more graphic objects. The following code example shows how to do this:

First, you need to register the manager view that displays the pop-up menu:

 IlvPopupMenuManager.registerView(mgrview);
 
Then, you assign your pop-up menu to the graphic objects displayed in mgrview:
  IlvPopupMenuManager.registerMenu("MENU1", createVerySimpleMenu());
  obj.setPopupMenuName("MENU1");
 

The following image shows the SimpleRectangle class with tool tip and pop-up menu visible.

SimpleRectangle

Note: ILOG recommends that you take advantage of the extra functionality found in IlvSimplePopupMenu to create your pop-up menus.

See Also:
IlvManager, IlvGraphicBag, IlvNamedProperty, IlvTransformer, IlvToolTipManager, IlvObjectInteractor, IlvSelectInteractor, IlvPopupMenuManager, IlvSimplePopupMenu, Serialized Form

Constructor Summary
IlvGraphic()
          Creates a new IlvGraphic with the default setting.
IlvGraphic(IlvGraphic source)
          Creates a new IlvGraphic by copying an existing one.
IlvGraphic(IlvInputStream stream)
          Reads a graphic object from an IlvInputStream.
 
Method Summary
 void addActionListener(ActionListener listener)
          Adds the specified action listener to receive action events from this object.
 void addNamedPropertyListener(NamedPropertyListener listener)
          Adds the specified listener to receive events when a named property is added or removed from the graphic object.
abstract  void applyTransform(IlvTransformer t)
          Applies a transformation to the shape of the object.
 IlvRect boundingBox()
          Returns the bounding rectangle of the object for the identity transformation.
abstract  IlvRect boundingBox(IlvTransformer t)
          Returns the bounding rectangle of the object for a given transformation.
 boolean contains(IlvPoint p, IlvPoint tp, IlvTransformer t)
          Tests if a point lies within the outline of the object.
abstract  IlvGraphic copy()
          Returns a copy of this IlvGraphic instance.
abstract  void draw(Graphics dst, IlvTransformer t)
          Draws the object.
 IlvObjectInteractor getAndAssociateObjectInteractor()
          Returns the active object interactor.
 IlvPoint getCenter(IlvTransformer t)
          Returns the center point of the graphic object.
 String getDefaultInteractor()
          Returns the class name of the default interactor.
 IlvGraphicBag getGraphicBag()
          Returns the graphic bag that contains the object.
static IlvGraphic GetGraphicObject(Transferable trans)
          A static method that decodes a Transferable object.
 IlvPoint getIntersectionWithOutline(IlvPoint innerPoint, IlvPoint outerPoint, IlvTransformer t)
          Returns the intersection of the line segment from inner point to outer point with the shape of the graphic object.
 String getName()
          Returns the name of the object.
 IlvNamedProperty getNamedProperty(String name)
          Returns the named property associated with this graphic object.
 IlvObjectInteractor getObjectInteractor()
          Returns the object interactor associated with this object.
 JPopupMenu getPopupMenu()
          Returns the Swing pop-up menu set by setPopupMenu(javax.swing.JPopupMenu).
 JPopupMenu getPopupMenu(IlvPoint p, IlvTransformer t, IlvManagerView view, IlvPopupMenuManager popupManager)
          Returns the Swing pop-up menu to display when the pop-up is triggered.
 String getPopupMenuName()
          Returns the name of the Swing pop-up menu set by setPopupMenuName(java.lang.String).
 Object getProperty(String key)
          Returns the value of a property.
 String getToolTipText()
          Returns the tool tip set for this graphic object.
 String getToolTipText(IlvPoint p, IlvTransformer t)
          Returns the tool tip text to display when the mouse pointer is at a specified location inside the graphic object.
 IlvGraphicBag getTopLevelGraphicBag()
          Returns the top level graphic bag.
 Object getTransferData(DataFlavor flavor)
          Returns an object that represents the data to be transferred.
 DataFlavor[] getTransferDataFlavors()
          Returns an array of DataFlavor objects indicating in which flavors the data can be provided.
 boolean hasProperty(String key, Object value)
          Tests the value of a property.
 boolean inside(IlvRect rect, IlvRect trect, IlvTransformer t)
          Tests if a rectangle contains the object.
 boolean intersects(IlvRect rect, IlvRect trect, IlvTransformer t)
          Tests if a rectangle overlaps the object.
 boolean isDataFlavorSupported(DataFlavor flavor)
          Indicates whether the specified data flavor is supported for this object or not.
 boolean isEditable()
          Tests if this graphic object is editable with the selection interactor.
 boolean isInApplyToObject()
          Returns true if this graphic object is currently treated inside a call to applyToObject.
 boolean isMovable()
          Tests whether this graphic object is movable with the selection interactor.
 boolean isPersistent()
          If this method returns true, the IlvGraphic instance will be saved in IVL files.
 boolean isSelectable()
          Tests if this graphic object can be selected with the selection interactor.
 boolean isVisible()
          Tests whether this graphic object is visible.
 IlvSelection makeSelection()
          Creates a selection object for this object.
 void move(float x, float y)
          Moves the object.
 void move(IlvPoint p)
          Moves the object.
 void moveResize(IlvRect size)
          Resizes the object.
protected  void notifyObjectInteractorToManager(IlvObjectInteractor interactor)
          Notifies the manager that the object interactor has changed.
 void processActionEvent(ActionEvent event)
          Processes action events on this object instance by dispatching them to all ActionListener objects registered with this graphic object.
 void reDraw()
          Redraws this object.
 void removeActionListener(ActionListener listener)
          Removes the specified action listener.
 void removeNamedProperty(String name)
          Removes the named property associated with this graphic object.
 void removeNamedPropertyListener(NamedPropertyListener listener)
          Removes the specified listener so that it no longer receives events from this graphic object when named properties are added or removed.
 boolean removeProperty(String key)
          Removes a property.
 boolean replaceProperty(String key, Object value)
          Replaces the value of an existing property.
 void resize(float neww, float newh)
          Resizes the object.
 void rotate(IlvPoint center, double angle)
          Rotates the object.
 void scale(double scalex, double scaley)
          Resizes the object.
 void setBackground(Color c)
          Changes the background color of the object.
 void setEditable(boolean editable)
          Allows or disallows editing for this graphic object with the selection interactor.
 void setFillOn(boolean value)
          Changes the fill status of the object.
 void setForeground(Color c)
          Changes the foreground color of the object.
 void setGraphicBag(IlvGraphicBag bag)
          Changes the bag that contains the object.
 boolean setInApplyToObject(boolean v)
          Sets whether this graphic object is currently treated inside a call to applyToObject.
 void setMovable(boolean movable)
          Allows or prohibits movement of this graphic object with the selection interactor.
 void setName(String name)
          Sets the name of the object.
 IlvNamedProperty setNamedProperty(IlvNamedProperty property)
          Associates a named property with this graphic object.
 void setNameImpl(String name)
          Sets the name of the object.
 void setObjectInteractor(IlvObjectInteractor interactor)
          Changes the object interactor associated with this object.
 void setPopupMenu(JPopupMenu popup)
          Sets the Swing pop-up menu of this object.
 void setPopupMenuName(String popupName)
          Sets the Swing pop-up menu of this object by name.
 void setProperty(String key, Object value)
          Sets the value of a property.
 void setSelectable(boolean selectable)
          Allows or disallows selection for this graphic object with the selection interactor.
 void setStrokeOn(boolean value)
          Changes the stroke status of the object.
 void setToolTipText(String text)
          Sets the text to display in the tool tip of this object.
 void setVisible(boolean v)
          Sets the visibility for this graphic object.
 String toString()
          Returns a string representation of this graphic object.
 void translate(float dx, float dy)
          Translates the object.
 void write(IlvOutputStream stream)
          Writes this object to an IlvOutputStream.
 boolean zoomable()
          Returns true if the object is zoomable; otherwise it returns false.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IlvGraphic

public IlvGraphic()
Creates a new IlvGraphic with the default setting.

By default a new graphic object is

See Also:
IlvGraphic, setVisible(boolean), setEditable(boolean), setSelectable(boolean), setMovable(boolean)

IlvGraphic

public IlvGraphic(IlvGraphic source)
Creates a new IlvGraphic by copying an existing one.

Persistent properties stored in the object are copied by calling IlvNamedProperty.copy. If this copy method returns null the named property is not copied.

Parameters:
source - The graphic object to be copied.
See Also:
IlvGraphic, IlvNamedProperty.copy()

IlvGraphic

public IlvGraphic(IlvInputStream stream)
           throws IlvReadFileException
Reads a graphic object from an IlvInputStream.

Note that any subclass of IlvGraphic, as in any implementation of the interface IlvPersistentObject, must have a constructor with the signature MyGraphicObject(IlvInputStream stream) so that it can be read by IlvInputStream.

When implementing this method, the superclass constructor must be called first. The following example shows how this is done:

 public MyGraphicObject(IlvInputStream stream)
   throws IlvReadFileException
 {
   super(stream);
   valueField = stream.readInt("valueFieldName");
 }
 

Parameters:
stream - The input stream to be read from.
Throws:
IlvReadFileException - if the format of stream is not correct.
See Also:
IlvGraphic, IlvPersistentObject, write(IlvOutputStream)
Method Detail

copy

public abstract IlvGraphic copy()
Returns a copy of this IlvGraphic instance.

This abstract method must be implemented when you create a custom graphic object. The implementation can for instance simply call the copy constructore, which is defined like this: public <CLASSNAME>(<CLASSNAME> source).

Returns:
A copy of this IlvGraphic instance.
See Also:
IlvGraphic

zoomable

public boolean zoomable()
Returns true if the object is zoomable; otherwise it returns false. The default implementation returns true.

The purpose of this method is to indicate to the class IlvManager whether the graphic object can be stored in an optimized way (using a quadtree data structure). Zoomable objects can be managed more efficiently than non-zoomable objects.

A graphic object is said to be zoomable if and only if the transformed bounding rectangle returned by boundingBox(t) for any value of transformer t, is contained in the rectangle obtained by applying t to the non-transformed bounding rectangle, as returned by calling boundingBox(id) with the identity transformer id. As mathematical formula:

for all t holds: obj.boundingBox(t) ≤ t.apply(obj.boundingBox(id))

Note: If this object is contained inside an IlvManager, users must use the method IlvManager.applyToObject(ilog.views.IlvGraphic, ilog.views.IlvApplyObject, java.lang.Object, boolean) for any operation that might change the return value of the method zoomable().

See Also:
IlvGraphic, draw(java.awt.Graphics, ilog.views.IlvTransformer), boundingBox(IlvTransformer), IlvManager

draw

public abstract void draw(Graphics dst,
                          IlvTransformer t)
Draws the object.

This method must be implemented to draw the oject in transformed way into the Java Graphics. Implementations of this method must not draw outside the bounding box for this graphic object. The bounding box is returned by calling boundingBox(t) where t is the parameter passed to this method.

Parameters:
dst - The destination Graphics.
t - The transformation used to draw the object.
See Also:
boundingBox(ilog.views.IlvTransformer), zoomable(), IlvGraphic

boundingBox

public abstract IlvRect boundingBox(IlvTransformer t)
Returns the bounding rectangle of the object for a given transformation.

You must implement this method to return the bounding rectangle of the object that is used when the object is drawn with the specified transformer.

The bounding box for a graphic object is a rectangle that completely encloses the drawing area of the object. The implementation of this method usually does not guarantee that the returned rectangle is the smallest bounding box that encloses the drawing area, only that the drawing area lies entirely within the returned rectangle.

Since the caller of this method may modify the returned rectangle, your implementation should avoid to return internally stored rectangles, that is, you should return a newly allocated rectangle. The following example shows how to do this:

   public IlvRect boundingBox(IlvTransformer t) {
     // drawrect is an internaly stored rectangle
     IlvRect rect = new IlvRect(drawrect);
     if (!(t == null || t.isIdentity())) 
       t.apply(rect);  
     return rect;
   }
 

Parameters:
t - The transformer used to draw the object. If the transformer is null, the bounding box for the identity transformer is returned.
See Also:
draw(java.awt.Graphics, ilog.views.IlvTransformer), zoomable(), IlvGraphic

boundingBox

public final IlvRect boundingBox()
Returns the bounding rectangle of the object for the identity transformation. This is the equivalent of calling boundingBox(null). The bounding box for a graphic object is the smallest rectangle containing the entire drawing area of the object.

See Also:
boundingBox(IlvTransformer), IlvGraphic

getCenter

public IlvPoint getCenter(IlvTransformer t)
Returns the center point of the graphic object. By default, it returns the center of the bounding rectangle. The returned point can be used as rotation center to rotate the object.

Parameters:
t - The transformer used to draw the object. If the transformer is null, the center for the identity transformer is returned.
Returns:
The center point of this graphic object. This point can be used as the center point to rotate the object.
Since:
JViews 8.0
See Also:
IlvGraphic

applyTransform

public abstract void applyTransform(IlvTransformer t)
Applies a transformation to the shape of the object. A transformation can be applied for instance to move, rotate or resize the object.

Note that the method must never be called with a null argument.

Parameters:
t - The transformation to be applied.
See Also:
IlvGraphic

contains

public boolean contains(IlvPoint p,
                        IlvPoint tp,
                        IlvTransformer t)
Tests if a point lies within the outline of the object. The default implementation tests if a point lies inside the bounding rectangle of the object, as computed by the method boundingBox(ilog.views.IlvTransformer) for the transformer t.

Note: override this method if this implementation is not correct for your customized graphic object.

Parameters:
p - The point to be tested.
tp - The point p transformed by the transformer t.
t - The transformation used to draw the object.
Returns:
true if the point lies inside this graphic object.
See Also:
IlvGraphic

intersects

public boolean intersects(IlvRect rect,
                          IlvRect trect,
                          IlvTransformer t)
Tests if a rectangle overlaps the object. The default implementation tests if a rectangle overlaps the bounding rectangle of the object, as computed by the method boundingBox(ilog.views.IlvTransformer) for the transformer t.

Note: override this method if this implementation is not correct for your customized graphic object.

Parameters:
rect - The rectangle to be tested.
trect - The rectangle rect transformed by the transformer t.
t - The transformation used to draw the object.
Returns:
true if the rectangle overlaps this graphic object.
See Also:
IlvGraphic

inside

public boolean inside(IlvRect rect,
                      IlvRect trect,
                      IlvTransformer t)
Tests if a rectangle contains the object. The default implementation tests if a rectangle contains the bounding rectangle of the object, as computed by the method boundingBox(ilog.views.IlvTransformer) for the transformer t.

Note: override this method if this implementation is not correct for your customized graphic object.

Parameters:
rect - The rectangle to be tested.
trect - The rectangle rect transformed by the transformer t.
t - The transformation used to draw the object.
See Also:
IlvGraphic

getIntersectionWithOutline

public IlvPoint getIntersectionWithOutline(IlvPoint innerPoint,
                                           IlvPoint outerPoint,
                                           IlvTransformer t)
Returns the intersection of the line segment from inner point to outer point with the shape of the graphic object. This method is used the clip links against the shape of the node. The implementation of this method must be robust with respect to the input points: Even if innerPoint is not inside the graphic object, or if outerPoint is not outside the graphic object, it must return a valid point. For instance, if there is no intersection, it can return the start point.

The default implementation calculates the intersection with the bounding box.

Parameters:
innerPoint - A point usually inside the graphic object, given in manager view coordinates.
outerPoint - A point usually outside of the graphic object, given in manager view coordinates.
t - The transformation used to draw the object.
Since:
JViews 8.1
See Also:
IlvGraphic, IlvClippingLinkConnector

move

public void move(float x,
                 float y)
Moves the object. Moves the top-left corner of the bounding box of this graphic object to the position (x, y). The position must be given in untransformed coordinates. The default implementation calls translate(float, float) (and this calls applyTransform(ilog.views.IlvTransformer)).

Parameters:
x - The new horizontal position.
y - The new vertical position.
See Also:
IlvGraphic, applyTransform(IlvTransformer)

move

public void move(IlvPoint p)
Moves the object. Moves the top-left corner of the bounding box of this graphic object to the point p. The position must be given in untransformed coordinates. The default implementation calls move(float, float) (and this calls applyTransform(ilog.views.IlvTransformer)).

Parameters:
p - The new position of the top-left corner.
See Also:
IlvGraphic, applyTransform(IlvTransformer)

moveResize

public void moveResize(IlvRect size)
Resizes the object. The method sets the bounding rectangle of this graphic object to the rectangle size. The rectangle must be given in untransformed coordinates. The default implementation calculates the difference transformation between the current and the desired bounding box and then calls applyTransform(ilog.views.IlvTransformer) to resize the graphic object.

Parameters:
size - The new bounding rectangle for this object.
See Also:
IlvGraphic, applyTransform(IlvTransformer)

translate

public void translate(float dx,
                      float dy)
Translates the object. Translates the bounding box of this object by the vector (dx, dy). The vector must be given in untransformed coordinates. The default implementation calls applyTransform(ilog.views.IlvTransformer) to translate the graphic object.

Parameters:
dx - The horizontal translation factor.
dy - The vertical translation factor.
See Also:
IlvGraphic, applyTransform(IlvTransformer)

rotate

public void rotate(IlvPoint center,
                   double angle)
Rotates the object. Rotates this object by angle degrees around the point center. The center must be given in untransformed coordinates. The default implementation calls applyTransform(ilog.views.IlvTransformer) to rotate the graphic object.

Parameters:
center - The center of the rotation.
angle - The rotation angle in degrees.
See Also:
IlvGraphic, applyTransform(IlvTransformer)

scale

public void scale(double scalex,
                  double scaley)
Resizes the object. Resizes the bounding rectangle of this object by factor (scalex, scaley). The default implementation calls applyTransform(ilog.views.IlvTransformer) to scale the graphic object.

Parameters:
scalex - The horizontal scaling factor.
scaley - The vertical scaling factor.
See Also:
IlvGraphic, applyTransform(IlvTransformer)

resize

public void resize(float neww,
                   float newh)
Resizes the object. The bounding rectangle of this object is set to the new width and height (neww, newh). The default implementation calls scale(double, double) (and this calls applyTransform(ilog.views.IlvTransformer)).

Parameters:
neww - The new horizontal width.
newh - The new horizontal height.
See Also:
IlvGraphic, applyTransform(IlvTransformer)

setGraphicBag

public void setGraphicBag(IlvGraphicBag bag)
Changes the bag that contains the object. This method is used when the object is added to, or removed from, an IlvGraphicBag such as an IlvManager.

Note: do not call this method directly unless you are creating a custom graphics bag.

Parameters:
bag - The graphic bag to contain this graphic object.
See Also:
IlvGraphic

getGraphicBag

public final IlvGraphicBag getGraphicBag()
Returns the graphic bag that contains the object. If this object is not part of a graphic bag, null is returned.

See Also:
setGraphicBag(ilog.views.IlvGraphicBag), IlvGraphic

getTopLevelGraphicBag

public final IlvGraphicBag getTopLevelGraphicBag()
Returns the top level graphic bag. The IlvManager graphic bag is itself a graphic object. Graphic bags and graphic objects can be nested inside other graphic objects or graphic bags. Nesting allows you to create applications that control and display graphic objects inside other graphic objects. If this object is contained in a graphic bag that itself is recursively contained in a graphic bag, then it returns the topmost graphic bag that is not contained in any graphic bag.

Since:
JViews 5.0
See Also:
getGraphicBag(), IlvGraphicBag.getGraphicBag(), setGraphicBag(ilog.views.IlvGraphicBag), IlvGraphic

setForeground

public void setForeground(Color c)
Changes the foreground color of the object. The default implementation does nothing. Override this method to set the foreground color for your custom graphic object.

Note: not all graphic objects have a foreground color. A call to this method may not do anything.

Parameters:
c - The new foreground color.
See Also:
draw(Graphics, IlvTransformer), setBackground(Color), setFillOn(boolean), setStrokeOn(boolean), IlvGraphic

setBackground

public void setBackground(Color c)
Changes the background color of the object. The default implementation does nothing. Override this method to set the background color for your custom graphic object.

Note: not all graphic objects have a background color. A call to this method may not need to do anything.

Parameters:
c - The new background color.
See Also:
draw(Graphics, IlvTransformer), setForeground(Color), setFillOn(boolean), setStrokeOn(boolean), IlvGraphic

setFillOn

public void setFillOn(boolean value)
Changes the fill status of the object. The default implementation does nothing. Override this method to enable or disable the fill style for your custom graphic object.

Note: not all graphic objects have a fill style. A call to this method may not need to do anything.

Parameters:
value - Set to true to enable the fill style for this graphic object.
Since:
JViews 5.5
See Also:
draw(Graphics, IlvTransformer), setBackground(Color), setForeground(Color), setStrokeOn(boolean), IlvGraphic

setStrokeOn

public void setStrokeOn(boolean value)
Changes the stroke status of the object. The default implementation does nothing. Override this method to enable or disable the stroke for your custom graphic object.

Note: not all graphic objects have a stroke style. A call to this method may not need to do anything.

Parameters:
value - Set to true to enable the stroke in your customized graphic object.
Since:
JViews 5.5
See Also:
draw(Graphics, IlvTransformer), setBackground(Color), setForeground(Color), setFillOn(boolean), IlvGraphic

reDraw

public void reDraw()
Redraws this object. The default implementation calls IlvGraphicBag.reDrawObj(ilog.views.IlvGraphic) from the graphic bag holding this graphic object.

See Also:
draw(Graphics, IlvTransformer), IlvGraphic

setName

public void setName(String name)
Sets the name of the object. The default implementation calls IlvGraphicBag.setObjectName(ilog.views.IlvGraphic, java.lang.String) from the graphic bag holding this graphic object.

Note: no two objects contained in an manager can have the same name. If the graphic bag already contains a graphic object called name, this graphic object will not be re-named.

Parameters:
name - The new name for this graphic object.
See Also:
IlvManager.setObjectName(ilog.views.IlvGraphic, java.lang.String)

setNameImpl

public void setNameImpl(String name)
Sets the name of the object. You should not call this method, the method is public for implementation purposes.

Since:
JViews 5.0
Internal method or field: do not use!

getName

public String getName()
Returns the name of the object.


removeProperty

public boolean removeProperty(String key)
Removes a property.

Parameters:
key - The key of the property to be removed. The key null is not allowed.
Returns:
true if the property was found and has been removed.
See Also:
getProperty(String), setProperty(String, Object), replaceProperty(String, Object), IlvGraphic

setProperty

public void setProperty(String key,
                        Object value)
Sets the value of a property. The method sets the value of property key to value if value is not null.

If property key does not exist, this property is added to the properties list. If property key is already exists, its value is replaced by value. If value is null and property key is already in the properties list, this property is removed.

Parameters:
key - The key of the property to be added. The key null is not allowed.
value - The new value for the property.
See Also:
getProperty(String), removeProperty(String), replaceProperty(String, Object), IlvGraphic

replaceProperty

public boolean replaceProperty(String key,
                               Object value)
Replaces the value of an existing property.

Parameters:
key - The key of the property to be replaced. The key null is not allowed.
value - The new value of the property. The value must not be null.
Returns:
true if property key was found and it's value has been replaced with value.
See Also:
getProperty(String), setProperty(String, Object), removeProperty(String), replaceProperty(String, Object), IlvGraphic

getProperty

public Object getProperty(String key)
Returns the value of a property.

Parameters:
key - The key of the property. The key null is not allowed.
Returns:
The value of a property key or null if property key does not exist.
See Also:
setProperty(String, Object), removeProperty(String), replaceProperty(String, Object), IlvGraphic

hasProperty

public boolean hasProperty(String key,
                           Object value)
Tests the value of a property.

Parameters:
key - The key of the property. The key null is not allowed.
value - The value to be tested.
Returns:
true if the value of the property key is value.
See Also:
IlvGraphic, setProperty(String, Object), removeProperty(String), replaceProperty(String, Object)

isVisible

public boolean isVisible()
Tests whether this graphic object is visible.

Returns:
true if this graphic object is visible.
See Also:
setVisible(boolean), setSelectable(boolean), setMovable(boolean), setEditable(boolean)

setVisible

public final void setVisible(boolean v)
Sets the visibility for this graphic object.

Note: This method is useful if the object is outside a manager. Call IlvManager.setVisible(IlvGraphic, boolean, boolean) instead when this object is stored inside a manager.

Parameters:
v - Set to true for this object to be visible. If an object is editable, edits are controlled using IlvSelectInteractor.
See Also:
isVisible(), IlvManager.setVisible(IlvGraphic, boolean, boolean)

isMovable

public boolean isMovable()
Tests whether this graphic object is movable with the selection interactor.

Returns:
true if this graphic object is movable.
Since:
JViews 8.0
See Also:
setVisible(boolean), setSelectable(boolean), setMovable(boolean), setEditable(boolean), IlvSelectInteractor, IlvGraphic

setMovable

public final void setMovable(boolean movable)
Allows or prohibits movement of this graphic object with the selection interactor.

Parameters:
movable - Set to true to allow this graphic object to be moved inside a view with the selection interactor.
Since:
JViews 8.0
See Also:
IlvGraphic, isMovable(), IlvSelectInteractor

isEditable

public final boolean isEditable()
Tests if this graphic object is editable with the selection interactor.

Returns:
true if this graphic object is editable.
Since:
JViews 8.0
See Also:
setVisible(boolean), setSelectable(boolean), setMovable(boolean), setEditable(boolean), IlvSelectInteractor, IlvGraphic

setEditable

public final void setEditable(boolean editable)
Allows or disallows editing for this graphic object with the selection interactor.

Parameters:
editable - Set to true to enable editing for this graphic object inside a view with the selection interactor.
Since:
JViews 8.0
See Also:
isEditable(), IlvSelectInteractor

isSelectable

public boolean isSelectable()
Tests if this graphic object can be selected with the selection interactor.

Note: if this object is stored inside a manager, use IlvManager.isSelectable(IlvGraphic) instead of this method, because that checks also the capacity of the manager layer being selected.

Returns:
true if this graphic object can be selected.
Since:
JViews 8.0
See Also:
IlvManager.isSelectable(IlvGraphic), IlvManagerLayer.isSelectable(), setVisible(boolean), setSelectable(boolean), setMovable(boolean), setEditable(boolean), IlvSelectInteractor, IlvGraphic

setSelectable

public final void setSelectable(boolean selectable)
Allows or disallows selection for this graphic object with the selection interactor.

Parameters:
selectable - Set to true to enable selection for this graphic object.
Since:
JViews 8.0
See Also:
isSelectable(), IlvSelectInteractor

addActionListener

public final void addActionListener(ActionListener listener)
Adds the specified action listener to receive action events from this object.

The following code example shows how to add an action listener to a graphic object.

 myGraphic.addActionListener(new ActionListener() {
   public void actionPerformed(ActionEvent evt) {
     ...
   }
 });
 

Parameters:
listener - The action listener.
See Also:
removeActionListener(java.awt.event.ActionListener), processActionEvent(java.awt.event.ActionEvent), IlvGraphic

removeActionListener

public final void removeActionListener(ActionListener listener)
Removes the specified action listener. Once listener is removed, it no longer receives action events from this graphic object.

Parameters:
listener - The action listener.
See Also:
addActionListener(java.awt.event.ActionListener), processActionEvent(java.awt.event.ActionEvent), IlvGraphic

processActionEvent

public void processActionEvent(ActionEvent event)
Processes action events on this object instance by dispatching them to all ActionListener objects registered with this graphic object. You should normally not call this method directly.

See Also:
addActionListener(java.awt.event.ActionListener), removeActionListener(java.awt.event.ActionListener), IlvGraphic

makeSelection

public IlvSelection makeSelection()
Creates a selection object for this object. The default implementation creates an instance of IlvDrawSelection.

Override this method in your custom graphic object to use a different selection object.

You should normally not call this method directly.

See Also:
IlvDrawSelection

getDefaultInteractor

public String getDefaultInteractor()
Returns the class name of the default interactor. The default implementation returns null. Override this method to return the class name of the default interactor.

See Also:
IlvGraphic

getObjectInteractor

public final IlvObjectInteractor getObjectInteractor()
Returns the object interactor associated with this object.

Since:
JViews 5.0
See Also:
setObjectInteractor(ilog.views.IlvObjectInteractor), IlvGraphic

setObjectInteractor

public final void setObjectInteractor(IlvObjectInteractor interactor)
Changes the object interactor associated with this object.

Parameters:
interactor - The new object interactor. Set this value to null to remove the existing interactor from this object.
Since:
JViews 5.0
See Also:
getObjectInteractor(), IlvGraphic

notifyObjectInteractorToManager

protected void notifyObjectInteractorToManager(IlvObjectInteractor interactor)
Notifies the manager that the object interactor has changed.

Since:
JViews 8.1
Internal method or field: do not use!

getAndAssociateObjectInteractor

public final IlvObjectInteractor getAndAssociateObjectInteractor()
Returns the active object interactor. This is a convenience method. It returns the object interactor associated with this object. If no object interactor is associated with this object, it returns the default object interactor and associates it with this object.

Since:
JViews 8.0
See Also:
getObjectInteractor(), setObjectInteractor(ilog.views.IlvObjectInteractor), getDefaultInteractor(), IlvGraphic

write

public void write(IlvOutputStream stream)
           throws IOException
Writes this object to an IlvOutputStream.

You should not call this method directly; instead, you should use the write methods of the manager.

When overriding this method to save additional information stored in your custom graphic, this superclass write method must to be called first. The following example shows how to do this:

 public void write(IlvOutputStream stream) throws IOException
 {
   super.write(stream);
   stream.write("myFieldName", myField);
 }
 

Specified by:
write in interface IlvPersistentObject
Parameters:
stream - The output stream to write this graphic object to.
Throws:
IOException - thrown when an exception occurs during the write operation for this object.

isPersistent

public boolean isPersistent()
If this method returns true, the IlvGraphic instance will be saved in IVL files. The default implementation returns true. Override this method to return false in those situations when this graphic object cannot be be saved to a .IVL file.

Since:
JViews 6.0

getTransferDataFlavors

public DataFlavor[] getTransferDataFlavors()
Returns an array of DataFlavor objects indicating in which flavors the data can be provided. By default, the only flavor supported by IlvGraphic is DataFlavor.stringFlavor.

Specified by:
getTransferDataFlavors in interface Transferable
Returns:
An array of data flavors in which this data can be transferred.

isDataFlavorSupported

public boolean isDataFlavorSupported(DataFlavor flavor)
Indicates whether the specified data flavor is supported for this object or not. By default, the only flavor supported by IlvGraphic is DataFlavor.stringFlavor.

Specified by:
isDataFlavorSupported in interface Transferable
Parameters:
flavor - The data flavor to be tested.
Returns:
Returns true if the data flavor is supported.

getTransferData

public Object getTransferData(DataFlavor flavor)
                       throws UnsupportedFlavorException,
                              IOException
Returns an object that represents the data to be transferred. The class of the object returned is defined by the representation class of the flavor. The only flavor supported by the default IlvGraphic implementation is DataFlavor.stringFlavor. Override this method to handle other DataFlavors.

Note: This method is called when you pass the IlvGraphic instance as a Transferable object. Normally you do not need to call this method directly.

Specified by:
getTransferData in interface Transferable
Parameters:
flavor - The requested data flavor.
Returns:
An object that represents the data to be transferred.
Throws:
IOException - if the data is not writable.
UnsupportedFlavorException - if the requested data flavor is not supported.
See Also:
GetGraphicObject(java.awt.datatransfer.Transferable)

GetGraphicObject

public static IlvGraphic GetGraphicObject(Transferable trans)
                                   throws IOException
A static method that decodes a Transferable<