Package org.loboevolution.img
Class PixelModel
java.lang.Object
org.loboevolution.img.PixelModel
Stores the x and y coordinate of a pixel. Either both coordinate is positive
or zero, indicating a valid pixel, or both are -1, indicating no pixel is
selected or should be shown.
Author Kazo Csaba
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChangeListener(ChangeListener listener) Adds aChangeListenerto the model.protected voidNotifies the registered listeners that the model has changed.intgetX()Returns the current x coordinate.intgetY()Returns the current y coordinate.booleanReturns whether the pixel is marked as invalid by setting one of the coordinates to -1.voidremoveChangeListener(ChangeListener listener) Removes aChangeListenerfrom the model.voidset(int x, int y) Changes the pixel stored in this model.
-
Constructor Details
-
PixelModel
public PixelModel()
-
-
Method Details
-
addChangeListener
Adds aChangeListenerto the model.- Parameters:
listener- the listener to add
-
removeChangeListener
Removes aChangeListenerfrom the model.- Parameters:
listener- the listener to remove
-
fireChange
protected void fireChange()Notifies the registered listeners that the model has changed. -
set
public void set(int x, int y) Changes the pixel stored in this model. If either coordinate is negative, the new value of the model will be (-1, -1).- Parameters:
x- the new x coordinatey- the new y coordinate
-
getX
public int getX()Returns the current x coordinate.- Returns:
- the x coordinate
-
getY
public int getY()Returns the current y coordinate.- Returns:
- the y coordinate
-
isInvalid
public boolean isInvalid()Returns whether the pixel is marked as invalid by setting one of the coordinates to -1.- Returns:
trueif the model does not have a valid pixel
-