source: josm/trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyle.java@ 3858

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

mapcss: support for opacity & icon-image

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.mappaint;
3
4import org.openstreetmap.josm.data.osm.OsmPrimitive;
5import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings;
6import org.openstreetmap.josm.data.osm.visitor.paint.MapPainter;
7
8abstract public class ElemStyle {
9
10 public float z_index;
11 public float object_z_index;
12
13 public ElemStyle(float z_index, float object_z_index) {
14 this.z_index = z_index;
15 this.object_z_index = object_z_index;
16 }
17
18 protected ElemStyle(Cascade c) {
19 z_index = c.get("z-index", 0f, Float.class);
20 object_z_index = c.get("object-z-index", 0f, Float.class);
21 }
22
23 public abstract void paintPrimitive(OsmPrimitive primitive, MapPaintSettings paintSettings, MapPainter painter, boolean selected, boolean member);
24
25 @Override
26 public boolean equals(Object o) {
27 if (!(o instanceof ElemStyle))
28 return false;
29 ElemStyle s = (ElemStyle) o;
30 return z_index == s.z_index && object_z_index == s.object_z_index;
31 }
32
33 @Override
34 public int hashCode() {
35 int hash = 5;
36 hash = 41 * hash + Float.floatToIntBits(this.z_index);
37 hash = 41 * hash + Float.floatToIntBits(this.object_z_index);
38 return hash;
39 }
40
41 @Override
42 public String toString() {
43 if (z_index != 0f || object_z_index != 0f)
44 return String.format("z_idx=%s/%s ", z_index, object_z_index);
45 return "";
46 }
47
48 public static Integer color_float2int(Float val) {
49 if (val == null || val < 0 || val > 1)
50 return null;
51 return (int) (255f * val + 0.5f);
52 }
53
54 public static Float color_int2float(Integer val) {
55 if (val == null || val < 0 || val > 255)
56 return null;
57 return ((float) val) / 255f;
58 }
59}
Note: See TracBrowser for help on using the repository browser.