public class IlvTranslateBehavior extends IlvSingleBehavior implements IlvInteractiveBehavior
IlvTranslateBehavior
is used to set the horizontal or
vertical position of a prototype element. It can be used, for example, to
move the slider box of a slider or a linear gauge.
An IlvTranslateBehavior
defines the new position of the
specified element with respect to its original position. When the value is
set, the element is translated from its current position to the new position.
The translate behavior object has parameters corresponding to the minimum
position, the position range, the minimum value, and the value range. The new
position is computed from the new value as follows:
position = positionMin + positionRange * (value - valueMin)/valueRange
If the dragAllowed
parameter is set to true
, the
user can translate the element by dragging it with the mouse.
Constructor and Description |
---|
IlvTranslateBehavior(IlvInputStream in)
Reads the behavior from an
IlvInputStream stream. |
IlvTranslateBehavior(IlvTranslateBehavior source)
Creates a new behavior object by copying an existing one.
|
IlvTranslateBehavior(String name,
String elementName,
String positionMin,
String positionRange,
String valueMin,
String valueRange,
boolean vertical)
Creates a new translate behavior object.
|
IlvTranslateBehavior(String name,
String elementName,
String positionMin,
String positionRange,
String valueMin,
String valueRange,
boolean vertical,
boolean inside,
boolean dragAllowed,
String increment)
Creates a new translate 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 |
getElementName()
Gets the
elementName parameter for this behavior object. |
String |
getIncrement()
Returns the
increment parameter of this behavior. |
String |
getPositionMin()
Gets the
positionMin parameter for this behavior object. |
String |
getPositionRange()
Gets the
positionRange parameter for this behavior object. |
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 |
isInside()
Returns the
inside parameter of this behavior. |
boolean |
isVertical()
Returns the
vertical parameter of this behavior. |
boolean |
processEvent(IlvGroup group,
IlvGraphicElement element,
AWTEvent event,
IlvObjectInteractorContext context)
Implementation of the
IlvInteractiveBehavior interface:
translates the element on mouse events. |
protected void |
set(IlvGroup group,
String name,
Object value)
Translates the element specified by the
elementName parameter
passed to the constructor according to the new value and to
the parameters of this behavior object, as explained in the class
description. |
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 |
setInside(boolean inside)
Sets the
inside parameter of this behavior. |
void |
setPositionMin(String positionMin)
Sets the
positionMin parameter for this behavior object. |
void |
setPositionRange(String positionRange)
Sets the
positionRange parameter for this behavior object. |
void |
setValueMin(String valueMin)
Sets the
valueMin parameter for this behavior object. |
void |
setValueRange(String valueRange)
Sets the
valueRange parameter for this behavior object. |
void |
setVertical(boolean vertical)
Sets the
vertical parameter of this behavior. |
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 parameter will be interpreted as the
maximum value instead of the value range. |
void |
write(IlvOutputStream out)
Writes the behavior to an
IlvOutputStream . |
get, getName, getValueNames, set, setName
detach, getParameter, isOutput, isReadable, isWritable
public IlvTranslateBehavior(String name, String elementName, String positionMin, String positionRange, String valueMin, String valueRange, boolean vertical, boolean inside, boolean dragAllowed, String increment)
name
- the name of the behavior, which is the name of the value that will
be used to set the position of the element.elementName
- the name of the element to be translated. This parameter can be
set to "[all]"
to translate the whole prototype to
which this behavior is attached.positionMin
- the minimum position (in pixels). This value can be either a
direct value, the name of another property, or an expression.positionRange
- the position range (in pixels). 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 translation. This
value can be either a direct value, the name of another property,
or an expression.valueRange
- the value range used to compute the actual translation. This value
can be either a direct value, the name of another property, or an
expression.vertical
- if true
, the element is translated vertically.
Otherwise, it is translated horizontally.inside
- if true
, the element will stay "inside" its
translation bounds, which means that the minimum position is
augmented by half the size of the translated element, and the
position range is reduced by the size of the translated element.
If inside
is false
, the element's
center will move between the minimum and maximum
position.dragAllowed
- if true
, the user can drag the 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 translated 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 IlvTranslateBehavior(String name, String elementName, String positionMin, String positionRange, String valueMin, String valueRange, boolean vertical)
inside
parameter set to false
, the dragAllowed
parameter
set to false
, and the increment
parameter set to
"0"
.public IlvTranslateBehavior(IlvTranslateBehavior source)
source
- the behavior object to be copied.public IlvTranslateBehavior(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 to
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 element position.IlvValueException
- if an error occurred while setting a property.IlvSingleBehavior.set(ilog.views.prototypes.IlvGroup,
java.lang.String[], java.lang.Object[], boolean[])
protected Object get(IlvGroup group, String name) throws IlvValueException
elementName
parameter 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 setPositionMin(String positionMin)
positionMin
parameter for this behavior object.public String getPositionMin()
positionMin
parameter for this behavior object.public void setPositionRange(String positionRange)
positionRange
parameter for this behavior object.public String getPositionRange()
positionRange
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 boolean processEvent(IlvGroup group, IlvGraphicElement element, AWTEvent event, IlvObjectInteractorContext context)
IlvInteractiveBehavior
interface:
translates 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.public void setVertical(boolean vertical)
vertical
parameter of this behavior.public boolean isVertical()
vertical
parameter of this behavior.public void setInside(boolean inside)
inside
parameter of this behavior.public boolean isInside()
inside
parameter of this behavior.public void setDragAllowed(boolean dragAllowed)
dragAllowed
parameter of this behavior.public boolean isDragAllowed()
dragAllowed
parameter of this behavior.public void setIncrement(String increment)
increment
parameter of this behavior.public String getIncrement()
increment
parameter of this behavior.public void useRangeAsMax(boolean useRangeAsMax)
useRangeAsMax
is true
, the
valueRange
parameter will be interpreted as the
maximum value instead of the value range.public boolean useRangeAsMax()
useRangeAsMax
parameter of this behavior.© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.