ilog.views.graphic
Class IlvShadowLabel

java.lang.Object
  extended by ilog.views.IlvGraphic
      extended by ilog.views.graphic.IlvRectangle
          extended by ilog.views.graphic.IlvShadowRectangle
              extended by ilog.views.graphic.IlvShadowLabel
All Implemented Interfaces:
IlvFontInterface, IlvLabelInterface, IlvPersistentObject, Transferable, Serializable

public class IlvShadowLabel
extends IlvShadowRectangle
implements IlvFontInterface, IlvLabelInterface

IlvShadowLabel represents a labeled rectangle with a shadow.

The default values for an IlvShadowLabel instance are as follows:

The default foreground and background colors are black. You must change one of these colors for the label to be visible.

Note: calls to the following methods result in a RuntimeException being thrown:

Example

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

   IlvManager manager = new IlvManager();
   IlvShadowLabel myDefaultRect = new IlvShadowLabel();
   
   IlvShadowLabel myCustomRect = new IlvShadowLabel(
                                  new IlvRect(60,90,80,20), 
                                  "My Custom Shadow Label",
                                  6, IlvConstants.TOP_LEFT);
   myCustomRect.setForeground(Color.blue);
   myCustomRect.setBackground(Color.yellow);
   myCustomRect.setFont(new Font("SansSerif", Font.BOLD, 14));
   
   manager.addObject( myDefaultRect, true);
   manager.addObject( myCustomRect, true);
 

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

About Graphic Objects

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

Field Summary
 
Fields inherited from class ilog.views.graphic.IlvRectangle
BOTTOM_LEFT, BOTTOM_RIGHT, drawrect, TOP_LEFT, TOP_RIGHT
 
Constructor Summary
IlvShadowLabel()
          Creates a new IlvShadowLabel with a (0, 0, 100, 100) definition rectangle, an empty label, a thickness of 2 and a IlvConstants.BOTTOM_RIGHT shadow position.
IlvShadowLabel(IlvInputStream stream)
          Reads the object from an IlvInputStream.
IlvShadowLabel(IlvPoint at, String label, float thickness, float hMargin, float vMargin, int shadowPosition)
          Creates a new IlvShadowLabel at a specified position and with specified label, thickness, margins, and shadow position.
IlvShadowLabel(IlvRect rect, String label, float thickness, int shadowPosition)
          Creates a new IlvShadowLabel with a specified definition rectangle, label, thickness, and shadow position.
IlvShadowLabel(IlvShadowLabel source)
          Creates a new IlvShadowLabel by copying an existing one.
 
Method Summary
 IlvGraphic copy()
          Copies the object.
protected  void drawContent(Graphics dst, IlvRect rect, IlvTransformer t)
          Draws the inner part of the object.
 void drawLabel(Graphics dst, IlvRect rect, IlvTransformer t)
          Draws the label inside the shadow rectangle.
 void fitToLabel(float hMargin, float vMargin)
          Recomputes the size of the object according to the current label and using the specified horizontal and vertical margins.
 Font getFont()
          Returns the font of the object.
 String getLabel()
          Returns the label of the object.
 IlvRect getLabelBBox(IlvTransformer t)
          Returns the bounding area within which the label is displayed.
 boolean isAntialiasing()
          Returns true if the anti-aliasing mode of the text is on.
 void setAntialiasing(boolean set)
          Changes the anti-aliasing mode of the text.
 void setFont(Font font)
          Changes the font of the object.
 void setLabel(String label)
          Changes the label of the object.
 boolean supportMultiline()
          Returns false since this object does not support multiline text.
 String toString()
          Returns a string representation of the graphic object.
 void write(IlvOutputStream stream)
          Writes the object to an IlvOutputStream.
 
Methods inherited from class ilog.views.graphic.IlvShadowRectangle
draw, getShadowPosition, getThickness, setCorners, setFillOn, setRadius, setShadowPosition, setStrokeOn, setThickness
 
Methods inherited from class ilog.views.graphic.IlvRectangle
applyTransform, boundingBox, contains, getBackground, getCorners, getDefinitionRect, getForeground, getIntersectionWithOutline, getRadius, isCornersZoomable, isFillOn, isStrokeOn, moveResize, setBackground, setCornersZoomable, setDefinitionRect, setForeground, translate
 
Methods inherited from class ilog.views.IlvGraphic
addActionListener, addNamedPropertyListener, boundingBox, getAndAssociateObjectInteractor, getCenter, 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, notifyObjectInteractorToManager, processActionEvent, reDraw, removeActionListener, removeNamedProperty, removeNamedPropertyListener, removeProperty, replaceProperty, resize, rotate, scale, setEditable, setGraphicBag, setInApplyToObject, setMovable, setName, setNamedProperty, setNameImpl, setObjectInteractor, setPopupMenu, setPopupMenuName, setProperty, setSelectable, setToolTipText, setVisible, zoomable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IlvShadowLabel

public IlvShadowLabel()
Creates a new IlvShadowLabel with a (0, 0, 100, 100) definition rectangle, an empty label, a thickness of 2 and a IlvConstants.BOTTOM_RIGHT shadow position.

Since:
JViews 6.0
See Also:
IlvShadowLabel(IlvRect, String, float, int)

IlvShadowLabel

public IlvShadowLabel(IlvRect rect,
                      String label,
                      float thickness,
                      int shadowPosition)
Creates a new IlvShadowLabel with a specified definition rectangle, label, thickness, and shadow position.

Parameters:
rect - The definition rectangle of the object.
label - The label.
thickness - The thickness of the shadow.
shadowPosition - The position of the shadow. Valid values are IlvConstants.TOP_LEFT, IlvConstants.BOTTOM_LEFT, IlvConstants.TOP_RIGHT, and IlvConstants.BOTTOM_RIGHT.
See Also:
setLabel(java.lang.String), IlvShadowRectangle.setThickness(float), IlvShadowRectangle.setShadowPosition(int)

IlvShadowLabel

public IlvShadowLabel(IlvPoint at,
                      String label,
                      float thickness,
                      float hMargin,
                      float vMargin,
                      int shadowPosition)
Creates a new IlvShadowLabel at a specified position and with specified label, thickness, margins, and shadow position. This constructor computes the definition rectangle of the object using the method fitToLabel(float, float), which preserves the specified margins around the label.

Parameters:
at - The upper-left point of the object.
label - The label.
thickness - The thickness of the shadow.
hMargin - The margin that is preserved on the left and right sides of the label.
vMargin - The margin that is preserved on the top and bottom sides of the label.
shadowPosition - The position of the shadow. Valid values are IlvConstants.TOP_LEFT, IlvConstants.BOTTOM_LEFT, IlvConstants.TOP_RIGHT, and IlvConstants.BOTTOM_RIGHT.
Since:
JViews 3.5
See Also:
setLabel(java.lang.String), IlvShadowRectangle.setThickness(float), IlvShadowRectangle.setShadowPosition(int), fitToLabel(float, float)

IlvShadowLabel

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

Parameters:
source - The copied object.

IlvShadowLabel

public IlvShadowLabel(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.

Overrides:
copy in class IlvShadowRectangle
Returns:
A copy of the object.
See Also:
IlvGraphic

getLabel

public String getLabel()
Returns the label of the object.

Specified by:
getLabel in interface IlvLabelInterface

setLabel

public void setLabel(String label)
Changes the label of the object.

Specified by:
setLabel in interface IlvLabelInterface

fitToLabel

public void fitToLabel(float hMargin,
                       float vMargin)
Recomputes the size of the object according to the current label and using the specified horizontal and vertical margins.

The width of the definition rectangle of the object is set to the width of the current label plus twice the horizontal margin. The height of the definition rectangle of the object is set to the height of the current label plus twice the vertical margin. The upper-left corner of the definition rectangle is not moved.

Note that if the object is contained inside a manager, you should call this method using the method IlvManager.applyToObject(ilog.views.IlvGraphic, ilog.views.IlvApplyObject, java.lang.Object, boolean).

Parameters:
hMargin - The margin to be preserved on the left and right sides of the bounding box of the label.
vMargin - The margin to be preserved on the top and bottom sides of the bounding box of the label.
Since:
JViews 3.5
See Also:
getLabel()

getFont

public Font getFont()
Returns the font of the object.

Specified by:
getFont in interface IlvFontInterface

setFont

public void setFont(Font font)
Changes the font of the object.

Specified by:
setFont in interface IlvFontInterface
Parameters:
font - The new font.

isAntialiasing

public final boolean isAntialiasing()
Returns true if the anti-aliasing mode of the text is on.


setAntialiasing

public final void setAntialiasing(boolean set)
Changes the anti-aliasing mode of the text. Changing this mode may change the bounding box of the object.


supportMultiline

public boolean supportMultiline()
Returns false since this object does not support multiline text.

Specified by:
supportMultiline in interface IlvLabelInterface

getLabelBBox

public IlvRect getLabelBBox(IlvTransformer t)
Returns the bounding area within which the label is displayed.

Specified by:
getLabelBBox in interface IlvLabelInterface
Parameters:
t - The transformer used to draw the object.

drawLabel

public void drawLabel(Graphics dst,
                      IlvRect rect,
                      IlvTransformer t)
Draws the label inside the shadow rectangle.

Parameters:
dst - The destination Graphics.
rect - The rectangle defining the inner part of the shadow rectangle (that is, the bounding box with the relief shadow removed). Note that this rectangle is already transformed by the transformer used to draw the object.
t - The transformation used to draw the object.

drawContent

protected void drawContent(Graphics dst,
                           IlvRect rect,
                           IlvTransformer t)
Draws the inner part of the object. It overrides the method drawContent of the class IlvShadowRectangle to draw the label of the object.

Overrides:
drawContent in class IlvShadowRectangle
Parameters:
dst - The Graphics to perform the drawing.
rect - The rectangle defining the inner part of the shadow rectangle (that is, the bounding box with the relief shadow removed). Note that this rectangle is already transformed by the transformer used to draw the object.
t - The transformer used to draw the object.

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 IlvShadowRectangle
Parameters:
stream - The output stream.
Throws:
IOException - thrown when an exception occurs during the write operation for this object.

toString

public String toString()
Returns a string representation of the graphic object. The method returns a string which is the concatenation of the string returned by IlvGraphic.toString() with the label (see getLabel()).

Overrides:
toString in class IlvGraphic
Since:
JViews 3.5
See Also:
IlvGraphic.getName()


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