Ignore:
Timestamp:
2014-01-19T14:52:39+01:00 (11 years ago)
Author:
malcolmh
Message:

new model structure

File:
1 edited

Legend:

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

    r30190 r30215  
    1919import s57.S57map;
    2020import s57.S57map.*;
    21 import s57.S57map.Area;
    2221import symbols.Areas;
    2322import symbols.Symbols;
     
    102101                if (symbols.size() > 4) {
    103102                        for (Instr instr : symbols.get(0)) {
    104                                 if (instr.type == Prim.BBOX) {
     103                                if (instr.type == Form.BBOX) {
    105104                                        bbox = (Rectangle2D.Double) instr.params;
    106105                                        break;
     
    180179                while (ssymb != null) {
    181180                        for (Instr item : symbol) {
    182                                 if (item.type == Prim.BBOX) {
     181                                if (item.type == Form.BBOX) {
    183182                                        return (Rectangle2D.Double) item.params;
    184183                                }
    185                                 if (item.type == Prim.SYMB) {
     184                                if (item.type == Form.SYMB) {
    186185                                        ssymb = ((SubSymbol) item.params).instr;
    187186                                        break;
     
    195194
    196195        public static void lineSymbols(Feature feature, Symbol prisymb, double space, Symbol secsymb, Symbol tersymb, int ratio, Color col) {
    197                 Area area;
    198                 switch (feature.flag) {
    199                 case LINE:
    200                         Edge edge = map.edges.get(feature.refs);
    201                         area = map.new Area();
    202                         area.add(map.new Bound(map.new Side(edge, true), true));
    203                         break;
    204                 case AREA:
    205                         area = map.areas.get(feature.refs);
    206                         break;
    207                 default:
     196                if ((feature.geom.prim == Pflag.NOSP) || (feature.geom.prim == Pflag.POINT))
    208197                        return;
    209                 }
    210198                Rectangle2D.Double prect = symbolSize(prisymb);
    211199                Rectangle2D.Double srect = symbolSize(secsymb);
     
    228216                        boolean stflag = false;
    229217                        Symbol symbol = prisymb;
    230                         for (Bound bound : area) {
    231                                 BoundIterator bit = map.new BoundIterator(bound);
     218                        GeomIterator git = map.new GeomIterator(feature.geom);
     219                        while (git.hasMore()) {
     220                                git.more();
    232221                                boolean first = true;
    233                                 while (bit.hasNext()) {
     222                                while (git.hasNext()) {
    234223                                        prev = next;
    235                                         next = context.getPoint(bit.next());
     224                                        next = context.getPoint(git.next());
    236225                                        angle = Math.atan2(next.getY() - prev.getY(), next.getX() - prev.getX());
    237226                                        piv = true;
     
    286275                p.setWindingRule(GeneralPath.WIND_EVEN_ODD);
    287276                Point2D point;
    288                 switch (feature.flag) {
    289                 case LINE:
    290                         EdgeIterator eit = map.new EdgeIterator(map.edges.get(feature.refs), true);
    291                         point = context.getPoint(eit.next());
     277                GeomIterator git = map.new GeomIterator(feature.geom);
     278                while (git.hasMore()) {
     279                        git.more();
     280                        point = context.getPoint(git.next());
    292281                        p.moveTo(point.getX(), point.getY());
    293                         while (eit.hasNext()) {
    294                                 point = context.getPoint(eit.next());
     282                        while (git.hasNext()) {
     283                                point = context.getPoint(git.next());
    295284                                p.lineTo(point.getX(), point.getY());
    296285                        }
    297                         break;
    298                 case AREA:
    299                         for (Bound bound : map.areas.get(feature.refs)) {
    300                                 BoundIterator bit = map.new BoundIterator(bound);
    301                                 point = context.getPoint(bit.next());
    302                                 p.moveTo(point.getX(), point.getY());
    303                                 while (bit.hasNext()) {
    304                                         point = context.getPoint(bit.next());
    305                                         p.lineTo(point.getX(), point.getY());
    306                                 }
    307                         }
    308                         break;
    309                 default:
    310                         break;
    311286                }
    312287                if (style.line != null) {
     
    353328                Symbol circle = new Symbol();
    354329                if (style.fill != null) {
    355                         circle.add(new Instr(Prim.FILL, style.fill));
    356                         circle.add(new Instr(Prim.RSHP, new Ellipse2D.Double(-radius,-radius,radius*2,radius*2)));
    357                 }
    358                 circle.add(new Instr(Prim.FILL, style.line));
    359                 circle.add(new Instr(Prim.STRK, new BasicStroke(style.width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, style.dash, 0)));
    360                 circle.add(new Instr(Prim.ELPS, new Ellipse2D.Double(-radius,-radius,radius*2,radius*2)));
     330                        circle.add(new Instr(Form.FILL, style.fill));
     331                        circle.add(new Instr(Form.RSHP, new Ellipse2D.Double(-radius,-radius,radius*2,radius*2)));
     332                }
     333                circle.add(new Instr(Form.FILL, style.line));
     334                circle.add(new Instr(Form.STRK, new BasicStroke(style.width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, style.dash, 0)));
     335                circle.add(new Instr(Form.ELPS, new Ellipse2D.Double(-radius,-radius,radius*2,radius*2)));
    361336                Point2D point = context.getPoint(feature.centre);
    362337                Symbols.drawSymbol(g2, circle, 1, point.getX(), point.getY(), null, null);
     
    368343                p.setWindingRule(GeneralPath.WIND_EVEN_ODD);
    369344                Point2D point;
    370                 switch (feature.flag) {
     345                switch (feature.geom.prim) {
    371346                case POINT:
    372347                        point = context.getPoint(feature.centre);
     
    375350                        break;
    376351                case AREA:
    377                         for (Bound bound : map.areas.get(feature.refs)) {
    378                                 BoundIterator bit = map.new BoundIterator(bound);
    379                                 point = context.getPoint(bit.next());
     352                        GeomIterator git = map.new GeomIterator(feature.geom);
     353                        while (git.hasMore()) {
     354                                git.more();
     355                                point = context.getPoint(git.next());
    380356                                p.moveTo(point.getX(), point.getY());
    381                                 while (bit.hasNext()) {
    382                                         point = context.getPoint(bit.next());
     357                                while (git.hasNext()) {
     358                                        point = context.getPoint(git.next());
    383359                                        p.lineTo(point.getX(), point.getY());
    384360                                }
     
    427403            tx = lx + (height * 0.34);
    428404            ty = ly + (height * 0.17);
    429                         label.add(new Instr(Prim.BBOX, new Rectangle2D.Double(lx,ly,width,height)));
    430                         label.add(new Instr(Prim.FILL, bg));
    431                         label.add(new Instr(Prim.RSHP, new RoundRectangle2D.Double(lx,ly,width,height,height,height)));
    432                         label.add(new Instr(Prim.FILL, fg));
    433                         label.add(new Instr(Prim.STRK, new BasicStroke(1 + (int)(height/10), BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER)));
    434                         label.add(new Instr(Prim.RRCT, new RoundRectangle2D.Double(lx,ly,width,height,height,height)));
     405                        label.add(new Instr(Form.BBOX, new Rectangle2D.Double(lx,ly,width,height)));
     406                        label.add(new Instr(Form.FILL, bg));
     407                        label.add(new Instr(Form.RSHP, new RoundRectangle2D.Double(lx,ly,width,height,height,height)));
     408                        label.add(new Instr(Form.FILL, fg));
     409                        label.add(new Instr(Form.STRK, new BasicStroke(1 + (int)(height/10), BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER)));
     410                        label.add(new Instr(Form.RRCT, new RoundRectangle2D.Double(lx,ly,width,height,height,height)));
    435411                        break;
    436412                case VCLR:
     
    442418            tx = lx + (height * 0.27);
    443419            ty = ly + (height * 0.25);
    444                         label.add(new Instr(Prim.BBOX, new Rectangle2D.Double(lx,ly,width,height)));
    445                         label.add(new Instr(Prim.FILL, bg));
    446                         label.add(new Instr(Prim.RSHP, new RoundRectangle2D.Double(lx,ly,width,height,height,height)));
    447                         label.add(new Instr(Prim.FILL, fg));
     420                        label.add(new Instr(Form.BBOX, new Rectangle2D.Double(lx,ly,width,height)));
     421                        label.add(new Instr(Form.FILL, bg));
     422                        label.add(new Instr(Form.RSHP, new RoundRectangle2D.Double(lx,ly,width,height,height,height)));
     423                        label.add(new Instr(Form.FILL, fg));
    448424                        int sw = 1 + (int)(height/10);
    449425                        double po = sw / 2;
    450                         label.add(new Instr(Prim.STRK, new BasicStroke(sw, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER)));
     426                        label.add(new Instr(Form.STRK, new BasicStroke(sw, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER)));
    451427                        Path2D.Double p = new Path2D.Double(); p.moveTo(-height*0.2,-ly-po); p.lineTo(height*0.2,-ly-po); p.moveTo(0,-ly-po); p.lineTo(0,-ly-po-(height*0.15));
    452428                        p.moveTo(-height*0.2,ly+po); p.lineTo((height*0.2),ly+po); p.moveTo(0,ly+po); p.lineTo(0,ly+po+(height*0.15));
    453                         label.add(new Instr(Prim.PLIN, p));
     429                        label.add(new Instr(Form.PLIN, p));
    454430                        break;
    455431                case PCLR:
     
    461437            tx = lx + (height * 0.27);
    462438            ty = ly + (height * 0.25);
    463                         label.add(new Instr(Prim.BBOX, new Rectangle2D.Double(lx,ly,width,height)));
    464                         label.add(new Instr(Prim.FILL, bg));
    465                         label.add(new Instr(Prim.RSHP, new RoundRectangle2D.Double(lx,ly,width,height,height,height)));
    466                         label.add(new Instr(Prim.FILL, fg));
     439                        label.add(new Instr(Form.BBOX, new Rectangle2D.Double(lx,ly,width,height)));
     440                        label.add(new Instr(Form.FILL, bg));
     441                        label.add(new Instr(Form.RSHP, new RoundRectangle2D.Double(lx,ly,width,height,height,height)));
     442                        label.add(new Instr(Form.FILL, fg));
    467443                        sw = 1 + (int)(height/10);
    468444                        po = sw / 2;
    469                         label.add(new Instr(Prim.STRK, new BasicStroke(sw, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER)));
     445                        label.add(new Instr(Form.STRK, new BasicStroke(sw, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER)));
    470446                        p = new Path2D.Double(); p.moveTo(-height*0.2,-ly-po); p.lineTo(height*0.2,-ly-po); p.moveTo(0,-ly-po); p.lineTo(0,-ly-po-(height*0.15));
    471447                        p.moveTo(-height*0.2,ly+po); p.lineTo((height*0.2),ly+po); p.moveTo(0,ly+po); p.lineTo(0,ly+po+(height*0.15));
    472                         label.add(new Instr(Prim.PLIN, p));
    473                         label.add(new Instr(Prim.SYMB, new Symbols.SubSymbol(Areas.CableFlash, 1, 0, 0, null, new Delta(Handle.CC, new AffineTransform(0,-1,1,0,-width/2,0)))));
    474                         label.add(new Instr(Prim.SYMB, new Symbols.SubSymbol(Areas.CableFlash, 1, 0, 0, null, new Delta(Handle.CC, new AffineTransform(0,-1,1,0,width/2,0)))));
     448                        label.add(new Instr(Form.PLIN, p));
     449                        label.add(new Instr(Form.SYMB, new Symbols.SubSymbol(Areas.CableFlash, 1, 0, 0, null, new Delta(Handle.CC, new AffineTransform(0,-1,1,0,-width/2,0)))));
     450                        label.add(new Instr(Form.SYMB, new Symbols.SubSymbol(Areas.CableFlash, 1, 0, 0, null, new Delta(Handle.CC, new AffineTransform(0,-1,1,0,width/2,0)))));
    475451                        break;
    476452                case HCLR:
     
    482458            tx = lx + (height * 0.5);
    483459            ty = ly + (height * 0.17);
    484                         label.add(new Instr(Prim.BBOX, new Rectangle2D.Double(lx,ly,width,height)));
    485                         label.add(new Instr(Prim.FILL, bg));
    486                         label.add(new Instr(Prim.RSHP, new RoundRectangle2D.Double(lx,ly,width,height,height,height)));
    487                         label.add(new Instr(Prim.FILL, fg));
     460                        label.add(new Instr(Form.BBOX, new Rectangle2D.Double(lx,ly,width,height)));
     461                        label.add(new Instr(Form.FILL, bg));
     462                        label.add(new Instr(Form.RSHP, new RoundRectangle2D.Double(lx,ly,width,height,height,height)));
     463                        label.add(new Instr(Form.FILL, fg));
    488464                        sw = 1 + (int)(height/10);
    489465                        double vo = height / 4;
    490                         label.add(new Instr(Prim.STRK, new BasicStroke(sw, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER)));
     466                        label.add(new Instr(Form.STRK, new BasicStroke(sw, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER)));
    491467                        p = new Path2D.Double(); p.moveTo(-width*0.4-sw,-ly-vo); p.lineTo(-width*0.4-sw,ly+vo); p.moveTo(-width*0.4-sw,0); p.lineTo(-width*0.4+sw,0);
    492468                        p.moveTo(width*0.4+sw,-ly-vo); p.lineTo(width*0.4+sw,ly+vo); p.moveTo(width*0.4-sw,0); p.lineTo(width*0.4+sw,0);
    493                         label.add(new Instr(Prim.PLIN, p));
     469                        label.add(new Instr(Form.PLIN, p));
    494470                        break;
    495471                default:
     
    498474                        tx = lx;
    499475                        ty = ly;
    500                         label.add(new Instr(Prim.BBOX, new Rectangle2D.Double(lx,ly,width,height)));
    501                         break;
    502                 }
    503                 label.add(new Instr(Prim.TEXT, new Caption(str, font, tc, new Delta(Handle.TL, AffineTransform.getTranslateInstance(tx, ty)))));
     476                        label.add(new Instr(Form.BBOX, new Rectangle2D.Double(lx,ly,width,height)));
     477                        break;
     478                }
     479                label.add(new Instr(Form.TEXT, new Caption(str, font, tc, new Delta(Handle.TL, AffineTransform.getTranslateInstance(tx, ty)))));
    504480                Point2D point = context.getPoint(feature.centre);
    505481                Symbols.drawSymbol(g2, label, sScale, point.getX(), point.getY(), null, delta);
     
    507483
    508484        public static void lineText(Feature feature, String str, Font font, Color colour, double offset, double dy) {
    509                 Area area;
    510                 switch (feature.flag) {
    511                 case LINE:
    512                         Edge edge = map.edges.get(feature.refs);
    513                         area = map.new Area();
    514                         area.add(map.new Bound(map.new Side(edge, true), true));
    515                         break;
    516                 case AREA:
    517                         area = map.areas.get(feature.refs);
    518                         break;
    519                 default:
    520                         return;
    521                 }
    522485//              Rectangle prect = symbolSize(prisymb);
    523486                if (!str.isEmpty()) {
     
    533496                        double len = 0;
    534497                        double angle = 0;
    535                         for (Bound bound : area) {
    536                                 BoundIterator bit = map.new BoundIterator(bound);
     498                        GeomIterator git = map.new GeomIterator(feature.geom);
     499                        while (git.hasMore()) {
     500                                git.more();
    537501                                boolean first = true;
    538                                 while (bit.hasNext()) {
     502                                while (git.hasNext()) {
    539503                                        prev = next;
    540                                         next = context.getPoint(bit.next());
     504                                        next = context.getPoint(git.next());
    541505                                        angle = Math.atan2(next.getY() - prev.getY(), next.getX() - prev.getX());
    542506                                        piv = true;
Note: See TracChangeset for help on using the changeset viewer.