Changeset 2596 in osm for applications/editors/josm
- Timestamp:
- 2007-04-19T19:00:44+02:00 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mappaint/src/mappaint/MapPaintVisitor.java
r1863 r2596 32 32 // Altered from SimplePaintVisitor 33 33 @Override public void visit(Node n) { 34 ElemStyle nodeStyle = MapPaintPlugin.elemStyles.getStyle(n); 35 if(nodeStyle!=null && Main.map.mapView.zoom()>=nodeStyle.getMinZoom()){ 36 if(nodeStyle instanceof IconElemStyle) { 37 drawNode(n, ((IconElemStyle)nodeStyle).getIcon()); 34 if (isNodeVisible(n)) { 35 ElemStyle nodeStyle = MapPaintPlugin.elemStyles.getStyle(n); 36 if(nodeStyle!=null && Main.map.mapView.zoom()>=nodeStyle.getMinZoom()){ 37 if(nodeStyle instanceof IconElemStyle) { 38 drawNode(n, ((IconElemStyle)nodeStyle).getIcon()); 39 } else { 40 // throw some sort of exception 41 } 38 42 } else { 39 // throw some sort of exception 40 } 41 } else { 42 drawNode(n, n.selected ? getPreferencesColor("selected", 43 Color.YELLOW) 44 : getPreferencesColor("node", Color.RED)); 43 drawNode(n, n.selected ? getPreferencesColor("selected", 44 Color.YELLOW) 45 : getPreferencesColor("node", Color.RED)); 46 } 45 47 } 46 48 } … … 52 54 */ 53 55 @Override public void visit(Segment ls) { 54 drawSegment(ls, getPreferencesColor("untagged",Color.GRAY)); 56 if (isSegmentVisible(ls)) 57 drawSegment(ls, getPreferencesColor("untagged",Color.GRAY)); 55 58 } 56 59 … … 87 90 for (Segment ls : w.segments) 88 91 { 89 if ( !ls.selected) // selected already in good color92 if ((!ls.selected) && (isSegmentVisible(ls))) // selected already in good color 90 93 drawSegment(ls, w.selected ? 91 94 getPreferencesColor("selected", Color.YELLOW) : colour, … … 126 129 g2d.setStroke(new BasicStroke(1)); 127 130 } 131 } 132 133 /** 134 * Checks if the given node is in the visible area. 135 */ 136 protected boolean isNodeVisible(Node n) { 137 Point p = nc.getPoint(n.eastNorth); 138 return !((p.x < 0) || (p.y < 0) || (p.x > nc.getWidth()) || (p.y > nc.getHeight())); 139 } 140 141 /** 142 * Checks is the given segment is int the visible area. 143 * NOTE: This will return true for a small number of non-visible 144 * segments. 145 */ 146 protected boolean isSegmentVisible(Segment ls) { 147 if (ls.incomplete) return false; 148 Point p1 = nc.getPoint(ls.from.eastNorth); 149 Point p2 = nc.getPoint(ls.to.eastNorth); 150 if ((p1.x < 0) && (p2.x < 0)) return false; 151 if ((p1.y < 0) && (p2.y < 0)) return false; 152 if ((p1.x > nc.getWidth()) && (p2.x > nc.getWidth())) return false; 153 if ((p1.y > nc.getHeight()) && (p2.y > nc.getHeight())) return false; 154 return true; 128 155 } 129 156
Note:
See TracChangeset
for help on using the changeset viewer.