Changeset 29204 in osm for applications/editors
- Timestamp:
- 2013-01-19T15:50:02+01:00 (12 years ago)
- Location:
- applications/editors/josm/plugins/smed2/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed2/src/seamap/Renderer.java
r29202 r29204 16 16 import java.awt.Rectangle; 17 17 import java.awt.RenderingHints; 18 import java.awt. font.TextLayout;18 import java.awt.geom.AffineTransform; 19 19 import java.awt.geom.GeneralPath; 20 20 import java.awt.geom.Path2D; … … 29 29 import seamap.SeaMap; 30 30 import seamap.SeaMap.*; 31 import symbols.Areas;32 31 import symbols.Symbols; 33 32 import symbols.Symbols.*; … … 145 144 } 146 145 146 private static Rectangle symbolSize(Symbol symbol) { 147 Symbol ssymb = symbol; 148 while (ssymb != null) { 149 for (Instr item : symbol) { 150 if (item.type == Prim.BBOX) { 151 return (Rectangle) item.params; 152 } 153 if (item.type == Prim.SYMB) { 154 ssymb = (Symbol) item.params; 155 break; 156 } 157 } 158 if (ssymb == symbol) 159 break; 160 } 161 return null; 162 } 163 147 164 public static void lineSymbols(Feature feature, Symbol prisymb, double space, Symbol secsymb, int ratio) { 148 165 if (feature.flag != Fflag.NODE) { 149 ArrayList<Long> way = map.ways.get(feature.refs); 150 for (long node : way) { 151 Point2D point = helper.getPoint(map.nodes.get(node)); 152 153 } 154 } 155 } 156 166 Rectangle prect = symbolSize(prisymb); 167 Rectangle srect = symbolSize(secsymb); 168 if (srect == null) 169 ratio = 0; 170 if (prect != null) { 171 ArrayList<Long> ways = new ArrayList<Long>(); 172 double psize = Math.abs(prect.getY()) * sScale; 173 double ssize = (srect != null) ? Math.abs(srect.getY()) * sScale : 0; 174 if (map.outers.containsKey(feature.refs)) { 175 ways.addAll(map.mpolys.get(map.outers.get(feature.refs))); 176 } else { 177 if (map.mpolys.containsKey(feature.refs)) { 178 ways.addAll(map.mpolys.get(feature.refs)); 179 } else { 180 ways.add(feature.refs); 181 } 182 } 183 Point2D prev = new Point2D.Double(); 184 Point2D next = new Point2D.Double(); 185 Point2D curr = new Point2D.Double(); 186 Point2D succ = new Point2D.Double(); 187 boolean gap = true; 188 boolean piv = false; 189 double len = 0; 190 double angle = 0; 191 int scount = ratio; 192 Symbol symbol = prisymb; 193 for (long way : ways) { 194 boolean first = true; 195 for (long node : map.ways.get(way)) { 196 prev = next; 197 next = helper.getPoint(map.nodes.get(node)); 198 angle = Math.atan2(next.getY() - prev.getY(), next.getX() - prev.getX()); 199 piv = true; 200 if (first) { 201 curr = succ = next; 202 gap = (space > 0); 203 scount = ratio; 204 symbol = prisymb; 205 len = gap ? psize * space * 0.5 : psize; 206 first = false; 207 } else { 208 while (curr.distance(next) >= len) { 209 if (piv) { 210 succ = new Point2D.Double(prev.getX() + (len * Math.cos(angle)), prev.getY() + (len * Math.sin(angle))); 211 piv = false; 212 } else { 213 succ = new Point2D.Double(curr.getX() + (len * Math.cos(angle)), curr.getY() + (len * Math.sin(angle))); 214 } 215 if (!gap) { 216 Symbols.drawSymbol(g2, symbol, sScale, curr.getX(), curr.getY(), new Delta(Handle.BC, AffineTransform.getRotateInstance(Math.atan2(succ.getY() - curr.getY(), succ.getX() - curr.getX())+Math.toRadians(90))), null); 217 } 218 if (space > 0) gap = !gap; 219 curr = succ; 220 len = gap ? (psize * space) : (--scount == 0) ? ssize : psize; 221 if (scount == 0) { 222 symbol = secsymb; 223 scount = ratio; 224 } else { 225 symbol = prisymb; 226 } 227 } 228 } 229 } 230 } 231 } 232 } 233 } 234 157 235 public static void lineVector (Feature feature, LineStyle style) { 158 236 if (feature.flag != Fflag.NODE) { … … 202 280 } 203 281 204 public static void labelText (Feature feature, String str, Font font, Delta delta) {282 public static void labelText (Feature feature, String str, Font font, Color colour, Delta delta) { 205 283 Symbol label = new Symbol(); 206 label.add(new Instr(Prim. FILL, Color.black));207 label.add(new Instr(Prim.TEXT, new Caption(str, font, delta)));284 label.add(new Instr(Prim.TEXT, new Caption(str, font, colour 285 , delta))); 208 286 Point2D point = helper.getPoint(findCentroid(feature)); 209 287 Symbols.drawSymbol(g2, label, tScale, point.getX(), point.getY(), delta, null); -
applications/editors/josm/plugins/smed2/src/seamap/Rules.java
r29202 r29204 148 148 AttItem name = feature.atts.get(Att.OBJNAM); 149 149 if ((zoom >= 10) && (name != null)) 150 Renderer.labelText(feature, (String) name.val, new Font("Arial", Font.BOLD, 150), n ull);150 Renderer.labelText(feature, (String) name.val, new Font("Arial", Font.BOLD, 150), new Color(0x80c480ff), null); 151 151 break; 152 152 case TSELNE: … … 170 170 } 171 171 if ((zoom >= 15) && (name != null)) 172 Renderer.labelText(feature, (String) name.val, new Font("Arial", Font.BOLD, 80), new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -90)));172 Renderer.labelText(feature, (String) name.val, new Font("Arial", Font.BOLD, 80), Color.black, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -90))); 173 173 break; 174 174 case MARCUL: … … 195 195 Renderer.lineVector(feature, new LineStyle(Color.black, 8, new float[] { 25, 25 }, null)); 196 196 if ((zoom >= 12) && (name != null)) 197 Renderer.labelText(feature, (String) name.val, new Font("Arial", Font.PLAIN, 100), new Delta(Handle.CC, AffineTransform.getTranslateInstance(0, 0)));197 Renderer.labelText(feature, (String) name.val, new Font("Arial", Font.PLAIN, 100), Color.black, new Delta(Handle.CC, AffineTransform.getTranslateInstance(0, 0))); 198 198 break; 199 199 case RESARE: 200 200 if (zoom >= 12) { 201 201 Renderer.lineSymbols(feature, Areas.Restricted, 1.0, null, 0); 202 if ((CatREA)Renderer.getAttVal(feature, feature.type, 0, Att.CATREA) == CatREA.REA_NWAK)203 Renderer.symbol(feature, Areas.NoWake, Obj.RESARE, null);202 // if ((CatREA)Renderer.getAttVal(feature, feature.type, 0, Att.CATREA) == CatREA.REA_NWAK) 203 // Renderer.symbol(feature, Areas.NoWake, Obj.RESARE, null); 204 204 } 205 205 break; … … 209 209 Renderer.lineVector(feature, new LineStyle(Color.black, 20, new float[] { 40, 40 }, null)); 210 210 if ((zoom >= 15) && (name != null)) 211 Renderer.labelText(feature, (String) name.val, new Font("Arial", Font.BOLD, 80), new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, 10)));211 Renderer.labelText(feature, (String) name.val, new Font("Arial", Font.BOLD, 80), Color.black, new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, 10))); 212 212 } 213 213 break; -
applications/editors/josm/plugins/smed2/src/smed2/MapImage.java
r29202 r29204 6 6 import java.awt.Rectangle; 7 7 import java.awt.geom.Point2D; 8 import java.awt.geom.Point2D.Double; 8 9 9 10 import javax.swing.Action; … … 86 87 } 87 88 88 public Point2D getPoint(Coord coord) {89 return Main.map.mapView.getPoint2D(new LatLon(Math.toDegrees(coord.lat), Math.toDegrees(coord.lon)));89 public Point2D.Double getPoint(Coord coord) { 90 return (Double) Main.map.mapView.getPoint2D(new LatLon(Math.toDegrees(coord.lat), Math.toDegrees(coord.lon))); 90 91 } 91 92 } -
applications/editors/josm/plugins/smed2/src/symbols/Areas.java
r29198 r29204 35 35 public static final Symbol LaneArrow = new Symbol(); 36 36 static { 37 LaneArrow.add(new Instr(Prim.BBOX, new Rectangle(-20,-240,40,240))); 37 38 LaneArrow.add(new Instr(Prim.STRK, new BasicStroke(10, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER))); 38 39 LaneArrow.add(new Instr(Prim.FILL, new Color(0x80c480ff, true))); -
applications/editors/josm/plugins/smed2/src/symbols/Notices.java
r29202 r29204 51 51 private static final Symbol Sport = new Symbol(); 52 52 static { 53 Sport.add(new Instr(Prim.TEXT, new Caption("SPORT", new Font("Arial", Font.BOLD, 15), new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 0)))));53 Sport.add(new Instr(Prim.TEXT, new Caption("SPORT", new Font("Arial", Font.BOLD, 15), Color.black, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 0))))); 54 54 } 55 55 private static final Symbol Turn = new Symbol(); … … 65 65 private static final Symbol VHF = new Symbol(); 66 66 static { 67 VHF.add(new Instr(Prim.TEXT, new Caption("VHF", new Font("Arial", Font.BOLD, 20), new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 0)))));67 VHF.add(new Instr(Prim.TEXT, new Caption("VHF", new Font("Arial", Font.BOLD, 20), Color.black, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 0))))); 68 68 } 69 69 private static final Symbol Waterbike = new Symbol(); -
applications/editors/josm/plugins/smed2/src/symbols/Symbols.java
r29202 r29204 57 57 58 58 public static class Instr { 59 Prim type;60 Object params;59 public Prim type; 60 public Object params; 61 61 62 62 public Instr(Prim itype, Object iparams) { … … 67 67 68 68 public static class Delta { 69 Handle h;70 AffineTransform t;69 public Handle h; 70 public AffineTransform t; 71 71 72 72 public Delta(Handle ih, AffineTransform it) { … … 77 77 78 78 public static class Scheme { 79 ArrayList<ColPAT> pat;80 ArrayList<ColCOL> col;79 public ArrayList<ColPAT> pat; 80 public ArrayList<ColCOL> col; 81 81 82 82 public Scheme(ArrayList<ColPAT> ipat, ArrayList<ColCOL> icol) { … … 87 87 88 88 public static class Caption { 89 String str; 90 Font font; 91 Delta dd; 92 93 public Caption(String istr, Font ifont, Delta idd) { 94 str = istr; 89 public String string; 90 public Font font; 91 public Color colour; 92 public Delta dd; 93 94 public Caption(String istr, Font ifont, Color icolour, Delta idd) { 95 string = istr; 95 96 font = ifont; 97 colour = icolour; 96 98 dd = idd; 97 99 } … … 287 289 case TEXT: 288 290 Caption c = (Caption) item.params; 289 TextLayout layout = new TextLayout(c.str, c.font, g2.getFontRenderContext()); 291 g2.setPaint(c.colour); 292 TextLayout layout = new TextLayout(c.string, c.font, g2.getFontRenderContext()); 290 293 Rectangle2D bb = layout.getBounds(); 291 294 dx = 0;
Note:
See TracChangeset
for help on using the changeset viewer.