Changeset 31532 in osm for applications/editors/josm/plugins
- Timestamp:
- 2015-08-29T16:55:46+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/seachart
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/seachart/jicons/src/jicons/Jicons.java
r31344 r31532 35 35 import s57.S57map.*; 36 36 import render.*; 37 import render.Rules.RuleSet;38 37 39 38 public class Jicons { … … 80 79 img = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); 81 80 g2 = img.createGraphics(); 82 Renderer.reRender(g2, RuleSet.SEAMARK,new Rectangle(x, y, w, h), 16, s / Renderer.symbolScale[16], map, context);81 Renderer.reRender(g2, new Rectangle(x, y, w, h), 16, s / Renderer.symbolScale[16], map, context); 83 82 try { 84 83 ImageIO.write(img, "png", new File(args[1] + file + ".png")); … … 94 93 SVGGraphics2D svgGenerator = new SVGGraphics2D(document); 95 94 svgGenerator.setSVGCanvasSize(new Dimension(w, h)); 96 Renderer.reRender(svgGenerator, RuleSet.SEAMARK,new Rectangle(x, y, w, h), 16, s / Renderer.symbolScale[16], map, context);95 Renderer.reRender(svgGenerator, new Rectangle(x, y, w, h), 16, s / Renderer.symbolScale[16], map, context); 97 96 boolean useCSS = true; 98 97 Writer out = null; … … 192 191 static class Context implements ChartContext { 193 192 194 @Override195 193 public Point2D getPoint(Snode coord) { 196 194 return new Point2D.Double(x, y); 197 195 } 198 196 199 @Override200 197 public double mile(Feature feature) { 201 198 return Math.min(w, h); 202 199 } 203 200 204 @Override205 201 public boolean clip() { 206 202 return false; 207 203 } 208 204 209 @Override210 205 public Color background() { 211 206 return new Color(0, true); 212 207 } 208 209 public RuleSet ruleset() { 210 return RuleSet.SEAMARK; 211 } 213 212 } 214 213 } -
applications/editors/josm/plugins/seachart/jrender/src/jrender/Jrender.java
r31044 r31532 10 10 package jrender; 11 11 12 import java.awt.Color; 12 13 import java.awt.Graphics2D; 13 14 import java.awt.Rectangle; … … 36 37 import symbols.*; 37 38 import render.*; 38 import render. Rules.RuleSet;39 import render.ChartContext.RuleSet; 39 40 40 41 public class Jrender { … … 66 67 } 67 68 68 @Override69 69 public Point2D getPoint(Snode coord) { 70 70 double x = (Math.toDegrees(coord.lon) - minlon) * 256.0 * 2048.0 / 180.0; … … 73 73 } 74 74 75 @Override76 75 public double mile(Feature feature) { 77 76 return mile; 77 } 78 79 public boolean clip() { 80 return false; 81 } 82 83 public Color background() { 84 return new Color(0, true); 85 } 86 87 public RuleSet ruleset() { 88 return RuleSet.ALL; 78 89 } 79 90 } … … 197 208 } else if (ln.contains("<osm")) { 198 209 inOsm = true; 199 map = new S57map( );210 map = new S57map(context.ruleset() == RuleSet.SEAMARK); 200 211 map.addNode(1, maxlat, minlon); 201 212 map.addNode(2, minlat, minlon); … … 213 224 Rectangle rect = new Rectangle(size, size); 214 225 img = new BufferedImage(rect.width, rect.height, BufferedImage.TYPE_INT_ARGB); 215 Renderer.reRender(img.createGraphics(), RuleSet.BASE,rect, zoom, 0.05, map, context);226 Renderer.reRender(img.createGraphics(), rect, zoom, 0.05, map, context); 216 227 ByteArrayOutputStream bos = new ByteArrayOutputStream(); 217 228 ImageIO.write(img, "png", bos); … … 231 242 svgGenerator.setClip(rect.x, rect.y, rect.width, rect.height); 232 243 // svgGenerator.translate(-256, -256); 233 Renderer.reRender(svgGenerator, RuleSet.BASE,rect, zoom, 0.05, map, context);244 Renderer.reRender(svgGenerator, rect, zoom, 0.05, map, context); 234 245 svgGenerator.stream(dstdir + "tst_" + zoom + "-" + xtile + "-" + ytile + ".svg"); 235 246 // } … … 244 255 g2.scale(s, s); 245 256 g2.translate(-(256 + (xn * 256 / s)), -(256 + (yn * 256 / s))); 246 Renderer.reRender(g2, RuleSet.BASE,new Rectangle(256, 256), zoom, 1, map, context);257 Renderer.reRender(g2, new Rectangle(256, 256), zoom, 1, map, context); 247 258 ByteArrayOutputStream bos = new ByteArrayOutputStream(); 248 259 ImageIO.write(img, "png", bos); -
applications/editors/josm/plugins/seachart/src/render/ChartContext.java
r31343 r31532 16 16 17 17 public interface ChartContext { 18 public enum RuleSet { ALL, BASE, SEAMARK } 19 18 20 Point2D getPoint(Snode coord); 19 21 double mile(Feature feature); 20 22 boolean clip(); 21 23 Color background(); 24 RuleSet ruleset(); 22 25 } -
applications/editors/josm/plugins/seachart/src/render/Renderer.java
r31343 r31532 16 16 import java.util.*; 17 17 18 import render.Rules.*;19 18 import s57.S57val.*; 20 19 import s57.S57map; … … 36 35 static int zoom; 37 36 38 public static void reRender(Graphics2D g, R uleSet set, Rectangle rect, int z, double factor, S57map m, ChartContext c) {37 public static void reRender(Graphics2D g, Rectangle rect, int z, double factor, S57map m, ChartContext c) { 39 38 g2 = g; 40 39 zoom = z; … … 53 52 g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP); 54 53 g2.setStroke(new BasicStroke(0, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER)); 55 Rules.rules( set);54 Rules.rules(); 56 55 } 57 56 } -
applications/editors/josm/plugins/seachart/src/render/Rules.java
r31344 r31532 22 22 import s57.S57obj.*; 23 23 import s57.S57map.*; 24 import render.ChartContext.RuleSet; 24 25 import render.Renderer.*; 25 26 import symbols.*; … … 28 29 public class Rules { 29 30 30 public enum RuleSet { ALL, BASE, SEAMARK }31 32 31 static final EnumMap<ColCOL, Color> bodyColours = new EnumMap<ColCOL, Color>(ColCOL.class); 33 32 static { … … 173 172 static Feature feature; 174 173 static ArrayList<Feature> objects; 175 static RuleSet ruleset;176 174 177 175 static boolean testObject(Obj obj) { … … 183 181 } 184 182 185 public static void rules (RuleSet set) { 186 ruleset = set; 187 if ((set == RuleSet.ALL) || (set == RuleSet.BASE)) { 183 public static void rules () { 184 if ((Renderer.context.ruleset() == RuleSet.ALL) || (Renderer.context.ruleset() == RuleSet.BASE)) { 188 185 if (testObject(Obj.LNDARE)) for (Feature f : objects) if (testFeature(f)) areas(); 189 186 if (testObject(Obj.BUAARE)) for (Feature f : objects) if (testFeature(f)) areas(); … … 202 199 } 203 200 if (testObject(Obj.SLCONS)) for (Feature f : objects) if (testFeature(f)) shoreline(); 204 if (( set == RuleSet.ALL) || (set== RuleSet.SEAMARK)) {201 if ((Renderer.context.ruleset() == RuleSet.ALL) || (Renderer.context.ruleset() == RuleSet.SEAMARK)) { 205 202 if (testObject(Obj.PIPSOL)) for (Feature f : objects) if (testFeature(f)) pipelines(); 206 203 if (testObject(Obj.CBLSUB)) for (Feature f : objects) if (testFeature(f)) cables(); … … 443 440 AttMap topmap = feature.objs.get(Obj.TOPMAR).get(0); 444 441 if (topmap.containsKey(Att.TOPSHP)) { 445 Symbol topmark = Topmarks.Shapes.get(((ArrayList<TopSHP>)(topmap.get(Att.TOPSHP).val)).get(0)); 446 if (topmark != null) 447 Renderer.symbol(feature, topmark, getScheme(feature, Obj.TOPMAR), Topmarks.BeaconDelta); 442 Renderer.symbol(feature, Topmarks.Shapes.get(((ArrayList<TopSHP>)(topmap.get(Att.TOPSHP).val)).get(0)), getScheme(feature, Obj.TOPMAR), Topmarks.BeaconDelta); 448 443 } 449 444 } else if (feature.objs.containsKey(Obj.DAYMAR)) { 450 445 AttMap topmap = feature.objs.get(Obj.DAYMAR).get(0); 451 446 if (topmap.containsKey(Att.TOPSHP)) { 452 Symbol topmark = Topmarks.Shapes.get(((ArrayList<TopSHP>)(topmap.get(Att.TOPSHP).val)).get(0)); 453 if (topmark != null) 454 Renderer.symbol(feature, topmark, getScheme(feature, Obj.DAYMAR), Topmarks.BeaconDelta); 447 Renderer.symbol(feature, Topmarks.Shapes.get(((ArrayList<TopSHP>)(topmap.get(Att.TOPSHP).val)).get(0)), getScheme(feature, Obj.DAYMAR), Topmarks.BeaconDelta); 455 448 } 456 449 } … … 468 461 AttMap topmap = feature.objs.get(Obj.TOPMAR).get(0); 469 462 if (topmap.containsKey(Att.TOPSHP)) { 470 Symbol topmark = Topmarks.Shapes.get(((ArrayList<TopSHP>)(topmap.get(Att.TOPSHP).val)).get(0)); 471 if (topmark != null) 472 Renderer.symbol(feature, topmark, getScheme(feature, Obj.TOPMAR), Topmarks.BuoyDeltas.get(shape)); 463 Renderer.symbol(feature, Topmarks.Shapes.get(((ArrayList<TopSHP>)(topmap.get(Att.TOPSHP).val)).get(0)), getScheme(feature, Obj.TOPMAR), Topmarks.BuoyDeltas.get(shape)); 473 464 } 474 465 } else if (feature.objs.containsKey(Obj.DAYMAR)) { 475 466 AttMap topmap = feature.objs.get(Obj.DAYMAR).get(0); 476 467 if (topmap.containsKey(Att.TOPSHP)) { 477 Symbol topmark = Topmarks.Shapes.get(((ArrayList<TopSHP>)(topmap.get(Att.TOPSHP).val)).get(0)); 478 if (topmark != null) 479 Renderer.symbol(feature, topmark, getScheme(feature, Obj.DAYMAR), Topmarks.BuoyDeltas.get(shape)); 468 Renderer.symbol(feature, Topmarks.Shapes.get(((ArrayList<TopSHP>)(topmap.get(Att.TOPSHP).val)).get(0)), getScheme(feature, Obj.DAYMAR), Topmarks.BuoyDeltas.get(shape)); 480 469 } 481 470 } … … 1035 1024 private static void shoreline() { 1036 1025 CatSLC cat = (CatSLC) getAttEnum(feature, feature.type, 0, Att.CATSLC); 1037 if (( ruleset == RuleSet.ALL) || (ruleset== RuleSet.BASE)) {1026 if ((Renderer.context.ruleset() == RuleSet.ALL) || (Renderer.context.ruleset() == RuleSet.BASE)) { 1038 1027 if ((cat != CatSLC.SLC_SWAY) && (cat != CatSLC.SLC_TWAL)) { 1039 1028 Renderer.lineVector(feature, new LineStyle(Color.black, 10, Symbols.Yland)); 1040 1029 } 1041 1030 } 1042 if (( ruleset == RuleSet.ALL) || (ruleset== RuleSet.SEAMARK)) {1031 if ((Renderer.context.ruleset() == RuleSet.ALL) || (Renderer.context.ruleset() == RuleSet.SEAMARK)) { 1043 1032 if (Renderer.zoom >= 12) { 1044 1033 switch (cat) { -
applications/editors/josm/plugins/seachart/src/s57/S57osm.java
r31044 r31532 37 37 OSMtags.put("waterway=riverbank", new KeyVal<>(Obj.RIVBNK, Att.UNKATT, null, null)); OSMtags.put("waterway=river", new KeyVal<>(Obj.RIVERS, Att.UNKATT, null, null)); 38 38 OSMtags.put("waterway=canal", new KeyVal<>(Obj.CANALS, Att.UNKATT, null, null)); OSMtags.put("waterway=dock", new KeyVal<>(Obj.HRBBSN, Att.UNKATT, null, null)); 39 OSMtags.put("waterway=lock", new KeyVal<>(Obj.HRBBSN, Att.UNKATT, null, null)); 39 OSMtags.put("waterway=lock", new KeyVal<>(Obj.HRBBSN, Att.UNKATT, null, null)); OSMtags.put("landuse=basin", new KeyVal<>(Obj.LAKARE, Att.UNKATT, null, null)); 40 40 OSMtags.put("wetland=tidalflat", new KeyVal<Double>(Obj.DEPARE, Att.DRVAL2, Conv.F, (Double)0.0)); OSMtags.put("tidal=yes", new KeyVal<Double>(Obj.DEPARE, Att.DRVAL2, Conv.F, (Double)0.0)); 41 41 OSMtags.put("natural=mud", new KeyVal<>(Obj.DEPARE, Att.UNKATT, null, null)); OSMtags.put("natural=sand", new KeyVal<>(Obj.DEPARE, Att.UNKATT, null, null)); -
applications/editors/josm/plugins/seachart/src/seachart/ChartImage.java
r31343 r31532 30 30 import render.ChartContext; 31 31 import render.Renderer; 32 import render.Rules.RuleSet;33 32 import s57.S57map.*; 34 33 import symbols.Symbols; … … 67 66 public void paint(Graphics2D g2, MapView mv, Bounds bb) { 68 67 Rectangle rect = Main.map.mapView.getBounds(); 69 Renderer.reRender(g2, RuleSet.ALL,rect, zoom, Math.pow(2, (zoom-12)), SeachartAction.map, this);68 Renderer.reRender(g2, rect, zoom, Math.pow(2, (zoom-12)), SeachartAction.map, this); 70 69 g2.setPaint(Color.black); 71 70 g2.setFont(new Font("Arial", Font.BOLD, 20)); … … 102 101 return (Symbols.Bwater); 103 102 } 103 104 public RuleSet ruleset() { 105 return RuleSet.ALL; 106 } 104 107 }
Note:
See TracChangeset
for help on using the changeset viewer.