ilog.views.graphic
Class IlvZoomableLabel

java.lang.Object
  extended by ilog.views.IlvGraphic
      extended by ilog.views.graphic.IlvZoomableLabel
All Implemented Interfaces:
IlvFontInterface, IlvLabelInterface, IlvPersistentObject, Transferable, Serializable
Direct Known Subclasses:
IlvPowerLabel

public class IlvZoomableLabel
extends IlvGraphic
implements IlvFontInterface, IlvLabelInterface

A graphic object that displays a label. Any transformation can be applied to it; in particular, it can be zoomed.
Warning: Beginning with JViews 6.0 it is advised to use IlvText instead except if you need some IlvZoomableLabel specifics such as stroked letters.

See Also:
Serialized Form

Constructor Summary
IlvZoomableLabel()
          Creates a new IlvZoomableLabel with the lower-left corner in (0, 0) and an empty label.
IlvZoomableLabel(IlvInputStream stream)
          Reads the object from an IlvInputStream.
IlvZoomableLabel(IlvPoint position, String label)
          Creates a new IlvZoomableLabel instance.
IlvZoomableLabel(IlvPoint position, String label, boolean compatibility)
          Creates a new IlvZoomableLabel instance.
IlvZoomableLabel(IlvZoomableLabel source)
          Copy constructor of IlvZoomableLabel.
 
Method Summary
protected  Paint adaptPaint(Shape shape, Paint paint)
          Returns a new Paint object that will fit the shape parameter according to the initial paint parameter.
 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.
 Paint getBackgroundPaint()
          Returns the paint object used to fill the background rectangle.
 float getBottomMargin()
          Returns the bottom margin of the box around the label.
 IlvPoint getCenter()
          Returns the center of the label.
 Shape getClip()
          Returns the shape that will clip the object.
 Paint getFillPaint()
          Returns the paint object used to draw the label text.
 Font getFont()
          Returns the font of the object.
 int getJustification()
          Returns the justification of the text.
 String getLabel()
          Returns the label.
 IlvRect getLabelBBox(IlvTransformer t)
          Returns the bounding area where the label is displayed.
 float getLeftMargin()
          Returns the left margin of the box around the label.
 float getMultilineSpacing()
          Returns the additional spacing to separate adjacent lines of a multiline label.
 float getRightMargin()
          Returns the right margin of the box around the label.
 Stroke getStroke()
          Returns the stroke object used when stroking the path.
 Paint getStrokePaint()
          Returns the paint object used when stroking the path.
 float getTopMargin()
          Returns the top margin of the box around the label.
 IlvTransformer getTransformer()
          Returns the transformation used to draw the label.
 boolean isAntialiasing()
          Returns true if the anti-aliasing mode of the label is on.
 boolean isBackgroundOn()
          Returns true if the background of the object will be filled.
 boolean isBorderOn()
          Returns true if the border of the object will be drawn.
 boolean isFillOn()
          Returns true if the inside of the text will be filled.
 boolean isFractionalMetrics()
          Returns true if the fractional metrics mode of the label is on.
 boolean isPaintAbsolute()
          Returns false if the TexturePaint or GradientPaint will be adapted to the bounding rectangle of the object.
 boolean isStrokeOn()
          Returns true if the outline of the text of the object is stroked.
static boolean IsTransformerDependentRendering()
          Returns whether all IlvZoomableLabel objects are rendered with a strategy that requires rerendering when the transformer changes.
 void moveResize(IlvRect size)
          Resizes the object.
 void resize(float neww, float newh)
          Resizes the object.
 void setAntialiasing(boolean set)
          Changes the anti-aliasing mode of the label.
 void setBackgroundOn(boolean set)
          If set to true the background of the object will be filled.
 void setBackgroundPaint(Paint paint)
          Changes the paint object used to fill the background rectangle.
 void setBorderOn(boolean set)
          If true, specifies that the border of the object will be drawn.
 void setBottomMargin(float margin)
          Sets the bottom margin of the box around the label.
 void setCenter(IlvPoint pt)
          Changes the center of the label.
 void setClip(Shape clip)
          Changes the shape that will clip the object.
 void setFillOn(boolean set)
          If true, specifies that the inside of the text will be filled.
 void setFillPaint(Paint paint)
          Changes the paint object used to draw the label text.
 void setFont(Font font)
          Changes the font of the object.
 void setForeground(Color color)
          Changes the foreground color of the object.
 void setFractionalMetrics(boolean set)
          Changes the fraction metrics mode of the label.
 void setJustification(int direction)
          Changes the justification of the multiline text.
 void setLabel(String label)
          Changes the label.
 void setLeftMargin(float margin)
          Sets the left margin of the box around the label.
 void setMultilineSpacing(float spacing)
          Sets the additional spacing to separate adjacent lines of a multiline label.
 void setPaintAbsolute(boolean set)
          When set to false, specifies that the TexturePaint or GradientPaint will be adapted to the bounding rectangle of the object.
 void setRightMargin(float margin)
          Sets the right margin of the box around the label.
 void setStroke(Stroke stroke)
          Changes the stroke object used when stroking the path.
 void setStrokeOn(boolean set)
          When set to true, specifies that the outline of the text of the object is stroked.
 void setStrokePaint(Paint paint)
          Changes the paint object used when stroking the path.
 void setTopMargin(float margin)
          Sets the top margin of the box around the label.
static void SetTransformerDependentRendering(boolean flag)
          Sets whether all IlvZoomableLabel objects are rendered with a strategy that requires rerendering when the transformer changes.
 boolean supportMultiline()
          Returns true since this object supports 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.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, notifyObjectInteractorToManager, processActionEvent, reDraw, removeActionListener, removeNamedProperty, removeNamedPropertyListener, removeProperty, replaceProperty, rotate, scale, setBackground, setEditable, setGraphicBag, setInApplyToObject, setMovable, setName, setNamedProperty, setNameImpl, setObjectInteractor, setPopupMenu, setPopupMenuName, setProperty, setSelectable, setToolTipText, setVisible, translate, zoomable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IlvZoomableLabel

public IlvZoomableLabel()
Creates a new IlvZoomableLabel with the lower-left corner in (0, 0) and an empty label.

Since:
JViews 6.0
See Also:
IlvZoomableLabel(IlvPoint, String)

IlvZoomableLabel

public IlvZoomableLabel(IlvPoint position,
                        String label,
                        boolean compatibility)
Creates a new IlvZoomableLabel instance. If the compatibility parameter is set to true, the object, when drawn without stroke and filled with a simple color, is drawn using the Graphics.drawString primitive as in ILOG JViews versions prior to ILOG JViews 3.5. Under some conditions, such a drawing method does not provide a fully zoomable drawing; this may lead in some cases to minor errors in the bounding box computation. If the compatibility parameter is set to false, the object is always drawn using the shape of the glyphs. In this case, the bounding box will always be flawless but the rendering may not be exactly the same as with the compatibility flag.

Since:
JViews 3.5
See Also:
IlvZoomableLabel(IlvPoint,String), IlvGraphic.zoomable()

IlvZoomableLabel

public IlvZoomableLabel(IlvPoint position,
                        String label)
Creates a new IlvZoomableLabel instance. It calls the other constructor with the compatibility flag set.

Parameters:
position - The lower-left corner of the label.
label - The text of the label.

IlvZoomableLabel

public IlvZoomableLabel(IlvZoomableLabel source)
Copy constructor of IlvZoomableLabel.

Parameters:
source - The object that is copied.

IlvZoomableLabel

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

setCenter

public void setCenter(IlvPoint pt)
Changes the center of the label.


getCenter

public IlvPoint getCenter()
Returns the center of the label.


getLabelBBox

public IlvRect getLabelBBox(IlvTransformer t)
Returns the bounding area where the label is displayed. The area is the bounding box of the object.

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

resize

public void resize(float neww,
                   float newh)
Resizes the object. The bounding rectangle of the object is modified. It sets its new size as (neww, newh). This method calls the applyTransform method.

Overrides:
resize in class IlvGraphic
Parameters:
neww - The new horizontal width.
newh - The new horizontal height.
See Also:
IlvGraphic, IlvGraphic.applyTransform(IlvTransformer)

moveResize

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

Overrides:
moveResize in class IlvGraphic
Parameters:
size - The new bounding rectangle of the object.
See Also:
IlvGraphic, IlvGraphic.applyTransform(IlvTransformer)

getTransformer

public IlvTransformer getTransformer()
Returns the transformation used to draw the label. The initial position of the label is part of this transformation.


boundingBox

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

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

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

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

getLabel

public String getLabel()
Returns the label.

Specified by:
getLabel in interface IlvLabelInterface
See Also:
setLabel(java.lang.String)

setLabel

public void setLabel(String label)
Changes the label. Note that this may change its bounding rectangle. For this reason, if the object is contained inside a manager, you should modify the label using the applyToObject method of the manager.

Specified by:
setLabel in interface IlvLabelInterface
Parameters:
label - The new label.
See Also:
getLabel()

supportMultiline

public boolean supportMultiline()
Returns true since this object supports multiline text.

Specified by:
supportMultiline in interface IlvLabelInterface

isAntialiasing

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


setAntialiasing

public void setAntialiasing(boolean set)
Changes the anti-aliasing mode of the label. Note that this may change its bounding rectangle. For this reason, if the object is contained inside a manager, you should modify this flag using the applyToObject method of the manager.


isFractionalMetrics

public final boolean isFractionalMetrics()
Returns true if the fractional metrics mode of the label is on.

Since:
JViews 5.0

setFractionalMetrics

public void setFractionalMetrics(boolean set)
Changes the fraction metrics mode of the label. Note that this may change its bounding rectangle. For this reason, if the object is contained inside a manager, you should modify this flag using the applyToObject method of the manager.

Since:
JViews 5.0

getFont

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

Specified by:
getFont in interface IlvFontInterface
See Also:
setFont(java.awt.Font)

setFont

public void setFont(Font font)
Changes the font of the object. Note that this may change its bounding rectangle. For this reason, if the object is contained inside a manager, you should modify the font using the applyToObject method of the manager.

Specified by:
setFont in interface IlvFontInterface
Parameters:
font - The new font.
See Also:
getFont()

getClip

public Shape getClip()
Returns the shape that will clip the object. The value may be null if no clip is applied. The shape is modified when a transformation is applied to the object.

Since:
JViews 3.5

setClip

public void setClip(Shape clip)
Changes the shape that will clip the object. The value may be null if no clip is applied.

Parameters:
clip - The new clip.
Since:
JViews 3.5

setForeground

public void setForeground(Color color)
Changes the foreground color of the object. This is the color that fills the font. It calls setFillPaint on the object.

Overrides:
setForeground in class IlvGraphic
Parameters:
color - The new color.
See Also:
setFillPaint(java.awt.Paint)

getFillPaint

public Paint getFillPaint()
Returns the paint object used to draw the label text.

Since:
JViews 3.5
See Also:
setFillPaint(java.awt.Paint)

setFillPaint

public void setFillPaint(Paint paint)
Changes the paint object used to draw the label text. It may be surprising, but because of drawing optimization code, this may change its bounding rectangle. For this reason, if the object is contained inside a manager, you should modify the paint using the applyToObject method of the manager.

Parameters:
paint - The new filling object.
Since:
JViews 3.5
See Also:
getFillPaint(), isFillOn()

getStrokePaint

public Paint getStrokePaint()
Returns the paint object used when stroking the path.

Since:
JViews 3.5
See Also:
setStrokePaint(java.awt.Paint), setStroke(java.awt.Stroke)

setStrokePaint

public void setStrokePaint(Paint paint)
Changes the paint object used when stroking the path. This is used to stroke the outline of the text if stroke is on, and to stroke the border of the label if the border is on.

Parameters:
paint - the new paint object.
Since:
JViews 3.5
See Also:
getStrokePaint(), isStrokeOn(), isBorderOn(), setStroke(java.awt.Stroke)

isFillOn

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

Since:
JViews 3.5
See Also:
setFillPaint(java.awt.Paint), setFillOn(boolean)

setFillOn

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

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

isStrokeOn

public boolean isStrokeOn()
Returns true if the outline of the text of the object is stroked.

Since:
JViews 3.5
See Also:
setStroke(java.awt.Stroke), setStrokePaint(java.awt.Paint), setStrokeOn(boolean)

setStrokeOn

public void setStrokeOn(boolean set)
When set to true, specifies that the outline of the text of the object is stroked. Note that this may change its bounding rectangle. For this reason, if the object is contained inside a manager, you should modify this flag using the applyToObject method of the manager.

Overrides:
setStrokeOn in class IlvGraphic
Parameters:
set - Set to true to enable the stroke in your customized graphic object.
Since:
JViews 3.5
See Also:
setStroke(java.awt.Stroke), setStrokePaint(java.awt.Paint), isStrokeOn()

getStroke

public Stroke getStroke()
Returns the stroke object used when stroking the path. This method may return nullif there is no stroke specified.

Since:
JViews 3.5
See Also:
getStrokePaint(), setStroke(java.awt.Stroke)

setStroke

public void setStroke(Stroke stroke)
Changes the stroke object used when stroking the path. This is used to stroke the outline of the text if stroke is on, and to stroke the border of the label if the border is on. 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 stroke using the applyToObject method of the manager.

Since:
JViews 3.5
See Also:
getStrokePaint(), getStroke(), isStrokeOn(), isBorderOn()

setBackgroundPaint

public void setBackgroundPaint(Paint paint)
Changes the paint object used to fill the background rectangle.

Parameters:
paint - The new paint object.
Since:
JViews 5.0
See Also:
getBackgroundPaint()

getBackgroundPaint

public Paint getBackgroundPaint()
Returns the paint object used to fill the background rectangle.

Since:
JViews 5.0
See Also:
setBackgroundPaint(java.awt.Paint)

isBackgroundOn

public boolean isBackgroundOn()
Returns true if the background of the object will be filled.

Since:
JViews 5.0
See Also:
setBackgroundPaint(java.awt.Paint), setBackgroundOn(boolean)

setBackgroundOn

public void setBackgroundOn(boolean set)
If set to true the background of the object will be filled. Note that this may change its bounding rectangle. For this reason, if the object is contained inside a manager you should modify this flag using the applyToObject method of the manager.

Since:
JViews 5.0
See Also:
isBackgroundOn(), setBackgroundPaint(java.awt.Paint)

isBorderOn

public boolean isBorderOn()
Returns true if the border of the object will be drawn. This method uses the stroke paint and the stroke for drawing the border.

Since:
JViews 5.0
See Also:
setStrokePaint(java.awt.Paint), setStroke(java.awt.Stroke), setBorderOn(boolean)

setBorderOn

public void setBorderOn(boolean set)
If true, specifies that the border of the object will be drawn. This method uses the stroke paint and the stroke for drawing the border. Note that this may change its bounding rectangle. For this reason, if the object is contained inside a manager you should modify this flag using the applyToObject method of the manager.

Since:
JViews 5.0
See Also:
isBorderOn(), setStrokePaint(java.awt.Paint), setStroke(java.awt.Stroke)

isPaintAbsolute

public boolean isPaintAbsolute()
Returns false if the TexturePaint or GradientPaint will be adapted to the bounding rectangle of the object. The default value is false. This value does not affect automatically adjusted Paint such as ilog.views.java2d.IlvLinearGradientPaint.

Since:
JViews 3.5
See Also:
setPaintAbsolute(boolean), setFillPaint(java.awt.Paint), setStrokePaint(java.awt.Paint), setBackgroundPaint(java.awt.Paint), adaptPaint(java.awt.Shape, java.awt.Paint)

setPaintAbsolute

public void setPaintAbsolute(boolean set)
When set to false, specifies that the TexturePaint or GradientPaint will be adapted to the bounding rectangle of the object. The default value is false. This value does not affect automatically adjusted Paint such as ilog.views.java2d.IlvLinearGradientPaint.

Since:
JViews 3.5
See Also:
isPaintAbsolute(), setFillPaint(java.awt.Paint), setStrokePaint(java.awt.Paint), setBackgroundPaint(java.awt.Paint), adaptPaint(java.awt.Shape, java.awt.Paint)

adaptPaint

protected Paint adaptPaint(Shape shape,
                           Paint paint)
Returns a new Paint object that will fit the shape parameter according to the initial paint parameter. This method is called only if isPaintAbsolute() returns false. By default, it deals with GradientPaint and TexturePaint instances to adapt them correctly because they do not automatically fit the shape of the object on which they are drawn. You can override this method to manage your own Paint subclasses if they do not take the shape of the object into account. You will generally call the superclass method for GradientPaint and TexturePaint instances. Other Paint objects deriving from IlvMultipleGradientPaint automatically take into account the shape of the object if their IlvMultipleGradientPaint.isAdapting() method returns true and thus are not modified by this method.

Parameters:
shape - The shape parameter that the returned Paint should fit.
paint - The initial Paint object.
See Also:
isPaintAbsolute()

setLeftMargin

public void setLeftMargin(float margin)
Sets the left margin of the box around the label. Note that this may change its bounding rectangle. For this reason, if the object is contained inside a manager you should modify the parameter using the applyToObject method of the manager.

Since:
JViews 5.0

getLeftMargin

public float getLeftMargin()
Returns the left margin of the box around the label.

Since:
JViews 5.0

setRightMargin

public void setRightMargin(float margin)
Sets the right margin of the box around the label. Note that this may change its bounding rectangle. For this reason, if the object is contained inside a manager you should modify the parameter using the applyToObject method of the manager.

Since:
JViews 5.0

getRightMargin

public float getRightMargin()
Returns the right margin of the box around the label.

Since:
JViews 5.0

setTopMargin

public void setTopMargin(float margin)
Sets the top margin of the box around the label. Note that this may change its bounding rectangle. For this reason, if the object is contained inside a manager you should modify the parameter using the applyToObject method of the manager.

Since:
JViews 5.0

getTopMargin

public float getTopMargin()
Returns the top margin of the box around the label.

Since:
JViews 5.0

setBottomMargin

public void setBottomMargin(float margin)
Sets the bottom margin of the box around the label. Note that this may change its bounding rectangle. For this reason, if the object is contained inside a manager you should modify the parameter using the applyToObject method of the manager.

Since:
JViews 5.0

getBottomMargin

public float getBottomMargin()
Returns the bottom margin of the box around the label.

Since:
JViews 5.0

setJustification

public void setJustification(int direction)
Changes the justification of the multiline text. Use the following values for justification:

Since:
JViews 5.0

getJustification

public final int getJustification()
Returns the justification of the text.

Since:
JViews 5.0

setMultilineSpacing

public final void setMultilineSpacing(float spacing)
Sets the additional spacing to separate adjacent lines of a multiline label. Note that this may change its bounding rectangle. For this reason, if the object is contained inside a manager you should modify the parameter using the applyToObject method of the manager.

Since:
JViews 5.0

getMultilineSpacing

public final float getMultilineSpacing()
Returns the additional spacing to separate adjacent lines of a multiline label.

Since:
JViews 5.0

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.

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

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.

toString

public String toString()
Returns a string representation of the graphic object. The method returns a string that 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()

SetTransformerDependentRendering

public static void SetTransformerDependentRendering(boolean flag)
Sets whether all IlvZoomableLabel objects are rendered with a strategy that requires rerendering when the transformer changes. This is slower and uses more memory per label, but some Chinese and Japanese fonts cannot be rendered with the faster default strategy where the rendering is precalculated independent from the transformer. In JDK 1.4, the slow transformer dependent mode was not required. In JDK 1.5 and later, the slow mode might be required. This depends on the operating system, on the available fonts, and on the status of Sun's bug list related to Chinese and Japanese rendering.

The default value is false.

Since:
JViews 8.1

IsTransformerDependentRendering

public static boolean IsTransformerDependentRendering()
Returns whether all IlvZoomableLabel objects are rendered with a strategy that requires rerendering when the transformer changes. This is slower and uses more memory per label, but some Chinese and Japanese fonts cannot be rendered with the faster default strategy where the rendering is precalculated independent from the transformer.

Since:
JViews 8.1


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