ilog.views.graphic
Class IlvIcon

java.lang.Object
  extended by ilog.views.IlvGraphic
      extended by ilog.views.graphic.IlvIcon
All Implemented Interfaces:
IlvPersistentObject, Transferable, ImageObserver, Serializable
Direct Known Subclasses:
IlvExpandCollapseRenderer.ExpandCollapseIcon, IlvRasterIcon, IlvSubGraphRenderer.ExpandCollapseIcon

public class IlvIcon
extends IlvGraphic
implements ImageObserver

IlvIcon is a graphic object that displays an image.

Example

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

   URL filePath = null;
   IlvManager manager = new IlvManager();
   try {
     filePath = new URL("file:///c:/ILOG/jviews-framework81/data/svg/logo.gif");
   } catch (MalformedURLException e)
   {
   }
   IlvIcon icon = new IlvIcon(filePath, new IlvRect(10,10,203,97));
   manager.addObject(icon, 1, true);
 

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

IlvIcon

About Graphic Objects

IlvIcon is a custom graphic object, that is, a subclass of IlvGraphic. Graphic objects are controlled using an instance of IlvManager or one of its subclasses, 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, IlvRect, Serialized Form

Field Summary
protected  IlvRect drawrect
          Deprecated. The object is now defined by a definition rectangle that is obtained by taking the result of a call to getDefinitionRect() and applying getTransformer() to it.
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
IlvIcon()
          Creates an empty IlvIcon.
IlvIcon(IlvIcon source)
          Creates a new IlvIcon by copying an existing one.
IlvIcon(IlvInputStream stream)
          Reads the object from an IlvInputStream.
IlvIcon(Image image, IlvRect rect)
          Creates a new IlvIcon.
IlvIcon(RenderedImage renderedImage, IlvRect rect)
          Creates a new IlvIcon to display the RenderedImage given as a parameter.
IlvIcon(String file, IlvRect rect)
          Creates a new IlvIcon.
IlvIcon(URL url, IlvRect rect)
          Creates a new IlvIcon.
 
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.
 float getAlpha()
          Returns the alpha value of this graphic object.
 Shape getClip()
          Returns the shape that will clip the object.
 IlvRect getDefinitionRect()
          Returns the definition rectangle of the IlvIcon.
 Image getImage()
          Returns the image.
 String getImageLocation()
          Returns the image location.
 RenderedImage getRenderedImage()
          Returns the RenderedImage.
 IlvTransformer getTransformer()
          Returns the transformer that is currently applied to the IlvIcon.
 boolean imageUpdate(Image img, int flags, int x, int y, int w, int h)
          Redraws the object when the image is fully loaded.
 boolean isAutoResizing()
          Returns whether or not the IlvIcon will be resized automatically to the width/height of the Image when setImageLocation(String) or setImage(Image) is called.
 boolean isHighQualityRendering()
          Returns true if high rendering quality mode is set.
 void setAlpha(float alpha)
          Changes the alpha value of this graphic object.
 void setAutoResizing(boolean value)
          Sets whether or not the IlvIcon will be resized automatically to the width/height of the Image when setImageLocation(String) or setImage(Image) is called.
 void setClip(Shape clip)
          Changes the shape that will clip the object.
 void setGraphicBag(IlvGraphicBag bag)
          Overrides the method to restart an animated GIF, if necessary.
 void setHighQualityRendering(boolean value)
          Changes the rendering quality state of the image.
 void setImage(Image image)
          Changes the image.
 void setImageLocation(String location)
          Changes the image.
 void setRenderedImage(RenderedImage rimage)
          Changes the RenderedImage.
 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, moveResize, notifyObjectInteractorToManager, processActionEvent, reDraw, removeActionListener, removeNamedProperty, removeNamedPropertyListener, removeProperty, replaceProperty, resize, rotate, scale, setBackground, setEditable, setFillOn, setForeground, setInApplyToObject, setMovable, setName, setNamedProperty, setNameImpl, setObjectInteractor, setPopupMenu, setPopupMenuName, setProperty, setSelectable, setStrokeOn, setToolTipText, setVisible, toString, translate, zoomable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

drawrect

protected final IlvRect drawrect
Deprecated. The object is now defined by a definition rectangle that is obtained by taking the result of a call to getDefinitionRect() and applying getTransformer() to it.
The definition rectangle of the object.

Constructor Detail

IlvIcon

public IlvIcon()
Creates an empty IlvIcon. The image used by the IlvIcon must be set later on with setImageLocation(String), setImage(Image) or setRenderedImage(RenderedImage). The image will be loaded synchronously and the definition rectangle of the image getDefinitionRect() will be computed from the image size.

Since:
JViews 6.0
See Also:
isAutoResizing()

IlvIcon

public IlvIcon(RenderedImage renderedImage,
               IlvRect rect)
Creates a new IlvIcon to display the RenderedImage given as a parameter. Note that when you create an IlvIcon with this constructor, the IlvIcon cannot be saved in an IVL file.

Parameters:
renderedImage - The RenderedImage.
rect - The definition rectangle of the object.
Since:
JViews 5.0

IlvIcon

public IlvIcon(Image image,
               IlvRect rect)
Creates a new IlvIcon. Note that when you create an IlvIcon with this constructor, the IlvIcon cannot be saved in an IVL file.

Parameters:
image - The image.
rect - The definition rectangle of the object.

IlvIcon

public IlvIcon(URL url,
               IlvRect rect)
Creates a new IlvIcon.

Parameters:
url - The image URL.
rect - The definition rectangle of the object.

IlvIcon

public IlvIcon(String file,
               IlvRect rect)
Creates a new IlvIcon.

Parameters:
file - The file location of the image.
rect - The definition rectangle of the object.

IlvIcon

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

Parameters:
source - The source icon.

IlvIcon

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

getImage

public Image getImage()
Returns the image.


getRenderedImage

public RenderedImage getRenderedImage()
Returns the RenderedImage.

Since:
JViews 5.0

setRenderedImage

public void setRenderedImage(RenderedImage rimage)
Changes the RenderedImage. Note that when you change the image with this method, the IlvIcon can no longer be saved in an IVL file.

Parameters:
rimage - The new rendered image.
Since:
JViews 5.0
See Also:
setImageLocation(java.lang.String)

setImage

public void setImage(Image image)
Changes the image. This method may change the bounding box of the IlvIcon if isAutoResizing() returns true. Note that when you change the image with this method, the IlvIcon can no longer be saved in an IVL file.

Parameters:
image - The new image.
See Also:
setImageLocation(java.lang.String)

getImageLocation

public String getImageLocation()
Returns the image location.

Returns:
A string containing the URL of the image or the name of the image file.

setImageLocation

public void setImageLocation(String location)
Changes the image. This method may change the bounding box of the IlvIcon if isAutoResizing() returns true.

Parameters:
location - A string containing the URL of the image.

getTransformer

public IlvTransformer getTransformer()
Returns the transformer that is currently applied to the IlvIcon.

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

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

setAlpha

public void setAlpha(float alpha)
Changes the alpha value of this graphic object. The alpha composition value is used to render the graphic object in a transparent way. The value must be in the range of [0.0, 1.0], the value of 1 meaning that the graphic object is not transparent.

If the containers of the graphic object (manager layer, graphic set) have their own alpha value, the object draws with a composed alpha value.

The default value is 1.

Parameters:
alpha - The new transparency level in the range [0.0, 1.0].
Since:
JViews 8.0
See Also:
getAlpha(), IlvManagerLayer.setAlpha(float)

getAlpha

public float getAlpha()
Returns the alpha value of this graphic object. The alpha composition value is used to render this graphic object in a transparent way. The value is in the range of [0.0, 1.0], the value of 1 meaning that the graphic object is not transparent.

Since:
JViews 8.0
See Also:
setAlpha(float), IlvManagerLayer.getAlpha()

setHighQualityRendering

public void setHighQualityRendering(boolean value)
Changes the rendering quality state of the image. Setting the value to true will improve the rendering. The default value is false.

Parameters:
value - The value.
Since:
JViews 3.5

isHighQualityRendering

public boolean isHighQualityRendering()
Returns true if high rendering quality mode is set.

Since:
JViews 3.5
See Also:
setHighQualityRendering(boolean)

imageUpdate

public boolean imageUpdate(Image img,
                           int flags,
                           int x,
                           int y,
                           int w,
                           int h)
Redraws the object when the image is fully loaded.

Specified by:
imageUpdate in interface ImageObserver

setGraphicBag

public void setGraphicBag(IlvGraphicBag bag)
Overrides the method to restart an animated GIF, if necessary.

Overrides:
setGraphicBag in class IlvGraphic
Parameters:
bag - The graphic bag.
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

getDefinitionRect

public IlvRect getDefinitionRect()
Returns the definition rectangle of the IlvIcon. This is the IlvRect that has been used at construction time. The IlvIcon is defined by a definition rectangle that is obtained by taking the result returned by this method and applying getTransformer() to it.

Since:
JViews 3.5

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

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

setAutoResizing

public final void setAutoResizing(boolean value)
Sets whether or not the IlvIcon will be resized automatically to the width/height of the Image when setImageLocation(String) or setImage(Image) is called. The default value is false except when the IlvIcon() constructor is used.

Parameters:
value - Sets whether the IlvIcon will be resized automatically or not.
Since:
JViews 6.0

isAutoResizing

public final boolean isAutoResizing()
Returns whether or not the IlvIcon will be resized automatically to the width/height of the Image when setImageLocation(String) or setImage(Image) is called. The default value is false except when the IlvIcon() constructor is used.

Since:
JViews 6.0

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.


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