Changeset 2688 in osm for applications/editors
- Timestamp:
- 2007-04-30T11:48:22+02:00 (18 years ago)
- Location:
- applications/editors/josm/plugins/mappaint
- Files:
-
- 3 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mappaint/src/mappaint/MapPaintVisitor.java
r2685 r2688 35 35 // Altered from SimplePaintVisitor 36 36 @Override public void visit(Node n) { 37 if ( isNodeVisible(n)) {37 if (!n.shown) { 38 38 ElemStyle nodeStyle = MapPaintPlugin.elemStyles.getStyle(n); 39 39 if(nodeStyle!=null && Main.map.mapView.zoom()>=nodeStyle.getMinZoom()){ … … 57 57 */ 58 58 @Override public void visit(Segment ls) { 59 if (isSegmentVisible(ls))60 59 drawSegment(ls, getPreferencesColor("untagged",Color.GRAY),Main.pref.getBoolean("draw.segment.direction")); 61 60 } … … 92 91 { 93 92 orderNumber++; 94 if (isSegmentVisible(ls))95 {96 93 if (area && fillAreas) 97 94 //Draw segments in a different colour so direction arrows show against the fill 98 drawSegment(ls, w.selected ? getPreferencesColor("selected", Color.YELLOW) : getPreferencesColor("untagged",Color.GRAY), width);95 drawSegment(ls, w.selected ? getPreferencesColor("selected", Color.YELLOW) : getPreferencesColor("untagged",Color.GRAY),Main.pref.getBoolean("draw.segment.direction"), width); 99 96 else 100 drawSegment(ls, w.selected ? getPreferencesColor("selected", Color.YELLOW) : colour, width);97 drawSegment(ls, w.selected ? getPreferencesColor("selected", Color.YELLOW) : colour,Main.pref.getBoolean("draw.segment.direction"), width); 101 98 if (!ls.incomplete && Main.pref.getBoolean("draw.segment.order_number")) 102 99 { … … 108 105 catch (IllegalAccessError e) {} //SimplePaintVisitor::drawOrderNumber was private prior to rev #211 109 106 } 110 }111 107 } 112 108 } … … 137 133 } 138 134 139 /**140 * Checks if the given node is in the visible area.141 */142 protected boolean isNodeVisible(Node n) {143 Point p = nc.getPoint(n.eastNorth);144 return !((p.x < 0) || (p.y < 0) || (p.x > nc.getWidth()) || (p.y > nc.getHeight()));145 }146 147 /**148 * Checks if the given segment is in the visible area.149 * NOTE: This will return true for a small number of non-visible150 * segments.151 */152 protected boolean isSegmentVisible(Segment ls) {153 if (ls.incomplete) return false;154 Point p1 = nc.getPoint(ls.from.eastNorth);155 Point p2 = nc.getPoint(ls.to.eastNorth);156 if ((p1.x < 0) && (p2.x < 0)) return false;157 if ((p1.y < 0) && (p2.y < 0)) return false;158 if ((p1.x > nc.getWidth()) && (p2.x > nc.getWidth())) return false;159 if ((p1.y > nc.getHeight()) && (p2.y > nc.getHeight())) return false;160 return true;161 }162 163 135 // NEW 164 136 protected void drawNode(Node n, ImageIcon icon) { 137 if (n.shown) return; 138 n.shown=true; 165 139 Point p = nc.getPoint(n.eastNorth); 140 if ((p.x < 0) || (p.y < 0) || (p.x > nc.getWidth()) || (p.y > nc.getHeight())) return; 166 141 int w = icon.getIconWidth(), h=icon.getIconHeight(); 167 142 icon.paintIcon ( Main.map.mapView, g, p.x-w/2, p.y-h/2 ); … … 187 162 // Altered - now specify width 188 163 @Override protected void drawSegment(Segment ls, Color col,boolean showDirection) { 189 drawSegment(ls,col,1); 190 } 164 drawSegment(ls,col,showDirection,1); 165 } 166 191 167 192 168 // Altered - now specify width 193 private void drawSegment (Segment ls, Color col, int width) { 169 private void drawSegment (Segment ls, Color col,boolean showDirection, int width) { 170 //do not draw already visible segments 171 if (ls.shown) return; 172 ls.shown=true; 194 173 Graphics2D g2d = (Graphics2D)g; 195 174 if (ls.incomplete) … … 202 181 Point p1 = nc.getPoint(ls.from.eastNorth); 203 182 Point p2 = nc.getPoint(ls.to.eastNorth); 183 // checking if this Point is visible 184 if ((p1.x < 0) && (p2.x < 0)) return ; 185 if ((p1.y < 0) && (p2.y < 0)) return ; 186 if ((p1.x > nc.getWidth()) && (p2.x > nc.getWidth())) return ; 187 if ((p1.y > nc.getHeight()) && (p2.y > nc.getHeight())) return ; 188 204 189 g.drawLine(p1.x, p1.y, p2.x, p2.y); 205 190 206 if ( Main.pref.getBoolean("draw.segment.direction")) {191 if (showDirection) { 207 192 double t = Math.atan2(p2.y-p1.y, p2.x-p1.x) + Math.PI; 208 g.drawLine(p2.x,p2.y, (int)(p2.x + 10*Math.cos(t-PHI)), (int)(p2.y + 10*Math.sin(t-PHI))); 209 g.drawLine(p2.x,p2.y, (int)(p2.x + 10*Math.cos(t+PHI)), (int)(p2.y + 10*Math.sin(t+PHI))); 210 } 193 g.drawLine(p2.x,p2.y, (int)(p2.x + 10*Math.cos(t-PHI)), (int)(p2.y + 10*Math.sin(t-PHI))); 194 g.drawLine(p2.x,p2.y, (int)(p2.x + 10*Math.cos(t+PHI)), (int)(p2.y + 10*Math.sin(t+PHI))); 195 } 196 211 197 } 212 198 … … 220 206 @Override public void drawNode(Node n, Color color) { 221 207 Point p = nc.getPoint(n.eastNorth); 208 if ((p.x < 0) || (p.y < 0) || (p.x > nc.getWidth()) || (p.y > nc.getHeight())) return; 222 209 g.setColor(color); 223 210 g.drawRect(p.x-1, p.y-1, 2, 2); … … 229 216 230 217 Collection<Way> noAreaWays = new LinkedList<Way>(); 218 231 219 for (final OsmPrimitive osm : data.segments) 232 220 if (!osm.deleted) 233 osm.visit(this); 221 osm.shown=false; 222 223 for (final OsmPrimitive osm : data.nodes) 224 if (!osm.deleted) 225 osm.shown=false; 234 226 235 227 for (final OsmPrimitive osm : data.ways) … … 242 234 osm.visit(this); 243 235 236 for (final OsmPrimitive osm : data.segments) 237 if (!osm.deleted) 238 osm.visit(this); 239 244 240 for (final OsmPrimitive osm : data.nodes) 245 241 if (!osm.deleted) … … 247 243 248 244 for (final OsmPrimitive osm : data.getSelected()) 249 if (!osm.deleted) 250 osm.visit(this); 245 if (!osm.deleted){ 246 osm.shown=false; //to be sure it will be drawn 247 osm.visit(this); 248 } 251 249 } 252 250 }
Note:
See TracChangeset
for help on using the changeset viewer.