Ignore:
Timestamp:
2013-01-17T12:08:28+01:00 (13 years ago)
Author:
malcolmh
Message:

save

Location:
applications/editors/josm/plugins/smed2/src/seamap
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/smed2/src/seamap/Renderer.java

    r29200 r29202  
    1111
    1212import java.awt.BasicStroke;
     13import java.awt.Color;
     14import java.awt.Font;
    1315import java.awt.Graphics2D;
     16import java.awt.Rectangle;
    1417import java.awt.RenderingHints;
     18import java.awt.font.TextLayout;
    1519import java.awt.geom.GeneralPath;
    1620import java.awt.geom.Path2D;
     
    2529import seamap.SeaMap;
    2630import seamap.SeaMap.*;
     31import symbols.Areas;
    2732import symbols.Symbols;
    2833import symbols.Symbols.*;
     
    6974        public static double calcArea(Feature feature) {
    7075          if (feature.flag == Fflag.AREA) {
    71                         ArrayList<Long> way = map.ways.get(feature.refs);
     76                        ArrayList<Long> way;
     77                        if (map.mpolys.containsKey(feature.refs)) {
     78                                way = map.ways.get(map.mpolys.get(feature.refs));
     79                        } else {
     80                                way = map.ways.get(feature.refs);
     81                        }
    7282                        Coord coord = map.nodes.get(way.get(0));
    7383            double llon = coord.lon;
     
    8999        public static Coord findCentroid(Feature feature) {
    90100                Coord coord;
    91                 ArrayList<Long> way = map.ways.get(feature.refs);
     101                ArrayList<Long> way;
     102                if (map.mpolys.containsKey(feature.refs)) {
     103                        way = map.ways.get(map.mpolys.get(feature.refs));
     104                } else {
     105                        way = map.ways.get(feature.refs);
     106                }
    92107                switch (feature.flag) {
    93108                case NODE:
     
    142157        public static void lineVector (Feature feature, LineStyle style) {
    143158                if (feature.flag != Fflag.NODE) {
    144                         Long mpoly = map.outers.get(feature.refs);
    145159                        ArrayList<Long> ways = new ArrayList<Long>();
    146                         if (mpoly != null) {
    147                                 ways.addAll(map.mpolys.get(mpoly));
     160                        if (map.outers.containsKey(feature.refs)) {
     161                                ways.addAll(map.mpolys.get(map.outers.get(feature.refs)));
    148162                        } else {
    149                                 ways.add(feature.refs);
     163                                if (map.mpolys.containsKey(feature.refs)) {
     164                                        ways.addAll(map.mpolys.get(feature.refs));
     165                                } else {
     166                                        ways.add(feature.refs);
     167                                }
    150168                        }
    151169                        Path2D.Double p = new Path2D.Double();
     
    168186                                        System.arraycopy(style.dash, 0, dash, 0, style.dash.length);
    169187                                        for (int i = 0; i < style.dash.length; i++) {
    170                                                 dash[i] *= (float) (sScale);
     188                                                dash[i] *= (float) sScale;
    171189                                        }
    172190                                        g2.setStroke(new BasicStroke((float) (style.width * sScale), BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1, dash, 0));
     
    184202        }
    185203       
    186         public static void labelText (Feature feature, String str, TextStyle style, Delta delta) {
     204        public static void labelText (Feature feature, String str, Font font, Delta delta) {
     205                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)));
     208                Point2D point = helper.getPoint(findCentroid(feature));
     209                Symbols.drawSymbol(g2, label, tScale, point.getX(), point.getY(), delta, null);
     210        }
     211       
     212        public static void lineText (Feature feature, String str, Font font, double offset, double dy) {
    187213               
    188214        }
    189        
    190         public static void lineText (Feature feature, String str, TextStyle style, double offset, Delta delta) {
    191                
    192         }
    193215}
  • applications/editors/josm/plugins/smed2/src/seamap/Rules.java

    r29199 r29202  
    103103       
    104104        private static void shoreline(Feature feature) {
    105                 CatSLC cat = (CatSLC) Renderer.getAttVal(feature, feature.type, 0, Att.CATSLC);
    106105                if (zoom >= 12) {
    107                         switch (cat) {
     106                        switch ((CatSLC) Renderer.getAttVal(feature, feature.type, 0, Att.CATSLC)) {
    108107                        case SLC_TWAL:
    109108                                WatLEV lev = (WatLEV) Renderer.getAttVal(feature, feature.type, 0, Att.WATLEV);
     
    111110                                        Renderer.lineVector(feature, new LineStyle(Color.black, 10, new float[] { 40, 40 }, null));
    112111                                        if (zoom >= 15)
    113                                                 Renderer.lineText(feature, "(covers)", new TextStyle(new Font("Arial", Font.PLAIN, 80)), 0.5, new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, 20)));
     112                                                Renderer.lineText(feature, "(covers)", new Font("Arial", Font.PLAIN, 80), 0.5, 20);
    114113                                } else {
    115114                                        Renderer.lineVector(feature, new LineStyle(Color.black, 10, null, null));
    116115                                }
    117116                                if (zoom >= 15)
    118                                         Renderer.lineText(feature, "Training Wall", new TextStyle(new Font("Arial", Font.PLAIN, 80)), 0.5, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -20)));
     117                                        Renderer.lineText(feature, "Training Wall", new Font("Arial", Font.PLAIN, 80), 0.5, -20);
    119118                        }
    120119                }
     
    149148                        AttItem name = feature.atts.get(Att.OBJNAM);
    150149                        if ((zoom >= 10) && (name != null))
    151                                 Renderer.labelText(feature, (String) name.val, new TextStyle(new Font("Arial", Font.BOLD, 150)), null);
     150                                Renderer.labelText(feature, (String) name.val, new Font("Arial", Font.BOLD, 150), null);
    152151                        break;
    153152                case TSELNE:
     
    171170                        }
    172171                        if ((zoom >= 15) && (name != null))
    173                                 Renderer.labelText(feature, (String) name.val, new TextStyle(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), new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -90)));
    174173                        break;
    175174                case MARCUL:
     
    196195                                Renderer.lineVector(feature, new LineStyle(Color.black, 8, new float[] { 25, 25 }, null));
    197196                        if ((zoom >= 12) && (name != null))
    198                                 Renderer.labelText(feature, (String) name.val, new TextStyle(new Font("Arial", Font.PLAIN, 100)), new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 0)));
     197                                Renderer.labelText(feature, (String) name.val, new Font("Arial", Font.PLAIN, 100), new Delta(Handle.CC, AffineTransform.getTranslateInstance(0, 0)));
    199198                        break;
    200199                case RESARE:
     
    210209                                Renderer.lineVector(feature, new LineStyle(Color.black, 20, new float[] { 40, 40 }, null));
    211210                                if ((zoom >= 15) && (name != null))
    212                                         Renderer.labelText(feature, (String) name.val, new TextStyle(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), new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, 10)));
    213212                        }
    214213                        break;
    215214                case SEAARE:
     215                        switch ((CatSEA) Renderer.getAttVal(feature, feature.type, 0, Att.CATSEA)) {
     216                        case SEA_RECH:
     217                                break;
     218                        case SEA_BAY:
     219                                break;
     220                        case SEA_SHOL:
     221                                break;
     222                        case SEA_GAT:
     223                        case SEA_NRRW:
     224                                break;
     225                        }
    216226                        break;
    217227                case SNDWAV:
  • applications/editors/josm/plugins/smed2/src/seamap/SeaMap.java

    r29200 r29202  
    120120        private Feature feature;
    121121        private ArrayList<Long> list;
    122         private long mpid;
    123122
    124123        public SeaMap() {
     
    154153                list = new ArrayList<Long>();
    155154                mpolys.put(id, list);
    156                 mpid = id;
     155                feature = new Feature();
     156                feature.refs = id;
     157                feature.flag = Fflag.AREA;
    157158        }
    158159
     
    164165                if (outer) {
    165166                        list.add(0, way);
    166                         outers.put(way, mpid);
     167                        outers.put(way, feature.refs);
    167168                } else {
    168169                        list.add(way);
Note: See TracChangeset for help on using the changeset viewer.