public class IlvRotationBehavior extends IlvSingleBehavior implements IlvInteractiveBehavior
IlvRotationBehavior
is used to set the angle of a
prototype element. It can be used, for example, to rotate the needle of a
gauge.
An IlvRotationBehavior
defines the rotation angle that is
applied to the specified element with respect to its original position. When
the angle value is set, the rotation angle applied to the element equals the
difference between the current angle and the new angle. The element is
rotated once.
The rotation behavior object has parameters corresponding to the minimum
angle, the angle range, the minimum value and the value range. The new angle
is computed from the new value using the following formula:
angle = angleMin + angleRange * (value - valueMin)/valueRange
Note: This class should not be confused with the
IlvRotateBehavior
class, which is used to rotate an object at a
specified time interval to produce an animation effect.
Constructor and Description |
---|
IlvRotationBehavior(IlvInputStream in)
Reads the behavior from an
IlvInputStream stream. |
IlvRotationBehavior(IlvRotationBehavior source)
Creates a new behavior object by copying an existing one.
|
IlvRotationBehavior(String name,
String elementName,
String angleMin,
String angleRange,
String valueMin,
String valueRange,
String centerX,
String centerY)
Creates a new rotation behavior object.
|
IlvRotationBehavior(String name,
String elementName,
String angleMin,
String angleRange,
String valueMin,
String valueRange,
String centerX,
String centerY,
boolean dragAllowed,
String increment)
Creates a new rotation behavior object.
|
Modifier and Type | Method and Description |
---|---|
protected void |
attach(IlvGroup group)
This method is overridden to set an
IlvGroupInteractor on the
translated element(s) to let the user drag the object with the mouse. |
IlvBehavior |
copy()
Returns a copy of the behavior.
|
protected Object |
get(IlvGroup group,
String name)
Returns the value of the behavior object.
|
String |
getAngleMin()
Gets the
angleMin parameter for this behavior object. |
String |
getAngleRange()
Gets the
angleRange parameter for this behavior object. |
String |
getCenterX()
Gets the
centerX parameter for this behavior object. |
String |
getCenterY()
Gets the
centerY parameter for this behavior object. |
String |
getElementName()
Gets the
elementName parameter for this behavior object. |
String |
getIncrement()
Returns the
increment parameter of this behavior. |
String |
getValueMin()
Gets the
valueMin parameter for this behavior object. |
String |
getValueRange()
Gets the
valueRange parameter for this behavior object. |
boolean |
isDragAllowed()
Returns the
dragAllowed parameter of this behavior. |
boolean |
processEvent(IlvGroup group,
IlvGraphicElement element,
AWTEvent event,
IlvObjectInteractorContext context)
Implementation of the
IlvInteractiveBehavior interface:
rotates the element on mouse events. |
protected void |
set(IlvGroup group,
String name,
Object value)
Sets the rotation angle of the element specified by the
elementName parameter passed to the constructor according to
the new value and the parameters of this behavior object, as
explained in the class description. |
void |
setAngleMin(String angleMin)
Sets the
angleMin parameter for this behavior object. |
void |
setAngleRange(String angleRange)
Sets the
angleRange parameter for this behavior object. |
void |
setCenterX(String centerX)
Sets the
centerX parameter for this behavior object. |
void |
setCenterY(String centerY)
Sets the
centerY parameter for this behavior object. |
void |
setDragAllowed(boolean dragAllowed)
Sets the
dragAllowed parameter of this behavior. |
void |
setElementName(String elementName)
Sets the
elementName parameter for this behavior object. |
void |
setIncrement(String increment)
Sets the
increment parameter of this behavior. |
void |
setValueMin(String valueMin)
Sets the
valueMin parameter for this behavior object. |
void |
setValueRange(String valueRange)
Sets the
valueRange parameter for this behavior object. |
String |
toString()
Returns a short text describing this behavior object.
|
boolean |
useRangeAsMax()
Returns the
useRangeAsMax parameter of this behavior. |
void |
useRangeAsMax(boolean useRangeAsMax)
If
useRangeAsMax is true , the
valueRange (resp. |
void |
write(IlvOutputStream out)
Writes the behavior to an
IlvOutputStream . |
get, getName, getValueNames, set, setName
detach, getParameter, isOutput, isReadable, isWritable
public IlvRotationBehavior(String name, String elementName, String angleMin, String angleRange, String valueMin, String valueRange, String centerX, String centerY, boolean dragAllowed, String increment)
name
- the name of the behavior object, which is the name of the value
that will be used to set the angle of the element.elementName
- the name of the element to be rotated. This parameter can be set
to "[all]"
to rotate the whole prototype to which
this behavior object is attached.angleMin
- the minimum angle (in degrees). This value can be either a direct
value, the name of another property, or an expression.angleRange
- the angle range (in degrees). This value can be either a direct
value, the name of another property, or an expression.valueMin
- the minimum value used to compute the actual rotation. This value
can be either a direct value, the name of another property, or an
expression.valueRange
- the value range to compute the actual rotation. This value can be
either a direct value, the name of another property, or an
expression.centerX
- the horizontal coordinate of the center of the rotation. This
value can be either a direct value, the name of another behavior,
or an expression.centerY
- the vertical coordinate of the center of the rotation. This value
can be either a direct value, the name of another property, or an
expression.dragAllowed
- if true
, the user can drag the rotating element with
the mouse.increment
- specifies the minimum increment by which the value is modified.
The increment is in "value" units. For example, if
valueMin
is 0
, valueRange
is 100
and increment
is 20
,
the element can be rotated to 6 different positions corresponding
to the values 0, 20, 40, 60, 80 and 100. The
increment
parameter can be specified either as a
direct value, the name of another property, or an expression.public IlvRotationBehavior(String name, String elementName, String angleMin, String angleRange, String valueMin, String valueRange, String centerX, String centerY)
This constructor calls the first constructor with the
dragAllowed
parameter set to false
, and the
increment
parameter set to "0"
.
public IlvRotationBehavior(IlvRotationBehavior source)
source
- the behavior object to be copied.public IlvRotationBehavior(IlvInputStream in) throws IlvReadFileException
IlvInputStream
stream. This
constructor must be called by the input constructors of subclasses.in
- The input stream.IlvReadFileException
- if the stream format is not correct.public void write(IlvOutputStream out) throws IOException
IlvOutputStream
.write
in interface IlvPersistentObject
write
in class IlvSingleBehavior
out
- The output stream.IOException
- thrown when an exception occurs during
the write operation for this object.public IlvBehavior copy()
copy
in class IlvBehavior
public String toString()
toString
in class IlvBehavior
protected void set(IlvGroup group, String name, Object value) throws IlvValueException
elementName
parameter passed to the constructor according to
the new value
and the parameters of this behavior object, as
explained in the class description.set
in class IlvSingleBehavior
group
- the group to which this behavior object is attached.name
- the name of this behavior object.value
- the new value used to compute the rotation angle applied to the
element.IlvValueException
- if an error occurred while setting a value.IlvSingleBehavior.set(ilog.views.prototypes.IlvGroup,
java.lang.String[], java.lang.Object[], boolean[])
protected Object get(IlvGroup group, String name) throws IlvValueException
elementName
passed to the constructor.get
in class IlvSingleBehavior
group
- the group to which this behavior object is attached.name
- the name of this behavior object.IlvValueException
- if an error occurred while reading a property.IlvSingleBehavior.get(ilog.views.prototypes.IlvGroup,
java.lang.String[], java.lang.Object[], boolean[])
protected void attach(IlvGroup group)
IlvGroupInteractor
on the
translated element(s) to let the user drag the object with the mouse.attach
in class IlvBehavior
group
- the group to which this behavior object is attached.IlvGroup.addBehavior(ilog.views.prototypes.IlvBehavior)
public void setElementName(String elementName)
elementName
parameter for this behavior object.public String getElementName()
elementName
parameter for this behavior object.public void setAngleMin(String angleMin)
angleMin
parameter for this behavior object.public String getAngleMin()
angleMin
parameter for this behavior object.public void setAngleRange(String angleRange)
angleRange
parameter for this behavior object.public String getAngleRange()
angleRange
parameter for this behavior object.public void setValueMin(String valueMin)
valueMin
parameter for this behavior object.public String getValueMin()
valueMin
parameter for this behavior object.public void setValueRange(String valueRange)
valueRange
parameter for this behavior object.public String getValueRange()
valueRange
parameter for this behavior object.public void setCenterX(String centerX)
centerX
parameter for this behavior object.public String getCenterX()
centerX
parameter for this behavior object.public void setCenterY(String centerY)
centerY
parameter for this behavior object.public String getCenterY()
centerY
parameter for this behavior object.public void setDragAllowed(boolean dragAllowed)
dragAllowed
parameter of this behavior.public boolean isDragAllowed()
dragAllowed
parameter of this behavior.public void useRangeAsMax(boolean useRangeAsMax)
useRangeAsMax
is true
, the
valueRange
(resp. angleRange
) parameter will be
interpreted as the maximum value (resp. angle) instead of the
value (resp. angle) range.public boolean useRangeAsMax()
useRangeAsMax
parameter of this behavior.public void setIncrement(String increment)
increment
parameter of this behavior.public String getIncrement()
increment
parameter of this behavior.public boolean processEvent(IlvGroup group, IlvGraphicElement element, AWTEvent event, IlvObjectInteractorContext context)
IlvInteractiveBehavior
interface:
rotates the element on mouse events.processEvent
in interface IlvInteractiveBehavior
group
- the group containing the element in which the event occurred.element
- the graphic element in which the event occurred.event
- the event, which can be a MouseEvent
or a
KeyEvent
.context
- the interactor context, which can be used to get the view
transformer.true
if the event was actually processed, or
false
if the event was ignored.© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.