Changeset 637 in josm for trunk/src/org
- Timestamp:
- 2008-05-13T00:02:14+02:00 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java
r627 r637 65 65 protected GeneralPath currentPath = new GeneralPath(); 66 66 67 private Rectangle screen;68 67 Rectangle bbox = new Rectangle(); 69 68 … … 171 170 int y = (p1.y+p2.y)/2 + 4; 172 171 173 if ( screen.contains(x,y)) {172 if (isSegmentVisible(p1, p2)) { 174 173 Color c = g.getColor(); 175 174 g.setColor(backgroundColor); … … 188 187 public void drawNode(Node n, Color color) { 189 188 Point p = nc.getPoint(n.eastNorth); 190 g.setColor(color); 191 192 if (screen.contains(p.x, p.y)) 193 if (n.tagged) { 194 g.drawRect(p.x, p.y, 0, 0); 195 g.drawRect(p.x-2, p.y-2, 4, 4); 196 } else { 197 g.drawRect(p.x-1, p.y-1, 2, 2); 198 } 189 if ((p.x < 0) || (p.y < 0) || (p.x > nc.getWidth()) || (p.y > nc.getHeight())) return; 190 191 g.setColor(color); 192 193 if (n.tagged) { 194 g.drawRect(p.x, p.y, 0, 0); 195 g.drawRect(p.x-2, p.y-2, 4, 4); 196 } else { 197 g.drawRect(p.x-1, p.y-1, 2, 2); 198 } 199 199 } 200 200 … … 206 206 if (col != currentColor) displaySegments(col); 207 207 208 if ( onScreen(p1, p2)) {208 if (isSegmentVisible(p1, p2)) { 209 209 currentPath.moveTo(p1.x, p1.y); 210 210 currentPath.lineTo(p2.x, p2.y); … … 219 219 } 220 220 221 private boolean onScreen(Point p1, Point p2) { 222 bbox.setBounds(p1.x, p1.y, 0, 0); 223 bbox.add(p2); 224 if (bbox.height + bbox.width < 1) return false; 225 bbox.width++; 226 bbox.height++; 227 return screen.intersects(bbox); 228 } 221 private boolean isSegmentVisible(Point p1, Point p2) { 222 if ((p1.x < 0) && (p2.x < 0)) return false; 223 if ((p1.y < 0) && (p2.y < 0)) return false; 224 if ((p1.x > nc.getWidth()) && (p2.x > nc.getWidth())) return false; 225 if ((p1.y > nc.getHeight()) && (p2.y > nc.getHeight())) return false; 226 return true; 227 } 229 228 230 229 public void setGraphics(Graphics g) { 231 230 this.g = g; 232 screen = g.getClipBounds();233 231 } 234 232
Note:
See TracChangeset
for help on using the changeset viewer.