DESY ACOP Beans Home

com.cosylab.gui.components.range2
Class RescalingValuePolicy

java.lang.Object
  extended by com.cosylab.gui.components.range2.RangedValuePolicy
      extended by com.cosylab.gui.components.range2.RescalingValuePolicy

public class RescalingValuePolicy
extends RangedValuePolicy

Implementation of RangedValuePolicy that resizes the range based on the value parameter.

Whenever the value is set below minimum, minimum will be changed to the the value, decreased by factor (maximum - minimum). Same rule applies for maximum.

This policy is value dominant i.e., bounds will be adjusted to ensure that value is always valid. If either bound is set incorrectly, it will be adjusted to conform with this condition.

Rule for adjusting bounds is as follows. Whenever value is either below minimum ore above maximum, the corresponding bound will be adjusted using value - range * factor or value + range * factor for minimum and maximum respectively, where range is maximum - minimum.

Version:
$id$
Author:
Ales Pucelj

Constructor Summary
RescalingValuePolicy()
          Default constructor for RescalingValuePolicy.
RescalingValuePolicy(double factor)
          Constructor for RescalingValuePolicy.
 
Method Summary
 double getFactor()
          Returns rescaling factor.
 void setFactor(double factor)
          Sets new rescaling factor.
 RangedValue validate(RangedValue params)
          Adjusts bounds as specified in class JavaDoc.
 
Methods inherited from class com.cosylab.gui.components.range2.RangedValuePolicy
addPeerPolicy, getPeerPolicy, insertPeerPolicy, removePeerPolicy, removePeerPolicyByType, validatePeerPolicy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RescalingValuePolicy

public RescalingValuePolicy()
Default constructor for RescalingValuePolicy. Initializes rescaling factor to 0.25.


RescalingValuePolicy

public RescalingValuePolicy(double factor)
Constructor for RescalingValuePolicy. Allows custom rescaling factor.

Parameters:
factor - by which the range will be resized.
Method Detail

validate

public RangedValue validate(RangedValue params)
Adjusts bounds as specified in class JavaDoc.

Specified by:
validate in class RangedValuePolicy
Parameters:
params - RangedValueHolder
Returns:
if the validation require the change of value or bounds of the RangedValue a new RangedValue with appropriate values should be returned
See Also:
com.cosylab.gui.components.range.RangedValuePolicy#validate(RangedValueHolder)

getFactor

public double getFactor()
Returns rescaling factor.

Returns:
factor.

setFactor

public void setFactor(double factor)
Sets new rescaling factor. Factor set will not be less that 0.

Parameters:
factor - new rescaling factor.


Copyright © 2010. All Rights Reserved.