Class TileSourceDisplaySettings
- java.lang.Object
-
- org.openstreetmap.josm.gui.layer.imagery.TileSourceDisplaySettings
-
- All Implemented Interfaces:
SessionAwareReadApply
public class TileSourceDisplaySettings extends java.lang.Object implements SessionAwareReadApply
This are the preferences of how to display aTileSource.They have been extracted from the
AbstractTileSourceLayer. Each layer has one set of such settings.- Since:
- 10568
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTileSourceDisplaySettings.DisplaySettingsChangeEventAn event that is created whenever the display settings change.static interfaceTileSourceDisplaySettings.DisplaySettingsChangeListenerA listener that listens to changes to theTileSourceDisplaySettingsobject.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringAUTO_LOADA string returned byTileSourceDisplaySettings.DisplaySettingsChangeEvent.getChangedSetting()if auto load was changed.static java.lang.StringAUTO_ZOOMA string returned byTileSourceDisplaySettings.DisplaySettingsChangeEvent.getChangedSetting()if auto zoom was changed.private booleanautoLoadif layer automatically loads new tilesprivate booleanautoZoomif layers changes automatically, when user zooms inprivate EastNorthdisplacementthe displacement (basically caches the displacement from the offsetBookmark in the current projection)private static java.lang.StringDISPLACEMENTprivate java.util.concurrent.CopyOnWriteArrayList<TileSourceDisplaySettings.DisplaySettingsChangeListener>listenersprivate OffsetBookmarkoffsetBookmarkprivate static java.lang.StringPREFERENCE_PREFIXprivate OffsetBookmarkpreviousOffsetBookmarkstatic BooleanPropertyPROP_AUTO_LOADThe default auto load propertystatic BooleanPropertyPROP_AUTO_ZOOMThe default auto zoom propertyprivate static java.lang.StringSHOW_ERRORSA string returned byTileSourceDisplaySettings.DisplaySettingsChangeEvent.getChangedSetting()if the show errors property was changed.private booleanshowErrorsif layer should show errors on tiles
-
Constructor Summary
Constructors Modifier Constructor Description TileSourceDisplaySettings()Create a newTileSourceDisplaySettingsTileSourceDisplaySettings(java.lang.String preferencePrefix)Create a newTileSourceDisplaySettingsprivateTileSourceDisplaySettings(java.lang.String... prefixes)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSettingsChangeListener(TileSourceDisplaySettings.DisplaySettingsChangeListener l)Add a listener that listens to display settings changes.voidapplyFromPropertiesMap(java.util.Map<java.lang.String,java.lang.String> data)Load the settings from the given data instance.booleanequals(java.lang.Object obj)private voidfireSettingsChange(java.lang.String changedSetting)Notifies all listeners that the paint settings have changedEastNorthgetDisplacement()Gets the displacement of the imagejava.lang.StringgetDisplacementString(java.util.Locale locale)Gets the displacement of the image formatted as a stringdoublegetDx()Gets the displacement in x (east) directiondoublegetDy()Gets the displacement in y (north) directionOffsetBookmarkgetOffsetBookmark()Gets the offset bookmark in use.OffsetBookmarkgetPreviousOffsetBookmark()Gets the offset bookmark previously in use.private static booleangetProperty(java.lang.String[] prefixes, java.lang.String name, java.lang.Boolean def)inthashCode()booleanisAutoLoad()Gets if the layer should automatically load new tiles.booleanisAutoZoom()Let the layer zoom automatically if the user zooms inbooleanisShowErrors()If the layer should display the errors it encountered while loading the tiles.voidremoveSettingsChangeListener(TileSourceDisplaySettings.DisplaySettingsChangeListener l)Remove a listener that listens to display settings changes.voidsetAutoLoad(boolean autoLoad)Sets the auto load propertyvoidsetAutoZoom(boolean autoZoom)Sets the auto zoom propertyprivate voidsetDisplacement(EastNorth displacement)voidsetOffsetBookmark(OffsetBookmark offsetBookmark)Sets an offset bookmark to use.voidsetShowErrors(boolean showErrors)Sets the show errors property.java.util.Map<java.lang.String,java.lang.String>toPropertiesMap()Stores the current settings object to the given hashmap.java.lang.StringtoString()
-
-
-
Field Detail
-
AUTO_LOAD
public static final java.lang.String AUTO_LOAD
A string returned byTileSourceDisplaySettings.DisplaySettingsChangeEvent.getChangedSetting()if auto load was changed.- See Also:
isAutoLoad(), Constant Field Values
-
AUTO_ZOOM
public static final java.lang.String AUTO_ZOOM
A string returned byTileSourceDisplaySettings.DisplaySettingsChangeEvent.getChangedSetting()if auto zoom was changed.- See Also:
isAutoZoom(), Constant Field Values
-
SHOW_ERRORS
private static final java.lang.String SHOW_ERRORS
A string returned byTileSourceDisplaySettings.DisplaySettingsChangeEvent.getChangedSetting()if the show errors property was changed.- See Also:
isShowErrors(), Constant Field Values
-
DISPLACEMENT
private static final java.lang.String DISPLACEMENT
- See Also:
- Constant Field Values
-
PREFERENCE_PREFIX
private static final java.lang.String PREFERENCE_PREFIX
- See Also:
- Constant Field Values
-
PROP_AUTO_LOAD
public static final BooleanProperty PROP_AUTO_LOAD
The default auto load property
-
PROP_AUTO_ZOOM
public static final BooleanProperty PROP_AUTO_ZOOM
The default auto zoom property
-
autoZoom
private boolean autoZoom
if layers changes automatically, when user zooms in
-
autoLoad
private boolean autoLoad
if layer automatically loads new tiles
-
showErrors
private boolean showErrors
if layer should show errors on tiles
-
previousOffsetBookmark
private OffsetBookmark previousOffsetBookmark
-
offsetBookmark
private OffsetBookmark offsetBookmark
-
displacement
private EastNorth displacement
the displacement (basically caches the displacement from the offsetBookmark in the current projection)
-
listeners
private final java.util.concurrent.CopyOnWriteArrayList<TileSourceDisplaySettings.DisplaySettingsChangeListener> listeners
-
-
Constructor Detail
-
TileSourceDisplaySettings
public TileSourceDisplaySettings()
Create a newTileSourceDisplaySettings
-
TileSourceDisplaySettings
public TileSourceDisplaySettings(java.lang.String preferencePrefix)
Create a newTileSourceDisplaySettings- Parameters:
preferencePrefix- The additional prefix to scan for preferences.
-
TileSourceDisplaySettings
private TileSourceDisplaySettings(java.lang.String... prefixes)
-
-
Method Detail
-
getProperty
private static boolean getProperty(java.lang.String[] prefixes, java.lang.String name, java.lang.Boolean def)
-
isAutoZoom
public boolean isAutoZoom()
Let the layer zoom automatically if the user zooms in- Returns:
- auto zoom
-
setAutoZoom
public void setAutoZoom(boolean autoZoom)
Sets the auto zoom property- Parameters:
autoZoom-trueto let the layer zoom automatically if the user zooms in- See Also:
isAutoZoom(),AUTO_ZOOM
-
isAutoLoad
public boolean isAutoLoad()
Gets if the layer should automatically load new tiles.- Returns:
trueif it should
-
setAutoLoad
public void setAutoLoad(boolean autoLoad)
Sets the auto load property- Parameters:
autoLoad-trueif the layer should automatically load new tiles- See Also:
isAutoLoad(),AUTO_LOAD
-
isShowErrors
public boolean isShowErrors()
If the layer should display the errors it encountered while loading the tiles.- Returns:
trueto show errors.
-
setShowErrors
public void setShowErrors(boolean showErrors)
Sets the show errors property. Fires a change event.- Parameters:
showErrors-trueif the layer should display the errors it encountered while loading the tiles- See Also:
isShowErrors(),SHOW_ERRORS
-
getDx
public double getDx()
Gets the displacement in x (east) direction- Returns:
- The displacement.
- Since:
- 10571
- See Also:
getDisplacement()
-
getDy
public double getDy()
Gets the displacement in y (north) direction- Returns:
- The displacement.
- Since:
- 10571
- See Also:
getDisplacement()
-
getDisplacement
public EastNorth getDisplacement()
Gets the displacement of the image- Returns:
- The displacement.
- Since:
- 10571
-
getDisplacementString
public java.lang.String getDisplacementString(java.util.Locale locale)
Gets the displacement of the image formatted as a string- Parameters:
locale- the locale used to format the decimals- Returns:
- the displacement string
- Since:
- 15733
- See Also:
getDisplacement()
-
setOffsetBookmark
public void setOffsetBookmark(OffsetBookmark offsetBookmark)
Sets an offset bookmark to use. Loads the displacement from the bookmark.- Parameters:
offsetBookmark- the offset bookmark, may be null
-
getOffsetBookmark
public OffsetBookmark getOffsetBookmark()
Gets the offset bookmark in use.- Returns:
- the offset bookmark, may be null
-
getPreviousOffsetBookmark
public OffsetBookmark getPreviousOffsetBookmark()
Gets the offset bookmark previously in use.- Returns:
- the previously used offset bookmark, may be null
-
setDisplacement
private void setDisplacement(EastNorth displacement)
-
fireSettingsChange
private void fireSettingsChange(java.lang.String changedSetting)
Notifies all listeners that the paint settings have changed- Parameters:
changedSetting- The setting name
-
addSettingsChangeListener
public void addSettingsChangeListener(TileSourceDisplaySettings.DisplaySettingsChangeListener l)
Add a listener that listens to display settings changes.- Parameters:
l- The listener
-
removeSettingsChangeListener
public void removeSettingsChangeListener(TileSourceDisplaySettings.DisplaySettingsChangeListener l)
Remove a listener that listens to display settings changes.- Parameters:
l- The listener
-
toPropertiesMap
public java.util.Map<java.lang.String,java.lang.String> toPropertiesMap()
Stores the current settings object to the given hashmap. The offset data is not stored and needs to be handled separately.- Specified by:
toPropertiesMapin interfaceSessionAwareReadApply- Returns:
- map of properties
- See Also:
applyFromPropertiesMap(Map),OffsetBookmark.toPropertiesMap()
-
applyFromPropertiesMap
public void applyFromPropertiesMap(java.util.Map<java.lang.String,java.lang.String> data)
Load the settings from the given data instance. The offset data is not loaded and needs to be handled separately.- Specified by:
applyFromPropertiesMapin interfaceSessionAwareReadApply- Parameters:
data- The data- See Also:
toPropertiesMap(),OffsetBookmark.fromPropertiesMap(java.util.Map)
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-