Documentation of 'kcl.waterloo.widget.GJDial' Java class
GJDial
kcl.waterloo.widget

Class GJDial

  • All Implemented Interfaces:
    java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.SwingConstants
    Direct Known Subclasses:
    GJGauge


    public class GJDial
    extends javax.swing.JSlider
    implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.beans.PropertyChangeListener

    GJDial is a subclass of the standard swing JSlider.

    GJDial provides a rotating dial instead of a slider to change the settings of the widget. By default the dial covers the range between the minimum and maximum in a single turn - equivalent to the sweep length of the JSlider. However, the number of turns available can be set programmatically using the setAvailableTurns method, e.g. with setAvailableTurns(10) the each rotation would cover 1/10th of the range of the GJDial.

    Dials are circular and will be drawn at the center of the GJDial's bounds with a diameter determined from the lesser of the width and the height - so it makes sense generally to specify square sizes.

    The following methods are specific to GJDial or have been overridden.

    getTurnCount - returns the number of turns made

    getValue - returns the value calculated from the current dial settings.

    The following also have suitable getters.

    setAvailableTurns(int) - sets the number of turns for the dial

    setDisplayValue(true/false) provides a text display of the value in the center of the dial

    setLineColor(Color/Paint) - sets the line color

    setFill(Color/Paint) - sets the fill color for the dial

    setMajorTickSpacing(int n) - displays n major ticks around the dial

    setMinorTickSpacing(int n) - displays n minor ticks around the dial

    setText(String) provides a JLabel with the specified string in the center of the dial

    setValue(int) - positions the dial (and internal settings as appropriate)

    Other JSlider methods, e.g. setMinimum and setMaximum act as you would expect or are ignored e.g. setExtent so a GJDial should work as a drop-in replacement for a JSlider.

    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class and Description
      static class  GJDial.BasicGJDialUI 
      • Nested classes/interfaces inherited from class javax.swing.JComponent

        javax.swing.JComponent.AccessibleJComponent
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.BaselineResizeBehavior
    • Field Summary

      • Fields inherited from class javax.swing.JComponent

        TOOL_TIP_TEXT_KEY, 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 javax.swing.SwingConstants

        BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
      • Fields inherited from interface java.awt.image.ImageObserver

        ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
    • Constructor Summary

      Constructors 
      Constructor and Description
      GJDial()
      Default constructor returns a 100x100 pixel single turn GJDial with no display of the value and no JLabel text
      GJDial(int diameter, int n)
      Constructor returns a GjDial with no display of the value and no JLabel text
      GJDial(int diameter, int n, boolean flag)
      Constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void addActionListener(java.awt.event.ActionListener listener) 
      java.awt.Paint getFill()
      Sets the fill for the dial
      java.awt.Color getLineColor() 
      java.lang.String getText()
      Returns the JLabel's text
      double getTheta() 
      int getTurnCount()
      Returns the number of turns made - by mouse or programmatically via setValue
      GJDial.BasicGJDialUI getUI()
      java.lang.String getUIClassID()
      int getValue()
      boolean isDisplayValue()
      Determines if values will be displayed at the center of the dial
      void mouseClicked(java.awt.event.MouseEvent me) 
      void mouseDragged(java.awt.event.MouseEvent me) 
      void mouseEntered(java.awt.event.MouseEvent me) 
      void mouseExited(java.awt.event.MouseEvent me) 
      void mouseMoved(java.awt.event.MouseEvent me) 
      void mousePressed(java.awt.event.MouseEvent me) 
      void mouseReleased(java.awt.event.MouseEvent me) 
      void paintComponent(java.awt.Graphics g)
      void propertyChange(java.beans.PropertyChangeEvent evt) 
      void setDisplayValue(boolean flag)
      Displays the current value at the center of the dial
      void setFill(java.awt.Paint p)
      Returns the fill for the dial
      void setLineColor(java.awt.Color LineColor) 
      void setMaximum(int val)
      void setMinimum(int val)
      void setText(java.lang.String str)
      Sets the text for a JLabel displayed at the center of the dial.
      void setValue(int val)
      void updateUI()
      • Methods inherited from class javax.swing.JSlider

        addChangeListener, createStandardLabels, createStandardLabels, getAccessibleContext, getChangeListeners, getExtent, getInverted, getLabelTable, getMajorTickSpacing, getMaximum, getMinimum, getMinorTickSpacing, getModel, getOrientation, getPaintLabels, getPaintTicks, getPaintTrack, getSnapToTicks, getValueIsAdjusting, imageUpdate, removeChangeListener, setExtent, setFont, setInverted, setLabelTable, setMajorTickSpacing, setMinorTickSpacing, setModel, setOrientation, setPaintLabels, setPaintTicks, setPaintTrack, setSnapToTicks, setUI, setValueIsAdjusting
      • Methods inherited from class javax.swing.JComponent

        addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, 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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
      • Methods inherited from class java.awt.Container

        add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate
      • Methods inherited from class java.awt.Component

        action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, 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, 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, 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, transferFocusBackward, transferFocusUpCycle
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • GJDial

        public GJDial()
        Default constructor returns a 100x100 pixel single turn GJDial with no display of the value and no JLabel text
      • GJDial

        public GJDial(int diameter,
                      int n)
        Constructor returns a GjDial with no display of the value and no JLabel text
        Parameters:
        diameter - diameter of the GJDial in pixels
        n - number of available turns
      • GJDial

        public GJDial(int diameter,
                      int n,
                      boolean flag)
        Constructor
        Parameters:
        diameter - diameter of the GJDial in pixels
        n - number of available turns
        flag - true to display the values as text
    • Method Detail

      • addActionListener

        public void addActionListener(java.awt.event.ActionListener listener)
      • setMinimum

        public void setMinimum(int val)
        Overrides:
        setMinimum in class javax.swing.JSlider
        Parameters:
        val -
      • setMaximum

        public void setMaximum(int val)
        Overrides:
        setMaximum in class javax.swing.JSlider
        Parameters:
        val -
      • getValue

        public int getValue()
        Overrides:
        getValue in class javax.swing.JSlider
        Returns:
        the current value of the dial.
      • setValue

        public void setValue(int val)
        Overrides:
        setValue in class javax.swing.JSlider
        Parameters:
        val -
      • getUI

        public GJDial.BasicGJDialUI getUI()
        Overrides:
        getUI in class javax.swing.JSlider
        Returns:
      • updateUI

        public final void updateUI()
        Overrides:
        updateUI in class javax.swing.JSlider
      • getUIClassID

        public java.lang.String getUIClassID()
        Overrides:
        getUIClassID in class javax.swing.JSlider
        Returns:
      • getFill

        public java.awt.Paint getFill()
        Sets the fill for the dial
        Returns:
        the Paint object
      • setFill

        public void setFill(java.awt.Paint p)
        Returns the fill for the dial
        Parameters:
        p - the Paint object e.g. a Color
      • getTheta

        public double getTheta()
      • getTurnCount

        public int getTurnCount()
        Returns the number of turns made - by mouse or programmatically via setValue
        Returns:
      • setText

        public void setText(java.lang.String str)
        Sets the text for a JLabel displayed at the center of the dial. Note that this will overlap displayed values if isDisplayValuetrue,/code>.
        Parameters:
        str -
      • getText

        public java.lang.String getText()
        Returns the JLabel's text
        Returns:
      • setDisplayValue

        public void setDisplayValue(boolean flag)
        Displays the current value at the center of the dial
        Parameters:
        flag -
      • isDisplayValue

        public boolean isDisplayValue()
        Determines if values will be displayed at the center of the dial
        Returns:
      • paintComponent

        public void paintComponent(java.awt.Graphics g)
        Overrides:
        paintComponent in class javax.swing.JComponent
        Parameters:
        g -
      • mouseClicked

        public void mouseClicked(java.awt.event.MouseEvent me)
        Specified by:
        mouseClicked in interface java.awt.event.MouseListener
      • mousePressed

        public void mousePressed(java.awt.event.MouseEvent me)
        Specified by:
        mousePressed in interface java.awt.event.MouseListener
      • mouseReleased

        public void mouseReleased(java.awt.event.MouseEvent me)
        Specified by:
        mouseReleased in interface java.awt.event.MouseListener
      • mouseEntered

        public void mouseEntered(java.awt.event.MouseEvent me)
        Specified by:
        mouseEntered in interface java.awt.event.MouseListener
      • mouseExited

        public void mouseExited(java.awt.event.MouseEvent me)
        Specified by:
        mouseExited in interface java.awt.event.MouseListener
      • mouseDragged

        public void mouseDragged(java.awt.event.MouseEvent me)
        Specified by:
        mouseDragged in interface java.awt.event.MouseMotionListener
      • mouseMoved

        public void mouseMoved(java.awt.event.MouseEvent me)
        Specified by:
        mouseMoved in interface java.awt.event.MouseMotionListener
      • getLineColor

        public java.awt.Color getLineColor()
        Returns:
        the LineColor
      • setLineColor

        public void setLineColor(java.awt.Color LineColor)
        Parameters:
        LineColor - the LineColor to set
      • propertyChange

        public void propertyChange(java.beans.PropertyChangeEvent evt)
        Specified by:
        propertyChange in interface java.beans.PropertyChangeListener

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.