public abstract class IlvGraphic extends Object implements Serializable, Transferable, IlvPersistentObject, IlvBlinkingObject, IlvBaseTextDirectionInterface
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 tooltips and pop-up menus. The following
code example shows how to set the tooltip for an instance of the
SimpleRectangle
class shown earlier:
First, you need to register the manager view that displays the tooltip:
IlvToolTipManager.registerView(mgrview);Then, you assign your tooltip 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 tooltips, 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
Rogue Wave 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 tooltip and
pop-up menu visible.
Note: We recommend that you take advantage of the
extra functionality found in IlvSimplePopupMenu
to create
your pop-up menus.
Constructor and Description |
---|
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 . |
Modifier and Type | Method and Description |
---|---|
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.
|
protected void |
allViewsRemoved()
Called if this object needs view notification and all views displaying
this object were removed.
|
abstract void |
applyTransform(IlvTransformer t)
Applies a transformation to the shape of the object.
|
void |
baseTextDirectionChanged(int oldBaseTextDirection,
int newBaseTextDirection)
Called when the object is base text direction sensitive and the
resolved base text direction has changed.
|
void |
blinkingStateOn(boolean state)
Sets the current state of the blinking.
|
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.
|
void |
callDraw(Graphics dst,
IlvTransformer t)
Draws the object.
|
void |
componentOrientationChanged(ComponentOrientation oldOri,
ComponentOrientation newOri)
Called when the object is component orientation sensitive and the
component orientation has changed.
|
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.
|
int |
getBaseTextDirection()
Returns the base direction of the text.
|
IlvBlinkingAction |
getBlinkingAction()
Returns the blinking action of the graphic object.
|
IlvBlinkingObjectOwner |
getBlinkingObjectOwner()
Returns the blinking object owner.
|
long |
getBlinkingOffPeriod()
Returns the duration, in milliseconds, the object is hidden when blinking.
|
long |
getBlinkingOnPeriod()
Returns the duration, in milliseconds, the object is shown when blinking.
|
IlvPoint |
getCenter(IlvTransformer t)
Returns the center point of the graphic object.
|
ComponentOrientation |
getComponentOrientation()
Returns the component orientation of this 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.
|
Locale |
getLocale()
Returns the locale of this 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.
|
int |
getResolvedBaseTextDirection()
Returns the resolved base text direction.
|
int |
getToolTipBaseTextDirection()
Returns the base direction of the tooltip text.
|
String |
getToolTipText()
Returns the tooltip set for this 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.
|
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. |
ULocale |
getULocale()
Returns the locale of this object.
|
int |
getZOrderIndex()
Returns the index within the manager layer.
|
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.
|
protected void |
invalidateBBoxCache()
Invalidates the bounding box cache.
|
protected void |
invalidateBidiCache()
Invalidates the bidi cache (locale, component orientation and
resolved base text direction).
|
boolean |
isBaseTextDirectionSensitive()
Returns
true if the bounding box of this object depends on
the base text direction of this object. |
boolean |
isComponentOrientationSensitive()
Returns
true if the bounding box of this object depends
on the component orientation of this 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 |
isLocaleSensitive()
Returns
true if the bounding box of this object depends
on the locale of this object. |
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.
|
void |
localeChanged(ULocale oldLocale,
ULocale newLocale)
Called when the object is locale sensitive and the locale has changed.
|
IlvSelection |
makeSelection()
Creates a selection object for this object.
|
void |
move(double x,
double y)
Moves the object.
|
void |
move(IlvPoint p)
Moves the object.
|
void |
moveResize(IlvRect size)
Resizes the object.
|
protected boolean |
needsViewNotification()
Returns
true if this object needs to be notified whenever
a manager view is added to or removed from an ancestor manager so that
the view displays the graphic 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.
|
void |
reDraw()
Redraws this object.
|
protected void |
registerBlinkingResource(Object oldResource,
Object newResource)
Registers a blinking drawing resource.
|
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(double neww,
double 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 |
setBaseTextDirection(int baseTextDirection)
Changes the base direction of the text.
|
protected void |
setBaseTextDirectionDuringConstruction(int baseTextDirection)
Changes the base direction of the text.
|
void |
setBlinkingAction(IlvBlinkingAction action)
Sets the blinking action of the graphic object.
|
void |
setBlinkingOffPeriod(long offPeriod)
Sets the time the object is hidden when blinking.
|
void |
setBlinkingOnPeriod(long onPeriod)
Sets the time the object is shown when blinking.
|
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 |
setToolTipBaseTextDirection(int baseTextDirection)
Changes the base direction of the tooltip text.
|
void |
setToolTipText(String text)
Sets the text to display in the tooltip of this object.
|
void |
setVisible(boolean v)
Sets the visibility for this graphic object.
|
void |
setZOrderIndex(int index)
Sets the index within a manager layer.
|
String |
toString()
Returns a string representation of this graphic object.
|
void |
translate(double dx,
double dy)
Translates the object.
|
protected void |
updateNeedsViewNotification()
This method should be called when the need for view notification
has changed.
|
boolean |
usesBidiMarkers()
Returns
true if in-place editing implementation uses markers,
which should be taken into account in hit-to-point and point-to-hit
calculations. |
protected void |
viewAddedOrRemoved(IlvManagerView view,
boolean added)
Called when a view is added to an ancestor manager so that the view displays * this object, or when a view displaying this object is removed from an ancestor * manager.
|
void |
write(IlvOutputStream stream)
Writes this object to an
IlvOutputStream . |
boolean |
zoomable()
Returns
true if the object is zoomable; otherwise it
returns false . |
public IlvGraphic()
IlvGraphic
with the default setting.
By default a new graphic object is
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)
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 constructor, which is defined like this:
public <CLASSNAME>(<CLASSNAME> source)
.
IlvGraphic
instance.IlvGraphic
public boolean zoomable()
true
if the object is zoomable; otherwise it
returns false
.
The default implementation returns true
.
This method does not impact the way the object is drawn, but
must return a value which is consistent with the way the
draw(Graphics, IlvTransformer)
considers the zoom level of
the drawing transformer.
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()
.
public final void setZOrderIndex(int index)
IlvIndexedSet.setIndex(ilog.views.IlvGraphic, int)
to modify the drawing order, if the
manager layer has Z-order indexing enabled.IlvIndexedSet.setZOrdering(boolean)
public final int getZOrderIndex()
public abstract void draw(Graphics dst, IlvTransformer t)
Implement this method to draw the object in a transformed manner
into the Java Graphics
context. Implementations must not
draw outside the bounding box for this graphic object. Return the
bounding box by calling boundingBox(t)
, passing in the
t
parameter.
If this object is drawn in a view, obtain the current view by calling
IlvManagerView.getCurrentView(Graphics)
, passing the input
Graphics
. However the view transformation is not
necessarily the same as the transformation to be used for this object.
Use the input transformation t
to draw the object.
dst
- The destination Graphics
instance.t
- The transformation used to draw the object.callDraw(Graphics,IlvTransformer)
,
boundingBox(IlvTransformer)
,
zoomable()
,
IlvGraphic
public final void callDraw(Graphics dst, IlvTransformer t)
This method preprocesses the graphic object to support blinking,
then it simply calls draw(java.awt.Graphics, ilog.views.IlvTransformer)
.
This method is designed to be invoked, while draw(java.awt.Graphics, ilog.views.IlvTransformer)
is designed
to be overridden.
dst
- The destination Graphics
.t
- The transformation used to draw the object.boundingBox(IlvTransformer)
,
zoomable()
,
IlvGraphic
public 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()
,
IlvGraphic
public 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)
,
IlvGraphic
public 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.IlvGraphic
public 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(double x, double y)
(x, y)
.
The position must be given in untransformed coordinates.
The default implementation calls translate(double, double)
(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(double, double)
(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(double dx, double 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(double neww, double 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.IlvGraphic
public final IlvGraphicBag getGraphicBag()
null
is returned.public 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)
,
IlvGraphic
public 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)
,
IlvGraphic
public 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)
,
IlvGraphic
public 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)
,
IlvGraphic
public 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)
,
IlvGraphic
public void reDraw()
IlvGraphicBag.reDrawObj(ilog.views.IlvGraphic)
from the graphic bag holding this graphic object.reDraw
in interface IlvBlinkingObject
draw(Graphics, IlvTransformer)
,
IlvGraphic
public 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)
,
IlvGraphic
public 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
,
IlvGraphic
public 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()
,
IlvSelectInteractor
public final boolean isEditable()
true
if this graphic object is editable.setVisible(boolean)
,
setSelectable(boolean)
,
setMovable(boolean)
,
setEditable(boolean)
,
IlvSelectInteractor
,
IlvGraphic
public final void setEditable(boolean editable)
editable
- Set to true
to enable editing for this
graphic object inside a view with the selection interactor.isEditable()
,
IlvSelectInteractor
public 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
,
IlvGraphic
public final void setSelectable(boolean selectable)
selectable
- Set to true
to enable selection for this
graphic object.isSelectable()
,
IlvSelectInteractor
public 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)
,
IlvGraphic
public 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)
,
IlvGraphic
public void processActionEvent(ActionEvent event)
This method is invoked by the IlvButtonInteractor
object
interactor.
The default implementation of this method dispatches the event to all
ActionListener
s registered with this graphic object.
It should be extended in subclasses, so as to give a visible feedback
upon receival of an ActionEvent
of type
IlvButtonInteractor.ARM
or IlvButtonInteractor.DISARM
.
public 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.IlvDrawSelection
public String getDefaultInteractor()
null
.
Override this method to return the class name of the default interactor.
The default interactor is used as object interactor (see
getObjectInteractor()
) if no other object interactor was set
on the object and getAndAssociateObjectInteractor()
is called.
Usually this happens only for IlvSelection
and its subclasses,
but not for regular graphic objects.
IlvGraphic
,
IlvSelection.getDefaultInteractor()
public final IlvObjectInteractor getObjectInteractor()
setObjectInteractor(ilog.views.IlvObjectInteractor)
,
IlvGraphic
public final void setObjectInteractor(IlvObjectInteractor interactor)
interactor
- The new object interactor. Set this value to
null
to remove the existing interactor from this object.getObjectInteractor()
,
IlvGraphic
protected 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 IlvPersistentObject
stream
- 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 Transferable
public boolean isDataFlavorSupported(DataFlavor flavor)
IlvGraphic
is DataFlavor.stringFlavor
.isDataFlavorSupported
in interface Transferable
flavor
- 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 Transferable
flavor
- The requested data flavor.IOException
- if the data is not writable.UnsupportedFlavorException
- if the requested data flavor is not
supported.GetGraphicObject(java.awt.datatransfer.Transferable)
public static IlvGraphic GetGraphicObject(Transferable trans) throws IOException
Transferable
object.
For trans
to be correctly decoded, it needs to have been
originally created from an IlvGraphic
object.
trans
. If
trans
does not handle a supported DataFlavor
,
null
is returned.IOException
- if an error occurs while the data is being read.isDataFlavorSupported(DataFlavor)
public String toString()
getName()
) if any.public void setBlinkingAction(IlvBlinkingAction action)
Example:
IlvMarker marker = new IlvMarker(); IlvBlinkingAction action = new IlvBlinkingAction() { protected void changeState(IlvGraphic obj, boolean isOn) { // no applyToObject necessary because the caller does it already for us IlvMarker marker = (IlvMarker)obj; if (isOn) { marker.setType(IlvMarker.IlvMarkerCircle); } else { marker.setType(IlvMarker.IlvMarkerPlus); } } }; marker.setBlinkingAction(action);Blinking is only effective if the graphic object is displayed in a manager view that has blinking enabled, and all graphic bag ancestors of this object are either
IlvManager
or
ManagerViewsHierarchyEventReceiver
(for instance
IlvFullZoomingGraphic
,
IlvHalfZoomingGraphic
,
IlvFixedSizeGraphic
,
IlvCompositeGraphic
,
or IlvGraphicSet
).getBlinkingAction()
,
IlvBlinkingAction
public IlvBlinkingAction getBlinkingAction()
null
if no blinking action
has been set.setBlinkingAction(ilog.views.java2d.IlvBlinkingAction)
protected void registerBlinkingResource(Object oldResource, Object newResource)
IlvBlinkingColor
, the
implementation should be like this:
public void setForeground(Color c) { Color old = this.colorField; this.colorField = c; registerBlinkingResource(old, c); }
oldResource
- The previous resource that is no longer used.newResource
- The new resource that is now used.public void setBlinkingOnPeriod(long onPeriod)
0
,
the object is blinking (see also setBlinkingOffPeriod(long)
).
To start blinking, set both periods to positive duration values, and
to stop blinking, set either one of both periods to 0
.
The default is 0
.
Blinking means that the object is periodically shown and hidden.
When blinking, isVisible()
remains unchanged, even when the
object is in the hiding period.
Limitation: For technical reasons, the "on" and "off" durations are limited from 0 to max integer (not max long). It is recommended to use the same durations whenever possible for all objects, and to choose the durations not too small (for example, not smaller than 100 ms), because otherwise the performance of the system will degrade dramatically.
onPeriod
- Duration, in milliseconds, of the "on" periodgetBlinkingOnPeriod()
,
setBlinkingOffPeriod(long)
public long getBlinkingOnPeriod()
0
, the object is not blinking.getBlinkingOnPeriod
in interface IlvBlinkingObject
setBlinkingOnPeriod(long)
public void setBlinkingOffPeriod(long offPeriod)
0
,
the object is blinking (see also setBlinkingOnPeriod(long)
).
To start blinking, set both periods to positive duration values, and
to stop blinking, set either one of both periods to 0
.
The default is 0
.
Blinking means that the object is periodically shown and hidden.
When blinking, isVisible()
remains unchanged, even when the
object is in the hiding period.
Limitation: For technical reasons, the "on" and "off" durations are limited from 0 to max integer (not max long). It is recommended to use the same durations whenever possible for all objects, and to choose the durations not too small (for example, not smaller than 100 ms), because otherwise the performance of the system will degrade dramatically.
offPeriod
- Duration, in milliseconds, of the "off" periodgetBlinkingOffPeriod()
,
setBlinkingOnPeriod(long)
public long getBlinkingOffPeriod()
0
, the object is not blinking.getBlinkingOffPeriod
in interface IlvBlinkingObject
setBlinkingOffPeriod(long)
public final void blinkingStateOn(boolean state)
IlvBlinkingObject
interface.
You should not call this method.blinkingStateOn
in interface IlvBlinkingObject
public IlvBlinkingObjectOwner getBlinkingObjectOwner()
IlvBlinkingObject
interface.
You should not call this method.getBlinkingObjectOwner
in interface IlvBlinkingObject
public void setToolTipText(String text)
Tooltips for Rogue Wave JViews graphic objects will work only
if your manager view is contained in a hierarchy of Swing components.
In addition, you must enable the tooltip mechanism for the manager view
by calling the static method
IlvToolTipManager.registerView(ilog.views.IlvManagerView)
.
Tooltip formatting is supported by the underlying Swing tooltip
mechanism (see JToolTip
). For instance, the
following string is a multiline tooltip:
"<html>This is a<br>multiline<br>tooltip</html>".
An easy way to create formatted multiline tooltips is the method
IlvSwingUtil.createMultiLineToolTipText(java.lang.String[], int)
.
See also the method
IlvSwingUtil.escapeForHTMLElement(java.lang.String, boolean)
.
text
- The tooltip string to display. Set text
to
null
to turn off the tooltip for this graphic object.IlvToolTipManager
,
IlvToolTipManager.registerView(ilog.views.IlvManagerView)
,
getToolTipText()
,
getToolTipText(IlvPoint, IlvTransformer)
,
IlvGraphic
public String getToolTipText()
null
if the tooltip
has not been set.setToolTipText(String)
,
getToolTipText(IlvPoint, IlvTransformer)
,
IlvGraphic
public String getToolTipText(IlvPoint p, IlvTransformer t)
The default implementation returns the same result as
getToolTipText()
.
Override this method to display different
tooltips over different parts of your custom graphic object.
p
- The location of the mouse in view coordinates.t
- The transformer that converts the manager coordinates of this
object into the coordinate system of the manager view in which the tooltip
will be displayed (the view coordinates).p
for transformation
t
, or null
if no tooltip should be displayed.IlvGraphic
,
getToolTipText()
,
setToolTipText(String)
public void setToolTipBaseTextDirection(int baseTextDirection)
IlvBidiUtil.INHERITED_DIRECTION
:
the base text direction of the tooltip is the same as the
the base text direction of the graphic object.
It is inherited from the base text direction of the graphic
object (in this sense, the graphic object is the parent of
its tooltip).
This is also the default.
IlvBidiUtil.COMPONENT_DIRECTION
:
the base text direction of the tooltip is calculated from the
component orientation of the graphic object.
IlvBidiUtil.LEFT_TO_RIGHT
:
the base text direction of the tooltip is left-to-right.
IlvBidiUtil.RIGHT_TO_LEFT
:
the base text direction of the tooltip is right-to-left.
IlvBidiUtil.CONTEXTUAL_DIRECTION
:
the base test direction is determined from the tooltip text
that is displayed according to the standard Bidi
algorithm, if the text contains at least one character
with a strong left-to-right or right-to-left direction.
If the text doesn't contain any character with a strong
direction, the real text direction is determined from
the current component orientation of the graphic object.
baseTextDirection
- The base text direction of the tooltip.IlvToolTipManager.setAdvancedBidiOnForTooltips(boolean)
public int getToolTipBaseTextDirection()
IlvBidiUtil.INHERITED_DIRECTION
:
the base text direction of the tooltip is the same as the
the base text direction of the graphic object.
It is inherited from the base text direction of the graphic
object (in this sense, the graphic object is the parent of
its tooltip).
This is also the default.
IlvBidiUtil.COMPONENT_DIRECTION
:
the base text direction of the tooltip is calculated from the
component orientation of the graphic object.
IlvBidiUtil.LEFT_TO_RIGHT
:
the base text direction of the tooltip is left-to-right.
IlvBidiUtil.RIGHT_TO_LEFT
:
the base text direction of the tooltip is right-to-left.
IlvBidiUtil.CONTEXTUAL_DIRECTION
:
the base test direction is determined from the tooltip text
that is displayed according to the standard Bidi
algorithm, if the text contains at least one character
with a strong left-to-right or right-to-left direction.
If the text doesn't contain any character with a strong
direction, the real text direction is determined from
the current component orientation of the graphic object.
public void setPopupMenu(JPopupMenu popup)
Pop-up menus for Rogue Wave JViews graphic objects only work
if your manager view is contained in a hierarchy of Swing components.
In addition, you must enable the pop-up menu mechanism for the manager view
by calling the static method
IlvPopupMenuManager.registerView(ilog.views.IlvManagerView)
.
Note that the pop-up menu is not persistent, that is, it is not saved in
in IVL files, and it is lost when using the paste operation (see
IlvManager.pasteSelection(IlvPoint, boolean)
).
If you want to avoid that pop-up menus are lost, you can register a
pop-up menu with a name by calling the static method
IlvPopupMenuManager.registerMenu(String name, javax.swing.JPopupMenu)
and then set the pop-up menu of this object by name
using setPopupMenuName(String)
.
For performance reasons, it is strongly recommended that graphic objects share the same pop-up menu whenever possible.
popup
- The Swing pop-up menu to be used for this graphic object.
If popup
is null
, the pop-up menu
is turned off for this graphic object.IlvPopupMenuManager
,
IlvPopupMenuManager.registerView(ilog.views.IlvManagerView)
,
IlvManager.pasteSelection(IlvPoint, boolean)
,
IlvPopupMenuManager.registerMenu(String name, javax.swing.JPopupMenu)
,
setPopupMenuName(String)
,
getPopupMenu()
,
getPopupMenu(IlvPoint, IlvTransformer, IlvManagerView, IlvPopupMenuManager)
,
IlvGraphic
public JPopupMenu getPopupMenu()
setPopupMenu(javax.swing.JPopupMenu)
.
If setPopupMenuName(java.lang.String)
was used to specify the pop-up menu,
this method returns null
.null
.setPopupMenu(JPopupMenu)
,
setPopupMenuName(String)
,
getPopupMenu(IlvPoint, IlvTransformer, IlvManagerView, IlvPopupMenuManager)
,
IlvGraphic
public void setPopupMenuName(String popupName)
This is an alternative way to set the pop-up menu of this object.
You need to register a Swing pop-up menu for the name via
IlvPopupMenuManager.registerMenu(String name, javax.swing.JPopupMenu)
and use the name to specify the pop-up menu of this graphic object.
Pop-up menus for Rogue Wave JViews graphic objects will work only
if your manager view is contained in a hierarchy of Swing components.
In addition, you must enable the pop-up menu mechanism for the manager view
by calling the static method
IlvPopupMenuManager.registerView(ilog.views.IlvManagerView)
.
The pop-up menu name is persistent, that is, it is saved in IVL files and is maintained properly when using copy and paste operations.
popupName
- The name of a Swing pop-up menu.
Set this value to null
to turn off pop-up
menus for this graphic object.IlvPopupMenuManager
,
setPopupMenu(JPopupMenu)
,
getPopupMenuName()
,
getPopupMenu(IlvPoint, IlvTransformer, IlvManagerView, IlvPopupMenuManager)
,
IlvGraphic
public String getPopupMenuName()
setPopupMenuName(java.lang.String)
.
If setPopupMenu(javax.swing.JPopupMenu)
was used to specify the pop-up menu,
this method returns null
.getPopupMenu(IlvPoint, IlvTransformer, IlvManagerView, IlvPopupMenuManager)
,
setPopupMenuName(String)
,
setPopupMenu(JPopupMenu)
,
IlvGraphic
public JPopupMenu getPopupMenu(IlvPoint p, IlvTransformer t, IlvManagerView view, IlvPopupMenuManager popupManager)
This method can return null
to turn off the pop-up menu
for this graphic object.
The default implementation returns the Swing pop-up menu obtained from
getPopupMenu()
, or the registered pop-up menu
with the name obtained from
getPopupMenuName()
.
Note that you must enable the pop-up menu mechanism for the manager view
by calling the static method
IlvPopupMenuManager.registerView(ilog.views.IlvManagerView)
.
p
- The location of the mouse in view coordinates.t
- The transformer that converts the manager coordinates of this
object into the coordinate system of the manager view in which the pop-up
menu will be displayed (the view coordinates).view
- The manager view that triggered the pop-up menu.popupManager
- The pop-up menu manager.null
.IlvGraphic
,
IlvPopupMenuManager.registerView(ilog.views.IlvManagerView)
,
getPopupMenu()
public final Locale getLocale()
java.util.Locale
mechanism.
It is recommended to use getULocale()
, because the class
ULocale
can contain more information such as collation
or currency than the Locale
.
Usually, graphic objects using the locale must also override
isLocaleSensitive()
if the bounding box depends on the locale.java.util.Locale
corresponding to the
current ULocale
.getULocale()
public ULocale getULocale()
isLocaleSensitive()
if the bounding box depends on the locale.
Note: Most predefined graphic objects are independent of locale.
If this object is contained in a graphic bag that has a locale,
it returns the locale of that graphic bag. Otherwise it returns
IlvLocaleUtil.getCurrentULocale()
.
Typically a graphic object is in a manager that is displayed in a manager
view, and the returned value is the locale of the first manager view
that displays the graphic.
localeChanged(com.ibm.icu.util.ULocale, com.ibm.icu.util.ULocale)
,
IlvManager.getULocale()
,
IlvLocaleUtil.getCurrentULocale()
public boolean isLocaleSensitive()
true
if the bounding box of this object depends
on the locale of this object.
The default implementation always returns false
.
A graphic object is locale sensitive if its bounding box calculation
yields different results when getULocale()
or getLocale()
calls return different locales. If this object is a graphic bag, it is
locale sensitive if it contains any object that is locale sensitive.
public void localeChanged(ULocale oldLocale, ULocale newLocale)
Subclasses must ensure this method is called whenever the
locale changes, for instance in a set method for the locale.
public void setULocale(ULocale locale)
{
ULocale oldLocale = getULocale();
_ulocale = locale;
ULocale newLocale = getULocale();
if (!oldLocale.equals(newLocale))
localeChanged(oldLocale, newLocale);
}
Graphic bags should use IlvGraphicUtil.startBidiChange(ilog.views.IlvGraphicBag)
and
IlvGraphicUtil.stopBidiChange(ilog.views.IlvGraphicBag, ilog.views.IlvGraphicVector, boolean)
which will automatically ensure
that localeChanged
is called on this and all
contained objects:
public void setULocale(ULocale locale)
{
IlvGraphicVector v = IlvGraphicUtil.startBidiChange(this);
try {
_ulocale = locale;
} finally {
IlvGraphicUtil.stopBidiChange(this, v, false);
}
}
Note: It is safe to change the bounding box of the
object inside this method, because the method is called using
IlvGraphicBag.applyToObject(ilog.views.IlvGraphic, ilog.views.IlvApplyObject, java.lang.Object, boolean)
when the object is contained
inside an IlvGraphicBag
.
If the object is a graphic bag, then the
implementation of this method does not need to call
localeChanged
of contained objects, since
IlvGraphicUtil.stopBidiChange(ilog.views.IlvGraphicBag, ilog.views.IlvGraphicVector, boolean)
will take care of this.
oldLocale
- Locale of this object before the locale change.newLocale
- Locale of this object after the locale change.isLocaleSensitive()
public ComponentOrientation getComponentOrientation()
isComponentOrientationSensitive()
if the bounding box depends
on the component orientation.
Note: Most predefined graphic objects are independent of component orientation.
If this object is contained in a graphic bag that has a component
orientation, it returns the component orientation of that graphic bag.
Otherwise it returns ComponentOrientation.UNKNOWN
.
Typically a graphic object is in a manager that is displayed in a manager view, and the returned value is the component orientation of the first manager view that displays the graphic.
componentOrientationChanged(java.awt.ComponentOrientation, java.awt.ComponentOrientation)
,
IlvManager.getComponentOrientation()
public boolean isComponentOrientationSensitive()
true
if the bounding box of this object depends
on the component orientation of this object.
The default implementation returns false
,
except when the object is sensitive to the base text direction
and the current choice of base text direction requires access to the
component orientation (see IlvBidiUtil.COMPONENT_DIRECTION
and IlvBidiUtil.CONTEXTUAL_DIRECTION
).
A graphic object is component orientation sensitive if its bounding box
calculation yields different results when
getComponentOrientation()
calls return different orientations.
If this object is a graphic bag, it is component orientation sensitive if
it contains any object that is component orientation sensitive.
public void componentOrientationChanged(ComponentOrientation oldOri, ComponentOrientation newOri)
Subclasses must ensure this method is called whenever the
component orientation changes, for instance in a set method for the
component orientation:
public void setComponentOrientation(ComponentOrientation co)
{
ComponentOrientation oldOri = getComponentOrientation();
_componentOrientation = co;
ComponentOrientation newOri = getComponentOrientation();
if (oldOri.isHorizontal() != newOri.isHorizontal() ||
oldOri.isLeftToRight() != newOri.isLeftToRight())
componentOrientationChanged(oldOri, newOri);
}
Graphic bags should use IlvGraphicUtil.startBidiChange(ilog.views.IlvGraphicBag)
and
IlvGraphicUtil.stopBidiChange(ilog.views.IlvGraphicBag, ilog.views.IlvGraphicVector, boolean)
which will automatically ensure
that componentOrientationChanged
is called on this and all
contained objects:
public void setComponentOrientation(ComponentOrientation co)
{
IlvGraphicVector v = IlvGraphicUtil.startBidiChange(this);
try {
_componentOrientation = co;
} finally {
IlvGraphicUtil.stopBidiChange(this, v, false);
}
}
Note: It is safe to change the bounding box of the
object inside this method, because the method is called using
IlvGraphicBag.applyToObject(ilog.views.IlvGraphic, ilog.views.IlvApplyObject, java.lang.Object, boolean)
when the object is contained
inside an IlvGraphicBag
.
If the object is a graphic bag, then the
implementation of this method does not need to call
componentOrientationChanged
of contained objects, since
IlvGraphicUtil.stopBidiChange(ilog.views.IlvGraphicBag, ilog.views.IlvGraphicVector, boolean)
will take care of this.
oldOri
- Orientation of this object before the orientation change.newOri
- Orientation of this object after the orientation change.isComponentOrientationSensitive()
public void setBaseTextDirection(int baseTextDirection)
IlvBidiUtil.INHERITED_DIRECTION
:
the base text direction is inherited from the
graphic bag that contains this object.
If this object is not contained in a graphic bag,
the base text direction is calculated from the
component orientation.
IlvBidiUtil.COMPONENT_DIRECTION
:
the base text direction is calculated from the
component orientation.
IlvBidiUtil.LEFT_TO_RIGHT
:
the base text direction is left-to-right.
IlvBidiUtil.RIGHT_TO_LEFT
:
the base text direction is right-to-left.
IlvBidiUtil.CONTEXTUAL_DIRECTION
:
the base test direction is determined from the text
that is displayed according to the standard Bidi
algorithm, if the text contains at least one character
with a strong left-to-right or right-to-left direction.
If the text doesn't contain any character with a strong
direction, the real text direction is determined from
the current component orientation of the object.
setBaseTextDirection
in interface IlvBaseTextDirectionInterface
baseTextDirection
- The base text directionbaseTextDirectionChanged(int, int)
protected void setBaseTextDirectionDuringConstruction(int baseTextDirection)
setBaseTextDirection(int)
.baseTextDirection
- The base text directionpublic int getBaseTextDirection()
IlvBidiUtil.INHERITED_DIRECTION
:
the base text direction is inherited from the
graphic bag that contains this object.
If this object is not contained in a graphic bag,
the base text direction is calculated from the
component orientation.
IlvBidiUtil.COMPONENT_DIRECTION
:
the base text direction is calculated from the
component orientation.
IlvBidiUtil.LEFT_TO_RIGHT
:
the base text direction is left-to-right.
IlvBidiUtil.RIGHT_TO_LEFT
:
the base text direction is right-to-left.
IlvBidiUtil.CONTEXTUAL_DIRECTION
:
the base test direction is determined from the text
that is displayed according to the standard Bidi
algorithm, if the text contains at least one character
with a strong left-to-right or right-to-left direction.
If the text doesn't contain any character with a strong
direction, the real text direction is determined from
the current component orientation of the object.
getBaseTextDirection
in interface IlvBaseTextDirectionInterface
public int getResolvedBaseTextDirection()
This method is similar to getBaseTextDirection()
but determines
the value when it is inherited from a parent component
(IlvBidiUtil.INHERITED_DIRECTION
) or dependent on
the component orientation (IlvBidiUtil.COMPONENT_DIRECTION
).
Hence, there are only 3 possible return values:
IlvBidiUtil.LEFT_TO_RIGHT
:
the base text direction is left-to-right.
IlvBidiUtil.RIGHT_TO_LEFT
:
the base text direction is right-to-left.
IlvBidiUtil.CONTEXTUAL_DIRECTION
:
the base test direction is determined from the text
that is displayed according to the standard Bidi
algorithm, if the text contains at least one character
with a strong left-to-right or right-to-left direction.
If the text doesn't contain any character with a strong
direction, the real text direction is determined from
the current component orientation of the object.
getResolvedBaseTextDirection
in interface IlvBaseTextDirectionInterface
public boolean isBaseTextDirectionSensitive()
true
if the bounding box of this object depends on
the base text direction of this object.
The default implementation always returns false
.
A graphic object is base text direction sensitive if its bounding
box calculation yields different results when
getResolvedBaseTextDirection()
calls return different directions.
If this object is a graphic bag, it is base text direction sensitive
if it contains any object that is base text direction sensitive.
public boolean usesBidiMarkers()
true
if in-place editing implementation uses markers,
which should be taken into account in hit-to-point and point-to-hit
calculations. The default implementation returns always false
.public void baseTextDirectionChanged(int oldBaseTextDirection, int newBaseTextDirection)
Subclasses must ensure this method is called whenever the resolved
base text direction changes, for instance in the set method for the
base text direction:
public void setBaseTextDirection(int baseTextDirection)
{
int oldBTDir = getResolvedBaseTextDirection();
_baseTextDirection = baseTextDirection;
int newBTDir = getResolvedBaseTextDirection();
if (newBTDir != oldBTDir)
baseTextDirectionChanged(oldBTDir, newBTDir);
}
Graphic bags should use IlvGraphicUtil.startBidiChange(ilog.views.IlvGraphicBag)
and
IlvGraphicUtil.stopBidiChange(ilog.views.IlvGraphicBag, ilog.views.IlvGraphicVector, boolean)
which will automatically ensure
that baseTextDirectionChanged
is called on this and all
contained objects:
public void setBaseTextDirection(int baseTextDirection)
{
if (baseTextDirection == _baseTextDirection)
return;
IlvGraphicVector v = IlvGraphicUtil.startBidiChange(this);
try {
_baseTextDirection = baseTextDirection;
} finally {
IlvGraphicUtil.stopBidiChange(this, v, false);
}
}
Note: It is safe to change the bounding box of the object
inside this method, because the method is called using
IlvGraphicBag.applyToObject(ilog.views.IlvGraphic, ilog.views.IlvApplyObject, java.lang.Object, boolean)
when the object is contained inside an
IlvGraphicBag
.
If the object is a graphic bag, then the
implementation of this method does not need to call
baseTextDirectionChanged
of contained objects, since
IlvGraphicUtil.stopBidiChange(ilog.views.IlvGraphicBag, ilog.views.IlvGraphicVector, boolean)
will take care of this.
oldBaseTextDirection
- Resolved base text direction of this object before the change.newBaseTextDirection
- Resolved base text direction of this object after the change.isBaseTextDirectionSensitive()
protected void invalidateBBoxCache()
protected void invalidateBidiCache()
public void addNamedPropertyListener(NamedPropertyListener listener)
listener
- The listener.removeNamedPropertyListener(ilog.views.event.NamedPropertyListener)
,
NamedPropertyEvent
public void removeNamedPropertyListener(NamedPropertyListener listener)
listener
- The listener.addNamedPropertyListener(ilog.views.event.NamedPropertyListener)
,
NamedPropertyEvent
public IlvNamedProperty setNamedProperty(IlvNamedProperty property)
property
- The persistent property to associate to this graphic
object.null
if no property of the
same name was previously associated.getNamedProperty(String)
,
IlvGraphic
public IlvNamedProperty getNamedProperty(String name)
name
- The name of the property to retrieve.null
if no such property exists.setNamedProperty(IlvNamedProperty)
,
addNamedPropertyListener(NamedPropertyListener)
,
IlvGraphic
public void removeNamedProperty(String name)
name
- The name of the property to remove.setNamedProperty(IlvNamedProperty)
,
addNamedPropertyListener(NamedPropertyListener)
,
IlvGraphic
public final boolean isInApplyToObject()
true
if this graphic object is currently treated
inside a call to applyToObject
.
All operations that may change the bounding box of a graphic object
stored
in a graphic bag must be run from an applyToObject
call.
The following code example shows how to use the apply to object
method:
graphic.getGraphicObject().applyToObject(graphic, new IlvApplyObject() { public void apply(IlvGraphic g, Object arg) { // do something that changes the bounding box ... } }, argument, redraw);It is useful to test whether the present call is inside or outside of any
applyToObject
session. In the example above,
the method would return true
when called inside the
apply
method. If this method returns false
, the
graphic object is currently not treated by any applyToObject
call.
The method returns also false
if this graphic
object does not belong to any manager, but in this case, an
applyToObject
session is not necessary and not possible.
Note: this is an expert method, it should be used for debugging purpose.
true
when called inside an applyToObject
call.IlvGraphic
,
IlvManager.applyToObject(ilog.views.IlvGraphic, ilog.views.IlvApplyObject, java.lang.Object, boolean)
,
IlvApplyObject
public final boolean setInApplyToObject(boolean v)
applyToObject
.
Returns true
if the status changed.
Every implementation of IlvGraphicBag.applyToObject(ilog.views.IlvGraphic, ilog.views.IlvApplyObject, java.lang.Object, boolean)
must
call this method in the following way:
public void applyToObject(IlvGraphic obj, IlvApplyObject f, Object arg, boolean redraw) { obj.setInApplyToObject(true); try { ... } finally { obj.setInApplyToObject(false); } }If an
IlvGraphic
implements the IlvGraphicBag
interface, the implementation can be done in the following way:
public void applyToObject(IlvGraphic obj, IlvApplyObject f, Object arg, boolean redraw) { boolean needsRecursion = obj.setInApplyToObject(true); try { if (needsRecursion && getGraphicBag() != null) { final IlvGraphic fobj = obj; final IlvApplyObject ff = f; getGraphicBag().applyToObject(this, new IlvApplyObject() { public void apply(IlvGraphic thisObj, Object arg) { doSomething(fobj, ff, arg, false); } }, arg, redraw); } else { doSomething(obj, f, arg, false); } } finally { obj.setInApplyToObject(false); } }
protected void updateNeedsViewNotification()
needsViewNotification()
,
viewAddedOrRemoved(ilog.views.IlvManagerView, boolean)
protected boolean needsViewNotification()
true
if this object needs to be notified whenever
a manager view is added to or removed from an ancestor manager so that
the view displays the graphic object.
If the graphic object needs view notification, you can override this
method to return true
. In this case, the method
viewAddedOrRemoved(ilog.views.IlvManagerView, boolean)
is called whenever a view displaying this
graphic object was added or removed. You can override
viewAddedOrRemoved(ilog.views.IlvManagerView, boolean)
to react on this. For example, you can
count how many views are currently displaying this object and you can update
the size of the internal caches accordingly.
When the need of view notification changes dynamically, you should call
updateNeedsViewNotification()
to update the corresponding internal
view listeners.
By default, the graphic object needs view notification when any form of
blinking is enabled.protected void viewAddedOrRemoved(IlvManagerView view, boolean added)
needsViewNotification()
returns true
.
For example, you can override this method to
count how many views are currently displaying this object and you can update
the size of the internal caches accordingly.
If you override this method, you must also override
needsViewNotification()
to return true
.
In many cases, you must also override allViewsRemoved()
.view
- The view that was added or removed.added
- true
if the view was added, and
false
if the view was removed.needsViewNotification()
,
allViewsRemoved()
protected void allViewsRemoved()
needsViewNotification()
returns
true
.
When this method is called, then viewAddedOrRemoved(ilog.views.IlvManagerView, boolean)
is not called
for each single removal of the views. You can override this method for
instance if you count via viewAddedOrRemoved(ilog.views.IlvManagerView, boolean)
how many views
display currently this object. In this case, you should reset the counter
to 0 in the overridden version of this method.needsViewNotification()
,
viewAddedOrRemoved(ilog.views.IlvManagerView, boolean)
© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.