Changeset 30215 in osm for applications/editors/josm/plugins/smed2/src/render/Renderer.java
- Timestamp:
- 2014-01-19T14:52:39+01:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed2/src/render/Renderer.java
r30190 r30215 19 19 import s57.S57map; 20 20 import s57.S57map.*; 21 import s57.S57map.Area;22 21 import symbols.Areas; 23 22 import symbols.Symbols; … … 102 101 if (symbols.size() > 4) { 103 102 for (Instr instr : symbols.get(0)) { 104 if (instr.type == Prim.BBOX) {103 if (instr.type == Form.BBOX) { 105 104 bbox = (Rectangle2D.Double) instr.params; 106 105 break; … … 180 179 while (ssymb != null) { 181 180 for (Instr item : symbol) { 182 if (item.type == Prim.BBOX) {181 if (item.type == Form.BBOX) { 183 182 return (Rectangle2D.Double) item.params; 184 183 } 185 if (item.type == Prim.SYMB) {184 if (item.type == Form.SYMB) { 186 185 ssymb = ((SubSymbol) item.params).instr; 187 186 break; … … 195 194 196 195 public static void lineSymbols(Feature feature, Symbol prisymb, double space, Symbol secsymb, Symbol tersymb, int ratio, Color col) { 197 Area area; 198 switch (feature.flag) { 199 case LINE: 200 Edge edge = map.edges.get(feature.refs); 201 area = map.new Area(); 202 area.add(map.new Bound(map.new Side(edge, true), true)); 203 break; 204 case AREA: 205 area = map.areas.get(feature.refs); 206 break; 207 default: 196 if ((feature.geom.prim == Pflag.NOSP) || (feature.geom.prim == Pflag.POINT)) 208 197 return; 209 }210 198 Rectangle2D.Double prect = symbolSize(prisymb); 211 199 Rectangle2D.Double srect = symbolSize(secsymb); … … 228 216 boolean stflag = false; 229 217 Symbol symbol = prisymb; 230 for (Bound bound : area) { 231 BoundIterator bit = map.new BoundIterator(bound); 218 GeomIterator git = map.new GeomIterator(feature.geom); 219 while (git.hasMore()) { 220 git.more(); 232 221 boolean first = true; 233 while ( bit.hasNext()) {222 while (git.hasNext()) { 234 223 prev = next; 235 next = context.getPoint( bit.next());224 next = context.getPoint(git.next()); 236 225 angle = Math.atan2(next.getY() - prev.getY(), next.getX() - prev.getX()); 237 226 piv = true; … … 286 275 p.setWindingRule(GeneralPath.WIND_EVEN_ODD); 287 276 Point2D point; 288 switch(feature.flag) {289 case LINE:290 EdgeIterator eit = map.new EdgeIterator(map.edges.get(feature.refs), true);291 point = context.getPoint( eit.next());277 GeomIterator git = map.new GeomIterator(feature.geom); 278 while (git.hasMore()) { 279 git.more(); 280 point = context.getPoint(git.next()); 292 281 p.moveTo(point.getX(), point.getY()); 293 while ( eit.hasNext()) {294 point = context.getPoint( eit.next());282 while (git.hasNext()) { 283 point = context.getPoint(git.next()); 295 284 p.lineTo(point.getX(), point.getY()); 296 285 } 297 break;298 case AREA:299 for (Bound bound : map.areas.get(feature.refs)) {300 BoundIterator bit = map.new BoundIterator(bound);301 point = context.getPoint(bit.next());302 p.moveTo(point.getX(), point.getY());303 while (bit.hasNext()) {304 point = context.getPoint(bit.next());305 p.lineTo(point.getX(), point.getY());306 }307 }308 break;309 default:310 break;311 286 } 312 287 if (style.line != null) { … … 353 328 Symbol circle = new Symbol(); 354 329 if (style.fill != null) { 355 circle.add(new Instr( Prim.FILL, style.fill));356 circle.add(new Instr( Prim.RSHP, new Ellipse2D.Double(-radius,-radius,radius*2,radius*2)));357 } 358 circle.add(new Instr( Prim.FILL, style.line));359 circle.add(new Instr( Prim.STRK, new BasicStroke(style.width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, style.dash, 0)));360 circle.add(new Instr( Prim.ELPS, new Ellipse2D.Double(-radius,-radius,radius*2,radius*2)));330 circle.add(new Instr(Form.FILL, style.fill)); 331 circle.add(new Instr(Form.RSHP, new Ellipse2D.Double(-radius,-radius,radius*2,radius*2))); 332 } 333 circle.add(new Instr(Form.FILL, style.line)); 334 circle.add(new Instr(Form.STRK, new BasicStroke(style.width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, style.dash, 0))); 335 circle.add(new Instr(Form.ELPS, new Ellipse2D.Double(-radius,-radius,radius*2,radius*2))); 361 336 Point2D point = context.getPoint(feature.centre); 362 337 Symbols.drawSymbol(g2, circle, 1, point.getX(), point.getY(), null, null); … … 368 343 p.setWindingRule(GeneralPath.WIND_EVEN_ODD); 369 344 Point2D point; 370 switch (feature. flag) {345 switch (feature.geom.prim) { 371 346 case POINT: 372 347 point = context.getPoint(feature.centre); … … 375 350 break; 376 351 case AREA: 377 for (Bound bound : map.areas.get(feature.refs)) { 378 BoundIterator bit = map.new BoundIterator(bound); 379 point = context.getPoint(bit.next()); 352 GeomIterator git = map.new GeomIterator(feature.geom); 353 while (git.hasMore()) { 354 git.more(); 355 point = context.getPoint(git.next()); 380 356 p.moveTo(point.getX(), point.getY()); 381 while ( bit.hasNext()) {382 point = context.getPoint( bit.next());357 while (git.hasNext()) { 358 point = context.getPoint(git.next()); 383 359 p.lineTo(point.getX(), point.getY()); 384 360 } … … 427 403 tx = lx + (height * 0.34); 428 404 ty = ly + (height * 0.17); 429 label.add(new Instr( Prim.BBOX, new Rectangle2D.Double(lx,ly,width,height)));430 label.add(new Instr( Prim.FILL, bg));431 label.add(new Instr( Prim.RSHP, new RoundRectangle2D.Double(lx,ly,width,height,height,height)));432 label.add(new Instr( Prim.FILL, fg));433 label.add(new Instr( Prim.STRK, new BasicStroke(1 + (int)(height/10), BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER)));434 label.add(new Instr( Prim.RRCT, new RoundRectangle2D.Double(lx,ly,width,height,height,height)));405 label.add(new Instr(Form.BBOX, new Rectangle2D.Double(lx,ly,width,height))); 406 label.add(new Instr(Form.FILL, bg)); 407 label.add(new Instr(Form.RSHP, new RoundRectangle2D.Double(lx,ly,width,height,height,height))); 408 label.add(new Instr(Form.FILL, fg)); 409 label.add(new Instr(Form.STRK, new BasicStroke(1 + (int)(height/10), BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER))); 410 label.add(new Instr(Form.RRCT, new RoundRectangle2D.Double(lx,ly,width,height,height,height))); 435 411 break; 436 412 case VCLR: … … 442 418 tx = lx + (height * 0.27); 443 419 ty = ly + (height * 0.25); 444 label.add(new Instr( Prim.BBOX, new Rectangle2D.Double(lx,ly,width,height)));445 label.add(new Instr( Prim.FILL, bg));446 label.add(new Instr( Prim.RSHP, new RoundRectangle2D.Double(lx,ly,width,height,height,height)));447 label.add(new Instr( Prim.FILL, fg));420 label.add(new Instr(Form.BBOX, new Rectangle2D.Double(lx,ly,width,height))); 421 label.add(new Instr(Form.FILL, bg)); 422 label.add(new Instr(Form.RSHP, new RoundRectangle2D.Double(lx,ly,width,height,height,height))); 423 label.add(new Instr(Form.FILL, fg)); 448 424 int sw = 1 + (int)(height/10); 449 425 double po = sw / 2; 450 label.add(new Instr( Prim.STRK, new BasicStroke(sw, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER)));426 label.add(new Instr(Form.STRK, new BasicStroke(sw, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER))); 451 427 Path2D.Double p = new Path2D.Double(); p.moveTo(-height*0.2,-ly-po); p.lineTo(height*0.2,-ly-po); p.moveTo(0,-ly-po); p.lineTo(0,-ly-po-(height*0.15)); 452 428 p.moveTo(-height*0.2,ly+po); p.lineTo((height*0.2),ly+po); p.moveTo(0,ly+po); p.lineTo(0,ly+po+(height*0.15)); 453 label.add(new Instr( Prim.PLIN, p));429 label.add(new Instr(Form.PLIN, p)); 454 430 break; 455 431 case PCLR: … … 461 437 tx = lx + (height * 0.27); 462 438 ty = ly + (height * 0.25); 463 label.add(new Instr( Prim.BBOX, new Rectangle2D.Double(lx,ly,width,height)));464 label.add(new Instr( Prim.FILL, bg));465 label.add(new Instr( Prim.RSHP, new RoundRectangle2D.Double(lx,ly,width,height,height,height)));466 label.add(new Instr( Prim.FILL, fg));439 label.add(new Instr(Form.BBOX, new Rectangle2D.Double(lx,ly,width,height))); 440 label.add(new Instr(Form.FILL, bg)); 441 label.add(new Instr(Form.RSHP, new RoundRectangle2D.Double(lx,ly,width,height,height,height))); 442 label.add(new Instr(Form.FILL, fg)); 467 443 sw = 1 + (int)(height/10); 468 444 po = sw / 2; 469 label.add(new Instr( Prim.STRK, new BasicStroke(sw, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER)));445 label.add(new Instr(Form.STRK, new BasicStroke(sw, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER))); 470 446 p = new Path2D.Double(); p.moveTo(-height*0.2,-ly-po); p.lineTo(height*0.2,-ly-po); p.moveTo(0,-ly-po); p.lineTo(0,-ly-po-(height*0.15)); 471 447 p.moveTo(-height*0.2,ly+po); p.lineTo((height*0.2),ly+po); p.moveTo(0,ly+po); p.lineTo(0,ly+po+(height*0.15)); 472 label.add(new Instr( Prim.PLIN, p));473 label.add(new Instr( Prim.SYMB, new Symbols.SubSymbol(Areas.CableFlash, 1, 0, 0, null, new Delta(Handle.CC, new AffineTransform(0,-1,1,0,-width/2,0)))));474 label.add(new Instr( Prim.SYMB, new Symbols.SubSymbol(Areas.CableFlash, 1, 0, 0, null, new Delta(Handle.CC, new AffineTransform(0,-1,1,0,width/2,0)))));448 label.add(new Instr(Form.PLIN, p)); 449 label.add(new Instr(Form.SYMB, new Symbols.SubSymbol(Areas.CableFlash, 1, 0, 0, null, new Delta(Handle.CC, new AffineTransform(0,-1,1,0,-width/2,0))))); 450 label.add(new Instr(Form.SYMB, new Symbols.SubSymbol(Areas.CableFlash, 1, 0, 0, null, new Delta(Handle.CC, new AffineTransform(0,-1,1,0,width/2,0))))); 475 451 break; 476 452 case HCLR: … … 482 458 tx = lx + (height * 0.5); 483 459 ty = ly + (height * 0.17); 484 label.add(new Instr( Prim.BBOX, new Rectangle2D.Double(lx,ly,width,height)));485 label.add(new Instr( Prim.FILL, bg));486 label.add(new Instr( Prim.RSHP, new RoundRectangle2D.Double(lx,ly,width,height,height,height)));487 label.add(new Instr( Prim.FILL, fg));460 label.add(new Instr(Form.BBOX, new Rectangle2D.Double(lx,ly,width,height))); 461 label.add(new Instr(Form.FILL, bg)); 462 label.add(new Instr(Form.RSHP, new RoundRectangle2D.Double(lx,ly,width,height,height,height))); 463 label.add(new Instr(Form.FILL, fg)); 488 464 sw = 1 + (int)(height/10); 489 465 double vo = height / 4; 490 label.add(new Instr( Prim.STRK, new BasicStroke(sw, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER)));466 label.add(new Instr(Form.STRK, new BasicStroke(sw, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER))); 491 467 p = new Path2D.Double(); p.moveTo(-width*0.4-sw,-ly-vo); p.lineTo(-width*0.4-sw,ly+vo); p.moveTo(-width*0.4-sw,0); p.lineTo(-width*0.4+sw,0); 492 468 p.moveTo(width*0.4+sw,-ly-vo); p.lineTo(width*0.4+sw,ly+vo); p.moveTo(width*0.4-sw,0); p.lineTo(width*0.4+sw,0); 493 label.add(new Instr( Prim.PLIN, p));469 label.add(new Instr(Form.PLIN, p)); 494 470 break; 495 471 default: … … 498 474 tx = lx; 499 475 ty = ly; 500 label.add(new Instr( Prim.BBOX, new Rectangle2D.Double(lx,ly,width,height)));501 break; 502 } 503 label.add(new Instr( Prim.TEXT, new Caption(str, font, tc, new Delta(Handle.TL, AffineTransform.getTranslateInstance(tx, ty)))));476 label.add(new Instr(Form.BBOX, new Rectangle2D.Double(lx,ly,width,height))); 477 break; 478 } 479 label.add(new Instr(Form.TEXT, new Caption(str, font, tc, new Delta(Handle.TL, AffineTransform.getTranslateInstance(tx, ty))))); 504 480 Point2D point = context.getPoint(feature.centre); 505 481 Symbols.drawSymbol(g2, label, sScale, point.getX(), point.getY(), null, delta); … … 507 483 508 484 public static void lineText(Feature feature, String str, Font font, Color colour, double offset, double dy) { 509 Area area;510 switch (feature.flag) {511 case LINE:512 Edge edge = map.edges.get(feature.refs);513 area = map.new Area();514 area.add(map.new Bound(map.new Side(edge, true), true));515 break;516 case AREA:517 area = map.areas.get(feature.refs);518 break;519 default:520 return;521 }522 485 // Rectangle prect = symbolSize(prisymb); 523 486 if (!str.isEmpty()) { … … 533 496 double len = 0; 534 497 double angle = 0; 535 for (Bound bound : area) { 536 BoundIterator bit = map.new BoundIterator(bound); 498 GeomIterator git = map.new GeomIterator(feature.geom); 499 while (git.hasMore()) { 500 git.more(); 537 501 boolean first = true; 538 while ( bit.hasNext()) {502 while (git.hasNext()) { 539 503 prev = next; 540 next = context.getPoint( bit.next());504 next = context.getPoint(git.next()); 541 505 angle = Math.atan2(next.getY() - prev.getY(), next.getX() - prev.getX()); 542 506 piv = true;
Note:
See TracChangeset
for help on using the changeset viewer.