CADI.Viewer.Util
Class SliderAndSpinnerPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by CADI.Viewer.Util.SliderAndSpinnerPanel
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class SliderAndSpinnerPanel
extends javax.swing.JPanel

This class creates a JPanel with a JSlider and a JSpinner.

Version:
1.0 2007/12/07
Author:
Group on Interactive Coding of Images (GICI)
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
(package private)  boolean changed
          Used to pass information between the slider and the spinner objects.
private  java.lang.String label
          The panel's label.
private  int max
          The maximum allowed value
private  int min
          The minimum allowed value.
private  javax.swing.JSlider slider
          The slider object.
private  javax.swing.JSpinner spinner
          The spinner object.
private  int stepSize
          The difference between two consecutive values.
private  int value
          The current value.
private  int width
          Width of the panel.
 
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
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
SliderAndSpinnerPanel(java.lang.String label, int min, int max, int value, int stepSize, int width)
          Constructor.
 
Method Summary
private  void createPanel()
          Creates and locates the slicder and the spinner.
 int getMaximum()
          Returns the maximum value supported by the panel.
 int getMinimum()
          Returns the minimum value supported by the panel.
 int getStepSize()
          Returns the size of the value change..
 int getValue()
          Returns the current value.
 void setEnabled(boolean enabled)
           
 void setLabelTable(int labels)
           
 void setMajorTickSpacing(int majorTick)
           
 void setMaximum(int maximum)
          Sets the maximum value to maximum.
 void setMinimum(int minimum)
          Sets the minimum value to minimum.
 void setMinorTickSpacing(int minorTick)
           
 void setRangeProperties(int min, int max, int value, int stepSize)
          Sets the panel properties.
 void setSnapToTicks(boolean b)
          Definition in JSlider.setSnapToTicks(boolean).
 void setStepSize(int stepSize)
          Sets the step size value to stepSize.
 void setValue(int n)
          Sets the current value to n.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

label

private java.lang.String label
The panel's label.


min

private int min
The minimum allowed value.


max

private int max
The maximum allowed value


value

private int value
The current value.


stepSize

private int stepSize
The difference between two consecutive values.


width

private int width
Width of the panel.


slider

private javax.swing.JSlider slider
The slider object.


spinner

private javax.swing.JSpinner spinner
The spinner object.


changed

boolean changed
Used to pass information between the slider and the spinner objects.

Constructor Detail

SliderAndSpinnerPanel

public SliderAndSpinnerPanel(java.lang.String label,
                             int min,
                             int max,
                             int value,
                             int stepSize,
                             int width)
Constructor.

Parameters:
label - the panel name.
min - the minimum value of the slider.
max - the maximum value of the slider.
value - the initial value of the slider.
stepSize - the difference between elements of the sequence.
Throws:
java.lang.IllegalArgumentException - if the following expression is false: minimum <= value <= maximum
Method Detail

setMinimum

public void setMinimum(int minimum)
Sets the minimum value to minimum.

Parameters:
minimum - the new minimum.
Throws:
java.lang.IllegalArgumentException - if the minimum is greather than the maximum.

setRangeProperties

public void setRangeProperties(int min,
                               int max,
                               int value,
                               int stepSize)
Sets the panel properties.

Parameters:
min - the minimum value of the slider.
max - the maximum value of the slider.
value - the initial value of the slider.
stepSize - the difference between elements of the sequence.
Throws:
java.lang.IllegalArgumentException - if the following expression is false: minimum <= value <= maximum.

setMaximum

public void setMaximum(int maximum)
Sets the maximum value to maximum.

Parameters:
maximum - the new maximum.
Throws:
java.lang.IllegalArgumentException - if the minimum is greather than the maximum.

setValue

public void setValue(int n)
Sets the current value to n.

Parameters:
n - the new minimum.
Throws:
java.lang.IllegalArgumentException - if the value is not between the minimum and the maximum.

setStepSize

public void setStepSize(int stepSize)
Sets the step size value to stepSize.

Parameters:
stepSize - the new stepSize.

getMinimum

public int getMinimum()
Returns the minimum value supported by the panel.

Returns:
the minimum value.

getMaximum

public int getMaximum()
Returns the maximum value supported by the panel.

Returns:
the maximum value.

getValue

public int getValue()
Returns the current value.

Returns:
the current value.

getStepSize

public int getStepSize()
Returns the size of the value change..

Returns:
the value of the stepSize property.

setEnabled

public void setEnabled(boolean enabled)
Overrides:
setEnabled in class javax.swing.JComponent

setSnapToTicks

public void setSnapToTicks(boolean b)
Definition in JSlider.setSnapToTicks(boolean).


setMajorTickSpacing

public void setMajorTickSpacing(int majorTick)

setMinorTickSpacing

public void setMinorTickSpacing(int minorTick)

setLabelTable

public void setLabelTable(int labels)

createPanel

private void createPanel()
Creates and locates the slicder and the spinner.



CADI - Copyright (C) 2007
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Group on Interactive Coding of Images (GICI) (contact)