001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.gui.mappaint.styleelement; 003 004import org.openstreetmap.josm.data.osm.Node; 005import org.openstreetmap.josm.gui.mappaint.Cascade; 006import org.openstreetmap.josm.gui.mappaint.Environment; 007import org.openstreetmap.josm.gui.mappaint.Keyword; 008import org.openstreetmap.josm.gui.mappaint.MultiCascade; 009import org.openstreetmap.josm.gui.mappaint.StyleElementList; 010import org.openstreetmap.josm.gui.mappaint.StyleKeys; 011import org.openstreetmap.josm.gui.mappaint.styleelement.BoxTextElement.BoxProvider; 012 013/** 014 * Default element styles. 015 * @since 14193 016 */ 017public final class DefaultStyles implements StyleKeys { 018 019 private DefaultStyles() { 020 // Hide public constructor 021 } 022 023 /** 024 * The style used for simple nodes 025 */ 026 public static final NodeElement SIMPLE_NODE_ELEMSTYLE; 027 028 /** 029 * A box provider that provides the size of a simple node 030 */ 031 public static final BoxProvider SIMPLE_NODE_ELEMSTYLE_BOXPROVIDER; 032 033 static { 034 MultiCascade mc = new MultiCascade(); 035 mc.getOrCreateCascade("default"); 036 SIMPLE_NODE_ELEMSTYLE = NodeElement.create(new Environment(null, mc, "default", null), 4.1f, true); 037 if (SIMPLE_NODE_ELEMSTYLE == null) throw new AssertionError(); 038 SIMPLE_NODE_ELEMSTYLE_BOXPROVIDER = SIMPLE_NODE_ELEMSTYLE.getBoxProvider(); 039 } 040 041 /** 042 * The default style a simple node should use for it's text 043 */ 044 public static final BoxTextElement SIMPLE_NODE_TEXT_ELEMSTYLE; 045 046 static { 047 MultiCascade mc = new MultiCascade(); 048 Cascade c = mc.getOrCreateCascade("default"); 049 c.put(TEXT, Keyword.AUTO); 050 Node n = new Node(); 051 n.put("name", "dummy"); 052 SIMPLE_NODE_TEXT_ELEMSTYLE = BoxTextElement.create(new Environment(n, mc, "default", null), SIMPLE_NODE_ELEMSTYLE.getBoxProvider()); 053 if (SIMPLE_NODE_TEXT_ELEMSTYLE == null) throw new AssertionError(); 054 } 055 056 /** 057 * The default styles that are used for nodes. 058 * @see DefaultStyles#SIMPLE_NODE_ELEMSTYLE 059 */ 060 public static final StyleElementList DEFAULT_NODE_STYLELIST = new StyleElementList(DefaultStyles.SIMPLE_NODE_ELEMSTYLE); 061 062 /** 063 * The default styles that are used for nodes with text. 064 */ 065 public static final StyleElementList DEFAULT_NODE_STYLELIST_TEXT = new StyleElementList(DefaultStyles.SIMPLE_NODE_ELEMSTYLE, 066 DefaultStyles.SIMPLE_NODE_TEXT_ELEMSTYLE); 067}