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 class
TileSourceDisplaySettings.DisplaySettingsChangeEvent
An event that is created whenever the display settings change.static interface
TileSourceDisplaySettings.DisplaySettingsChangeListener
A listener that listens to changes to theTileSourceDisplaySettings
object.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
AUTO_LOAD
A string returned byTileSourceDisplaySettings.DisplaySettingsChangeEvent.getChangedSetting()
if auto load was changed.static java.lang.String
AUTO_ZOOM
A string returned byTileSourceDisplaySettings.DisplaySettingsChangeEvent.getChangedSetting()
if auto zoom was changed.private boolean
autoLoad
if layer automatically loads new tilesprivate boolean
autoZoom
if layers changes automatically, when user zooms inprivate EastNorth
displacement
the displacement (basically caches the displacement from the offsetBookmark in the current projection)private static java.lang.String
DISPLACEMENT
private java.util.concurrent.CopyOnWriteArrayList<TileSourceDisplaySettings.DisplaySettingsChangeListener>
listeners
private OffsetBookmark
offsetBookmark
private static java.lang.String
PREFERENCE_PREFIX
private OffsetBookmark
previousOffsetBookmark
static BooleanProperty
PROP_AUTO_LOAD
The default auto load propertystatic BooleanProperty
PROP_AUTO_ZOOM
The default auto zoom propertyprivate static java.lang.String
SHOW_ERRORS
A string returned byTileSourceDisplaySettings.DisplaySettingsChangeEvent.getChangedSetting()
if the show errors property was changed.private boolean
showErrors
if layer should show errors on tiles
-
Constructor Summary
Constructors Modifier Constructor Description TileSourceDisplaySettings()
Create a newTileSourceDisplaySettings
TileSourceDisplaySettings(java.lang.String preferencePrefix)
Create a newTileSourceDisplaySettings
private
TileSourceDisplaySettings(java.lang.String... prefixes)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSettingsChangeListener(TileSourceDisplaySettings.DisplaySettingsChangeListener l)
Add a listener that listens to display settings changes.void
applyFromPropertiesMap(java.util.Map<java.lang.String,java.lang.String> data)
Load the settings from the given data instance.boolean
equals(java.lang.Object obj)
private void
fireSettingsChange(java.lang.String changedSetting)
Notifies all listeners that the paint settings have changedEastNorth
getDisplacement()
Gets the displacement of the imagejava.lang.String
getDisplacementString(java.util.Locale locale)
Gets the displacement of the image formatted as a stringdouble
getDx()
Gets the displacement in x (east) directiondouble
getDy()
Gets the displacement in y (north) directionOffsetBookmark
getOffsetBookmark()
Gets the offset bookmark in use.OffsetBookmark
getPreviousOffsetBookmark()
Gets the offset bookmark previously in use.private static boolean
getProperty(java.lang.String[] prefixes, java.lang.String name, java.lang.Boolean def)
int
hashCode()
boolean
isAutoLoad()
Gets if the layer should automatically load new tiles.boolean
isAutoZoom()
Let the layer zoom automatically if the user zooms inboolean
isShowErrors()
If the layer should display the errors it encountered while loading the tiles.void
removeSettingsChangeListener(TileSourceDisplaySettings.DisplaySettingsChangeListener l)
Remove a listener that listens to display settings changes.void
setAutoLoad(boolean autoLoad)
Sets the auto load propertyvoid
setAutoZoom(boolean autoZoom)
Sets the auto zoom propertyprivate void
setDisplacement(EastNorth displacement)
void
setOffsetBookmark(OffsetBookmark offsetBookmark)
Sets an offset bookmark to use.void
setShowErrors(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.String
toString()
-
-
-
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
-true
to 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:
true
if it should
-
setAutoLoad
public void setAutoLoad(boolean autoLoad)
Sets the auto load property- Parameters:
autoLoad
-true
if 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:
true
to show errors.
-
setShowErrors
public void setShowErrors(boolean showErrors)
Sets the show errors property. Fires a change event.- Parameters:
showErrors
-true
if 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:
toPropertiesMap
in 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:
applyFromPropertiesMap
in interfaceSessionAwareReadApply
- Parameters:
data
- The data- See Also:
toPropertiesMap()
,OffsetBookmark.fromPropertiesMap(java.util.Map)
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-