public final class ToolManager extends Object
Constructor and Description |
---|
ToolManager(ViewComponent viewComponent) |
Modifier and Type | Method and Description |
---|---|
void |
activate(Class<? extends Tool> tc)
Activates the tool of the given class.
|
void |
addPropertyChangeListener(PropertyChangeListener listener) |
void |
addPropertyChangeListener(String propertyName,
PropertyChangeListener listener) |
protected void |
changeEnabledState(Tool t,
boolean enabled) |
Tool |
deregister(Class<? extends Tool> tc)
Deregisters the tool of the given class if the tool instance of this class is currently
registered as tool.
|
ToolActivationPolicy |
getActivationPolicy() |
Class<? extends Tool> |
getActiveTool()
|
<T> Collection<T> |
getCompatibleTools(Class<T> clazz)
Return all registered Tools which are derived from the given class or which implement the given
interface.
|
<T> Collection<T> |
getCompatibleTools(Class<T> clazz,
boolean enabledOnly)
Return all registered Tools which are derived from the given class or which implement the given
interface.
|
Collection<? extends MenuContributor> |
getMenuContributors()
Return the current list of tools suitable as menu contributors.
|
Collection<Class<? extends Tool>> |
getRegisteredToolClasses()
Allows access to all registered tool classes.
|
String |
getStatusFeedback() |
<T extends Tool> |
getTool(Class<T> cls)
Return the tool instance for the given tool class, or
null if no such tool is
registered. |
static String |
getToolPropertyPrefix(Class<? extends Tool> tc)
Constructs the property name prefix for
Tool property change events. |
ViewComponent |
getViewComponent() |
void |
handleEditEvent(Class<?> context,
EditEvent e) |
boolean |
hasTool(Class<? extends Tool> cls)
Return whether this tool manager currently manages a tool of the given class.
|
boolean |
isActive(Class<? extends Tool> tc)
Return whether the tool of the given class is currently active.
|
protected boolean |
isActive(Tool t)
Return whether the given tool is currently active.
|
boolean |
isEnabled(Class<? extends Tool> tc)
Checks whether the given
Tool is enabled. |
boolean |
isExclusive()
Return whether the exclusive tool mode is active, i.e.
|
<T extends Tool> |
register(Class<T> tc,
boolean enabled)
Registers the tool of the given class if the tool instance of this class is not currently
registered as tool.
|
void |
removePropertyChangeListener(PropertyChangeListener listener) |
void |
removePropertyChangeListener(String propertyName,
PropertyChangeListener listener) |
void |
render(RenderParameters parameters)
Render the Tool UIs onto the given
Graphics2D context using the given
RenderControls . |
void |
repaint(Page p)
Repaint the area pertaining to the given page.
|
void |
repaint(Page p,
Rectangle2D boundsDU)
Repaint the area pertaining to the given page and bounds.
|
void |
setActivationPolicy(ToolActivationPolicy activationPolicy) |
protected void |
setCursor(Cursor cursor) |
void |
setEnabled(Class<? extends Tool> tc,
boolean enabled)
Change the enabled state of the tool of the given class.
|
void |
setExclusive(Class<? extends Tool> tc)
Set the tool of the given class to be the exclusive tool.
|
void |
setNonExclusive(Class<? extends Tool> tc)
Leave exclusive mode.
|
protected void |
setStatusFeedback(String statusFeedback) |
void |
toolPropertyChanged(Tool tool,
String propertyName,
Object oldValue,
Object newValue)
Send a
PropertyChangeEvent for the specified Tool property. |
@CallOnEDT public ToolManager(ViewComponent viewComponent)
@CallableOffEDT public static String getToolPropertyPrefix(Class<? extends Tool> tc)
Tool
property change events. Any Event sent
using toolPropertyChanged(Tool, String, Object, Object)
will use the value returned by
this class as a prefix.tc
- the Tool
implementation class@CallOnEDT public void repaint(Page p)
@CallOnEDT public void repaint(Page p, Rectangle2D boundsDU)
@CallOnEDT public ViewComponent getViewComponent()
@CallOnEDT public <T extends Tool> T register(Class<T> tc, boolean enabled)
tc
- the tool classenabled
- whether the tool will initially be enabledIllegalStateException
- if the calling thread is not the Event Dispatch
Thread
@CallOnEDT public Tool deregister(Class<? extends Tool> tc)
null
will be returned.
NOTE: Once the view component
has been realized, this method
must not be called on a thread other than the Event Dispatch Thread
. For
details please see: TGASwingUtil.ensureEventDispatchThread(Component)
tc
- the tool classnull
if available otherwise
null
. Be aware this tool instance is already deregistered when returned
and can not be used as tool anymore.IllegalStateException
- if the component has been realized and the calling thread is not
the Event Dispatch Thread
@CallOnEDT public void activate(Class<? extends Tool> tc)
NOTE: Once the view component
has been realized, this method
must not be called on a thread other than the Event Dispatch Thread
. For
details please see: TGASwingUtil.ensureEventDispatchThread(Component)
tc
- the tool classIllegalArgumentException
- if no tool of the given class is currently managed by this
ToolManager
.IllegalStateException
- if the component has been realized and the calling thread is not
the Event Dispatch Thread
@CallOnEDT public void handleEditEvent(Class<?> context, EditEvent e)
@CallableOffEDT public boolean hasTool(Class<? extends Tool> cls)
@CallableOffEDT public <T extends Tool> T getTool(Class<T> cls)
null
if no such tool is
registered.@CallOnEDT public boolean isActive(Class<? extends Tool> tc)
tc
- the tool classtrue
if the tool is active@CallOnEDT protected boolean isActive(Tool t)
t
- the tooltrue
if the tool is active@CallOnEDT public boolean isExclusive()
true
if exclusive mode is active@CallOnEDT public void render(RenderParameters parameters)
Graphics2D
context using the given
RenderControls
.
This render method is usually called within the context and during the rendering of a single page. It will dispatch the render calls to all active tools.
parameters
- the render parameters to use.@CallOnEDT public void setEnabled(Class<? extends Tool> tc, boolean enabled)
NOTE: Once the view component
has been realized, this method
must not be called on a thread other than the Event Dispatch Thread
. For
details please see: TGASwingUtil.ensureEventDispatchThread(Component)
tc
- the tool classenabled
- true
to enabled the tool, otherwise false
IllegalArgumentException
- if no tool of the given class is currently managed by this
ToolManager
.IllegalStateException
- if the component has been realized and the calling thread is not
the Event Dispatch Thread
@CallOnEDT protected void changeEnabledState(Tool t, boolean enabled)
@CallOnEDT public boolean isEnabled(Class<? extends Tool> tc)
@CallOnEDT public void setExclusive(Class<? extends Tool> tc)
NOTE: Once the view component
has been realized, this method
must not be called on a thread other than the Event Dispatch Thread
. For
details please see: TGASwingUtil.ensureEventDispatchThread(Component)
tc
- the class of the tool to make exclusiveIllegalArgumentException
- if no tool of the given class is currently managed by this
ToolManager
.IllegalStateException
- if the component has been realized and the calling thread is not
the Event Dispatch Thread
@CallOnEDT public void setNonExclusive(Class<? extends Tool> tc)
public void toolPropertyChanged(Tool tool, String propertyName, Object oldValue, Object newValue)
PropertyChangeEvent
for the specified Tool
property. The
property name
will be qualified using the
following schema: "ToolPropertyPrefix
.propertyName
"propertyName
- the property name, which will be prefixed with
a Tool specific prefix
getToolPropertyPrefix(Class)
@CallableOffEDT public void addPropertyChangeListener(PropertyChangeListener listener)
@CallableOffEDT public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
@CallableOffEDT public void removePropertyChangeListener(PropertyChangeListener listener)
@CallableOffEDT public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
@CallOnEDT public <T> Collection<T> getCompatibleTools(Class<T> clazz)
T
- type of class or interface in questionclazz
- the class or interface in question@CallOnEDT public <T> Collection<T> getCompatibleTools(Class<T> clazz, boolean enabledOnly)
T
- type of class or interface in questionclazz
- the class or interface in questionenabledOnly
- whether only enabled tools (true
) or all registered tools shall
be considered@CallableOffEDT public Collection<Class<? extends Tool>> getRegisteredToolClasses()
Tool
s. The returned Collection
is read-only and does not follow any kind of
sorting. (The order is random)Collection
of all registered Tool
classes.@CallOnEDT public Collection<? extends MenuContributor> getMenuContributors()
@CallOnEDT public void setActivationPolicy(ToolActivationPolicy activationPolicy)
@CallOnEDT public ToolActivationPolicy getActivationPolicy()
@CallOnEDT protected void setCursor(Cursor cursor)
@CallOnEDT protected void setStatusFeedback(String statusFeedback)
@CallOnEDT public String getStatusFeedback()
@CallOnEDT public Class<? extends Tool> getActiveTool()
Copyright © 2024 levigo holding gmbh. All rights reserved.