ilog.views.graphic.composite.decoration
Class IlvDiamond

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

public class IlvDiamond
extends IlvGraphic

IlvDiamond represents a diamond shape. This class is designed to be used with an IlvCompositeGraphic instance.

The default values for an IlvDiamond instance are as follows:

Example

The following code example shows how to use IlvDiamond in a simple Java application:

  // Creates the grapher to hold the composite graphic
  IlvGrapher grapher = new IlvGrapher();
  // Creates the composite graphic with an IlvAttachmentLayout layout
  IlvCompositeGraphic composite = new IlvCompositeGraphic();
  IlvAttachmentLayout attLayout = new IlvAttachmentLayout();
  composite.setLayout(attLayout);
  
  IlvDiamond diamond = new IlvDiamond(new IlvRect(5,5,80,130));
  diamond.setFillOn(true);
  diamond.setBackground(Color.red);
  diamond.setForeground(Color.blue);
  diamond.setStroke(new BasicStroke(4));
  
  composite.setChildren(0,diamond);
  
  IlvText text = new IlvText(new IlvPoint(10,10),"IlvDiamond");
  composite.setChildren(1,text);
  //Attach the top center point of the text object to the bottom center 
  //point of the diamond.
  composite.setConstraints(1,
      new IlvAttachmentConstraint(IlvAttachmentLocation.TopCenter,
      IlvAttachmentLocation.BottomCenter));
  
  grapher.addNode(composite,true);
 

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

IlvDiamond

About Graphic Objects

IlvDiamond is a custom graphic object, that is, a subclass of IlvGraphic. Graphic objects are controlled using an instance of IlvManager or one of its subclasses, 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:
IlvManager, IlvManagerView, Serialized Form

Constructor Summary
IlvDiamond()
          Default bean constructor.
IlvDiamond(IlvDiamond source)
          Creates a new IlvDiamond by copying an existing one.
IlvDiamond(IlvInputStream stream)
          Reads the object from an IlvInputStream.
IlvDiamond(IlvRect definitionRect)
          Creates an IlvDiamond with its size defined by the supplied rectangle.
 
Method Summary
 void applyTransform(IlvTransformer t)
          Applies a transformation to the shape of the object.
 IlvRect boundingBox(IlvTransformer t)
          Returns the bounding box of this IlvDiamond
 boolean contains(IlvPoint p, IlvPoint tp, IlvTransformer t)
          Tests if a point lies within the shape.
 IlvGraphic copy()
          Copies this object.
 void draw(Graphics dst, IlvTransformer t)
          Draws this object.
 Color getBackground()
          Returns the background color of this object.
 IlvRect getDefinitionRect()
          Returns the rectangle that provides the bounds of the diamond.
 Color getForeground()
          Returns the foreground color of this object.
 float getHeight()
          Returns the height of this diamond.
 Stroke getStroke()
          Returns the stroke object used to stroke the shape.
 float getWidth()
          Returns the width of this diamond.
 boolean isFillOn()
          Returns true if the inside of the ellipse will be filled.
 void setBackground(Color c)
          Changes the background color of this object.
 void setFillOn(boolean set)
          If true, specifies that the inside of the ellipse will be filled.
 void setForeground(Color c)
          Changes the foreground color of this object.
 void setHeight(float h)
          Sets the height of this diamond
 void setStroke(Stroke stroke)
          Changes the stroke object used to stroke the shape.
 void setWidth(float w)
          Sets the width of this diamond.
 void write(IlvOutputStream stream)
          Writes the object to an IlvOutputStream.
 
Methods inherited from class ilog.views.IlvGraphic
addActionListener, addNamedPropertyListener, boundingBox, 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, isPersistent, isSelectable, isVisible, makeSelection, move, move, moveResize, notifyObjectInteractorToManager, processActionEvent, reDraw, removeActionListener, removeNamedProperty, removeNamedPropertyListener, removeProperty, replaceProperty, resize, rotate, scale, setEditable, setGraphicBag, setInApplyToObject, setMovable, setName, setNamedProperty, setNameImpl, setObjectInteractor, setPopupMenu, setPopupMenuName, setProperty, setSelectable, setStrokeOn, setToolTipText, setVisible, toString, translate, zoomable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IlvDiamond

public IlvDiamond()
Default bean constructor. Creates an IlvDiamond with the default values.


IlvDiamond

public IlvDiamond(IlvRect definitionRect)
Creates an IlvDiamond with its size defined by the supplied rectangle.


IlvDiamond

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

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

IlvDiamond

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

Method Detail

applyTransform

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

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

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

boundingBox

public IlvRect boundingBox(IlvTransformer t)
Returns the bounding box of this IlvDiamond

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

contains

public boolean contains(IlvPoint p,
                        IlvPoint tp,
                        IlvTransformer t)
Tests if a point lies within the shape.

Overrides:
contains in class IlvGraphic
Parameters:
p - The point to be tested.
tp - The point p transformed by the transformer t.
t - The transformation that was applied to the object when it was drawn.
Returns:
true if the point lies inside this graphic object.
See Also:
IlvGraphic

copy

public IlvGraphic copy()
Copies this object.

Specified by:
copy in class IlvGraphic
Returns:
A copy of this object.
See Also:
IlvGraphic

draw

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

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

setForeground

public void setForeground(Color c)
Changes the foreground color of this object. The default implementation does nothing.

Note that not all graphic objects have a foreground color. Therefore, a call to this method may not do anything.

Overrides:
setForeground in class IlvGraphic
Parameters:
c - 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 foreground color of this object.


setBackground

public void setBackground(Color c)
Changes the background color of this object. The default implementation does nothing.

Note that not all graphic objects have a background color. Therefore, a call to this method may not do anything.

Overrides:
setBackground in class IlvGraphic
Parameters:
c - The new color.
See Also:
setFillOn(boolean), isFillOn()

getBackground

public Color getBackground()
Returns the background color of this object.

See Also:
setFillOn(boolean), isFillOn()

isFillOn

public boolean isFillOn()
Returns true if the inside of the ellipse will be filled.

See Also:
setFillOn(boolean)

setFillOn

public void setFillOn(boolean set)
If true, specifies that the inside of the ellipse will be filled.

Overrides:
setFillOn in class IlvGraphic
Parameters:
set - Set to true to enable the fill style for this graphic object.
See Also:
isFillOn()

getDefinitionRect

public IlvRect getDefinitionRect()
Returns the rectangle that provides the bounds of the diamond.


setStroke

public void setStroke(Stroke stroke)
Changes the stroke object used to stroke the shape. You may set the value to null to remove the stroke. Note that changing the stroke may modify the bounding rectangle of the object. For this reason, if the object is contained inside a manager, you should modify the shape using the applyToObject method of the manager.

See Also:
getStroke()

getStroke

public Stroke getStroke()
Returns the stroke object used to stroke the shape. This method may return null if there is no stroke specified.

See Also:
setStroke(java.awt.Stroke)

setWidth

public void setWidth(float w)
Sets the width of this diamond.


getWidth

public float getWidth()
Returns the width of this diamond.


setHeight

public void setHeight(float h)
Sets the height of this diamond


getHeight

public float getHeight()
Returns the height of this diamond.


write

public void write(IlvOutputStream stream)
           throws IOException
Writes the object to an IlvOutputStream. You should not call this method directly; instead, you should use the write methods of the manager.

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


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