ilog.views.graphic
Class IlvComponentGraphic

java.lang.Object
  extended by ilog.views.IlvGraphic
      extended by ilog.views.graphic.IlvComponentGraphic
All Implemented Interfaces:
IlvPersistentObject, Transferable, Serializable

public class IlvComponentGraphic
extends IlvGraphic

IlvComponentGraphic is used to mix graphic objects and lightweight Java Components. A lightweight component is a component that is written entirely in Java, that is, it is not associated with a native peer.

Note: use IlvJComponentGraphic and not IlvComponentGraphic to add Java Swing components to your custom application.

Example

The following code example shows how to use an IlvComponentGraphic to include a lightweight component in a simple Java application:

   public class RoundButton extends Component {
   
       public RoundButton() {
         this.setSize(new Dimension(50,50));
       }
       
       public void paint(Graphics g) {
           int s = Math.min(getSize().width - 1, getSize().height - 1);
           
           g.setColor(getBackground());
           g.fillArc(0, 0, s, s, 0, 360);
           
           // draw the perimeter of the button
           g.setColor(getBackground().darker().darker().darker());
           g.drawArc(0, 0, s, s, 0, 360);
       }
   }
   
   public class myCustomApp {
     ...
     public static void main(String[] args) {
  
       IlvManager manager = new IlvManager();
       IlvManagerView view = new IlvManagerView(manager);
       view.setBackground(Color.WHITE);
       // Creates the component graphic
       RoundButton myButton = new RoundButton();
       IlvComponentGraphic compGraphic = new     
         IlvComponentGraphic(new IlvRect(5,5,100,100),
           myButton, 
           view);
       ...
     }
   }
 

The following image shows the graphic objects created in the code example:

IlvComponentGraphic

About Graphic Objects

IlvComponentGraphic is a custom graphic object, that is, a subclass of IlvGraphic. Graphic objects are controlled using an IlvManager instance and displayed using one or more IlvManagerView instances in a Java Swing application. For information about generic features for graphic objects, see IlvGraphic.

See Also:
IlvJComponentGraphic, IlvManager, IlvManagerView, Serialized Form

Field Summary
protected  IlvRect drawrect
          The bounding rectangle of the object.
 
Constructor Summary
IlvComponentGraphic(IlvRect rect, Component component, IlvManagerView v)
          Creates a new component graphic for a specified component.
 
Method Summary
 void applyTransform(IlvTransformer t)
          Applies a transformation to the shape of the object.
 IlvRect boundingBox(IlvTransformer t)
          Returns the bounding rectangle of the object.
 IlvGraphic copy()
          Copies the object.
 void draw(Graphics dst, IlvTransformer t)
          Draws the object by calling the paint method of the component.
 Component getComponent()
          Returns the component.
 boolean isPersistent()
          If this method returns true, the IlvGraphic instance will be saved in IVL files.
 void setGraphicBag(IlvGraphicBag bag)
          Changes the bag that contains the object.
 void setView(IlvManagerView v)
          Adds the component to a manager view.
 
Methods inherited from class ilog.views.IlvGraphic
addActionListener, addNamedPropertyListener, boundingBox, contains, getAndAssociateObjectInteractor, getCenter, getDefaultInteractor, getGraphicBag, GetGraphicObject, getIntersectionWithOutline, getName, getNamedProperty, getObjectInteractor, getPopupMenu, getPopupMenu, getPopupMenuName, getProperty, getToolTipText, getToolTipText, getTopLevelGraphicBag, getTransferData, getTransferDataFlavors, hasProperty, inside, intersects, isDataFlavorSupported, isEditable, isInApplyToObject, isMovable, isSelectable, isVisible, makeSelection, move, move, moveResize, notifyObjectInteractorToManager, processActionEvent, reDraw, removeActionListener, removeNamedProperty, removeNamedPropertyListener, removeProperty, replaceProperty, resize, rotate, scale, setBackground, setEditable, setFillOn, setForeground, setInApplyToObject, setMovable, setName, setNamedProperty, setNameImpl, setObjectInteractor, setPopupMenu, setPopupMenuName, setProperty, setSelectable, setStrokeOn, setToolTipText, setVisible, toString, translate, write, zoomable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

drawrect

protected final IlvRect drawrect
The bounding rectangle of the object.

Constructor Detail

IlvComponentGraphic

public IlvComponentGraphic(IlvRect rect,
                           Component component,
                           IlvManagerView v)
Creates a new component graphic for a specified component. This constructor adds the component in the specified view. The component may be displayed in multiple views, but it will react (receive events) only in the view where it has been added.

Parameters:
rect - The rectangle defining the size of the component.
component - The component.
v - The manager view where the component will be added. It can be null: the component must then be added later to a manager view with the setView method.
Method Detail

setView

public void setView(IlvManagerView v)
Adds the component to a manager view.

Parameters:
v - The manager view where the component will be added. It can be null to remove the component from its view.

setGraphicBag

public void setGraphicBag(IlvGraphicBag bag)
Changes the bag that contains the object. You should not call this method directly.

Overrides:
setGraphicBag in class IlvGraphic
Parameters:
bag - The graphic bag.
See Also:
IlvGraphic

getComponent

public Component getComponent()
Returns the component.


copy

public IlvGraphic copy()
Copies the object.

Specified by:
copy in class IlvGraphic
Returns:
null; this object cannot be copied.
See Also:
IlvGraphic

draw

public void draw(Graphics dst,
                 IlvTransformer t)
Draws the object by calling the paint method of the component.

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

boundingBox

public IlvRect boundingBox(IlvTransformer t)
Returns the bounding rectangle of the object.

Specified by:
boundingBox in class IlvGraphic
Parameters:
t - The transformer used to draw the object.
See Also:
IlvGraphic.draw(java.awt.Graphics, ilog.views.IlvTransformer), IlvGraphic.zoomable(), IlvGraphic

applyTransform

public void applyTransform(IlvTransformer t)
Applies a transformation to the shape of the object.

Specified by:
applyTransform in class IlvGraphic
Parameters:
t - The transformer to be applied.
See Also:
IlvGraphic

isPersistent

public boolean isPersistent()
If this method returns true, the IlvGraphic instance will be saved in IVL files. This method always returns false for IlvComponentGraphic.

Overrides:
isPersistent in class IlvGraphic
Returns:
Whether the IlvGraphic is persistent or not.
Since:
JViews 6.0


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.