Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Class uk.co.ist.mwt.Scale

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--uk.co.ist.mwt.ShadowedComponent
                    |
                    +--uk.co.ist.mwt.Scale

public class Scale
extends ShadowedComponent
A Scale mimics the Scale capabilities of a Motif XmScale; it does not implement the layout part. If you want a Scale with children a la Motif, use a ScalePanel.

See Also:
Serialized Form

Field Summary
static int kUndefined
          A constant to say that a resource setting is undefined.
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
Scale()
          Creates a scale with a normal shadow thickness
 
Method Summary
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?
int getValue()
          Gets the value of the scale
boolean getVertical()
          Accessor for the current orientation
boolean isMaxTopRight()
          Returns whether the top/right part of the scale is where its maximum value is
void maxTopRightIf(boolean mtr)
          Sets the scale up so that the minimum value is on the right/at the bottom (as appropriate for the orientation).
java.awt.Dimension minimumSize()
          Finds out the smallest possible size for the scale
boolean mouseDown(java.awt.Event e, int x, int y)
          Event handler to start tracking mouse movements on mousedown; decides whether the button press is the start of a drag, or part of a paging action (ie. the user has clicked in the trough)
boolean mouseDrag(java.awt.Event e, int x, int y)
          Handles drags by updating the current value
boolean mouseUp(java.awt.Event e, int x, int y)
          Event handler to work out what to do when the user releases the mouse button; if we were dragging, then set the value to the appropriate value.
void paint(java.awt.Graphics g)
          Draws the scale
java.awt.Dimension preferredSize()
          Finds out the size the scale would like to be
void reshape(int x, int y, int width, int height)
          Changes the size/position of the scale
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 setMinimum(int min)
          Sets the minimum value for the scale
void setMultiple(int mult)
          Sets the multiple's 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 current orientation to vertical (or horizontal, of course)
boolean showingValue()
          Tells you whether this scale is showing its value
void showValueIf(boolean whether)
          Tell the scale to display its current value
 
Methods inherited from class uk.co.ist.mwt.ShadowedComponent
draw3DRect, draw3DRect, draw3DRect, draw3DRect, drawShadow, drawShadow, getBottomShadowColor, getShadowThickness, getTopShadowColor, setBottomShadowColor, setShadowThickness, setTopShadowColor
 
Methods inherited from class java.awt.Canvas
addNotify, paint
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, deliverEvent, disable, dispatchEvent, doLayout, enable, enable, enableInputMethods, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paint, postEvent, preferredSize, prepareImage, prepareImage, printAll, print, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Field Detail

kUndefined

public static final int kUndefined
A constant to say that a resource setting is undefined.
Constructor Detail

Scale

public Scale()
Creates a scale with a normal shadow thickness
Method Detail

setVertical

public void setVertical(boolean vert)
Sets the current orientation to vertical (or horizontal, of course)
See Also:
getVertical

getVertical

public boolean getVertical()
Accessor for the current orientation
Returns:
true if this scale is vertical, false otherwise
See Also:
setVertical

showValueIf

public void showValueIf(boolean whether)
Tell the scale to display its current value
See Also:
setDecimalPoints, #getShowValue

showingValue

public boolean showingValue()
Tells you whether this scale is showing its value
Returns:
true if it is, false otherwise
See Also:
showValueIf

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:
showValueIf

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:
setDecimalPoints

setValue

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

getValue

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

maxTopRightIf

public void maxTopRightIf(boolean mtr)
Sets the scale up so that the minimum value is on the right/at the bottom (as appropriate for the orientation).

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

getMaximum

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

setMinimum

public void setMinimum(int min)
Sets the minimum value for the scale

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.)

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.

reshape

public void reshape(int x,
                    int y,
                    int width,
                    int height)
Changes the size/position of the scale
Overrides:
reshape in class java.awt.Component

paint

public void paint(java.awt.Graphics g)
Draws the scale
Overrides:
paint in class java.awt.Canvas

preferredSize

public java.awt.Dimension preferredSize()
Finds out the size the scale would like to be
Overrides:
preferredSize in class java.awt.Component

minimumSize

public java.awt.Dimension minimumSize()
Finds out the smallest possible size for the scale
Overrides:
minimumSize in class java.awt.Component

mouseDown

public boolean mouseDown(java.awt.Event e,
                         int x,
                         int y)
Event handler to start tracking mouse movements on mousedown; decides whether the button press is the start of a drag, or part of a paging action (ie. the user has clicked in the trough)
Overrides:
mouseDown in class java.awt.Component

mouseUp

public boolean mouseUp(java.awt.Event e,
                       int x,
                       int y)
Event handler to work out what to do when the user releases the mouse button; if we were dragging, then set the value to the appropriate value. If this was just a click, see if we should be moving the scale by a page increment. Otherwise ignore the event.
Overrides:
mouseUp in class java.awt.Component

mouseDrag

public boolean mouseDrag(java.awt.Event e,
                         int x,
                         int y)
Handles drags by updating the current value
Overrides:
mouseDrag in class java.awt.Component

Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD