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 classAutoScaleAction.AutoScaleModeA list of things we can zoom to.private classAutoScaleAction.MapFrameAdapterAdapter for MapFrame change eventsprivate classAutoScaleAction.ZoomChangeAdapterAdapter 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 intlastZoomAreaLast zoomed boundsprotected longlastZoomTimeTime of last zoom to bounds actionprivate AutoScaleAction.AutoScaleModemodeOne 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.privateAutoScaleAction(AutoScaleAction.AutoScaleMode mode, boolean marker)Constructs a newAutoScaleAction.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactionPerformed(java.awt.event.ActionEvent e)voidautoScale()Performs this auto scale operation for the mode this action is in.static voidautoScale(AutoScaleAction.AutoScaleMode mode)Performs the auto scale operation of the given mode without the need to create a new action.protected LayergetFirstSelectedLayer()Replies the first selected layer in the layer list dialog.private static intgetModeShortcut(java.lang.String mode)protected voidinstallAdapters()Installs the listeners to this action.private static voidmodeData(BoundingXYVisitor v)private voidmodeDownload()private voidmodeLayer(BoundingXYVisitor v)private static voidmodeProblem(ValidatorDialog.ValidatorBoundingXYVisitor v)private voidmodeSelectionOrConflict(BoundingXYVisitor v)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.static voidzoomTo(java.util.Collection<? extends IPrimitive> sel)Zooms the view to display the given set of primitives.static voidzoomToSelection()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: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()
-
installAdapters
protected final void installAdapters()
Description copied from class:JosmActionInstalls 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:
installAdaptersin classJosmAction
-
-