Changeset 34896 in osm for applications/editors/josm


Ignore:
Timestamp:
2019-02-15T18:17:18+01:00 (5 years ago)
Author:
malcolmh
Message:

refine light sectors

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

Legend:

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

    r34652 r34896  
    602602
    603603    public static void lightSector(Color col1, Color col2, double radius, double s1, double s2, Double dir, String str) {
    604         if ((zoom >= 16) && (radius > 0.2)) {
    605             radius /= Math.pow(2, zoom-15);
    606         }
    607604        double mid = (((s1 + s2) / 2) + (s1 > s2 ? 180 : 0)) % 360;
    608605        g2.setStroke(new BasicStroke((float) (3.0 * sScale), BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1,
  • applications/editors/josm/plugins/seachart/src/render/Rules.java

    r34886 r34896  
    121121                        }
    122122                }
    123                 return (name != null) ? (String) name.val : null;
     123                return (name != null) ? ((String) name.val).replace(""", "\"") : null;
    124124        }
    125125
     
    430430                        if (testAttribute(feature.type, Att.CATPRA, CatPRA.PRA_WFRM)) {
    431431                                Renderer.symbol(Areas.WindFarm);
    432                                 Renderer.lineVector(new LineStyle(Color.black, 20, new float[] { 40, 40 }));
    433                                 addName(15, new Font("Arial", Font.BOLD, 80), new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, 10)));
     432                                Renderer.lineVector(new LineStyle(Color.black, 12, new float[] { 40, 40 }));
     433                                addName(15, new Font("Arial", Font.BOLD, 80), new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, 120)));
    434434                        }
    435435                        break;
     
    954954        @SuppressWarnings("unchecked")
    955955        private static void landmarks() {
    956                 if (!hasAttribute(Obj.LNDMRK, Att.CATLMK) && (!hasAttribute(Obj.LNDMRK, Att.FUNCTN) || testAttribute(Obj.LNDMRK, Att.FUNCTN, FncFNC.FNC_LGHT)) && hasObject(Obj.LIGHTS))
     956                if (!hasAttribute(Obj.LNDMRK, Att.CATLMK) && (!hasAttribute(Obj.LNDMRK, Att.FUNCTN) || testAttribute(Obj.LNDMRK, Att.FUNCTN, FncFNC.FNC_LGHT)) && hasObject(Obj.LIGHTS)) {
    957957                        lights();
     958                        addName(15, new Font("Arial", Font.BOLD, 40), new Delta(Handle.BL, AffineTransform.getTranslateInstance(60, -50)));
     959                }
    958960                else if (Renderer.zoom >= 12) {
    959961                        switch (feature.type) {
     
    981983                                break;
    982984                        }
    983                         if (Renderer.zoom >= 15)
    984                                 addName(15, new Font("Arial", Font.BOLD, 40), new Delta(Handle.BL, AffineTransform.getTranslateInstance(60, -50)));
    985985                        Signals.addSignals();
     986            addName(15, new Font("Arial", Font.BOLD, 40), new Delta(Handle.BL, AffineTransform.getTranslateInstance(60, -50)));
    986987                }
    987988        }
  • applications/editors/josm/plugins/seachart/src/render/Signals.java

    r34652 r34896  
    377377        }
    378378
    379         @SuppressWarnings("unchecked")
    380         public static void lights() {
    381                 Enum<ColCOL> col = null;
    382                 Enum<ColCOL> tcol = null;
    383                 ObjTab lights = feature.objs.get(Obj.LIGHTS);
    384                 for (AttMap atts : lights.values()) {
    385                         if (atts.containsKey(Att.COLOUR)) {
    386                                 ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val;
    387                                 if (cols.size() == 1) {
    388                                         if (atts.containsKey(Att.CATLIT) && ((ArrayList<?>) atts.get(Att.CATLIT).val).contains(CatLIT.LIT_FLDL)) {
    389                                                 Renderer.symbol(Beacons.Floodlight, new Delta(Handle.CC, AffineTransform.getRotateInstance(Math.toRadians(90))));
    390                                         } else {
    391                                                 tcol = cols.get(0);
    392                                                 if (col == null) {
    393                                                         col = tcol;
    394                                                 } else if (tcol != col) {
    395                                                         col = ColCOL.COL_MAG;
    396                                                         break;
    397                                                 }
    398                                         }
    399                                 } else {
    400                                         col = ColCOL.COL_MAG;
    401                                         break;
    402                                 }
    403                         }
    404                 }
    405                 if (col != null) {
    406                         Renderer.symbol(Beacons.LightFlare, new Scheme(LightColours.get(col)),
    407                                         new Delta(Handle.BC, AffineTransform.getRotateInstance(Math.toRadians(120))));
    408                 }
    409                 if (Renderer.zoom >= 12) {
    410                         String str = "";
    411                         if (lights.get(1) != null) {
    412                                 for (AttMap atts : lights.values()) {
    413                                         Enum<ColCOL> col1 = null;
    414                                         Enum<ColCOL> col2 = null;
    415                                         double radius = 0.2;
    416                                         double s1 = 361;
    417                                         double s2 = 361;
    418                                         Double dir = null;
    419                                         if (atts.containsKey(Att.COLOUR)) {
    420                                                 ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val;
    421                                                 col1 = cols.get(0);
    422                                                 if (cols.size() > 1)
    423                                                         col2 = cols.get(1);
    424                                         } else {
    425                                                 continue;
    426                                         }
    427                                         if (atts.containsKey(Att.CATLIT)) {
    428                                                 ArrayList<CatLIT> cats = (ArrayList<CatLIT>) atts.get(Att.CATLIT).val;
    429                                                 if (cats.contains(CatLIT.LIT_DIR)) {
    430                                                         if (atts.containsKey(Att.ORIENT)) {
    431                                                                 dir = (Double) atts.get(Att.ORIENT).val;
    432                                                                 s1 = ((dir - 4) + 360) % 360;
    433                                                                 s2 = (dir + 4) % 360;
    434                                                                 for (AttMap satts : lights.values()) {
    435                                                                         double srad = 0.2;
    436                                                                         double ss1 = 361;
    437                                                                         double ss2 = 361;
    438                                                                         Double sdir = null;
    439                                                                         if (satts == atts)
    440                                                                                 continue;
    441                                                                         if (srad == radius) {
    442                                                                                 ArrayList<CatLIT> scats = (ArrayList<CatLIT>) (satts.containsKey(Att.CATLIT) ? (ArrayList<CatLIT>) satts.get(Att.CATLIT).val : new ArrayList<>());
    443                                                                                 if (scats.contains(CatLIT.LIT_DIR)) {
    444                                                                                         if (satts.containsKey(Att.ORIENT)) {
    445                                                                                                 sdir = (Double) satts.get(Att.ORIENT).val;
    446                                                                                                 ss1 = sdir;
    447                                                                                                 ss2 = sdir;
    448                                                                                         }
    449                                                                                 } else {
    450                                                                                         if (satts.containsKey(Att.SECTR1)) {
    451                                                                                                 ss1 = (Double) satts.get(Att.SECTR1).val;
    452                                                                                         }
    453                                                                                         if (satts.containsKey(Att.SECTR2)) {
    454                                                                                                 ss2 = (Double) satts.get(Att.SECTR2).val;
    455                                                                                         }
    456                                                                                 }
    457                                                                                 if ((ss1 > 360) || (ss2 > 360))
    458                                                                                         continue;
    459                                                                                 if (sdir != null) {
    460                                                                                         if (((dir - sdir + 360) % 360) < 8) {
    461                                                                                                 s1 = ((((sdir > dir) ? 360 : 0) + sdir + dir) / 2) % 360;
    462                                                                                         }
    463                                                                                         if (((sdir - dir + 360) % 360) < 8) {
    464                                                                                                 s2 = ((((dir > sdir) ? 360 : 0) + sdir + dir) / 2) % 360;
    465                                                                                         }
    466                                                                                 } else {
    467                                                                                         if (((dir - ss2 + 360) % 360) < 4) {
    468                                                                                                 s1 = ss2;
    469                                                                                         }
    470                                                                                         if (((ss1 - dir + 360) % 360) < 4) {
    471                                                                                                 s2 = ss1;
    472                                                                                         }
    473                                                                                 }
    474                                                                         }
    475                                                                 }
    476                                                         }
    477                                                 }
    478                                         }
    479                                         if ((s1 > 360) && atts.containsKey(Att.SECTR1)) {
    480                                                 s1 = (Double) atts.get(Att.SECTR1).val;
    481                                         } else if (dir == null) {
    482                                                 continue;
    483                                         }
    484                                         if ((s2 > 360) && atts.containsKey(Att.SECTR2)) {
    485                                                 s2 = (Double) atts.get(Att.SECTR2).val;
    486                                         } else if (dir == null) {
    487                                                 continue;
    488                                         }
    489                                         str = "";
    490                                         if (atts.containsKey(Att.LITCHR)) {
    491                                                 str += LightCharacters.get(((ArrayList<LitCHR>) atts.get(Att.LITCHR).val).get(0));
    492                                         }
    493                                         if (atts.containsKey(Att.SIGGRP)) {
    494                                                 str += "(" + atts.get(Att.SIGGRP).val + ")";
    495                                         } else if (!str.isEmpty()) {
    496                                                 str += ".";
    497                                         }
    498                                         if (atts.containsKey(Att.COLOUR)) {
    499                                                 ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val;
    500                                                 str += LightLetters.get(cols.get(0));
    501                                                 if (cols.size() > 1)
    502                                                         str += LightLetters.get(cols.get(1));
    503                                         }
    504                                         if (atts.containsKey(Att.SIGPER)) {
    505                                                 str += "." + df.format(atts.get(Att.SIGPER).val) + "s";
    506                                         }
    507                                         if ((s1 <= 360) && (s2 <= 360) && (s1 != s2))
    508                                                 Renderer.lightSector(LightColours.get(col1), LightColours.get(col2), radius, s1, s2, dir, (Renderer.zoom >= 15) ? str : "");
    509                                 }
    510                                 if (Renderer.zoom >= 15) {
    511                                         class LitSect {
    512                                                 boolean dir;
    513                                                 LitCHR chr;
    514                                                 ColCOL col;
    515                                                 String grp;
    516                                                 double per;
    517                                                 double rng;
    518                                                 double hgt;
    519                                         }
    520 
    521                                         ArrayList<LitSect> litatts = new ArrayList<>();
    522                                         for (AttMap atts : lights.values()) {
    523                                                 LitSect sect = new LitSect();
    524                                                 sect.dir = (atts.containsKey(Att.CATLIT) && ((ArrayList<CatLIT>) atts.get(Att.CATLIT).val).contains(CatLIT.LIT_DIR));
    525                                                 sect.chr = atts.containsKey(Att.LITCHR) ? ((ArrayList<LitCHR>) atts.get(Att.LITCHR).val).get(0) : LitCHR.CHR_UNKN;
    526                                                 switch (sect.chr) {
    527                                                 case CHR_AL:
    528                                                         sect.chr = LitCHR.CHR_F;
    529                                                         break;
    530                                                 case CHR_ALOC:
    531                                                         sect.chr = LitCHR.CHR_OC;
    532                                                         break;
    533                                                 case CHR_ALLFL:
    534                                                         sect.chr = LitCHR.CHR_LFL;
    535                                                         break;
    536                                                 case CHR_ALFL:
    537                                                         sect.chr = LitCHR.CHR_FL;
    538                                                         break;
    539                                                 case CHR_ALFFL:
    540                                                         sect.chr = LitCHR.CHR_FFL;
    541                                                         break;
    542                                                 default:
    543                                                         break;
    544                                                 }
    545                                                 sect.grp = atts.containsKey(Att.SIGGRP) ? (String) atts.get(Att.SIGGRP).val : "";
    546                                                 sect.per = atts.containsKey(Att.SIGPER) ? (Double) atts.get(Att.SIGPER).val : 0.0;
    547                                                 sect.rng = atts.containsKey(Att.VALNMR) ? (Double) atts.get(Att.VALNMR).val : 0.0;
    548                                                 sect.hgt = atts.containsKey(Att.HEIGHT) ? (Double) atts.get(Att.HEIGHT).val : 0.0;
    549                                                 ArrayList<ColCOL> cols = (ArrayList<ColCOL>) (atts.containsKey(Att.COLOUR) ? atts.get(Att.COLOUR).val : new ArrayList<>());
    550                                                 sect.col = cols.size() > 0 ? cols.get(0) : ColCOL.COL_UNK;
    551                                                 if ((sect.chr != LitCHR.CHR_UNKN) && (sect.col != null))
    552                                                         litatts.add(sect);
    553                                         }
    554                                         ArrayList<ArrayList<LitSect>> groupings = new ArrayList<>();
    555                                         for (LitSect lit : litatts) {
    556                                                 boolean found = false;
    557                                                 for (ArrayList<LitSect> group : groupings) {
    558                                                         LitSect mem = group.get(0);
    559                                                         if (lit.dir == mem.dir && lit.chr == mem.chr && lit.grp.equals(mem.grp) && lit.per == mem.per && lit.hgt == mem.hgt) {
    560                                                                 group.add(lit);
    561                                                                 found = true;
    562                                                         }
    563                                                 }
    564                                                 if (!found) {
    565                                                         ArrayList<LitSect> tmp = new ArrayList<>();
    566                                                         tmp.add(lit);
    567                                                         groupings.add(tmp);
    568                                                 }
    569                                         }
    570                                         for (boolean moved = true; moved;) {
    571                                                 moved = false;
    572                                                 for (int i = 0; i < groupings.size() - 1; i++) {
    573                                                         if (groupings.get(i).size() < groupings.get(i + 1).size()) {
    574                                                                 ArrayList<LitSect> tmp = groupings.remove(i);
    575                                                                 groupings.add(i + 1, tmp);
    576                                                                 moved = true;
    577                                                         }
    578                                                 }
    579                                         }
    580                                         class ColRng {
    581                                                 ColCOL col;
    582                                                 double rng;
    583 
    584                                                 ColRng(ColCOL c, double r) {
    585                                                         col = c;
    586                                                         rng = r;
    587                                                 }
    588                                         }
    589 
    590                                         int y = -30;
    591                                         for (ArrayList<LitSect> group : groupings) {
    592                                                 ArrayList<ColRng> colrng = new ArrayList<>();
    593                                                 for (LitSect lit : group) {
    594                                                         boolean found = false;
    595                                                         for (ColRng cr : colrng) {
    596                                                                 if (cr.col == lit.col) {
    597                                                                         if (lit.rng > cr.rng) {
    598                                                                                 cr.rng = lit.rng;
    599                                                                         }
    600                                                                         found = true;
    601                                                                 }
    602                                                         }
    603                                                         if (!found) {
    604                                                                 colrng.add(new ColRng(lit.col, lit.rng));
    605                                                         }
    606                                                 }
    607                                                 for (boolean moved = true; moved;) {
    608                                                         moved = false;
    609                                                         for (int i = 0; i < colrng.size() - 1; i++) {
    610                                                                 if (colrng.get(i).rng < colrng.get(i + 1).rng) {
    611                                                                         ColRng tmp = colrng.remove(i);
    612                                                                         colrng.add(i + 1, tmp);
    613                                                                         moved = true;
    614                                                                 }
    615                                                         }
    616                                                 }
    617                                                 LitSect tmp = group.get(0);
    618                                                 str = tmp.dir ? "Dir" : "";
    619                                                 str += LightCharacters.get(tmp.chr);
    620                                                 if (!tmp.grp.isEmpty())
    621                                                         str += "(" + tmp.grp + ")";
    622                                                 else
    623                                                         str += ".";
    624                                                 for (ColRng cr : colrng) {
    625                                                         str += LightLetters.get(cr.col);
    626                                                 }
    627                                                 if ((tmp.per > 0) || (tmp.hgt > 0) || (colrng.get(0).rng > 0))
    628                                                         str += ".";
    629                                                 if (tmp.per > 0)
    630                                                         str += df.format(tmp.per) + "s";
    631                                                 if (tmp.hgt > 0)
    632                                                         str += df.format(tmp.hgt) + "m";
    633                                                 if (colrng.get(0).rng > 0)
    634                                                         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";
    635                                                 Renderer.labelText(str, new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.TL, AffineTransform.getTranslateInstance(60, y)));
    636                                                 y += 40;
    637                                                 str = "";
    638                                         }
    639                                 }
    640                         } else {
    641                                 if (Renderer.zoom >= 15) {
    642                                         AttMap atts = lights.get(0);
    643                                         ArrayList<CatLIT> cats = new ArrayList<>();
    644                                         if (atts.containsKey(Att.CATLIT)) {
    645                                                 cats = (ArrayList<CatLIT>) atts.get(Att.CATLIT).val;
    646                                         }
    647                                         str = cats.contains(CatLIT.LIT_DIR) ? "Dir" : "";
    648                                         str += atts.containsKey(Att.MLTYLT) ? atts.get(Att.MLTYLT).val : "";
    649                                         if (atts.containsKey(Att.LITCHR)) {
    650                                                 LitCHR chr = ((ArrayList<LitCHR>) atts.get(Att.LITCHR).val).get(0);
    651                                                 if (atts.containsKey(Att.SIGGRP)) {
    652                                                         String grp = (String) atts.get(Att.SIGGRP).val;
    653                                                         switch (chr) {
    654                                                         case CHR_QLFL:
    655                                                                 str += String.format("Q(%s)+LFl", grp);
    656                                                                 break;
    657                                                         case CHR_VQLFL:
    658                                                                 str += String.format("VQ(%s)+LFl", grp);
    659                                                                 break;
    660                                                         case CHR_UQLFL:
    661                                                                 str += String.format("UQ(%s)+LFl", grp);
    662                                                                 break;
    663                                                         default:
    664                                                                 str += String.format("%s(%s)", LightCharacters.get(chr), grp);
    665                                                                 break;
    666                                                         }
    667                                                 } else {
    668                                                         str += LightCharacters.get(chr);
    669                                                 }
    670                                         }
    671                                         if (atts.containsKey(Att.COLOUR)) {
    672                                                 ArrayList<ColCOL> cols = (ArrayList<ColCOL>) atts.get(Att.COLOUR).val;
    673                                                 if (!((cols.size() == 1) && (cols.get(0) == ColCOL.COL_WHT))) {
    674                                                         if (!str.isEmpty() && !str.endsWith(")")) {
    675                                                                 str += ".";
    676                                                         }
    677                                                         for (ColCOL acol : cols) {
    678                                                                 str += LightLetters.get(acol);
    679                                                         }
    680                                                 }
    681                                         }
    682                                         str += cats.contains(CatLIT.LIT_VERT) ? "(vert)" : "";
    683                                         str += cats.contains(CatLIT.LIT_HORI) ? "(hor)" : "";
    684                                         str += (!str.isEmpty() && (atts.containsKey(Att.SIGPER) || atts.containsKey(Att.HEIGHT) || atts.containsKey(Att.VALMXR)) && !str.endsWith(")")) ? "." : "";
    685                                         str += atts.containsKey(Att.SIGPER) ? df.format(atts.get(Att.SIGPER).val) + "s" : "";
    686                                         str += atts.containsKey(Att.HEIGHT) ? df.format(atts.get(Att.HEIGHT).val) + "m" : "";
    687                                         str += atts.containsKey(Att.VALNMR) ? df.format(atts.get(Att.VALNMR).val) + "M" : "";
    688                                         str += cats.contains(CatLIT.LIT_FRNT) ? "(Front)" : "";
    689                                         str += cats.contains(CatLIT.LIT_REAR) ? "(Rear)" : "";
    690                                         str += cats.contains(CatLIT.LIT_UPPR) ? "(Upper)" : "";
    691                                         str += cats.contains(CatLIT.LIT_LOWR) ? "(Lower)" : "";
    692                                         Renderer.labelText(str, new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.TL, AffineTransform.getTranslateInstance(60, -30)));
    693                                 }
    694                         }
    695                 }
    696         }
     379    @SuppressWarnings("unchecked")
     380    public static void lights() {
     381        Enum<ColCOL> col = null;
     382        Enum<ColCOL> tcol = null;
     383        ObjTab lights = feature.objs.get(Obj.LIGHTS);
     384        for (AttMap atts : lights.values()) {
     385            if (atts.containsKey(Att.COLOUR)) {
     386                ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val;
     387                if (cols.size() == 1) {
     388                    if (atts.containsKey(Att.CATLIT) && ((ArrayList<?>) atts.get(Att.CATLIT).val).contains(CatLIT.LIT_FLDL)) {
     389                        Renderer.symbol(Beacons.Floodlight, new Delta(Handle.CC, AffineTransform.getRotateInstance(Math.toRadians(90))));
     390                    } else {
     391                        tcol = cols.get(0);
     392                        if (col == null) {
     393                            col = tcol;
     394                        } else if (tcol != col) {
     395                            col = ColCOL.COL_MAG;
     396                            break;
     397                        }
     398                    }
     399                } else {
     400                    col = ColCOL.COL_MAG;
     401                    break;
     402                }
     403            }
     404        }
     405        if (col != null) {
     406            Renderer.symbol(Beacons.LightFlare, new Scheme(LightColours.get(col)), new Delta(Handle.BC, AffineTransform.getRotateInstance(Math.toRadians(120))));
     407        }
     408        String str = "";
     409        if (lights.get(1) != null) {
     410            for (AttMap atts : lights.values()) {
     411                Enum<ColCOL> col1 = null;
     412                Enum<ColCOL> col2 = null;
     413                double radius = 0.5;
     414                if (atts.containsKey(Att.VALNMR)) {
     415                    radius += Math.log10((Double) atts.get(Att.VALNMR).val) * 2.0;
     416                }
     417                radius /= Math.pow(Renderer.zoom, 4) / 5000;
     418                double s1 = 361;
     419                double s2 = 361;
     420                Double dir = null;
     421                if (atts.containsKey(Att.COLOUR)) {
     422                    ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val;
     423                    col1 = cols.get(0);
     424                    if (cols.size() > 1)
     425                        col2 = cols.get(1);
     426                } else {
     427                    continue;
     428                }
     429                if (atts.containsKey(Att.CATLIT)) {
     430                    ArrayList<CatLIT> cats = (ArrayList<CatLIT>) atts.get(Att.CATLIT).val;
     431                    if (cats.contains(CatLIT.LIT_DIR)) {
     432                        if (atts.containsKey(Att.ORIENT)) {
     433                            dir = (Double) atts.get(Att.ORIENT).val;
     434                            s1 = ((dir - 4) + 360) % 360;
     435                            s2 = (dir + 4) % 360;
     436                            for (AttMap satts : lights.values()) {
     437                                double ss1 = 361;
     438                                double ss2 = 361;
     439                                Double sdir = null;
     440                                if (satts == atts)
     441                                    continue;
     442                                ArrayList<CatLIT> scats = (ArrayList<CatLIT>) (satts.containsKey(Att.CATLIT) ? (ArrayList<CatLIT>) satts.get(Att.CATLIT).val : new ArrayList<>());
     443                                if (scats.contains(CatLIT.LIT_DIR)) {
     444                                    if (satts.containsKey(Att.ORIENT)) {
     445                                        sdir = (Double) satts.get(Att.ORIENT).val;
     446                                        ss1 = sdir;
     447                                        ss2 = sdir;
     448                                    }
     449                                } else {
     450                                    if (satts.containsKey(Att.SECTR1)) {
     451                                        ss1 = (Double) satts.get(Att.SECTR1).val;
     452                                    }
     453                                    if (satts.containsKey(Att.SECTR2)) {
     454                                        ss2 = (Double) satts.get(Att.SECTR2).val;
     455                                    }
     456                                }
     457                                if ((ss1 > 360) || (ss2 > 360))
     458                                    continue;
     459                                if (sdir != null) {
     460                                    if (((dir - sdir + 360) % 360) < 8) {
     461                                        s1 = ((((sdir > dir) ? 360 : 0) + sdir + dir) / 2) % 360;
     462                                    }
     463                                    if (((sdir - dir + 360) % 360) < 8) {
     464                                        s2 = ((((dir > sdir) ? 360 : 0) + sdir + dir) / 2) % 360;
     465                                    }
     466                                } else {
     467                                    if (((dir - ss2 + 360) % 360) < 4) {
     468                                        s1 = ss2;
     469                                    }
     470                                    if (((ss1 - dir + 360) % 360) < 4) {
     471                                        s2 = ss1;
     472                                    }
     473                                }
     474                            }
     475                        }
     476                    }
     477                }
     478                if ((s1 > 360) && atts.containsKey(Att.SECTR1)) {
     479                    s1 = (Double) atts.get(Att.SECTR1).val;
     480                } else if (dir == null) {
     481                    continue;
     482                }
     483                if ((s2 > 360) && atts.containsKey(Att.SECTR2)) {
     484                    s2 = (Double) atts.get(Att.SECTR2).val;
     485                } else if (dir == null) {
     486                    continue;
     487                }
     488                str = "";
     489                if (atts.containsKey(Att.LITCHR)) {
     490                    str += LightCharacters.get(((ArrayList<LitCHR>) atts.get(Att.LITCHR).val).get(0));
     491                }
     492                if (atts.containsKey(Att.SIGGRP)) {
     493                    str += "(" + atts.get(Att.SIGGRP).val + ")";
     494                } else if (!str.isEmpty()) {
     495                    str += ".";
     496                }
     497                if (atts.containsKey(Att.COLOUR)) {
     498                    ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val;
     499                    str += LightLetters.get(cols.get(0));
     500                    if (cols.size() > 1)
     501                        str += LightLetters.get(cols.get(1));
     502                }
     503                if (atts.containsKey(Att.SIGPER)) {
     504                    str += "." + df.format(atts.get(Att.SIGPER).val) + "s";
     505                }
     506                if ((s1 <= 360) && (s2 <= 360) && (s1 != s2))
     507                    Renderer.lightSector(LightColours.get(col1), LightColours.get(col2), radius, s1, s2, dir, (Renderer.zoom >= 15) ? str : "");
     508            }
     509            if (Renderer.zoom >= 15) {
     510                class LitSect {
     511                    boolean dir;
     512                    LitCHR chr;
     513                    ColCOL col;
     514                    String grp;
     515                    double per;
     516                    double rng;
     517                    double hgt;
     518                }
     519
     520                ArrayList<LitSect> litatts = new ArrayList<>();
     521                for (AttMap atts : lights.values()) {
     522                    LitSect sect = new LitSect();
     523                    sect.dir = (atts.containsKey(Att.CATLIT) && ((ArrayList<CatLIT>) atts.get(Att.CATLIT).val).contains(CatLIT.LIT_DIR));
     524                    sect.chr = atts.containsKey(Att.LITCHR) ? ((ArrayList<LitCHR>) atts.get(Att.LITCHR).val).get(0) : LitCHR.CHR_UNKN;
     525                    switch (sect.chr) {
     526                    case CHR_AL:
     527                        sect.chr = LitCHR.CHR_F;
     528                        break;
     529                    case CHR_ALOC:
     530                        sect.chr = LitCHR.CHR_OC;
     531                        break;
     532                    case CHR_ALLFL:
     533                        sect.chr = LitCHR.CHR_LFL;
     534                        break;
     535                    case CHR_ALFL:
     536                        sect.chr = LitCHR.CHR_FL;
     537                        break;
     538                    case CHR_ALFFL:
     539                        sect.chr = LitCHR.CHR_FFL;
     540                        break;
     541                    default:
     542                        break;
     543                    }
     544                    sect.grp = atts.containsKey(Att.SIGGRP) ? (String) atts.get(Att.SIGGRP).val : "";
     545                    sect.per = atts.containsKey(Att.SIGPER) ? (Double) atts.get(Att.SIGPER).val : 0.0;
     546                    sect.rng = atts.containsKey(Att.VALNMR) ? (Double) atts.get(Att.VALNMR).val : 0.0;
     547                    sect.hgt = atts.containsKey(Att.HEIGHT) ? (Double) atts.get(Att.HEIGHT).val : 0.0;
     548                    ArrayList<ColCOL> cols = (ArrayList<ColCOL>) (atts.containsKey(Att.COLOUR) ? atts.get(Att.COLOUR).val : new ArrayList<>());
     549                    sect.col = cols.size() > 0 ? cols.get(0) : ColCOL.COL_UNK;
     550                    if ((sect.chr != LitCHR.CHR_UNKN) && (sect.col != null))
     551                        litatts.add(sect);
     552                }
     553                ArrayList<ArrayList<LitSect>> groupings = new ArrayList<>();
     554                for (LitSect lit : litatts) {
     555                    boolean found = false;
     556                    for (ArrayList<LitSect> group : groupings) {
     557                        LitSect mem = group.get(0);
     558                        if (lit.dir == mem.dir && lit.chr == mem.chr && lit.grp.equals(mem.grp) && lit.per == mem.per && lit.hgt == mem.hgt) {
     559                            group.add(lit);
     560                            found = true;
     561                        }
     562                    }
     563                    if (!found) {
     564                        ArrayList<LitSect> tmp = new ArrayList<>();
     565                        tmp.add(lit);
     566                        groupings.add(tmp);
     567                    }
     568                }
     569                for (boolean moved = true; moved;) {
     570                    moved = false;
     571                    for (int i = 0; i < groupings.size() - 1; i++) {
     572                        if (groupings.get(i).size() < groupings.get(i + 1).size()) {
     573                            ArrayList<LitSect> tmp = groupings.remove(i);
     574                            groupings.add(i + 1, tmp);
     575                            moved = true;
     576                        }
     577                    }
     578                }
     579                class ColRng {
     580                    ColCOL col;
     581                    double rng;
     582
     583                    ColRng(ColCOL c, double r) {
     584                        col = c;
     585                        rng = r;
     586                    }
     587                }
     588
     589                int y = -30;
     590                for (ArrayList<LitSect> group : groupings) {
     591                    ArrayList<ColRng> colrng = new ArrayList<>();
     592                    for (LitSect lit : group) {
     593                        boolean found = false;
     594                        for (ColRng cr : colrng) {
     595                            if (cr.col == lit.col) {
     596                                if (lit.rng > cr.rng) {
     597                                    cr.rng = lit.rng;
     598                                }
     599                                found = true;
     600                            }
     601                        }
     602                        if (!found) {
     603                            colrng.add(new ColRng(lit.col, lit.rng));
     604                        }
     605                    }
     606                    for (boolean moved = true; moved;) {
     607                        moved = false;
     608                        for (int i = 0; i < colrng.size() - 1; i++) {
     609                            if (colrng.get(i).rng < colrng.get(i + 1).rng) {
     610                                ColRng tmp = colrng.remove(i);
     611                                colrng.add(i + 1, tmp);
     612                                moved = true;
     613                            }
     614                        }
     615                    }
     616                    LitSect tmp = group.get(0);
     617                    str = tmp.dir ? "Dir" : "";
     618                    str += LightCharacters.get(tmp.chr);
     619                    if (!tmp.grp.isEmpty())
     620                        str += "(" + tmp.grp + ")";
     621                    else
     622                        str += ".";
     623                    for (ColRng cr : colrng) {
     624                        str += LightLetters.get(cr.col);
     625                    }
     626                    if ((tmp.per > 0) || (tmp.hgt > 0) || (colrng.get(0).rng > 0))
     627                        str += ".";
     628                    if (tmp.per > 0)
     629                        str += df.format(tmp.per) + "s";
     630                    if (tmp.hgt > 0)
     631                        str += df.format(tmp.hgt) + "m";
     632                    if (colrng.get(0).rng > 0)
     633                        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";
     634                    Renderer.labelText(str, new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.TL, AffineTransform.getTranslateInstance(60, y)));
     635                    y += 40;
     636                    str = "";
     637                }
     638            }
     639        } else {
     640            if (Renderer.zoom >= 15) {
     641                AttMap atts = lights.get(0);
     642                ArrayList<CatLIT> cats = new ArrayList<>();
     643                if (atts.containsKey(Att.CATLIT)) {
     644                    cats = (ArrayList<CatLIT>) atts.get(Att.CATLIT).val;
     645                }
     646                str = cats.contains(CatLIT.LIT_DIR) ? "Dir" : "";
     647                str += atts.containsKey(Att.MLTYLT) ? atts.get(Att.MLTYLT).val : "";
     648                if (atts.containsKey(Att.LITCHR)) {
     649                    LitCHR chr = ((ArrayList<LitCHR>) atts.get(Att.LITCHR).val).get(0);
     650                    if (atts.containsKey(Att.SIGGRP)) {
     651                        String grp = (String) atts.get(Att.SIGGRP).val;
     652                        switch (chr) {
     653                        case CHR_QLFL:
     654                            str += String.format("Q(%s)+LFl", grp);
     655                            break;
     656                        case CHR_VQLFL:
     657                            str += String.format("VQ(%s)+LFl", grp);
     658                            break;
     659                        case CHR_UQLFL:
     660                            str += String.format("UQ(%s)+LFl", grp);
     661                            break;
     662                        default:
     663                            str += String.format("%s(%s)", LightCharacters.get(chr), grp);
     664                            break;
     665                        }
     666                    } else {
     667                        str += LightCharacters.get(chr);
     668                    }
     669                }
     670                if (atts.containsKey(Att.COLOUR)) {
     671                    ArrayList<ColCOL> cols = (ArrayList<ColCOL>) atts.get(Att.COLOUR).val;
     672                    if (!((cols.size() == 1) && (cols.get(0) == ColCOL.COL_WHT))) {
     673                        if (!str.isEmpty() && !str.endsWith(")")) {
     674                            str += ".";
     675                        }
     676                        for (ColCOL acol : cols) {
     677                            str += LightLetters.get(acol);
     678                        }
     679                    }
     680                }
     681                str += cats.contains(CatLIT.LIT_VERT) ? "(vert)" : "";
     682                str += cats.contains(CatLIT.LIT_HORI) ? "(hor)" : "";
     683                str += (!str.isEmpty() && (atts.containsKey(Att.SIGPER) || atts.containsKey(Att.HEIGHT) || atts.containsKey(Att.VALMXR)) && !str.endsWith(")")) ? "." : "";
     684                str += atts.containsKey(Att.SIGPER) ? df.format(atts.get(Att.SIGPER).val) + "s" : "";
     685                str += atts.containsKey(Att.HEIGHT) ? df.format(atts.get(Att.HEIGHT).val) + "m" : "";
     686                str += atts.containsKey(Att.VALNMR) ? df.format(atts.get(Att.VALNMR).val) + "M" : "";
     687                str += cats.contains(CatLIT.LIT_FRNT) ? "(Front)" : "";
     688                str += cats.contains(CatLIT.LIT_REAR) ? "(Rear)" : "";
     689                str += cats.contains(CatLIT.LIT_UPPR) ? "(Upper)" : "";
     690                str += cats.contains(CatLIT.LIT_LOWR) ? "(Lower)" : "";
     691                Renderer.labelText(str, new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.TL, AffineTransform.getTranslateInstance(60, -30)));
     692            }
     693        }
     694    }
    697695}
    698 
Note: See TracChangeset for help on using the changeset viewer.