public class CADToolAdapter extends Behavior
Allows user interact with different CAD tools, on a layer being edited.
There are two ways of interacting:
CADTool
that
produces mouse events as consequence of the actions working with the layer
being edited.CADTool
mouse actions can also be called writing a command or
a command's parameter in the associated edition console, and pressing the key
Enter
. If the command isn't valid, will notify it.The edition has been implemented as a finite machine, with three kind of transitions between states according the parameters introduced:
text
matches
with any pattern of parameters needed for any kind of point coordinates.String
and dealt as an option of the
current tool state. Ultimately, if isn't valid, text
will be
rewritten in the console notifying the user that isn't correct.Behavior
,
MapControl
Modifier and Type | Field and Description |
---|---|
static int |
ABSOLUTE
Identifies that the data are absolute coordinates of the new point from
the (0, 0) position.
|
static int |
POLAR_SCP
Identifies that the data are relative polar distances (longitude of the
line and angle given in degrees) of the new point from the previous
introduced.
|
static int |
POLAR_SCU
Identifies that the data are relative polar distances (longitude of the
line and angle given in radians) of the new point from the previous
introduced.
|
static int |
RELATIVE_SCP
Equivalent to
CADToolAdapter#ABSOLUTE . |
static int |
RELATIVE_SCU
Identifies that the data are relative distances of the new point from the
previous introduced.
|
BUTTON_LEFT, BUTTON_MIDDLE, BUTTON_RIGHT, geomManager
Constructor and Description |
---|
CADToolAdapter() |
Modifier and Type | Method and Description |
---|---|
static void |
addCADTool(String name,
CADTool c)
Associates and stores the specified name with the specified
CADTool . |
void |
askQuestion()
Displays at the console associated to the current active view that's
being edited, the question of the following operation that user can do
with the current
CADTool , only if it hasn't just answered. |
void |
configureMenu()
If there are options related with the
CADTool at the peek
of the CAD tool stack, displays them as a popup. |
void |
delete()
Removes all geometries selected in the associated
MapControl . |
GeometryType |
getActiveLayerGeometryType()
Returns the GeometryType of the current active and vector layer being
edited.
|
int |
getActiveLayerType()
Deprecated.
use
getActiveLayerGeometryType() instead. To be
removed in gvSIG 2.1 |
CADTool |
getCadTool()
Returns the
CADTool at the top of the stack without
removing it from the CAD tool stack. |
CADTool |
getCADTool(String text)
Returns the
CADTool to which the specified name is
mapped. |
static CADTool[] |
getCADTools()
Gets all CAD tools available to edit layers with this tool listener.
|
IEditionManager |
getEditionManager()
Gets the object used to manage the edition of the layers of the
associated
MapControl . |
ToolListener |
getListener()
Shows or hides a grid on the
ViewPort of the associated
MapControl . |
void |
initializeFlatness()
Initializes the flatness with the defined in preferences.
|
boolean |
isOrtoMode()
Determines if is enabled or not the orto mode.
|
void |
keyPressed(String actionCommand)
Responds to actions of writing common key commands for all kind of CAD
operations, enabling/disabling after the controls to manage the available
information according the tool selected:
eliminar: removes the geometries that are now selected.
|
void |
mouseClicked(MouseEvent e)
Responds two kind of mouse click events:
One click of the third mouse's button: displays a popup
with edition options.
|
void |
mouseDragged(MouseEvent e) |
void |
mouseEntered(MouseEvent e) |
void |
mouseExited(MouseEvent e) |
void |
mouseMoved(MouseEvent e) |
void |
mousePressed(MouseEvent e)
Selects the vertex of a geometry at the point selected on the
MapControl by pressing the first mouse's button. |
void |
mouseReleased(MouseEvent e) |
void |
mouseWheelMoved(MouseWheelEvent e)
Tries to find the nearest geometry or grid control point by the position
of the current snap tool.
|
void |
paintComponent(MapControlDrawer mapControlDrawer)
Draws the selected geometries to edit.
|
void |
popCadTool()
Removes the peek of the CAD tool stack.
|
void |
pushCadTool(CADTool cadTool)
Pushes a
CADTool onto the top of the CAD tool stack, and
sets it as current. |
void |
refreshEditedLayer()
Applies a lightweight repaint of the active layer being edited.
|
void |
setCadTool(CADTool cadTool)
Empties the CAD tools stack and pushes
cadTool in it. |
void |
setMapControl(MapControl mc)
Associates this behavior to a
MapControl object. |
void |
setOrtoMode(boolean b)
Enables / disables the orto mode.
|
void |
textEntered(String text)
Process the information written by the user about the next point
coordinate, determining the kind of transition according the
parameters written.
|
void |
transition(String option)
One of the three kind of transaction methods of the finite machine
of edition.
|
clean, createArc, createArc, createArc, createCircle, createLineString, createPoint, createPoint, getImageCursor, getMapControl, isMyButton, isMyButton, paintComponent, resetMyButton
public static final int ABSOLUTE
public static final int RELATIVE_SCP
CADToolAdapter#ABSOLUTE
.public static final int RELATIVE_SCU
public static final int POLAR_SCP
public static final int POLAR_SCU
public void setMapControl(MapControl mc)
IBehavior
Associates this behavior to a MapControl
object.
setMapControl
in interface IBehavior
setMapControl
in class Behavior
mc
- the MapControl
object to associateIBehavior.getMapControl()
public void paintComponent(MapControlDrawer mapControlDrawer)
Draws the selected geometries to edit. And, if the snapping is enabled, draws also its effect over them.
paintComponent
in interface IBehavior
paintComponent
in class Behavior
com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#paintComponent(java.awt.Graphics)
public void mouseClicked(MouseEvent e) throws BehaviorException
Responds two kind of mouse click events:
mouseClicked
in interface IBehavior
mouseClicked
in class Behavior
BehaviorException
- any exception processing the action associated to a mouse clicked event, by the IBehavior
objectcom.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseClicked(java.awt.event.MouseEvent)
,
CADExtension.showPopup(MouseEvent)
public void mouseEntered(MouseEvent e) throws BehaviorException
mouseEntered
in interface IBehavior
mouseEntered
in class Behavior
BehaviorException
- any exception processing the action associated to a mouse entered event, by the IBehavior
objectMouseListener.mouseEntered(java.awt.event.MouseEvent)
public void mouseExited(MouseEvent e) throws BehaviorException
mouseExited
in interface IBehavior
mouseExited
in class Behavior
BehaviorException
- any exception processing the action associated to a mouse exited event, by the IBehavior
objectMouseListener.mouseExited(java.awt.event.MouseEvent)
public void mousePressed(MouseEvent e) throws BehaviorException
MapControl
by pressing the first mouse's button.mousePressed
in interface IBehavior
mousePressed
in class Behavior
BehaviorException
- any exception processing the action associated to a mouse pressed event, by the IBehavior
objectcom.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mousePressed(java.awt.event.MouseEvent)
public void mouseReleased(MouseEvent e) throws BehaviorException
mouseReleased
in interface IBehavior
mouseReleased
in class Behavior
BehaviorException
- any exception processing the action associated to a mouse released event, by the IBehavior
objectMouseListener.mouseReleased(java.awt.event.MouseEvent)
public void mouseDragged(MouseEvent e) throws BehaviorException
mouseDragged
in interface IBehavior
mouseDragged
in class Behavior
BehaviorException
- any exception processing the action associated to a mouse dragged event, by the IBehavior
objectMouseMotionListener.mouseDragged(java.awt.event.MouseEvent)
public void mouseMoved(MouseEvent e) throws BehaviorException
mouseMoved
in interface IBehavior
mouseMoved
in class Behavior
BehaviorException
- any exception processing the action associated to a mouse moved event, by the IBehavior
objectMouseMotionListener.mouseMoved(java.awt.event.MouseEvent)
public void mouseWheelMoved(MouseWheelEvent e) throws BehaviorException
Tries to find the nearest geometry or grid control point by the position of the current snap tool.
Prioritizes the grid control points than the geometries ones.
If finds any near, stores the map and pixel coordinates for
the snap, and enables the bForceCoord
attribute for the next
draw of the mouse's cursor.
mouseWheelMoved
in interface IBehavior
mouseWheelMoved
in class Behavior
point
- current mouse 2D positionBehaviorException
- any exception processing the action associated to a mouse wheel event, by the IBehavior
objectMouseWheelListener.mouseWheelMoved(java.awt.event.MouseWheelEvent)
public void textEntered(String text)
Process the information written by the user about the next point coordinate, determining the kind of transition according the parameters written.
After, invokes one of the three possible transition methods of the finite machine of edition:
text
matches with any pattern of parameters needed for any kind of point
coordinates.String
and dealt as an option of the
current tool state. Ultimately, if isn't valid, text
will be
rewritten in the console notifying the user that isn't correct.text
- command written by user in the edition's consolepublic void configureMenu()
CADTool
at the peek
of the CAD tool stack, displays them as a popup.public void transition(String option)
One of the three kind of transaction methods of the finite machine of edition.
This one deals option
as an option of the current tool
state. Ultimately, if isn't valid, option
will be rewritten
in the console notifying the user that isn't correct.
option
- option for the current tool stateCADTool.transition(String)
,
transition(double[], InputEvent, int)
,
transition(double)
public ToolListener getListener()
ViewPort
of the associated
MapControl
.getListener
in interface IBehavior
getListener
in class Behavior
value
- true
to make the grid visible; false
to make it invisibleToolListener
used by this behaviorpublic CADTool getCadTool()
CADTool
at the top of the stack without
removing it from the CAD tool stack.CADTool
at the top of the stackpushCadTool(CADTool)
,
popCadTool()
,
setCadTool(CADTool)
public void pushCadTool(CADTool cadTool)
Pushes a CADTool
onto the top of the CAD tool stack, and
sets it as current.
cadTool
- CAD tool to enable as currentgetCadTool()
,
popCadTool()
,
setCadTool(CADTool)
public void popCadTool()
pushCadTool(CADTool)
,
getCadTool()
,
setCadTool(CADTool)
public void askQuestion()
Displays at the console associated to the current active view that's
being edited, the question of the following operation that user can do
with the current CADTool
, only if it hasn't just answered.
The format of the question will be according the following pattern:
"\n#"{cadtool at CAD tool stack peek}.getQuestion()">"
public void setCadTool(CADTool cadTool)
cadTool
in it.cadTool
- CAD tool to set at the peek of the stackpushCadTool(CADTool)
,
popCadTool()
,
getCadTool()
public void delete()
Removes all geometries selected in the associated MapControl
.
public void keyPressed(String actionCommand)
Responds to actions of writing common key commands for all kind of CAD operations, enabling/disabling after the controls to manage the available information according the tool selected:
MapControl
:
SelectionCADTool
, which is identified by
_selection and allows select features of the active vector layer
of the associated MapControl
instance.MapControl
instance isn't identified by "cadtooladapter", changes the enabled
tool by the previous.actionCommand
- identifier of the key action command executed by the userSelectionCADTool
,
MapControl.setPrevTool()
public void refreshEditedLayer()
Applies a lightweight repaint of the active layer being edited.
All layers under it won't be drawn, only the upper one and whose are over that layer in the TOC.
MapControl.rePaintDirtyLayers()
public boolean isOrtoMode()
true
if is enabled the orto mode;
otherwise false
setOrtoMode(boolean)
public void setOrtoMode(boolean b)
b
- the desired valueisOrtoMode()
public static void addCADTool(String name, CADTool c)
CADTool
.name
- name of the toolc
- CAD tool to interactuate editing the layersgetCADTools()
,
getCADTool(String)
public static CADTool[] getCADTools()
addCADTool(String, CADTool)
,
getCADTool(String)
public CADTool getCADTool(String text)
CADTool
to which the specified name is
mapped.text
- name of the tooladdCADTool(String, CADTool)
,
getCADTools()
public IEditionManager getEditionManager()
MapControl
.IEditionManager
public void initializeFlatness()
Initializes the flatness with the defined in preferences.
The flatness is the maximum tolerance used to approximate curved lines in a shape by polylines.
The shapes doesn't support primitive like arcs neither other curved lines to draw their geometries, then for drawing any kind of this geometries the curved lines are drawn approximately by a polyline. And for doing more realistic that curves, is used the flatness parameter, that indicates that the difference between each arc and the straight segment that approximates it must be in the worse case, like the flatness.
FConverter#FLATNESS
public GeometryType getActiveLayerGeometryType()
Returns the GeometryType of the current active and vector layer being edited.
FLyrVect#getGeom
public int getActiveLayerType()
getActiveLayerGeometryType()
instead. To be
removed in gvSIG 2.1Returns the type of the shape that's the current active and vector layer being edited.
FLyrVect.getGeometryType()