Package org.openstreetmap.josm.actions
Class AutoScaleAction
- java.lang.Object
-
- javax.swing.AbstractAction
-
- org.openstreetmap.josm.actions.JosmAction
-
- org.openstreetmap.josm.actions.AutoScaleAction
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.io.Serializable
,java.lang.Cloneable
,java.util.EventListener
,javax.swing.Action
,Destroyable
public class AutoScaleAction extends JosmAction
Toggles the autoScale feature of the mapView- Since:
- 17
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AutoScaleAction.AutoScaleMode
A list of things we can zoom to.private class
AutoScaleAction.MapFrameAdapter
Adapter for MapFrame change eventsprivate class
AutoScaleAction.ZoomChangeAdapter
Adapter for zoom change events-
Nested classes/interfaces inherited from class org.openstreetmap.josm.actions.JosmAction
JosmAction.ActiveLayerChangeAdapter, JosmAction.LayerChangeAdapter, JosmAction.SelectionChangeAdapter
-
-
Field Summary
Fields Modifier and Type Field Description protected int
lastZoomArea
Last zoomed boundsprotected long
lastZoomTime
Time of last zoom to bounds actionprivate AutoScaleAction.AutoScaleMode
mode
One ofAutoScaleAction.AutoScaleMode
.-
Fields inherited from class org.openstreetmap.josm.actions.JosmAction
sc
-
-
Constructor Summary
Constructors Modifier Constructor Description AutoScaleAction(AutoScaleAction.AutoScaleMode mode)
Constructs a newAutoScaleAction
.private
AutoScaleAction(AutoScaleAction.AutoScaleMode mode, boolean marker)
Constructs a newAutoScaleAction
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
actionPerformed(java.awt.event.ActionEvent e)
void
autoScale()
Performs this auto scale operation for the mode this action is in.static void
autoScale(AutoScaleAction.AutoScaleMode mode)
Performs the auto scale operation of the given mode without the need to create a new action.protected Layer
getFirstSelectedLayer()
Replies the first selected layer in the layer list dialog.private static int
getModeShortcut(java.lang.String mode)
protected void
installAdapters()
Installs the listeners to this action.private static void
modeData(BoundingXYVisitor v)
private void
modeDownload()
private void
modeLayer(BoundingXYVisitor v)
private static void
modeProblem(ValidatorDialog.ValidatorBoundingXYVisitor v)
private void
modeSelectionOrConflict(BoundingXYVisitor v)
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.static void
zoomTo(java.util.Collection<? extends IPrimitive> sel)
Zooms the view to display the given set of primitives.static void
zoomToSelection()
Zooms the current map view to the currently selected primitives.-
Methods inherited from class org.openstreetmap.josm.actions.JosmAction
buildActiveLayerChangeAdapter, buildLayerChangeAdapter, checkAndConfirmOutlyingOperation, destroy, getLayerManager, getShortcut, initEnabledState, 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
-
-
-
-
Field Detail
-
mode
private final AutoScaleAction.AutoScaleMode mode
One ofAutoScaleAction.AutoScaleMode
. Defines what we are zooming to.
-
lastZoomTime
protected long lastZoomTime
Time of last zoom to bounds action
-
lastZoomArea
protected int lastZoomArea
Last zoomed bounds
-
-
Constructor Detail
-
AutoScaleAction
private AutoScaleAction(AutoScaleAction.AutoScaleMode mode, boolean marker)
Constructs a newAutoScaleAction
.- Parameters:
mode
- The autoscale mode (one ofAutoScaleAction.AutoScaleMode
)marker
- Must be set to false. Used only to differentiate from default constructor
-
AutoScaleAction
public AutoScaleAction(AutoScaleAction.AutoScaleMode mode)
Constructs a newAutoScaleAction
.- Parameters:
mode
- The autoscale mode (one ofAutoScaleAction.AutoScaleMode
)- Since:
- 14221
-
-
Method Detail
-
zoomToSelection
public static void zoomToSelection()
Zooms the current map view to the currently selected primitives. Does nothing if there either isn't a current map view or if there isn't a current data layer.
-
zoomTo
public static void zoomTo(java.util.Collection<? extends IPrimitive> sel)
Zooms the view to display the given set of primitives.- Parameters:
sel
- The primitives to zoom to, e.g. the current selection.
-
autoScale
public static void autoScale(AutoScaleAction.AutoScaleMode mode)
Performs the auto scale operation of the given mode without the need to create a new action.- Parameters:
mode
- One ofAutoScaleAction.AutoScaleMode
.- Since:
- 14221
-
getModeShortcut
private static int getModeShortcut(java.lang.String mode)
-
autoScale
public void autoScale()
Performs this auto scale operation for the mode this action is in.
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent e)
-
getFirstSelectedLayer
protected Layer getFirstSelectedLayer()
Replies the first selected layer in the layer list dialog. null, if no such layer exists, either because the layer list dialog is not yet created or because no layer is selected.- Returns:
- the first selected layer in the layer list dialog
-
modeProblem
private static void modeProblem(ValidatorDialog.ValidatorBoundingXYVisitor v)
-
modeData
private static void modeData(BoundingXYVisitor v)
-
modeLayer
private void modeLayer(BoundingXYVisitor v)
-
modeSelectionOrConflict
private void modeSelectionOrConflict(BoundingXYVisitor v)
-
modeDownload
private void modeDownload()
-
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()
-
installAdapters
protected final void installAdapters()
Description copied from class:JosmAction
Installs the listeners to this action.This should either never be called or only called in the constructor of this action.
All registered adapters should be removed in
JosmAction.destroy()
- Overrides:
installAdapters
in classJosmAction
-
-