source: josm/trunk/src/org/openstreetmap/josm/gui/mappaint/AreaElemStyle.java@ 3856

Last change on this file since 3856 was 3856, checked in by bastiK, 13 years ago

improve mapcss support

  • Property svn:eol-style set to native
File size: 1.9 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.mappaint;
3
4import java.awt.Color;
5
6import org.openstreetmap.josm.data.osm.OsmPrimitive;
7import org.openstreetmap.josm.data.osm.Relation;
8import org.openstreetmap.josm.data.osm.Way;
9import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings;
10import org.openstreetmap.josm.data.osm.visitor.paint.MapPainter;
11import org.openstreetmap.josm.tools.Utils;
12
13public class AreaElemStyle extends ElemStyle
14{
15 public Color color;
16
17 protected AreaElemStyle(Cascade c, Color color) {
18 super(c);
19 this.color = color;
20 }
21
22 public static AreaElemStyle create(Cascade c) {
23 Color color = c.get("fill-color", null, Color.class);
24 if (color == null)
25 return null;
26 return new AreaElemStyle(c, color);
27 }
28
29 @Override
30 public void paintPrimitive(OsmPrimitive primitive, MapPaintSettings paintSettings, MapPainter painter, boolean selected, boolean member) {
31 if (primitive instanceof Way) {
32 Way w = (Way) primitive;
33 String name = painter.isShowNames() ? painter.getAreaName(w) : null;
34 painter.drawArea(w, w.isSelected() ? paintSettings.getSelectedColor() : color, name);
35 } else if (primitive instanceof Relation) {
36 painter.drawArea((Relation) primitive, selected ? paintSettings.getRelationSelectedColor() : color, painter.getAreaName(primitive));
37 }
38 }
39
40 @Override
41 public boolean equals(Object obj) {
42 if (obj == null || getClass() != obj.getClass())
43 return false;
44 if (!super.equals(obj))
45 return false;
46 return Utils.equal(color, ((AreaElemStyle) obj).color);
47 }
48
49 @Override
50 public int hashCode() {
51 return 11 * super.hashCode() + color.hashCode();
52 }
53
54 @Override
55 public String toString() {
56 return "AreaElemStyle{" + super.toString() + "color=" + color + '}';
57 }
58}
Note: See TracBrowser for help on using the repository browser.