Changeset 29199 in osm for applications/editors/josm
- Timestamp:
- 2013-01-15T15:08:25+01:00 (12 years ago)
- Location:
- applications/editors/josm/plugins/smed2/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed2/src/seamap/Renderer.java
r29198 r29199 10 10 package seamap; 11 11 12 import java.awt.BasicStroke; 12 13 import java.awt.Graphics2D; 13 14 import java.awt.RenderingHints; 15 import java.awt.geom.GeneralPath; 16 import java.awt.geom.Path2D; 14 17 import java.awt.geom.Point2D; 15 18 import java.util.ArrayList; … … 20 23 import s57.S57val.*; 21 24 import s57.S57val; 25 import seamap.SeaMap; 22 26 import seamap.SeaMap.*; 23 27 import symbols.Symbols; … … 31 35 static double tScale; 32 36 static Graphics2D g2; 37 static int zoom; 33 38 34 public static void reRender(Graphics2D g, int z oom, double factor, SeaMap m, MapHelper h) {39 public static void reRender(Graphics2D g, int z, double factor, SeaMap m, MapHelper h) { 35 40 g2 = g; 41 zoom = z; 36 42 helper = h; 37 43 map = m; … … 115 121 public static void symbol(Feature feature, Symbol symbol, Obj obj, Delta delta) { 116 122 Point2D point = helper.getPoint(findCentroid(feature)); 117 ArrayList<ColCOL> colours = (ArrayList<ColCOL>) getAttVal(feature, obj, 0, Att.COLOUR); 118 ArrayList<ColPAT> pattern = (ArrayList<ColPAT>) getAttVal(feature, obj, 0, Att.COLPAT); 119 Symbols.drawSymbol(g2, symbol, sScale, point.getX(), point.getY(), delta, new Scheme(pattern, colours)); 123 if (obj == null) { 124 Symbols.drawSymbol(g2, symbol, sScale, point.getX(), point.getY(), delta, null); 125 } else { 126 ArrayList<ColCOL> colours = (ArrayList<ColCOL>) getAttVal(feature, obj, 0, Att.COLOUR); 127 ArrayList<ColPAT> pattern = (ArrayList<ColPAT>) getAttVal(feature, obj, 0, Att.COLPAT); 128 Symbols.drawSymbol(g2, symbol, sScale, point.getX(), point.getY(), delta, new Scheme(pattern, colours)); 129 } 120 130 } 121 131 … … 131 141 132 142 public static void lineVector (Feature feature, LineStyle style) { 133 143 if (feature.flag != Fflag.NODE) { 144 ArrayList<Long> nodes = map.ways.get(feature.refs); 145 Path2D.Double p = new Path2D.Double(); 146 p.setWindingRule(GeneralPath.WIND_NON_ZERO); 147 boolean first = true; 148 for (long node : nodes) { 149 Point2D point = helper.getPoint(map.nodes.get(node)); 150 if (first) { 151 p.moveTo(point.getX(), point.getY()); 152 first = false; 153 } else { 154 p.lineTo(point.getX(), point.getY()); 155 } 156 } 157 if (style.line != null) { 158 if (style.dash != null) { 159 float[] dash = new float[style.dash.length]; 160 System.arraycopy(style.dash, 0, dash, 0, style.dash.length); 161 for (int i = 0; i < style.dash.length; i++) { 162 dash[i] *= (float) (sScale); 163 } 164 g2.setStroke(new BasicStroke((float) (style.width * sScale), BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1, dash, 0)); 165 } else { 166 g2.setStroke(new BasicStroke((float) (style.width * sScale), BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND)); 167 } 168 g2.setPaint(style.line); 169 g2.draw(p); 170 } 171 if (style.fill != null) { 172 g2.setPaint(style.fill); 173 g2.fill(p); 174 } 175 } 134 176 } 135 177 -
applications/editors/josm/plugins/smed2/src/seamap/Rules.java
r29198 r29199 109 109 WatLEV lev = (WatLEV) Renderer.getAttVal(feature, feature.type, 0, Att.WATLEV); 110 110 if (lev == WatLEV.LEV_CVRS) { 111 Renderer.lineVector(feature, new LineStyle( new BasicStroke(10, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1, new float[] { 40, 40 }, 0), Color.black, null));111 Renderer.lineVector(feature, new LineStyle(Color.black, 10, new float[] { 40, 40 }, null)); 112 112 if (zoom >= 15) 113 113 Renderer.lineText(feature, "(covers)", new TextStyle(new Font("Arial", Font.PLAIN, 80)), 0.5, new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, 20))); 114 114 } else { 115 Renderer.lineVector(feature, new LineStyle( new BasicStroke(10, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND), Color.black, null));115 Renderer.lineVector(feature, new LineStyle(Color.black, 10, null, null)); 116 116 } 117 117 if (zoom >= 15) … … 144 144 case TSSRON: 145 145 if (zoom <= 15) 146 Renderer.lineVector(feature, new LineStyle(null, null, new Color(0x80c480ff, true)));146 Renderer.lineVector(feature, new LineStyle(null, 0, null, new Color(0x80c480ff, true))); 147 147 else 148 Renderer.lineVector(feature, new LineStyle(new BasicStroke(20, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND), new Color(0x80c480ff, true), null));148 Renderer.lineVector(feature, new LineStyle(new Color(0x80c480ff, true), 20, null, null)); 149 149 AttItem name = feature.atts.get(Att.OBJNAM); 150 150 if ((zoom >= 10) && (name != null)) … … 152 152 break; 153 153 case TSELNE: 154 Renderer.lineVector(feature, new LineStyle(new BasicStroke(20, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND), new Color(0x80c480ff, true), null));154 Renderer.lineVector(feature, new LineStyle(new Color(0x80c480ff, true), 20, null, null)); 155 155 break; 156 156 case TSSLPT: … … 158 158 break; 159 159 case TSSBND: 160 Renderer.lineVector(feature, new LineStyle(new BasicStroke(20, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1, new float[] { 40, 40 }, 0), new Color(0x80c480ff, true), null));160 Renderer.lineVector(feature, new LineStyle(new Color(0x80c480ff, true), 20, new float[] { 40, 40 }, null)); 161 161 break; 162 162 } … … 177 177 Renderer.symbol(feature, Areas.MarineFarm, Obj.MARCUL, null); 178 178 if (zoom >= 16) 179 Renderer.lineVector(feature, new LineStyle( new BasicStroke(4, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1, new float[] { 10, 10 }, 0), Color.black, null));179 Renderer.lineVector(feature, new LineStyle( Color.black, 4, new float[] { 10, 10 }, null)); 180 180 break; 181 181 case FAIRWY: 182 182 if (Renderer.calcArea(feature) > 2.0) { 183 183 if (zoom < 16) 184 Renderer.lineVector(feature, new LineStyle(new BasicStroke(8, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1, new float[] { 50, 50 }, 0), new Color(0xc480ff), new Color(0x40ffffff, true)));184 Renderer.lineVector(feature, new LineStyle(new Color(0xc480ff), 8, new float[] { 50, 50 }, new Color(0x40ffffff, true))); 185 185 else 186 Renderer.lineVector(feature, new LineStyle(new BasicStroke(8, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1, new float[] { 50, 50 }, 0), new Color(0xc480ff), null));186 Renderer.lineVector(feature, new LineStyle(new Color(0xc480ff), 8, new float[] { 50, 50 }, null)); 187 187 } else { 188 188 if (zoom >= 14) 189 Renderer.lineVector(feature, new LineStyle(n ull, null, new Color(0x40ffffff, true)));189 Renderer.lineVector(feature, new LineStyle(new Color(0x40ffffff, true), 0, null, null)); 190 190 } 191 191 break; 192 192 case DRGARE: 193 193 if (zoom < 16) 194 Renderer.lineVector(feature, new LineStyle( new BasicStroke(8, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1, new float[] { 25, 25 }, 0), Color.black, new Color(0x40ffffff, true)));194 Renderer.lineVector(feature, new LineStyle(Color.black, 8, new float[] { 25, 25 }, new Color(0x40ffffff, true))); 195 195 else 196 Renderer.lineVector(feature, new LineStyle( new BasicStroke(8, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1, new float[] { 25, 25 }, 0), Color.black, null));196 Renderer.lineVector(feature, new LineStyle(Color.black, 8, new float[] { 25, 25 }, null)); 197 197 if ((zoom >= 12) && (name != null)) 198 198 Renderer.labelText(feature, (String) name.val, new TextStyle(new Font("Arial", Font.PLAIN, 100)), new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 0))); … … 208 208 if ((CatPRA)Renderer.getAttVal(feature, feature.type, 0, Att.CATPRA) == CatPRA.PRA_WFRM) { 209 209 Renderer.symbol(feature, Areas.WindFarm, Obj.OSPARE, null); 210 Renderer.lineVector(feature, new LineStyle( new BasicStroke(20, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1, new float[] { 40, 40 }, 0), Color.black, null));210 Renderer.lineVector(feature, new LineStyle(Color.black, 20, new float[] { 40, 40 }, null)); 211 211 if ((zoom >= 15) && (name != null)) 212 212 Renderer.labelText(feature, (String) name.val, new TextStyle(new Font("Arial", Font.BOLD, 80)), new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, 10))); … … 261 261 switch (lvl) { 262 262 case LEV_CVRS: 263 Renderer.symbol(feature, Areas.RockC, feature.type, null);263 Renderer.symbol(feature, Areas.RockC, null, null); 264 264 break; 265 265 case LEV_AWSH: 266 Renderer.symbol(feature, Areas.RockA, feature.type, null);266 Renderer.symbol(feature, Areas.RockA, null, null); 267 267 break; 268 268 default: 269 Renderer.symbol(feature, Areas.Rock, feature.type, null);269 Renderer.symbol(feature, Areas.Rock, null, null); 270 270 } 271 271 } else { 272 Renderer.symbol(feature, Areas.Rock, feature.type, null);272 Renderer.symbol(feature, Areas.Rock, null, null); 273 273 } 274 274 } … … 299 299 if (cats.get(0) == CatLMK.LMK_RADR) 300 300 fncSym = Landmarks.RadioTV; 301 Renderer.symbol(feature, catSym, feature.type, null);302 Renderer.symbol(feature, fncSym, feature.type, null);301 Renderer.symbol(feature, catSym, null, null); 302 Renderer.symbol(feature, fncSym, null, null); 303 303 } 304 304 private static void moorings(Feature feature) { … … 306 306 switch (cat) { 307 307 case MOR_DLPN: 308 Renderer.symbol(feature, Harbours.Dolphin, feature.type, null);308 Renderer.symbol(feature, Harbours.Dolphin, null, null); 309 309 break; 310 310 case MOR_DDPN: 311 Renderer.symbol(feature, Harbours.DeviationDolphin, feature.type, null);311 Renderer.symbol(feature, Harbours.DeviationDolphin, null, null); 312 312 break; 313 313 case MOR_BLRD: 314 314 case MOR_POST: 315 Renderer.symbol(feature, Harbours.Bollard, feature.type, null);315 Renderer.symbol(feature, Harbours.Bollard, null, null); 316 316 break; 317 317 case MOR_BUOY: … … 335 335 case WRK_DNGR: 336 336 case WRK_MSTS: 337 Renderer.symbol(feature, Areas.WreckD, feature.type, null);337 Renderer.symbol(feature, Areas.WreckD, null, null); 338 338 break; 339 339 case WRK_HULS: 340 Renderer.symbol(feature, Areas.WreckS, feature.type, null);340 Renderer.symbol(feature, Areas.WreckS, null, null); 341 341 break; 342 342 default: 343 Renderer.symbol(feature, Areas.WreckND, feature.type, null);343 Renderer.symbol(feature, Areas.WreckND, null, null); 344 344 } 345 345 } else { 346 Renderer.symbol(feature, Areas.WreckND, feature.type, null);346 Renderer.symbol(feature, Areas.WreckND, null, null); 347 347 } 348 348 } … … 352 352 switch (feature.type) { 353 353 case LITMAJ: 354 Renderer.symbol(feature, Beacons.LightMajor, feature.type, null);354 Renderer.symbol(feature, Beacons.LightMajor, null, null); 355 355 break; 356 356 case LITMIN: 357 357 case LIGHTS: 358 Renderer.symbol(feature, Beacons.LightMinor, feature.type, null);358 Renderer.symbol(feature, Beacons.LightMinor, null, null); 359 359 break; 360 360 } … … 364 364 case SISTAT: 365 365 case SISTAW: 366 Renderer.symbol(feature, Harbours.SignalStation, feature.type, null);366 Renderer.symbol(feature, Harbours.SignalStation, null, null); 367 367 break; 368 368 case RDOSTA: 369 Renderer.symbol(feature, Harbours.SignalStation, feature.type, null);369 Renderer.symbol(feature, Harbours.SignalStation, null, null); 370 370 break; 371 371 case RADSTA: 372 Renderer.symbol(feature, Harbours.SignalStation, feature.type, null); 372 Renderer.symbol(feature, Harbours.SignalStation, null, null); 373 Renderer.symbol(feature, Beacons.RadarStation, null, null); 373 374 break; 374 375 case PILBOP: 375 Renderer.symbol(feature, Harbours. SignalStation, feature.type, null);376 Renderer.symbol(feature, Harbours.Pilot, null, null); 376 377 break; 377 378 case CGUSTA: 378 Renderer.symbol(feature, Harbours. CoastGStation, feature.type, null);379 Renderer.symbol(feature, Harbours.SignalStation, null, null); 379 380 break; 380 381 case RSCSTA: 381 Renderer.symbol(feature, Harbours.Rescue Station, feature.type, null);382 Renderer.symbol(feature, Harbours.Rescue, null, null); 382 383 break; 383 384 } … … 399 400 } 400 401 private static void platforms(Feature feature) { 401 Renderer.symbol(feature, Landmarks.Platform, feature.type, null);402 Renderer.symbol(feature, Landmarks.Platform, null, null); 402 403 } 403 404 private static void buoys(Feature feature) { … … 415 416 case LAM_PORT: 416 417 if (shape == BcnSHP.BCN_PRCH) 417 Renderer.symbol(feature, Beacons.PerchPort, feature.type, null);418 Renderer.symbol(feature, Beacons.PerchPort, null, null); 418 419 else 419 Renderer.symbol(feature, Beacons.WithyPort, feature.type, null);420 Renderer.symbol(feature, Beacons.WithyPort, null, null); 420 421 break; 421 422 case LAM_STBD: 422 423 if (shape == BcnSHP.BCN_PRCH) 423 Renderer.symbol(feature, Beacons.PerchStarboard, feature.type, null);424 Renderer.symbol(feature, Beacons.PerchStarboard, null, null); 424 425 else 425 Renderer.symbol(feature, Beacons.WithyStarboard, feature.type, null);426 Renderer.symbol(feature, Beacons.WithyStarboard, null, null); 426 427 break; 427 428 default: -
applications/editors/josm/plugins/smed2/src/seamap/SeaMap.java
r29198 r29199 67 67 } 68 68 69 public class MpolyTab extends HashMap<Long, Long> { 70 public MpolyTab() { 71 super(); 72 } 73 } 74 69 75 public class FtrMap extends EnumMap<Obj, ArrayList<Feature>> { 70 76 public FtrMap() { … … 108 114 public WayTab ways; 109 115 public WayTab mpolys; 116 public MpolyTab outers; 110 117 public FtrMap features; 111 118 public FtrTab index; … … 113 120 private Feature feature; 114 121 private ArrayList<Long> list; 122 private long mpid; 115 123 116 124 public SeaMap() { … … 145 153 list = new ArrayList<Long>(); 146 154 mpolys.put(id, list); 155 mpid = id; 147 156 } 148 157 … … 152 161 153 162 public void addToMpoly(long way, boolean outer) { 154 if (outer) 163 if (outer) { 155 164 list.add(0, way); 156 else 165 outers.put(way, mpid); 166 } else { 157 167 list.add(way); 168 } 158 169 } 159 170 -
applications/editors/josm/plugins/smed2/src/symbols/Harbours.java
r29198 r29199 71 71 ClearV.add(new Instr(Prim.LINE, new Line2D.Double(-10,25,10,25))); 72 72 ClearV.add(new Instr(Prim.LINE, new Line2D.Double(0,25,0,15))); 73 }74 public static final Symbol CoastGStation = new Symbol();75 static{76 77 73 } 78 74 public static final Symbol ContainerCrane = new Symbol(); … … 149 145 MarinaNF.add(new Instr(Prim.SYMB, new Symbols.SubSymbol(Harbours.Yacht, 1.0, 0, 0, null, null))); 150 146 } 147 public static final Symbol Pilot = new Symbol(); 148 static{ 149 Pilot.add(new Instr(Prim.STRK, new BasicStroke(4, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER))); 150 Pilot.add(new Instr(Prim.FILL, new Color(0xd400d4))); 151 Path2D.Double p = new Path2D.Double(); p.moveTo(-15,0); p.lineTo(0,-56); p.lineTo(15,0); p.lineTo(0,56); p.closePath(); 152 Pilot.add(new Instr(Prim.PGON, p)); 153 Pilot.add(new Instr(Prim.ELPS, new Ellipse2D.Double(-58,-58,116,116))); 154 } 151 155 public static final Symbol PortCrane = new Symbol(); 152 156 static { … … 161 165 Post.add(new Instr(Prim.RSHP, new Ellipse2D.Double(-10,-10,20,20))); 162 166 } 163 public static final Symbol Rescue Station= new Symbol();167 public static final Symbol Rescue = new Symbol(); 164 168 static{ 165 169 Rescue.add(new Instr(Prim.STRK, new BasicStroke(4, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER))); 170 Rescue.add(new Instr(Prim.FILL, Color.black)); 171 Path2D.Double p = new Path2D.Double(); p.moveTo(-11,0); p.lineTo(0,-43); p.lineTo(11,0); p.lineTo(0,43); p.closePath(); 172 Rescue.add(new Instr(Prim.PGON, p)); 173 Rescue.add(new Instr(Prim.LINE, new Line2D.Double(-15,0,15,0))); 166 174 } 167 175 public static final Symbol SignalStation = new Symbol(); -
applications/editors/josm/plugins/smed2/src/symbols/Symbols.java
r29198 r29199 108 108 109 109 public static class LineStyle { 110 BasicStroke stroke;111 Color line;112 Color fill;113 114 public LineStyle(BasicStroke istroke, Color iline, Color ifill) { 115 stroke = istroke;110 public Color line; 111 public float width; 112 public float[] dash; 113 public Color fill; 114 115 public LineStyle(Color iline, float iwidth, float[] idash, Color ifill) { 116 116 line = iline; 117 width = iwidth; 118 dash = idash; 117 119 fill = ifill; 118 120 }
Note:
See TracChangeset
for help on using the changeset viewer.