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

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

Separate styles from style generation. This may seem a little over the top, but its just an intermediate state of development, should make sense later. Regarding performance: execution time is the same, memory use is similar, or a little less (due to intern pool for StyleCache). Tested, but can have still some bugs.

  • Property svn:eol-style set to native
File size: 1.5 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.Way;
8import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings;
9import org.openstreetmap.josm.data.osm.visitor.paint.MapPainter;
10import org.openstreetmap.josm.tools.Utils;
11
12public class AreaElemStyle extends ElemStyle
13{
14 public Color color;
15
16 public AreaElemStyle(long minScale, long maxScale, Color color) {
17 super(minScale, maxScale);
18 this.color = color;
19 }
20
21 @Override
22 public void paintPrimitive(OsmPrimitive primitive, MapPaintSettings paintSettings, MapPainter painter, boolean selected, boolean member) {
23 if (primitive instanceof Way) {
24 Way w = (Way) primitive;
25 String name = painter.isShowNames() ? painter.getAreaName(w) : null;
26 painter.drawArea(w, w.isSelected() ? paintSettings.getSelectedColor() : color, name);
27 // line.paintPrimitive(way, paintSettings, painter, selected);
28 }
29 }
30
31 @Override
32 public boolean equals(Object obj) {
33 if (obj == null || getClass() != obj.getClass())
34 return false;
35 if (!super.equals(obj))
36 return false;
37 return Utils.equal(color, ((AreaElemStyle) obj).color);
38 }
39
40 @Override
41 public int hashCode() {
42 return color.hashCode();
43 }
44
45 @Override
46 public String toString() {
47 return "AreaElemStyle{" + "color=" + color + '}';
48 }
49}
Note: See TracBrowser for help on using the repository browser.