ilog.views.graphic
Class IlvCircularScale

java.lang.Object
  extended by ilog.views.IlvGraphic
      extended by ilog.views.graphic.IlvScale
          extended by ilog.views.graphic.IlvCircularScale
All Implemented Interfaces:
IlvDefinitionRectInterface, IlvFontInterface, IlvPersistentObject, Transferable, Serializable

public class IlvCircularScale
extends IlvScale
implements IlvDefinitionRectInterface

IlvCircularScale represents a circular scale.

The default values for an IlvCircularScale instance are as follows:

Example

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

   IlvManager manager = new IlvManager();
       
   IlvCircularScale myDefaultScale = new IlvCircularScale();   
   IlvCircularScale myCustomScale = new IlvCircularScale(
      new IlvRect(160,80,40,40), "#", 0, 76, 0, 200, false, 5, 2,5,5);
   
   myCustomScale.setForeground(Color.blue);
   myCustomScale.setFont(new Font("SansSerif", Font.BOLD, 14));
   
   manager.addObject(myDefaultScale, true);
   manager.addObject(myCustomScale, true);
 

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

About Graphic Objects

IlvCircularScale 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:
IlvRect, IlvPoint, IlvConstants, IlvManager, IlvManagerView, Serialized Form

Field Summary
static int BOTH
          Both first and the last label are visible.
static int FIRST
          The first label must be visible.
static int LAST
          The last label must be visible.
 
Constructor Summary
IlvCircularScale()
          Creates a new IlvCircularScale with default values.
IlvCircularScale(IlvCircularScale source)
          Creates a new IlvCircularScale by copying an existing one.
IlvCircularScale(IlvInputStream stream)
          Reads the object from an IlvInputStream.
IlvCircularScale(IlvRect rect, String[] labels, float start, float range, boolean inside, int numberOfSubSteps, float stepSize, float subStepSize)
          Creates a new IlvCircularScale by specifying the labels to be displayed.
IlvCircularScale(IlvRect rect, String format, float min, float max, float start, float range, boolean inside, int numberOfSteps, int numberOfSubSteps, float stepSize, float subStepSize)
          Creates a new IlvCircularScale with numeric labels by specifying a minimum and maximum value for the labels.
 
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.
 boolean contains(IlvPoint p, IlvPoint tp, IlvTransformer t)
          Tests if a point lies within the outline of the object.
 IlvGraphic copy()
          Copies the object.
 void draw(Graphics dst, IlvTransformer t)
          Draws the object.
 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 returns null to indicate that there is no definition transformation.
 int getLabelPolicy()
          Returns the label visibility policy, one of the following values: FIRST, LAST, FIRST|LAST, or 0.
 boolean getLabelsInside()
          Returns the true if the labels are drawn inside the scale; false if the labels are drawn outside the scale.
 float getRange()
          Returns the angle range of the scale.
 float getStart()
          Returns the start angle of the scale.
 void moveResize(IlvRect rect)
          Resizes the object.
 void setDefinitionRect(IlvRect drawrect)
          Note that, if this circular scale is contained inside an IlvManager, this method can be called only using the method IlvManager.applyToObject(ilog.views.IlvGraphic, ilog.views.IlvApplyObject, java.lang.Object, boolean) of the manager.
 void setLabelPolicy(int policy)
          Sets the label visibility policy.
 void setLabelsInside(boolean inside)
          Changes the way the labels are drawn.
 void setRange(float range)
          Sets the angle range of the scale.
 void setStart(float start)
          Sets the start range of the scale.
 void write(IlvOutputStream stream)
          Writes the object to an IlvOutputStream.
 boolean zoomable()
          Returns true if the object is zoomable.
 
Methods inherited from class ilog.views.graphic.IlvScale
getFont, getForeground, getFormat, getLabels, getMax, getMin, getNumberOfSteps, getNumberOfSubSteps, getStepSize, getSubStepSize, isAntialiasing, setAntialiasing, setFont, setForeground, setFormat, setLabel, setLabels, setMax, setMin, setNumberOfSteps, setNumberOfSubSteps, setStepSize, setSubStepSize
 
Methods inherited from class ilog.views.IlvGraphic
addActionListener, addNamedPropertyListener, boundingBox, getAndAssociateObjectInteractor, 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, notifyObjectInteractorToManager, processActionEvent, reDraw, removeActionListener, removeNamedProperty, removeNamedPropertyListener, removeProperty, replaceProperty, resize, rotate, scale, setBackground, setEditable, setFillOn, setGraphicBag, 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
 

Field Detail

FIRST

public static int FIRST
The first label must be visible.

Since:
JViews 8.0

LAST

public static int LAST
The last label must be visible.

Since:
JViews 8.0

BOTH

public static int BOTH
Both first and the last label are visible. This is the default setting.

Since:
JViews 8.0
Constructor Detail

IlvCircularScale

public IlvCircularScale()
Creates a new IlvCircularScale with default values.

Since:
JViews 6.0

IlvCircularScale

public IlvCircularScale(IlvRect rect,
                        String format,
                        float min,
                        float max,
                        float start,
                        float range,
                        boolean inside,
                        int numberOfSteps,
                        int numberOfSubSteps,
                        float stepSize,
                        float subStepSize)
Creates a new IlvCircularScale with numeric labels by specifying a minimum and maximum value for the labels.

Parameters:
rect - the location and size of the ellipse that defines the scale. The scale is defined as a portion of the ellipse defined by this parameter, by its starting angle (the start parameter as well as the angle range it uses (the range parameter).
format - a format used to display the labels of the scale. (See the class java.text.DecimalFormat for a description of this parameter).
min - the minimum value of the labels of the scale.
max - the maximum value of the labels of the scale.
start - the start angle in degrees.
range - the angle range in degrees.
inside - if true then labels are displayed inside the arc; otherwise they are displayed outside.
numberOfSteps - the number of major steps.
numberOfSubSteps - the number of minor steps between two major steps.
stepSize - the size of the major ticks.
subStepSize - the size of the minor ticks.

IlvCircularScale

public IlvCircularScale(IlvRect rect,
                        String[] labels,
                        float start,
                        float range,
                        boolean inside,
                        int numberOfSubSteps,
                        float stepSize,
                        float subStepSize)
Creates a new IlvCircularScale by specifying the labels to be displayed.

Parameters:
rect - the location and size of the ellipse that defines the scale. The scale is defined as a portion of the ellipse defined by this parameter, by its starting angle (the start parameter as well as the angle range it uses (the range parameter).
labels - the labels of the scale.
start - the start angle in degrees.
range - the angle range in degrees.
inside - if true the labels are displayed inside the arc; otherwise they are displayed outside.
numberOfSubSteps - the number of minor steps between two major steps.
stepSize - the size of the major ticks.
subStepSize - the size of the minor ticks.

IlvCircularScale

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

Parameters:
source - the origin object for the copy.

IlvCircularScale

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

Parameters:
stream - the input stream.
Throws:
IlvReadFileException - if the format is not correct.
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 final void setDefinitionRect(IlvRect drawrect)
Note that, if this circular scale is contained inside an IlvManager, this method can be called only using the method IlvManager.applyToObject(ilog.views.IlvGraphic, ilog.views.IlvApplyObject, java.lang.Object, boolean) of the manager.

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

getDefinitionTransformer

public IlvTransformer getDefinitionTransformer()
This function returns null to indicate that there is no definition transformation.

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

getStart

public final float getStart()
Returns the start angle of the scale.

Returns:
the start angle of the scale in degrees.

setStart

public final void setStart(float start)
Sets the start range of the scale.

Parameters:
start - the new angle in degrees.

getRange

public final float getRange()
Returns the angle range of the scale.

Returns:
the angle range of the scale in degrees.

setRange

public final void setRange(float range)
Sets the angle range of the scale.

Parameters:
range - the new angle range in degrees.

getLabelsInside

public final boolean getLabelsInside()
Returns the true if the labels are drawn inside the scale; false if the labels are drawn outside the scale.


setLabelsInside

public final void setLabelsInside(boolean inside)
Changes the way the labels are drawn.

Parameters:
inside - if this parameter is set to true, the labels are drawn inside the scale; otherwise, they are drawn outside.

setLabelPolicy

public void setLabelPolicy(int policy)
Sets the label visibility policy. You can control the visibility of the first and/or the last label. This function is especially useful when the range of the scale is 360 degrees.

Parameters:
policy - You can specify one of the following values: FIRST, LAST, FIRST|LAST, or 0.
Since:
JViews 8.0
See Also:
FIRST, LAST, LAST

getLabelPolicy

public int getLabelPolicy()
Returns the label visibility policy, one of the following values: FIRST, LAST, FIRST|LAST, or 0.

Since:
JViews 8.0
See Also:
FIRST, LAST, LAST

boundingBox

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

Overrides:
boundingBox in class IlvScale
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

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

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

applyTransform

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

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

moveResize

public void moveResize(IlvRect rect)
Resizes the object. The method sets the bounding rectangle of the object to the IlvRect parameter. This method calls the applyTransform(ilog.views.IlvTransformer) method.

Overrides:
moveResize in class IlvGraphic
Parameters:
rect - The new bounding rectangle of the object.
See Also:
setDefinitionRect(IlvRect)

zoomable

public boolean zoomable()
Returns true if the object is zoomable. Otherwise it returns false.

Overrides:
zoomable in class IlvGraphic
Returns:
false because this object is not zoomable.
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 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 IlvScale
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.