All Packages Class Hierarchy This Package Previous Next Index
Class com.ibm.imageprocessing.RotationFilter
java.lang.Object
|
+----com.ibm.imageprocessing.ImageProcessing
|
+----com.ibm.imageprocessing.RotationFilter
- public class RotationFilter
- extends ImageProcessing
This class is a concrete implementation of an ImageProcessing
abstract class and provides the Rotation Filtering facility.
This class provides the concrete implementation of the startProcessing
method in its base class. In this method, the rotation
filtering of the original image is done and processing events are fired
to indicate the status of processing the image.
This class uses one extended java.awt.image.ImageFilter
class
for filtering operation. This extended filter is available by the
getImageFilter
method, which can be used in the context of
the producer/filter/consumer paradigm and
java.awt.image.FilteredImageSource
can be used to take the
advantage of it.
For example:
java.awt.Canvas c = new java.awt.Canvas();
RotationFilter rf = new RotationFilter();
java.awt.ImageFilter filter = rf.getImageFilter();
java.awt.Image image = Toolkit.getDefaultToolkit().
getImage("c:\\apple.gif");
.....
// use java.awt.MediaTracker or any other technique to load the image
....
FilteredImageSource producer =new FilteredImageSource(image.getSource()
, filter);
java.awt.Image processedImage = c.createImage(producer);
There is one more way to do the filtering operation. This will be
particularly useful if this class is used as a bean in an IDE and
is wired to other beans to do the filtering.
RotationFilter rf = new RotationFilter();
// if FetchArgumentsEvent
is used for setting the input image
// or any control property, autoAction
property should be set to false.
// otherwise there can be an infinite loop.
rf.triggerAction();
// since the triggerAction method fires FetchArgumentsEvent
,
// on receiving this event the input image for this bean is set using
// setInputImage
method of this bean. When the processing
// is over,the processed image can be retrieved using getResult
// method.
java.awt.Image processedImage = rf.getResult();
- See Also:
- ImageFilter, ImageProcessing, ProcessingEvent, ProcessingListener, ProcessingErrorEvent, ProcessingErrorListener, RotationErrorEvent, RotationErrorListener, ImageProcessedEvent, ImageProcessedListener
-
ANTICLOCKWISE
- Useful constant for a direction .
-
CLOCKWISE
- Useful constant for a direction .
-
NOTIFY_USER
- Variable to be used for either notifying the user
about the error messages or not
-
RotationFilter()
-
The default constructor.
-
addImageProcessedListener(ImageProcessedListener)
- Adds an ImageProcessedListener to the listener list.
-
addProcessingErrorListener(ProcessingErrorListener)
- Adds a ProcessingErrorListener to the listener list.
-
addProcessingListener(ProcessingListener)
- Adds a ProcessingListener to the listener list.
-
addRotationErrorListener(RotationErrorListener)
- Adds a RotationErrorListener to the listener list.
-
getDirection()
-
Gets the direction of rotation.
-
getImageFilter()
- Returns the filter used by this class.
-
getResult()
- Returns a processed image.
-
getRotationAngle()
-
Gets the angle of rotation
-
removeImageProcessedListener(ImageProcessedListener)
- Removes an ImageProcessedListener from the listener list.
-
removeProcessingErrorListener(ProcessingErrorListener)
- Removes a ProcessingErrorListener from the listener list.
-
removeProcessingListener(ProcessingListener)
- Removes a ProcessingListener from the listener list.
-
removeRotationErrorListener(RotationErrorListener)
- Removes a RotationErrorListener from the listener list.
-
setDirection(String)
-
Sets the direction of rotation(clockwise or anticlockwise).
-
setInputImage(Image)
- Sets an inputImage to be processed by this class.
-
setRotationAngle(int)
-
Sets the angle of rotation.
-
startProcessing()
- Processes an input image and various events are fired to indicate the status
of processing the image.
CLOCKWISE
public static final String CLOCKWISE
- Useful constant for a direction .
The value of this constant is "Clockwise".
ANTICLOCKWISE
public static final String ANTICLOCKWISE
- Useful constant for a direction .
The value of this constant is "AntiClockwise".
NOTIFY_USER
public boolean NOTIFY_USER
- Variable to be used for either notifying the user
about the error messages or not
RotationFilter
public RotationFilter()
- The default constructor.
getResult
public Image getResult()
- Returns a processed image.
- Returns:
- processed image
setInputImage
public void setInputImage(Image inputImage)
- Sets an inputImage to be processed by this class.
If the
processing
flag is true, this method returns without setting
the input image. If the processing
flag is false, this method sets
the input image and calls evaluate
if autoAction
is set to true. If the input argument is null and debug
flag is
true, IllegalArgumentException
will be thrown, else the null value
will be set as the input argument and no exception will be thrown.
- Parameters:
- inputImage - inputImage to be processed
- Throws: IllegalArgumentException
- if the passed value is null
- See Also:
- Image, processing, evaluate
setDirection
public void setDirection(String direction)
- Sets the direction of rotation(clockwise or anticlockwise).
RotationErrorEvent
is thrown if an invalid non-null argument
is passed. The property change event is also fired if the old value
is not equal to new value. If autoAction
is set to true, the
evaluate
method is called. If the processing
flag is
true, the direction is not set and returns without doing anything.
- Parameters:
- direction - direction of rotation(clockwise or anticlockwise)
- Throws: IllegalArgumentException
- if the passed value is null
- See Also:
- getDirection, evaluate, RotationErrorEvent, processing, CLOCKWISE, ANTICLOCKWISE
getDirection
public String getDirection()
- Gets the direction of rotation.
- Returns:
- direction(clockwise or anticlockwise)
- See Also:
- setDirection
setRotationAngle
public void setRotationAngle(int angle)
- Sets the angle of rotation.
RotationErrorEvent
is thrown if an invalid argument is passed.
The property change event is also fired if the old value
is not equal to new value. If autoAction
is set to true,
the evaluate
method is called. If the processing
flag is
true, the rotation angle is not set and returns without doing anything.
- Parameters:
- angle - angle of rotation(any non-negative angle which is a multiple of 90)
- Throws: IllegalArgumentException
- if the passed value is null
- See Also:
- getRotationAngle, evaluate, RotationErrorEvent, processing
getRotationAngle
public int getRotationAngle()
- Gets the angle of rotation
- Returns:
- angle(any non-negative angle which is a multiple of 90)
- See Also:
- setRotationAngle
getImageFilter
public ImageFilter getImageFilter()
- Returns the filter used by this class. This filter
extends from
java.awt.image.ImageFilter
and can be used
as the second argument of the constructor of the
java.awt.image.FilteredImageSource
class. This method is
provided so that this class can also be used in the context of the
producer/filter/consumer paradigm. This method also facilitates the
use of beans as simple classes (instead of wiring them in IDEs).
- Returns:
- image filter used by this class to do the filtering
- See Also:
- ImageFilter
addImageProcessedListener
public synchronized void addImageProcessedListener(ImageProcessedListener listener)
- Adds an ImageProcessedListener to the listener list.
- Parameters:
- listener - ImageProcessedListener to be added
- Throws: IllegalArgumentException
- if the passed value is null
- See Also:
- ImageProcessedListener, removeImageProcessedListener
removeImageProcessedListener
public synchronized void removeImageProcessedListener(ImageProcessedListener listener)
- Removes an ImageProcessedListener from the listener list.
- Parameters:
- listener - ImageProcessedListener to be removed
- Throws: IllegalArgumentException
- if the passed value is null
- See Also:
- ImageProcessedListener, addImageProcessedListener
addProcessingListener
public synchronized void addProcessingListener(ProcessingListener listener)
- Adds a ProcessingListener to the listener list.
- Parameters:
- listener - ProcessingListener to be added
- Throws: IllegalArgumentException
- if the passed value is null
- See Also:
- ProcessingListener, removeProcessingListener
removeProcessingListener
public synchronized void removeProcessingListener(ProcessingListener listener)
- Removes a ProcessingListener from the listener list.
- Parameters:
- listener - ProcessingListener to be removed
- Throws: IllegalArgumentException
- if the passed value is null
- See Also:
- ProcessingListener, addProcessingListener
addProcessingErrorListener
public synchronized void addProcessingErrorListener(ProcessingErrorListener listener)
- Adds a ProcessingErrorListener to the listener list.
- Parameters:
- listener - ProcessingErrorListener to be added
- Throws: IllegalArgumentException
- if the passed value is null
- See Also:
- ProcessingErrorListener, removeProcessingErrorListener
removeProcessingErrorListener
public synchronized void removeProcessingErrorListener(ProcessingErrorListener listener)
- Removes a ProcessingErrorListener from the listener list.
- Parameters:
- listener - ProcessingErrorListener to be removed
- Throws: IllegalArgumentException
- if the passed value is null
- See Also:
- ProcessingErrorListener, addProcessingErrorListener
addRotationErrorListener
public synchronized void addRotationErrorListener(RotationErrorListener listener)
- Adds a RotationErrorListener to the listener list.
- Parameters:
- listener - RotationErrorListener to be added
- Throws: IllegalArgumentException
- if the passed value is null
- See Also:
- RotationErrorListener, removeRotationErrorListener
removeRotationErrorListener
public synchronized void removeRotationErrorListener(RotationErrorListener listener)
- Removes a RotationErrorListener from the listener list.
- Parameters:
- listener - RotationErrorListener to be removed
- Throws: IllegalArgumentException
- if the passed value is null
- See Also:
- RotationErrorListener, addRotationErrorListener
startProcessing
protected void startProcessing()
- Processes an input image and various events are fired to indicate the status
of processing the image.
It fires the
processingStarted
event initially.Then it waits for the
image to be loaded. If the image has been successfully loaded
(meaning that no ProcessingErrorEvent
event is fired),the image
is filtered and the processed image is stored as a result.
If there is any error in processing(which includes grabbing pixels for result image),
it fires the ProcessingErrorEvent
event and returns.
If the processing is successfully completed, it fires the processingOver
and
ImageProcessedEvent
events. The old result is also stored. It then
compares the new result with the old result. If they are different,
the PropertyChangeEvent
event is fired. If the debug
flag
is true and inputImage
is null, NullPointerException
will be thrown. If the debug
flag is false and inputImage
is null,the result will be set to null and all the required events will be
thrown.
- Throws: NullPointerException
- if an input image is null
- Overrides:
- startProcessing in class ImageProcessing
- See Also:
- processingStarted, processingOver, ProcessingErrorEvent, ImageProcessedEvent, PropertyChangeEvent
All Packages Class Hierarchy This Package Previous Next Index