Changeset 221 in josm
- Timestamp:
- 2007-04-27T21:27:20+02:00 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java
r211 r221 4 4 import java.awt.Graphics; 5 5 import java.awt.Point; 6 import java.awt.Rectangle; 7 import java.awt.geom.Line2D; 6 8 7 9 import org.openstreetmap.josm.Main; … … 68 70 */ 69 71 public void visit(Segment ls) { 70 drawSegment(ls, getPreferencesColor("segment", darkgreen) );72 drawSegment(ls, getPreferencesColor("segment", darkgreen), Main.pref.getBoolean("draw.segment.direction")); 71 73 } 72 74 … … 85 87 } 86 88 89 boolean showDirectionArrow = Main.pref.getBoolean("draw.segment.direction"); 90 boolean showOrderNumber = Main.pref.getBoolean("draw.segment.order_number"); 87 91 int orderNumber = 0; 88 92 for (Segment ls : w.segments) { 89 93 orderNumber++; 90 94 if (!ls.selected) // selected already in good color 91 drawSegment(ls, w.selected ? getPreferencesColor("selected", Color.WHITE) : wayColor );92 if (!ls.incomplete && Main.pref.getBoolean("draw.segment.order_number"))95 drawSegment(ls, w.selected ? getPreferencesColor("selected", Color.WHITE) : wayColor, showDirectionArrow); 96 if (!ls.incomplete && showOrderNumber) 93 97 drawOrderNumber(ls, orderNumber); 94 98 } … … 104 108 int x = (p1.x+p2.x)/2 - 4*strlen; 105 109 int y = (p1.y+p2.y)/2 + 4; 106 Color c = g.getColor(); 107 g.setColor(Color.black); 108 g.fillRect(x-1,y-12,8*strlen+1,14); 109 g.setColor(c); 110 g.drawString(""+orderNumber,x,y); 110 111 Rectangle screen = g.getClipBounds(); 112 if (screen.contains(x,y)) { 113 Color c = g.getColor(); 114 g.setColor(getPreferencesColor("background", Color.BLACK)); 115 g.fillRect(x-1, y-12, 8*strlen+1, 14); 116 g.setColor(c); 117 g.drawString(""+orderNumber, x, y); 118 } 111 119 } 112 120 … … 120 128 Point p = nc.getPoint(n.eastNorth); 121 129 g.setColor(color); 122 g.drawRect(p.x-1, p.y-1, 2, 2); 130 Rectangle screen = g.getClipBounds(); 131 132 if ( screen.contains(p.x, p.y) ) 133 g.drawRect(p.x-1, p.y-1, 2, 2); 123 134 } 124 135 … … 126 137 * Draw a line with the given color. 127 138 */ 128 protected void drawSegment(Segment ls, Color col ) {139 protected void drawSegment(Segment ls, Color col, boolean showDirection) { 129 140 if (ls.incomplete) 130 141 return; … … 134 145 Point p1 = nc.getPoint(ls.from.eastNorth); 135 146 Point p2 = nc.getPoint(ls.to.eastNorth); 136 g.drawLine(p1.x, p1.y, p2.x, p2.y); 137 138 if (Main.pref.getBoolean("draw.segment.direction")) { 139 double t = Math.atan2(p2.y-p1.y, p2.x-p1.x) + Math.PI; 140 g.drawLine(p2.x,p2.y, (int)(p2.x + 10*Math.cos(t-PHI)), (int)(p2.y + 10*Math.sin(t-PHI))); 141 g.drawLine(p2.x,p2.y, (int)(p2.x + 10*Math.cos(t+PHI)), (int)(p2.y + 10*Math.sin(t+PHI))); 147 148 Rectangle screen = g.getClipBounds(); 149 Line2D line = new Line2D.Double(p1.x, p1.y, p2.x, p2.y); 150 if (screen.contains(p1.x, p1.y, p2.x, p2.y) || screen.intersectsLine(line)) 151 { 152 g.drawLine(p1.x, p1.y, p2.x, p2.y); 153 154 if (showDirection) { 155 double t = Math.atan2(p2.y-p1.y, p2.x-p1.x) + Math.PI; 156 g.drawLine(p2.x,p2.y, (int)(p2.x + 10*Math.cos(t-PHI)), (int)(p2.y + 10*Math.sin(t-PHI))); 157 g.drawLine(p2.x,p2.y, (int)(p2.x + 10*Math.cos(t+PHI)), (int)(p2.y + 10*Math.sin(t+PHI))); 158 } 142 159 } 143 160 }
Note:
See TracChangeset
for help on using the changeset viewer.