1 | package org.openstreetmap.josm.gui.mappaint;
|
---|
2 |
|
---|
3 | import javax.swing.GrayFilter;
|
---|
4 | import javax.swing.ImageIcon;
|
---|
5 |
|
---|
6 | import org.openstreetmap.josm.data.osm.Node;
|
---|
7 | import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
---|
8 | import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings;
|
---|
9 | import org.openstreetmap.josm.data.osm.visitor.paint.MapPainter;
|
---|
10 |
|
---|
11 | public 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 | }
|
---|