Ignore:
Timestamp:
2016-02-27T09:09:45+01:00 (9 years ago)
Author:
malcolmh
Message:

[seachart] update

Location:
applications/editors/josm/plugins/seachart/src/render
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/seachart/src/render/ChartContext.java

    r31532 r32082  
    1313import java.awt.geom.Point2D;
    1414
     15import s57.S57map;
    1516import s57.S57map.*;
    1617
     
    2122        double mile(Feature feature);
    2223        boolean clip();
    23         Color background();
     24        Color background(S57map map);
    2425        RuleSet ruleset();
    2526}
  • applications/editors/josm/plugins/seachart/src/render/Renderer.java

    r31532 r32082  
    4747                                g2.clip(new Rectangle2D.Double(tl.getX(), tl.getY(), (br.getX() - tl.getX()), (br.getY() - tl.getY())));
    4848                        }
    49                         g2.setBackground(context.background());
     49                        g2.setBackground(context.background(map));
    5050                        g2.clearRect(rect.x, rect.y, rect.width, rect.height);
    5151                        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
     
    484484            g2.setPaint(colour);
    485485            FontRenderContext frc = g2.getFontRenderContext();
    486             GlyphVector gv = font.deriveFont((float)(font.getSize()*sScale)).createGlyphVector(frc, (" " + str));
     486            GlyphVector gv = font.deriveFont(font.getSize2D() * (float)sScale).createGlyphVector(frc, (" " + str));
    487487            GeneralPath path = new GeneralPath();
    488488                        Point2D prev = new Point2D.Double();
     
    560560                        g2.draw(new Line2D.Double(centre.x, centre.y, centre.x - radial * Math.sin(Math.toRadians(mid)), centre.y + radial * Math.cos(Math.toRadians(mid))));
    561561                } else {
    562                         g2.draw(new Line2D.Double(centre.x, centre.y, centre.x - radial * Math.sin(Math.toRadians(s1)), centre.y + radial * Math.cos(Math.toRadians(s1))));
    563                         g2.draw(new Line2D.Double(centre.x, centre.y, centre.x - radial * Math.sin(Math.toRadians(s2)), centre.y + radial * Math.cos(Math.toRadians(s2))));
     562                        if ((s1 != 0.0) || (s2 != 360.0)) {
     563                                g2.draw(new Line2D.Double(centre.x, centre.y, centre.x - radial * Math.sin(Math.toRadians(s1)), centre.y + radial * Math.cos(Math.toRadians(s1))));
     564                                g2.draw(new Line2D.Double(centre.x, centre.y, centre.x - radial * Math.sin(Math.toRadians(s2)), centre.y + radial * Math.cos(Math.toRadians(s2))));
     565                        }
    564566                }
    565567                double arcWidth =  10.0 * sScale;
    566568                g2.setStroke(new BasicStroke((float)arcWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1));
    567569                g2.setPaint(col1);
    568                 g2.draw(new Arc2D.Double(centre.x - radial, centre.y - radial, 2 * radial, 2 * radial, -(s1 + 90), (s1 - s2 - 360) % 360, Arc2D.OPEN));
     570                g2.draw(new Arc2D.Double(centre.x - radial, centre.y - radial, 2 * radial, 2 * radial, -(s1 + 90), (s1 - s2), Arc2D.OPEN));
    569571                if (col2 != null) {
    570572                        g2.setPaint(col2);
    571                         g2.draw(new Arc2D.Double(centre.x - radial + arcWidth, centre.y - radial + arcWidth, 2 * (radial - arcWidth), 2 * (radial - arcWidth), -(s1 + 90), (s1 - s2 - 360) % 360, Arc2D.OPEN));
     573                        g2.draw(new Arc2D.Double(centre.x - radial + arcWidth, centre.y - radial + arcWidth, 2 * (radial - arcWidth), 2 * (radial - arcWidth), -(s1 + 90), (s1 - s2), Arc2D.OPEN));
    572574                }
    573575                if ((str != null) && (!str.isEmpty())) {
     
    577579            Font font = new Font("Arial", Font.PLAIN, 40);
    578580            GeneralPath path = new GeneralPath();
    579             GlyphVector gv = font.deriveFont((float)(font.getSize()*sScale)).createGlyphVector(frc, (" " + str));
     581            GlyphVector gv = font.deriveFont(font.getSize2D() * (float)sScale).createGlyphVector(frc, (" " + str));
    580582                        double gwidth = gv.getLogicalBounds().getWidth();
    581583                        boolean hand = false;
    582584            double offset = 0;
    583585            Point2D origin;
    584                         double arc = (s2 - s1 + 360) % 360;
     586                        double arc = (s2 - s1);
    585587                        if (dir) {
    586588                                radial += 10 * sScale;
  • applications/editors/josm/plugins/seachart/src/render/Rules.java

    r31846 r32082  
    278278                        break;
    279279                case COALNE:
    280                         Renderer.lineVector(feature, new LineStyle(Color.black, 10));
     280                        if (Renderer.zoom >= 12)
     281                                Renderer.lineVector(feature, new LineStyle(Color.black, 10));
    281282                        break;
    282283                case DEPARE:
     
    287288                        break;
    288289                case LAKARE:
    289                         Renderer.lineVector(feature, new LineStyle(Symbols.Bwater, 10, Symbols.Bwater));
     290                        if ((Renderer.zoom >= 12) || (feature.geom.area > 10.0))
     291                                Renderer.lineVector(feature, new LineStyle(Symbols.Bwater));
    290292                        break;
    291293                case DRGARE:
     
    310312                case LOKBSN:
    311313                case HRBBSN:
    312                         Renderer.lineVector(feature, new LineStyle(Color.black, 10, Symbols.Bwater));
     314                        if (Renderer.zoom >= 12) {
     315                                Renderer.lineVector(feature, new LineStyle(Color.black, 10, Symbols.Bwater));
     316                        } else {
     317                                Renderer.lineVector(feature, new LineStyle(Symbols.Bwater));
     318                        }
    313319                        break;
    314320                case HRBFAC:
    315321                        if (feature.objs.get(Obj.HRBBSN) != null) {
    316                                 Renderer.lineVector(feature, new LineStyle(Color.black, 10, Symbols.Bwater));
     322                                if (Renderer.zoom >= 12) {
     323                                        Renderer.lineVector(feature, new LineStyle(Color.black, 10, Symbols.Bwater));
     324                                } else {
     325                                        Renderer.lineVector(feature, new LineStyle(Symbols.Bwater));
     326                                }
    317327                        }
    318328                        break;
     
    10381048                if ((Renderer.context.ruleset() == RuleSet.ALL) || (Renderer.context.ruleset() == RuleSet.BASE)) {
    10391049                        if ((cat != CatSLC.SLC_SWAY) && (cat != CatSLC.SLC_TWAL)) {
    1040                                 Renderer.lineVector(feature, new LineStyle(Color.black, 10, Symbols.Yland));
     1050                                if (Renderer.zoom >= 12) {
     1051                                        Renderer.lineVector(feature, new LineStyle(Color.black, 10, Symbols.Yland));
     1052                                } else {
     1053                                        Renderer.lineVector(feature, new LineStyle(Symbols.Yland));
     1054                                }
    10411055                        }
    10421056                }
     
    10491063                                                Renderer.lineVector(feature, new LineStyle(Color.black, 10, new float[] { 40, 40 }, null));
    10501064                                                if (Renderer.zoom >= 15)
    1051                                                         Renderer.lineText(feature, "(covers)", new Font("Arial", Font.PLAIN, 80), Color.black, 0.5, 80);
     1065                                                        Renderer.lineText(feature, "(covers)", new Font("Arial", Font.PLAIN, 60), Color.black, 0.5, 80);
    10521066                                        } else {
    10531067                                                Renderer.lineVector(feature, new LineStyle(Color.black, 10, null, null));
    10541068                                        }
    10551069                                        if (Renderer.zoom >= 15)
    1056                                                 Renderer.lineText(feature, "Training Wall", new Font("Arial", Font.PLAIN, 80), Color.black, 0.5, -30);
     1070                                                Renderer.lineText(feature, "Training Wall", new Font("Arial", Font.PLAIN, 60), Color.black, 0.5, -30);
    10571071                                        break;
    10581072                                case SLC_SWAY:
     
    11991213
    12001214        private static void waterways() {
    1201                 Renderer.lineVector(feature, new LineStyle(Symbols.Bwater, 20, Symbols.Bwater));
     1215                Renderer.lineVector(feature, new LineStyle(Symbols.Bwater, 20, (feature.geom.prim == Pflag.AREA) ? Symbols.Bwater : null));
    12021216        }
    12031217
  • applications/editors/josm/plugins/seachart/src/render/Signals.java

    r31955 r32082  
    1313import java.awt.Font;
    1414import java.awt.geom.*;
     15import java.text.DecimalFormat;
    1516import java.util.ArrayList;
    1617import java.util.EnumMap;
    1718
     19import s57.S57val.CatLIT;
     20import s57.S57val.ColCOL;
    1821import s57.S57att.*;
    1922import s57.S57obj.*;
     
    2730public class Signals {
    2831
    29         static final EnumMap<ColCOL, Color> lightColours = new EnumMap<ColCOL, Color>(ColCOL.class);
     32        static final EnumMap<ColCOL, Color> LightColours = new EnumMap<ColCOL, Color>(ColCOL.class);
    3033        static {
    31                 lightColours.put(ColCOL.COL_WHT, new Color(0xffff00));
    32                 lightColours.put(ColCOL.COL_RED, new Color(0xff0000));
    33                 lightColours.put(ColCOL.COL_GRN, new Color(0x00ff00));
    34                 lightColours.put(ColCOL.COL_BLU, new Color(0x0000ff));
    35                 lightColours.put(ColCOL.COL_YEL, new Color(0xffff00));
    36                 lightColours.put(ColCOL.COL_AMB, new Color(0xffc200));
    37                 lightColours.put(ColCOL.COL_VIO, new Color(0xee82ee));
    38                 lightColours.put(ColCOL.COL_ORG, Color.orange);
    39                 lightColours.put(ColCOL.COL_MAG, Color.magenta);
    40         }
    41 
    42         static final EnumMap<ColCOL, String> lightLetters = new EnumMap<ColCOL, String>(ColCOL.class);
     34                LightColours.put(ColCOL.COL_WHT, new Color(0xffff00));
     35                LightColours.put(ColCOL.COL_RED, new Color(0xff0000));
     36                LightColours.put(ColCOL.COL_GRN, new Color(0x00ff00));
     37                LightColours.put(ColCOL.COL_BLU, new Color(0x0000ff));
     38                LightColours.put(ColCOL.COL_YEL, new Color(0xffff00));
     39                LightColours.put(ColCOL.COL_AMB, new Color(0xffc200));
     40                LightColours.put(ColCOL.COL_VIO, new Color(0xee82ee));
     41                LightColours.put(ColCOL.COL_ORG, Color.orange);
     42                LightColours.put(ColCOL.COL_MAG, Color.magenta);
     43        }
     44
     45        static final EnumMap<ColCOL, String> LightLetters = new EnumMap<ColCOL, String>(ColCOL.class);
    4346        static {
    44                 lightLetters.put(ColCOL.COL_WHT, "W");
    45                 lightLetters.put(ColCOL.COL_RED, "R");
    46                 lightLetters.put(ColCOL.COL_GRN, "G");
    47                 lightLetters.put(ColCOL.COL_BLU, "Bu");
    48                 lightLetters.put(ColCOL.COL_YEL, "Y");
    49                 lightLetters.put(ColCOL.COL_AMB, "Am");
    50                 lightLetters.put(ColCOL.COL_VIO, "Vi");
    51                 lightLetters.put(ColCOL.COL_ORG, "Or");
    52         }
    53 
    54         static final EnumMap<LitCHR, String> lightCharacters = new EnumMap<LitCHR, String>(LitCHR.class);
     47                LightLetters.put(ColCOL.COL_WHT, "W");
     48                LightLetters.put(ColCOL.COL_RED, "R");
     49                LightLetters.put(ColCOL.COL_GRN, "G");
     50                LightLetters.put(ColCOL.COL_BLU, "Bu");
     51                LightLetters.put(ColCOL.COL_YEL, "Y");
     52                LightLetters.put(ColCOL.COL_AMB, "Am");
     53                LightLetters.put(ColCOL.COL_VIO, "Vi");
     54                LightLetters.put(ColCOL.COL_ORG, "Or");
     55        }
     56
     57        static final EnumMap<LitCHR, String> LightCharacters = new EnumMap<LitCHR, String>(LitCHR.class);
    5558        static {
    56                 lightCharacters.put(LitCHR.CHR_F, "F");
    57                 lightCharacters.put(LitCHR.CHR_FL, "Fl");
    58                 lightCharacters.put(LitCHR.CHR_LFL, "LFl");
    59                 lightCharacters.put(LitCHR.CHR_Q, "Q");
    60                 lightCharacters.put(LitCHR.CHR_VQ, "VQ");
    61                 lightCharacters.put(LitCHR.CHR_UQ, "UQ");
    62                 lightCharacters.put(LitCHR.CHR_ISO, "Iso");
    63                 lightCharacters.put(LitCHR.CHR_OC, "Oc");
    64                 lightCharacters.put(LitCHR.CHR_IQ, "IQ");
    65                 lightCharacters.put(LitCHR.CHR_IVQ, "IVQ");
    66                 lightCharacters.put(LitCHR.CHR_IUQ, "IUQ");
    67                 lightCharacters.put(LitCHR.CHR_MO, "Mo");
    68                 lightCharacters.put(LitCHR.CHR_FFL, "FFl");
    69                 lightCharacters.put(LitCHR.CHR_FLLFL, "FlLFl");
    70                 lightCharacters.put(LitCHR.CHR_OCFL, "OcFl");
    71                 lightCharacters.put(LitCHR.CHR_FLFL, "FLFl");
    72                 lightCharacters.put(LitCHR.CHR_ALOC, "Al.Oc");
    73                 lightCharacters.put(LitCHR.CHR_ALLFL, "Al.LFl");
    74                 lightCharacters.put(LitCHR.CHR_ALFL, "Al.Fl");
    75                 lightCharacters.put(LitCHR.CHR_ALGR, "Al.Gr");
    76                 lightCharacters.put(LitCHR.CHR_QLFL, "Q+LFl");
    77                 lightCharacters.put(LitCHR.CHR_VQLFL, "VQ+LFl");
    78                 lightCharacters.put(LitCHR.CHR_UQLFL, "UQ+LFl");
    79                 lightCharacters.put(LitCHR.CHR_AL, "Al");
    80                 lightCharacters.put(LitCHR.CHR_ALFFL, "Al.FFl");
     59                LightCharacters.put(LitCHR.CHR_F, "F");
     60                LightCharacters.put(LitCHR.CHR_FL, "Fl");
     61                LightCharacters.put(LitCHR.CHR_LFL, "LFl");
     62                LightCharacters.put(LitCHR.CHR_Q, "Q");
     63                LightCharacters.put(LitCHR.CHR_VQ, "VQ");
     64                LightCharacters.put(LitCHR.CHR_UQ, "UQ");
     65                LightCharacters.put(LitCHR.CHR_ISO, "Iso");
     66                LightCharacters.put(LitCHR.CHR_OC, "Oc");
     67                LightCharacters.put(LitCHR.CHR_IQ, "IQ");
     68                LightCharacters.put(LitCHR.CHR_IVQ, "IVQ");
     69                LightCharacters.put(LitCHR.CHR_IUQ, "IUQ");
     70                LightCharacters.put(LitCHR.CHR_MO, "Mo");
     71                LightCharacters.put(LitCHR.CHR_FFL, "FFl");
     72                LightCharacters.put(LitCHR.CHR_FLLFL, "FlLFl");
     73                LightCharacters.put(LitCHR.CHR_OCFL, "OcFl");
     74                LightCharacters.put(LitCHR.CHR_FLFL, "FLFl");
     75                LightCharacters.put(LitCHR.CHR_ALOC, "Al.Oc");
     76                LightCharacters.put(LitCHR.CHR_ALLFL, "Al.LFl");
     77                LightCharacters.put(LitCHR.CHR_ALFL, "Al.Fl");
     78                LightCharacters.put(LitCHR.CHR_ALGR, "Al.Gr");
     79                LightCharacters.put(LitCHR.CHR_QLFL, "Q+LFl");
     80                LightCharacters.put(LitCHR.CHR_VQLFL, "VQ+LFl");
     81                LightCharacters.put(LitCHR.CHR_UQLFL, "UQ+LFl");
     82                LightCharacters.put(LitCHR.CHR_AL, "Al");
     83                LightCharacters.put(LitCHR.CHR_ALFFL, "Al.FFl");
    8184        }
    8285       
     
    103106        }
    104107
     108        static final DecimalFormat df = new DecimalFormat("#.#");
     109       
    105110        public static void fogSignals(Feature feature) {
    106111                Renderer.symbol(feature, Beacons.FogSignal);
     
    116121                }
    117122                if (atts.containsKey(Att.SIGPER)) {
    118                         str += atts.get(Att.SIGPER).val + "s";
     123                        str += df.format(atts.get(Att.SIGPER).val) + "s";
    119124                }
    120125                if (atts.containsKey(Att.VALMXR)) {
    121                         str += atts.get(Att.VALMXR).val + "M";
     126                        str += df.format(atts.get(Att.VALMXR).val) + "M";
    122127                }
    123128                if ((Renderer.zoom >= 15) && !str.isEmpty()) {
     
    169174        @SuppressWarnings("unchecked")
    170175        public static void radioStations(Feature feature) {
    171                 Renderer.symbol(feature, Beacons.RadarStation);
    172176                ArrayList<CatROS> cats = (ArrayList<CatROS>)Rules.getAttList(feature, Obj.RDOSTA, 0, Att.CATROS);
    173177                boolean vais = false;
     
    272276                                break;
    273277                        }
     278                }
     279                if (!vais) {
     280                        Renderer.symbol(feature, Beacons.RadarStation);
    274281                }
    275282                if (Renderer.zoom >= 15) {
     
    315322                        }
    316323                }
    317                 Renderer.symbol(feature, Beacons.LightFlare, new Scheme(lightColours.get(col)), new Delta(Handle.BC, AffineTransform.getRotateInstance(Math.toRadians(120))));
    318                 if (lights.get(1) != null) {
    319                         for (AttMap atts : lights.values()) {
    320                                 Enum<ColCOL> col1 = null;
    321                                 Enum<ColCOL> col2 = null;
    322                                 double radius = 0.2;
    323                                 double s1 = 0;
    324                                 double s2 = 0;
    325                                 boolean dir = false;
     324                Renderer.symbol(feature, Beacons.LightFlare, new Scheme(LightColours.get(col)), new Delta(Handle.BC, AffineTransform.getRotateInstance(Math.toRadians(120))));
     325                if (Renderer.zoom >= 15) {
     326                        String str = "";
     327                        if (lights.get(1) != null) {
     328                                for (AttMap atts : lights.values()) {
     329                                        Enum<ColCOL> col1 = null;
     330                                        Enum<ColCOL> col2 = null;
     331                                        double radius = 0.2;
     332                                        double s1 = 0;
     333                                        double s2 = 0;
     334                                        boolean dir = false;
     335                                        if (atts.containsKey(Att.COLOUR)) {
     336                                                ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val;
     337                                                col1 = cols.get(0);
     338                                                if (cols.size() > 1)
     339                                                        col2 = cols.get(1);
     340                                        } else {
     341                                                continue;
     342                                        }
     343                                        if (atts.containsKey(Att.LITRAD)) {
     344                                                radius = (Double) atts.get(Att.LITRAD).val;
     345                                        }
     346                                        if (atts.containsKey(Att.SECTR1)) {
     347                                                s1 = (Double) atts.get(Att.SECTR1).val;
     348                                        } else {
     349                                                continue;
     350                                        }
     351                                        if (atts.containsKey(Att.SECTR2)) {
     352                                                s2 = (Double) atts.get(Att.SECTR2).val;
     353                                        } else {
     354                                                continue;
     355                                        }
     356                                        if (atts.containsKey(Att.CATLIT)) {
     357                                                ArrayList<CatLIT> cats = (ArrayList<CatLIT>) atts.get(Att.CATLIT).val;
     358                                                if (cats.contains(CatLIT.LIT_DIR)) {
     359                                                        dir = true;
     360                                                }
     361                                        }
     362                                        str = "";
     363                                        if (atts.containsKey(Att.LITCHR)) {
     364                                                str += LightCharacters.get(((ArrayList<LitCHR>) atts.get(Att.LITCHR).val).get(0));
     365                                        }
     366                                        if (atts.containsKey(Att.SIGGRP)) {
     367                                                str += "(" + atts.get(Att.SIGGRP).val + ")";
     368                                        } else if (!str.isEmpty()) {
     369                                                str += ".";
     370                                        }
     371                                        if (atts.containsKey(Att.COLOUR)) {
     372                                                ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val;
     373                                                str += LightLetters.get(cols.get(0));
     374                                                if (cols.size() > 1)
     375                                                        str += LightLetters.get(cols.get(1));
     376                                        }
     377                                        if (dir && atts.containsKey(Att.ORIENT)) {
     378                                                double orient = (Double) atts.get(Att.ORIENT).val;
     379                                                str += " " + orient + "°";
     380                                                s1 = (orient - 4 + 360) % 360;
     381                                                s2 = (orient + 4) % 360;
     382                                                double n1 = 360;
     383                                                double n2 = 360;
     384                                                for (AttMap sect : lights.values()) {
     385                                                        if (sect != atts) {
     386
     387                                                        }
     388                                                }
     389                                        }
     390                                        Renderer.lightSector(feature, LightColours.get(col1), LightColours.get(col2), radius, s1, s2, dir, (Renderer.zoom >= 15) ? str : "");
     391                                }
     392                                class LitSect {
     393                                        boolean dir;
     394                                        LitCHR chr;
     395                                        ColCOL col;
     396                                        ColCOL alt;
     397                                        String grp;
     398                                        double per;
     399                                        double rng;
     400                                        double hgt;
     401                                }
     402                                str = "";
     403                                ArrayList<LitSect> litatts = new ArrayList<>();
     404                                for (AttMap atts : lights.values()) {
     405                                        LitSect sect = new LitSect();
     406                                        litatts.add(sect);
     407                                        sect.dir = (atts.containsKey(Att.CATLIT)) && (atts.get(Att.CATLIT).val == CatLIT.LIT_DIR);
     408                                        sect.chr = atts.containsKey(Att.LITCHR) ? ((ArrayList<LitCHR>) atts.get(Att.LITCHR).val).get(0) : LitCHR.CHR_UNKN;
     409                                        switch (sect.chr) {
     410                                        case CHR_AL:
     411                                                sect.chr = LitCHR.CHR_F;
     412                                                break;
     413                                        case CHR_ALOC:
     414                                                sect.chr = LitCHR.CHR_OC;
     415                                                break;
     416                                        case CHR_ALLFL:
     417                                                sect.chr = LitCHR.CHR_LFL;
     418                                                break;
     419                                        case CHR_ALFL:
     420                                                sect.chr = LitCHR.CHR_FL;
     421                                                break;
     422                                        case CHR_ALFFL:
     423                                                sect.chr = LitCHR.CHR_FFL;
     424                                                break;
     425                                        default:
     426                                                break;
     427                                        }
     428                                        sect.grp = atts.containsKey(Att.SIGGRP) ? (String) atts.get(Att.SIGGRP).val : "";
     429                                        sect.per = atts.containsKey(Att.SIGPER) ? (Double) atts.get(Att.SIGPER).val : 0.0;
     430                                        sect.rng = atts.containsKey(Att.VALNMR) ? (Double) atts.get(Att.VALNMR).val : 0.0;
     431                                        sect.hgt = atts.containsKey(Att.HEIGHT) ? (Double) atts.get(Att.HEIGHT).val : 0.0;
     432                                        ArrayList<ColCOL> cols = (ArrayList<ColCOL>) (atts.containsKey(Att.COLOUR) ? atts.get(Att.COLOUR).val : new ArrayList<>());
     433                                        sect.col = cols.size() > 0 ? cols.get(0) : ColCOL.COL_UNK;
     434                                        sect.alt = cols.size() > 1 ? cols.get(1) : ColCOL.COL_UNK;
     435                                }
     436                                ArrayList<ArrayList<LitSect>> groupings = new ArrayList<>();
     437                                for (LitSect lit : litatts) {
     438                                        boolean found = false;
     439                                        for (ArrayList<LitSect> group : groupings) {
     440                                                LitSect mem = group.get(0);
     441                                                if ((lit.dir == mem.dir) && (lit.chr == mem.chr) && (lit.grp.equals(mem.grp)) && (lit.per == mem.per) && (lit.hgt == mem.hgt)) {
     442                                                        group.add(lit);
     443                                                        found = true;
     444                                                }
     445                                        }
     446                                        if (!found) {
     447                                                ArrayList<LitSect> tmp = new ArrayList<LitSect>();
     448                                                tmp.add(lit);
     449                                                groupings.add(tmp);
     450                                        }
     451                                }
     452                                for (boolean moved = true; moved;) {
     453                                        moved = false;
     454                                        for (int i = 0; i < groupings.size() - 1; i++) {
     455                                                if (groupings.get(i).size() < groupings.get(i + 1).size()) {
     456                                                        ArrayList<LitSect> tmp = groupings.remove(i);
     457                                                        groupings.add(i + 1, tmp);
     458                                                        moved = true;
     459                                                }
     460                                        }
     461                                }
     462                                class ColRng {
     463                                        ColCOL col;
     464                                        double rng;
     465
     466                                        public ColRng(ColCOL c, double r) {
     467                                                col = c;
     468                                                rng = r;
     469                                        }
     470                                }
     471                                int y = -30;
     472                                for (ArrayList<LitSect> group : groupings) {
     473                                        ArrayList<ColRng> colrng = new ArrayList<>();
     474                                        for (LitSect lit : group) {
     475                                                boolean found = false;
     476                                                for (ColRng cr : colrng) {
     477                                                        if (cr.col == lit.col) {
     478                                                                if (lit.rng > cr.rng) {
     479                                                                        cr.rng = lit.rng;
     480                                                                }
     481                                                                found = true;
     482                                                        }
     483                                                }
     484                                                if (!found) {
     485                                                        colrng.add(new ColRng(lit.col, lit.rng));
     486                                                }
     487                                        }
     488                                        for (boolean moved = true; moved;) {
     489                                                moved = false;
     490                                                for (int i = 0; i < colrng.size() - 1; i++) {
     491                                                        if (colrng.get(i).rng < colrng.get(i + 1).rng) {
     492                                                                ColRng tmp = colrng.remove(i);
     493                                                                colrng.add(i + 1, tmp);
     494                                                                moved = true;
     495                                                        }
     496                                                }
     497                                        }
     498                                        LitSect tmp = group.get(0);
     499                                        if (tmp.dir)
     500                                                str += "Dir";
     501                                        str += LightCharacters.get(tmp.chr);
     502                                        if (!tmp.grp.isEmpty())
     503                                                str += "(" + tmp.grp + ")";
     504                                        else
     505                                                str += ".";
     506                                        for (ColRng cr : colrng) {
     507                                                str += LightLetters.get(cr.col);
     508                                        }
     509                                        if (tmp.per > 0)
     510                                                str += df.format(tmp.per) + "s";
     511                                        if (tmp.hgt > 0)
     512                                                str += df.format(tmp.hgt) + "m";
     513                                        if (colrng.get(0).rng > 0)
     514                                                str += df.format(colrng.get(0).rng) + ((colrng.size() > 1) ? ((colrng.size() > 2) ? ("-" + df.format(colrng.get(colrng.size() - 1).rng)) : ("/" + df.format(colrng.get(1).rng))) : "") + "M";
     515                                        Renderer.labelText(feature, str, new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.TL, AffineTransform.getTranslateInstance(60, y)));
     516                                        y += 40;
     517                                        str = "";
     518                                }
     519                        } else {
     520                                AttMap atts = lights.get(0);
     521                                ArrayList<CatLIT> cats = new ArrayList<>();
     522                                if (atts.containsKey(Att.CATLIT)) {
     523                                        cats = (ArrayList<CatLIT>) atts.get(Att.CATLIT).val;
     524                                }
     525                                str += (cats.contains(CatLIT.LIT_DIR)) ? "Dir" : "";
     526                                str += (atts.containsKey(Att.MLTYLT)) ? atts.get(Att.MLTYLT).val : "";
     527                                if (atts.containsKey(Att.LITCHR)) {
     528                                        LitCHR chr = ((ArrayList<LitCHR>) atts.get(Att.LITCHR).val).get(0);
     529                                        if (atts.containsKey(Att.SIGGRP)) {
     530                                                String grp = (String) atts.get(Att.SIGGRP).val;
     531                                                switch (chr) {
     532                                                case CHR_QLFL:
     533                                                        str += String.format("Q(%s)+LFl", grp);
     534                                                        break;
     535                                                case CHR_VQLFL:
     536                                                        str += String.format("VQ(%s)+LFl", grp);
     537                                                        break;
     538                                                case CHR_UQLFL:
     539                                                        str += String.format("UQ(%s)+LFl", grp);
     540                                                        break;
     541                                                default:
     542                                                        str += String.format("%s(%s)", LightCharacters.get(chr), grp);
     543                                                        break;
     544                                                }
     545                                        } else {
     546                                                str += LightCharacters.get(chr);
     547                                        }
     548                                }
    326549                                if (atts.containsKey(Att.COLOUR)) {
    327                                         ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val;
    328                                         col1 = cols.get(0);
    329                                         if (cols.size() > 1) col2 = cols.get(1);
    330                                 } else {
    331                                         continue;
    332                                 }
    333                                 if (atts.containsKey(Att.RADIUS)) {
    334                                         radius = (Double) atts.get(Att.RADIUS).val;
    335                                 }
    336                                 if (atts.containsKey(Att.SECTR1)) {
    337                                         s1 = (Double) atts.get(Att.SECTR1).val;
    338                                 } else {
    339                                         continue;
    340                                 }
    341                                 if (atts.containsKey(Att.SECTR2)) {
    342                                         s2 = (Double) atts.get(Att.SECTR2).val;
    343                                 } else {
    344                                         continue;
    345                                 }
    346                                 if (atts.containsKey(Att.CATLIT)) {
    347                                         ArrayList<CatLIT> cats = (ArrayList<CatLIT>) atts.get(Att.CATLIT).val;
    348                                         if (cats.contains(CatLIT.LIT_DIR)) {
    349                                                 dir = true;
    350                                         }
    351                                 }
    352                                 String str = "";
    353                                 if (atts.containsKey(Att.LITCHR)) {
    354                                         str += lightCharacters.get(atts.get(Att.LITCHR).val);
    355                                 }
    356                                 if (atts.containsKey(Att.SIGGRP)) {
    357                                         str += "(" + atts.get(Att.SIGGRP).val + ")";
    358                                 } else if (!str.isEmpty()) {
    359                                         str += ".";
    360                                 }
    361                                 if (atts.containsKey(Att.COLOUR)) {
    362                                         ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val;
    363                                         str += lightLetters.get(cols.get(0));
    364                                         if (cols.size() > 1)
    365                                                 str += lightLetters.get(cols.get(1));
    366                                 }
    367                                 if (dir && atts.containsKey(Att.ORIENT)) {
    368                                         double orient = (Double)atts.get(Att.ORIENT).val;
    369                                         str += " " + orient + "°";
    370                                         s1 = (orient - 4 + 360) % 360;
    371                                         s2 = (orient + 4) % 360;
    372                                         double n1 = 360;
    373                                         double n2 = 360;
    374                                         for (AttMap sect : lights.values()) {
    375                                                 if (sect != atts) {
    376                                                        
    377                                                 }
    378                                         }
    379                                 }
    380                                 Renderer.lightSector(feature, lightColours.get(col1), lightColours.get(col2), radius, s1, s2, dir, str);
    381                         }
    382                 }
    383 /*      int secmax = countObjects(item, "light");
    384       if ((idx == 0) && (secmax > 0)) {
    385         struct SECT {
    386           struct SECT *next;
    387           int dir;
    388           LitCHR_t chr;
    389           ColCOL_t col;
    390           ColCOL_t alt;
    391           char *grp;
    392           double per;
    393           double rng;
    394         } *lights = NULL;
    395         for (int i = secmax; i > 0; i--) {
    396           struct SECT *tmp = calloc(1, sizeof(struct SECT));
    397           tmp->next = lights;
    398           lights = tmp;
    399           obj = getObj(item, LIGHTS, i);
    400           if ((att = getAtt(obj, CATLIT)) != NULL) {
    401             lights->dir = testAtt(att, LIT_DIR);
    402           }
    403           if ((att = getAtt(obj, LITCHR)) != NULL) {
    404             lights->chr = att->val.val.e;
    405             switch (lights->chr) {
    406               case CHR_AL:
    407                 lights->chr = CHR_F;
    408                 break;
    409               case CHR_ALOC:
    410                 lights->chr = CHR_OC;
    411                 break;
    412               case CHR_ALLFL:
    413                 lights->chr = CHR_LFL;
    414                 break;
    415               case CHR_ALFL:
    416                 lights->chr = CHR_FL;
    417                 break;
    418               case CHR_ALFFL:
    419                 lights->chr = CHR_FFL;
    420                 break;
    421               default:
    422                 break;
    423             }
    424           }
    425           if ((att = getAtt(obj, SIGGRP)) != NULL) {
    426             lights->grp = att->val.val.a;
    427           } else {
    428             lights->grp = "";
    429           }
    430           if ((att = getAtt(obj, SIGPER)) != NULL) {
    431             lights->per = att->val.val.f;
    432           }
    433           if ((att = getAtt(obj, VALNMR)) != NULL) {
    434             lights->rng = att->val.val.f;
    435           }
    436           if ((att = getAtt(obj, COLOUR)) != NULL) {
    437             lights->col = att->val.val.l->val;
    438             if (att->val.val.l->next != NULL)
    439               lights->alt = att->val.val.l->next->val;
    440           }
    441         }
    442         struct COLRNG {
    443           int col;
    444           double rng;
    445         } colrng[14];
    446         while (lights != NULL) {
    447           strcpy(string2, "");
    448           bzero(colrng, 14*sizeof(struct COLRNG));
    449           colrng[lights->col].col = 1;
    450           colrng[lights->col].rng = lights->rng;
    451           struct SECT *this = lights;
    452           struct SECT *next = lights->next;
    453           while (next != NULL) {
    454             if ((this->dir == next->dir) && (this->chr == next->chr) &&
    455                 (strcmp(this->grp, next->grp) == 0) && (this->per == next->per)) {
    456               colrng[next->col].col = 1;
    457               if (next->rng > colrng[next->col].rng)
    458                 colrng[next->col].rng = next->rng;
    459               struct SECT *tmp = lights;
    460               while (tmp->next != next) tmp = tmp->next;
    461               tmp->next = next->next;
    462               free(next);
    463               next = tmp->next;
    464             } else {
    465               next = next->next;
    466             }
    467           }
    468           if (this->chr != CHR_UNKN) {
    469             if (this->dir) strcpy(string2, "Dir.");
    470             strcat(string2, light_characters[this->chr]);
    471             if (strcmp(this->grp, "") != 0) {
    472               if (this->grp[0] == '(')
    473                 sprintf(strchr(string2, 0), "%s", this->grp);
    474               else
    475                 sprintf(strchr(string2, 0), "(%s)", this->grp);
    476             } else {
    477               if (strlen(string2) > 0) strcat(string2, ".");
    478             }
    479             int n = 0;
    480             for (int i = 0; i < 14; i++) if (colrng[i].col) n++;
    481             double max = 0.0;
    482             for (int i = 0; i < 14; i++) if (colrng[i].col && (colrng[i].rng > max)) max = colrng[i].rng;
    483             double min = max;
    484             for (int i = 0; i < 14; i++) if (colrng[i].col && (colrng[i].rng > 0.0) && (colrng[i].rng < min)) min = colrng[i].rng;
    485             if (min == max) {
    486               for (int i = 0; i < 14; i++) if (colrng[i].col) strcat(string2, light_letters[i]);
    487             } else {
    488               for (int i = 0; i < 14; i++) if (colrng[i].col && (colrng[i].rng == max)) strcat(string2, light_letters[i]);
    489               for (int i = 0; i < 14; i++) if (colrng[i].col && (colrng[i].rng < max) && (colrng[i].rng > min)) strcat(string2, light_letters[i]);
    490               for (int i = 0; i < 14; i++) if (colrng[i].col && colrng[i].rng == min) strcat(string2, light_letters[i]);
    491             }
    492             strcat(string2, ".");
    493             if (this->per > 0.0) sprintf(strchr(string2, 0), "%gs", this->per);
    494             if (max > 0.0) {
    495               sprintf(strchr(string2, 0), "%g", max);
    496               if (min != max) {
    497                 if (n == 2) strcat(string2, "/");
    498                 else if (n > 2) strcat(string2, "-");
    499                 if (min < max) sprintf(strchr(string2, 0), "%g", min);
    500               }
    501               strcat(string2, "M");
    502             }
    503             if (strlen(string1) > 0) strcat(string1, "\n");
    504             strcat(string1, string2);
    505           }
    506           lights = this->next;
    507           free(this);
    508           this = lights;
    509         }
    510       } else {
    511         if ((att = getAtt(obj, CATLIT)) != NULL) {
    512           if (testAtt(att, LIT_DIR))
    513             strcat(string1, "Dir");
    514         }
    515         if ((att = getAtt(obj, MLTYLT)) != NULL)
    516           sprintf(strchr(string1, 0), "%s", stringValue(att->val));
    517         if ((att = getAtt(obj, LITCHR)) != NULL) {
    518           char *chrstr = strdup(stringValue(att->val));
    519           Att_t *grp = getAtt(obj, SIGGRP);
    520           if (grp != NULL) {
    521             char *strgrp = strdup(stringValue(grp->val));
    522             char *grpstr = strtok(strgrp, "()");
    523             switch (att->val.val.e) {
    524               case CHR_QLFL:
    525                 sprintf(strchr(string1, 0), "Q(%s)+LFl", grpstr);
    526                 break;
    527               case CHR_VQLFL:
    528                 sprintf(strchr(string1, 0), "VQ(%s)+LFl", grpstr);
    529                 break;
    530               case CHR_UQLFL:
    531                 sprintf(strchr(string1, 0), "UQ(%s)+LFl", grpstr);
    532                 break;
    533               default:
    534                 sprintf(strchr(string1, 0), "%s(%s)", chrstr, grpstr);
    535                 break;
    536             }
    537             free(strgrp);
    538           } else {
    539             sprintf(strchr(string1, 0), "%s", chrstr);
    540           }
    541           free(chrstr);
    542         }
    543         if ((att = getAtt(obj, COLOUR)) != NULL) {
    544           int n = countValues(att);
    545           if (!((n == 1) && (idx == 0) && (testAtt(att, COL_WHT)))) {
    546             if ((strlen(string1) > 0) && ((string1[strlen(string1)-1] != ')')))
    547               strcat(string1, ".");
    548             Lst_t *lst = att->val.val.l;
    549             while (lst != NULL) {
    550               strcat(string1, light_letters[lst->val]);
    551               lst = lst->next;
    552             }
    553           }
    554         }
    555         if ((idx == 0) && (att = getAtt(obj, CATLIT)) != NULL) {
    556           if (testAtt(att, LIT_VERT))
    557             strcat(string1, "(vert)");
    558           if (testAtt(att, LIT_HORI))
    559             strcat(string1, "(hor)");
    560         }
    561         if ((strlen(string1) > 0) &&
    562             ((getAtt(obj, SIGPER) != NULL) ||
    563              (getAtt(obj, HEIGHT) != NULL) ||
    564              (getAtt(obj, VALMXR) != NULL)) &&
    565             (string1[strlen(string1)-1] != ')'))
    566           strcat(string1, ".");
    567         if ((att = getAtt(obj, SIGPER)) != NULL)
    568           sprintf(strchr(string1, 0), "%ss", stringValue(att->val));
    569         if ((idx == 0) && (item->objs.obj != LITMIN)) {
    570           if ((att = getAtt(obj, HEIGHT)) != NULL)
    571             sprintf(strchr(string1, 0), "%sm", stringValue(att->val));
    572           if ((att = getAtt(obj, VALNMR)) != NULL)
    573             sprintf(strchr(string1, 0), "%sM", stringValue(att->val));
    574         }
    575         if ((idx == 0) && (att = getAtt(obj, CATLIT)) != NULL) {
    576           if (testAtt(att, LIT_FRNT))
    577             strcat(string1, "(Front)");
    578           if (testAtt(att, LIT_REAR))
    579             strcat(string1, "(Rear)");
    580           if (testAtt(att, LIT_UPPR))
    581             strcat(string1, "(Upper)");
    582           if (testAtt(att, LIT_LOWR))
    583             strcat(string1, "(Lower)");
    584         }
    585       }
    586     }
    587 */      }
    588 
     550                                        ArrayList<ColCOL> cols = (ArrayList<ColCOL>) atts.get(Att.COLOUR).val;
     551                                        if (!((cols.size() == 1) && (cols.get(0) == ColCOL.COL_WHT))) {
     552                                                if (!str.isEmpty() && !str.endsWith(")")) {
     553                                                        str += ".";
     554                                                }
     555                                                for (ColCOL acol : cols) {
     556                                                        str += LightLetters.get(acol);
     557                                                }
     558                                        }
     559                                }
     560                                str += (cats.contains(CatLIT.LIT_VERT)) ? "(vert)" : "";
     561                                str += (cats.contains(CatLIT.LIT_HORI)) ? "(hor)" : "";
     562                                str += (!str.isEmpty() && (atts.containsKey(Att.SIGPER) || atts.containsKey(Att.HEIGHT) || atts.containsKey(Att.VALMXR)) && !str.endsWith(")")) ? "." : "";
     563                                str += (atts.containsKey(Att.SIGPER)) ? df.format(atts.get(Att.SIGPER).val) + "s" : "";
     564                                str += (atts.containsKey(Att.HEIGHT)) ? df.format(atts.get(Att.HEIGHT).val) + "m" : "";
     565                                str += (atts.containsKey(Att.VALNMR)) ? df.format(atts.get(Att.VALNMR).val) + "M" : "";
     566                                str += (cats.contains(CatLIT.LIT_FRNT)) ? "(Front)" : "";
     567                                str += (cats.contains(CatLIT.LIT_REAR)) ? "(Rear)" : "";
     568                                str += (cats.contains(CatLIT.LIT_UPPR)) ? "(Upper)" : "";
     569                                str += (cats.contains(CatLIT.LIT_LOWR)) ? "(Lower)" : "";
     570                                Renderer.labelText(feature, str, new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.TL, AffineTransform.getTranslateInstance(60, -30)));
     571                        }
     572                }
     573        }
    589574}
Note: See TracChangeset for help on using the changeset viewer.