Package org.openstreetmap.josm.actions
Class CreateCircleAction
- java.lang.Object
-
- javax.swing.AbstractAction
-
- org.openstreetmap.josm.actions.JosmAction
-
- org.openstreetmap.josm.actions.CreateCircleAction
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.io.Serializable
,java.lang.Cloneable
,java.util.EventListener
,javax.swing.Action
,Destroyable
public final class CreateCircleAction extends JosmAction
- Create a new circle from two selected nodes or a way with 2 nodes which represent the diameter of the circle. - Create a new circle from three selected nodes--or a way with 3 nodes. - Useful for roundabouts Notes: * If a way is selected, it is changed. If nodes are selected a new way is created. So if you've got a way with nodes it makes a difference between running this on the way or the nodes! * The existing nodes are retained, and additional nodes are inserted regularly to achieve the desired number of nodes (`createcircle.nodecount`). BTW: Someone might want to implement projection corrections for this...- Since:
- 996
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
CreateCircleAction.PolarNode
Class designed to create a couple between a node and its angle relative to the center of the circle.-
Nested classes/interfaces inherited from class org.openstreetmap.josm.actions.JosmAction
JosmAction.ActiveLayerChangeAdapter, JosmAction.LayerChangeAdapter, JosmAction.SelectionChangeAdapter
-
-
Field Summary
-
Fields inherited from class org.openstreetmap.josm.actions.JosmAction
sc
-
-
Constructor Summary
Constructors Constructor Description CreateCircleAction()
Constructs a newCreateCircleAction
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
actionPerformed(java.awt.event.ActionEvent e)
private static int[]
distributeNodes(CreateCircleAction.PolarNode[] angles, int nodesCount)
Distributes nodes according to the algorithm of election with largest remainder.private static void
notifyNodesNotOnCircle()
private static void
notifyNodesOutsideWorld()
private static java.util.List<Node>
orderNodesByTrafficHand(java.util.List<Node> nodes)
Order nodes according to left/right hand traffic.private static java.util.List<Node>
orderNodesByWay(java.util.List<Node> nodes, Way way)
Order nodes according to way direction.static void
runOn(DataSet ds)
Run the action on the given dataset.protected void
updateEnabledState()
Override in subclasses to update the enabled state of the action when something in the JOSM state changes, i.e.protected void
updateEnabledState(java.util.Collection<? extends OsmPrimitive> selection)
Override in subclasses to update the enabled state of the action if the collection of selected primitives changes.-
Methods inherited from class org.openstreetmap.josm.actions.JosmAction
buildActiveLayerChangeAdapter, buildLayerChangeAdapter, checkAndConfirmOutlyingOperation, destroy, getLayerManager, getShortcut, initEnabledState, installAdapters, listenToLayerChange, listenToSelectionChange, setHelpId, setToolbarId, setTooltip, updateEnabledStateOnCurrentSelection, updateEnabledStateOnCurrentSelection, updateEnabledStateOnModifiableSelection, waitFuture
-
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
-
-
-
-
Constructor Detail
-
CreateCircleAction
public CreateCircleAction()
Constructs a newCreateCircleAction
.
-
-
Method Detail
-
distributeNodes
private static int[] distributeNodes(CreateCircleAction.PolarNode[] angles, int nodesCount)
Distributes nodes according to the algorithm of election with largest remainder.- Parameters:
angles
- Array of PolarNode ordered by increasing anglesnodesCount
- Number of nodes to be distributed- Returns:
- Array of number of nodes to put in each arc
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent e)
-
runOn
public static void runOn(DataSet ds)
Run the action on the given dataset.- Parameters:
ds
- dataset- Since:
- 14542
-
orderNodesByTrafficHand
private static java.util.List<Node> orderNodesByTrafficHand(java.util.List<Node> nodes)
Order nodes according to left/right hand traffic.- Parameters:
nodes
- Nodes list to be ordered.- Returns:
- Modified nodes list ordered according hand traffic.
-
orderNodesByWay
private static java.util.List<Node> orderNodesByWay(java.util.List<Node> nodes, Way way)
Order nodes according to way direction.- Parameters:
nodes
- Nodes list to be ordered.way
- Way used to determine direction.- Returns:
- Modified nodes list with same direction as way.
-
notifyNodesNotOnCircle
private static void notifyNodesNotOnCircle()
-
notifyNodesOutsideWorld
private static void notifyNodesOutsideWorld()
-
updateEnabledState
protected void updateEnabledState()
Description copied from class:JosmAction
Override in subclasses to update the enabled state of the action when something in the JOSM state changes, i.e. when a layer is removed or added. SeeJosmAction.updateEnabledState(Collection)
to respond to changes in the collection of selected primitives. Default behavior is empty.- Overrides:
updateEnabledState
in classJosmAction
- See Also:
JosmAction.updateEnabledState(Collection)
,JosmAction.initEnabledState()
,JosmAction.listenToLayerChange()
-
updateEnabledState
protected void updateEnabledState(java.util.Collection<? extends OsmPrimitive> selection)
Description copied from class:JosmAction
Override in subclasses to update the enabled state of the action if the collection of selected primitives changes. This method is called with the new selection.- Overrides:
updateEnabledState
in classJosmAction
- Parameters:
selection
- the collection of selected primitives; may be empty, but not null- See Also:
JosmAction.updateEnabledState()
,JosmAction.initEnabledState()
,JosmAction.listenToSelectionChange()
-
-