ago.beans
Class AgoSlider

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--ago.beans.AgoSlider
All Implemented Interfaces:
Colorable, java.util.EventListener, java.awt.event.FocusListener, Gradientable, java.awt.image.ImageObserver, java.awt.event.KeyListener, java.awt.MenuContainer, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.io.Serializable

public class AgoSlider
extends javax.swing.JComponent
implements java.awt.event.MouseMotionListener, java.awt.event.MouseListener, Gradientable, java.awt.event.MouseWheelListener, java.awt.event.KeyListener, java.awt.event.FocusListener, Colorable

Cool Slider for editing color, or numbers from [0..1]

Version:
1.0
Author:
Arcadiy Gobuzov
See Also:
Serialized Form

Field Summary
static int COLOR
          CONSTANT for thumbMode
static java.lang.String icon16
          filename of 16x16 color icon.
static int IMAGE
          CONSTANT for track mode
static int NOIMAGE
          CONSTANT for track mode
static int OVAL
          CONSTANT for shape of thumb
static int PENTAGON
          CONSTANT for shape of thumb
static int PENTAGON2
          CONSTANT for shape of thumb
static int RECTANGLE
          CONSTANT for shape of thumb
static int RHOMBUS
          CONSTANT for shape of thumb
static int SOLID
          CONSTANT for thumbMode
static int TRANS
          CONSTANT for thumbMode
static int TRIANGLE
          CONSTANT for shape of thumb
static int TRIANGLE2
          CONSTANT for shape of thumb
 
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
AgoSlider()
          default constructor.
 
Method Summary
 void addActionListener(java.awt.event.ActionListener a)
          register ActionListener, which listen ActionEvents.
 void addChangeListener(javax.swing.event.ChangeListener c)
          register ChangeListener, which listen ChangeEvents.
 void focusGained(java.awt.event.FocusEvent fe)
          focus listener method
 void focusLost(java.awt.event.FocusEvent fe)
          focus listener method
 java.lang.String getAbout()
          Application code will not use these methods explicitly.
 java.awt.Color getColor()
          color's getter
 ago.beans.Gradient getGradient()
          Gradient's getter
 int getMode()
           
 int getShape()
           
 int getThickness()
           
 int getThumbHeight()
           
 int getThumbMode()
           
 int getThumbs()
           
 int getThumbWidth()
           
 float getValue()
           
 float[] getValues()
           
 boolean isHorizontal()
           
 void keyPressed(java.awt.event.KeyEvent e)
          realization of KeyListener interface.
 void keyReleased(java.awt.event.KeyEvent e)
          realized without noname classes, coz need to reduce jar size.
 void keyTyped(java.awt.event.KeyEvent e)
          realization of KeyListener interface.
 void mouseClicked(java.awt.event.MouseEvent event)
          realization of MouseListener interface
 void mouseDragged(java.awt.event.MouseEvent event)
          realization of MouseMotionListener interface realized without noname classes, coz need to reduce jar size
 void mouseEntered(java.awt.event.MouseEvent mouseevent)
          realization of MouseListener interface
 void mouseExited(java.awt.event.MouseEvent mouseevent)
          realization of MouseListener interface
 void mouseMoved(java.awt.event.MouseEvent event)
          realization of MouseMotionListener interface
 void mousePressed(java.awt.event.MouseEvent event)
          realization of MouseListener interface realized without noname classes, coz need to reduce jar size
 void mouseReleased(java.awt.event.MouseEvent mouseevent)
          realization of MouseListener interface
 void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
          realization of MouseWheelListener interface.
 void paintComponent(java.awt.Graphics g)
           
 void removeActionListener(java.awt.event.ActionListener a)
           
 void removeChangeListener(javax.swing.event.ChangeListener c)
           
 void setAbout(java.lang.String s)
          Application code will not use these methods explicitly.
 void setColor(java.awt.Color c)
          in fact application code will not use this method explicitly.
 void setGradient(ago.beans.Gradient g)
          Gradient's setter
 void setHorizontal(boolean b)
           
 void setHue()
          setup Hue-line as image
 void setMode(int i)
           
 void setShape(int i)
           
 void setThickness(int i)
           
 void setThumbHeight(int height)
           
 void setThumbMode(int i)
           
 void setThumbs(int n)
          set thumb's quantity & init values by default
 void setThumbWidth(int width)
           
 void setValue(float f)
           
 void setValues(float[] values)
           
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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

icon16

public static final java.lang.String icon16
filename of 16x16 color icon.

See Also:
Constant Field Values

SOLID

public static final int SOLID
CONSTANT for thumbMode

See Also:
Constant Field Values

TRANS

public static final int TRANS
CONSTANT for thumbMode

See Also:
Constant Field Values

COLOR

public static final int COLOR
CONSTANT for thumbMode

See Also:
Constant Field Values

NOIMAGE

public static final int NOIMAGE
CONSTANT for track mode

See Also:
Constant Field Values

IMAGE

public static final int IMAGE
CONSTANT for track mode

See Also:
Constant Field Values

OVAL

public static final int OVAL
CONSTANT for shape of thumb

See Also:
Constant Field Values

RHOMBUS

public static final int RHOMBUS
CONSTANT for shape of thumb

See Also:
Constant Field Values

TRIANGLE2

public static final int TRIANGLE2
CONSTANT for shape of thumb

See Also:
Constant Field Values

TRIANGLE

public static final int TRIANGLE
CONSTANT for shape of thumb

See Also:
Constant Field Values

RECTANGLE

public static final int RECTANGLE
CONSTANT for shape of thumb

See Also:
Constant Field Values

PENTAGON

public static final int PENTAGON
CONSTANT for shape of thumb

See Also:
Constant Field Values

PENTAGON2

public static final int PENTAGON2
CONSTANT for shape of thumb

See Also:
Constant Field Values
Constructor Detail

AgoSlider

public AgoSlider()
default constructor. One thumb, value = 0, preferredSize =24x24 default gradient, enabled

Method Detail

setHue

public void setHue()
setup Hue-line as image


setAbout

public void setAbout(java.lang.String s)
Application code will not use these methods explicitly.


getAbout

public java.lang.String getAbout()
Application code will not use these methods explicitly.


getThumbWidth

public int getThumbWidth()
Returns:
width of thumb in pixels

setThumbWidth

public void setThumbWidth(int width)
Parameters:
width - width of thumb (3..25 - limitations)

getThumbHeight

public int getThumbHeight()
Returns:
height of thumb in pixels

setThumbHeight

public void setThumbHeight(int height)
Parameters:
height - height of thumb (3..25 - limitations)

getShape

public int getShape()
Returns:
shape of slider's thumb (see CONSTANTS)

setShape

public void setShape(int i)
Parameters:
i - - shape of slider's thumb (see CONSTANTS, describe shapes)

getMode

public int getMode()
Returns:
mode of slider's track (IMAGE/ NOIMAGE)

setMode

public void setMode(int i)
Parameters:
i - mode of slider's track (IMAGE/ NOIMAGE)

getThumbMode

public int getThumbMode()
Returns:
mode of slider's thumb (SOLID/ TRANS/ COLOR)

setThumbMode

public void setThumbMode(int i)
Parameters:
i - mode of slider's thumb (SOLID/ TRANS/ COLOR)

getThickness

public int getThickness()
Returns:
thickness of slider's track (height for horizontal, width for vertical)

setThickness

public void setThickness(int i)
Parameters:
i - thickness of slider's track (height for horizontal, width for vertical)

isHorizontal

public boolean isHorizontal()
Returns:
true - horizontal orientation, false - vertical

setHorizontal

public void setHorizontal(boolean b)
Parameters:
b - true - horizontal orientation, false - vertical

getThumbs

public int getThumbs()
Returns:
numbers of thumbs

setThumbs

public void setThumbs(int n)
set thumb's quantity & init values by default

Parameters:
n - - quantity of thumbs

getGradient

public ago.beans.Gradient getGradient()
Description copied from interface: Gradientable
Gradient's getter

Specified by:
getGradient in interface Gradientable
Returns:
gradient of slider (if any)

setGradient

public void setGradient(ago.beans.Gradient g)
Description copied from interface: Gradientable
Gradient's setter

Specified by:
setGradient in interface Gradientable
Parameters:
g - gradient for slider. Will visible only in IMAGE mode

getColor

public java.awt.Color getColor()
Description copied from interface: Colorable
color's getter

Specified by:
getColor in interface Colorable
Returns:
selected color if IMAGE mode, null if NOIMAGE

setColor

public void setColor(java.awt.Color c)
in fact application code will not use this method explicitly. Just realization of Colorable interface

Specified by:
setColor in interface Colorable
Parameters:
c - color

getValue

public float getValue()
Returns:
values[0] even if slider have more than one thumb

setValue

public void setValue(float f)
Parameters:
f - value for values[0], sets only if one thumb

getValues

public float[] getValues()
Returns:
values, even if slider have one thumb

setValues

public void setValues(float[] values)
Parameters:
values - values for thumbs positions. must to be in[0..1]

paintComponent

public void paintComponent(java.awt.Graphics g)
Overrides:
paintComponent in class javax.swing.JComponent
Parameters:
g - graphics where draw

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent event)
realization of MouseMotionListener interface realized without noname classes, coz need to reduce jar size

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
Parameters:
event - mouse event

mousePressed

public void mousePressed(java.awt.event.MouseEvent event)
realization of MouseListener interface realized without noname classes, coz need to reduce jar size

Specified by:
mousePressed in interface java.awt.event.MouseListener
Parameters:
event - mouse event

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent event)
realization of MouseListener interface

Specified by:
mouseClicked in interface java.awt.event.MouseListener
Parameters:
event - mouse event

mouseExited

public void mouseExited(java.awt.event.MouseEvent mouseevent)
realization of MouseListener interface

Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent mouseevent)
realization of MouseListener interface

Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent mouseevent)
realization of MouseListener interface

Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent event)
realization of MouseMotionListener interface

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
Parameters:
event - mouse event

mouseWheelMoved

public void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
realization of MouseWheelListener interface. One of causes why need Java 1.4 realized without noname classes, coz need to reduce jar size

Specified by:
mouseWheelMoved in interface java.awt.event.MouseWheelListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
realized without noname classes, coz need to reduce jar size. Realization of KeyListener interface.

Specified by:
keyReleased in interface java.awt.event.KeyListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
realization of KeyListener interface.

Specified by:
keyTyped in interface java.awt.event.KeyListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
realization of KeyListener interface.

Specified by:
keyPressed in interface java.awt.event.KeyListener

addChangeListener

public void addChangeListener(javax.swing.event.ChangeListener c)
register ChangeListener, which listen ChangeEvents. Events occurring, when user move mouse/mousewheel/key

Parameters:
c - ChangeListener for slider

removeChangeListener

public void removeChangeListener(javax.swing.event.ChangeListener c)
Parameters:
c - ChangeListener to remove

addActionListener

public void addActionListener(java.awt.event.ActionListener a)
register ActionListener, which listen ActionEvents. Events occurring, when user type/move mouse/mousewheel/key


removeActionListener

public void removeActionListener(java.awt.event.ActionListener a)
Parameters:
a - ActionListener to remove

focusLost

public void focusLost(java.awt.event.FocusEvent fe)
focus listener method

Specified by:
focusLost in interface java.awt.event.FocusListener

focusGained

public void focusGained(java.awt.event.FocusEvent fe)
focus listener method

Specified by:
focusGained in interface java.awt.event.FocusListener