Changeset 30123 in osm for applications


Ignore:
Timestamp:
2013-12-10T22:02:45+01:00 (11 years ago)
Author:
malcolmh
Message:

save

Location:
applications/editors/josm/plugins/smed2/src
Files:
4 edited

Legend:

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

    r30119 r30123  
    2020import seamap.SeaMap.*;
    2121import seamap.SeaMap.Area;
     22import symbols.Areas;
     23import symbols.Harbours;
    2224import symbols.Symbols;
    2325import symbols.Symbols.*;
     
    6264        }
    6365       
    64         public enum LabelStyle { NONE, RRCT, RECT, ELPS, CIRC, VCLR, HCLR }
     66        public enum LabelStyle { NONE, RRCT, RECT, ELPS, CIRC, VCLR, PCLR, HCLR }
    6567
    6668        static MapContext context;
     
    446448                        label.add(new Instr(Prim.PLIN, p));
    447449                        break;
     450                case PCLR:
     451                        width += height * 1.0;
     452                        height *= 2.0;
     453            if (width < height) width = height;
     454            lx = -width / 2;
     455            ly = -height / 2;
     456            tx = lx + (height * 0.27);
     457            ty = ly + (height * 0.25);
     458                        label.add(new Instr(Prim.BBOX, new Rectangle2D.Double(lx,ly,width,height)));
     459                        label.add(new Instr(Prim.FILL, bg));
     460                        label.add(new Instr(Prim.RSHP, new RoundRectangle2D.Double(lx,ly,width,height,height,height)));
     461                        label.add(new Instr(Prim.FILL, fg));
     462                        sw = 1 + (int)(height/10);
     463                        po = sw / 2;
     464                        label.add(new Instr(Prim.STRK, new BasicStroke(sw, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER)));
     465                        p = new Path2D.Double(); p.moveTo(-height*0.2,-ly-po); p.lineTo(height*0.2,-ly-po); p.moveTo(0,-ly-po); p.lineTo(0,-ly-po-(height*0.15));
     466                        p.moveTo(-height*0.2,ly+po); p.lineTo((height*0.2),ly+po); p.moveTo(0,ly+po); p.lineTo(0,ly+po+(height*0.15));
     467                        label.add(new Instr(Prim.PLIN, p));
     468                        label.add(new Instr(Prim.SYMB, new Symbols.SubSymbol(Areas.CableFlash, 1, 0, 0, null, new Delta(Handle.CC, new AffineTransform(0,-1,1,0,-width/2,0)))));
     469                        label.add(new Instr(Prim.SYMB, new Symbols.SubSymbol(Areas.CableFlash, 1, 0, 0, null, new Delta(Handle.CC, new AffineTransform(0,-1,1,0,width/2,0)))));
     470                        break;
    448471                case HCLR:
    449472                        width += height * 1.5;
  • applications/editors/josm/plugins/smed2/src/seamap/Rules.java

    r30120 r30123  
    381381                                        Renderer.lineSymbols(feature, Areas.CableDash, 0, Areas.CableDot, null, 2, Color.black);
    382382                                }
     383                                if (atts != null) {
     384                                        if (atts.containsKey(Att.VERCLR)) {
     385                                                Renderer.labelText(feature, String.valueOf((Double) atts.get(Att.VERCLR).val), new Font("Arial", Font.PLAIN, 50), LabelStyle.VCLR, Color.black, new Delta(Handle.TC, AffineTransform.getTranslateInstance(0,25)));
     386                                        } else if (atts.containsKey(Att.VERCSA)) {
     387                                                Renderer.labelText(feature, String.valueOf((Double) atts.get(Att.VERCSA).val), new Font("Arial", Font.PLAIN, 50), LabelStyle.PCLR, Color.black, new Delta(Handle.TC, AffineTransform.getTranslateInstance(0,25)));
     388                                        }
     389                                }
    383390                        }
    384391                }
     
    876883
    877884        private static void pipelines(Feature feature) {
    878                 if (zoom >= 14) {
     885                if ((zoom >= 16) && (feature.length < 2)) {
    879886                        if (feature.type == Obj.PIPSOL) {
    880887                                Renderer.lineSymbols(feature, Areas.Pipeline, 1.0, null, null, 0, Renderer.Mline);
    881888                        } else if (feature.type == Obj.PIPOHD) {
    882 
     889                                Renderer.lineVector(feature, new LineStyle(Color.black, 8));
     890                                AttMap atts = feature.objs.get(Obj.PIPOHD).get(0);
     891                                double verclr = 0;
     892                                if (atts != null) {
     893                                        if (atts.containsKey(Att.VERCLR)) {
     894                                                verclr = (Double) atts.get(Att.VERCLR).val;
     895                                        } else {
     896                                                verclr = atts.containsKey(Att.VERCSA) ? (Double) atts.get(Att.VERCSA).val : 0;
     897                                        }
     898                                        if (verclr > 0) {
     899                                                Renderer.labelText(feature, String.valueOf(verclr), new Font("Arial", Font.PLAIN, 50), LabelStyle.VCLR, Color.black, new Delta(Handle.TC, AffineTransform.getTranslateInstance(0,25)));
     900                                        }
     901                                }
    883902                        }
    884903                }
     
    961980        private static void stations(Feature feature) {
    962981                if (zoom >= 14) {
     982                        String str = "";
    963983                        switch (feature.type) {
    964984                        case SISTAT:
    965985                        case SISTAW:
    966986                                Renderer.symbol(feature, Harbours.SignalStation);
    967                                 String str = "SS";
     987                                str = "SS";
    968988                                //  Append (cat) to str
    969                                 Renderer.labelText(feature, str, new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.LC, AffineTransform.getTranslateInstance(30, 0)));
    970989                                break;
    971990                        case RDOSTA:
     
    9821001                        case CGUSTA:
    9831002                                Renderer.symbol(feature, Harbours.SignalStation);
    984                                 Renderer.labelText(feature, "CG", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.LC, AffineTransform.getTranslateInstance(30, 0)));
     1003                                str = "CG";
    9851004                                break;
    9861005                        case RSCSTA:
    9871006                                Renderer.symbol(feature, Harbours.Rescue);
    9881007                                break;
     1008                        }
     1009                        if ((zoom >= 15) && !str.isEmpty()) {
     1010                                Renderer.labelText(feature, str, new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.LC, AffineTransform.getTranslateInstance(30, 0)));
    9891011                        }
    9901012                }
  • applications/editors/josm/plugins/smed2/src/seamap/Signals.java

    r30046 r30123  
    1515import java.util.ArrayList;
    1616
    17 import s57.S57att.Att;
    18 import s57.S57obj.Obj;
    19 import s57.S57val.CatROS;
    20 import seamap.Renderer.LabelStyle;
     17import s57.S57att.*;
     18import s57.S57obj.*;
     19import s57.S57val.*;
     20import seamap.Renderer.*;
    2121import seamap.SeaMap.*;
    2222import symbols.Beacons;
    2323import symbols.Topmarks;
    24 import symbols.Symbols.Delta;
    25 import symbols.Symbols.Handle;
     24import symbols.Symbols.*;
    2625
    2726public class Signals {
    2827
    2928        public static void addSignals(Feature feature) {
    30           if (feature.objs.containsKey(Obj.FOGSIG)) Signals.fogSignals(feature);
    31           if (feature.objs.containsKey(Obj.RTPBCN)) Signals.radarStations(feature);
    32           if (feature.objs.containsKey(Obj.RADSTA)) Signals.radarStations(feature);
    33           if (feature.objs.containsKey(Obj.RDOSTA)) Signals.radioStations(feature);
    34           if (feature.objs.containsKey(Obj.LIGHTS)) Signals.lights(feature);
     29          if (feature.objs.containsKey(Obj.FOGSIG)) fogSignals(feature);
     30          if (feature.objs.containsKey(Obj.RTPBCN)) radarStations(feature);
     31          if (feature.objs.containsKey(Obj.RADSTA)) radarStations(feature);
     32          if (feature.objs.containsKey(Obj.RDOSTA)) radioStations(feature);
     33          if (feature.objs.containsKey(Obj.LIGHTS)) lights(feature);
    3534        }
    3635       
     
    4140        public static void radarStations(Feature feature) {
    4241                Renderer.symbol(feature, Beacons.RadarStation);
     42                String bstr = "";
     43                CatRTB cat = (CatRTB) Rules.getAttVal(feature, Obj.RTPBCN, 0, Att.CATRTB);
     44                switch (cat) {
     45                case RTB_RAMK:
     46                        bstr += " Ramark";
     47                        break;
     48                case RTB_RACN:
     49                        bstr += " Racon";
     50                        String astr = (String) Rules.getAttVal(feature, Obj.RTPBCN, 0, Att.SIGGRP);
     51                        if (!astr.isEmpty()) {
     52                                bstr += "(" + astr + ")";
     53                        }
     54                        Double per = (Double) Rules.getAttVal(feature, Obj.RTPBCN, 0, Att.SIGPER);
     55                        Double mxr = (Double) Rules.getAttVal(feature, Obj.RTPBCN, 0, Att.VALMXR);
     56                        if ((per != 0) || (mxr != 0)) {
     57                                bstr += (astr.isEmpty() ? " " : "");
     58                                bstr += (per != 0) ? per.toString() + "s" : "";
     59                                bstr += (mxr != 0) ? mxr.toString() + "M" : "";
     60                        }
     61                        break;
     62                default:
     63                        break;
     64                }
     65                if ((Renderer.zoom >= 15) && !bstr.isEmpty()) {
     66                        Renderer.labelText(feature, bstr, new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BR, AffineTransform.getTranslateInstance(-30, -30)));
     67                }
     68        }
     69
     70        public static void radioStations(Feature feature) {
     71                Renderer.symbol(feature, Beacons.RadarStation);
    4372                ArrayList<CatROS> cats = (ArrayList<CatROS>)Rules.getAttVal(feature, Obj.RDOSTA, 0, Att.CATROS);
    44                 String str = "";
     73                boolean vais = false;
     74                String bstr = "";
    4575                for (CatROS ros : cats) {
    4676                        switch (ros) {
    4777                        case ROS_OMNI:
    48                                 str += " RC";
     78                                bstr += " RC";
    4979                                break;
    5080                        case ROS_DIRL:
    51                                 str += " RD";
     81                                bstr += " RD";
    5282                                break;
    5383                        case ROS_ROTP:
    54                                 str += " RW";
     84                                bstr += " RW";
    5585                                break;
    5686                        case ROS_CNSL:
    57                                 str += " Consol";
     87                                bstr += " Consol";
    5888                                break;
    5989                        case ROS_RDF:
    60                                 str += " RG";
     90                                bstr += " RG";
    6191                                break;
    6292                        case ROS_QTA:
    63                                 str += " R";
     93                                bstr += " R";
    6494                                break;
    6595                        case ROS_AERO:
    66                                 str += " AeroRC";
     96                                bstr += " AeroRC";
    6797                                break;
    6898                        case ROS_DECA:
    69                                 str += " Decca";
     99                                bstr += " Decca";
    70100                                break;
    71101                        case ROS_LORN:
    72                                 str += " Loran";
     102                                bstr += " Loran";
    73103                                break;
    74104                        case ROS_DGPS:
    75                                 str += " DGPS";
     105                                bstr += " DGPS";
    76106                                break;
    77107                        case ROS_TORN:
    78                                 str += " Toran";
     108                                bstr += " Toran";
    79109                                break;
    80110                        case ROS_OMGA:
    81                                 str += " Omega";
     111                                bstr += " Omega";
    82112                                break;
    83113                        case ROS_SYLD:
    84                                 str += " Syledis";
     114                                bstr += " Syledis";
    85115                                break;
    86116                        case ROS_CHKA:
    87                                 str += " Chiaka";
     117                                bstr += " Chiaka";
    88118                                break;
    89119                        case ROS_PCOM:
     
    94124                        case ROS_PAIS:
    95125                        case ROS_SAIS:
    96                                 str += " AIS";
     126                                bstr += " AIS";
    97127                                break;
    98128                        case ROS_VAIS:
    99                                 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
     129                                vais = true;
    100130                                break;
    101131                        case ROS_VANC:
    102                                 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
     132                                vais = true;
    103133                                Renderer.symbol(feature, Topmarks.TopNorth, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
    104134                                break;
    105135                        case ROS_VASC:
    106                                 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
     136                                vais = true;
    107137                                Renderer.symbol(feature, Topmarks.TopSouth, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
    108138                                break;
    109139                        case ROS_VAEC:
    110                                 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
     140                                vais = true;
    111141                                Renderer.symbol(feature, Topmarks.TopEast, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
    112142                                break;
    113143                        case ROS_VAWC:
    114                                 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
     144                                vais = true;
    115145                                Renderer.symbol(feature, Topmarks.TopWest, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
    116146                                break;
    117147                        case ROS_VAPL:
    118                                 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
     148                                vais = true;
    119149                                Renderer.symbol(feature, Topmarks.TopCan, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
    120150                                break;
    121151                        case ROS_VASL:
    122                                 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
     152                                vais = true;
    123153                                Renderer.symbol(feature, Topmarks.TopCone, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
    124154                                break;
    125155                        case ROS_VAID:
    126                                 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
     156                                vais = true;
    127157                                Renderer.symbol(feature, Topmarks.TopIsol, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
    128158                                break;
    129159                        case ROS_VASW:
    130                                 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
     160                                vais = true;
    131161                                Renderer.symbol(feature, Topmarks.TopSphere, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
    132162                                break;
    133163                        case ROS_VASP:
    134                                 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
     164                                vais = true;
    135165                                Renderer.symbol(feature, Topmarks.TopX, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
    136166                                break;
    137167                        case ROS_VAWK:
    138                                 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
     168                                vais = true;
    139169                                Renderer.symbol(feature, Topmarks.TopCross, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
    140170                                break;
     
    143173                        }
    144174                }
    145                 if (!str.isEmpty()) Renderer.labelText(feature, str, new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BR, AffineTransform.getTranslateInstance(-30, -70)));
    146         }
    147 
    148         public static void radioStations(Feature feature) {
    149                
     175                if (Renderer.zoom >= 15) {
     176                        if (vais) {
     177                                Renderer.labelText(feature, "V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
     178                        }
     179                        if (!bstr.isEmpty()) {
     180                                Renderer.labelText(feature, bstr, new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BR, AffineTransform.getTranslateInstance(-30, -70)));
     181                        }
     182                }
    150183        }
    151184
     
    334367        if ((att = getAtt(obj, CATFOG)) != NULL)
    335368          strcat(string1, fog_signals[att->val.val.e]);
    336         if ((att = getAtt(obj, SIGGRP)) != NULL)
    337           sprintf(strchr(string1, 0), "(%s)", stringValue(att->val));
    338         else
    339           strcat(string1, " ");
    340         if ((att = getAtt(obj, SIGPER)) != NULL)
    341           sprintf(strchr(string1, 0), "%ss ", stringValue(att->val));
    342         if ((att = getAtt(obj, VALMXR)) != NULL)
    343           sprintf(strchr(string1, 0), "%sM", stringValue(att->val));
    344       }
    345       break;
    346     case RTPBCN:
    347       if (obj != NULL) {
    348         if ((att = getAtt(obj, CATRTB)) != NULL)
    349           strcat(string1, rtb_map[att->val.val.e]);
    350369        if ((att = getAtt(obj, SIGGRP)) != NULL)
    351370          sprintf(strchr(string1, 0), "(%s)", stringValue(att->val));
  • applications/editors/josm/plugins/smed2/src/smed2/MapImage.java

    r30033 r30123  
    9292                        width = Main.map.mapView.getBounds().getWidth();
    9393                        height = Main.map.mapView.getBounds().getHeight();
    94                         zoom = ((int) Math.min(18, Math.max(9, Math.round(Math.floor(Math.log(4096 / bounds.asRect().width) / Math.log(2))))));
     94                        zoom = ((int) Math.min(18, Math.max(9, Math.round(Math.floor(Math.log(1024 / bounds.asRect().height) / Math.log(2))))));
    9595                }
    9696        }
Note: See TracChangeset for help on using the changeset viewer.