uk.co.ist.mwt
Class ScalePanel

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--uk.co.ist.mwt.ScalePanel

public class ScalePanel
extends javax.swing.JPanel

The ScalePanel implements the behaviour of a Motif XmScale widget; it is a Panel subclass and can thus take children. If you want to use a simple scale component - that is, one without children - you should use the Scale component

See Also:
Serialized Form

Inner classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
ScalePanel()
          Create a new ScalePanel with default settings (vertical orientation, and default values for the Scale child).
 
Method Summary
protected  void addImpl(java.awt.Component comp, java.lang.Object constraints, int pos)
          Add a component to the Panel; overriden so that any children added are put into the scaleChildPanel.
 java.awt.Component getComponentAt(int x, int y)
          Locate a component; as we're hiding the existence of the internal scaleChildPanel, we must return one of its children if the click is inside it.
 int getDecimalPoints()
          Gets the number of digits to the right of the decimal point if we've decided to show the value
 int getMaximum()
          Gets the maximum value for the scale
 int getMinimum()
          Gets the minimum value for the scale
 int getMultiple()
          What is the multiple's value? (The multiple is the amount (in terms of the maximum and minimum values) that the scale will move its thumb when a non-thumb place in the scale is clicked.) Because the multiple, if it has never been set, is dynamically calculated, all access to it should be through this method - even from inside this class.
 boolean getShowValue()
          Are we showing the scale's value at the moment?
 int getValue()
          Gets the value of the scale
 boolean isMaxTopRight()
          Returns whether the top/right part of the scale is where its maximum value is
 boolean isVertical()
          Gets the Scale's orientation
 void remove(java.awt.Component comp)
          Remove a component from the panel; overriden so that any children are removed from the scaleChildPanel.
 void removeAll()
          Remove all components from the panel; actually removes those from the scaleChildPanel.
 void setDecimalPoints(int dp)
          Sets the number of digits to the right of the decimal point if we've decided to show the value
 void setMaximum(int max)
          Sets the maximum value for the scale
 void setMaxTopRight(boolean mtr)
          Sets the scale up so that the minimum value is on the right/at the top (as appropriate for the orientation).
 void setMinimum(int min)
          Sets the minimum value for the scale
 void setMultiple(int mult)
          Sets the multiple's value.
 void setShowValue(boolean whether)
          Tell the scale to display its current value
 void setValue(int val)
          Sets the current value of the scale, rounded up or down to the minimum or maximum if appropriate
 void setVertical(boolean vert)
          Sets the Scale's orientation, and reorganise the children of this panel to reflect this.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUIClassID, paramString, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, processComponentKeyEvent, processFocusEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, removeContainerListener, setCursor, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hide, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ScalePanel

public ScalePanel()
Create a new ScalePanel with default settings (vertical orientation, and default values for the Scale child).
Method Detail

setVertical

public void setVertical(boolean vert)
Sets the Scale's orientation, and reorganise the children of this panel to reflect this.
Parameters:
vert - if true, set the orientation to vertical; if false, set orientation to horizontal.

isVertical

public boolean isVertical()
Gets the Scale's orientation
Returns:
true if the scale is vertical, false if otherwise

setShowValue

public void setShowValue(boolean whether)
Tell the scale to display its current value
Parameters:
whether - if true, the value will be displayed; if false, it won't
See Also:
setDecimalPoints(int), getShowValue()

getShowValue

public boolean getShowValue()
Are we showing the scale's value at the moment?
Returns:
true if we are, false otherwise
See Also:
setShowValue(boolean)

setDecimalPoints

public void setDecimalPoints(int dp)
Sets the number of digits to the right of the decimal point if we've decided to show the value
See Also:
setShowValue(boolean), getDecimalPoints()

getDecimalPoints

public int getDecimalPoints()
Gets the number of digits to the right of the decimal point if we've decided to show the value
See Also:
setShowValue(boolean), setDecimalPoints(int)

setValue

public void setValue(int val)
Sets the current value of the scale, rounded up or down to the minimum or maximum if appropriate
Parameters:
val - the new value
See Also:
getValue()

getValue

public int getValue()
Gets the value of the scale
Returns:
the value
See Also:
setValue(int)

setMaxTopRight

public void setMaxTopRight(boolean mtr)
Sets the scale up so that the minimum value is on the right/at the top (as appropriate for the orientation).
Parameters:
mtr - true to set the maximum value to the right or top, false for the maximum at the bottom or left.

isMaxTopRight

public boolean isMaxTopRight()
Returns whether the top/right part of the scale is where its maximum value is
Returns:
true if the maximum is in the top or right, false otherwise

setMaximum

public void setMaximum(int max)
Sets the maximum value for the scale
Parameters:
max - the new maximum

getMaximum

public int getMaximum()
Gets the maximum value for the scale

setMinimum

public void setMinimum(int min)
Sets the minimum value for the scale
Parameters:
min - the new minimum

getMinimum

public int getMinimum()
Gets the minimum value for the scale

setMultiple

public void setMultiple(int mult)
Sets the multiple's value. (The multiple is the amount (in terms of the maximum and minimum values) that the scale will move its thumb when a non-thumb place in the scale is clicked.)
Parameters:
mult - the new multiple

getMultiple

public int getMultiple()
What is the multiple's value? (The multiple is the amount (in terms of the maximum and minimum values) that the scale will move its thumb when a non-thumb place in the scale is clicked.) Because the multiple, if it has never been set, is dynamically calculated, all access to it should be through this method - even from inside this class.
Returns:
the multiple for this scale

addImpl

protected void addImpl(java.awt.Component comp,
                       java.lang.Object constraints,
                       int pos)
Add a component to the Panel; overriden so that any children added are put into the scaleChildPanel.
Overrides:
addImpl in class java.awt.Container
Parameters:
comp - the component to add
constraints - any constraints specified
pos - the position in the list of children at which to add it; -1 means 'at the end'.

remove

public void remove(java.awt.Component comp)
Remove a component from the panel; overriden so that any children are removed from the scaleChildPanel.
Overrides:
remove in class java.awt.Container
Parameters:
comp - the component to remove

removeAll

public void removeAll()
Remove all components from the panel; actually removes those from the scaleChildPanel.
Overrides:
removeAll in class java.awt.Container

getComponentAt

public java.awt.Component getComponentAt(int x,
                                         int y)
Locate a component; as we're hiding the existence of the internal scaleChildPanel, we must return one of its children if the click is inside it.
Overrides:
getComponentAt in class java.awt.Container
Parameters:
x - the x co-ordinate within this component which the desired component contains
y - the y co-ordinate within this component which the desired component contains