public abstract class ToolDraw extends Tool implements ViewEventListener, ViewManagerEventListener, java.awt.event.KeyListener, JMapEventDispatcher
| Modifier and Type | Field and Description |
|---|---|
protected AltKeyManager |
altKeyEventManager |
protected boolean |
altLastPressed |
protected boolean |
createStyledElement |
protected java.awt.Cursor |
cursorCrosshair |
protected java.awt.Cursor |
cursorWait |
protected java.text.DecimalFormat |
df |
protected boolean |
displayLabel |
protected VectorLayer |
drawLayer |
protected int |
drawLayerId |
protected EditionEventDispatcher |
eventDispatcher |
protected Point |
firstPointWc |
protected static int |
ID_DISTANCE_LINE |
protected static int |
ID_LABEL |
protected static int |
ID_LINE_TMP |
protected static int |
ID_SNAP_POINT |
protected boolean |
isPersistant |
protected Point |
lastMousePositionDc |
protected Point |
secPointWc |
protected boolean |
showAttributesEditor |
protected Layer[] |
snapLayers |
protected StyleContainer |
styleContainer |
protected K2DTransform |
t |
protected Rectangle |
toRedrawDc |
protected boolean |
useHighlightHandles |
protected boolean |
useUndoManager |
| Constructor and Description |
|---|
ToolDraw()
Initiates this drawing tool so that it isn't persistent, won't display any
label and draws elements in the default user drawing layer.
|
ToolDraw(int nbDecimals,
boolean displayLabel,
boolean isPersistant,
int drawLayerId,
StyleContainer styleContainer,
boolean useUndoManager)
Initiates this drawing tool
|
| Modifier and Type | Method and Description |
|---|---|
void |
addEditionEventListener(EditionEventListener listener) |
protected boolean |
altIsPressed(java.awt.event.MouseEvent me)
Determine if ALT key was pressed when this mouse event occurred.
|
protected boolean |
altLastPressed() |
protected boolean |
ctrlIsPressed(java.awt.event.MouseEvent me)
Determine if CTRL key was pressed when this mouse event occurred.
|
void |
dispatchEvent(JMapEvent event)
The
dispatchEvent method is used to dispatch synchronously
JMap events to all registered listeners. |
protected void |
fireEditionEvent(EditionEvent event) |
protected static StyleContainer |
genTrnsprntFillContainer(StyleContainer styleContainer)
Initializes and sets the ToolDrawStyleContainer with a transparent fill if
its null.
|
java.awt.Cursor |
getCursor()
returns the cursor
|
VectorLayer |
getDrawLayer()
Returns the layer used to store the drawn elements.
|
protected int |
getLabelAlignment() |
static Style |
getLabelStyle()
Initializes and sets the Style with parameters Color, labelPosition, etc...
|
static Style |
getLineStyle()
Initializes and sets the Style with parameters LineThickness,
RenderingHints.
|
StyleContainer |
getStyleContainer() |
void |
init(View view)
Initiates this drawing tool: Sets the view, the K2DTransform and sets the
layer if none was specified before
|
protected EditionEventDispatcher |
initEventDispatcher() |
boolean |
isCreateStyledElement()
Determines if the elements draw using this tool are styled elements (style
defined by the style container).
|
boolean |
isPersistant()
Deprecated.
use isPersistent instead
|
boolean |
isPersistent()
Determines if the elements drawn using this tool are persisted (placed on a
layer).
|
boolean |
isUseUndoManager() |
void |
keyPressed(java.awt.event.KeyEvent e)
KeyListener methods
|
void |
keyReleased(java.awt.event.KeyEvent e) |
void |
keyTyped(java.awt.event.KeyEvent e) |
static Geometry |
offsetGeometry(Geometry geo,
Point offset)
Add an offset to geometry.
|
void |
removeEditionEventListener(EditionEventListener listener) |
void |
setCreateStyledElement(boolean createStyledElement)
Specifies if the elements drawn using this tool are styled elements (style
defined by the style container).
|
void |
setDrawLayer(VectorLayer drawLayer)
Changes the layer used to store the drawn elements.
|
void |
setPersistant(boolean isPersistent)
Deprecated.
use setPersistent instead
|
void |
setPersistent(boolean isPersistent)
Specifies if the elements drawn using this tool are persisted (placed on a
layer).
|
void |
setShowAttributesEditor(boolean showAttributesEditor)
Specifies id the attributes editor will show when adding a new element.
|
void |
setStyleContainer(StyleContainer styleContainer) |
void |
setUseUndoManager(boolean useUndoManager)
Sets whether this tool uses the UndoManager.
|
protected boolean |
shiftIsPressed(java.awt.event.MouseEvent me)
Determine if SHIFT key was pressed when this mouse event occurred.
|
void |
terminate()
Terminates the current tool
|
static Geometry |
unoffsetGeometry(Geometry geo,
Point offset)
Remove an offset from geometry.
|
protected void |
updatePtMouseVars(Point p,
double x,
double y)
sets the WC location of the specified point using the current transform and
DC coordinates
|
protected void |
updatePtMouseVars(Point p,
java.awt.event.MouseEvent me)
sets the WC location of the specified point using the current transform and
DC coordinates
|
void |
viewActivated(ViewActivatedEvent e)
ViewManagerEventListener methods
|
void |
viewAdded(ViewAddedEvent e)
This method handles viewAdded
|
void |
viewChangedOccurred(ViewChangedEvent e)
This method handles ViewChangedEvent
|
void |
viewDeactivated(ViewDeactivatedEvent e)
This method handles viewActivated
|
void |
viewPopupMenuShowing(ViewPopupMenuShowingEvent e)
This method handles ViewPopupMenuShowing
|
void |
viewReadyOccurred(ViewReadyEvent e)
This method handles ViewReadyOccurred
|
void |
viewRedrawOccurred(ViewRedrawEvent e)
This method handles viewRedrawOccurred
|
void |
viewRemoved(ViewRemovedEvent e)
This method handles viewRemoved
|
void |
viewRepaintOccurred(ViewRepaintEvent e)
This method handles viewRepaintOccurred
|
void |
viewStaticElementChanged(ViewStaticElementEvent e)
This method handles viewStaticElementChanged
|
void |
viewToolChangedOccurred(ViewToolChangedEvent e)
ViewEventListener methods
|
getView, isAutoPan, onToolClicked, onToolDragged, onToolMoved, onToolPressed, onToolReleased, setAutoPan, toWCPointprotected java.awt.Cursor cursorCrosshair
protected java.awt.Cursor cursorWait
protected java.text.DecimalFormat df
protected Rectangle toRedrawDc
protected Point firstPointWc
protected Point secPointWc
protected Point lastMousePositionDc
protected boolean isPersistant
protected boolean displayLabel
protected VectorLayer drawLayer
protected int drawLayerId
protected K2DTransform t
protected StyleContainer styleContainer
protected boolean useUndoManager
protected Layer[] snapLayers
protected boolean useHighlightHandles
protected AltKeyManager altKeyEventManager
protected boolean createStyledElement
protected EditionEventDispatcher eventDispatcher
protected static final int ID_SNAP_POINT
protected static final int ID_LABEL
protected static final int ID_DISTANCE_LINE
protected static final int ID_LINE_TMP
protected boolean altLastPressed
protected boolean showAttributesEditor
public ToolDraw()
public ToolDraw(int nbDecimals,
boolean displayLabel,
boolean isPersistant,
int drawLayerId,
StyleContainer styleContainer,
boolean useUndoManager)
nbDecimals - The number of decimals to display on the labeldisplayLabel - if a label displaying the proportions of the element should be
drawnisPersistant - if the element needs to be stored once drawn or if it is just
volatiledrawLayerId - the layer where the element is addedstyleContainer - the style containeruseUndoManager - Whether the UndoManager is used or notprotected EditionEventDispatcher initEventDispatcher()
public void addEditionEventListener(EditionEventListener listener)
public void removeEditionEventListener(EditionEventListener listener)
public void dispatchEvent(JMapEvent event)
dispatchEvent method is used to dispatch synchronously
JMap events to all registered listeners. The main use of the JMapEventDispatcher
interface is to dispatch events that were previously added to the JMap event queue. EditionEvent will be accepted by this method. Any
other JMap event types will cause the tool to throw an exception.dispatchEvent in interface JMapEventDispatcherevent - the event to be dispatched.java.lang.IllegalArgumentException - will be thrown if the JMapEvent instance is not
an instance of the EditionEvent class.JMapEventQueue.push(JMapEvent, JMapEventDispatcher)protected void fireEditionEvent(EditionEvent event)
protected static StyleContainer genTrnsprntFillContainer(StyleContainer styleContainer)
public void init(View view)
public java.awt.Cursor getCursor()
public StyleContainer getStyleContainer()
public void setStyleContainer(StyleContainer styleContainer)
public void viewToolChangedOccurred(ViewToolChangedEvent e)
viewToolChangedOccurred in interface ViewEventListenere - the corresponding ViewToolChangedEvent objectpublic void viewChangedOccurred(ViewChangedEvent e)
ViewEventListenerviewChangedOccurred in interface ViewEventListenere - the corresponding ViewChangedEvent objectpublic void viewRedrawOccurred(ViewRedrawEvent e)
ViewEventListenerviewRedrawOccurred in interface ViewEventListenere - the corresponding ViewRedrawEvent objectpublic void viewRepaintOccurred(ViewRepaintEvent e)
ViewEventListenerviewRepaintOccurred in interface ViewEventListenere - the corresponding ViewRepaintEvent objectpublic void viewStaticElementChanged(ViewStaticElementEvent e)
ViewEventListenerviewStaticElementChanged in interface ViewEventListenere - the corresponding ViewStaticElementEvent objectpublic void viewPopupMenuShowing(ViewPopupMenuShowingEvent e)
ViewEventListenerviewPopupMenuShowing in interface ViewEventListenere - the corresponding ViewPopupMenuShowingEvent objectpublic void viewReadyOccurred(ViewReadyEvent e)
ViewEventListenerviewReadyOccurred in interface ViewEventListenere - the corresponding ViewReadyEvent objectpublic void viewActivated(ViewActivatedEvent e)
viewActivated in interface ViewManagerEventListenere - the corresponding ViewActivatedEvent objectpublic void viewDeactivated(ViewDeactivatedEvent e)
ViewManagerEventListenerviewDeactivated in interface ViewManagerEventListenere - the corresponding ViewDeactivatedEvent objectpublic void viewAdded(ViewAddedEvent e)
ViewManagerEventListenerviewAdded in interface ViewManagerEventListenere - the corresponding ViewAddedEvent objectpublic void viewRemoved(ViewRemovedEvent e)
ViewManagerEventListenerviewRemoved in interface ViewManagerEventListenere - the corresponding ViewRemovedEvent objectpublic void keyPressed(java.awt.event.KeyEvent e)
keyPressed in interface java.awt.event.KeyListenerpublic void keyReleased(java.awt.event.KeyEvent e)
keyReleased in interface java.awt.event.KeyListenerpublic void keyTyped(java.awt.event.KeyEvent e)
keyTyped in interface java.awt.event.KeyListenerpublic void setUseUndoManager(boolean useUndoManager)
useUndoManager - public boolean isUseUndoManager()
protected void updatePtMouseVars(Point p, double x, double y)
p - the point which we will set the location in WC with the specified
DC coordinatesx - the X coord in DCy - the Y coord in DCprotected void updatePtMouseVars(Point p, java.awt.event.MouseEvent me)
p - the point which we will set the location in WC with the specified
DC coordinatesme - the mouse event from which the DC coordinates will be taken.protected boolean altIsPressed(java.awt.event.MouseEvent me)
me - the mouse event to check if ALT key was pressed.protected boolean altLastPressed()
protected boolean ctrlIsPressed(java.awt.event.MouseEvent me)
me - the mouse event to check if CTRL key was pressed.protected boolean shiftIsPressed(java.awt.event.MouseEvent me)
me - the mouse event to check if SHIFT key was pressed.public static Style getLabelStyle()
public static Style getLineStyle()
public static Geometry unoffsetGeometry(Geometry geo, Point offset)
geo - the geometry that should be unoffsetted.offset - the point contains the offset values.public static Geometry offsetGeometry(Geometry geo, Point offset)
geo - the geometry that should be offsetted.offset - the point contains the offset values.protected int getLabelAlignment()
public VectorLayer getDrawLayer()
public void setDrawLayer(VectorLayer drawLayer)
drawLayer - new layer to use@Deprecated public boolean isPersistant()
public boolean isPersistent()
@Deprecated public void setPersistant(boolean isPersistent)
isPersistent - new persistent valuepublic void setPersistent(boolean isPersistent)
isPersistent - new persistent valuepublic void setCreateStyledElement(boolean createStyledElement)
true.createStyledElement - K2DStyledElementpublic boolean isCreateStyledElement()
true.K2DStyledElementpublic void setShowAttributesEditor(boolean showAttributesEditor)
showAttributesEditor -