|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jpicedt.graphic.toolkit.EditorKit
public class EditorKit
A pluggable EditorKit
for a PECanvas
, that mainly provides mouse-tool management,
e.g. zooming, selecting and drawing capabilities, together with a set of Action
's.
Action
's that make sense for this EditorKit
are implemented as static inner
classes to reduce name space. They can be shared across multiple PECanvas
through the use of
an ActionDispatcher
given to the Action
constructor.
New mouseTool's can be registered via the registerMouseTool method ; they're backed by a hashMap,
and can be activated (ie set as the current mouse-tool) by using setCurrentMouseTool with the tool name as
the parameter string.
This EditorKit
provides also a ViewFactory
, which delegates most of its behaviour
to an underlying factory (except for the View associated with the RootElement
of the
Drawing
), and whose type depends on the current content-type, as set by setContentType. This
allows the "root-view" to maintain a reference to the container (which this EditorKit
can
easily provide), while still allowing underlying ViewFactory
's to be really independant of the
exact structure of the Drawing
(especially the existence of a
RootElement
). Besides, the EditorKit
can plug a new ViewFactory
on-the-fly when the content-type changed, w/o other objects having to be informed.
[todo]
Nested Class Summary | |
---|---|
static class |
EditorKit.ActivateSnapAction
Toggles grid-snap activation |
static class |
EditorKit.CopyAction
Copy target's content to clipboard |
static class |
EditorKit.CutAction
Cut target's content to clipboard |
static class |
EditorKit.DeleteAction
Delete the current selection |
class |
EditorKit.DeleteConvexZoneAction
|
static class |
EditorKit.EditBoundingBoxAction
Edit Drawing 's bounding box. |
static class |
EditorKit.EditDispositionAction
Bring one or more selected objets to back, to front, forward or backward. |
static class |
EditorKit.EditGeometryAction
Open a dialog that allows the user to edit the geometry of the currently selected element from a dialog box. |
static class |
EditorKit.EditTextModeAction
Allows the user to switch the text to a small icon and back to full size. |
static class |
EditorKit.GroupAction
Group all selected objects into a new PicGroup. |
static class |
EditorKit.JoinCurvesAction
Join all selected objects of type PicMultiCurveConvertable into a new PicMultiCurve. |
static class |
EditorKit.PasteAction
Paste the content of the given ClipBoard into the target canvas. |
static class |
EditorKit.SelectAllAction
selects all objects in the current active internal frame |
static class |
EditorKit.SelectMouseToolAction
Sets the current mouse-tool for the editor-kit. |
static class |
EditorKit.ShowGridAction
Toggles grid's visible state |
static class |
EditorKit.ToggleEditPointsModeAction
Toggles the EditorKit's edit-points-mode b/w LOCAL_MODE and GLOBAL_MODE. |
static class |
EditorKit.ToggleUseConvexZoneModeAction
Bascule le mode use-convex-zone-mode de l' EditorKit entre
USE et NOT_USE . |
static class |
EditorKit.ZoomInAction
zoom in |
static class |
EditorKit.ZoomOutAction
zoom out |
Field Summary | |
---|---|
protected PECanvas |
board
the PECanvas this EditorKit is installed in. null if not installed |
static String |
CZ_DRAWING_TRANSLATE
|
static String |
CZ_DRAWING_TRIM
|
static String |
CZ_EDIT
|
static String |
CZ_SELECT
|
static String |
EDIT_MODE_CHANGE
property name for edit mode change : "edit-mode" |
static String |
EDIT_POINT
point edition tool |
protected EventListenerList |
listenerList
list of HelpMessageListener's and PropertyChangeListener's for this EditorKit |
static String |
MIRROR
mirror |
static String |
MOVE
move |
static String |
ROTATE
rotate |
static String |
SCALE
scale |
static String |
SELECT
selection |
static String |
SHEAR
shear |
static String |
ZOOM
zoom mode |
Constructor Summary | |
---|---|
EditorKit()
Construct a new EditorKit with SELECT being the default initial edit-mode, and a default viewfactory. |
|
EditorKit(ContentType contentType,
EditorKit oldKit)
Construct a new EditorKit with SELECT being the default initial edit-mode. |
Method Summary | |
---|---|
void |
addHelpMessageListener(HelpMessageListener l)
adds a HelpMessageListener to the listener list |
void |
addPropertyChangeListener(PropertyChangeListener l)
adds a PropertyChangeListener to the listener list |
static ActionMap |
createActionMap(ActionDispatcher dispatcher,
ActionLocalizer localizer)
|
ContentType |
createDefaultContentType()
Creates a default content-type suited for this editor. |
InputMap |
createInputMap()
|
void |
deinstall(PECanvas board)
Called when the kit is being removed from a PECanvas . |
protected void |
firePropertyChange(String propertyName,
Object oldValue,
Object newValue)
Notify all listeners that have registered interest for notification on this event type. |
static String[][] |
getAvailableConvexZoneToolNames()
Renvoie une liste d'outils à la souris de manipulation de zone convexes, lesdits outils étant enrgistrés par défaut pour l' EditorKit . |
static String[][] |
getAvailableToolNames()
Returns all mousetool-names registered by default with this EditorKit. |
PECanvas |
getCanvas()
Return the PECanvas into which this kit is installed, or null if the kit has not been
installed yet. |
static Clipboard |
getClipboard()
Return a static reference to the local ClipBoard shared across all instance of this EditorKit |
ConvexZoneSelectionHandler |
getConvexZoneSelectionHandler()
|
MouseTool |
getCurrentMouseTool()
|
MouseTool.MouseToolType |
getCurrentMouseToolType()
|
DialogFactory |
getDialogFactory()
Returns the factory that produces GUI dialogs |
FormatterFactory |
getFormatterFactory()
|
HighlighterFactory |
getHighlighterFactory()
Return the factory delegate for producing View's Highlighters |
PicAttributeSet |
getInputAttributes()
Get the input attributes for the PECanvas attached to this EditorKit . |
PopupMenuFactory |
getPopupMenuFactory()
|
Collection<MouseTool> |
getRegisteredMouseTools()
|
Set<String> |
getRegisteredMouseToolsByName()
|
SelectionHandler |
getSelectionHandler()
|
ViewFactory |
getViewFactory()
|
void |
install(PECanvas board)
Called when the kit is being installed into a PECanvas . |
boolean |
isConvexZoneSetShown()
|
EditorKit.DeleteConvexZoneAction |
newDeleteConvexZoneAction(ActionDispatcher actionDispatcher,
ActionLocalizer localizer)
|
void |
paint(Graphics2D g,
Rectangle2D allocation,
double scale)
Allow this EditorKit to paint shapes specific to the current tool, either directly,
or through the paint method of its tools. |
protected void |
postHelpMessage(String message)
Notify all listeners that have registered interest for notification on this event type. |
void |
registerMouseTool(String key,
MouseTool mt)
Registers the given mouse-tool by associating it with the given key in the hashtable of available mouse-tools. |
void |
removeHelpMessageListener(HelpMessageListener l)
removes an HelpMessageListener from the EditorKit |
void |
removePropertyChangeListener(PropertyChangeListener l)
removes an PropertyChangeListener from the EditorKit |
void |
setCurrentMouseTool(String editMode)
set the current mouse tool for this editor kit When setting a new edit-mode, the editor kit fire a PropertyChange Event with key "EDIT_MODE_CHANGE" and the given edit-mode as the new value. |
void |
setDialogFactory(DialogFactory dm)
Sets the factory that produces GUI dialogs |
void |
setFactoriesFromContentType(ContentType ct)
Plugs new FormatterFactory and ViewFactory into this EditorKit ,
using the given ContentType to create them on-the-fly. |
void |
setHighlighterFactory(HighlighterFactory hf)
Sets the factory delegate for producing View's Highlighters |
void |
setInputAttributes(PicAttributeSet set)
set the input attributes for the PECanvas attached to this EditorKit . |
void |
setIsConvexZoneSetShown(boolean v)
|
void |
setPopupMenuFactory(PopupMenuFactory popupMenuFactory)
Set the popup-menu factory that produces a JPopupMenu when the EditorKit asks
for it. |
void |
unRegisterMouseTool(String key)
Unregisters the mouse-tool having the given key from the hashmap of available mouse-tools. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String ZOOM
public static final String SELECT
public static final String EDIT_POINT
public static final String MOVE
public static final String SCALE
public static final String ROTATE
public static final String MIRROR
public static final String SHEAR
public static final String CZ_SELECT
public static final String CZ_EDIT
public static final String CZ_DRAWING_TRANSLATE
public static final String CZ_DRAWING_TRIM
public static final String EDIT_MODE_CHANGE
protected PECanvas board
protected EventListenerList listenerList
Constructor Detail |
---|
public EditorKit()
public EditorKit(ContentType contentType, EditorKit oldKit)
contentType
- if non-null, this set the view- and formatter- factories to use for rendering the associated content ;
otherwise, default factories are created using createDefaultContentType()
.oldKit
- if an old instance already existed, and one wishes to reuse its properties, e.g.
listener-list, popupmenu-factory, input-attributes,… except obviously for the ViewFactory
and the FormatterFactory given as arguments. May be safely be set to null.Method Detail |
---|
public MouseTool.MouseToolType getCurrentMouseToolType()
MouseTool.MouseToolType
définissant le
type de l'outil souris courant.public boolean isConvexZoneSetShown()
boolean
, vraie si les zone convexes sont
visonnées, faux si elles sont masquées.public void setIsConvexZoneSetShown(boolean v)
public void install(PECanvas board)
PECanvas
.
This registers default mouse-tools, ie :
board
- the PECanvaspublic void deinstall(PECanvas board)
PECanvas
. This is used to unregister any
previously registered mouse-tool.
board
- the PECanvaspublic PECanvas getCanvas()
PECanvas
into which this kit is installed, or null if the kit has not been
installed yet.
public void setFactoriesFromContentType(ContentType ct)
FormatterFactory
and ViewFactory
into this EditorKit
,
using the given ContentType to create them on-the-fly.
ct
- if null, a default content-type is used, as returned by createDefaultContentType
public ContentType createDefaultContentType()
public PicAttributeSet getInputAttributes()
PECanvas
attached to this EditorKit
.
public void setInputAttributes(PicAttributeSet set)
PECanvas
attached to this EditorKit
.
public FormatterFactory getFormatterFactory()
FormatterFactory
used to write the content of a Drawing to a stream, according
to the type of content this kit can edit.public static String[][] getAvailableToolNames()
public static String[][] getAvailableConvexZoneToolNames()
EditorKit
.
public void registerMouseTool(String key, MouseTool mt)
setCurrentMouseTool()
.
public void unRegisterMouseTool(String key)
public Set<String> getRegisteredMouseToolsByName()
public Collection<MouseTool> getRegisteredMouseTools()
public void setCurrentMouseTool(String editMode)
When setting a new edit-mode, the editor kit fire a PropertyChange Event with key
"EDIT_MODE_CHANGE" and the given edit-mode as the new value.
This may be used by the UI to get informed that a change occured (since some
mouse-tools in this kit may change the edit-mode from the inside).
editMode
- a previously registered mouseTool's keypublic MouseTool getCurrentMouseTool()
MouseTool
for this EditorKit
.public void addPropertyChangeListener(PropertyChangeListener l)
public void removePropertyChangeListener(PropertyChangeListener l)
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
public void addHelpMessageListener(HelpMessageListener l)
public void removeHelpMessageListener(HelpMessageListener l)
protected void postHelpMessage(String message)
public void setPopupMenuFactory(PopupMenuFactory popupMenuFactory)
JPopupMenu
when the EditorKit
asks
for it. In this implementation, a popup-menu gets raised if :
public PopupMenuFactory getPopupMenuFactory()
JPopupMenu
's for this EditorKit
.public void setDialogFactory(DialogFactory dm)
public DialogFactory getDialogFactory()
public void paint(Graphics2D g, Rectangle2D allocation, double scale)
EditorKit
to paint shapes specific to the current tool, either directly,
or through the paint method of its tools.
scale
- the current scale factor b/w model-coordinates and view-coordinates ; this depends on the
AffineTransform
being currently active in PECanvas
's paintComponent,
and may be used, e.g. to scale down lines thickness so that they're displayed with a constant
thickness whatever the scale factor attached to Graphics2D (this is faster than retrieving the
AffineTransform attached to the graphic context given as parameter, and computing the scale
factor by using getScaleX).public ViewFactory getViewFactory()
ViewFactory
that produces View's for the kind of content-type this editor-kit
can edit or create.public HighlighterFactory getHighlighterFactory()
public void setHighlighterFactory(HighlighterFactory hf)
public SelectionHandler getSelectionHandler()
public ConvexZoneSelectionHandler getConvexZoneSelectionHandler()
public EditorKit.DeleteConvexZoneAction newDeleteConvexZoneAction(ActionDispatcher actionDispatcher, ActionLocalizer localizer)
public static ActionMap createActionMap(ActionDispatcher dispatcher, ActionLocalizer localizer)
public InputMap createInputMap()
public static Clipboard getClipboard()
|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |