public class ElemStyles extends Object implements Preferences.PreferenceChangedListener
Modifier and Type | Field and Description |
---|---|
private int |
cacheIdx |
private boolean |
defaultLines |
private int |
defaultLinesIdx |
private boolean |
defaultNodes |
private int |
defaultNodesIdx |
private boolean |
drawMultipolygon |
private Map<String,String> |
preferenceCache |
private List<StyleSource> |
styleSources |
Constructor and Description |
---|
ElemStyles()
Constructs a new
ElemStyles . |
Modifier and Type | Method and Description |
---|---|
(package private) void |
add(StyleSource style)
add a style source; only accessed from MapPaintStyles
|
private static <T> void |
addIfNotNull(List<T> list,
T obj) |
(package private) void |
clear()
remove all style sources; only accessed from MapPaintStyles
|
void |
clearCached()
Clear the style cache for all primitives of all DataSets.
|
private <T> T |
fromCanvas(String key,
T def,
Class<T> c) |
Pair<StyleElementList,Range> |
generateStyles(OsmPrimitive osm,
double scale,
boolean pretendWayIsClosed)
Create the list of styles and its valid scale range for one primitive.
|
StyleElementList |
get(OsmPrimitive osm,
double scale,
NavigatableComponent nc)
Create the list of styles for one primitive.
|
static AreaElement |
getAreaElemStyle(OsmPrimitive p,
boolean pretendWayIsClosed)
Returns the first AreaElement for a given primitive.
|
private Pair<StyleElementList,Range> |
getImpl(OsmPrimitive osm,
double scale,
NavigatableComponent nc)
Create the list of styles and its valid scale range for one primitive.
|
String |
getPreferenceCached(String key,
String def)
Looks up a preference value and ensures the style cache is invalidated
as soon as this preference value is changed by the user.
|
Pair<StyleElementList,Range> |
getStyleCacheWithRange(OsmPrimitive osm,
double scale,
NavigatableComponent nc)
Create the list of styles and its valid scale range for one primitive.
|
List<StyleSource> |
getStyleSources() |
static boolean |
hasAreaElemStyle(OsmPrimitive p,
boolean pretendWayIsClosed)
Determines whether primitive has an AreaElement.
|
static boolean |
hasOnlyAreaElemStyle(OsmPrimitive p)
Determines whether primitive has only an AreaElement.
|
private boolean |
isDefaultLines()
Draw a default line for ways that do not have an own line style?
|
private boolean |
isDefaultNodes()
Draw a default node symbol for nodes that have no style?
|
boolean |
isDrawMultipolygon() |
void |
preferenceChanged(Preferences.PreferenceChangeEvent e)
Trigerred when a preference entry value changes.
|
void |
setDrawMultipolygon(boolean drawMultipolygon) |
(package private) void |
setStyleSources(Collection<StyleSource> sources)
set the style sources; only accessed from MapPaintStyles
|
private final List<StyleSource> styleSources
private boolean drawMultipolygon
private int cacheIdx
private boolean defaultNodes
private boolean defaultLines
private int defaultNodesIdx
private int defaultLinesIdx
private final Map<String,String> preferenceCache
public ElemStyles()
ElemStyles
.public void clearCached()
public List<StyleSource> getStyleSources()
public StyleElementList get(OsmPrimitive osm, double scale, NavigatableComponent nc)
osm
- the primitivescale
- the scale (in meters per 100 pixel)nc
- display componentpublic Pair<StyleElementList,Range> getStyleCacheWithRange(OsmPrimitive osm, double scale, NavigatableComponent nc)
osm
- OSM primitivescale
- scalenc
- navigatable componentprivate Pair<StyleElementList,Range> getImpl(OsmPrimitive osm, double scale, NavigatableComponent nc)
osm
- OSM primitivescale
- scalenc
- navigatable componentpublic Pair<StyleElementList,Range> generateStyles(OsmPrimitive osm, double scale, boolean pretendWayIsClosed)
osm
- the primitive to create styles forscale
- the scale (in meters per 100 px), must be > 0pretendWayIsClosed
- For styles that require the way to be closed,
we pretend it is. This is useful for generating area styles from the (segmented)
outer ways of a multipolygon.private static <T> void addIfNotNull(List<T> list, T obj)
private boolean isDefaultNodes()
true
if default node symbol must be drawnprivate boolean isDefaultLines()
true
if default line must be drawnprivate <T> T fromCanvas(String key, T def, Class<T> c)
public boolean isDrawMultipolygon()
public void setDrawMultipolygon(boolean drawMultipolygon)
void clear()
void add(StyleSource style)
style
- style source to addvoid setStyleSources(Collection<StyleSource> sources)
sources
- new style sourcespublic static AreaElement getAreaElemStyle(OsmPrimitive p, boolean pretendWayIsClosed)
p
- the OSM primitivepretendWayIsClosed
- For styles that require the way to be closed,
we pretend it is. This is useful for generating area styles from the (segmented)
outer ways of a multipolygon.null
.public static boolean hasAreaElemStyle(OsmPrimitive p, boolean pretendWayIsClosed)
p
- the OSM primitivepretendWayIsClosed
- For styles that require the way to be closed,
we pretend it is. This is useful for generating area styles from the (segmented)
outer ways of a multipolygon.true
if primitive has an AreaElementpublic static boolean hasOnlyAreaElemStyle(OsmPrimitive p)
p
- the OSM primitivetrue
if primitive has only an AreaElementpublic String getPreferenceCached(String key, String def)
Main.pref.get()
) for
each primitive can be slow during rendering.key
- preference keydef
- default valuePreferences.get(String, String)
public void preferenceChanged(Preferences.PreferenceChangeEvent e)
Preferences.PreferenceChangedListener
preferenceChanged
in interface Preferences.PreferenceChangedListener
e
- the preference change event