- Timestamp:
- 2011-03-26T18:50:33+01:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/MapPaintVisitor.java
r3964 r4005 21 21 import org.openstreetmap.josm.gui.mappaint.ElemStyle; 22 22 import org.openstreetmap.josm.gui.mappaint.ElemStyles; 23 import org.openstreetmap.josm.gui.mappaint.LineElemStyle;24 23 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles; 25 24 import org.openstreetmap.josm.gui.mappaint.NodeElemStyle; … … 40 39 41 40 private class StyleCollector { 42 private List<Pair<ElemStyle, OsmPrimitive>> styleElems; 43 protected boolean memberSelected = false; 44 private Class klass; 45 46 public StyleCollector(Class<?> klass) { 41 private final boolean drawArea; 42 private final boolean drawMultipolygon; 43 private final boolean drawRestriction; 44 private final boolean memberSelected; 45 46 private final List<Pair<ElemStyle, OsmPrimitive>> styleElems; 47 48 public StyleCollector(boolean drawArea, boolean drawMultipolygon, boolean drawRestriction, boolean memberSelected) { 49 this.drawArea = drawArea; 50 this.drawMultipolygon = drawMultipolygon; 51 this.drawRestriction = drawRestriction; 52 this.memberSelected = memberSelected; 47 53 styleElems = new ArrayList<Pair<ElemStyle, OsmPrimitive>>(); 48 this.klass = klass; 49 } 50 51 public void add(OsmPrimitive osm) { 54 } 55 56 public void add(Node osm) { 52 57 StyleList sl = styles.get(osm, circum, nc); 53 58 for (ElemStyle s : sl) { 54 if (klass.isInstance(s)) { 59 styleElems.add(new Pair<ElemStyle, OsmPrimitive>(s, osm)); 60 } 61 } 62 63 public void add(Way osm) { 64 StyleList sl = styles.get(osm, circum, nc); 65 for (ElemStyle s : sl) { 66 if (!drawArea && s instanceof AreaElemStyle) { 67 continue; 68 } 69 styleElems.add(new Pair<ElemStyle, OsmPrimitive>(s, osm)); 70 } 71 } 72 73 public void add(Relation osm) { 74 StyleList sl = styles.get(osm, circum, nc); 75 for (ElemStyle s : sl) { 76 if (drawMultipolygon && drawArea && s instanceof AreaElemStyle) { 77 styleElems.add(new Pair<ElemStyle, OsmPrimitive>(s, osm)); 78 } else if (drawRestriction && s instanceof NodeElemStyle) { 55 79 styleElems.add(new Pair<ElemStyle, OsmPrimitive>(s, osm)); 56 80 } … … 63 87 p.a.paintPrimitive(p.b, paintSettings, painter, data.isSelected(p.b), memberSelected); 64 88 } 65 }66 67 public boolean isMemberSelected() {68 return memberSelected;69 }70 71 public void setMemberSelected(boolean memberSelected) {72 this.memberSelected = memberSelected;73 89 } 74 90 } … … 116 132 this.painter = new MapPainter(paintSettings, g, inactive, nc, virtual, circum, leftHandTraffic); 117 133 118 StyleCollector scDisabledLines = new StyleCollector(LineElemStyle.class); 119 StyleCollector scSelectedLines = new StyleCollector(LineElemStyle.class); 120 StyleCollector scSelectedAreas = new StyleCollector(AreaElemStyle.class); 121 StyleCollector scMemberLines = new StyleCollector(LineElemStyle.class); 122 scMemberLines.setMemberSelected(true); 123 StyleCollector scNormalAreas = new StyleCollector(AreaElemStyle.class); 124 StyleCollector scNormalLines = new StyleCollector(LineElemStyle.class); 134 StyleCollector scDisabledPrimitives = new StyleCollector(false, false, drawRestriction, false); 135 StyleCollector scSelectedPrimitives = new StyleCollector(drawArea, drawMultipolygon, drawRestriction, false); 136 StyleCollector scMemberPrimitives = new StyleCollector(drawArea, drawMultipolygon, drawRestriction, true); 137 StyleCollector scNormalPrimitives = new StyleCollector(drawArea, drawMultipolygon, drawRestriction, false); 138 139 for (final Node n: data.searchNodes(bbox)) { 140 if (n.isDrawable()) { 141 if (n.isDisabled()) { 142 scDisabledPrimitives.add(n); 143 } else if (n.isSelected()) { 144 scSelectedPrimitives.add(n); 145 } else if (n.isMemberOfSelected()) { 146 scMemberPrimitives.add(n); 147 } else { 148 scNormalPrimitives.add(n); 149 } 150 } 151 } 125 152 for (final Way w : data.searchWays(bbox)) { 126 153 if (w.isDrawable()) { 127 154 if (w.isDisabled()) { 128 scDisabled Lines.add(w);155 scDisabledPrimitives.add(w); 129 156 } else if (w.isSelected()) { 130 scSelectedLines.add(w); 131 if (drawArea) { 132 scSelectedAreas.add(w); 133 } 157 scSelectedPrimitives.add(w); 134 158 } else if (w.isMemberOfSelected()) { 135 scMemberLines.add(w); 136 if (drawArea) { 137 scNormalAreas.add(w); 138 } 159 scMemberPrimitives.add(w); 139 160 } else { 140 scNormalLines.add(w); 141 if (drawArea) { 142 scNormalAreas.add(w); 143 } 144 } 145 } 146 } 147 scDisabledLines.drawAll(); 148 scDisabledLines = null; 149 150 StyleCollector scDisabledNodes = new StyleCollector(NodeElemStyle.class); 151 StyleCollector scSelectedNodes = new StyleCollector(NodeElemStyle.class); 152 StyleCollector scMemberNodes = new StyleCollector(NodeElemStyle.class); 153 scMemberNodes.setMemberSelected(true); 154 StyleCollector scNormalNodes = new StyleCollector(NodeElemStyle.class); 155 for (final Node n: data.searchNodes(bbox)) { 156 if (n.isDrawable()) { 157 if (n.isDisabled()) { 158 scDisabledNodes.add(n); 159 } else if (n.isSelected()) { 160 scSelectedNodes.add(n); 161 } else if (n.isMemberOfSelected()) { 162 scMemberNodes.add(n); 163 } else { 164 scNormalNodes.add(n); 165 } 166 } 167 } 168 scDisabledNodes.drawAll(); 169 scDisabledNodes = null; 170 171 StyleCollector scDisabledRestrictions = new StyleCollector(NodeElemStyle.class); 172 StyleCollector scNormalRestrictions = new StyleCollector(NodeElemStyle.class); 173 StyleCollector scSelectedRestrictions = new StyleCollector(NodeElemStyle.class); 161 scNormalPrimitives.add(w); 162 } 163 } 164 } 174 165 for (Relation r: data.searchRelations(bbox)) { 175 166 if (r.isDrawable()) { 176 167 if (r.isDisabled()) { 177 if (drawRestriction) { 178 scDisabledRestrictions.add(r); 179 } 168 scDisabledPrimitives.add(r); 180 169 } else if (r.isSelected()) { 181 if (drawMultipolygon) { 182 scSelectedAreas.add(r); 183 } 184 if (drawRestriction) { 185 scSelectedRestrictions.add(r); 186 } 170 scSelectedPrimitives.add(r); 187 171 } else { 188 if (drawMultipolygon) { 189 scNormalAreas.add(r); 190 } 191 if (drawRestriction) { 192 scNormalRestrictions.add(r); 193 } 194 } 195 } 196 } 197 scDisabledRestrictions.drawAll(); 198 scDisabledRestrictions = null; 199 200 scNormalAreas.drawAll(); 201 scSelectedAreas.drawAll(); 202 scNormalLines.drawAll(); 203 scMemberLines.drawAll(); 204 scSelectedLines.drawAll(); 205 scNormalNodes.drawAll(); 206 scNormalRestrictions.drawAll(); 207 scMemberNodes.drawAll(); 208 scSelectedRestrictions.drawAll(); 209 scSelectedNodes.drawAll(); 172 scNormalPrimitives.add(r); 173 } 174 } 175 } 176 177 //long phase1 = System.currentTimeMillis(); 178 179 scDisabledPrimitives.drawAll(); 180 scDisabledPrimitives = null; 181 scNormalPrimitives.drawAll(); 182 scNormalPrimitives = null; 183 scMemberPrimitives.drawAll(); 184 scMemberPrimitives = null; 185 scSelectedPrimitives.drawAll(); 186 scSelectedPrimitives = null; 210 187 211 188 painter.drawVirtualNodes(data.searchWays(bbox)); 212 //System.err.println("PAINTING TOOK "+(System.currentTimeMillis() - start)+ " (at scale "+circum+")"); 189 190 //long now = System.currentTimeMillis(); 191 //System.err.println(String.format("PAINTING TOOK %d [PHASE1 took %d] (at scale %s)", now - start, phase1 - start, circum)); 213 192 } 214 193 -
trunk/src/org/openstreetmap/josm/gui/mappaint/AreaElemStyle.java
r3992 r4005 30 30 31 31 protected AreaElemStyle(Cascade c, Color color, BufferedImage fillImage, float fillImageAlpha, TextElement text) { 32 super(c );32 super(c, -1000f); 33 33 CheckParameterUtil.ensureParameterNotNull(color); 34 34 this.color = color; -
trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyle.java
r3987 r4005 27 27 } 28 28 29 protected ElemStyle(Cascade c ) {30 z_index = c.get("z-index", 0f, Float.class);29 protected ElemStyle(Cascade c, float default_z_index) { 30 z_index = c.get("z-index", default_z_index, Float.class); 31 31 object_z_index = c.get("object-z-index", 0f, Float.class); 32 32 isModifier = c.get("modifier", false, Boolean.class); -
trunk/src/org/openstreetmap/josm/gui/mappaint/LineElemStyle.java
r3994 r4005 36 36 37 37 protected LineElemStyle(Cascade c, BasicStroke line, Color color, BasicStroke dashesLine, Color dashesBackground, TextElement text, float realWidth) { 38 super(c );38 super(c, 0f); 39 39 this.line = line; 40 40 this.color = color; -
trunk/src/org/openstreetmap/josm/gui/mappaint/NodeElemStyle.java
r4003 r4005 141 141 142 142 protected NodeElemStyle(Cascade c, ImageIcon icon, Integer iconAlpha, Symbol symbol, NodeTextElement text) { 143 super(c );143 super(c, 1000f); 144 144 this.icon = icon; 145 145 this.iconAlpha = iconAlpha == null ? 0 : iconAlpha;
Note:
See TracChangeset
for help on using the changeset viewer.