ilog.views.graphic
Class IlvArc

java.lang.Object
  extended by ilog.views.IlvGraphic
      extended by ilog.views.graphic.IlvArc
All Implemented Interfaces:
IlvDefinitionRectInterface, IlvPersistentObject, Transferable, Serializable
Direct Known Subclasses:
IlvFilledArc

public class IlvArc
extends IlvGraphic
implements IlvDefinitionRectInterface

IlvArc defines an arc shape.

Overview

The default arc created when you call IlvArc() has the fill disabled and the stroke enabled. The default color for both is Color.black. You control the arc's fill and stroke by calling setFillOn(boolean), setStrokeOn(boolean) and setForeground(Color), setBackground(Color). Call setAnnulusThickness(float) to draw the annulus of the arc, that is, to draw the arc as a donut shape.

Example

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

   IlvManager manager = new IlvManager();
   IlvArc arc, arcAnnulus;
   
   //Create new filled arc, change its fill and stroke color, then add it to 
   //the manager.
   //This constructor sets the bounding box, start angle, arc angle,
   //fill and stroke for the new IlvArc instance.
   arc = new IlvArc(new IlvRect(30,10,50,50), 40, 150, true, true);
   arc.setBackground(Color.green);
   arc.setForeground(Color.red);
   manager.addObject(arc,true);
   
   //Create new arc, rotate it and set the annulus.
   arcAnnulus = new IlvArc(new IlvRect(70,40,50,50), 40, 150, true, true);
   IlvPoint arcCenter = arcAnnulus.getCenter(new IlvTransformer());
   arcAnnulus.rotate(arcCenter,65);
   arcAnnulus.setAnnulusThickness(6);
   manager.addObject(arcAnnulus,true);     
 

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

IlvArc

About Graphic Objects

IlvArc 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:
IlvManager, IlvManagerView, Serialized Form

Field Summary
protected  IlvRect bbox
          The rectangle that contains the ellipse defining the arc.
 
Constructor Summary
IlvArc()
          Creates an arc with a default definition rect of (0,0,100,100) a 0 degree start angle and a 90 degrees range angle.
IlvArc(IlvArc source)
          Creates an arc by copying an existing arc.
IlvArc(IlvInputStream stream)
          Reads the object from an IlvInputStream.
IlvArc(IlvRect rect, float startAngle, float angle)
          Creates an arc.
IlvArc(IlvRect rect, float startAngle, float angle, boolean outlined, boolean filled)
          Creates a new IlvArc.
 
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 arc.
 boolean contains(IlvPoint p, IlvPoint tp, IlvTransformer t)
          Tests if a point lies within the outline of the arc.
 IlvGraphic copy()
          Copies the object.
 void draw(Graphics dst, IlvTransformer t)
          Draws the object.
 float getAnnulusThickness()
          Returns the thickness of the annulus.
 Color getBackground()
          Returns the background color of the IlvArc.
 IlvPoint getCenter(IlvTransformer t)
          Returns the center point of the graphic object.
 IlvRect getDefinitionRect()
          Returns the rectangle that contains the ellipse defining the arc.
 IlvTransformer getDefinitionTransformer()
          This function calls getTransformer().
 float getDeltaAngle()
          Returns the angle range of the arc, in degrees.
 Color getForeground()
          Returns the foreground color of the arc.
 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.
 float getStartAngle()
          Returns the start angle of the arc, in degrees.
 IlvTransformer getTransformer()
          Gets a copy of the internal transformer of the arc.
 boolean isFillOn()
          Returns true if the inside of the arc will be filled.
 boolean isStrokeOn()
          Returns true if the shape of the arc is stroked.
 boolean isTransformerMode()
          Returns if the arc is in transformer mode.
 void rotate(IlvPoint center, double angle)
          Rotates the arc object.
 void setAnnulusThickness(float annulus)
          Specifies the thickness of the annulus.
 void setBackground(Color color)
          Changes the background color of the IlvArc.
 void setDefinitionRect(IlvRect rect)
          Sets the definition rectangle.
 void setDeltaAngle(float delta_angle)
          Changes the angle range of the arc.
 void setFillOn(boolean set)
          If true, specifies that the inside of the arc will be filled.
 void setForeground(Color color)
          Changes the foreground color of the arc.
 void setStartAngle(float start_angle)
          Changes the start angle of the arc.
 void setStrokeOn(boolean set)
          When set to true, specifies that the shape of the arc is stroked.
 void setTransformer(IlvTransformer t)
          Specifies a new transformer to the arc object.
 void setTransformerMode(boolean enabled)
          Enables and disables the transformer mode.
 void symmetry(int axis)
          Modifies the arc, by applying a symmetry around the specified axis.
 void write(IlvOutputStream stream)
          Writes the object to an IlvOutputStream.
 
Methods inherited from class ilog.views.IlvGraphic
addActionListener, addNamedPropertyListener, boundingBox, getAndAssociateObjectInteractor, getDefaultInteractor, getGraphicBag, GetGraphicObject, 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, scale, setEditable, setGraphicBag, setInApplyToObject, setMovable, setName, setNamedProperty, setNameImpl, setObjectInteractor, setPopupMenu, setPopupMenuName, setProperty, setSelectable, setToolTipText, setVisible, toString, translate, zoomable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

bbox

protected final IlvRect bbox
The rectangle that contains the ellipse defining the arc.

Constructor Detail

IlvArc

public IlvArc()
Creates an arc with a default definition rect of (0,0,100,100) a 0 degree start angle and a 90 degrees range angle.

Since:
JViews 6.0
See Also:
IlvArc(IlvRect, float, float)

IlvArc

public IlvArc(IlvRect rect,
              float startAngle,
              float angle)
Creates an arc.

Parameters:
rect - The rectangle that contains the ellipse defining the arc.
startAngle - The start angle of the arc in degrees.
angle - The range angle of the arc in degrees.

IlvArc

public IlvArc(IlvRect rect,
              float startAngle,
              float angle,
              boolean outlined,
              boolean filled)
Creates a new IlvArc.

Parameters:
rect - The definition rectangle of the arc.
startAngle - The start angle of the arc in degrees.
angle - The range angle of the arc in degrees.
outlined - true if the arc has to be stroked.
filled - true if the arc has to be filled.
Since:
JViews 5.5
See Also:
setStrokeOn(boolean), setFillOn(boolean)

IlvArc

public IlvArc(IlvArc source)
Creates an arc by copying an existing arc.

Parameters:
source - The source arc.

IlvArc

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

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

copy

public IlvGraphic copy()
Copies the object. This method copies the object by calling the copy constructor.

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

getDefinitionRect

public final IlvRect getDefinitionRect()
Returns the rectangle that contains the ellipse defining the arc.

Specified by:
getDefinitionRect in interface IlvDefinitionRectInterface
Returns:
The definition rectangle.

setDefinitionRect

public void setDefinitionRect(IlvRect rect)
Sets the definition rectangle. A copy of the specified rectangle is stored.

Specified by:
setDefinitionRect in interface IlvDefinitionRectInterface
Parameters:
rect - The new definition rectangle.
Since:
JViews 8.0

getDefinitionTransformer

public IlvTransformer getDefinitionTransformer()
This function calls getTransformer().

Specified by:
getDefinitionTransformer in interface IlvDefinitionRectInterface
Returns:
null
Since:
JViews 8.0
See Also:
IlvDefinitionRectInterface

getStartAngle

public final float getStartAngle()
Returns the start angle of the arc, in degrees.

See Also:
setStartAngle(float)

setStartAngle

public final void setStartAngle(float start_angle)
Changes the start angle of the arc.

Parameters:
start_angle - The new angle in degrees.
See Also:
getStartAngle()

getDeltaAngle

public final float getDeltaAngle()
Returns the angle range of the arc, in degrees.

See Also:
setDeltaAngle(float)

setDeltaAngle

public final void setDeltaAngle(float delta_angle)
Changes the angle range of the arc.

Parameters:
delta_angle - The new angle in degrees.
See Also:
getDeltaAngle()

getAnnulusThickness

public float getAnnulusThickness()
Returns the thickness of the annulus.

Since:
JViews 8.0
See Also:
setAnnulusThickness(float)

setAnnulusThickness

public void setAnnulusThickness(float annulus)
Specifies the thickness of the annulus. When this thickness is 0, a normal arc is drawn and is compatible to previous JViews releases. When the thickness is not zero, an annulus form is defined. This thickness can not be negative.

Parameters:
annulus - The thickness of the annulus.
Since:
JViews 8.0
See Also:
getDefinitionRect()

isTransformerMode

public final boolean isTransformerMode()
Returns if the arc is in transformer mode. If the transformer mode is enabled, the arc can be transformed (scaled, translated, and rotated).

Returns:
true, if the arc is in transformer mode.
Since:
JViews 8.0
See Also:
setTransformerMode(boolean)

setTransformerMode

public final void setTransformerMode(boolean enabled)
Enables and disables the transformer mode.

Parameters:
enabled - Enables the transformer mode or not.
Since:
JViews 8.0
See Also:
isTransformerMode()

setTransformer

public final void setTransformer(IlvTransformer t)
Specifies a new transformer to the arc object. This transformer will apply to the arc while rendering this object. A copy of the specified transformer is stored by the arc object if the parameter is not null. If you specify a null parameter, the internal transformer will be set to null too. This resets the transformation of this arc.

If the arc object has an internal transformer, that is, the transformer you specify here is not null, when you call the applyTransform(IlvTransformer) method, the specified transformation will apply to the internal transformer.

Parameters:
t - The new transformer.
Since:
JViews 8.0
See Also:
getTransformer(), applyTransform(IlvTransformer)

getTransformer

public final IlvTransformer getTransformer()
Gets a copy of the internal transformer of the arc. Returns null if there is no internal transformer.

Returns:
A copy of the internal transformer of the arc.
Since:
JViews 8.0
See Also:
setTransformer(IlvTransformer)

draw

public void draw(Graphics dst,
                 IlvTransformer t)
Draws the 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

contains

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

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

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.

Overrides:
getIntersectionWithOutline in class IlvGraphic
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:
IlvClippingLinkConnector

boundingBox

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

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

getCenter

public IlvPoint getCenter(IlvTransformer t)
Returns the center point of the graphic object. The returned point can be used as rotation center to rotate the object.

Overrides:
getCenter in class IlvGraphic
Parameters:
t - The transformer used to draw the object. The value null can be used for the identity transformer.
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 void applyTransform(IlvTransformer t)
Applies a transformation to the shape of the object. If the arc object has no internal transformer, the transformation will apply to the definition of the arc, that is, the start angle or the definition rectangle might be changed. Since JViews 8.0, if the internal transformer exists, that is, the arc is in transformer mode, this method does not change the arc definition and applies the transformation to the internal transformer.

Specified by:
applyTransform in class IlvGraphic
Parameters:
t - The transformer to be applied.
See Also:
setTransformer(IlvTransformer), getTransformer(), setTransformerMode(boolean), isTransformerMode()

rotate

public void rotate(IlvPoint center,
                   double angle)
Rotates the arc object. The object is rotated around the point specified by center, by an angle in degrees specified by angle.

If the arc is in transformer mode, this method calls the applyTransform(IlvTransformer) method to perform the rotation.

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

symmetry

public void symmetry(int axis)
Modifies the arc, by applying a symmetry around the specified axis.

Parameters:
axis - The axis for the symmetry can be one of IlvConstants.HORIZONTAL_CENTER, IlvConstants.CENTER, or IlvConstants.VERTICAL_CENTER.

setForeground

public void setForeground(Color color)
Changes the foreground color of the arc. It is the color used to draw the arc.

Overrides:
setForeground in class IlvGraphic
Parameters:
color - The new foreground color.
See Also:
getForeground()

getForeground

public Color getForeground()
Returns the foreground color of the arc. It is the color used to draw the arc.

Returns:
The foreground color of the arc.
See Also:
setForeground(java.awt.Color)

setBackground

public void setBackground(Color color)
Changes the background color of the IlvArc. It is the color used to fill the arc.

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

getBackground

public Color getBackground()
Returns the background color of the IlvArc. It is the color used to fill the arc.

Returns:
The background color of the arc.
Since:
JViews 5.5

isFillOn

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

Since:
JViews 5.5
See Also:
setFillOn(boolean), setFillOn(boolean)

setFillOn

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

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

isStrokeOn

public boolean isStrokeOn()
Returns true if the shape of the arc is stroked.

Since:
JViews 5.5
See Also:
setStrokeOn(boolean), setFillOn(boolean)

setStrokeOn

public void setStrokeOn(boolean set)
When set to true, specifies that the shape of the arc is stroked.

Overrides:
setStrokeOn in class IlvGraphic
Parameters:
set - Set to true to enable the stroke in your customized graphic object.
Since:
JViews 5.5
See Also:
isStrokeOn(), setFillOn(boolean)

write

public void write(IlvOutputStream stream)
           throws IOException
Writes the object to an IlvOutputStream. Note that even if this is a public method, you should not call it directly. 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.