|
||||||||||
| PREV CLASS Documentation homepage NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectilog.views.IlvGraphic
public abstract class IlvGraphic
IlvGraphic is the abstract base class for all graphic objects
managed by an IlvManager instance.
IlvGraphic,
examples of this are IlvRectangle, IlvLine,
IlvText and IlvLinkImage. A collection of graphic
objects is managed using a graphic bag, that is, a class that implements the
IlvGraphicBag interface. An example of a graphic bag is the
IlvManager class. IlvGraphic is used as the base
object for specialized graphic objects.
Potentially persistent properties are stored in IlvGraphic
instances using implementations of the IlvNamedProperty
abstract class.
public IlvGraphic copy()public void draw(Graphics graphic, IlvTransformer trans)public IlvRect boundingBox(IlvTransformer trans)public void applyTransform(IlvTransformer trans)Note: these methods are called frequently, custom overrides must be optimized to ensure maximum performance.
Although not mandatory, it is often necessary to override the following methods:
contains(IlvPoint p, IlvPoint tp, IlvTransformer t)intersects(IlvRect rect, IlvRect trect,IlvTransformer t)inside(IlvRect rect, IlvRect trect, IlvTransformer t)The following code example shows a very simple customized graphic object.
public class SimpleRectangle extends IlvGraphic {
protected final IlvRect drawrect = new IlvRect();
public SimpleRectangle(){
this(new IlvRect(10, 10, 30, 20));
}
public SimpleRectangle(IlvRect rect) {
super();
drawrect.reshape(rect.x, rect.y, rect.width, rect.height);
}
public SimpleRectangle(SimpleRectangle source){
super(source);
drawrect.reshape(source.drawrect.x, source.drawrect.y,
source.drawrect.width, source.drawrect.height);
}
public IlvGraphic copy() {
return new SimpleRectangle(this);
}
public void draw(Graphics graphic, IlvTransformer trans) {
graphic.setColor(Color.GREEN);
IlvRect tmprect = new IlvRect();
tmprect.reshape(drawrect.x, drawrect.y,
drawrect.width, drawrect.height);
trans.applyFloor(tmprect);
graphic.fillRect((int)tmprect.x,
(int)tmprect.y,
(int)tmprect.width+1,
(int)tmprect.height+1);
}
public IlvRect boundingBox(IlvTransformer trans) {
IlvRect rect = new IlvRect(drawrect);
if (!(trans == null || trans.isIdentity()))
trans.apply(rect);
return rect;
}
public void applyTransform(IlvTransformer trans) {
if (trans == null || trans.isIdentity())
return;
trans.apply(drawrect);
}
}
SimpleRectangle
custom graphic object into a Java application.
public class FrameworkTest extends JFrame {
IlvManager manager;
IlvManagerView mgrview;
public FrameworkTest()
{
manager = new IlvManager();
mgrview = new IlvManagerView(manager);
mgrview.setBackground(Color.white);
getContentPane().setLayout(new BorderLayout(0,0));
getContentPane().add(new IlvJScrollManagerView(mgrview),
BorderLayout.CENTER);
IlvGraphic obj = new SimpleRectangle();
manager.addObject(obj, 1, false);
}
public static void main(String[] args) {
JFrame frame = new FrameworkTest();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(200,200);
frame.setVisible(true);
}
}
See IlvManager for a more complete explanation of how to integrate
graphic objects into graphic application.
IlvManager instance.
A transformation defines the area of a manager that the current view is
displaying. It also defines the zoom level and rotation applied to graphic
objects inside a manager. Transformation is controlled using an
IlvTransformer instance.
A transformation that does not translate, rotate or zoom any object is
called the identity transformation.
The rectangle returned by the boundingBox(IlvTransformer)
method follows the zoom factor of the transformation. If it does not, calls
to zoomable() for this manager return false.
IlvGraphic methods that modify the bounding box of a graphic
object must only be used by calling the applyToObject
method from its manager. For some operations, best practice is to call the
corresponding method from the manager. For example, call
IlvManager.moveObject instead of IlvGraphic.move.
The following examples show equivalent code:
obj.getGraphicBag().applyToObject(obj, new IlvApplyObject() {
public void apply(IlvGraphic obj, Object arg) {
IlvPoint p = (IlvPoint)arg;
obj.move(p.x, p.y);
}
}, point, redraw);
The applyToObject implementation above corresponds to:
manager.moveObject(obj, point.x, point.y, redraw);
IlvSelectInteractor associated to the entire manager view or by
object interactors associated to each individual graphic object. An object
interactor is an instance of IlvObjectInteractor, it is
associated to graphic object using setObjectInteractor.
For details, see IlvObjectInteractor.
IlvManager.write(String, boolean).
Java serialization cannot work for graphic objects such as
IlvIcon, these classes manage JDK objects that are not
serializable.
The IlvGraphic class enables you to add interactive content
to you application in the form of tool tips and pop-up menus. The following
code example shows how to set the tool tip for an instance of the
SimpleRectangle class shown earlier:
First, you need to register the manager view that displays the tool tip:
IlvToolTipManager.registerView(mgrview);Then, you assign your tool tip to the graphic objects displayed in
mgrview:
IlvGraphic obj = new SimpleRectangle();
obj.setToolTipText("Simple Rectangle");
Pop-up menus appear when the pop-up trigger interaction is performed. This occurs when the user right-clicks a graphic object. A pop-up menu allows the user to select actions that are associated with the graphic object. Pop-up menus work like tool tips, that is, your have to register the manager view and associate the pop-up menu at each graphic object.
Pop-up menus use a lot of memory. To optimize your application the
ILOG JViews API enables you to share menus among multiple graphic objects.
This is done by registering menus directly with the static pop-up menu
manager IlvPopupMenuManager. Once a pop-up menu is
registered globally, you can allocate it to one or more graphic objects. The
following code example shows how to do this:
First, you need to register the manager view that displays the pop-up menu:
IlvPopupMenuManager.registerView(mgrview);Then, you assign your pop-up menu to the graphic objects displayed in
mgrview:
IlvPopupMenuManager.registerMenu("MENU1", createVerySimpleMenu());
obj.setPopupMenuName("MENU1");
The following image shows the SimpleRectangle class with tool tip and
pop-up menu visible.
Note: ILOG recommends that you take advantage of the
extra functionality found in IlvSimplePopupMenu to create
your pop-up menus.
IlvManager,
IlvGraphicBag,
IlvNamedProperty,
IlvTransformer,
IlvToolTipManager,
IlvObjectInteractor,
IlvSelectInteractor,
IlvPopupMenuManager,
IlvSimplePopupMenu,
Serialized Form| Constructor Summary | |
|---|---|
IlvGraphic()
Creates a new IlvGraphic with the default setting. |
|
IlvGraphic(IlvGraphic source)
Creates a new IlvGraphic by copying an existing one. |
|
IlvGraphic(IlvInputStream stream)
Reads a graphic object from an IlvInputStream. |
|
| Method Summary | |
|---|---|
void |
addActionListener(ActionListener listener)
Adds the specified action listener to receive action events from this object. |
void |
addNamedPropertyListener(NamedPropertyListener listener)
Adds the specified listener to receive events when a named property is added or removed from the graphic object. |
abstract void |
applyTransform(IlvTransformer t)
Applies a transformation to the shape of the object. |
IlvRect |
boundingBox()
Returns the bounding rectangle of the object for the identity transformation. |
abstract IlvRect |
boundingBox(IlvTransformer t)
Returns the bounding rectangle of the object for a given transformation. |
boolean |
contains(IlvPoint p,
IlvPoint tp,
IlvTransformer t)
Tests if a point lies within the outline of the object. |
abstract IlvGraphic |
copy()
Returns a copy of this IlvGraphic instance. |
abstract void |
draw(Graphics dst,
IlvTransformer t)
Draws the object. |
IlvObjectInteractor |
getAndAssociateObjectInteractor()
Returns the active object interactor. |
IlvPoint |
getCenter(IlvTransformer t)
Returns the center point of the graphic object. |
String |
getDefaultInteractor()
Returns the class name of the default interactor. |
IlvGraphicBag |
getGraphicBag()
Returns the graphic bag that contains the object. |
static IlvGraphic |
GetGraphicObject(Transferable trans)
A static method that decodes a Transferable object. |
IlvPoint |
getIntersectionWithOutline(IlvPoint innerPoint,
IlvPoint outerPoint,
IlvTransformer t)
Returns the intersection of the line segment from inner point to outer point with the shape of the graphic object. |
String |
getName()
Returns the name of the object. |
IlvNamedProperty |
getNamedProperty(String name)
Returns the named property associated with this graphic object. |
IlvObjectInteractor |
getObjectInteractor()
Returns the object interactor associated with this object. |
JPopupMenu |
getPopupMenu()
Returns the Swing pop-up menu set by setPopupMenu(javax.swing.JPopupMenu). |
JPopupMenu |
getPopupMenu(IlvPoint p,
IlvTransformer t,
IlvManagerView view,
IlvPopupMenuManager popupManager)
Returns the Swing pop-up menu to display when the pop-up is triggered. |
String |
getPopupMenuName()
Returns the name of the Swing pop-up menu set by setPopupMenuName(java.lang.String). |
Object |
getProperty(String key)
Returns the value of a property. |
String |
getToolTipText()
Returns the tool tip set for this graphic object. |
String |
getToolTipText(IlvPoint p,
IlvTransformer t)
Returns the tool tip text to display when the mouse pointer is at a specified location inside the graphic object. |
IlvGraphicBag |
getTopLevelGraphicBag()
Returns the top level graphic bag. |
Object |
getTransferData(DataFlavor flavor)
Returns an object that represents the data to be transferred. |
DataFlavor[] |
getTransferDataFlavors()
Returns an array of DataFlavor objects indicating
in which flavors the data can be provided. |
boolean |
hasProperty(String key,
Object value)
Tests the value of a property. |
boolean |
inside(IlvRect rect,
IlvRect trect,
IlvTransformer t)
Tests if a rectangle contains the object. |
boolean |
intersects(IlvRect rect,
IlvRect trect,
IlvTransformer t)
Tests if a rectangle overlaps the object. |
boolean |
isDataFlavorSupported(DataFlavor flavor)
Indicates whether the specified data flavor is supported for this object or not. |
boolean |
isEditable()
Tests if this graphic object is editable with the selection interactor. |
boolean |
isInApplyToObject()
Returns true if this graphic object is currently treated
inside a call to applyToObject. |
boolean |
isMovable()
Tests whether this graphic object is movable with the selection interactor. |
boolean |
isPersistent()
If this method returns true, the IlvGraphic
instance will be saved in IVL files. |
boolean |
isSelectable()
Tests if this graphic object can be selected with the selection interactor. |
boolean |
isVisible()
Tests whether this graphic object is visible. |
IlvSelection |
makeSelection()
Creates a selection object for this object. |
void |
move(float x,
float y)
Moves the object. |
void |
move(IlvPoint p)
Moves the object. |
void |
moveResize(IlvRect size)
Resizes the object. |
protected void |
notifyObjectInteractorToManager(IlvObjectInteractor interactor)
Notifies the manager that the object interactor has changed. |
void |
processActionEvent(ActionEvent event)
Processes action events on this object instance by dispatching them to all ActionListener objects registered with this
graphic object. |
void |
reDraw()
Redraws this object. |
void |
removeActionListener(ActionListener listener)
Removes the specified action listener. |
void |
removeNamedProperty(String name)
Removes the named property associated with this graphic object. |
void |
removeNamedPropertyListener(NamedPropertyListener listener)
Removes the specified listener so that it no longer receives events from this graphic object when named properties are added or removed. |
boolean |
removeProperty(String key)
Removes a property. |
boolean |
replaceProperty(String key,
Object value)
Replaces the value of an existing property. |
void |
resize(float neww,
float newh)
Resizes the object. |
void |
rotate(IlvPoint center,
double angle)
Rotates the object. |
void |
scale(double scalex,
double scaley)
Resizes the object. |
void |
setBackground(Color c)
Changes the background color of the object. |
void |
setEditable(boolean editable)
Allows or disallows editing for this graphic object with the selection interactor. |
void |
setFillOn(boolean value)
Changes the fill status of the object. |
void |
setForeground(Color c)
Changes the foreground color of the object. |
void |
setGraphicBag(IlvGraphicBag bag)
Changes the bag that contains the object. |
boolean |
setInApplyToObject(boolean v)
Sets whether this graphic object is currently treated inside a call to applyToObject. |
void |
setMovable(boolean movable)
Allows or prohibits movement of this graphic object with the selection interactor. |
void |
setName(String name)
Sets the name of the object. |
IlvNamedProperty |
setNamedProperty(IlvNamedProperty property)
Associates a named property with this graphic object. |
void |
setNameImpl(String name)
Sets the name of the object. |
void |
setObjectInteractor(IlvObjectInteractor interactor)
Changes the object interactor associated with this object. |
void |
setPopupMenu(JPopupMenu popup)
Sets the Swing pop-up menu of this object. |
void |
setPopupMenuName(String popupName)
Sets the Swing pop-up menu of this object by name. |
void |
setProperty(String key,
Object value)
Sets the value of a property. |
void |
setSelectable(boolean selectable)
Allows or disallows selection for this graphic object with the selection interactor. |
void |
setStrokeOn(boolean value)
Changes the stroke status of the object. |
void |
setToolTipText(String text)
Sets the text to display in the tool tip of this object. |
void |
setVisible(boolean v)
Sets the visibility for this graphic object. |
String |
toString()
Returns a string representation of this graphic object. |
void |
translate(float dx,
float dy)
Translates the object. |
void |
write(IlvOutputStream stream)
Writes this object to an IlvOutputStream. |
boolean |
zoomable()
Returns true if the object is zoomable; otherwise it
returns false. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public IlvGraphic()
IlvGraphic with the default setting.
By default a new graphic object is
IlvGraphic,
setVisible(boolean),
setEditable(boolean),
setSelectable(boolean),
setMovable(boolean)public IlvGraphic(IlvGraphic source)
IlvGraphic by copying an existing one.
Persistent properties stored in the object are copied by calling
IlvNamedProperty.copy. If this copy method returns
null the named property is not copied.
source - The graphic object to be copied.IlvGraphic,
IlvNamedProperty.copy()
public IlvGraphic(IlvInputStream stream)
throws IlvReadFileException
IlvInputStream.
Note that any subclass of IlvGraphic, as in any
implementation of the interface IlvPersistentObject,
must have a constructor with the signature
MyGraphicObject(IlvInputStream stream)
so that it can be read by IlvInputStream.
When implementing this method, the superclass constructor must be called first. The following example shows how this is done:
public MyGraphicObject(IlvInputStream stream)
throws IlvReadFileException
{
super(stream);
valueField = stream.readInt("valueFieldName");
}
stream - The input stream to be read from.
IlvReadFileException - if the format of stream is
not correct.IlvGraphic,
IlvPersistentObject,
write(IlvOutputStream)| Method Detail |
|---|
public abstract IlvGraphic copy()
IlvGraphic instance.
This abstract method must be implemented when you create a custom
graphic object. The implementation can for instance simply call the
copy constructore, which is defined like this:
public <CLASSNAME>(<CLASSNAME> source).
IlvGraphic instance.IlvGraphicpublic boolean zoomable()
true if the object is zoomable; otherwise it
returns false.
The default implementation returns true.
The purpose of this method is to indicate to the class
IlvManager whether the graphic object can be stored in an
optimized way (using a quadtree data structure).
Zoomable objects can be managed more efficiently than non-zoomable
objects.
A graphic object is said to be zoomable if and only if the transformed
bounding rectangle returned by boundingBox(t)
for any value of transformer t, is contained in the rectangle
obtained by applying t to the non-transformed
bounding rectangle, as returned by calling boundingBox(id)
with the identity transformer id. As mathematical
formula:
for all t holds: obj.boundingBox(t) ≤ t.apply(obj.boundingBox(id))
Note: If this object is contained inside an
IlvManager, users must use the method
IlvManager.applyToObject(ilog.views.IlvGraphic, ilog.views.IlvApplyObject, java.lang.Object, boolean) for any operation that might change
the return value of the method zoomable().
IlvGraphic,
draw(java.awt.Graphics, ilog.views.IlvTransformer),
boundingBox(IlvTransformer),
IlvManager
public abstract void draw(Graphics dst,
IlvTransformer t)
This method must be implemented to draw the oject in transformed
way into the Java Graphics.
Implementations of this method must not draw outside the bounding
box for this graphic object. The bounding box is returned by calling
boundingBox(t) where t is the parameter passed
to this method.
dst - The destination Graphics.t - The transformation used to draw the object.boundingBox(ilog.views.IlvTransformer),
zoomable(),
IlvGraphicpublic abstract IlvRect boundingBox(IlvTransformer t)
You must implement this method to return the bounding rectangle of the object that is used when the object is drawn with the specified transformer.
The bounding box for a graphic object is a rectangle that completely encloses the drawing area of the object. The implementation of this method usually does not guarantee that the returned rectangle is the smallest bounding box that encloses the drawing area, only that the drawing area lies entirely within the returned rectangle.
Since the caller of this method may modify the returned rectangle, your implementation should avoid to return internally stored rectangles, that is, you should return a newly allocated rectangle. The following example shows how to do this:
public IlvRect boundingBox(IlvTransformer t) {
// drawrect is an internaly stored rectangle
IlvRect rect = new IlvRect(drawrect);
if (!(t == null || t.isIdentity()))
t.apply(rect);
return rect;
}
t - The transformer used to draw the object. If the
transformer is null, the bounding box for the
identity transformer is returned.draw(java.awt.Graphics, ilog.views.IlvTransformer),
zoomable(),
IlvGraphicpublic final IlvRect boundingBox()
boundingBox(null).
The bounding box for a graphic object is the smallest rectangle
containing the entire drawing area of the object.
boundingBox(IlvTransformer),
IlvGraphicpublic IlvPoint getCenter(IlvTransformer t)
t - The transformer used to draw the object. If the
transformer is null, the center for the
identity transformer is returned.
IlvGraphicpublic abstract void applyTransform(IlvTransformer t)
Note that the method must never be called with a null
argument.
t - The transformation to be applied.IlvGraphic
public boolean contains(IlvPoint p,
IlvPoint tp,
IlvTransformer t)
boundingBox(ilog.views.IlvTransformer) for
the transformer t.
Note: override this method if this implementation is not correct for your customized graphic object.
p - The point to be tested.tp - The point p transformed by the transformer
t.t - The transformation used to draw the object.
true if the point lies inside this graphic object.IlvGraphic
public boolean intersects(IlvRect rect,
IlvRect trect,
IlvTransformer t)
boundingBox(ilog.views.IlvTransformer) for
the transformer t.
Note: override this method if this implementation is not correct for your customized graphic object.
rect - The rectangle to be tested.trect - The rectangle rect transformed by the
transformer t.t - The transformation used to draw the object.
true if the rectangle overlaps this graphic object.IlvGraphic
public boolean inside(IlvRect rect,
IlvRect trect,
IlvTransformer t)
boundingBox(ilog.views.IlvTransformer) for the transformer
t.
Note: override this method if this implementation is not correct for your customized graphic object.
rect - The rectangle to be tested.trect - The rectangle rect transformed by the
transformer t.t - The transformation used to draw the object.IlvGraphic
public IlvPoint getIntersectionWithOutline(IlvPoint innerPoint,
IlvPoint outerPoint,
IlvTransformer t)
innerPoint is not inside the graphic object,
or if outerPoint is not outside the graphic object, it
must return a valid point. For instance, if there is no intersection,
it can return the start point.
The default implementation calculates the intersection with the bounding box.
innerPoint - A point usually inside the graphic object, given in
manager view coordinates.outerPoint - A point usually outside of the graphic object, given in
manager view coordinates.t - The transformation used to draw the object.IlvGraphic,
IlvClippingLinkConnector
public void move(float x,
float y)
(x, y).
The position must be given in untransformed coordinates.
The default implementation calls translate(float, float) (and this calls
applyTransform(ilog.views.IlvTransformer)).
x - The new horizontal position.y - The new vertical position.IlvGraphic,
applyTransform(IlvTransformer)public void move(IlvPoint p)
p.
The position must be given in untransformed coordinates.
The default implementation calls move(float, float) (and this
calls applyTransform(ilog.views.IlvTransformer)).
p - The new position of the top-left corner.IlvGraphic,
applyTransform(IlvTransformer)public void moveResize(IlvRect size)
size.
The rectangle must be given in untransformed coordinates.
The default implementation calculates the difference transformation
between the current and the desired bounding box and then calls
applyTransform(ilog.views.IlvTransformer) to resize the graphic object.
size - The new bounding rectangle for this object.IlvGraphic,
applyTransform(IlvTransformer)
public void translate(float dx,
float dy)
dx, dy).
The vector must be given in untransformed coordinates.
The default implementation calls applyTransform(ilog.views.IlvTransformer) to translate
the graphic object.
dx - The horizontal translation factor.dy - The vertical translation factor.IlvGraphic,
applyTransform(IlvTransformer)
public void rotate(IlvPoint center,
double angle)
angle degrees around the point
center.
The center must be given in untransformed coordinates.
The default implementation calls applyTransform(ilog.views.IlvTransformer) to rotate
the graphic object.
center - The center of the rotation.angle - The rotation angle in degrees.IlvGraphic,
applyTransform(IlvTransformer)
public void scale(double scalex,
double scaley)
(scalex, scaley).
The default implementation calls applyTransform(ilog.views.IlvTransformer) to scale
the graphic object.
scalex - The horizontal scaling factor.scaley - The vertical scaling factor.IlvGraphic,
applyTransform(IlvTransformer)
public void resize(float neww,
float newh)
(neww, newh).
The default implementation calls scale(double, double) (and this
calls applyTransform(ilog.views.IlvTransformer)).
neww - The new horizontal width.newh - The new horizontal height.IlvGraphic,
applyTransform(IlvTransformer)public void setGraphicBag(IlvGraphicBag bag)
IlvGraphicBag such as an
IlvManager.
Note: do not call this method directly unless you are creating a custom graphics bag.
bag - The graphic bag to contain this graphic object.IlvGraphicpublic final IlvGraphicBag getGraphicBag()
null is returned.
setGraphicBag(ilog.views.IlvGraphicBag),
IlvGraphicpublic final IlvGraphicBag getTopLevelGraphicBag()
IlvManager graphic bag is itself a graphic object.
Graphic bags and graphic objects can be nested inside other graphic
objects or graphic bags. Nesting allows you to create applications that
control and display graphic objects inside other graphic objects.
If this object is contained in a graphic bag that itself is recursively
contained in a graphic bag, then it returns the topmost graphic bag that
is not contained in any graphic bag.
getGraphicBag(),
IlvGraphicBag.getGraphicBag(),
setGraphicBag(ilog.views.IlvGraphicBag),
IlvGraphicpublic void setForeground(Color c)
Note: not all graphic objects have a foreground color. A call to this method may not do anything.
c - The new foreground color.draw(Graphics, IlvTransformer),
setBackground(Color),
setFillOn(boolean),
setStrokeOn(boolean),
IlvGraphicpublic void setBackground(Color c)
Note: not all graphic objects have a background color. A call to this method may not need to do anything.
c - The new background color.draw(Graphics, IlvTransformer),
setForeground(Color),
setFillOn(boolean),
setStrokeOn(boolean),
IlvGraphicpublic void setFillOn(boolean value)
Note: not all graphic objects have a fill style. A call to this method may not need to do anything.
value - Set to true to enable the fill style for this
graphic object.draw(Graphics, IlvTransformer),
setBackground(Color),
setForeground(Color),
setStrokeOn(boolean),
IlvGraphicpublic void setStrokeOn(boolean value)
Note: not all graphic objects have a stroke style. A call to this method may not need to do anything.
value - Set to true to enable the stroke in your
customized graphic object.draw(Graphics, IlvTransformer),
setBackground(Color),
setForeground(Color),
setFillOn(boolean),
IlvGraphicpublic void reDraw()
IlvGraphicBag.reDrawObj(ilog.views.IlvGraphic)
from the graphic bag holding this graphic object.
draw(Graphics, IlvTransformer),
IlvGraphicpublic void setName(String name)
IlvGraphicBag.setObjectName(ilog.views.IlvGraphic, java.lang.String)
from the graphic bag holding this graphic object.
Note: no two objects contained in an manager can have
the same name. If the graphic bag already contains a graphic object called
name, this graphic object will not be re-named.
name - The new name for this graphic object.IlvManager.setObjectName(ilog.views.IlvGraphic, java.lang.String)public void setNameImpl(String name)
public String getName()
public boolean removeProperty(String key)
key - The key of the property to be removed.
The key null is not allowed.
true if the property was found and has been removed.getProperty(String),
setProperty(String, Object),
replaceProperty(String, Object),
IlvGraphic
public void setProperty(String key,
Object value)
key to
value if value is not null.
If property key does not exist, this property is added to
the properties list. If property key is already exists,
its value is replaced by value.
If value is null and property key
is already in the properties list, this property is removed.
key - The key of the property to be added.
The key null is not allowed.value - The new value for the property.getProperty(String),
removeProperty(String),
replaceProperty(String, Object),
IlvGraphic
public boolean replaceProperty(String key,
Object value)
key - The key of the property to be replaced.
The key null is not allowed.value - The new value of the property.
The value must not be null.
true if property key was found and it's
value has been replaced with value.getProperty(String),
setProperty(String, Object),
removeProperty(String),
replaceProperty(String, Object),
IlvGraphicpublic Object getProperty(String key)
key - The key of the property.
The key null is not allowed.
key or null if
property key does not exist.setProperty(String, Object),
removeProperty(String),
replaceProperty(String, Object),
IlvGraphic
public boolean hasProperty(String key,
Object value)
key - The key of the property.
The key null is not allowed.value - The value to be tested.
true if the value of the property key
is value.IlvGraphic,
setProperty(String, Object),
removeProperty(String),
replaceProperty(String, Object)public boolean isVisible()
true if this graphic object is visible.setVisible(boolean),
setSelectable(boolean),
setMovable(boolean),
setEditable(boolean)public final void setVisible(boolean v)
Note: This method is useful if the object is
outside a manager. Call
IlvManager.setVisible(IlvGraphic, boolean, boolean) instead
when this object is stored inside a manager.
v - Set to true for this object to be visible.
If an object is editable, edits are controlled using
IlvSelectInteractor.isVisible(),
IlvManager.setVisible(IlvGraphic, boolean, boolean)public boolean isMovable()
true if this graphic object is movable.setVisible(boolean),
setSelectable(boolean),
setMovable(boolean),
setEditable(boolean),
IlvSelectInteractor,
IlvGraphicpublic final void setMovable(boolean movable)
movable - Set to true to allow this graphic object
to be moved inside a view with the selection interactor.IlvGraphic,
isMovable(),
IlvSelectInteractorpublic final boolean isEditable()
true if this graphic object is editable.setVisible(boolean),
setSelectable(boolean),
setMovable(boolean),
setEditable(boolean),
IlvSelectInteractor,
IlvGraphicpublic final void setEditable(boolean editable)
editable - Set to true to enable editing for this
graphic object inside a view with the selection interactor.isEditable(),
IlvSelectInteractorpublic boolean isSelectable()
Note: if this object is stored inside a manager,
use IlvManager.isSelectable(IlvGraphic) instead
of this method, because that checks also the capacity of the
manager layer being selected.
true if this graphic object can be selected.IlvManager.isSelectable(IlvGraphic),
IlvManagerLayer.isSelectable(),
setVisible(boolean),
setSelectable(boolean),
setMovable(boolean),
setEditable(boolean),
IlvSelectInteractor,
IlvGraphicpublic final void setSelectable(boolean selectable)
selectable - Set to true to enable selection for this
graphic object.isSelectable(),
IlvSelectInteractorpublic final void addActionListener(ActionListener listener)
The following code example shows how to add an action listener to a graphic object.
myGraphic.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
...
}
});
listener - The action listener.removeActionListener(java.awt.event.ActionListener),
processActionEvent(java.awt.event.ActionEvent),
IlvGraphicpublic final void removeActionListener(ActionListener listener)
listener is removed, it no longer
receives action events from this graphic object.
listener - The action listener.addActionListener(java.awt.event.ActionListener),
processActionEvent(java.awt.event.ActionEvent),
IlvGraphicpublic void processActionEvent(ActionEvent event)
ActionListener objects registered with this
graphic object.
You should normally not call this method directly.
addActionListener(java.awt.event.ActionListener),
removeActionListener(java.awt.event.ActionListener),
IlvGraphicpublic IlvSelection makeSelection()
IlvDrawSelection.
Override this method in your custom graphic object to use a different selection object.
You should normally not call this method directly.
IlvDrawSelectionpublic String getDefaultInteractor()
null.
Override this method to return the class name of the default interactor.
IlvGraphicpublic final IlvObjectInteractor getObjectInteractor()
setObjectInteractor(ilog.views.IlvObjectInteractor),
IlvGraphicpublic final void setObjectInteractor(IlvObjectInteractor interactor)
interactor - The new object interactor. Set this value to
null to remove the existing interactor from this object.getObjectInteractor(),
IlvGraphicprotected void notifyObjectInteractorToManager(IlvObjectInteractor interactor)
public final IlvObjectInteractor getAndAssociateObjectInteractor()
getObjectInteractor(),
setObjectInteractor(ilog.views.IlvObjectInteractor),
getDefaultInteractor(),
IlvGraphic
public void write(IlvOutputStream stream)
throws IOException
IlvOutputStream.
You should not
call this method directly; instead, you should use the
write methods of the manager.
When overriding this method to save additional information stored in your custom graphic, this superclass write method must to be called first. The following example shows how to do this:
public void write(IlvOutputStream stream) throws IOException
{
super.write(stream);
stream.write("myFieldName", myField);
}
write in interface IlvPersistentObjectstream - The output stream to write this graphic object to.
IOException - thrown when an exception occurs during
the write operation for this object.public boolean isPersistent()
true, the IlvGraphic
instance will be saved in IVL files.
The default implementation returns true.
Override this method to return false in those situations
when this graphic object cannot be be saved to a .IVL file.
public DataFlavor[] getTransferDataFlavors()
DataFlavor objects indicating
in which flavors the data can be provided.
By default, the only flavor supported by IlvGraphic is
DataFlavor.stringFlavor.
getTransferDataFlavors in interface Transferablepublic boolean isDataFlavorSupported(DataFlavor flavor)
IlvGraphic
is DataFlavor.stringFlavor.
isDataFlavorSupported in interface Transferableflavor - The data flavor to be tested.
true if the data flavor is supported.
public Object getTransferData(DataFlavor flavor)
throws UnsupportedFlavorException,
IOException
IlvGraphic
implementation is DataFlavor.stringFlavor. Override this
method to handle other DataFlavors.
Note: This method is called when you pass the
IlvGraphic instance as a Transferable object.
Normally you do not need to call this method directly.
getTransferData in interface Transferableflavor - The requested data flavor.
IOException - if the data is not writable.