public abstract class Handler extends java.lang.Object implements IActionInterface
NoAnchor, NorthEastAnchor, NorthWestAnchor, SouthEastAnchor, SouthWestAnchor
Constructor and Description |
---|
Handler(Model model,
DrawingPalette view) |
Modifier and Type | Method and Description |
---|---|
boolean |
complete(java.awt.Point pt,
int modifiers,
java.util.Optional<Element> elt)
Complete the mouse interaction.
|
boolean |
completeAnchor(java.awt.Point pt,
int modifiers,
Element elt)
Complete the mouse interaction as started by dragType.
|
boolean |
drag(java.awt.Point start,
int modifiers,
java.util.Optional<Element> elt,
java.awt.Point current)
Act on the mouse drag.
|
boolean |
dragAnchor(java.awt.Point start,
int modifiers,
Element elt,
java.awt.Point current)
Act on the anchor with mouse down.
|
java.util.Optional<Handler> |
getNext()
Return next one in chain, to allow external configuration.
|
boolean |
isInterested()
Uses currently selected action to determine if this handler is interested in processing events.
|
boolean |
move(java.awt.Point pt,
int modifiers,
java.util.Optional<Element> elt,
int anchor)
Movement of cursor detected without the mouse button being pressed.
|
void |
paint(java.awt.Graphics g)
Each handler gets the chance to override and provide specific paint capabilities after elements are drawn.
|
Handler |
setNext(Handler next)
Add next to be the next in the chain.
|
boolean |
start(java.awt.Point pt,
int modifiers,
java.util.Optional<Element> elt)
Initiate action by pressing mouse at point with, potentially, a selected element.
|
boolean |
startAnchor(java.awt.Point pt,
int modifiers,
Element elt,
int anchor)
Start the mouse interaction as started by dragType.
|
public Handler(Model model, DrawingPalette view)
public java.util.Optional<Handler> getNext()
public boolean isInterested()
interested(Action)
method to declare actions of interest.public Handler setNext(Handler next)
next
- Next handler to appendpublic boolean move(java.awt.Point pt, int modifiers, java.util.Optional<Element> elt, int anchor)
IActionInterface
Element is the optional element over which the point is moving. If it is present then there are two options:
When element is not present, then cursor is moving over some place in which no element intersects.
In all cases, modifiers reflects whether shift or control is down.
move
in interface IActionInterface
pt
- mouse locationmodifiers
- keyboard modifiers in effectelt
- optional element in playanchor
- which anchor is affectedpublic boolean start(java.awt.Point pt, int modifiers, java.util.Optional<Element> elt)
IActionInterface
start
in interface IActionInterface
pt
- starting an element action at this mouse locationmodifiers
- keyboard modifiers in effectelt
- optional element in playpublic boolean drag(java.awt.Point start, int modifiers, java.util.Optional<Element> elt, java.awt.Point current)
IActionInterface
drag
in interface IActionInterface
start
- original starting mouse location of this drag actionmodifiers
- keyboard modifiers in effectelt
- optional element in playcurrent
- current mouse locationpublic boolean complete(java.awt.Point pt, int modifiers, java.util.Optional<Element> elt)
IActionInterface
complete
in interface IActionInterface
pt
- ending mouse location of this mouse actionmodifiers
- keyboard modifiers in effectelt
- optional element in playpublic boolean startAnchor(java.awt.Point pt, int modifiers, Element elt, int anchor)
IActionInterface
startAnchor
in interface IActionInterface
pt
- start an anchor at this mouse locationmodifiers
- keyboard modifiers in effectelt
- affected elementanchor
- initiating anchor index positionpublic boolean dragAnchor(java.awt.Point start, int modifiers, Element elt, java.awt.Point current)
IActionInterface
dragAnchor
in interface IActionInterface
start
- mouse location where action startedmodifiers
- keyboard modifiers in effectelt
- affected elementcurrent
- current mouse locationpublic boolean completeAnchor(java.awt.Point pt, int modifiers, Element elt)
IActionInterface
completeAnchor
in interface IActionInterface
pt
- ending an anchor action at this mouse locationmodifiers
- keyboard modifiers in effectelt
- affected elementpublic void paint(java.awt.Graphics g)
paint
in interface IActionInterface
g
- Graphics context into which to draw whatever is necessary based on the tool