ilog.views.graphic
Class IlvRectangularScale

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

public class IlvRectangularScale
extends IlvScale
implements IlvDefinitionRectInterface

IlvRectangularScale represents a vertical or horizontal scale.

The default values for an IlvRectangularScale instance are as follows:

To have a vertical scale, set the origin to IlvConstants.TOP or IlvConstants.BOTTOM; for a horizontal scale, set the origin to IlvConstants.LEFT or IlvConstants.RIGHT.

Example

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

   IlvManager manager = new IlvManager();
   IlvRectangularScale myDefaultScale = new IlvRectangularScale();
   myDefaultScale.move(new IlvPoint(40,30));
      
   IlvRectangularScale myCustomScale = new IlvRectangularScale(
      new IlvPoint(120,20), 54, "#", 0, 76, 7, 3, IlvConstants.BOTTOM,
      IlvConstants.BOTTOM, 5, 2);
   
   
   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

IlvRectangularScale 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

Constructor Summary
IlvRectangularScale()
          Creates a new rectangular scale with default values for all the parameters.
IlvRectangularScale(IlvInputStream stream)
          Reads the object from an IlvInputStream.
IlvRectangularScale(IlvPoint origin, float size, String[] labels, int numberOfSubSteps, int originPosition, int labelsPosition, float stepSize, float subStepSize)
          Creates a new IlvRectangularScale by specifying the labels to be displayed.
IlvRectangularScale(IlvPoint origin, float size, String format, float min, float max, int numberOfSteps, int numberOfSubSteps, int originPosition, int labelsPosition, float stepSize, float subStepSize)
          Creates a new IlvRectangularScale by specifying a minimum and a maximum value for the labels.
IlvRectangularScale(IlvRectangularScale source)
          Creates a new IlvRectangularScale by copying an existing one.
 
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.
 IlvRect getDefinitionRect()
          Returns a copy of the definition rectangle.
 IlvTransformer getDefinitionTransformer()
          This function returns null to indicate that there is no definition transformation.
 boolean getLabelsCentered()
          Returns true if the scale draws its labels between the markers; false if it draws each label with its corresponding marker.
 int getLabelsPosition()
          Returns the position of the labels of the scale.
 IlvPoint getOrigin()
          Returns the origin of the scale (the location of the minimum value representation).
 int getOriginPosition()
          Returns the position of the origin of the scale.
 float getSize()
          Returns the size of the scale (the height or the width).
 void moveResize(IlvRect rect)
          Resizes the object.
 void setDefinitionRect(IlvRect rect)
          Sets the definition rectangle.
 void setLabelsCentered(boolean set)
          Centers the label between the markers.
 void setLabelsPosition(int position)
          Changes the position of the labels of the scale.
 void setOrigin(IlvPoint point)
          Changes the origin of the scale (the location of the minimum value representation).
 void setOriginPosition(int orientation)
          Changes the position of the origin of the scale.
 void setSize(float size)
          Sets the size of the scale (the height or the width).
 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, 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, 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
 

Constructor Detail

IlvRectangularScale

public IlvRectangularScale(IlvPoint origin,
                           float size,
                           String format,
                           float min,
                           float max,
                           int numberOfSteps,
                           int numberOfSubSteps,
                           int originPosition,
                           int labelsPosition,
                           float stepSize,
                           float subStepSize)
Creates a new IlvRectangularScale by specifying a minimum and a maximum value for the labels.

Parameters:
origin - the origin of the scale. The location of the minimum value representation.
size - the height or the width depending on if the scale is vertical or horizontal.
format - the format used to display the labels. (See the class java.text.DecimalFormat for a description of this parameter.)
min - the minimum value for labels
max - the maximum value for labels
numberOfSteps - the number of major steps.
numberOfSubSteps - the number of minor steps between two major steps.
originPosition - the position of the origin. The value can be IlvConstants.TOP or IlvConstants.BOTTOM for a vertical scale and IlvConstants.LEFT or IlvConstants.RIGHT for a horizontal scale.
labelsPosition - the position of the labels on the scale. It can be IlvConstants.TOP or IlvConstants.BOTTOM for a horizontal scale of IlvConstants.LEFT or IlvConstants.RIGHT for a vertical scale.
stepSize - the size of the major ticks.
subStepSize - the size of the minor ticks.

IlvRectangularScale

public IlvRectangularScale(IlvPoint origin,
                           float size,
                           String[] labels,
                           int numberOfSubSteps,
                           int originPosition,
                           int labelsPosition,
                           float stepSize,
                           float subStepSize)
Creates a new IlvRectangularScale by specifying the labels to be displayed.

Parameters:
origin - the origin of the scale. The location of the minimum value representation.
size - the height or the width depending if the scale is vertical or horizontal.
labels - the labels of the scale. The number of elements in the array defines the number of major steps.
numberOfSubSteps - the number of minor steps between two major steps.
originPosition - the position of the origin. The value can be IlvConstants.TOP or IlvConstants.BOTTOM for a vertical scale and IlvConstants.LEFT or IlvConstants.RIGHT for a horizontal scale.
labelsPosition - the position of the labels on the scale. It can be IlvConstants.TOP or IlvConstants.BOTTOM for a horizontal scale of IlvConstants.LEFT or IlvConstants.RIGHT for a vertical scale.
stepSize - the size of the major ticks.
subStepSize - the size of the minor ticks.

IlvRectangularScale

public IlvRectangularScale()
Creates a new rectangular scale with default values for all the parameters.

Since:
JViews 7.5

IlvRectangularScale

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

Parameters:
source - the origin object for the copy.

IlvRectangularScale

public IlvRectangularScale(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

getOriginPosition

public final int getOriginPosition()
Returns the position of the origin of the scale. It can be IlvConstants.TOP or IlvConstants.BOTTOM for a vertical scale, or IlvConstants.LEFT or IlvConstants.RIGHT for a horizontal scale.


setOriginPosition

public final void setOriginPosition(int orientation)
Changes the position of the origin of the scale. It can be IlvConstants.TOP or IlvConstants.BOTTOM for a vertical scale, or IlvConstants.LEFT or IlvConstants.RIGHT for a horizontal scale. Changing this attribute may change the bounding box of the scale.


getLabelsPosition

public final int getLabelsPosition()
Returns the position of the labels of the scale.


setLabelsPosition

public final void setLabelsPosition(int position)
Changes the position of the labels of the scale. If the scale is vertical, the possible values for position are IlvConstants.LEFT or IlvConstants.RIGHT. If the scale is horizontal, the possible values for position are IlvConstants.TOP or IlvConstants.BOTTOM.


setSize

public final void setSize(float size)
Sets the size of the scale (the height or the width). The size is the distance from the minimum to the maximum tick. This changes the bounding box of the scale.


getSize

public final float getSize()
Returns the size of the scale (the height or the width). The size is the distance from the minimum to the maximum tick.


getLabelsCentered

public final boolean getLabelsCentered()
Returns true if the scale draws its labels between the markers; false if it draws each label with its corresponding marker.


setLabelsCentered

public final void setLabelsCentered(boolean set)
Centers the label between the markers.

See Also:
getLabelsCentered()

getDefinitionRect

public IlvRect getDefinitionRect()
Returns a copy of the definition rectangle. The definition rectangle is defined by the origin, the size, and the step size of the scale. It does not contain the labels. It is smaller than its bounding box.

Specified by:
getDefinitionRect in interface IlvDefinitionRectInterface
Returns:
A copy of the definition rectangle.
Since:
JViews 8.0
See Also:
setDefinitionRect(IlvRect)

setDefinitionRect

public void setDefinitionRect(IlvRect rect)
Sets the definition rectangle. The scale recomputes its origin and its size to meet the specified rectangle. It does not change its step size. So you may find that the definition rectangle you get is not the one you have set.

Specified by:
setDefinitionRect in interface IlvDefinitionRectInterface
Parameters:
rect - The new definition rectangle.
Since:
JViews 8.0
See Also:
getDefinitionRect()

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

getOrigin

public final IlvPoint getOrigin()
Returns the origin of the scale (the location of the minimum value representation).


setOrigin

public final void setOrigin(IlvPoint point)
Changes the origin of the scale (the location of the minimum value representation). Note that this modifies the bounding box of the scale.

Parameters:
point - the new origin.

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

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

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

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)

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.