ilog.views.graphic.composite.decoration
Class IlvAssociation

java.lang.Object
  extended by ilog.views.IlvGraphic
      extended by ilog.views.graphic.IlvGraphicSet
          extended by ilog.views.graphic.composite.decoration.IlvAssociation
All Implemented Interfaces:
GraphicBagHierarchyEventReceiver, ManagerContentChangedListener, ManagerViewsHierarchyEventReceiver, IlvGraphicBag, IlvPersistentObject, Transferable, Serializable, EventListener

public class IlvAssociation
extends IlvGraphicSet
implements ManagerContentChangedListener, IlvPersistentObject

An IlvAssociation contains an IlvLine that connects to the center point of two graphic objects. The connection point for the anchor and callout nodes can be either of the following:

The default values for an IlvAssociation instance are as follows:

Example

The following code example shows how to use IlvAssociation in a simple Java application:
  IlvGrapher grapher = new IlvGrapher();
  
  // Creates the origin and the destination nodes
  IlvRectangle origin = new IlvReliefRectangle(new IlvRect(50,80,40,40));
  origin.setBackground(Color.lightGray);
  grapher.addNode(origin,false);
      
  IlvRectangle dest = new IlvReliefRectangle(new IlvRect(250,80,40,40));
  dest.setBackground(Color.lightGray);
  grapher.addNode(dest,false);
  
  // Creates the link between the nodes
  IlvLinkImage link = new IlvPolylineLinkImage(origin,dest,false,null);
  link.setLineWidth(5);
  link.setForeground(Color.decode("#40BFBD"));
  grapher.addLink(link,false);
  
  // Creates a composite which groups a label and a left bracket
  IlvCompositeGraphic callout = new IlvCompositeGraphic();
  IlvCenteredLayout cl = new IlvCenteredLayout();
  cl.setInsets(new Insets(5,5,5,5));
  callout.setLayout(cl);
  
  // Creates the bracket
  IlvBracket bracket = new IlvBracket();
  bracket.move(10,10);
  bracket.setFillOn(true);
  bracket.setBackground(Color.white);
  bracket.setWidthRatio(0.5f);
  callout.setChildren(0,bracket);
  
  // Creates the text
  IlvText text = new IlvText(new IlvPoint(),"This is a link annotation");
  text.setFont(Font.decode("sansserif-BOLD-10"));
  callout.setChildren(1,text);
  
  grapher.addNode(callout,false);
  
  // Creates the association which links the bracket to the link
  IlvAssociation association = new IlvAssociation();
  association.setAnchor(link);
  association.setCallout(callout);
  association.setLineWidth(1);
  association.setForeground(Color.black);
  association.setLineStyle(new float[]{2.0f,4.0f});
  grapher.addNode(association,false);
 

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

About Graphic Objects

IlvAssociation 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.

Since:
JViews 6.0
See Also:
IlvCompositeGraphic, IlvCenteredLayout, IlvManager, IlvManagerView, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class ilog.views.graphic.IlvGraphicSet
IlvGraphicSet.DelegateObjectInteractor
 
Field Summary
 
Fields inherited from class ilog.views.graphic.IlvGraphicSet
list
 
Constructor Summary
IlvAssociation()
          Creates an IlvAssociation with the default values.
IlvAssociation(IlvAssociation source)
          Creates a new IlvAssociation by copying an existing one.
IlvAssociation(IlvGraphic anchor)
          Creates an IlvAssociation with the supplied anchor.
IlvAssociation(IlvInputStream stream)
          Reads the object from an IlvInputStream.
 
Method Summary
 void contentsChanged(ManagerContentChangedEvent evt)
          This method is called by the manager, to notify content modifications.
 IlvGraphic copy()
          Copies this object.
 IlvGraphic getAnchor()
          Returns the IlvGraphic which defines the anchor point of the association.
 IlvGraphic getCallout()
          Returns the callout of this association.
 Color getForeground()
          Returns the color of the line.
 IlvLine getLine()
          Returns the line that represents the association.
 float[] getLineStyle()
          Returns the array representing the lengths of the dash segments.
 float getLineWidth()
          Returns the line width of the object.
 float getMaximumLineWidth()
          Returns the maximum line width of the line.
 IlvSelection makeSelection()
          Creates a selection object for this object.
 void setAnchor(IlvGraphic anchor)
          Sets the IlvGraphic which defines the anchor point of the association.
 void setCallout(IlvGraphic graphic)
          Defines the callout of this association.
 void setForeground(Color color)
          Changes the color of the line.
 void setGraphicBag(IlvGraphicBag bag)
          Changes the bag that contains the object.
 void setLine(IlvLine line)
          Sets the line that associates the anchor callout and the callout callout
 void setLineStyle(float[] lineStyle)
          Changes the array representing the lengths of the dash segments.
 void setLineWidth(float lineWidth)
          Changes the line width of the object.
 void setMaximumLineWidth(float maximumLineWidth)
          Changes the maximum line width of the line.
 void write(IlvOutputStream stream)
          Writes the attributes of a persistent object.
 boolean zoomable()
          Returns always false, because this object is not zoomable.
 
Methods inherited from class ilog.views.graphic.IlvGraphicSet
addGraphicBagHierarchyListener, addManagerViewsHierarchyListener, addObject, addObjectAt, applyToObject, applyTransform, boundingBox, contains, contains, draw, drawCore, enableGraphicBagHierarchyEventForwarding, enableManagerViewsHierarchyEventForwarding, fireGraphicBagHierarchyEvent, fireManagerViewsHierarchyEvent, firstContains, getAlpha, getCardinal, getClip, getIndex, getIntersectionWithOutline, getObject, getObject, getObjectName, getObjects, getOriginalPopupMenu, getPopupMenu, getToolTipText, isPersistent, moveObject, needsGraphicBagHierarchyEvent, needsManagerViewsHierarchyEvent, reDrawObj, reDrawRegion, removeAll, removeGraphicBagHierarchyListener, removeManagerViewsHierarchyListener, removeObject, removeObjectAt, reshapeObject, setAlpha, setClip, setObjectName
 
Methods inherited from class ilog.views.IlvGraphic
addActionListener, addNamedPropertyListener, boundingBox, getAndAssociateObjectInteractor, getCenter, getDefaultInteractor, getGraphicBag, GetGraphicObject, getName, getNamedProperty, getObjectInteractor, getPopupMenu, getPopupMenuName, getProperty, getToolTipText, getTopLevelGraphicBag, getTransferData, getTransferDataFlavors, hasProperty, inside, intersects, isDataFlavorSupported, isEditable, isInApplyToObject, isMovable, isSelectable, isVisible, move, move, moveResize, notifyObjectInteractorToManager, processActionEvent, reDraw, removeActionListener, removeNamedProperty, removeNamedPropertyListener, removeProperty, replaceProperty, resize, rotate, scale, setBackground, setEditable, setFillOn, setInApplyToObject, setMovable, setName, setNamedProperty, setNameImpl, setObjectInteractor, setPopupMenu, setPopupMenuName, setProperty, setSelectable, setStrokeOn, setToolTipText, setVisible, toString, translate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ilog.views.IlvGraphicBag
getGraphicBag
 

Constructor Detail

IlvAssociation

public IlvAssociation()
Creates an IlvAssociation with the default values.


IlvAssociation

public IlvAssociation(IlvInputStream stream)
               throws IlvReadFileException
Reads the object from an IlvInputStream.

Parameters:
stream - The input stream.
Throws:
IlvReadFileException - if the format is not correct.

IlvAssociation

public IlvAssociation(IlvGraphic anchor)
Creates an IlvAssociation with the supplied anchor.


IlvAssociation

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

Method Detail

copy

public IlvGraphic copy()
Copies this object.

Overrides:
copy in class IlvGraphicSet
Returns:
A copy of this object.
See Also:
IlvGraphic

getLine

public IlvLine getLine()
Returns the line that represents the association.


setLine

public void setLine(IlvLine line)
Sets the line that associates the anchor callout and the callout callout


getAnchor

public IlvGraphic getAnchor()
Returns the IlvGraphic which defines the anchor point of the association.


setAnchor

public void setAnchor(IlvGraphic anchor)
Sets the IlvGraphic which defines the anchor point of the association. The anchor can be either:


getCallout

public IlvGraphic getCallout()
Returns the callout of this association.


setCallout

public void setCallout(IlvGraphic graphic)
Defines the callout of this association.


setGraphicBag

public void setGraphicBag(IlvGraphicBag bag)
Changes the bag that contains the object.

Overrides:
setGraphicBag in class IlvGraphicSet
Parameters:
bag - The graphic bag to contain this graphic object.
See Also:
IlvGraphic

contentsChanged

public void contentsChanged(ManagerContentChangedEvent evt)
This method is called by the manager, to notify content modifications.

Specified by:
contentsChanged in interface ManagerContentChangedListener
Parameters:
evt - the "content changed" event.
See Also:
IlvManager.addManagerContentChangedListener(ilog.views.event.ManagerContentChangedListener), IlvManager.removeManagerContentChangedListener(ilog.views.event.ManagerContentChangedListener), IlvManager.addManagerTreeContentChangedListener(ilog.views.event.ManagerContentChangedListener), IlvManager.removeManagerTreeContentChangedListener(ilog.views.event.ManagerContentChangedListener)

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.

Overrides:
makeSelection in class IlvGraphic
See Also:
IlvDrawSelection

zoomable

public boolean zoomable()
Returns always false, because this object is not zoomable.

Overrides:
zoomable in class IlvGraphicSet
See Also:
IlvGraphic, IlvGraphic.draw(java.awt.Graphics, ilog.views.IlvTransformer), IlvGraphic.boundingBox(IlvTransformer), IlvManager

write

public void write(IlvOutputStream stream)
           throws IOException
Writes the attributes of a persistent object.

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

getLineStyle

public float[] getLineStyle()
Returns the array representing the lengths of the dash segments. Alternate entries in the array represent the user space lengths of the opaque and transparent segments of the dashes.


setLineStyle

public void setLineStyle(float[] lineStyle)
Changes the array representing the lengths of the dash segments. Alternate entries in the array represent the user space lengths of the opaque and transparent segments of the dashes.

Parameters:
lineStyle - The new line style.

getLineWidth

public float getLineWidth()
Returns the line width of the object. The default value is 0.


setLineWidth

public void setLineWidth(float lineWidth)
Changes the line width of the object.

Parameters:
lineWidth - The new line width.

setForeground

public void setForeground(Color color)
Changes the color of the line.

Overrides:
setForeground in class IlvGraphic
Parameters:
color - The new color.
See Also:
IlvGraphic.draw(Graphics, IlvTransformer), IlvGraphic.setBackground(Color), IlvGraphic.setFillOn(boolean), IlvGraphic.setStrokeOn(boolean), IlvGraphic

getForeground

public Color getForeground()
Returns the color of the line.

Returns:
The color of the object.

getMaximumLineWidth

public float getMaximumLineWidth()
Returns the maximum line width of the line. If the maximum line width is specified and not equal to zero, the width of the line will stop zooming when the maximum line width is reached. The default value is zero (no limit).


setMaximumLineWidth

public void setMaximumLineWidth(float maximumLineWidth)
Changes the maximum line width of the line. If the maximum line width is specified and not equal to zero, then the width of the line will stop zooming when the maximum line width is reached. A value of zero means that there is no limit.

Parameters:
maximumLineWidth - The new maximum line width.


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