Package it.tidalwave.image.render
Class EditingTool
- java.lang.Object
-
- it.tidalwave.image.render.EditingTool
-
- All Implemented Interfaces:
Overlay
,java.awt.event.KeyListener
,java.awt.event.MouseListener
,java.awt.event.MouseMotionListener
,java.util.EventListener
public class EditingTool extends java.lang.Object implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.KeyListener, Overlay
- Author:
- Fabrizio Giudici
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
EditingTool.State
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CHANGED_ATTRIBUTE
protected EditableImageRenderer
imageRenderer
-
Constructor Summary
Constructors Modifier Constructor Description protected
EditingTool(EditableImageRenderer imageRenderer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activate()
void
commitChanges()
Programmatically commits the changes.void
connectButton(javax.swing.JToggleButton button)
void
deactivate()
protected EditingTool.State
getCurrentState()
void
imageChanged()
Invoked when the renderer changes the image being edited by this tool.boolean
isActive()
boolean
isEnabled()
boolean
isVisible()
void
keyPressed(java.awt.event.KeyEvent event)
void
keyReleased(java.awt.event.KeyEvent event)
void
keyTyped(java.awt.event.KeyEvent event)
protected java.awt.Cursor
makeCursor(javax.swing.Icon icon, java.lang.String name)
void
mouseClicked(java.awt.event.MouseEvent event)
void
mouseDragged(java.awt.event.MouseEvent event)
void
mouseEntered(java.awt.event.MouseEvent event)
void
mouseExited(java.awt.event.MouseEvent event)
void
mouseMoved(java.awt.event.MouseEvent event)
void
mousePressed(java.awt.event.MouseEvent event)
void
mouseReleased(java.awt.event.MouseEvent event)
void
paint(java.awt.Graphics2D g, EditableImageRenderer imageRenderer)
As the Graphics2D object passed is a copy of the original, this method can change attributes (e.g.protected void
registerState(EditingTool.State state)
protected void
repaint()
void
reset()
void
setEnabled(boolean enabled)
void
setIcon(javax.swing.Icon icon)
protected void
setInitialState(java.lang.Class<? extends EditingTool.State> initialStateClass)
protected void
setState(java.lang.Class<? extends EditingTool.State> newStateClass)
-
-
-
Field Detail
-
CHANGED_ATTRIBUTE
public static final java.lang.String CHANGED_ATTRIBUTE
-
imageRenderer
protected final EditableImageRenderer imageRenderer
-
-
Constructor Detail
-
EditingTool
protected EditingTool(EditableImageRenderer imageRenderer)
-
-
Method Detail
-
setEnabled
public void setEnabled(boolean enabled)
-
isEnabled
public boolean isEnabled()
-
isActive
public boolean isActive()
-
commitChanges
public void commitChanges()
Programmatically commits the changes. E.g. called by the save of an image editor when a tools is currently on.
-
activate
public void activate()
-
deactivate
public void deactivate()
-
imageChanged
public void imageChanged()
Invoked when the renderer changes the image being edited by this tool. By default, the tool is deactivated (by invokingdeactivate()
), but you can change the default behaviour by overriding this method (for instance, committing changes).
-
reset
public void reset()
-
setIcon
public void setIcon(javax.swing.Icon icon)
-
connectButton
public void connectButton(javax.swing.JToggleButton button)
-
setInitialState
protected void setInitialState(java.lang.Class<? extends EditingTool.State> initialStateClass)
-
setState
protected void setState(java.lang.Class<? extends EditingTool.State> newStateClass)
-
getCurrentState
protected EditingTool.State getCurrentState()
-
registerState
protected void registerState(EditingTool.State state)
-
repaint
protected void repaint()
-
makeCursor
protected java.awt.Cursor makeCursor(javax.swing.Icon icon, java.lang.String name)
-
mouseClicked
public final void mouseClicked(java.awt.event.MouseEvent event)
- Specified by:
mouseClicked
in interfacejava.awt.event.MouseListener
-
mousePressed
public final void mousePressed(java.awt.event.MouseEvent event)
- Specified by:
mousePressed
in interfacejava.awt.event.MouseListener
-
mouseReleased
public final void mouseReleased(java.awt.event.MouseEvent event)
- Specified by:
mouseReleased
in interfacejava.awt.event.MouseListener
-
mouseEntered
public final void mouseEntered(java.awt.event.MouseEvent event)
- Specified by:
mouseEntered
in interfacejava.awt.event.MouseListener
-
mouseExited
public final void mouseExited(java.awt.event.MouseEvent event)
- Specified by:
mouseExited
in interfacejava.awt.event.MouseListener
-
mouseDragged
public final void mouseDragged(java.awt.event.MouseEvent event)
- Specified by:
mouseDragged
in interfacejava.awt.event.MouseMotionListener
-
mouseMoved
public final void mouseMoved(java.awt.event.MouseEvent event)
- Specified by:
mouseMoved
in interfacejava.awt.event.MouseMotionListener
-
keyTyped
public final void keyTyped(java.awt.event.KeyEvent event)
- Specified by:
keyTyped
in interfacejava.awt.event.KeyListener
-
keyPressed
public final void keyPressed(java.awt.event.KeyEvent event)
- Specified by:
keyPressed
in interfacejava.awt.event.KeyListener
-
keyReleased
public final void keyReleased(java.awt.event.KeyEvent event)
- Specified by:
keyReleased
in interfacejava.awt.event.KeyListener
-
paint
public final void paint(java.awt.Graphics2D g, EditableImageRenderer imageRenderer)
Description copied from interface:Overlay
As the Graphics2D object passed is a copy of the original, this method can change attributes (e.g. color, clip) without worrying about restoring them to their original values.
-
-