Class PuDouble
- java.lang.Object
-
- jv.object.PsObject
-
- jv.number.PuDouble
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, PsUpdateIf
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 vgp.tutor.ode.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 update listener // to receive update events whenever user has modified the slider. m_length = new PuDouble("Length", this); } public void init() { // Set default min/max values and increments of slider. m_length.setDefBounds(1., 50., 0.1, 1.0); // Set default value to be assigned in m_length.init() or // when slider is reset. m_length.setDefValue(15.); m_length.init(); // Reset to default values. } public boolean update(Object event) { // Catch update events whenever user has modified slider. if (event == m_length) { solve(m_length.getValue()); // Do something application depended return true; } } }- See Also:
PuInteger, Serialized Form- Author:
- Konrad Polthier
- Version:
- 09.10.08, 1.90 revised (mn) New checkbox showing the 'enabled' status of the PuDouble.
09.12.06, 1.80 revised (kp) New methods doubleToString() moved to here from PgLoader.
12.08.05, 1.70 revised (ep) Introduced shortcutinitWithDefaultsfor setDefBounds/setDefValue/init.
03.08.04, 1.60 revised (kp) Handling of background color of inspector.
13.08.03, 1.50 revised (kp) Assure that value and defValue lie within bounds.
25.11.02, 1.40 revised (kp) New constructor added.
06.01.02, 1.30 revised (kp) Obsolete update method removed.
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)
-
-
Field Summary
-
Fields inherited from class jv.object.PsObject
HAS_BOUNDARY_PANEL, HAS_CONFIG_PANEL, HAS_INFO_PANEL, HAS_LABEL_PANEL, HAS_MATERIAL_PANEL, HAS_TEXTURE_PANEL, HAS_VECTOR_PANEL, INSPECTOR_INFO, INSPECTOR_INFO_EXT, IS_DELETED, IS_FIXED, IS_FOCUSSED, IS_PICKED, IS_SELECTED, IS_USED, NUM_TAGS
-
-
Constructor Summary
Constructors Constructor and Description PuDouble(java.lang.String name)Create new instance with given name.PuDouble(java.lang.String name, PsUpdateIf parent)Create new instance with given name and parent.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidblend(double a, PuDouble v, double b, PuDouble w)Blend with other doubles usingthis = a*v + b*w.voidcopy(PuDouble num)Copy all instance variables of argument source into 'this'.doubleenforceBounds(double value)Constrain value to lie within bounds of this slider.java.awt.ColorgetBackground()Get color of background of info panel.doublegetDefLineIncr()Get the default line increment which are used when slider is reset.doublegetDefMaximum()Get the default maximum value which are used when slider is reset.doublegetDefMinimum()Get the default minimum value which are used when slider is reset.doublegetDefPageIncr()Get the default page increment which are used when slider is reset.doublegetDefValue()Get the default value which is used when slider is reset.doublegetLineIncr()Get line increment of slider.doublegetMax()Get maximal value allowed in slider.doublegetMin()Get minimal value allowed in slider.doublegetPageIncr()Get block increment of slider.doublegetValue()Get current double value.voidinit()Assign default values, and may be used to reset instance.voidinitWithDefaults(double min, double max, double lineIncr, double pageIncr, double defValue)Sets the default values for this component and initializes it.booleanisEnabled()Check whether slider is enabled or disabled.booleanisEnabledConfigButton()Flag determines whether button for config panel is enabled or not, in this way permitting/prohibiting GUI control over bounds and increments.booleanisShowingEnabled()Whether to show a checkbox in the info panel.static doubleparseDouble(java.io.StreamTokenizer st)Parse double value in exponential notation.static doubleparseDouble(java.lang.String string)Parse double value in exponential notation using Double(String).doubleValue().voidsetBackground(java.awt.Color color)Set color of background of info panel.voidsetBounds(double min, double max)Set current min/max values and adjust value if current value lies outside the new min/max bounds.voidsetBounds(double min, double max, double lineIncr, double pageIncr)Set current min/max values and slider increments.voidsetDefBounds(double min, double max, double lineIncr, double pageIncr)Set default min/max values and slider increments to be assigned wheninit()is called as reset.voidsetDefValue(double value)Set default value to be assigned wheninit()is called as reset.voidsetEnabled(boolean flag)Enable or disable the slider for interactive use.voidsetEnabledConfigButton(boolean flag)Flag determines whether button for config panel is enabled or not, in this way permitting/prohibiting GUI control over bounds and increments.voidsetLineIncr(double lineIncr)Set line increment of slider.voidsetPageIncr(double pageIncr)Set block increment of slider.voidsetValue(double value)Set value of double, and adjust slider if visible.voidshowEnabled(boolean show)Toggle whether to show a checkbox in the info panel.-
Methods inherited from class jv.object.PsObject
addInspector, addUpdateListener, assureInspector, clearTag, clone, clone, clone, copy, getFather, getInfoPanel, getInspector, getName, getNumObjects, getSymbol, hasInspector, hasTag, hasUpdateListener, instanceOf, instanceOf, newInspector, newInspector, removeInspector, removeInspector, removeUpdateListener, setName, setParent, setSymbol, setTag, toString, update, updatePanels
-
-
-
-
Constructor Detail
-
PuDouble
public PuDouble(java.lang.String name)
Create new instance with given name. The name appears as label on the slider.In order to receive update events of this slider one might either assign a parent or register an update listener.
- Parameters:
name- Name of double to appear as label in slider.- Since:
- JavaView 2.47
- Version:
- 25.11.02, 1.00 created (kp)
-
PuDouble
public PuDouble(java.lang.String name, PsUpdateIf parent)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 usingparent.update(this).- Parameters:
name- Name of double to appear as label in slider.parent- Parent of double to receive update events.
-
-
Method Detail
-
init
public void init()
Assign default values, and may be used to reset instance.
-
initWithDefaults
public void initWithDefaults(double min, double max, double lineIncr, double pageIncr, double defValue)Sets the default values for this component and initializes it.
-
copy
public void copy(PuDouble num)
Copy all instance variables of argument source into 'this'.
-
getDefValue
public double getDefValue()
Get the default value which is used when slider is reset.- Since:
- JavaView 2.91.000
- See Also:
setDefValue(double),getValue()- Version:
- 13.08.03, 1.00 created (kp)
-
setDefValue
public void setDefValue(double value)
Set default value to be assigned wheninit()is called as reset.If new value is outside the current bounds, then the bounds are enlarged.
SetDefValue() should be assigned AFTER the default interval has been resized with setDefBounds() in order to avoid automatic defBound resize.
- See Also:
setDefBounds(double, double, double, double)- Version:
- 19.08.03, 1.50 revised (kp) Enlarge def bounds if necessary.
-
getDefMinimum
public double getDefMinimum()
Get the default minimum value which are used when slider is reset.- See Also:
setDefBounds(double, double, double, double),setBounds(double,double)- Version:
- 08.07.01, 1.00 created (kp)
-
getDefMaximum
public double getDefMaximum()
Get the default maximum value which are used when slider is reset.- See Also:
setDefBounds(double, double, double, double),setBounds(double,double)- Version:
- 08.07.01, 1.00 created (kp)
-
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)- Version:
- 08.07.01, 1.00 created (kp)
-
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)- Version:
- 08.07.01, 1.00 created (kp)
-
setDefBounds
public void setDefBounds(double min, double max, double lineIncr, double pageIncr)Set default min/max values and slider increments to be assigned wheninit()is called as reset.Line and page increments are clipped if larger than range.
Current default value of slider is clipped to lie within [min,max] bounds.
- Parameters:
min- Default minimal value in slider, min must be smaller than max.max- Default maximal value in slider, min must be smaller than max.lineIncr- Default line increment used in slider.pageIncr- Default block increment used in slider.- Version:
- 13.08.03, 2.00 revised (kp) Adjust values if out of order/range.
-
enforceBounds
public double enforceBounds(double value)
Constrain value to lie within bounds of this slider.- Parameters:
value- number to be bracketed by allowable range.- Returns:
- number constrained to the allowable range.
- Since:
- JavaView 2.75.000
- See Also:
setValue(double)- Version:
- 25.05.03, 1.00 created (kp)
-
setValue
public void setValue(double value)
Set value of double, and adjust slider if visible. If new value is outside the current bounds, then the bounds are enlarged.This routine called from outside to set the value. Only here we update the panel.
- Version:
- 25.05.03, 1.50 revised (kp) Enlarge bounds if necessary.
-
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.
-
setLineIncr
public void setLineIncr(double lineIncr)
Set line increment of slider.- Since:
- JavaView 2.49.001
- Version:
- 07.01.03, 1.00 created (kp)
-
getPageIncr
public double getPageIncr()
Get block increment of slider. May be interactively modified with config panel.
-
setPageIncr
public void setPageIncr(double pageIncr)
Set block increment of slider.- Since:
- JavaView 2.49.001
- Version:
- 07.01.03, 1.00 created (kp)
-
setBounds
public void setBounds(double min, double max, double lineIncr, double pageIncr)Set current min/max values and slider increments. Adjust value if current value lies outside the new min/max bounds. These bounds will be overridden if instance is reset usinginit().- Parameters:
min- Minimal value in slider, min must be smaller than max.max- Maximal value in slider, min must be smaller than max.lineIncr- Line increment used in slider.pageIncr- Block increment used in slider.- Version:
- 18.12.02, 2.00 revised (kp) Adjust values if out of order/range. 16.06.00, 1.10 revised (ep) Force update of info panel.
-
setBounds
public void setBounds(double min, double max)Set current min/max values and adjust value if current value lies outside the new min/max bounds. These bounds will be overridden if instance is reset usinginit(). Line and block increments of slider are set to default values.- Parameters:
min- Minimal value in slider.max- Maximal value in slider.- Version:
- 28.07.04, 1.10 revised (kp) Increment values synchronized with 10/100 rule.
-
isEnabled
public boolean isEnabled()
Check whether slider is enabled or disabled.
-
showEnabled
public void showEnabled(boolean show)
Toggle whether to show a checkbox in the info panel.- Version:
- 08.10.08, 1.00 created (mn)
-
isShowingEnabled
public boolean isShowingEnabled()
Whether to show a checkbox in the info panel.
-
setEnabled
public void setEnabled(boolean flag)
Enable or disable the slider for interactive use. If disabled, the double variable can still be modified by callssetValue(double), and the slider is always updated.- Version:
- 06.01.02, 1.10 revised (kp) Update all panels instead of directly enabling the info panel only.
-
blend
public void blend(double a, PuDouble v, double b, PuDouble w)Blend with other doubles usingthis = a*v + b*w.
-
setEnabledConfigButton
public void setEnabledConfigButton(boolean flag)
Flag determines whether button for config panel is enabled or not, in this way permitting/prohibiting GUI control over bounds and increments. Bounds and increments can still be changed by method calls.- Since:
- JavaView 2.49.004
-
isEnabledConfigButton
public boolean isEnabledConfigButton()
Flag determines whether button for config panel is enabled or not, in this way permitting/prohibiting GUI control over bounds and increments. Bounds and increments can still be changed by method calls.- Since:
- JavaView 2.49.004
-
getBackground
public java.awt.Color getBackground()
Get color of background of info panel.- Since:
- JavaView 3.50.003
- Version:
- 01.08.04, 1.00 created (kp)
-
setBackground
public void setBackground(java.awt.Color color)
Set color of background of info panel.- Since:
- JavaView 3.50.003
- Version:
- 01.08.04, 1.00 created (kp)
-
parseDouble
public static double parseDouble(java.io.StreamTokenizer st) throws java.io.IOExceptionParse double value in exponential notation. This method tries to catch different settings of character in the StreamTokenizer, but not any situations might be handled correctly.This method first acquires the next token from StreamTokenizer, then analyzes the following token if there is a number in exponential form. If yes, then the number is created in this method, otherwise the second token is pushed back.
The need for this method arise from the special setup of some StreamTokenizers in JavaView where several characters like 'e', 'E', '+', are sometimes marked as word characters.
- Throws:
java.io.IOException- Author:
- Ulrich Reitebuch
- Version:
- 16.09.02, 1.30 revised (kp) Check for '/' added since Maple uses 3/4.
, 27.02.01, 1.21 revised (kp) Throw exception, compress code.
27.02.01, 1.20 revised (ur) Call of st.nextToken() in the beginning added.
07.04.00, 1.10 revised (ur) Bug removed.
16.02.00, 1.00 created (ur).
-
parseDouble
public static double parseDouble(java.lang.String string)
Parse double value in exponential notation using Double(String).doubleValue(). This method is a convenience to avoid catching NumberFormatException.- Author:
- Ulrich Reitebuch
- Version:
- 16.02.00, 1.00 created (ur).
-
-
"