FileDocCategorySizeDatePackage
FractionSpring.javaAPI DocExample1294Thu Oct 24 20:14:24 BST 2002None

FractionSpring

public class FractionSpring extends Spring

Fields Summary
protected Spring
parent
protected double
fraction
Constructors Summary
public FractionSpring(Spring p, double f)

    if (p == null) {
      throw new NullPointerException("Parent spring cannot be null");
    }
    parent = p;
    fraction = f;
  
Methods Summary
public intgetMaximumValue()

 
    return (int)Math.round(parent.getMaximumValue() * fraction);
  
public intgetMinimumValue()

 
    return (int)Math.round(parent.getMinimumValue() * fraction);
  
public intgetPreferredValue()

 
    return (int)Math.round(parent.getPreferredValue() * fraction);
  
public intgetValue()

    return (int)Math.round(parent.getValue() * fraction);
  
public static FractionSpringhalf(javax.swing.Spring s)

    return new FractionSpring(s, 0.5);
  
public voidsetValue(int val)

    // Uncomment this next line to watch when our spring is resized:
    // System.err.println("Value to setValue: " + val);
    if (val == UNSET) {
      return;
    }
    throw new UnsupportedOperationException(
         "Cannot set value on a derived spring");