|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.levigo.jadice.swing.tool.Tool
public abstract class Tool
This abstract class must be sub-classed in order to contribute additional functionality to
page-visualization components like the PageView
, or the ThumbnailView
.
Note: this class is a successor to and supersedes the EditPane interface.
Nested Class Summary | |
---|---|
static class |
Tool.ActivationRequest
This class describes an auto-activation request issued by a tool in response to an event. |
Field Summary | |
---|---|
static int |
DEFAULT_PRIORITY
The default priority used with respect to dispatching or rendering. |
static int |
MAX_PRIORITY
The maximum priority a tool is supposed to use with respect to dispatching or rendering. |
static int |
MIN_PRIORITY
The minimum priority a tool is supposed to use with respect to dispatching or rendering. |
Constructor Summary | |
---|---|
Tool()
|
Method Summary | |
---|---|
void |
contribute(ContributionContext context,
MenuBuilder contextMenu)
This method is called in order to give the menu contributor a chance to contribute context menu entries via the supplied MenuBuilder . |
protected Tool.ActivationRequest |
getActivationFeedback(MouseEditEvent e)
Provide feedback for the user about what would happen, if the mouse were pressed at the current location. |
protected Tool.ActivationRequest |
getActivationRequest(EditEvent e)
Return the auto-activation request for this this tool in response to the given event. |
protected Tool.ActivationRequest |
getActivationRequestForKeyPressed(KeyEditEvent e)
Return the auto-activation request for this this tool in response to the given key press. |
protected Tool.ActivationRequest |
getActivationRequestForMouseDragged(MouseEditEvent e)
Return the auto-activation request for this this tool in response to the given mouse drag event. |
protected Tool.ActivationRequest |
getActivationRequestForMousePressed(MouseEditEvent e)
Return the auto-activation request for this this tool in response to the given mouse press. |
protected Cursor |
getCursor()
Return the current cursor in use on the associated view component. |
protected int |
getDispatchPriority()
Return the dispatch priority for this tool. |
protected ToolManager |
getManager()
Return the current tool manager. |
protected int |
getRenderPriority()
Return the render priority for this tool. |
protected void |
handleEditEvent(boolean isActive,
EditEvent e)
Handle the given EditEvent . |
protected void |
handleKeyPressed(KeyEditEvent e,
boolean isActive)
Invoked when a key has been pressed. |
protected void |
handleKeyReleased(KeyEditEvent e,
boolean isActive)
Invoked when a key has been released. |
protected void |
handleKeyTyped(KeyEditEvent e,
boolean isActive)
Invoked when a key has been typed. |
protected void |
handleMouseClicked(MouseEditEvent e,
boolean isActive)
Invoked when the mouse button has been clicked (pressed and released) on a component. |
protected void |
handleMouseDragged(MouseEditEvent e,
boolean isActive)
Invoked when a mouse button is pressed on a component and then dragged. |
protected void |
handleMouseEntered(MouseEditEvent e,
boolean isActive)
Invoked when the mouse cursor enters the unobscured part of component's geometry. |
protected void |
handleMouseExited(MouseEditEvent e,
boolean isActive)
Invoked when the mouse cursor exits the unobscured part of component's geometry. |
protected void |
handleMouseMoved(MouseEditEvent e,
boolean isActive)
Invoked when the mouse cursor has been moved onto a component but no buttons have been pushed. |
protected void |
handleMousePressed(MouseEditEvent e,
boolean isActive)
Invoked when a mouse button has been pressed on a component. |
protected void |
handleMouseReleased(MouseEditEvent e,
boolean isActive)
Invoked when a mouse button has been released on a component. |
protected void |
handleMouseWheelMoved(MouseWheelEditEvent e,
boolean isActive)
Invoked when the mouse wheel is rotated. |
protected void |
propagatePropertyChange(String name,
Object oldValue,
Object newValue)
|
protected void |
render(RenderParameters parameters,
boolean isActive)
Renders the Tool's UI onto the given Graphics2D context using the given
RenderControls . |
protected void |
setActive(boolean active)
Receive notification from the tool manager about the tool's active state. |
protected void |
setCursor(Cursor cursor)
Set the cursor on the associated view component. |
protected void |
setEnabled(boolean enabled)
Receive notification from the tool manager about the tool's enabled state. |
protected void |
setManager(ToolManager manager)
Receives the ToolManager instance, which the Tool implementation has been
registered for. |
protected void |
setStatusFeedback(String feedback)
Set the status feedback message published by the tool manager using ToolManager.getStatusFeedback() . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MIN_PRIORITY
getRenderPriority()
,
getDispatchPriority()
,
Constant Field Valuespublic static final int MAX_PRIORITY
getRenderPriority()
,
getDispatchPriority()
,
Constant Field Valuespublic static final int DEFAULT_PRIORITY
getRenderPriority()
,
getDispatchPriority()
,
Constant Field ValuesConstructor Detail |
---|
@CallOnEDT public Tool()
Method Detail |
---|
@CallOnEDT protected void render(RenderParameters parameters, boolean isActive)
Graphics2D
context using the given
RenderControls
.
This render method is called within the context and during the rendering of a single page. The page being rendered is passed to implementors of this method in order to be able to control and influence the page rendering.
parameters
- the view component which is currently being renderedisActive
- whether the called tool is currently active@CallOnEDT protected void handleEditEvent(boolean isActive, EditEvent e)
EditEvent
. This method dispatches the edit event to the individual
handleXYZ()
-Methods. However, implementors may want and are allowed to override
this method in order to perform standard handling tasks common to all types of events.
isActive
- whether this tool is currently activee
- the event@CallOnEDT protected void handleMouseClicked(MouseEditEvent e, boolean isActive)
isActive
- whether this tool is currently active@CallOnEDT protected void handleMousePressed(MouseEditEvent e, boolean isActive)
isActive
- whether this tool is currently active@CallOnEDT protected void handleMouseReleased(MouseEditEvent e, boolean isActive)
isActive
- whether this tool is currently active@CallOnEDT protected void handleMouseDragged(MouseEditEvent e, boolean isActive)
MOUSE_DRAGGED
events will continue to be delivered to the component where the drag
originated until the mouse button is released (regardless of whether the mouse position is
within the bounds of the component).
Due to platform-dependent Drag&Drop implementations, MOUSE_DRAGGED
events may
not be delivered during a native Drag&Drop operation.
isActive
- whether this tool is currently active@CallOnEDT protected void handleMouseMoved(MouseEditEvent e, boolean isActive)
isActive
- whether this tool is currently active@CallOnEDT protected void handleMouseEntered(MouseEditEvent e, boolean isActive)
isActive
- whether this tool is currently active@CallOnEDT protected void handleMouseExited(MouseEditEvent e, boolean isActive)
isActive
- whether this tool is currently active@CallOnEDT protected void handleMouseWheelMoved(MouseWheelEditEvent e, boolean isActive)
isActive
- whether this tool is currently activeMouseWheelEvent
@CallOnEDT protected void handleKeyTyped(KeyEditEvent e, boolean isActive)
KeyEvent
for a
definition of a key typed event.
isActive
- whether this tool is currently active@CallOnEDT protected void handleKeyPressed(KeyEditEvent e, boolean isActive)
KeyEvent
for a
definition of a key pressed event.
isActive
- whether this tool is currently active@CallOnEDT protected void handleKeyReleased(KeyEditEvent e, boolean isActive)
KeyEvent
for a
definition of a key released event.
isActive
- whether this tool is currently active@CallOnEDT protected Tool.ActivationRequest getActivationRequest(EditEvent e)
Tool.ActivationRequest
, it becomes eligible for auto-activation.
However, the final decision about which tool will actually be activated is up to the
ToolActivationPolicy
used be the tool manager.
e
- the event
Tool.ActivationRequest
or null
if the tool does not seek to be
auto-activated at this time.@CallOnEDT protected Tool.ActivationRequest getActivationRequestForMousePressed(MouseEditEvent e)
Tool.ActivationRequest
, it becomes eligible for auto-activation.
However, the final decision about which tool will actually be activated is up to the
ToolActivationPolicy
used be the tool manager.
e
- the KeyEditEvent
Tool.ActivationRequest
or null
if the tool does not seek to be
auto-activated at this time.@CallOnEDT protected Tool.ActivationRequest getActivationRequestForMouseDragged(MouseEditEvent e)
Tool.ActivationRequest
, it becomes eligible for auto-activation.
However, the final decision about which tool will actually be activated is up to the
ToolActivationPolicy
used be the tool manager.
Caveat: some tools may only be able to decide about their activation once the mouse starts
dragging. However, this means that they may take the back seat with respect to tools requesting
their auto-activation during the mouse-press already.
e
- the KeyEditEvent
Tool.ActivationRequest
or null
if the tool does not seek to be
auto-activated at this time.@CallOnEDT protected Tool.ActivationRequest getActivationRequestForKeyPressed(KeyEditEvent e)
Tool.ActivationRequest
, it becomes eligible for auto-activation.
However, the final decision about which tool will actually be activated is up to the
ToolActivationPolicy
used be the tool manager.
e
- the KeyEditEvent
Tool.ActivationRequest
or null
if the tool does not seek to be
auto-activated at this time.@CallOnEDT protected Tool.ActivationRequest getActivationFeedback(MouseEditEvent e)
MouseEvent.MOUSE_MOVED
events. If this
method returns null
no feedback is provided at all.
The activation request returned from this method is the same object that is used during
getActivationRequestForKeyPressed(KeyEditEvent)
to signal the auto-activation
candidacy.
This method should only return an activation request if it will actually candidate for
auto-activation later on using getActivationRequestForMousePressed(MouseEditEvent)
or
getActivationRequestForMouseDragged(MouseEditEvent)
.
@CallOnEDT protected int getRenderPriority()
MIN_PRIORITY
...MAX_PRIORITY
.
The default priority is equal to DEFAULT_PRIORITY
.
@CallOnEDT protected int getDispatchPriority()
MIN_PRIORITY
...MAX_PRIORITY
.
The default priority is equal to MAX_PRIORITY
minus the render priority.
@CallOnEDT protected void setManager(ToolManager manager)
ToolManager
instance, which the Tool
implementation has been
registered for. If the Tool
is deregistered
this
method will be called with null.
manager
- @CallOnEDT protected void propagatePropertyChange(String name, Object oldValue, Object newValue)
@CallOnEDT protected void setEnabled(boolean enabled)
handleEditEvent(boolean, EditEvent)
and render(RenderParameters, boolean)
in
the appropriate state only. However, some tools may need to perform extended actions (for
example, for resource management purposes) upon a change of the enabled state.
enabled
- @CallOnEDT protected void setActive(boolean active)
active
- @CallOnEDT public void contribute(ContributionContext context, MenuBuilder contextMenu)
MenuContributor
MenuBuilder
.
contribute
in interface MenuContributor
context
- the ContributionContext
which provides contribution context informationscontextMenu
- the MenuBuilder
to which the tool may contribute entries.@CallOnEDT protected void setCursor(Cursor cursor)
getActivationFeedback(MouseEditEvent)
.
cursor
- the Cursor
to be set@CallOnEDT protected Cursor getCursor()
Cursor
@CallOnEDT protected void setStatusFeedback(String feedback)
ToolManager.getStatusFeedback()
. Tools should not generally try to change the status
message unless they are currently the exclusive tool. Status-feedback while not being the
exclusive tool should be provided using getActivationFeedback(MouseEditEvent)
.
feedback
- the feedback message to set@CallOnEDT protected ToolManager getManager()
ToolManager
or null
if this tool is not currently associated
with a tool manager.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |