|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ITransformations
Classes implementing the ITransformations
interface can be
used with the ImageTransformerGUI
class to transform grey-scale images.
ITransformations
instances do the actual work of transforming
the images: brightening, rotating, flipping, etc. The GUI finds the
available transformations by calling getTransformationNames
and makes a button for each name in the returned array. The
performTransformation
method is called each time one of these
buttons is clicked by the user with the appropriate transformation name
passed as a parameter.
Each pixel ("picture element") in the image to be transformed is
represented by an integer between 0 and 255. A small value represents
a dark color and a
larger value represents a light color. These integers are stored in a two-
dimensional array. The value in pixels[0][0]
represents the upper-
left corner of the image. By rearranging the order of these values
the image can be rotated or flipped. By changing the magnitude of each
value the image can be lighted or darkened.
A class implementing ITransformations
would typically be
structured like this:
public class MyTransformations extends Object implements ITransformations { private int[][] pixels; private ViewList views = new ViewList(); public MyTransformations() { ... } public void setPixels(int[][] newPix) { this.pixels = newPix; this.views.updateAllViews(); } public int[][] getPixels() { return this.pixels; } public void performTransformation(String transformationName) { ... this.views.updateAllViews(); } public String[] getTransformationNames() { return new String[] {"Darken", "Brighten", "FlipX", "FlipY", "Reset"}; } public void addView(IView aView) { this.views.addVIew(aView); } }
It is up to the implementor whether transformations are cumulative
(each transformation changes the pixels
array) or independent
(the transformed image is copied into a new array that is returned,
leaving pixels
untouched).
Please see the package description for a more in-depth discussion of using this class.
Method Summary | |
---|---|
void |
addView(IView aView)
Add a view (graphical user interface) to the image transformer. |
int[][] |
getPixels()
Get the image that was transformed. |
String[] |
getTransformationNames()
A array filled with the names of the transformations implemented by this class. |
void |
performTransformation(String transformationName)
Perform the transformation indicated. |
void |
setPixels(int[][] newPix)
Set the image to be transformed to a new set of pixels. |
Method Detail |
---|
void setPixels(int[][] newPix)
newPix
- The new image to be used for subsequent transformations.int[][] getPixels()
void performTransformation(String transformationName)
transformationName
- The name of the transformation to perform. Must
be one of the transformation names returned by getTransformationNames
.String[] getTransformationNames()
void addView(IView aView)
updateView
method must be called each time the transformer's state changes.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |