source: josm/trunk/src/org/openstreetmap/josm/gui/mappaint/IconElemStyle.java@ 3128

Last change on this file since 3128 was 2675, checked in by jttt, 14 years ago

MapPaintVisitor - delegate drawing to styles, MapPaintVisitor should only select correct style and then let primitives draw in correct order. (not finished yet)

  • Property svn:eol-style set to native
File size: 1.7 KB
Line 
1package org.openstreetmap.josm.gui.mappaint;
2
3import javax.swing.GrayFilter;
4import javax.swing.ImageIcon;
5
6import org.openstreetmap.josm.data.osm.Node;
7import org.openstreetmap.josm.data.osm.OsmPrimitive;
8import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings;
9import org.openstreetmap.josm.data.osm.visitor.paint.MapPainter;
10
11public class IconElemStyle extends ElemStyle
12{
13 public ImageIcon icon;
14 private ImageIcon disabledIcon;
15 public boolean annotate;
16
17 public IconElemStyle (IconElemStyle i, long maxScale, long minScale) {
18 this.icon = i.icon;
19 this.annotate = i.annotate;
20 this.priority = i.priority;
21 this.maxScale = maxScale;
22 this.minScale = minScale;
23 this.rules = i.rules;
24 }
25 public IconElemStyle() { init(); }
26
27 public void init() {
28 icon = null;
29 priority = 0;
30 annotate = true;
31 }
32
33 public ImageIcon getDisabledIcon() {
34 if (disabledIcon != null)
35 return disabledIcon;
36 if (icon == null)
37 return null;
38 return disabledIcon = new ImageIcon(GrayFilter.createDisabledImage(icon.getImage()));
39 }
40 @Override
41 public void paintPrimitive(OsmPrimitive primitive, MapPaintSettings settings, MapPainter painter, boolean selected) {
42 if (painter.isShowIcons()) {
43 Node n = (Node) primitive;
44 String name = painter.isShowNames()?painter.getNodeName(n):null;
45 painter.drawNodeIcon(n, (painter.isInactive() || n.isDisabled())?getDisabledIcon():icon,
46 annotate, selected, name);
47 } else {
48 SimpleNodeElemStyle.INSTANCE.paintPrimitive(primitive, settings, painter, selected);
49 }
50
51 }
52}
Note: See TracBrowser for help on using the repository browser.