home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VCafe / Source.bin / Slider.java < prev    next >
Encoding:
Java Source  |  1998-05-14  |  26.5 KB  |  898 lines

  1. package symantec.itools.awt;
  2.  
  3. import java.awt.Canvas;
  4. import java.awt.Dimension;
  5. import java.awt.Graphics;
  6. import java.awt.AWTEventMulticaster;
  7. import java.awt.event.ActionEvent;
  8. import java.beans.PropertyVetoException;
  9. import java.beans.PropertyChangeListener;
  10. import java.beans.VetoableChangeListener;
  11. import java.beans.PropertyChangeEvent;
  12. import java.awt.event.ActionListener;
  13. import java.awt.AWTEvent;
  14. import java.util.ResourceBundle;
  15.  
  16. //     02/15/97    RKM    Added change checking on setter before invalidating
  17. //                    Added range checking in setValue
  18. //     02/27/97    RKM    Merged Scott's change to call invalidate in setValue
  19. //  05/11/97    CAR Added a call to validate for all setters.
  20. //    05/30/97    MSH    Updated to Java 1.1
  21. //    07/17/97    LAB    Added add/removePropertyChangeListener and add/removeVetoableChangeListener event
  22. //                    registration functions.  Added setTickSyle. Moved doMove() from Horizontal and Vertical
  23. //                    Slider into Slider since they were the same. Moved Action Listener/Event stuff into
  24. //                    base class since it's the same. In general, moved thigs common in Vertical and Horzontal
  25. //                    slider into Slider. Made setTickFreq() bound and constrained.
  26. //    07/22/97    LAB    Moved SliderTick class from Slider.java into it's own file at
  27. //                    compiler's request.
  28. //  07/24/97    CAR marked field transient as needed
  29. //  08/12/97    RKM Lower cased property names when firing change and veto stuff
  30. //                    Remove calls to validate after invalidate (caused D'Arcy problems)
  31. //  08/26/97    CAR setTickFreq will not set the freq greater than the slider's max value -1
  32. //  08/27/97    RKM Changed invalidate calls to repaints, moved code from validate to paint
  33. //                    Removed reshape override
  34. //  08/27/97    CAR fixed bug re: setValue was inadvertantly dependant on setTickFreq
  35. //    10/05/97    LAB    Constrained min and max so max can't be larger than min (Addresses Mac Bug #8844).
  36. //    10/06/97    LAB    Made setMaxValue and setMinValue set the temp values to the current
  37. //                    value when changing the current value.  Changed getMinValue and
  38. //                    getMaxValue to return the temp value if the component is not added.
  39. //                    This fixes a problem at design time where the component would revert
  40. //                    to it's default state after a back run (Address Mac Bug #9022).
  41. //    10/17/97    LAB    Fixed order dependence with value, and tick frequency (Addresses Mac Bug #9296).
  42.  
  43. /**
  44.  * Components based on this class are used to select
  45.  * one value from a continuous range of values. It has a movable thumb in
  46.  * front of a gauge with ticks marks on it.
  47.  * <p>
  48.  * @see symantec.itools.awt.HorizontalSlider
  49.  * @see symantec.itools.awt.VerticalSlider
  50.  * @version 1.1, July 17, 1997
  51.  * @author Symantec
  52.  */
  53. public abstract class Slider extends Canvas
  54. {
  55.     /**
  56.      * Defines the slider tick style where the tick marks appear to the left of
  57.      * the slider thumb.
  58.      */
  59.     public static final int TICK_LEFT       = 0;
  60.  
  61.    /**
  62.      * Defines the slider tick style where the tick marks appear to the right of
  63.      * the slider thumb.
  64.      */
  65.     public static final int TICK_RIGHT      = 1;
  66.  
  67.     /**
  68.      * Defines the slider tick style where the tick marks appear below
  69.      * the slider thumb.
  70.      */
  71.     public static final int TICK_BOTTOM     = TICK_LEFT;
  72.  
  73.     /**
  74.      * Defines the slider tick style where the tick marks appear above
  75.      * the slider thumb.
  76.      */
  77.     public static final int TICK_TOP        = TICK_RIGHT;
  78.  
  79.     /**
  80.      * Defines the slider tick style where the tick marks appear both
  81.      * to the left and right of the slider thumb.
  82.      */
  83.     public static final int TICK_BOTH       = 2;
  84.  
  85.     /**
  86.      * Defines the slider tick style where no tick marks are drawn.
  87.      */
  88.     public static final int TICK_NONE       = 3;
  89.  
  90.     /**
  91.      * Constructs the Slider.
  92.      */
  93.     protected Slider()
  94.     {
  95.         this.style        = TICK_BOTH;
  96.         this.min        = 1;
  97.         this.max        = 10;
  98.         this.freq        = 1;
  99.         prevPos            =
  100.         curPos            = 0;
  101.         height            = 50;
  102.         showBorder        = true;
  103.         tick            = null;
  104.         tempMinValue    = min;
  105.         tempMaxValue    = max;
  106.         tempTickFreq    = this.freq;
  107.         tempValue        = curPos;
  108.         isAdded            = false;
  109.     }
  110.  
  111.     /**
  112.      * Sets the current slider tick mark style.
  113.      *
  114.      * @param style the new tick mark style, one of TICK_LEFT, TICK_RIGHT, TICK_TOP, TICK_BOTTOM, TICK_BOTH, or TICK_NONE
  115.      * @see #getTickStyle
  116.      * @see #TICK_LEFT
  117.      * @see #TICK_RIGHT
  118.      * @see #TICK_TOP
  119.      * @see #TICK_BOTTOM
  120.      * @see #TICK_BOTH
  121.      * @see #TICK_NONE
  122.      * @exception PropertyVetoException
  123.      * if the specified property value is unacceptable
  124.      */
  125.     public void setTickStyle(int style) throws PropertyVetoException
  126.     {
  127.         if (this.style != style)
  128.         {
  129.             Integer oldValue = new Integer( this.style );
  130.             Integer newValue = new Integer( style );
  131.  
  132.             vetos.fireVetoableChange( "tickStyle", oldValue, newValue );
  133.  
  134.             this.style = style;
  135.  
  136.             changes.firePropertyChange( "tickStyle", oldValue, newValue );
  137.  
  138.             forceCallDoReshape = true;
  139.         }
  140.     }
  141.  
  142.     /**
  143.      * Returns the current slider tick mark style.
  144.      * @return one of: TICK_LEFT, TICK_RIGHT, TICK_TOP, TICK_BOTTOM, TICK_BOTH, or TICK_NONE
  145.      * @see #TICK_LEFT
  146.      * @see #TICK_RIGHT
  147.      * @see #TICK_TOP
  148.      * @see #TICK_BOTTOM
  149.      * @see #TICK_BOTH
  150.      * @see #TICK_NONE
  151.      */
  152.     public int getTickStyle()
  153.     {
  154.         return style;
  155.     }
  156.  
  157.     /**
  158.      * Sets the minimum value of the slider.
  159.      * @param min the new minimum slider value
  160.      * @see #getMinValue
  161.      * @see #setMaxValue
  162.      * @exception PropertyVetoException
  163.      * if the specified property value is unacceptable
  164.      */
  165.     public void setMinValue(int min) throws PropertyVetoException
  166.     {
  167.         if(isAdded)
  168.         {
  169.             if (this.min != min)
  170.             {
  171.                 Integer oldValue = new Integer( this.min );
  172.                 Integer newValue = new Integer( min );
  173.  
  174.                 vetos.fireVetoableChange( "minValue", oldValue, newValue );
  175.  
  176.                 this.min = min;
  177.                 tempMinValue = min;
  178.  
  179.                 changes.firePropertyChange( "minValue", oldValue, newValue );
  180.  
  181.                 forceCallDoReshape = true;
  182.                 repaint();
  183.             }
  184.         }
  185.            //We store the value until we are added then set the value to avoid code-gen order dependencies.
  186.         else
  187.         {
  188.             tempMinValue = min;
  189.         }
  190.     }
  191.  
  192.     /**
  193.      * Returns the current minimum value of the slider.
  194.      * @see #setMinValue
  195.      * @see #getMaxValue
  196.      */
  197.     public int getMinValue()
  198.     {
  199.         return isAdded ? min : tempMinValue;
  200.     }
  201.  
  202.     /**
  203.      * Sets the maximum value of the slider.
  204.      * @param max the new maximum slider value
  205.      * @see #getMaxValue
  206.      * @see #setMinValue
  207.      * @exception PropertyVetoException
  208.      * if the specified property value is unacceptable
  209.      */
  210.     public void setMaxValue(int max) throws PropertyVetoException
  211.     {
  212.         if(isAdded)
  213.         {
  214.             if (this.max != max)
  215.             {
  216.                 Integer oldValue = new Integer( this.max );
  217.                 Integer newValue = new Integer( max );
  218.  
  219.                 vetos.fireVetoableChange( "maxValue", oldValue, newValue );
  220.  
  221.                 this.max = max;
  222.                 tempMaxValue = max;
  223.  
  224.                 changes.firePropertyChange( "maxValue", oldValue, newValue );
  225.  
  226.                 forceCallDoReshape = true;
  227.                 repaint();
  228.             }
  229.         }
  230.         //We store the value until we are added then set the value to avoid code-gen order dependencies.
  231.         else
  232.         {
  233.             tempMaxValue = max;
  234.         }
  235.     }
  236.  
  237.     /**
  238.      * Returns the current maximum value of the slider.
  239.      * @see #setMaxValue
  240.      * @see #getMinValue
  241.      */
  242.     public int getMaxValue()
  243.     {
  244.         return isAdded ? max : tempMaxValue;
  245.     }
  246.  
  247.     /**
  248.      * Sets the tick mark display frequency.
  249.      * This is the range in value between each tick mark.
  250.      * @param freq the range in value between tick marks
  251.      * @exception PropertyVetoException
  252.      * if the specified property value is unacceptable
  253.      * @see #getTickFreq
  254.      */
  255.     public void setTickFreq(int freq) throws PropertyVetoException
  256.     {
  257.         if(isAdded)
  258.         {
  259.             if (this.freq != freq)
  260.             {
  261.                 if(freq >= max)
  262.                     freq = max - 1;
  263.  
  264.                 Integer oldValue = new Integer(this.freq);
  265.                 Integer newValue = new Integer(freq);
  266.  
  267.                    vetos.fireVetoableChange( "tickFreq", oldValue, newValue );
  268.  
  269.                 int pos = curPos * this.freq + min;
  270.                 this.freq = freq;
  271.                 doMove((pos - min) / this.freq, false);
  272.  
  273.                 changes.firePropertyChange( "tickFreq", oldValue, newValue );
  274.  
  275.                 forceCallDoReshape = true;
  276.                 repaint();
  277.             }
  278.         }
  279.  
  280.            tempTickFreq = freq;
  281.     }
  282.  
  283.     /**
  284.      * Returns the current tick mark display frequency.
  285.      * This is the range in value between each tick mark.
  286.      * @return the range in value between tick marks
  287.      * @see #setTickFreq
  288.      */
  289.     public int getTickFreq()
  290.     {
  291.         if(isAdded)
  292.         {
  293.             return freq;
  294.         }
  295.         else
  296.         {
  297.             return tempTickFreq;
  298.         }
  299.     }
  300.  
  301.     /**
  302.      * Sets the slider value.
  303.      * @param pos the new slider value
  304.      * @see #getValue
  305.      * @exception PropertyVetoException
  306.      * if the specified property value is unacceptable
  307.      */
  308.     public void setValue(int pos) throws PropertyVetoException
  309.     {
  310.         if(isAdded)
  311.         {
  312.             //Do range checking on pos
  313.             Integer oldValue = new Integer( curPos * freq + min );
  314.             Integer newValue = new Integer( pos );
  315.  
  316.                vetos.fireVetoableChange( "value", oldValue, newValue );
  317.  
  318.             if (pos < getMinValue())
  319.                 pos = getMinValue();
  320.             else if (pos > getMaxValue())
  321.                 pos = getMaxValue();
  322.  
  323.             doMove((pos - min) / freq, false);
  324.  
  325.             changes.firePropertyChange( "value", oldValue, newValue );
  326.  
  327.             forceCallDoReshape = true;
  328.             repaint();
  329.         }
  330.  
  331.         tempValue = pos;
  332.     }
  333.  
  334.     /**
  335.      * Returns the current slider value.
  336.      * @see #setValue
  337.      */
  338.     public int getValue()
  339.     {
  340.         if(isAdded)
  341.         {
  342.             return curPos * freq + min;
  343.         }
  344.         else
  345.         {
  346.             return tempValue;
  347.         }
  348.     }
  349.  
  350.     /**
  351.      * Sets the border display flag.
  352.      * @param f true for the border to show
  353.      * @see #getShowBorder
  354.      * @exception PropertyVetoException
  355.      * if the specified property value is unacceptable
  356.      */
  357.     public void setShowBorder(boolean f) throws PropertyVetoException
  358.     {
  359.         if (showBorder != f)
  360.         {
  361.             Boolean oldValue = new Boolean( showBorder );
  362.             Boolean newValue = new Boolean( f );
  363.  
  364.             vetos.fireVetoableChange( "showBorder", oldValue, newValue );
  365.  
  366.             showBorder = f;
  367.  
  368.             changes.firePropertyChange( "showBorder", oldValue, newValue );
  369.  
  370.             repaint();
  371.         }
  372.     }
  373.  
  374.     /**
  375.      * @deprecated
  376.      * @see #isShowBorder
  377.      */
  378.     public boolean getShowBorder()
  379.     {
  380.         return isShowBorder();
  381.     }
  382.  
  383.     /**
  384.      * Returns the current border display flag.
  385.      * @return true if the border is visible
  386.      * @see #setShowBorder
  387.      * @see #getShowBorder
  388.      */
  389.     public boolean isShowBorder()
  390.     {
  391.         return showBorder;
  392.     }
  393.  
  394.     /**
  395.      * Sets the command name of the action event fired by this component.
  396.      * @param command The name of the action event command fired by this component
  397.      * @exception PropertyVetoException
  398.      * if the specified property value is unacceptable
  399.      */
  400.     public void setActionCommand(String command) throws PropertyVetoException
  401.     {
  402.         String oldValue = actionCommand;
  403.  
  404.         vetos.fireVetoableChange("actionCommand", oldValue, command);
  405.  
  406.         actionCommand = command;
  407.  
  408.         changes.firePropertyChange("actionCommand", oldValue, command);
  409.     }
  410.  
  411.     /**
  412.      * @returns the command name of the action event fired by this component.
  413.      */
  414.     public String getActionCommand()
  415.     {
  416.         return actionCommand;
  417.     }
  418.  
  419.     /**
  420.      * Tells this component that it has been added to a container.
  421.      * This is a standard Java AWT method which gets called by the AWT when
  422.      * this component is added to a container. Typically, it is used to
  423.      * create this component's peer.
  424.      *
  425.      * It has been overridden here to hook-up event listeners.
  426.      * It is also used to setup the component, creating the TextField as needed.
  427.      *
  428.      * @see #removeNotify
  429.      */
  430.     public synchronized void addNotify()
  431.     {
  432.         super.addNotify();
  433.         
  434.         try
  435.         {
  436.             errors = ResourceBundle.getBundle("symantec.itools.resources.ErrorsBundle");
  437.         }
  438.         catch(Throwable ex)
  439.         {
  440.             errors = new symantec.itools.resources.ErrorsBundle();
  441.         }
  442.  
  443.         //Hook up listeners
  444.         if (maxVeto == null)
  445.         {
  446.             maxVeto = new MaxVeto();
  447.             addMaxValueListener(maxVeto);
  448.         }
  449.         if (minVeto == null)
  450.         {
  451.             minVeto = new MinVeto();
  452.             addMinValueListener(minVeto);
  453.         }
  454.  
  455.         isAdded = true;
  456.         verifyContstrainedPropertyValues();
  457.     }
  458.  
  459.     /**
  460.      * Tells this component that it is being removed from a container.
  461.      * This is a standard Java AWT method which gets called by the AWT when
  462.      * this component is removed from a container. Typically, it is used to
  463.      * destroy the peers of this component and all its subcomponents.
  464.      *
  465.      * It has been overridden here to unhook event listeners.
  466.      *
  467.      * @see #addNotify
  468.      */
  469.     public synchronized void removeNotify()
  470.     {
  471.         //Unhook listeners
  472.         if (maxVeto != null)
  473.         {
  474.             removeMaxValueListener(maxVeto);
  475.             maxVeto = null;
  476.         }
  477.         if (minVeto != null)
  478.         {
  479.             removeMinValueListener(minVeto);
  480.             minVeto = null;
  481.         }
  482.  
  483.         super.removeNotify();
  484.         isAdded = false;
  485.     }
  486.  
  487.     /**
  488.      * Adds a listener for the max property changes.
  489.      * @param listener the listener to add.
  490.      * @see #removeMaxValueListener(java.beans.PropertyChangeListener)
  491.      */
  492.     public synchronized void addMaxValueListener(PropertyChangeListener listener)
  493.     {
  494.         changes.addPropertyChangeListener("maxValue", listener);
  495.     }
  496.  
  497.     /**
  498.      * Removes a listener for the max property changes.
  499.      * @param listener the listener to remove.
  500.      * @see #addMaxValueListener(java.beans.PropertyChangeListener)
  501.      */
  502.     public synchronized void removeMaxValueListener(PropertyChangeListener listener)
  503.     {
  504.         changes.removePropertyChangeListener("maxValue", listener);
  505.     }
  506.  
  507.     /**
  508.      * Adds a vetoable listener for the max property changes.
  509.      * @param listener the listener to add.
  510.      * @see #removeMaxValueListener(java.beans.VetoableChangeListener)
  511.      */
  512.     public synchronized void addMaxValueListener(VetoableChangeListener listener)
  513.     {
  514.         vetos.addVetoableChangeListener("maxValue", listener);
  515.     }
  516.  
  517.     /**
  518.      * Removes a vetoable listener for the max property changes.
  519.      * @param listener the listener to remove.
  520.      * @see #addMaxValueListener(java.beans.VetoableChangeListener)
  521.      */
  522.     public synchronized void removeMaxValueListener(VetoableChangeListener listener)
  523.     {
  524.         vetos.removeVetoableChangeListener("maxValue", listener);
  525.     }
  526.  
  527.     /**
  528.      * Adds a listener for the min property changes.
  529.      * @param listener the listener to add.
  530.      * @see #removeMinValueListener(java.beans.PropertyChangeListener)
  531.      */
  532.     public synchronized void addMinValueListener(PropertyChangeListener listener)
  533.     {
  534.         changes.addPropertyChangeListener("minValue", listener);
  535.     }
  536.  
  537.     /**
  538.      * Removes a listener for the min property changes.
  539.      * @param listener the listener to remove.
  540.      * @see #addMinValueListener(java.beans.PropertyChangeListener)
  541.      */
  542.     public synchronized void removeMinValueListener(PropertyChangeListener listener)
  543.     {
  544.         changes.removePropertyChangeListener("minValue", listener);
  545.     }
  546.  
  547.     /**
  548.      * Adds a vetoable listener for the min property changes.
  549.      * @param listener the listener to add.
  550.      * @see #removeMinValueListener(java.beans.VetoableChangeListener)
  551.      */
  552.     public synchronized void addMinValueListener(VetoableChangeListener listener)
  553.     {
  554.         vetos.addVetoableChangeListener("minValue", listener);
  555.     }
  556.  
  557.     /**
  558.      * Removes a vetoable listener for the min property changes.
  559.      * @param listener the listener to remove.
  560.      * @see #addMinValueListener(java.beans.VetoableChangeListener)
  561.      */
  562.     public synchronized void removeMinValueListener(VetoableChangeListener listener)
  563.     {
  564.         vetos.removeVetoableChangeListener("minValue", listener);
  565.     }
  566.  
  567.     /**
  568.      * This is the PropertyChangeEvent handling inner class for the constrained Max property.
  569.      * Handles vetoing Max values that are not valid.
  570.      */
  571.     class MaxVeto implements java.beans.VetoableChangeListener, java.io.Serializable
  572.     {
  573.         /**
  574.          * This method gets called when an attempt to change the constrained Current property is made.
  575.          * Ensures the given Max value is valid for this component.
  576.          *
  577.          * @param     e a <code>PropertyChangeEvent</code> object describing the
  578.          *             event source and the property that has changed.
  579.          * @exception PropertyVetoException if the recipient wishes the property
  580.          *              change to be rolled back.
  581.          */
  582.         public void vetoableChange(PropertyChangeEvent e) throws PropertyVetoException
  583.         {
  584.             int i = ((Integer)e.getNewValue()).intValue();
  585.             if (!isValidMaxValue(i))
  586.             {
  587.                 throw new PropertyVetoException(errors.getString("InvalidMaxValue") + i, e);
  588.             }
  589.         }
  590.     }
  591.  
  592.     /**
  593.      * This is the PropertyChangeEvent handling inner class for the constrained Min property.
  594.      * Handles vetoing Min values that are not valid.
  595.      */
  596.     class MinVeto implements java.beans.VetoableChangeListener, java.io.Serializable
  597.     {
  598.         /**
  599.          * This method gets called when an attempt to change the constrained Current property is made.
  600.          * Ensures the given Min value is valid for this component.
  601.          *
  602.          * @param     e a <code>PropertyChangeEvent</code> object describing the
  603.          *             event source and the property that has changed.
  604.          * @exception PropertyVetoException if the recipient wishes the property
  605.          *              change to be rolled back.
  606.          */
  607.         public void vetoableChange(PropertyChangeEvent e) throws PropertyVetoException
  608.         {
  609.             int i = ((Integer)e.getNewValue()).intValue();
  610.             if (!isValidMinValue(i))
  611.             {
  612.                 throw new PropertyVetoException(errors.getString("InvalidMinValue") + i, e);
  613.             }
  614.         }
  615.     }
  616.  
  617.     /**
  618.      * Is the given value valid for the Max property .
  619.      * @param i the given value
  620.      * @return true if the given value is acceptable, false if not.
  621.      */
  622.     protected boolean isValidMaxValue(int i)
  623.     {
  624.         return (i >= min);
  625.     }
  626.  
  627.     /**
  628.      * Is the given value valid for the Min property .
  629.      * @param i the given value
  630.      * @return true if the given value is acceptable, false if not.
  631.      */
  632.     protected boolean isValidMinValue(int i)
  633.     {
  634.         return (i <= max);
  635.     }
  636.  
  637.     /**
  638.      * Called after addNotify to set the internally constrined properties to their
  639.      * temporary values to validate them now that the component has been added to the form.
  640.      * This is used to avoid code-gen order dependencies, since VC generates all property
  641.      * manipulating code before adding the component to its container.
  642.      * Subclasses should override this function for any internally constrained properties,
  643.      * and call the super version in the overridden version.
  644.      */
  645.     protected void verifyContstrainedPropertyValues()
  646.     {
  647.         try { setMinValue(tempMinValue); }    catch (PropertyVetoException exc) { /*Silently verify.*/ }
  648.         try { setMaxValue(tempMaxValue); }    catch (PropertyVetoException exc) { /*Silently verify.*/ }
  649.         try { setTickFreq(tempTickFreq); }    catch (PropertyVetoException exc) { /*Silently verify.*/ }
  650.         try { setValue(tempValue); }        catch (PropertyVetoException exc) { /*Silently verify.*/ }
  651.     }
  652.  
  653.     /**
  654.      * This abstract function is called by reshape.  Override it to change the way the Slider
  655.      * is reshaped.
  656.      */
  657.     protected abstract void do_reshape(int w, int h);
  658.  
  659.     /**
  660.      * This routine updates the thumb position, paints the Slider, and
  661.      * posts a new action event as needed. If the thumb position has
  662.      * changed or the forcePost parameter is true the component will be painted
  663.      * and an action event posted.
  664.      * @param pos the new thumb position
  665.      * @param forcePost true forces painting the slider and posting of an action
  666.      * event even if the thumb position hasn't changed
  667.      */
  668.     protected void doMove(int pos, boolean forcePost)
  669.     {
  670.         if (tick == null)
  671.         {
  672.             prevPos = curPos = pos;
  673.             return;
  674.         }
  675.  
  676.         if (pos >= tick.length)
  677.             pos = tick.length - 1;
  678.  
  679.         if (pos != curPos || forcePost)
  680.         {
  681.             prevPos = curPos;
  682.             curPos  = pos;
  683.  
  684.             Graphics g = getGraphics();
  685.             paint(g);
  686.             if (g != null)
  687.                 g.dispose();
  688.             g = null;
  689.  
  690.             sourceActionEvent();
  691.         }
  692.     }
  693.  
  694.     public void paint(Graphics g)
  695.     {
  696.         boolean callDoReshape = false;
  697.  
  698.         //If size of component changes, we want to call do_reshape
  699.         Dimension currentSize = getSize();
  700.         if (!symantec.itools.util.GeneralUtils.objectsEqual(cachedSize,currentSize))
  701.         {
  702.             cachedSize = currentSize;
  703.  
  704.             width = cachedSize.width;
  705.             height = cachedSize.height;
  706.  
  707.             callDoReshape = true;
  708.         }
  709.  
  710.         if (forceCallDoReshape || callDoReshape)
  711.         {
  712.             do_reshape(width, height);
  713.             forceCallDoReshape = false;
  714.         }
  715.     }
  716.  
  717.     /**
  718.      * Handles the mouse pressing or dragging this component's thumb.
  719.      * It is not typically called directly.
  720.      * @param i the mouse horizontal or vertical position coordinate
  721.      * @param forcePost true forces painting the slider and posting of an action
  722.      * event even if the thumb position hasn't changed
  723.      */
  724.     protected  void moveThumb(int i, boolean forcePost)
  725.     {
  726.         if(tick.length > 1)
  727.         {
  728.             int dist = tick[1].c - tick[0].c;
  729.  
  730.             if (dist == 0)
  731.                 return;
  732.  
  733.             int newPos = (i - tick[0].c) / dist;
  734.  
  735.             if (newPos < 0)
  736.                 newPos = 0;
  737.  
  738.             if (((i - tick[0].c) % dist) > (dist / 2))
  739.                 ++newPos;
  740.  
  741.             doMove(newPos, forcePost);
  742.         }
  743.     }
  744.  
  745.     /**
  746.      * Adds the specified action listener to receive action events
  747.      * from this component.
  748.      * @param l the action listener
  749.      */
  750.     public synchronized void addActionListener(ActionListener l)
  751.     {
  752.         actionListener = AWTEventMulticaster.add(actionListener, l);
  753.     }
  754.  
  755.     /**
  756.      * Removes the specified action listener so it no longer receives
  757.      * action events from this component.
  758.      * @param l the action listener
  759.      */
  760.     public synchronized void removeActionListener(ActionListener l)
  761.     {
  762.         actionListener = AWTEventMulticaster.remove(actionListener, l);
  763.     }
  764.  
  765.     /**
  766.      * Adds a listener for all event changes.
  767.      * @param listener the listener to add.
  768.      * @see #removePropertyChangeListener
  769.      */
  770.     public synchronized void addPropertyChangeListener(PropertyChangeListener listener)
  771.     {
  772.         changes.addPropertyChangeListener(listener);
  773.     }
  774.  
  775.     /**
  776.      * Removes a listener for all event changes.
  777.      * @param listener the listener to remove.
  778.      * @see #addPropertyChangeListener
  779.      */
  780.     public synchronized void removePropertyChangeListener(PropertyChangeListener listener)
  781.     {
  782.         changes.removePropertyChangeListener(listener);
  783.     }
  784.  
  785.     /**
  786.      * Adds a vetoable listener for all event changes.
  787.      * @param listener the listener to add.
  788.      * @see #removeVetoableChangeListener
  789.      */
  790.     public synchronized void addVetoableChangeListener(VetoableChangeListener listener)
  791.     {
  792.         vetos.addVetoableChangeListener(listener);
  793.     }
  794.  
  795.     /**
  796.      * Removes a vetoable listener for all event changes.
  797.      * @param listener the listener to remove.
  798.      * @see #addVetoableChangeListener
  799.      */
  800.     public synchronized void removeVetoableChangeListener(VetoableChangeListener listener)
  801.     {
  802.         vetos.removeVetoableChangeListener(listener);
  803.     }
  804.  
  805.     /**
  806.      * Fire an action event to the listeners
  807.      */
  808.     protected void sourceActionEvent()
  809.     {
  810.         if (actionListener != null)
  811.             actionListener.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, actionCommand));
  812.     }
  813.  
  814.     /**
  815.      * The current component width.
  816.      */
  817.     protected int width;
  818.     /**
  819.      * The current component height.
  820.      */
  821.     protected int height;
  822.     /**
  823.      * The size of the component, the last time paint was called.
  824.      */
  825.     protected Dimension cachedSize = null;
  826.     /**
  827.      * Set if paint override should call DoReshape, even if the size has not changed.
  828.      */
  829.     protected boolean forceCallDoReshape = false;
  830.     /**
  831.      * The current slider tick mark style.
  832.      */
  833.     protected int style;
  834.     /**
  835.      * The current tick mark display frequency.
  836.      */
  837.     protected int freq;
  838.     protected int tempTickFreq;
  839.     /**
  840.      * The minimum value of the slider range.
  841.      */
  842.     protected int min;
  843.     protected int tempMinValue;
  844.     /**
  845.      * The maximum value of the slider range.
  846.      */
  847.     protected int max;
  848.     protected int tempMaxValue;
  849.     /**
  850.      * The position of the slider thumb last time control painted.
  851.      */
  852.     protected int prevPos;
  853.     /**
  854.      * The current position of the slider thumb.
  855.      */
  856.     protected int curPos;
  857.     protected int tempValue;
  858.     /**
  859.      * Flag indicating if border should be drawn.
  860.      */
  861.     protected boolean showBorder;
  862.     /**
  863.      * The action listener to keep track of listeners for our action event.
  864.      */
  865.     protected ActionListener        actionListener    = null;
  866.  
  867.     /**
  868.      * The command name of the action event fired by this component.
  869.      */
  870.     protected String actionCommand = "Slider Moved";
  871.  
  872.     /**
  873.      * is the component added to a container hierarchy?
  874.      */
  875.     protected boolean   isAdded = false;
  876.     /**
  877.      * The tick marks for this slider.
  878.      */
  879.     transient protected SliderTick tick[];
  880.  
  881.     /**
  882.      * Drawing constant for the horizontal axis.
  883.      */
  884.      protected static final int BORDER_X       = 15;
  885.     /**
  886.      * Drawing constant for the vertical axis.
  887.      */
  888.     protected static final int BORDER_Y       = 10;
  889.  
  890.     transient protected ResourceBundle errors;
  891.  
  892.     private MaxVeto maxVeto = null;
  893.     private MinVeto minVeto = null;
  894.     private symantec.itools.beans.VetoableChangeSupport vetos = new symantec.itools.beans.VetoableChangeSupport(this);
  895.     private symantec.itools.beans.PropertyChangeSupport changes = new symantec.itools.beans.PropertyChangeSupport(this);
  896.  
  897. }
  898.