ilog.views.sdm.graphic
Class IlvURLGraphic

java.lang.Object
  extended by ilog.views.IlvGraphic
      extended by ilog.views.graphic.IlvGraphicSet
          extended by ilog.views.sdm.graphic.IlvURLGraphic
All Implemented Interfaces:
GraphicBagHierarchyEventReceiver, ManagerViewsHierarchyEventReceiver, IlvGraphicBag, IlvPersistentObject, Transferable, Serializable

public class IlvURLGraphic
extends IlvGraphicSet

A class that loads the contents of an IlvGraphic from a URL.

The contents of the graphic object can be specified as an SVG file, an IVL file, a DXF file, a GIF or JPG or PNG image or as an ILOG JViews prototype. The type of the file is determined by the file name extension.

This class can be used in two ways:

  1. As a factory: The get(java.lang.String) method returns a new graphic object whose contents are described by the specified URL.
  2. Directly as an IlvGraphic: You can create a new instance of IlvURLGraphic and call setURL(java.lang.String) to specify the contents of the graphic object.

The first way is recommended, because it saves the extra cost of the graphic set. The second way can be used when the object must be created through its constructor.

Since:
JViews 5.5
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class ilog.views.graphic.IlvGraphicSet
IlvGraphicSet.DelegateObjectInteractor
 
Field Summary
 
Fields inherited from class ilog.views.graphic.IlvGraphicSet
list
 
Constructor Summary
IlvURLGraphic()
          Creates a new empty URL graphic.
IlvURLGraphic(IlvInputStream in)
          Reads a new URL graphic from an input stream.
IlvURLGraphic(IlvURLGraphic source)
          Creates a new copy of a URL graphic.
 
Method Summary
 void applyTransform(IlvTransformer t)
          Applies a transformer to this graphic object.
 IlvGraphic copy()
          Returns a new copy of this URL graphic.
 void flush()
          Flushes the URL cache that corresponds to this IlvURLGraphic instance.
static IlvGraphic get(String file)
          Returns an IlvGraphic containing the graphic objects described by the specified URL.
 Color getBackground()
          Returns the background color of all the objects in the graphic set, or null if the background color has not been set.
 Color getForeground()
          Returns the foreground color of all the objects in the graphic set, or null if the foreground color has not been set.
 String getURL()
          Returns the URL that describes the contents of this URL graphic.
static String getURL(IlvGraphic g)
          Returns the URL from which a graphic object has been read.
static boolean isSupported(String file)
          Returns true if the specified URL is of a type supported by the URL graphic class.
 void setBackground(Color c)
          Sets the background color of all the objects in the graphic set.
 void setForeground(Color c)
          Sets the foreground color of all the objects in the graphic set.
 void setURL(String file)
          Sets the URL that describes the contents of this URL graphic.
 void write(IlvOutputStream out)
          Writes this URL graphic to an output stream.
 
Methods inherited from class ilog.views.graphic.IlvGraphicSet
addGraphicBagHierarchyListener, addManagerViewsHierarchyListener, addObject, addObjectAt, applyToObject, boundingBox, contains, contains, draw, drawCore, enableGraphicBagHierarchyEventForwarding, enableManagerViewsHierarchyEventForwarding, fireGraphicBagHierarchyEvent, fireManagerViewsHierarchyEvent, firstContains, getAlpha, getCardinal, getClip, getIndex, getIntersectionWithOutline, getObject, getObject, getObjectName, getObjects, getOriginalPopupMenu, getPopupMenu, getToolTipText, isPersistent, moveObject, needsGraphicBagHierarchyEvent, needsManagerViewsHierarchyEvent, reDrawObj, reDrawRegion, removeAll, removeGraphicBagHierarchyListener, removeManagerViewsHierarchyListener, removeObject, removeObjectAt, reshapeObject, setAlpha, setClip, setGraphicBag, setObjectName, zoomable
 
Methods inherited from class ilog.views.IlvGraphic
addActionListener, addNamedPropertyListener, boundingBox, getAndAssociateObjectInteractor, getCenter, getDefaultInteractor, getGraphicBag, GetGraphicObject, getName, getNamedProperty, getObjectInteractor, getPopupMenu, getPopupMenuName, getProperty, getToolTipText, getTopLevelGraphicBag, getTransferData, getTransferDataFlavors, hasProperty, inside, intersects, isDataFlavorSupported, isEditable, isInApplyToObject, isMovable, isSelectable, isVisible, makeSelection, move, move, moveResize, notifyObjectInteractorToManager, processActionEvent, reDraw, removeActionListener, removeNamedProperty, removeNamedPropertyListener, removeProperty, replaceProperty, resize, rotate, scale, setEditable, setFillOn, 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
 
Methods inherited from interface ilog.views.IlvGraphicBag
getGraphicBag
 

Constructor Detail

IlvURLGraphic

public IlvURLGraphic()
Creates a new empty URL graphic.


IlvURLGraphic

public IlvURLGraphic(IlvInputStream in)
              throws IlvReadFileException,
                     IOException
Reads a new URL graphic from an input stream.

Parameters:
in - The input stream.
Throws:
IlvReadFileException - if the stream is not correctly formatted.
IOException - if an error occurred while reading the stream.

IlvURLGraphic

public IlvURLGraphic(IlvURLGraphic source)
Creates a new copy of a URL graphic.

Parameters:
source - The URL graphic to copy.
Method Detail

setURL

public void setURL(String file)
Sets the URL that describes the contents of this URL graphic.

Parameters:
file - The URL that describes the contents of this URL graphic. This can be an SVG file (for example: "http://myserver/drawings/tiger.svg"), an IVL file (for example: "http://myserver/drawings/butterfly.ivl"), or a prototype URL (for example: "file:mydir/myprotos.ivl#aproto").

Since JViews 8.0, this class can load a DXF file as well. Since JViews 8.1, this class can load JPG, GIF and PNG files as well.

Throws:
IllegalArgumentException - if the URL points to a file in a format that is not supported by the URL graphic.

getURL

public String getURL()
Returns the URL that describes the contents of this URL graphic.

Returns:
last URL set

write

public void write(IlvOutputStream out)
           throws IOException
Writes this URL graphic to an output stream.

Specified by:
write in interface IlvPersistentObject
Overrides:
write in class IlvGraphicSet
Parameters:
out - The output stream.
Throws:
IOException - if an error occurred while writing to the stream.

copy

public IlvGraphic copy()
Returns a new copy of this URL graphic.

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

flush

public void flush()
Flushes the URL cache that corresponds to this IlvURLGraphic instance. Call this method if the URL content has changed. After this method has been called the internal graphic cache is deleted. Graphics are no longer loaded from the internal cache.

Since:
JViews 8.0

get

public static IlvGraphic get(String file)
Returns an IlvGraphic containing the graphic objects described by the specified URL.

Parameters:
file - The URL to read the graphics from. This can be either an SVG file, an IVL file, an ILOG JViews prototypes URL of the form file:/.../protos.ivl#aProto, a DXF file, a PNG file, a JPG file, or a GIF file.
Returns:
Returns an IlvGraphic containing the graphic objects described by the specified URL.

isSupported

public static boolean isSupported(String file)
Returns true if the specified URL is of a type supported by the URL graphic class. Only the suffix of the URL is checked by this method, not its actual contents.

Parameters:
file - The specified URL.
Returns:
true if file is of a supported type

getURL

public static String getURL(IlvGraphic g)
Returns the URL from which a graphic object has been read.

Parameters:
g - The URL graphic.
Returns:
URL that produced the given graphic object

setForeground

public void setForeground(Color c)
Sets the foreground color of all the objects in the graphic set.

Overrides:
setForeground in class IlvGraphic
Parameters:
c - The new foreground color.
Since:
JViews 6.0
See Also:
IlvGraphic.draw(Graphics, IlvTransformer), IlvGraphic.setBackground(Color), IlvGraphic.setFillOn(boolean), IlvGraphic.setStrokeOn(boolean), IlvGraphic

setBackground

public void setBackground(Color c)
Sets the background color of all the objects in the graphic set.

Overrides:
setBackground in class IlvGraphic
Parameters:
c - The new background color.
Since:
JViews 6.0
See Also:
IlvGraphic.draw(Graphics, IlvTransformer), IlvGraphic.setForeground(Color), IlvGraphic.setFillOn(boolean), IlvGraphic.setStrokeOn(boolean), IlvGraphic

getForeground

public Color getForeground()
Returns the foreground color of all the objects in the graphic set, or null if the foreground color has not been set.

Returns:
foreground color
Since:
JViews 6.5
See Also:
setForeground(java.awt.Color)

getBackground

public Color getBackground()
Returns the background color of all the objects in the graphic set, or null if the background color has not been set.

Returns:
background color
Since:
JViews 6.5
See Also:
setBackground(java.awt.Color)

applyTransform

public void applyTransform(IlvTransformer t)
Applies a transformer to this graphic object.

Overrides:
applyTransform in class IlvGraphicSet
Parameters:
t - The transformer to be applied.
Since:
JViews 6.5
See Also:
IlvGraphic


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