Changeset 2671 in josm for trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/MapPaintVisitor.java
- Timestamp:
- 2009-12-22T09:13:07+01:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/MapPaintVisitor.java
r2668 r2671 7 7 8 8 import java.awt.Color; 9 import java.awt.Graphics2D; 9 10 import java.awt.Point; 10 11 import java.awt.Polygon; 12 import java.awt.Rectangle; 11 13 import java.awt.geom.Point2D; 12 14 import java.util.ArrayList; … … 32 34 import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor; 33 35 import org.openstreetmap.josm.gui.DefaultNameFormatter; 36 import org.openstreetmap.josm.gui.NavigatableComponent; 34 37 import org.openstreetmap.josm.gui.mappaint.AreaElemStyle; 35 38 import org.openstreetmap.josm.gui.mappaint.ElemStyle; … … 40 43 import org.openstreetmap.josm.tools.LanguageInfo; 41 44 42 public class MapPaintVisitor extends SimplePaintVisitor { 45 public class MapPaintVisitor implements PaintVisitor { 46 47 protected Graphics2D g; 48 protected NavigatableComponent nc; 49 43 50 protected boolean useRealWidth; 44 51 protected boolean zoomLevelDisplay; … … 63 70 protected Collection<String> regionalNameOrder; 64 71 72 public boolean inactive; 73 protected boolean fillSelectedNode; 74 protected boolean fillUnselectedNode; 75 protected int defaultSegmentWidth; 76 protected boolean showOrderNumber; 77 78 protected boolean showRelevantDirectionsOnly; 79 protected boolean showHeadArrowOnly; 80 protected boolean showDirectionArrow; 81 82 protected int selectedNodeRadius; 83 protected int selectedNodeSize; 84 protected int taggedNodeSize; 85 protected int taggedNodeRadius; 86 protected int unselectedNodeRadius; 87 protected int unselectedNodeSize; 88 89 protected Color selectedColor; 90 protected Color highlightColor; 91 protected Color inactiveColor; 92 protected Color nodeColor; 93 65 94 protected boolean isZoomOk(ElemStyle e) { 66 95 if (!zoomLevelDisplay) /* show everything if the user wishes so */ … … 108 137 } 109 138 110 /**111 * Draw a small rectangle.112 * White if selected (as always) or red otherwise.113 *114 * @param n The node to draw.115 */116 @Override117 public void visit(Node n) {}118 139 public void drawNode(Node n) { 119 140 /* check, if the node is visible at all */ … … 151 172 } 152 173 153 /**154 * Draw a line for all segments, according to tags.155 * @param w The way to draw.156 */157 @Override158 public void visit(Way w) {}159 174 public void drawWay(Way w, int fillAreas) { 160 175 if(w.getNodesCount() < 2) … … 453 468 } 454 469 455 @Override456 public void visit(Relation r) {}457 470 public void paintUnselectedRelation(Relation r) { 458 471 … … 982 995 } 983 996 997 protected boolean isPolygonVisible(Polygon polygon) { 998 Rectangle bounds = polygon.getBounds(); 999 if (bounds.width == 0 && bounds.height == 0) return false; 1000 if (bounds.x > nc.getWidth()) return false; 1001 if (bounds.y > nc.getHeight()) return false; 1002 if (bounds.x + bounds.width < 0) return false; 1003 if (bounds.y + bounds.height < 0) return false; 1004 return true; 1005 } 1006 984 1007 protected Polygon getPolygon(Way w) 985 1008 { … … 1054 1077 } 1055 1078 1056 @Override 1057 public void getColors() 1058 { 1059 super.getColors(); 1079 public void getColors() { 1080 selectedColor = PaintColors.SELECTED.get(); 1081 highlightColor = PaintColors.HIGHLIGHT.get(); 1082 inactiveColor = PaintColors.INACTIVE.get(); 1083 nodeColor = PaintColors.NODE.get(); 1060 1084 untaggedColor = PaintColors.UNTAGGED.get(); 1061 1085 textColor = PaintColors.TEXT.get(); … … 1083 1107 1084 1108 /* Shows areas before non-areas */ 1085 @Override1086 1109 public void visitAll(DataSet data, boolean virtual, Bounds bounds) { 1087 1110 BBox bbox = new BBox(bounds); … … 1098 1121 dist = ll1.greatCircleDistance(ll2); 1099 1122 1100 getSettings(virtual); 1123 getColors(); 1124 1125 showDirectionArrow = Main.pref.getBoolean("draw.segment.direction", true); 1126 showRelevantDirectionsOnly = Main.pref.getBoolean("draw.segment.relevant_directions_only", true); 1127 showHeadArrowOnly = Main.pref.getBoolean("draw.segment.head_only", false); 1128 showOrderNumber = Main.pref.getBoolean("draw.segment.order_number", false); 1129 selectedNodeRadius = Main.pref.getInteger("mappaint.node.selected-size", 5) / 2; 1130 selectedNodeSize = selectedNodeRadius * 2; 1131 unselectedNodeRadius = Main.pref.getInteger("mappaint.node.unselected-size", 3) / 2; 1132 unselectedNodeSize = unselectedNodeRadius * 2; 1133 taggedNodeRadius = Main.pref.getInteger("mappaint.node.tagged-size", 5) / 2; 1134 taggedNodeSize = taggedNodeRadius * 2; 1135 defaultSegmentWidth = Main.pref.getInteger("mappaint.segment.default-width", 2); 1136 fillSelectedNode = Main.pref.getBoolean("mappaint.node.fill-selected", true); 1137 fillUnselectedNode = Main.pref.getBoolean("mappaint.node.fill-unselected", false); 1138 1101 1139 useRealWidth = Main.pref.getBoolean("mappaint.useRealWidth", false); 1102 1140 zoomLevelDisplay = Main.pref.getBoolean("mappaint.zoomLevelDisplay", false); … … 1111 1149 regionalNameOrder = Main.pref.getCollection("mappaint.nameOrder", Arrays.asList(names)); 1112 1150 1113 this.painter = new MapPainter(g, inactive, nc, useStrokes > dist );1151 this.painter = new MapPainter(g, inactive, nc, useStrokes > dist, virtual); 1114 1152 1115 1153 data.clearErrors(); … … 1194 1232 } 1195 1233 1196 drawVirtualNodes(data.searchWays(bbox));1234 painter.drawVirtualNodes(data.searchWays(bbox)); 1197 1235 } 1198 1236 … … 1204 1242 Point p1 = nc.getPoint(n1); 1205 1243 Point p2 = nc.getPoint(n2); 1206 drawOrderNumber(p1, p2, orderNumber);1244 painter.drawOrderNumber(p1, p2, orderNumber); 1207 1245 } 1208 1246 … … 1211 1249 data.addError(p, isError ? tr("Error: {0}", text) : tr("Warning: {0}", text)); 1212 1250 } 1251 1252 public void setGraphics(Graphics2D g) { 1253 this.g = g; 1254 } 1255 1256 public void setInactive(boolean inactive) { 1257 this.inactive = inactive; 1258 } 1259 1260 public void setNavigatableComponent(NavigatableComponent nc) { 1261 this.nc = nc; 1262 } 1213 1263 }
Note:
See TracChangeset
for help on using the changeset viewer.