JavaView® v2.00.008

jv.number
Class PuInteger

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

public final class PuInteger
extends PsObject

Basic integer class with update functionality and panel containing a slider. This class may always be used when a integer 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  PuInteger  m_length;
		public PjExprOde() {
			// Create a new instance of PuInteger and register 'this' as parent
			// to receive update events whenever user has modified the slider.
			m_length		= new PuInteger("Length", this);
			init();
		}
		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, 1, 10);
			// 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:
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

Field Summary
protected  boolean m_enabled
          Flag determining whether slider is enabled or disabled. modified using the config panel.
protected  int m_lineIncr
          Line increment as integer value supplied by user.
protected  int m_maximum
          Maximal allowed value of integer variable.
protected  int m_minimum
          Minimal allowed value of integer variable.
protected  int m_pageIncr
          Block increment as integer value supplied by user.
protected  int m_value
          Current value of integer variable.
 
Fields inherited from class jv.object.PsObject
HAS_CONFIG_PANEL, HAS_INFO_PANEL, HAS_MATERIAL_PANEL, INSPECTOR_INFO, INSPECTOR_INFO_EXT, IS_DELETED, IS_FIXED, IS_SELECTED, IS_USED, m_infoPanel, m_name, m_panelList, m_parent, m_tag, m_updateList, NUM_TAGS
 
Constructor Summary
PuInteger(java.lang.String aName, PsUpdateIf aParent)
          Create new instance with given name and parent.
 
Method Summary
 void copy(PuInteger num)
          Copy all instance variables of argument source into 'this'.
 int getLineIncr()
          Get line increment of slider.
 int getMax()
          Get maximal value allowed in slider.
 int getMin()
          Get minimal value allowed in slider.
 int getPageIncr()
          Get block increment of slider.
 int getValue()
          Get current integer value.
protected  void incrValue(int units)
          This routine is called from scrollbar's scrolling events here we do not need to update the panel.
 void init()
          Assign default values, and may be used to reset instance.
 boolean isEnabled()
          Check whether slider is enabled or disabled.
 void setBounds(int aMin, int aMax)
          Set current min/max values and adjust value if current value lies outside the new min/max bounds.
 void setBounds(int aMin, int aMax, int aLineIncr, int aPageIncr)
          Set current min/max values and slider increments.
 void setDefBounds(int aMin, int aMax, int aLineIncr, int aPageIncr)
          Set default min/max values and slider increments to be assigned when init() is called as reset.
 void setDefValue(int 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(int aValue)
          Set value of integer, and adjust slider if visible.
protected  void setValueFromPanel(int aValue, java.lang.Object event)
          Set value of integer, but do not adjust slider.
 boolean update(java.lang.Object anObject)
          Catch update events sent from info panel.
 
Methods inherited from class jv.object.PsObject
addInspector, addUpdateListener, 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, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_value

protected int m_value
Current value of integer variable.

m_minimum

protected int m_minimum
Minimal allowed value of integer variable. Used as lower bound in slider.

m_maximum

protected int m_maximum
Maximal allowed value of integer variable. Used as upper bound in slider.

m_lineIncr

protected int m_lineIncr
Line increment as integer value supplied by user. May be interactively modified using the config panel.

m_pageIncr

protected int m_pageIncr
Block increment as integer value supplied by user. May be interactively modified using the config panel.

m_enabled

protected boolean m_enabled
Flag determining whether slider is enabled or disabled. modified using the config panel. If disabled, the integer variable can still be modified by calls setValue(integer), and the slider is always updated.
Constructor Detail

PuInteger

public PuInteger(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 integer to appear as label in slider.
aParent - Parent of integer 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(PuInteger num)
Copy all instance variables of argument source into 'this'.

setDefValue

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

setDefBounds

public void setDefBounds(int aMin,
                         int aMax,
                         int aLineIncr,
                         int aPageIncr)
Set default min/max values and slider increments to be assigned when init() is called as reset.

setValue

public void setValue(int aValue)
Set value of integer, and adjust slider if visible. This routine called from outside to set the value. Only here we update the panel.

incrValue

protected void incrValue(int units)
This routine is called from scrollbar's scrolling events here we do not need to update the panel.

setValueFromPanel

protected void setValueFromPanel(int aValue,
                                 java.lang.Object event)
Set value of integer, but do not adjust slider. This routine is called from scrollbar's text field.

getValue

public int getValue()
Get current integer value.

getMin

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

getMax

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

getLineIncr

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

getPageIncr

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

setBounds

public void setBounds(int aMin,
                      int aMax,
                      int aLineIncr,
                      int 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(int aMin,
                      int 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 integer variable can still be modified by calls setValue(integer), 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)

JavaView® v2.00.008

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