cdox.util.image
Class CorrectorSlider

java.lang.Object
  extended byjava.util.Observable
      extended bycdox.util.image.CorrectorSlider
All Implemented Interfaces:
javax.swing.event.ChangeListener, java.util.EventListener, ImageCorrector
Direct Known Subclasses:
Blur, Brightness, Contrast, GammaCorrection, Sharpen

public abstract class CorrectorSlider
extends java.util.Observable
implements ImageCorrector, javax.swing.event.ChangeListener

This class is the superclass of all the imageCorrection-classes. At the Time of this writing there are five implementing subclasses:

It has the possibility to be used with a JSlider, or without. If you use this class without the JSlider (e.g call the supclass-constuctor with the float-value) you should use the setValue(float) method to update the value which is used in the filterMethod of the supclasses. No value update no filter usage :-). If you want to use this JSlider you should use the other constructor, and you must supply an Observer. Which will be called when the JSlider has been moved. To retreive the container which contains the JSlider call the getSliderPane-method.

Version:
May 22nd 2002
Author:
Rutger Bezema, Andreas Schmitz
See Also:
getSliderPane(), Brightness, Contrast, GammaCorrection, Sharpen, Blur

Field Summary
protected  javax.swing.JSlider corSlider
          The slider which sets the value
protected  ImageCorrector imageCorrector
          The current filterClass.
protected  java.awt.Component obs
          The Observer to be called when the slider is dragged.
protected  javax.swing.JPanel sliderPane
          The panel containing the slider
protected  float value
          The value used in the filter method
 
Constructor Summary
protected CorrectorSlider(float val)
          Constructs a CorrectorSlider without the JSlider.
protected CorrectorSlider(java.util.Observer obs, java.lang.String paneTitle, int minValue, int maxValue, int startValue, int spacing, int labelSpacing, boolean grid)
          Constructs a new CorrectorSlider with the JSlider which is used to set the value to be used in the sub-classes-filter method.
 
Method Summary
protected  java.awt.image.BufferedImage getRedrawnImage(java.awt.image.BufferedImage bi)
          This method draws the given BufferedImage on a new BufferedImage and returns it.
 javax.swing.JPanel getSliderPane()
          Returns the container containing the JSlider which can be added to your Dialog, JFrame or every other container.
 int getValue()
          Returns the current value with which the current filter is working.
 void setValue(float val)
          This method is used to set the value which is used in the current filter, you should use this method, if you have chosen to define your own JSlider-classes.
 void stateChanged(javax.swing.event.ChangeEvent ce)
          Called when the JSlider has been moved.
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface cdox.util.image.ImageCorrector
filter
 

Field Detail

corSlider

protected javax.swing.JSlider corSlider
The slider which sets the value


sliderPane

protected javax.swing.JPanel sliderPane
The panel containing the slider


value

protected float value
The value used in the filter method


imageCorrector

protected ImageCorrector imageCorrector
The current filterClass.


obs

protected java.awt.Component obs
The Observer to be called when the slider is dragged.

Constructor Detail

CorrectorSlider

protected CorrectorSlider(float val)
Constructs a CorrectorSlider without the JSlider. The sliderPane is initialized to be used as an ImageObserver in the getRedrawnImage- Method. Use the setValue(float val) method to set the current value.

Parameters:
val - The initialization value used in the filter of the subclasses.
See Also:
getRedrawnImage(java.awt.image.BufferedImage)

CorrectorSlider

protected CorrectorSlider(java.util.Observer obs,
                          java.lang.String paneTitle,
                          int minValue,
                          int maxValue,
                          int startValue,
                          int spacing,
                          int labelSpacing,
                          boolean grid)
Constructs a new CorrectorSlider with the JSlider which is used to set the value to be used in the sub-classes-filter method. The JSlider is used initialized with the values given. The titledBorder of its container is set with the given paneTitle. The Observer is registered to this Class, and is updated when the slider has been moved.

Parameters:
obs - the Observer to be notified when the JSlider has been moved,
paneTitle - the title of the titledBorder of the container containing the JSlider,
minValue - the minimum value of the JSlider,
maxValue - the maximum Value of the JSlider,
startValue - the start value of the JSlider,
spacing - the value between the spacings drawn on the JSlider,
labelSpacing - the value between the spacing to draw a text,
grid - true if snaptogrid false otherwhise.
See Also:
stateChanged(javax.swing.event.ChangeEvent)
Method Detail

stateChanged

public void stateChanged(javax.swing.event.ChangeEvent ce)
Called when the JSlider has been moved. If the JSlider has been moved an is not adjusting now, the Observer is called and value is set. If the user is adjusting the JSlider, the ToolTipText is set to the current value of the JSlider (doesn't work so fine yet).

Specified by:
stateChanged in interface javax.swing.event.ChangeListener
Parameters:
ce - the ChangeEvent representing a movement of the JSlider.

getSliderPane

public javax.swing.JPanel getSliderPane()
Returns the container containing the JSlider which can be added to your Dialog, JFrame or every other container.

Returns:
the JPanel containing the Slider.

getValue

public int getValue()
Returns the current value with which the current filter is working.

Specified by:
getValue in interface ImageCorrector
Returns:
the current value.

setValue

public void setValue(float val)
This method is used to set the value which is used in the current filter, you should use this method, if you have chosen to define your own JSlider-classes.

Parameters:
val - the value to set the filters-working-value.

getRedrawnImage

protected java.awt.image.BufferedImage getRedrawnImage(java.awt.image.BufferedImage bi)
This method draws the given BufferedImage on a new BufferedImage and returns it. The returned method is one of TYPE_INT_ARGB which means it has an Alpha chanel. This method insures that all images are filterable (JDK-BUG?). And that transperable gif images are still transparent after filtering.

Parameters:
bi - the BufferedImage to be redrawn,
Returns:
the redrawn TYPE_INT_ARGB BufferedImage.