Changeset 32090 in osm for applications/editors/josm/plugins/seachart/src/render/Renderer.java
- Timestamp:
- 2016-03-03T08:32:31+01:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/seachart/src/render/Renderer.java
r32088 r32090 56 56 } 57 57 58 public static void symbol( Feature feature,Symbol symbol) {59 Point2D point = context.getPoint(feature.geom.centre); 58 public static void symbol(Symbol symbol) { 59 Point2D point = context.getPoint(Rules.feature.geom.centre); 60 60 Symbols.drawSymbol(g2, symbol, sScale, point.getX(), point.getY(), null, null); 61 61 } 62 public static void symbol( Feature feature,Symbol symbol, Scheme scheme) {63 Point2D point = context.getPoint(feature.geom.centre); 62 public static void symbol(Symbol symbol, Scheme scheme) { 63 Point2D point = context.getPoint(Rules.feature.geom.centre); 64 64 Symbols.drawSymbol(g2, symbol, sScale, point.getX(), point.getY(), scheme, null); 65 65 } 66 public static void symbol( Feature feature,Symbol symbol, Delta delta) {67 Point2D point = context.getPoint(feature.geom.centre); 66 public static void symbol(Symbol symbol, Delta delta) { 67 Point2D point = context.getPoint(Rules.feature.geom.centre); 68 68 Symbols.drawSymbol(g2, symbol, sScale, point.getX(), point.getY(), null, delta); 69 69 } 70 public static void symbol( Feature feature,Symbol symbol, Scheme scheme, Delta delta) {71 Point2D point = context.getPoint(feature.geom.centre); 70 public static void symbol(Symbol symbol, Scheme scheme, Delta delta) { 71 Point2D point = context.getPoint(Rules.feature.geom.centre); 72 72 Symbols.drawSymbol(g2, symbol, sScale, point.getX(), point.getY(), scheme, delta); 73 73 } 74 74 75 public static void cluster( Feature feature,ArrayList<Symbol> symbols) {75 public static void cluster(ArrayList<Symbol> symbols) { 76 76 Rectangle2D.Double bbox = null; 77 77 if (symbols.size() > 4) { … … 86 86 switch (symbols.size()) { 87 87 case 1: 88 symbol( feature,symbols.get(0), new Delta(Handle.CC, new AffineTransform()));88 symbol(symbols.get(0), new Delta(Handle.CC, new AffineTransform())); 89 89 break; 90 90 case 2: 91 symbol( feature,symbols.get(0), new Delta(Handle.RC, new AffineTransform()));92 symbol( feature,symbols.get(1), new Delta(Handle.LC, new AffineTransform()));91 symbol(symbols.get(0), new Delta(Handle.RC, new AffineTransform())); 92 symbol(symbols.get(1), new Delta(Handle.LC, new AffineTransform())); 93 93 break; 94 94 case 3: 95 symbol( feature,symbols.get(0), new Delta(Handle.BC, new AffineTransform()));96 symbol( feature,symbols.get(1), new Delta(Handle.TR, new AffineTransform()));97 symbol( feature,symbols.get(2), new Delta(Handle.TL, new AffineTransform()));95 symbol(symbols.get(0), new Delta(Handle.BC, new AffineTransform())); 96 symbol(symbols.get(1), new Delta(Handle.TR, new AffineTransform())); 97 symbol(symbols.get(2), new Delta(Handle.TL, new AffineTransform())); 98 98 break; 99 99 case 4: 100 symbol( feature,symbols.get(0), new Delta(Handle.BR, new AffineTransform()));101 symbol( feature,symbols.get(1), new Delta(Handle.BL, new AffineTransform()));102 symbol( feature,symbols.get(2), new Delta(Handle.TR, new AffineTransform()));103 symbol( feature,symbols.get(3), new Delta(Handle.TL, new AffineTransform()));100 symbol(symbols.get(0), new Delta(Handle.BR, new AffineTransform())); 101 symbol(symbols.get(1), new Delta(Handle.BL, new AffineTransform())); 102 symbol(symbols.get(2), new Delta(Handle.TR, new AffineTransform())); 103 symbol(symbols.get(3), new Delta(Handle.TL, new AffineTransform())); 104 104 break; 105 105 case 5: 106 symbol( feature,symbols.get(0), new Delta(Handle.BR, new AffineTransform()));107 symbol( feature,symbols.get(1), new Delta(Handle.BL, new AffineTransform()));108 symbol( feature,symbols.get(2), new Delta(Handle.TR, AffineTransform.getTranslateInstance(-bbox.width/2, 0)));109 symbol( feature,symbols.get(3), new Delta(Handle.TC, new AffineTransform()));110 symbol( feature,symbols.get(4), new Delta(Handle.TL, AffineTransform.getTranslateInstance(bbox.width/2, 0)));106 symbol(symbols.get(0), new Delta(Handle.BR, new AffineTransform())); 107 symbol(symbols.get(1), new Delta(Handle.BL, new AffineTransform())); 108 symbol(symbols.get(2), new Delta(Handle.TR, AffineTransform.getTranslateInstance(-bbox.width/2, 0))); 109 symbol(symbols.get(3), new Delta(Handle.TC, new AffineTransform())); 110 symbol(symbols.get(4), new Delta(Handle.TL, AffineTransform.getTranslateInstance(bbox.width/2, 0))); 111 111 break; 112 112 case 6: 113 symbol( feature,symbols.get(0), new Delta(Handle.BR, AffineTransform.getTranslateInstance(-bbox.width/2, 0)));114 symbol( feature,symbols.get(1), new Delta(Handle.BC, new AffineTransform()));115 symbol( feature,symbols.get(2), new Delta(Handle.BL, AffineTransform.getTranslateInstance(bbox.width/2, 0)));116 symbol( feature,symbols.get(3), new Delta(Handle.TR, AffineTransform.getTranslateInstance(-bbox.width/2, 0)));117 symbol( feature,symbols.get(4), new Delta(Handle.TC, new AffineTransform()));118 symbol( feature,symbols.get(5), new Delta(Handle.TL, AffineTransform.getTranslateInstance(bbox.width/2, 0)));113 symbol(symbols.get(0), new Delta(Handle.BR, AffineTransform.getTranslateInstance(-bbox.width/2, 0))); 114 symbol(symbols.get(1), new Delta(Handle.BC, new AffineTransform())); 115 symbol(symbols.get(2), new Delta(Handle.BL, AffineTransform.getTranslateInstance(bbox.width/2, 0))); 116 symbol(symbols.get(3), new Delta(Handle.TR, AffineTransform.getTranslateInstance(-bbox.width/2, 0))); 117 symbol(symbols.get(4), new Delta(Handle.TC, new AffineTransform())); 118 symbol(symbols.get(5), new Delta(Handle.TL, AffineTransform.getTranslateInstance(bbox.width/2, 0))); 119 119 break; 120 120 case 7: 121 symbol( feature,symbols.get(0), new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -bbox.height/2)));122 symbol( feature,symbols.get(1), new Delta(Handle.RC, AffineTransform.getTranslateInstance(-bbox.width/2, 0)));123 symbol( feature,symbols.get(2), new Delta(Handle.CC, new AffineTransform()));124 symbol( feature,symbols.get(3), new Delta(Handle.LC, AffineTransform.getTranslateInstance(bbox.width/2, 0)));125 symbol( feature,symbols.get(4), new Delta(Handle.TR, AffineTransform.getTranslateInstance(-bbox.width/2, bbox.height/2)));126 symbol( feature,symbols.get(5), new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, bbox.height/2)));127 symbol( feature,symbols.get(6), new Delta(Handle.TL, AffineTransform.getTranslateInstance(bbox.width/2, bbox.height/2)));121 symbol(symbols.get(0), new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -bbox.height/2))); 122 symbol(symbols.get(1), new Delta(Handle.RC, AffineTransform.getTranslateInstance(-bbox.width/2, 0))); 123 symbol(symbols.get(2), new Delta(Handle.CC, new AffineTransform())); 124 symbol(symbols.get(3), new Delta(Handle.LC, AffineTransform.getTranslateInstance(bbox.width/2, 0))); 125 symbol(symbols.get(4), new Delta(Handle.TR, AffineTransform.getTranslateInstance(-bbox.width/2, bbox.height/2))); 126 symbol(symbols.get(5), new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, bbox.height/2))); 127 symbol(symbols.get(6), new Delta(Handle.TL, AffineTransform.getTranslateInstance(bbox.width/2, bbox.height/2))); 128 128 break; 129 129 case 8: 130 symbol( feature,symbols.get(0), new Delta(Handle.BR, AffineTransform.getTranslateInstance(0, -bbox.height/2)));131 symbol( feature,symbols.get(1), new Delta(Handle.BL, AffineTransform.getTranslateInstance(0, -bbox.height/2)));132 symbol( feature,symbols.get(2), new Delta(Handle.RC, AffineTransform.getTranslateInstance(-bbox.width/2, 0)));133 symbol( feature,symbols.get(3), new Delta(Handle.CC, new AffineTransform()));134 symbol( feature,symbols.get(4), new Delta(Handle.LC, AffineTransform.getTranslateInstance(bbox.width/2, 0)));135 symbol( feature,symbols.get(5), new Delta(Handle.TR, AffineTransform.getTranslateInstance(-bbox.width/2, bbox.height/2)));136 symbol( feature,symbols.get(6), new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, bbox.height/2)));137 symbol( feature,symbols.get(7), new Delta(Handle.TL, AffineTransform.getTranslateInstance(bbox.width/2, bbox.height/2)));130 symbol(symbols.get(0), new Delta(Handle.BR, AffineTransform.getTranslateInstance(0, -bbox.height/2))); 131 symbol(symbols.get(1), new Delta(Handle.BL, AffineTransform.getTranslateInstance(0, -bbox.height/2))); 132 symbol(symbols.get(2), new Delta(Handle.RC, AffineTransform.getTranslateInstance(-bbox.width/2, 0))); 133 symbol(symbols.get(3), new Delta(Handle.CC, new AffineTransform())); 134 symbol(symbols.get(4), new Delta(Handle.LC, AffineTransform.getTranslateInstance(bbox.width/2, 0))); 135 symbol(symbols.get(5), new Delta(Handle.TR, AffineTransform.getTranslateInstance(-bbox.width/2, bbox.height/2))); 136 symbol(symbols.get(6), new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, bbox.height/2))); 137 symbol(symbols.get(7), new Delta(Handle.TL, AffineTransform.getTranslateInstance(bbox.width/2, bbox.height/2))); 138 138 break; 139 139 case 9: 140 symbol( feature,symbols.get(0), new Delta(Handle.BR, AffineTransform.getTranslateInstance(-bbox.width/2, -bbox.height/2)));141 symbol( feature,symbols.get(1), new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -bbox.height/2)));142 symbol( feature,symbols.get(2), new Delta(Handle.BL, AffineTransform.getTranslateInstance(bbox.width/2, -bbox.height/2)));143 symbol( feature,symbols.get(3), new Delta(Handle.RC, AffineTransform.getTranslateInstance(-bbox.width/2, 0)));144 symbol( feature,symbols.get(4), new Delta(Handle.CC, new AffineTransform()));145 symbol( feature,symbols.get(5), new Delta(Handle.LC, AffineTransform.getTranslateInstance(bbox.width/2, 0)));146 symbol( feature,symbols.get(6), new Delta(Handle.TR, AffineTransform.getTranslateInstance(-bbox.width/2, bbox.height/2)));147 symbol( feature,symbols.get(7), new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, bbox.height/2)));148 symbol( feature,symbols.get(8), new Delta(Handle.TL, AffineTransform.getTranslateInstance(bbox.width/2, bbox.height/2)));140 symbol(symbols.get(0), new Delta(Handle.BR, AffineTransform.getTranslateInstance(-bbox.width/2, -bbox.height/2))); 141 symbol(symbols.get(1), new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -bbox.height/2))); 142 symbol(symbols.get(2), new Delta(Handle.BL, AffineTransform.getTranslateInstance(bbox.width/2, -bbox.height/2))); 143 symbol(symbols.get(3), new Delta(Handle.RC, AffineTransform.getTranslateInstance(-bbox.width/2, 0))); 144 symbol(symbols.get(4), new Delta(Handle.CC, new AffineTransform())); 145 symbol(symbols.get(5), new Delta(Handle.LC, AffineTransform.getTranslateInstance(bbox.width/2, 0))); 146 symbol(symbols.get(6), new Delta(Handle.TR, AffineTransform.getTranslateInstance(-bbox.width/2, bbox.height/2))); 147 symbol(symbols.get(7), new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, bbox.height/2))); 148 symbol(symbols.get(8), new Delta(Handle.TL, AffineTransform.getTranslateInstance(bbox.width/2, bbox.height/2))); 149 149 break; 150 150 } … … 169 169 } 170 170 171 public static void lineSymbols( Feature feature,Symbol prisymb, double space, Symbol secsymb, Symbol tersymb, int ratio, Color col) {172 if ((feature.geom.prim == Pflag.NOSP) || (feature.geom.prim == Pflag.POINT)) 171 public static void lineSymbols(Symbol prisymb, double space, Symbol secsymb, Symbol tersymb, int ratio, Color col) { 172 if ((Rules.feature.geom.prim == Pflag.NOSP) || (Rules.feature.geom.prim == Pflag.POINT)) 173 173 return; 174 174 Rectangle2D.Double prect = symbolSize(prisymb); … … 192 192 boolean stflag = false; 193 193 Symbol symbol = prisymb; 194 GeomIterator git = map.new GeomIterator(feature.geom); 194 GeomIterator git = map.new GeomIterator(Rules.feature.geom); 195 195 while (git.hasComp()) { 196 196 git.nextComp(); … … 253 253 } 254 254 255 public static void lineVector( Feature feature,LineStyle style) {255 public static void lineVector(LineStyle style) { 256 256 Path2D.Double p = new Path2D.Double(); 257 257 p.setWindingRule(GeneralPath.WIND_EVEN_ODD); 258 258 Point2D point; 259 GeomIterator git = map.new GeomIterator(feature.geom); 259 GeomIterator git = map.new GeomIterator(Rules.feature.geom); 260 260 while (git.hasComp()) { 261 261 git.nextComp(); … … 278 278 } 279 279 } 280 if ((style.fill != null) && (feature.geom.prim == Pflag.AREA)) { 280 if ((style.fill != null) && (Rules.feature.geom.prim == Pflag.AREA)) { 281 281 g2.setPaint(style.fill); 282 282 g2.fill(p); … … 298 298 } 299 299 300 public static void lineCircle( Feature feature,LineStyle style, double radius, UniHLU units) {300 public static void lineCircle(LineStyle style, double radius, UniHLU units) { 301 301 switch (units) { 302 302 case HLU_FEET: … … 318 318 break; 319 319 } 320 radius *= context.mile(feature); 320 radius *= context.mile(Rules.feature); 321 321 Symbol circle = new Symbol(); 322 322 if (style.fill != null) { … … 327 327 circle.add(new Instr(Form.STRK, new BasicStroke(style.width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, style.dash, 0))); 328 328 circle.add(new Instr(Form.ELPS, new Ellipse2D.Double(-radius,-radius,radius*2,radius*2))); 329 Point2D point = context.getPoint(feature.geom.centre); 329 Point2D point = context.getPoint(Rules.feature.geom.centre); 330 330 Symbols.drawSymbol(g2, circle, 1, point.getX(), point.getY(), null, null); 331 331 } 332 332 333 public static void fillPattern( Feature feature,BufferedImage image) {333 public static void fillPattern(BufferedImage image) { 334 334 Path2D.Double p = new Path2D.Double(); 335 335 p.setWindingRule(GeneralPath.WIND_EVEN_ODD); 336 336 Point2D point; 337 switch (feature.geom.prim) { 337 switch (Rules.feature.geom.prim) { 338 338 case POINT: 339 point = context.getPoint(feature.geom.centre); 339 point = context.getPoint(Rules.feature.geom.centre); 340 340 g2.drawImage(image, new AffineTransformOp(AffineTransform.getScaleInstance(sScale, sScale), AffineTransformOp.TYPE_NEAREST_NEIGHBOR), 341 341 (int)(point.getX() - (50 * sScale)), (int)(point.getY() - (50 * sScale))); 342 342 break; 343 343 case AREA: 344 GeomIterator git = map.new GeomIterator(feature.geom); 344 GeomIterator git = map.new GeomIterator(Rules.feature.geom); 345 345 while (git.hasComp()) { 346 346 git.nextComp(); … … 365 365 } 366 366 367 public static void labelText( Feature feature,String str, Font font, Color tc) {368 labelText( feature,str, font, tc, LabelStyle.NONE, null, null, null);369 } 370 public static void labelText( Feature feature,String str, Font font, Color tc, Delta delta) {371 labelText( feature,str, font, tc, LabelStyle.NONE, null, null, delta);372 } 373 public static void labelText( Feature feature,String str, Font font, Color tc, LabelStyle style, Color fg) {374 labelText( feature,str, font, tc, style, fg, null, null);375 } 376 public static void labelText( Feature feature,String str, Font font, Color tc, LabelStyle style, Color fg, Color bg) {377 labelText( feature,str, font, tc, style, fg, bg, null);378 } 379 public static void labelText( Feature feature,String str, Font font, Color tc, LabelStyle style, Color fg, Delta delta) {380 labelText( feature,str, font, tc, style, fg, null, delta);381 } 382 public static void labelText( Feature feature,String str, Font font, Color tc, LabelStyle style, Color fg, Color bg, Delta delta) {367 public static void labelText(String str, Font font, Color tc) { 368 labelText(str, font, tc, LabelStyle.NONE, null, null, null); 369 } 370 public static void labelText(String str, Font font, Color tc, Delta delta) { 371 labelText(str, font, tc, LabelStyle.NONE, null, null, delta); 372 } 373 public static void labelText(String str, Font font, Color tc, LabelStyle style, Color fg) { 374 labelText(str, font, tc, style, fg, null, null); 375 } 376 public static void labelText(String str, Font font, Color tc, LabelStyle style, Color fg, Color bg) { 377 labelText(str, font, tc, style, fg, bg, null); 378 } 379 public static void labelText(String str, Font font, Color tc, LabelStyle style, Color fg, Delta delta) { 380 labelText(str, font, tc, style, fg, null, delta); 381 } 382 public static void labelText(String str, Font font, Color tc, LabelStyle style, Color fg, Color bg, Delta delta) { 383 383 if (delta == null) delta = new Delta(Handle.CC); 384 384 if (bg == null) bg = new Color(0x00000000, true); … … 475 475 } 476 476 label.add(new Instr(Form.TEXT, new Caption(str, font, tc, new Delta(Handle.TL, AffineTransform.getTranslateInstance(tx, ty))))); 477 Point2D point = context.getPoint(feature.geom.centre); 477 Point2D point = context.getPoint(Rules.feature.geom.centre); 478 478 Symbols.drawSymbol(g2, label, sScale, point.getX(), point.getY(), null, delta); 479 479 } 480 480 481 public static void lineText( Feature feature,String str, Font font, Color colour, double offset, double dy) {481 public static void lineText(String str, Font font, Color colour, double offset, double dy) { 482 482 if (!str.isEmpty()) { 483 483 g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); … … 493 493 double angle = 0; 494 494 int index = 0; 495 double gwidth = offset * (feature.geom.length * context.mile(feature) - gv.getLogicalBounds().getWidth()) + gv.getGlyphMetrics(0).getAdvance(); 496 GeomIterator git = map.new GeomIterator(feature.geom); 495 double gwidth = offset * (Rules.feature.geom.length * context.mile(Rules.feature) - gv.getLogicalBounds().getWidth()) + gv.getGlyphMetrics(0).getAdvance(); 496 GeomIterator git = map.new GeomIterator(Rules.feature.geom); 497 497 while (git.hasComp()) { 498 498 git.nextComp(); … … 548 548 } 549 549 550 public static void lightSector( Feature feature,Color col1, Color col2, double radius, double s1, double s2, Double dir, String str) {550 public static void lightSector(Color col1, Color col2, double radius, double s1, double s2, Double dir, String str) { 551 551 if ((zoom >= 16) && (radius > 0.2)) { 552 552 radius /= (Math.pow(2, zoom-15)); … … 555 555 g2.setStroke(new BasicStroke((float) (3.0 * sScale), BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1, new float[] {20 * (float)sScale, 20 * (float)sScale}, 0)); 556 556 g2.setPaint(Color.black); 557 Point2D.Double centre = (Point2D.Double) context.getPoint(feature.geom.centre); 558 double radial = radius * context.mile(feature); 557 Point2D.Double centre = (Point2D.Double) context.getPoint(Rules.feature.geom.centre); 558 double radial = radius * context.mile(Rules.feature); 559 559 if (dir != null) { 560 560 g2.draw(new Line2D.Double(centre.x, centre.y, centre.x - radial * Math.sin(Math.toRadians(dir)), centre.y + radial * Math.cos(Math.toRadians(dir)))); … … 585 585 if (gv.getLogicalBounds().getWidth() < awidth) { 586 586 at.rotate(Math.toRadians(mid + (hand ? 0 : 180))); 587 Renderer.labelText( feature,str, font, Color.black, new Delta(Handle.CC, at));587 Renderer.labelText(str, font, Color.black, new Delta(Handle.CC, at)); 588 588 } else if (gv.getLogicalBounds().getHeight() < awidth) { 589 589 hand = (mid < 180); 590 590 at.rotate(Math.toRadians(mid + (hand ? -90 : 90))); 591 Renderer.labelText( feature,str, font, Color.black, hand ? new Delta(Handle.RC, at) : new Delta(Handle.LC, at));591 Renderer.labelText(str, font, Color.black, hand ? new Delta(Handle.RC, at) : new Delta(Handle.LC, at)); 592 592 } 593 593 if (dir != null) { … … 599 599 at = AffineTransform.getTranslateInstance(-radial * Math.sin(phi) / sScale, radial * Math.cos(phi) / sScale); 600 600 at.rotate(Math.toRadians(dir + (hand ? 90 : -90))); 601 Renderer.labelText( feature,str, font, Color.black, hand ? new Delta(Handle.BR, at) : new Delta(Handle.BL, at));601 Renderer.labelText(str, font, Color.black, hand ? new Delta(Handle.BR, at) : new Delta(Handle.BL, at)); 602 602 } 603 603 }
Note:
See TracChangeset
for help on using the changeset viewer.