JavaView® v2.12

jv.number
Class PuDouble

java.lang.Object
  |
  +--jv.object.PsObject
        |
        +--jv.number.PuDouble
All Implemented Interfaces:
java.lang.Cloneable, PsUpdateIf, java.io.Serializable

public final class PuDouble
extends PsObject

Basic double class with update functionality and panel containing a slider. This class may always be used when a double instance variable shall be modifiable by a slider in the info panel of its parent class. See the class PjExprOde as a sample application.

Usage demonstrated in a sample class:


	 public class PjExprOde
  {
		protected  PuDouble  m_length;
		public PjExprOde() {
			// Create a new instance of PuDouble and register 'this' as parent
			// to receive update events whenever user has modified the slider.
			m_length		= new PuDouble("Length", this);
		}
		public void init() {
			// Set default value to be assigned when user resets slider
			// using a call m_length.init().
			m_length.setDefValue(15.);
			// Set default min/max values and increments of slider.
			m_length.setDefBounds(1., 50., 0.1, 1.0);
			// Reset to default values.
			m_length.init();
		}
		public boolean update(Object event) {
			// Catch update events sent whenever user has modifed slider.
			if (event == m_length) {
				// Do something application depended
				solve();
				return true;
			}
		}
		public void solve() {
			// Access current value
			System.out.println("Current value = "+m_length.getValue());
		}
  }
 

Version:
15.04.00, 1.20 revised (ep,kp) Initialization of m_iValue in init() done.
07.08.99, 1.10 revised (kp) Converted to AWT 1.1
00.00.98, 1.00 created (kp)
Author:
Konrad Polthier
See Also:
PuInteger, PjExprOde, Serialized Form

Fields inherited from class jv.object.PsObject
HAS_CONFIG_PANEL, HAS_INFO_PANEL, HAS_MATERIAL_PANEL, HAS_TEXTURE_PANEL, INSPECTOR_INFO, INSPECTOR_INFO_EXT, IS_DELETED, IS_FIXED, IS_SELECTED, IS_USED, NUM_TAGS
 
Constructor Summary
PuDouble(java.lang.String aName, PsUpdateIf aParent)
          Create new instance with given name and parent.
 
Method Summary
 void blend(double a, PuDouble v, double b, PuDouble w)
          Blend with other doubles using this = a*v + b*w.
 void copy(PuDouble num)
          Copy all instance variables of argument source into 'this'.
 double getDefLineIncr()
          Get the default line increment which are used when slider is reset.
 double getDefMaximum()
          Get the default maximum value which are used when slider is reset.
 double getDefMinimum()
          Get the default minimum value which are used when slider is reset.
 double getDefPageIncr()
          Get the default page increment which are used when slider is reset.
 double getLineIncr()
          Get line increment of slider.
 double getMax()
          Get maximal value allowed in slider.
 double getMin()
          Get minimal value allowed in slider.
 double getPageIncr()
          Get block increment of slider.
 double getValue()
          Get current double value.
 void init()
          Assign default values, and may be used to reset instance.
 boolean isEnabled()
          Check whether slider is enabled or disabled.
 void setBounds(double aMin, double aMax)
          Set current min/max values and adjust value if current value lies outside the new min/max bounds.
 void setBounds(double aMin, double aMax, double aLineIncr, double aPageIncr)
          Set current min/max values and slider increments.
 void setDefBounds(double aMin, double aMax, double aLineIncr, double aPageIncr)
          Set default min/max values and slider increments to be assigned when init() is called as reset.
 void setDefValue(double value)
          Set default value to be assigned when init() is called as reset.
 void setEnabled(boolean flag)
          Enable or disable the slider for interactive use.
 void setValue(double aValue)
          Set value of double, and adjust slider if visible.
 boolean update(java.lang.Object anObject)
          Catch update events sent from info panel.
 
Methods inherited from class jv.object.PsObject
addInspector, addUpdateListener, assureInspector, clearTag, clone, clone, clone, copy, getFather, getInfoPanel, getInspector, getName, getNumObjects, hasInspector, hasTag, hasUpdateListener, instanceOf, instanceOf, removeInspector, removeUpdateListener, setName, setParent, setTag, toString, updatePanels
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PuDouble

public PuDouble(java.lang.String aName,
                PsUpdateIf aParent)
Create new instance with given name and parent. The name appears as label on the slider, and the parent is informed whenever the slider has changed using aParent.update(this).
Parameters:
aName - Name of double to appear as label in slider.
aParent - Parent of double to receive update events.
Method Detail

init

public void init()
Assign default values, and may be used to reset instance.
Overrides:
init in class PsObject

copy

public void copy(PuDouble num)
Copy all instance variables of argument source into 'this'.

setDefValue

public void setDefValue(double value)
Set default value to be assigned when init() is called as reset.

getDefMinimum

public double getDefMinimum()
Get the default minimum value which are used when slider is reset. Current value of slider is clipped to lie within [min,max] bounds.
See Also:
setDefBounds(double, double, double, double), setBounds(double, double, double, double)

getDefMaximum

public double getDefMaximum()
Get the default maximum value which are used when slider is reset. Current value of slider is clipped to lie within [min,max] bounds.
See Also:
setDefBounds(double, double, double, double), setBounds(double, double, double, double)

getDefLineIncr

public double getDefLineIncr()
Get the default line increment which are used when slider is reset.
See Also:
setDefBounds(double, double, double, double), setBounds(double, double, double, double)

getDefPageIncr

public double getDefPageIncr()
Get the default page increment which are used when slider is reset.
See Also:
setDefBounds(double, double, double, double), setBounds(double, double, double, double)

setDefBounds

public void setDefBounds(double aMin,
                         double aMax,
                         double aLineIncr,
                         double aPageIncr)
Set default min/max values and slider increments to be assigned when init() is called as reset. Current value of slider is clipped to lie within [min,max] bounds.

setValue

public void setValue(double aValue)
Set value of double, and adjust slider if visible. If new value is outside the current bounds, then the new value is clipped to lie within the bounds. This routine called from outside to set the value. Only here we update the panel.

getValue

public double getValue()
Get current double value.

getMin

public double getMin()
Get minimal value allowed in slider. May be interactively modified with config panel.

getMax

public double getMax()
Get maximal value allowed in slider. May be interactively modified with config panel.

getLineIncr

public double getLineIncr()
Get line increment of slider. May be interactively modified with config panel.

getPageIncr

public double getPageIncr()
Get block increment of slider. May be interactively modified with config panel.

setBounds

public void setBounds(double aMin,
                      double aMax,
                      double aLineIncr,
                      double aPageIncr)
Set current min/max values and slider increments. Adjust value if current value lies outside the new min/max bounds. These bounds will be overriden if instance is reset using init().
Parameters:
aMin, - aMax Minimal and maximal values in slider.
aLineIncr - Line increment used in slider.
aPageIncr - Block increment used in slider.

setBounds

public void setBounds(double aMin,
                      double aMax)
Set current min/max values and adjust value if current value lies outside the new min/max bounds. These bounds will be overriden if instance is reset using init(). Line and block increments of slider are set to default values.
Parameters:
aMin, - aMax Minimal and maximal values in slider.

isEnabled

public boolean isEnabled()
Check whether slider is enabled or disabled.

setEnabled

public void setEnabled(boolean flag)
Enable or disable the slider for interactive use. If disabled, the double variable can still be modified by calls setValue(double), and the slider is always updated.

update

public boolean update(java.lang.Object anObject)
Catch update events sent from info panel.
Overrides:
update in class PsObject
Following copied from class: jv.object.PsObject
See Also:
PsObject.setParent(PsUpdateIf), PsObject.getFather(), PsObject.addUpdateListener(PsUpdateIf)

blend

public void blend(double a,
                  PuDouble v,
                  double b,
                  PuDouble w)
Blend with other doubles using this = a*v + b*w.

JavaView® v2.12

The software JavaView® is copyright protected. All Rights Reserved.