- Timestamp:
- 2011-02-13T13:13:04+01:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/MapPainter.java
r3889 r3896 92 92 this.relationSelectedColor = PaintColors.RELATIONSELECTED.get(); 93 93 this.nodeColor = PaintColors.NODE.get(); 94 this.backgroundColor = PaintColors. BACKGROUND.get();94 this.backgroundColor = PaintColors.getBackgroundColor(); 95 95 96 96 this.orderFont = new Font(Main.pref.get("mappaint.font", "Helvetica"), Font.PLAIN, Main.pref.getInteger("mappaint.fontsize", 8)); -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/PaintColors.java
r3291 r3896 5 5 6 6 import java.awt.Color; 7 import java.util.List; 7 8 8 9 import org.openstreetmap.josm.Main; 9 10 import org.openstreetmap.josm.data.Preferences.ColorKey; 11 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles; 12 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles.MapPaintSylesUpdateListener; 13 import org.openstreetmap.josm.gui.mappaint.StyleSource; 10 14 11 15 public enum PaintColors implements ColorKey { … … 30 34 private final String name; 31 35 private final Color defaultColor; 36 37 private static Color backgroundColorCache = null; 38 39 private static final MapPaintSylesUpdateListener styleOverrideListener = new MapPaintSylesUpdateListener() { 40 41 public void mapPaintStylesUpdated() { 42 backgroundColorCache = null; 43 } 44 45 public void mapPaintStyleEntryUpdated(int idx) { 46 mapPaintStylesUpdated(); 47 } 48 }; 49 50 static { 51 MapPaintStyles.addMapPaintSylesUpdateListener(styleOverrideListener); 52 } 32 53 33 54 private PaintColors(String name, Color defaultColor) { … … 57 78 } 58 79 } 80 81 public static Color getBackgroundColor() { 82 if (backgroundColorCache != null) 83 return backgroundColorCache; 84 List<StyleSource> sources = MapPaintStyles.getStyles().getStyleSources(); 85 for (StyleSource s : sources) { 86 if (!s.active) { 87 continue; 88 } 89 Color backgroundColorOverride = s.getBackgroundColorOverride(); 90 if (backgroundColorOverride != null) { 91 backgroundColorCache = backgroundColorOverride; 92 } 93 } 94 if (backgroundColorCache == null) { 95 backgroundColorCache = BACKGROUND.get(); 96 } 97 return backgroundColorCache; 98 } 59 99 } -
trunk/src/org/openstreetmap/josm/gui/MapView.java
r3837 r3896 498 498 Graphics2D g2 = nonChangedLayersBuffer.createGraphics(); 499 499 g2.setClip(g.getClip()); 500 g2.setColor(PaintColors. BACKGROUND.get());500 g2.setColor(PaintColors.getBackgroundColor()); 501 501 g2.fillRect(0, 0, getWidth(), getHeight()); 502 502 -
trunk/src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java
r3894 r3896 70 70 import org.openstreetmap.josm.tools.ImageProvider; 71 71 import org.openstreetmap.josm.tools.Shortcut; 72 import org.openstreetmap.josm.tools.Utils; 72 73 73 74 public class MapPaintDialog extends ToggleDialog { … … 601 602 private JPanel buildInfoPanel(StyleSource s) { 602 603 JPanel p = new JPanel(new GridBagLayout()); 603 StringBuilder text = new StringBuilder("<table cellpadding=3><tr><td>"); 604 text.append("<b>" + tr("Name:") + "</b></td><td>" + s.getDisplayString() + "</td></tr>"); 605 text.append("<tr><td>"); 604 StringBuilder text = new StringBuilder("<table cellpadding=3>"); 605 text.append(tableRow(tr("Title:"), s.getDisplayString())); 606 606 if (s.url.startsWith("http://")) { 607 text.append( "<b>" + tr("URL:") + "</b></td><td>" + s.url + "</td></tr>");607 text.append(tableRow(tr("URL:"), s.url)); 608 608 } else if (s.url.startsWith("resource://")) { 609 text.append( "<b>" + tr("Built-in Style, internal path:</b>") + "</b></td><td>" + s.url + "</td></tr>");609 text.append(tableRow(tr("Built-in Style, internal path:"), s.url)); 610 610 } else { 611 text.append("<b>" + tr("Path:") + "</b></td><td>" + s.url + "</td></tr>"); 612 } 613 text.append("<tr><td><b>" + tr("Style is currently active?") + "</b></td><td>" + (s.active ? tr("Yes") : tr("No")) + "</td></tr>"); 611 text.append(tableRow(tr("Path:"), s.url)); 612 } 613 if (s.icon != null) { 614 text.append(tableRow(tr("Icon:"), s.icon)); 615 } 616 if (s.getBackgroundColorOverride() != null) { 617 text.append(tableRow(tr("Background:"), Utils.toString(s.getBackgroundColorOverride()))); 618 } 619 text.append(tableRow(tr("Style is currently active?"), s.active ? tr("Yes") : tr("No"))); 614 620 text.append("</table>"); 615 621 p.add(new JScrollPane(new HtmlPanel(text.toString())), GBC.eol().fill(GBC.BOTH)); 616 622 return p; 623 } 624 625 private String tableRow(String firstColumn, String secondColumn) { 626 return "<tr><td><b>" + firstColumn + "</b></td><td>" + secondColumn + "</td></tr>"; 617 627 } 618 628 -
trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java
r3893 r3896 9 9 import java.util.Arrays; 10 10 import java.util.Collection; 11 import java.util.Collections;12 11 import java.util.LinkedList; 13 12 import java.util.List; -
trunk/src/org/openstreetmap/josm/gui/mappaint/StyleSource.java
r3894 r3896 4 4 import static org.openstreetmap.josm.tools.I18n.trn; 5 5 6 import java.awt.Color; 6 7 import java.io.File; 7 8 import java.io.IOException; … … 99 100 errors.size(), errors.size()); 100 101 } 102 103 public Color getBackgroundColorOverride() { 104 return null; 105 } 101 106 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSource.java
r3894 r3896 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.Color; 6 7 import java.io.IOException; 7 8 import java.io.InputStream; … … 28 29 29 30 final public List<MapCSSRule> rules; 31 private Color backgroundColorOverride; 30 32 31 33 public MapCSSStyleSource(String url, String name, String shortdescription) { … … 47 49 parser.sheet(this); 48 50 loadMeta(); 51 loadCanvas(); 49 52 } catch(IOException e) { 50 53 System.err.println(tr("Warning: failed to load Mappaint styles from ''{0}''. Exception was: {1}", url, e.toString())); … … 78 81 */ 79 82 private void loadMeta() { 83 Cascade c = constructSpecial("meta"); 84 String pTitle = c.get("title", null, String.class); 85 if (title == null) { 86 title = pTitle; 87 } 88 String pIcon = c.get("icon", null, String.class); 89 if (icon == null) { 90 icon = pIcon; 91 } 92 } 93 94 private void loadCanvas() { 95 Cascade c = constructSpecial("canvas"); 96 backgroundColorOverride = c.get("background-color", null, Color.class); 97 } 98 99 private Cascade constructSpecial(String type) { 100 80 101 MultiCascade mc = new MultiCascade(); 81 102 Node n = new Node(); … … 88 109 for (MapCSSRule r : rules) { 89 110 for (Selector s : r.selectors) { 90 if (s.base.equals( "meta")) {111 if (s.base.equals(type)) { 91 112 for (Condition cnd : s.conds) { 92 113 if (!cnd.applies(env)) … … 99 120 } 100 121 } 101 Cascade c = mc.getCascade("default"); 102 String pTitle = c.get("title", null, String.class); 103 if (title == null) { 104 title = pTitle; 105 } 106 String pIcon = c.get("icon", null, String.class); 107 if (icon == null) { 108 icon = pIcon; 109 } 122 return mc.getCascade("default"); 123 } 124 125 public Color getBackgroundColorOverride() { 126 return backgroundColorOverride; 110 127 } 111 128 -
trunk/src/org/openstreetmap/josm/gui/preferences/ColorPreference.java
r3641 r3896 260 260 MarkerLayer.getColor(null); 261 261 GpxLayer.getColor(null); 262 OsmDataLayer.getBackgroundColor();263 262 OsmDataLayer.getOutsideColor(); 264 263 MapScaler.getColor();
Note:
See TracChangeset
for help on using the changeset viewer.