public class EditorState extends java.lang.Object implements MenuIndexConstants
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
currentDirectory |
private PixelImage |
currentImage |
static int |
DEFAULT_INTERPOLATION
The default interpolation type, one of the three INTERPOLATION_xyz constants.
|
static int |
DEFAULT_MAX_REDO_IMAGES
The default number of redo steps possible.
|
static int |
DEFAULT_MAX_UNDO_IMAGES
The default number of undo steps possible.
|
private java.lang.String |
fileName |
private int |
interpolation |
static int |
INTERPOLATION_BICUBIC
Integer constant for bicubic interpolation.
|
static int |
INTERPOLATION_BILINEAR
Integer constant for bilinear neighbor interpolation.
|
static int |
INTERPOLATION_NEAREST_NEIGHBOR
Integer constant for nearest neighbor interpolation.
|
private java.util.Locale |
locale |
private int |
maxRedoImages |
private int |
maxUndoImages |
private boolean |
modified |
static int |
ORIGINAL_SIZE_ZOOM_INDEX
The index into the
ZOOM_LEVELS array that holds the original size zoom level (100 percent). |
private java.util.Vector |
progressListeners |
private java.util.Vector |
redoImages |
private java.util.Vector |
redoModified |
private java.lang.String |
startupImageName |
private Strings |
strings |
private java.util.Vector |
undoImages |
private java.util.Vector |
undoModified |
static int[] |
ZOOM_LEVELS
All allowed zoom levels, as percentage values in ascending order.
|
private double |
zoomFactorX |
private double |
zoomFactorY |
private int |
zoomIndex |
private boolean |
zoomToFit |
COLOR, COLOR_ADJUST, COLOR_ADJUST_BRIGHTNESS, COLOR_ADJUST_CONTRAST, COLOR_ADJUST_GAMMA, COLOR_ADJUST_HUESATURATIONVALUE, COLOR_CONVERTTOMINIMUMCOLORTYPE, COLOR_HISTOGRAM, COLOR_HISTOGRAM_COUNTCOLORSUSED, COLOR_HISTOGRAM_EQUALIZE, COLOR_HISTOGRAM_NORMALIZE, COLOR_HISTOGRAM_SAVECOOCCURRENCEFREQUENCYMATRIXAS, COLOR_HISTOGRAM_SAVECOOCCURRENCEMATRIXAS, COLOR_HISTOGRAM_SAVEHISTOGRAMAS, COLOR_HISTOGRAM_TEXTUREPROPERTIES, COLOR_INVERT, COLOR_PALETTE, COLOR_PALETTE_SAVEAS, COLOR_PROMOTE, COLOR_PROMOTE_PROMOTETOGRAY16, COLOR_PROMOTE_PROMOTETOGRAY8, COLOR_PROMOTE_PROMOTETOPALETTED, COLOR_PROMOTE_PROMOTETORGB24, COLOR_PROMOTE_PROMOTETORGB48, COLOR_REDUCE, COLOR_REDUCE_CONVERTTOGRAYSCALE, COLOR_REDUCE_MAPTOARBITRARYPALETTE, COLOR_REDUCE_MEDIANCUT, COLOR_REDUCE_OCTREE, COLOR_REDUCE_REDUCENUMBEROFSHADESOFGRAY, COLOR_REDUCE_REDUCETOBILEVELTHRESHOLD, COLOR_REDUCE_UNIFORMPALETTE, EDIT, EDIT_REDO, EDIT_UNDO, FILE, FILE_CLOSE, FILE_EXIT, FILE_IMAGE_1, FILE_OPEN, FILE_SAVEAS, FILE_SAVEAS_GIF, FILE_SAVEAS_PALM, FILE_SAVEAS_PBM, FILE_SAVEAS_PGM, FILE_SAVEAS_PNG, FILE_SAVEAS_PPM, FILE_SAVEAS_SUNRASTER, FILE_SAVEAS_WINDOWSBMP, FILTERS, FILTERS_BLUR, FILTERS_EDGEDETECTION, FILTERS_EMBOSS, FILTERS_HORIZONTALPREWITT, FILTERS_HORIZONTALSOBEL, FILTERS_LITHOGRAPH, FILTERS_MAXIMUM, FILTERS_MEAN, FILTERS_MEDIAN, FILTERS_MINIMUM, FILTERS_OIL, FILTERS_PSYCHEDELICDISTILLATION, FILTERS_SHARPEN, FILTERS_VERTICALPREWITT, FILTERS_VERTICALSOBEL, HELP, HELP_ABOUT, HELP_SYSTEMINFORMATION, NUM_CONSTANTS, TRANSFORMATIONS, TRANSFORMATIONS_CROP, TRANSFORMATIONS_FLIP, TRANSFORMATIONS_MIRROR, TRANSFORMATIONS_ROTATE180, TRANSFORMATIONS_ROTATELEFT90, TRANSFORMATIONS_ROTATERIGHT90, TRANSFORMATIONS_SCALE, TRANSFORMATIONS_SHEAR, VIEW, VIEW_INTERPOLATIONTYPE, VIEW_INTERPOLATIONTYPE_BICUBIC, VIEW_INTERPOLATIONTYPE_BILINEAR, VIEW_INTERPOLATIONTYPE_NEARESTNEIGHBOR, VIEW_SETORIGINALSIZE, VIEW_ZOOMIN, VIEW_ZOOMOUT
Constructor and Description |
---|
EditorState()
Create new EditorState object and initialize its private fields
to default values.
|
Modifier and Type | Method and Description |
---|---|
private void |
addImageToRedo(PixelImage image,
boolean modifiedState) |
private void |
addImageToUndo(PixelImage image,
boolean modifiedState) |
void |
addProgressListener(ProgressListener pl)
Adds the argument progress listener to the internal list of progress
listeners to be notified by progress updates.
|
boolean |
canRedo()
Returns if a redo operation is possible right now.
|
boolean |
canUndo()
Returns if an undo operation is possible right now.
|
void |
clearRedo() |
void |
clearUndo() |
void |
ensureStringsAvailable() |
java.lang.String |
getCurrentDirectory()
Returns the current directory.
|
java.lang.String |
getFileName()
Returns the name of the file from which the current image was loaded.
|
PixelImage |
getImage()
Returns the image object currently loaded.
|
int |
getInterpolation()
Returns the current interpolation type, one of the INTERPOLATION_xyz constants.
|
java.util.Locale |
getLocale()
Returns the Locale object currently used.
|
boolean |
getModified()
Returns the current modified state (true if image was modified and not saved
after modification, false otherwise).
|
java.util.Vector |
getProgressListeners()
Returns the internal list of progress listeners.
|
java.lang.String |
getStartupImageName() |
Strings |
getStrings()
Returns the Strings object currently in use.
|
double |
getZoomFactorX()
Returns the current zoom factor in horizontal direction.
|
double |
getZoomFactorY()
Returns the current zoom factor in vertical direction.
|
boolean |
getZoomToFit()
Returns if image display is currently set to "zoom to fit"
Zoom to fit means that the image is always zoomed to fit exactly into the window.
|
boolean |
hasImage()
Returns if this state encapsulates an image object.
|
void |
installProgressListeners(Operation op)
Adds all ProgressListener objects from the internal list of listeners to
the argument operation.
|
boolean |
isMaximumZoom()
Returns if the image is displayed at maximum zoom level.
|
boolean |
isMinimumZoom()
Returns if the image is displayed at minimum zoom level.
|
boolean |
isZoomOriginalSize()
Returns if the current zoom level is set to original size
(each image pixel is displayed as one pixel).
|
void |
redo()
Perform a redo operation, restore the state before the last undo operation.
|
void |
resetZoomFactors() |
void |
setCurrentDirectory(java.lang.String newCurrentDirectory)
Sets a new current directory.
|
void |
setFileName(java.lang.String newFileName)
Sets a new file name.
|
void |
setImage(PixelImage image,
boolean newModifiedState)
Sets image and modified state to argument values.
|
void |
setInterpolation(int newInterpolation)
Sets a new interpolation type to be used for display.
|
void |
setLocale(java.util.Locale newLocale)
Defines a new Locale to be used.
|
void |
setStartupImageName(java.lang.String name) |
void |
setStrings(java.lang.String iso639Code)
Set new Strings resource.
|
void |
setZoomFactors(double zoomX,
double zoomY)
Sets the zoom factors to the argument values.
|
void |
undo()
Perform an undo step - the previous state will be set, the
current state will be saved for a redo operation
|
void |
zoomIn()
Increase the zoom level by one.
|
void |
zoomOut()
Decrease the zoom level by one.
|
void |
zoomSetOriginalSize()
Set the zoom level to 100 percent (1:1).
|
public static final int DEFAULT_MAX_UNDO_IMAGES
public static final int DEFAULT_MAX_REDO_IMAGES
public static final int[] ZOOM_LEVELS
public static final int ORIGINAL_SIZE_ZOOM_INDEX
ZOOM_LEVELS
array that holds the original size zoom level (100 percent).
So, ZOOM_LEVELS[ORIGINAL_SIZE_ZOOM_INDEX] must be equal to 100.public static final int INTERPOLATION_NEAREST_NEIGHBOR
public static final int INTERPOLATION_BILINEAR
public static final int INTERPOLATION_BICUBIC
public static final int DEFAULT_INTERPOLATION
private java.lang.String currentDirectory
private java.lang.String fileName
private PixelImage currentImage
private int interpolation
private java.util.Locale locale
private int maxRedoImages
private int maxUndoImages
private boolean modified
private java.util.Vector progressListeners
private java.util.Vector redoImages
private java.util.Vector redoModified
private java.lang.String startupImageName
private Strings strings
private java.util.Vector undoImages
private java.util.Vector undoModified
private int zoomIndex
private double zoomFactorX
private double zoomFactorY
private boolean zoomToFit
public EditorState()
private void addImageToRedo(PixelImage image, boolean modifiedState)
private void addImageToUndo(PixelImage image, boolean modifiedState)
public void addProgressListener(ProgressListener pl)
pl
- object implementing ProgressListener to be addedpublic boolean canRedo()
public boolean canUndo()
public void clearRedo()
public void clearUndo()
public void ensureStringsAvailable()
public java.lang.String getCurrentDirectory()
public java.lang.String getFileName()
public PixelImage getImage()
public int getInterpolation()
public java.util.Locale getLocale()
public boolean getModified()
public java.util.Vector getProgressListeners()
public java.lang.String getStartupImageName()
public Strings getStrings()
public double getZoomFactorX()
getZoomFactorY()
public double getZoomFactorY()
getZoomFactorX()
public boolean getZoomToFit()
public boolean hasImage()
public void installProgressListeners(Operation op)
public boolean isMaximumZoom()
public boolean isMinimumZoom()
public boolean isZoomOriginalSize()
public void redo()
public void resetZoomFactors()
public void setCurrentDirectory(java.lang.String newCurrentDirectory)
newCurrentDirectory
- the directory to be used as current directory from now onpublic void setFileName(java.lang.String newFileName)
newFileName
- new name of the current filepublic void setImage(PixelImage image, boolean newModifiedState)
image
- new current imagenewModifiedState
- new state of modified flagpublic void setStartupImageName(java.lang.String name)
public void setInterpolation(int newInterpolation)
newInterpolation
- an int for the interpolation type, must be one of the INTERPOLATION_xyz constantspublic void setLocale(java.util.Locale newLocale)
newLocale
- Locale object used from now onsetStrings(java.lang.String)
public void setStrings(java.lang.String iso639Code)
iso639Code
- language of the new Strings resourcepublic void setZoomFactors(double zoomX, double zoomY)
public void undo()
redo()
public void zoomIn()
zoomOut()
,
zoomSetOriginalSize()
public void zoomOut()
zoomIn()
,
zoomSetOriginalSize()