Package org.openstreetmap.josm.actions
Class SetGridOriginAction
- java.lang.Object
-
- javax.swing.AbstractAction
-
- org.openstreetmap.josm.actions.JosmAction
-
- org.openstreetmap.josm.actions.SetGridOriginAction
-
- All Implemented Interfaces:
java.awt.event.ActionListener,java.io.Serializable,java.lang.Cloneable,java.util.EventListener,javax.swing.Action,Destroyable
public class SetGridOriginAction extends JosmAction
Moves the origin of the grid drawn over the map to the current selection, so that grid lines pass through it, and enables the grid. The origin is the position of the selected node, or the centroid (arithmetic mean position) of all nodes reachable from the current selection (nodes of selected ways, node members of selected relations) if more than one node is involved.- Since:
- 19640
- See Also:
MapGridPaintable,AlignGridRotationAction, Serialized Form
-
-
Nested Class Summary
-
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 SetGridOriginAction()Constructs a newSetGridOriginAction.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactionPerformed(java.awt.event.ActionEvent e)(package private) static EastNorthgetCentroid(DataSet ds)Computes the centroid of the current selection: the (arithmetic mean) position of every node reachable from the selected primitives (the selected nodes themselves, the nodes of selected ways, and the node members of selected relations).static voidsetOrigin(EastNorth position)Sets the grid origin (in the coordinates of the current grid type) and enables the grid.protected voidupdateEnabledState()Override in subclasses to update the enabled state of the action when something in the JOSM state changes, i.e.protected voidupdateEnabledState(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
-
SetGridOriginAction
public SetGridOriginAction()
Constructs a newSetGridOriginAction.
-
-
Method Detail
-
updateEnabledState
protected void updateEnabledState()
Description copied from class:JosmActionOverride 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:
updateEnabledStatein classJosmAction- See Also:
JosmAction.updateEnabledState(Collection),JosmAction.initEnabledState(),JosmAction.listenToLayerChange()
-
updateEnabledState
protected void updateEnabledState(java.util.Collection<? extends OsmPrimitive> selection)
Description copied from class:JosmActionOverride 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:
updateEnabledStatein classJosmAction- Parameters:
selection- the collection of selected primitives; may be empty, but not null- See Also:
JosmAction.updateEnabledState(),JosmAction.initEnabledState(),JosmAction.listenToSelectionChange()
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent e)
-
getCentroid
static EastNorth getCentroid(DataSet ds)
Computes the centroid of the current selection: the (arithmetic mean) position of every node reachable from the selected primitives (the selected nodes themselves, the nodes of selected ways, and the node members of selected relations). For a single selected node this is simply that node's position.- Parameters:
ds- the data set, may benull- Returns:
- the centroid, or
nullif the selection contains no node with known coordinates
-
-