|
||||||||||
| PREV CLASS Documentation homepage NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectilog.views.IlvGraphic
ilog.views.graphic.IlvGraphicSet
public class IlvGraphicSet
An IlvGraphicSet instance is used to group several graphic
objects together.
For an IlvGraphicSet object contained inside an
IlvGraphicBag instance (for instance inside IlvManager,
the following methods must be called from the
applyToObject method of the
IlvGraphicBag instance holding this IlvGraphicSet
object.
The following code example shows how to use IlvGraphicSet in a
simple Java application:
IlvManager manager = new IlvManager();
IlvGraphicSet graphicSet = new IlvGraphicSet();
// Set an object interactor that makes the graphic objects sensitive to events.
graphicSet.setObjectInteractor(new IlvGraphicSet.DelegateObjectInteractor());
// Create the graphic objects and add them to the graphic set.
IlvReliefRectangle border = new IlvReliefRectangle(new IlvRect(10,10,60,90));
border.setBackground(new Color(228,225,224));
graphicSet.addObject(border, false);
IlvText label1 = new IlvText(new IlvPoint(27,40), "ILOG");
Font font = new Font(label1.getFont().getName(), Font.BOLD,
label1.getFont().getSize());
label1.setFont(font);
graphicSet.addObject(label1, false);
IlvText label2 = new IlvText(new IlvPoint(20,60), "JViews");
label2.setFont(font);
graphicSet.addObject(label2, false);
// Add the graphic set containing all the graphic objects to the manager.
manager.addObject(graphicSet, true);
The following image shows the graphic objects created in the code example:
>
The following code example shows how to remove an object from the graphic set, even when the graphic set is already inside a manager:
graphicSet.removeObject(label2, false);
IlvGraphicSet 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.
IlvManager,
IlvManagerView,
IlvRect,
Serialized Form| Nested Class Summary | |
|---|---|
static class |
IlvGraphicSet.DelegateObjectInteractor
A delegating interactor for IlvGraphicSet objects. |
| Field Summary | |
|---|---|
protected IlvGraphicVector |
list
The internal IlvGraphicVector storing the IlvGraphic
instances for this IlvGraphicSet. |
| Constructor Summary | |
|---|---|
IlvGraphicSet()
Creates a new empty graphic set. |
|
IlvGraphicSet(IlvGraphicSet source)
Creates a new IlvGraphicSet by copying an existing one. |
|
IlvGraphicSet(IlvInputStream stream)
Reads the object from an IlvInputStream. |
|
| Method Summary | |
|---|---|
void |
addGraphicBagHierarchyListener(GraphicBagHierarchyListener listener)
Adds the specified listener to receive events from the ancestor managers and ancestor graphic sets and from this graphic set when the hierarchy of graphic bags has changed. |
void |
addManagerViewsHierarchyListener(ManagerViewsChangedListener listener)
Adds the specified listener to receive events from the owning manager of this object and from its ancestors when a manager view was added or removed. |
void |
addObject(IlvGraphic obj,
boolean redraw)
Adds a graphic object at the end of the set. |
void |
addObjectAt(IlvGraphic obj,
int index,
boolean redraw)
Adds a graphic object at the specified index in the set. |
void |
applyToObject(IlvGraphic obj,
IlvApplyObject f,
Object arg,
boolean redraw)
Applies a method to an object of the bag. |
void |
applyTransform(IlvTransformer t)
Applies a transformation to the shape of contained objects. |
IlvRect |
boundingBox(IlvTransformer t)
Returns the bounding rectangle of the object. |
boolean |
contains(IlvGraphic obj)
Returns true if the object is in the graphic set. |
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. |
protected void |
drawCore(Graphics2D dst,
IlvTransformer t)
Draws the object. |
void |
enableGraphicBagHierarchyEventForwarding()
Enables forwarding of GraphicBagHierarchyEvent events, since
the objects contained in this graphic set need to receive the events. |
void |
enableManagerViewsHierarchyEventForwarding()
Enables forwarding of ManagerViewsChangedEvent events through the nesting hierarchy,
since the objects contained in this graphic set need to receive the events. |
void |
fireGraphicBagHierarchyEvent(GraphicBagHierarchyEvent event)
Fires a graphic bag hierarchy event to this graphic set and all contained objects. |
void |
fireManagerViewsHierarchyEvent(ManagerViewsChangedEvent event)
Fires a ManagerViewsChangedEvent event to all listeners
installed via addManagerViewsHierarchyListener(ilog.views.event.ManagerViewsChangedListener) on this graphic
set or contained objects. |
IlvGraphic |
firstContains(IlvPoint p,
IlvPoint tp,
IlvTransformer t)
Searches for the first graphic object in the set that contains the specified point. |
float |
getAlpha()
Returns the alpha value of this graphic object. |
int |
getCardinal()
Returns the number of objects. |
Shape |
getClip()
Returns the shape that will clip the object. |
int |
getIndex(IlvGraphic obj)
Searches for the specified graphic object in the set and returns an index to it. |
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. |
IlvGraphic |
getObject(int index)
Returns the graphic object at the specified index. |
IlvGraphic |
getObject(String name)
Returns the object with the specified name. |
String |
getObjectName(IlvGraphic obj)
Returns the name of the object. |
IlvGraphicEnumeration |
getObjects()
Returns an enumeration of all the objects in the graphic set. |
protected JPopupMenu |
getOriginalPopupMenu(IlvPoint p,
IlvTransformer t,
IlvManagerView view,
IlvPopupMenuManager popupManager)
This is the original implementation of getPopupMenu
from the super class to retrieve the popup menu. |
JPopupMenu |
getPopupMenu(IlvPoint p,
IlvTransformer t,
IlvManagerView view,
IlvPopupMenuManager popupManager)
Returns the Swing popup menu to display when the popup is triggered while the mouse pointer is at a specified location inside the graphic object. |
String |
getToolTipText(IlvPoint p,
IlvTransformer t)
Returns the tooltip text to display when the mouse pointer is at a specified location inside the graphic object. |
boolean |
isPersistent()
If this method returns true the IlvGraphic
instance will be saved in IVL files. |
void |
moveObject(IlvGraphic obj,
float x,
float y,
boolean redraw)
Changes the location of a graphic object. |
boolean |
needsGraphicBagHierarchyEvent()
Returns whether this object needs to receive GraphicBagHierarchyEvent events, either from itself or from its
ancestors. |
boolean |
needsManagerViewsHierarchyEvent()
Returns whether the graphic set needs to receive ManagerViewsChangedEvent events, either from its owning manager
or from its ancestors. |
void |
reDrawObj(IlvGraphic obj)
Redraws a graphic object contained in the set. |
void |
reDrawRegion(IlvRegion region)
Redraws a region of the set. |
void |
removeAll(boolean redraw)
Removes all the graphic objects from this bag. |
void |
removeGraphicBagHierarchyListener(GraphicBagHierarchyListener listener)
Removes the specified listener so that it no longer receives events from ancestor manager and ancestor graphic sets and from this graphic set when the hierarchy of graphic bags has changed. |
void |
removeManagerViewsHierarchyListener(ManagerViewsChangedListener listener)
Removes the specified listener so that it no longer receives events from the owning manager of this object and from its ancestors when a manager view was added or removed. |
void |
removeObject(IlvGraphic obj,
boolean redraw)
Removes a graphic object from this bag. |
void |
removeObjectAt(int index,
boolean redraw)
Removes the graphic object located at the specified index from this bag. |
void |
reshapeObject(IlvGraphic obj,
IlvRect newrect,
boolean redraw)
Changes the size of a graphic object located in the set. |
void |
setAlpha(float alpha)
Changes the alpha value of this graphic object. |
void |
setClip(Shape clip)
Changes the shape that will clip the object. |
void |
setGraphicBag(IlvGraphicBag bag)
Changes the bag that contains the object. |
boolean |
setObjectName(IlvGraphic obj,
String name)
Changes the name of a graphic object. |
void |
write(IlvOutputStream stream)
Writes the object to an IlvOutputStream. |
boolean |
zoomable()
Tests if the graphic set is zoomable. |
| 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 |
| Field Detail |
|---|
protected IlvGraphicVector list
IlvGraphicVector storing the IlvGraphic
instances for this IlvGraphicSet.
Warning:: This field is protected for implementation reasons and
should not be modified by third-party.
| Constructor Detail |
|---|
public IlvGraphicSet()
public IlvGraphicSet(IlvGraphicSet source)
IlvGraphicSet by copying an existing one.
Note that objects in the graphic set are copied too.
source - The origin object for the copy.
public IlvGraphicSet(IlvInputStream stream)
throws IlvReadFileException
IlvInputStream.
stream - The input stream.
IlvReadFileException - if the format is not correct.| Method Detail |
|---|
public void setGraphicBag(IlvGraphicBag bag)
Note: do not call this method directly unless you are creating a custom graphics bag.
setGraphicBag in class IlvGraphicbag - The graphic bag to contain this graphic object.IlvGraphic
public void addObject(IlvGraphic obj,
boolean redraw)
IlvGraphicSet at the same time.
addObject in interface IlvGraphicBagobj - The graphic object.redraw - If true, the object is redrawn.
public void addObjectAt(IlvGraphic obj,
int index,
boolean redraw)
IlvGraphicSet at the same time.
obj - The graphic object.index - The desired index or -1 to add the object
to the end.redraw - If true, the object is redrawn.
ArrayIndexOutOfBoundsException - if the index was not valid.
public void removeObject(IlvGraphic obj,
boolean redraw)
removeObject in interface IlvGraphicBagobj - The graphic object.redraw - If true the object is redrawn.
public void removeObjectAt(int index,
boolean redraw)
index - The desired index.redraw - If true, the object is redrawn.
ArrayIndexOutOfBoundsException - if
the index supplied was not valid.public void removeAll(boolean redraw)
redraw - If true, the object is redrawn.public final IlvGraphic getObject(int index)
index - The desired index.
ArrayIndexOutOfBoundsException - if
the index supplied was not valid.public final int getIndex(IlvGraphic obj)
obj - The desired graphic object.
-1 if it is not
found.public final boolean contains(IlvGraphic obj)
true if the object is in the graphic set.
public final IlvGraphicEnumeration getObjects()
getObjects in interface IlvGraphicBagpublic final int getCardinal()
public void reDrawObj(IlvGraphic obj)
reDrawObj in interface IlvGraphicBagobj - The graphic object.public void reDrawRegion(IlvRegion region)
reDrawRegion in interface IlvGraphicBagregion - The region to redraw in the
IlvGraphicSet coordinate system.
public void reshapeObject(IlvGraphic obj,
IlvRect newrect,
boolean redraw)
reshapeObject in interface IlvGraphicBagobj - The graphic object.newrect - The new desired bounding rectangle.redraw - If true, the object is redrawn.
public void moveObject(IlvGraphic obj,
float x,
float y,
boolean redraw)
moveObject in interface IlvGraphicBagobj - The graphic object.x - The new desired x.y - The new desired y.redraw - If true, the object is redrawn.
public void applyToObject(IlvGraphic obj,
IlvApplyObject f,
Object arg,
boolean redraw)
obj
must be encapsulated into applyToObject.
applyToObject in interface IlvGraphicBagobj - The graphic object.f - The method to apply.arg - The arguments passed to f.redraw - If true, the object is redrawn.public IlvGraphic copy()
copy in class IlvGraphicIlvGraphicpublic IlvGraphic getObject(String name)
getObject in interface IlvGraphicBagname - The name.getObjectName(ilog.views.IlvGraphic),
setObjectName(ilog.views.IlvGraphic, java.lang.String)public String getObjectName(IlvGraphic obj)
obj - The graphic object.setObjectName(ilog.views.IlvGraphic, java.lang.String),
getObject(int)
public boolean setObjectName(IlvGraphic obj,
String name)
setObjectName in interface IlvGraphicBagobj - The graphic object.name - The new name.
true if the name can be changed.public void setClip(Shape clip)
null if no clip is applied.
clip - The new clip.public Shape getClip()
null if no clip is applied. The shape is modified when a
transformation is applied to the object.
public void setAlpha(float alpha)
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.
alpha - The new transparency level in the range [0.0, 1.0].getAlpha(),
IlvManagerLayer.setAlpha(float)public float getAlpha()
setAlpha(float),
IlvManagerLayer.getAlpha()
public void draw(Graphics dst,
IlvTransformer t)
draw methods of
contained objects. Objects not in the clip area are
not drawn.
draw in class IlvGraphicdst - The destination Graphics.t - The transformation used to draw the object.IlvGraphic.boundingBox(ilog.views.IlvTransformer),
IlvGraphic.zoomable(),
IlvGraphic
protected void drawCore(Graphics2D dst,
IlvTransformer t)
draw(java.awt.Graphics, ilog.views.IlvTransformer) after processing the
alpha transparency. It can be overridden in subclasses.
dst - The destination Graphics.t - The transformation used to draw the object.setAlpha(float)public void applyTransform(IlvTransformer t)
Note that a call to this method can modify the bounding box of
the graphic set.
For this reason, if the graphic set is contained inside an
IlvManager, this method can be called only using the method
IlvManager.applyToObject(ilog.views.IlvGraphic, ilog.views.IlvApplyObject, java.lang.Object, boolean) of the manager.
applyTransform in class IlvGraphict - The transformer to be applied.IlvGraphicpublic IlvRect boundingBox(IlvTransformer t)
IlvGraphic.setVisible(boolean)).
boundingBox in class IlvGraphict - The transformer used to draw the object.IlvGraphic.draw(java.awt.Graphics, ilog.views.IlvTransformer),
IlvGraphic.zoomable(),
IlvGraphicpublic boolean zoomable()
zoomable in class IlvGraphicIlvGraphic,
IlvGraphic.draw(java.awt.Graphics, ilog.views.IlvTransformer),
IlvGraphic.boundingBox(IlvTransformer),
IlvManager
public boolean contains(IlvPoint p,
IlvPoint tp,
IlvTransformer t)
firstContains to find the first object
that contains the point.
contains in class IlvGraphicp - 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.
true if the point lies inside this graphic object.firstContains(ilog.views.IlvPoint, ilog.views.IlvPoint, ilog.views.IlvTransformer)
public IlvGraphic firstContains(IlvPoint p,
IlvPoint tp,
IlvTransformer t)
p - The point.tp - The transformed point.t - The transformer used to draw the set.
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.
This implementation works well if no clip is set on this object, by choosing the best intersection with a subobject contained in the graphic set. If a clip is set on the object, it checks whether this intersection is inside the clip area. If it is outside the clip area, it returns the intersection with the clip area. This works well only if subobjects are not entirely outside the clip area.
getIntersectionWithOutline in class IlvGraphicinnerPoint - 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.IlvClippingLinkConnector
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.
write in interface IlvPersistentObjectwrite in class IlvGraphicstream - The output stream.
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 method returns true if all subobjects are persistent.
isPersistent in class IlvGraphic
public String getToolTipText(IlvPoint p,
IlvTransformer t)
Note that you must enable the tooltip mechanism for the manager view
by calling the static method
IlvToolTipManager.registerView(ilog.views.IlvManagerView).
getToolTipText in class IlvGraphicp - The location of the mouse (in view coordinates).t - The transformer that converts the coordinate system of this object
(the manager coordinates) into the coordinate system of the
manager view in which the tooltip is about to be displayed
(the view coordinates).
p for transformation
t, or null if no tool tip should be displayed.IlvGraphic,
IlvGraphic.getToolTipText(),
IlvGraphic.setToolTipText(String)
public JPopupMenu getPopupMenu(IlvPoint p,
IlvTransformer t,
IlvManagerView view,
IlvPopupMenuManager popupManager)
Note that you must enable the popup menu mechanism for the manager view
by calling the static method
IlvPopupMenuManager.registerView(ilog.views.IlvManagerView).
getPopupMenu in class IlvGraphicp - The location of the mouse (in view coordinates).t - The transformer that converts the coordinate system of this object
(the manager coordinates) into the coordinate system of the
manager view in which the tooltip is about to be displayed
(the view coordinates).view - The manager view that triggered the popup menu.popupManager - The popup menu manager.
null.IlvGraphic,
IlvPopupMenuManager.registerView(ilog.views.IlvManagerView),
IlvGraphic.getPopupMenu()
protected JPopupMenu getOriginalPopupMenu(IlvPoint p,
IlvTransformer t,
IlvManagerView view,
IlvPopupMenuManager popupManager)
getPopupMenu
from the super class to retrieve the popup menu.
Subclasses of this class might need access to the original implementation.
p - The location of the mouse (in view coordinates).t - The transformer that converts the coordinate system of this object
(the manager coordinates) into the coordinate system of the
manager view in which the tooltip is about to be displayed
(the view coordinates).view - The manager view that triggered the popup menu.popupManager - The popup menu manager.
public void addGraphicBagHierarchyListener(GraphicBagHierarchyListener listener)
addGraphicBagHierarchyListener in interface GraphicBagHierarchyEventReceiverlistener - The listener.removeGraphicBagHierarchyListener(ilog.views.event.GraphicBagHierarchyListener)public void removeGraphicBagHierarchyListener(GraphicBagHierarchyListener listener)
removeGraphicBagHierarchyListener in interface GraphicBagHierarchyEventReceiverlistener - The listener.addGraphicBagHierarchyListener(ilog.views.event.GraphicBagHierarchyListener)public void enableGraphicBagHierarchyEventForwarding()
GraphicBagHierarchyEvent events, since
the objects contained in this graphic set need to receive the events.
enableGraphicBagHierarchyEventForwarding in interface GraphicBagHierarchyEventReceiverpublic boolean needsGraphicBagHierarchyEvent()
GraphicBagHierarchyEvent events, either from itself or from its
ancestors.
needsGraphicBagHierarchyEvent in interface GraphicBagHierarchyEventReceiverpublic void fireGraphicBagHierarchyEvent(GraphicBagHierarchyEvent event)
fireGraphicBagHierarchyEvent in interface GraphicBagHierarchyEventReceiverpublic void addManagerViewsHierarchyListener(ManagerViewsChangedListener listener)
The hierarchy event mechanism is comparable to
java.awt.event.HierarchyEvent on swing components.
The view changed event is generated by a manager when a view is added
or removed, and passed down the nesting hierarchy.
The event is dispatched to every graphic set that is contained in the
manager whose view has changed.
addManagerViewsHierarchyListener in interface ManagerViewsHierarchyEventReceiverlistener - The listener.removeManagerViewsHierarchyListener(ilog.views.event.ManagerViewsChangedListener)public void removeManagerViewsHierarchyListener(ManagerViewsChangedListener listener)
removeManagerViewsHierarchyListener in interface ManagerViewsHierarchyEventReceiverlistener - The listener.addManagerViewsHierarchyListener(ilog.views.event.ManagerViewsChangedListener)public void enableManagerViewsHierarchyEventForwarding()
ManagerViewsChangedEvent events through the nesting hierarchy,
since the objects contained in this graphic set need to receive the events.
enableManagerViewsHierarchyEventForwarding in interface ManagerViewsHierarchyEventReceiverpublic boolean needsManagerViewsHierarchyEvent()
ManagerViewsChangedEvent events, either from its owning manager
or from its ancestors. It returns true, if a listener was installed through
addManagerViewsHierarchyListener(ilog.views.event.ManagerViewsChangedListener) on this graphic set or on any
object contained in this graphic set.
needsManagerViewsHierarchyEvent in interface ManagerViewsHierarchyEventReceiverpublic void fireManagerViewsHierarchyEvent(ManagerViewsChangedEvent event)
ManagerViewsChangedEvent event to all listeners
installed via addManagerViewsHierarchyListener(ilog.views.event.ManagerViewsChangedListener) on this graphic
set or contained objects.
fireManagerViewsHierarchyEvent in interface ManagerViewsHierarchyEventReceiver
|
||||||||||
| PREV CLASS Documentation homepage NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||