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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addChangeListener
(ChangeListener listener) Adds aChangeListener
to the model.protected void
Notifies the registered listeners that the model has changed.int
getX()
Returns the current x coordinate.int
getY()
Returns the current y coordinate.boolean
Returns whether the pixel is marked as invalid by setting one of the coordinates to -1.void
removeChangeListener
(ChangeListener listener) Removes aChangeListener
from the model.void
set
(int x, int y) Changes the pixel stored in this model.
-
Constructor Details
-
PixelModel
public PixelModel()
-
-
Method Details
-
addChangeListener
Adds aChangeListener
to the model.- Parameters:
listener
- the listener to add
-
removeChangeListener
Removes aChangeListener
from 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:
true
if the model does not have a valid pixel
-