public class ReparentStripeHandler extends Object implements IReparentStripeHandler
IReparentStripeHandler
interface.
This implementation allows to specify a maximal nesting depth for reparent operations.
Constructor and Description |
---|
ReparentStripeHandler() |
Modifier and Type | Method and Description |
---|---|
protected void |
adjustSize(IInputModeContext context,
IStripe stripe,
IStripe newParent,
StripeReparentPolicy reparentPosition,
int index,
double originalStripeSize,
double originalParentSize)
Adjust the size of the source or the target stripe.
|
int |
getMaxColumnLevel()
The maximum nesting level the column hierarchy may acquire during a reparent gesture.
|
int |
getMaxRowLevel()
The maximum nesting level the row hierarchy may acquire during a reparent gesture.
|
boolean |
isValidParent(IInputModeContext context,
IStripe stripe,
IStripe newParent,
int index,
StripeReparentPolicy reparentPosition)
Checks the constraints imposed by
MaxRowLevel or MaxColumnLevel
for a valid gesture. |
void |
reparent(IInputModeContext context,
IStripe stripe,
IStripe newParent,
int index,
StripeReparentPolicy reparentPosition)
Performs the actual reparenting after the reparent gesture has been finalized.
|
void |
setMaxColumnLevel(int value)
The maximum nesting level the column hierarchy may acquire during a reparent gesture.
|
void |
setMaxRowLevel(int value)
The maximum nesting level the row hierarchy may acquire during a reparent gesture.
|
boolean |
shouldReparent(IInputModeContext context,
IStripe stripe)
Determines whether the user may detach the given stripe from its current parent in order to reparent it.
|
protected void adjustSize(IInputModeContext context, IStripe stripe, IStripe newParent, StripeReparentPolicy reparentPosition, int index, double originalStripeSize, double originalParentSize)
This implementation adjusts the size of stripe
to Math.Max(originalStripeSize, originalParentSize)
if reparentPosition
is an StripeReparentPolicy.ADD_CHILD
operation
context
- The context that provides information about the user input.stripe
- The stripe that will be reparented.newParent
- The potential new parent.index
- The index where the stripe should be inserted.reparentPosition
- Where to place the stripe as a result of the gesture that triggered the reparent operation.originalStripeSize
- The original size of stripe
originalParentSize
- The original size of newParent
public final int getMaxColumnLevel()
Note that it is always possible to decrease the nesting depth, even if the resulting depth would still be too high. This
allows to interactively reduce an invalid nesting depth in multiple steps. The default value is
Integer.MAX_VALUE
, which effectively means an unlimited nesting depth.
setMaxColumnLevel(int)
public final int getMaxRowLevel()
Note that it is always possible to decrease the nesting depth, even if the resulting depth would still be too high. This
allows to interactively reduce an invalid nesting depth in multiple steps. The default value is
Integer.MAX_VALUE
, which effectively means an unlimited nesting depth.
setMaxRowLevel(int)
public boolean isValidParent(IInputModeContext context, IStripe stripe, IStripe newParent, int index, StripeReparentPolicy reparentPosition)
MaxRowLevel
or MaxColumnLevel
for a valid gesture.isValidParent
in interface IReparentStripeHandler
context
- The context that provides information about the user input.stripe
- The stripe that will be reparented.newParent
- The potential new parent.index
- The index where the stripe would be
reparented
reparentPosition
- Where to place the stripe as a result of the gesture that would be used for the reparent(IInputModeContext, IStripe, IStripe, int, StripeReparentPolicy)
operation.true
iff the resulting nesting depth is smaller than MaxRowLevel
or
MaxColumnLevel
, or if the nesting depth would not increase by the operation.public void reparent(IInputModeContext context, IStripe stripe, IStripe newParent, int index, StripeReparentPolicy reparentPosition)
This implementation adjusts the size of the moved and/or the target stripe by calling adjustSize(IInputModeContext, IStripe, IStripe, StripeReparentPolicy, int, double, double)
.
reparent
in interface IReparentStripeHandler
context
- The context that provides information about the user input.stripe
- The stripe that will be reparented.newParent
- The potential new parent.index
- The index where the stripe should be inserted.reparentPosition
- Where to place the stripe as a result of the gesture that triggered the reparent operation.public final void setMaxColumnLevel(int value)
Note that it is always possible to decrease the nesting depth, even if the resulting depth would still be too high. This
allows to interactively reduce an invalid nesting depth in multiple steps. The default value is
Integer.MAX_VALUE
, which effectively means an unlimited nesting depth.
value
- The MaxColumnLevel to set.getMaxColumnLevel()
public final void setMaxRowLevel(int value)
Note that it is always possible to decrease the nesting depth, even if the resulting depth would still be too high. This
allows to interactively reduce an invalid nesting depth in multiple steps. The default value is
Integer.MAX_VALUE
, which effectively means an unlimited nesting depth.
value
- The MaxRowLevel to set.getMaxRowLevel()
public boolean shouldReparent(IInputModeContext context, IStripe stripe)
shouldReparent
in interface IReparentStripeHandler
context
- The context that provides information about the user input.stripe
- The stripe that is about to be detached from its current parent.true
.