public final class PuDouble extends PsObject
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;
}
}
}
PuInteger
,
Serialized FormHAS_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 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.
|
Modifier and Type | Method and Description |
---|---|
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 |
enforceBounds(double value)
Constrain value to lie within bounds of this slider.
|
java.awt.Color |
getBackground()
Get color of background of info panel.
|
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 |
getDefValue()
Get the default value which is 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.
|
void |
initWithDefaults(double min,
double max,
double lineIncr,
double pageIncr,
double defValue)
Sets the default values for this component and initializes it.
|
boolean |
isEnabled()
Check whether slider is enabled or disabled.
|
boolean |
isEnabledConfigButton()
Flag determines whether button for config panel is enabled or not,
in this way permitting/prohibiting GUI control over bounds and increments.
|
boolean |
isShowingEnabled()
Whether to show a checkbox in the info panel.
|
static double |
parseDouble(java.io.StreamTokenizer st)
Parse double value in exponential notation.
|
static double |
parseDouble(java.lang.String string)
Parse double value in exponential notation using Double(String).doubleValue().
|
void |
setBackground(java.awt.Color color)
Set color of background of info panel.
|
void |
setBounds(double min,
double max)
Set current min/max values and adjust value if current value lies outside
the new min/max bounds.
|
void |
setBounds(double min,
double max,
double lineIncr,
double pageIncr)
Set current min/max values and slider increments.
|
void |
setDefBounds(double min,
double max,
double lineIncr,
double pageIncr)
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 |
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.
|
void |
setLineIncr(double lineIncr)
Set line increment of slider.
|
void |
setPageIncr(double pageIncr)
Set block increment of slider.
|
void |
setValue(double value)
Set value of double, and adjust slider if visible.
|
void |
showEnabled(boolean show)
Toggle whether to show a checkbox in the info panel.
|
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
public PuDouble(java.lang.String name)
In order to receive update events of this slider one might either assign a parent or register an update listener.
name
- Name of double to appear as label in slider.public PuDouble(java.lang.String name, PsUpdateIf parent)
parent.update(this)
.name
- Name of double to appear as label in slider.parent
- Parent of double to receive update events.public void init()
public void initWithDefaults(double min, double max, double lineIncr, double pageIncr, double defValue)
public void copy(PuDouble num)
public double getDefValue()
setDefValue(double)
,
getValue()
public void setDefValue(double value)
init()
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.
public double getDefMinimum()
public double getDefMaximum()
public double getDefLineIncr()
public double getDefPageIncr()
public void setDefBounds(double min, double max, double lineIncr, double pageIncr)
init()
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.
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.public double enforceBounds(double value)
value
- number to be bracketed by allowable range.setValue(double)
public void setValue(double value)
This routine called from outside to set the value. Only here we update the panel.
public double getValue()
public double getMin()
public double getMax()
public double getLineIncr()
public void setLineIncr(double lineIncr)
public double getPageIncr()
public void setPageIncr(double pageIncr)
public void setBounds(double min, double max, double lineIncr, double pageIncr)
init()
.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.public void setBounds(double min, double max)
init()
.
Line and block increments of slider are set to default values.min
- Minimal value in slider.max
- Maximal value in slider.public boolean isEnabled()
public void showEnabled(boolean show)
public boolean isShowingEnabled()
public void setEnabled(boolean flag)
setValue(double)
, and the slider
is always updated.public void blend(double a, PuDouble v, double b, PuDouble w)
this = a*v + b*w
.public void setEnabledConfigButton(boolean flag)
public boolean isEnabledConfigButton()
public java.awt.Color getBackground()
public void setBackground(java.awt.Color color)
public static double parseDouble(java.io.StreamTokenizer st) throws java.io.IOException
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.
java.io.IOException
public static double parseDouble(java.lang.String string)
"