Ignore:
Timestamp:
2016-03-03T08:32:31+01:00 (9 years ago)
Author:
malcolmh
Message:

add RADRFLs

File:
1 edited

Legend:

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

    r32088 r32090  
    5656        }
    5757
    58         public static void symbol(Feature feature, Symbol symbol) {
    59                 Point2D point = context.getPoint(feature.geom.centre);
     58        public static void symbol(Symbol symbol) {
     59                Point2D point = context.getPoint(Rules.feature.geom.centre);
    6060                Symbols.drawSymbol(g2, symbol, sScale, point.getX(), point.getY(), null, null);
    6161        }
    62         public static void symbol(Feature feature, Symbol symbol, Scheme scheme) {
    63                 Point2D point = context.getPoint(feature.geom.centre);
     62        public static void symbol(Symbol symbol, Scheme scheme) {
     63                Point2D point = context.getPoint(Rules.feature.geom.centre);
    6464                Symbols.drawSymbol(g2, symbol, sScale, point.getX(), point.getY(), scheme, null);
    6565        }
    66         public static void symbol(Feature feature, Symbol symbol, Delta delta) {
    67                 Point2D point = context.getPoint(feature.geom.centre);
     66        public static void symbol(Symbol symbol, Delta delta) {
     67                Point2D point = context.getPoint(Rules.feature.geom.centre);
    6868                Symbols.drawSymbol(g2, symbol, sScale, point.getX(), point.getY(), null, delta);
    6969        }
    70         public static void symbol(Feature feature, Symbol symbol, Scheme scheme, Delta delta) {
    71                 Point2D point = context.getPoint(feature.geom.centre);
     70        public static void symbol(Symbol symbol, Scheme scheme, Delta delta) {
     71                Point2D point = context.getPoint(Rules.feature.geom.centre);
    7272                Symbols.drawSymbol(g2, symbol, sScale, point.getX(), point.getY(), scheme, delta);
    7373        }
    7474       
    75         public static void cluster(Feature feature, ArrayList<Symbol> symbols) {
     75        public static void cluster(ArrayList<Symbol> symbols) {
    7676                Rectangle2D.Double bbox = null;
    7777                if (symbols.size() > 4) {
     
    8686                switch (symbols.size()) {
    8787                case 1:
    88                         symbol(feature, symbols.get(0), new Delta(Handle.CC, new AffineTransform()));
     88                        symbol(symbols.get(0), new Delta(Handle.CC, new AffineTransform()));
    8989                        break;
    9090                case 2:
    91                         symbol(feature, symbols.get(0), new Delta(Handle.RC, new AffineTransform()));
    92                         symbol(feature, symbols.get(1), new Delta(Handle.LC, new AffineTransform()));
     91                        symbol(symbols.get(0), new Delta(Handle.RC, new AffineTransform()));
     92                        symbol(symbols.get(1), new Delta(Handle.LC, new AffineTransform()));
    9393                        break;
    9494                case 3:
    95                         symbol(feature, symbols.get(0), new Delta(Handle.BC, new AffineTransform()));
    96                         symbol(feature, symbols.get(1), new Delta(Handle.TR, new AffineTransform()));
    97                         symbol(feature, symbols.get(2), new Delta(Handle.TL, new AffineTransform()));
     95                        symbol(symbols.get(0), new Delta(Handle.BC, new AffineTransform()));
     96                        symbol(symbols.get(1), new Delta(Handle.TR, new AffineTransform()));
     97                        symbol(symbols.get(2), new Delta(Handle.TL, new AffineTransform()));
    9898                        break;
    9999                case 4:
    100                         symbol(feature, symbols.get(0), new Delta(Handle.BR, new AffineTransform()));
    101                         symbol(feature, symbols.get(1), new Delta(Handle.BL, new AffineTransform()));
    102                         symbol(feature, symbols.get(2), new Delta(Handle.TR, new AffineTransform()));
    103                         symbol(feature, symbols.get(3), new Delta(Handle.TL, new AffineTransform()));
     100                        symbol(symbols.get(0), new Delta(Handle.BR, new AffineTransform()));
     101                        symbol(symbols.get(1), new Delta(Handle.BL, new AffineTransform()));
     102                        symbol(symbols.get(2), new Delta(Handle.TR, new AffineTransform()));
     103                        symbol(symbols.get(3), new Delta(Handle.TL, new AffineTransform()));
    104104                        break;
    105105                case 5:
    106                         symbol(feature, symbols.get(0), new Delta(Handle.BR, new AffineTransform()));
    107                         symbol(feature, symbols.get(1), new Delta(Handle.BL, new AffineTransform()));
    108                         symbol(feature, symbols.get(2), new Delta(Handle.TR, AffineTransform.getTranslateInstance(-bbox.width/2, 0)));
    109                         symbol(feature, symbols.get(3), new Delta(Handle.TC, new AffineTransform()));
    110                         symbol(feature, symbols.get(4), new Delta(Handle.TL, AffineTransform.getTranslateInstance(bbox.width/2, 0)));
     106                        symbol(symbols.get(0), new Delta(Handle.BR, new AffineTransform()));
     107                        symbol(symbols.get(1), new Delta(Handle.BL, new AffineTransform()));
     108                        symbol(symbols.get(2), new Delta(Handle.TR, AffineTransform.getTranslateInstance(-bbox.width/2, 0)));
     109                        symbol(symbols.get(3), new Delta(Handle.TC, new AffineTransform()));
     110                        symbol(symbols.get(4), new Delta(Handle.TL, AffineTransform.getTranslateInstance(bbox.width/2, 0)));
    111111                        break;
    112112                case 6:
    113                         symbol(feature, symbols.get(0), new Delta(Handle.BR, AffineTransform.getTranslateInstance(-bbox.width/2, 0)));
    114                         symbol(feature, symbols.get(1), new Delta(Handle.BC, new AffineTransform()));
    115                         symbol(feature, symbols.get(2), new Delta(Handle.BL, AffineTransform.getTranslateInstance(bbox.width/2, 0)));
    116                         symbol(feature, symbols.get(3), new Delta(Handle.TR, AffineTransform.getTranslateInstance(-bbox.width/2, 0)));
    117                         symbol(feature, symbols.get(4), new Delta(Handle.TC, new AffineTransform()));
    118                         symbol(feature, symbols.get(5), new Delta(Handle.TL, AffineTransform.getTranslateInstance(bbox.width/2, 0)));
     113                        symbol(symbols.get(0), new Delta(Handle.BR, AffineTransform.getTranslateInstance(-bbox.width/2, 0)));
     114                        symbol(symbols.get(1), new Delta(Handle.BC, new AffineTransform()));
     115                        symbol(symbols.get(2), new Delta(Handle.BL, AffineTransform.getTranslateInstance(bbox.width/2, 0)));
     116                        symbol(symbols.get(3), new Delta(Handle.TR, AffineTransform.getTranslateInstance(-bbox.width/2, 0)));
     117                        symbol(symbols.get(4), new Delta(Handle.TC, new AffineTransform()));
     118                        symbol(symbols.get(5), new Delta(Handle.TL, AffineTransform.getTranslateInstance(bbox.width/2, 0)));
    119119                        break;
    120120                case 7:
    121                         symbol(feature, symbols.get(0), new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -bbox.height/2)));
    122                         symbol(feature, symbols.get(1), new Delta(Handle.RC, AffineTransform.getTranslateInstance(-bbox.width/2, 0)));
    123                         symbol(feature, symbols.get(2), new Delta(Handle.CC, new AffineTransform()));
    124                         symbol(feature, symbols.get(3), new Delta(Handle.LC, AffineTransform.getTranslateInstance(bbox.width/2, 0)));
    125                         symbol(feature, symbols.get(4), new Delta(Handle.TR, AffineTransform.getTranslateInstance(-bbox.width/2, bbox.height/2)));
    126                         symbol(feature, symbols.get(5), new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, bbox.height/2)));
    127                         symbol(feature, symbols.get(6), new Delta(Handle.TL, AffineTransform.getTranslateInstance(bbox.width/2, bbox.height/2)));
     121                        symbol(symbols.get(0), new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -bbox.height/2)));
     122                        symbol(symbols.get(1), new Delta(Handle.RC, AffineTransform.getTranslateInstance(-bbox.width/2, 0)));
     123                        symbol(symbols.get(2), new Delta(Handle.CC, new AffineTransform()));
     124                        symbol(symbols.get(3), new Delta(Handle.LC, AffineTransform.getTranslateInstance(bbox.width/2, 0)));
     125                        symbol(symbols.get(4), new Delta(Handle.TR, AffineTransform.getTranslateInstance(-bbox.width/2, bbox.height/2)));
     126                        symbol(symbols.get(5), new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, bbox.height/2)));
     127                        symbol(symbols.get(6), new Delta(Handle.TL, AffineTransform.getTranslateInstance(bbox.width/2, bbox.height/2)));
    128128                        break;
    129129                case 8:
    130                         symbol(feature, symbols.get(0), new Delta(Handle.BR, AffineTransform.getTranslateInstance(0, -bbox.height/2)));
    131                         symbol(feature, symbols.get(1), new Delta(Handle.BL, AffineTransform.getTranslateInstance(0, -bbox.height/2)));
    132                         symbol(feature, symbols.get(2), new Delta(Handle.RC, AffineTransform.getTranslateInstance(-bbox.width/2, 0)));
    133                         symbol(feature, symbols.get(3), new Delta(Handle.CC, new AffineTransform()));
    134                         symbol(feature, symbols.get(4), new Delta(Handle.LC, AffineTransform.getTranslateInstance(bbox.width/2, 0)));
    135                         symbol(feature, symbols.get(5), new Delta(Handle.TR, AffineTransform.getTranslateInstance(-bbox.width/2, bbox.height/2)));
    136                         symbol(feature, symbols.get(6), new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, bbox.height/2)));
    137                         symbol(feature, symbols.get(7), new Delta(Handle.TL, AffineTransform.getTranslateInstance(bbox.width/2, bbox.height/2)));
     130                        symbol(symbols.get(0), new Delta(Handle.BR, AffineTransform.getTranslateInstance(0, -bbox.height/2)));
     131                        symbol(symbols.get(1), new Delta(Handle.BL, AffineTransform.getTranslateInstance(0, -bbox.height/2)));
     132                        symbol(symbols.get(2), new Delta(Handle.RC, AffineTransform.getTranslateInstance(-bbox.width/2, 0)));
     133                        symbol(symbols.get(3), new Delta(Handle.CC, new AffineTransform()));
     134                        symbol(symbols.get(4), new Delta(Handle.LC, AffineTransform.getTranslateInstance(bbox.width/2, 0)));
     135                        symbol(symbols.get(5), new Delta(Handle.TR, AffineTransform.getTranslateInstance(-bbox.width/2, bbox.height/2)));
     136                        symbol(symbols.get(6), new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, bbox.height/2)));
     137                        symbol(symbols.get(7), new Delta(Handle.TL, AffineTransform.getTranslateInstance(bbox.width/2, bbox.height/2)));
    138138                        break;
    139139                case 9:
    140                         symbol(feature, symbols.get(0), new Delta(Handle.BR, AffineTransform.getTranslateInstance(-bbox.width/2, -bbox.height/2)));
    141                         symbol(feature, symbols.get(1), new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -bbox.height/2)));
    142                         symbol(feature, symbols.get(2), new Delta(Handle.BL, AffineTransform.getTranslateInstance(bbox.width/2, -bbox.height/2)));
    143                         symbol(feature, symbols.get(3), new Delta(Handle.RC, AffineTransform.getTranslateInstance(-bbox.width/2, 0)));
    144                         symbol(feature, symbols.get(4), new Delta(Handle.CC, new AffineTransform()));
    145                         symbol(feature, symbols.get(5), new Delta(Handle.LC, AffineTransform.getTranslateInstance(bbox.width/2, 0)));
    146                         symbol(feature, symbols.get(6), new Delta(Handle.TR, AffineTransform.getTranslateInstance(-bbox.width/2, bbox.height/2)));
    147                         symbol(feature, symbols.get(7), new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, bbox.height/2)));
    148                         symbol(feature, symbols.get(8), new Delta(Handle.TL, AffineTransform.getTranslateInstance(bbox.width/2, bbox.height/2)));
     140                        symbol(symbols.get(0), new Delta(Handle.BR, AffineTransform.getTranslateInstance(-bbox.width/2, -bbox.height/2)));
     141                        symbol(symbols.get(1), new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -bbox.height/2)));
     142                        symbol(symbols.get(2), new Delta(Handle.BL, AffineTransform.getTranslateInstance(bbox.width/2, -bbox.height/2)));
     143                        symbol(symbols.get(3), new Delta(Handle.RC, AffineTransform.getTranslateInstance(-bbox.width/2, 0)));
     144                        symbol(symbols.get(4), new Delta(Handle.CC, new AffineTransform()));
     145                        symbol(symbols.get(5), new Delta(Handle.LC, AffineTransform.getTranslateInstance(bbox.width/2, 0)));
     146                        symbol(symbols.get(6), new Delta(Handle.TR, AffineTransform.getTranslateInstance(-bbox.width/2, bbox.height/2)));
     147                        symbol(symbols.get(7), new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, bbox.height/2)));
     148                        symbol(symbols.get(8), new Delta(Handle.TL, AffineTransform.getTranslateInstance(bbox.width/2, bbox.height/2)));
    149149                        break;
    150150                }
     
    169169        }
    170170
    171         public static void lineSymbols(Feature feature, Symbol prisymb, double space, Symbol secsymb, Symbol tersymb, int ratio, Color col) {
    172                 if ((feature.geom.prim == Pflag.NOSP) || (feature.geom.prim == Pflag.POINT))
     171        public static void lineSymbols(Symbol prisymb, double space, Symbol secsymb, Symbol tersymb, int ratio, Color col) {
     172                if ((Rules.feature.geom.prim == Pflag.NOSP) || (Rules.feature.geom.prim == Pflag.POINT))
    173173                        return;
    174174                Rectangle2D.Double prect = symbolSize(prisymb);
     
    192192                        boolean stflag = false;
    193193                        Symbol symbol = prisymb;
    194                         GeomIterator git = map.new GeomIterator(feature.geom);
     194                        GeomIterator git = map.new GeomIterator(Rules.feature.geom);
    195195                        while (git.hasComp()) {
    196196                                git.nextComp();
     
    253253        }
    254254
    255         public static void lineVector(Feature feature, LineStyle style) {
     255        public static void lineVector(LineStyle style) {
    256256                Path2D.Double p = new Path2D.Double();
    257257                p.setWindingRule(GeneralPath.WIND_EVEN_ODD);
    258258                Point2D point;
    259                 GeomIterator git = map.new GeomIterator(feature.geom);
     259                GeomIterator git = map.new GeomIterator(Rules.feature.geom);
    260260                while (git.hasComp()) {
    261261                        git.nextComp();
     
    278278                        }
    279279                }
    280                 if ((style.fill != null) && (feature.geom.prim == Pflag.AREA)) {
     280                if ((style.fill != null) && (Rules.feature.geom.prim == Pflag.AREA)) {
    281281                        g2.setPaint(style.fill);
    282282                        g2.fill(p);
     
    298298        }
    299299       
    300         public static void lineCircle(Feature feature, LineStyle style, double radius, UniHLU units) {
     300        public static void lineCircle(LineStyle style, double radius, UniHLU units) {
    301301                switch (units) {
    302302                case HLU_FEET:
     
    318318                        break;
    319319                }
    320                 radius *= context.mile(feature);
     320                radius *= context.mile(Rules.feature);
    321321                Symbol circle = new Symbol();
    322322                if (style.fill != null) {
     
    327327                circle.add(new Instr(Form.STRK, new BasicStroke(style.width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, style.dash, 0)));
    328328                circle.add(new Instr(Form.ELPS, new Ellipse2D.Double(-radius,-radius,radius*2,radius*2)));
    329                 Point2D point = context.getPoint(feature.geom.centre);
     329                Point2D point = context.getPoint(Rules.feature.geom.centre);
    330330                Symbols.drawSymbol(g2, circle, 1, point.getX(), point.getY(), null, null);
    331331        }
    332332
    333         public static void fillPattern(Feature feature, BufferedImage image) {
     333        public static void fillPattern(BufferedImage image) {
    334334                Path2D.Double p = new Path2D.Double();
    335335                p.setWindingRule(GeneralPath.WIND_EVEN_ODD);
    336336                Point2D point;
    337                 switch (feature.geom.prim) {
     337                switch (Rules.feature.geom.prim) {
    338338                case POINT:
    339                         point = context.getPoint(feature.geom.centre);
     339                        point = context.getPoint(Rules.feature.geom.centre);
    340340                        g2.drawImage(image, new AffineTransformOp(AffineTransform.getScaleInstance(sScale, sScale), AffineTransformOp.TYPE_NEAREST_NEIGHBOR),
    341341                                        (int)(point.getX() - (50 * sScale)), (int)(point.getY() - (50 * sScale)));
    342342                        break;
    343343                case AREA:
    344                         GeomIterator git = map.new GeomIterator(feature.geom);
     344                        GeomIterator git = map.new GeomIterator(Rules.feature.geom);
    345345                        while (git.hasComp()) {
    346346                                git.nextComp();
     
    365365        }
    366366       
    367         public static void labelText(Feature feature, String str, Font font, Color tc) {
    368                 labelText(feature, str, font, tc, LabelStyle.NONE, null, null, null);
    369         }
    370         public static void labelText(Feature feature, String str, Font font, Color tc, Delta delta) {
    371                 labelText(feature, str, font, tc, LabelStyle.NONE, null, null, delta);
    372         }
    373         public static void labelText(Feature feature, String str, Font font, Color tc, LabelStyle style, Color fg) {
    374                 labelText(feature, str, font, tc, style, fg, null, null);
    375         }
    376         public static void labelText(Feature feature, String str, Font font, Color tc, LabelStyle style, Color fg, Color bg) {
    377                 labelText(feature, str, font, tc, style, fg, bg, null);
    378         }
    379         public static void labelText(Feature feature, String str, Font font, Color tc, LabelStyle style, Color fg, Delta delta) {
    380                 labelText(feature, str, font, tc, style, fg, null, delta);
    381         }
    382         public static void labelText(Feature feature, String str, Font font, Color tc, LabelStyle style, Color fg, Color bg, Delta delta) {
     367        public static void labelText(String str, Font font, Color tc) {
     368                labelText(str, font, tc, LabelStyle.NONE, null, null, null);
     369        }
     370        public static void labelText(String str, Font font, Color tc, Delta delta) {
     371                labelText(str, font, tc, LabelStyle.NONE, null, null, delta);
     372        }
     373        public static void labelText(String str, Font font, Color tc, LabelStyle style, Color fg) {
     374                labelText(str, font, tc, style, fg, null, null);
     375        }
     376        public static void labelText(String str, Font font, Color tc, LabelStyle style, Color fg, Color bg) {
     377                labelText(str, font, tc, style, fg, bg, null);
     378        }
     379        public static void labelText(String str, Font font, Color tc, LabelStyle style, Color fg, Delta delta) {
     380                labelText(str, font, tc, style, fg, null, delta);
     381        }
     382        public static void labelText(String str, Font font, Color tc, LabelStyle style, Color fg, Color bg, Delta delta) {
    383383                if (delta == null) delta = new Delta(Handle.CC);
    384384                if (bg == null) bg = new Color(0x00000000, true);
     
    475475                }
    476476                label.add(new Instr(Form.TEXT, new Caption(str, font, tc, new Delta(Handle.TL, AffineTransform.getTranslateInstance(tx, ty)))));
    477                 Point2D point = context.getPoint(feature.geom.centre);
     477                Point2D point = context.getPoint(Rules.feature.geom.centre);
    478478                Symbols.drawSymbol(g2, label, sScale, point.getX(), point.getY(), null, delta);
    479479        }
    480480
    481         public static void lineText(Feature feature, String str, Font font, Color colour, double offset, double dy) {
     481        public static void lineText(String str, Font font, Color colour, double offset, double dy) {
    482482                if (!str.isEmpty()) {
    483483                        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
     
    493493                        double angle = 0;
    494494                        int index = 0;
    495                         double gwidth = offset * (feature.geom.length * context.mile(feature) - gv.getLogicalBounds().getWidth()) + gv.getGlyphMetrics(0).getAdvance();
    496                         GeomIterator git = map.new GeomIterator(feature.geom);
     495                        double gwidth = offset * (Rules.feature.geom.length * context.mile(Rules.feature) - gv.getLogicalBounds().getWidth()) + gv.getGlyphMetrics(0).getAdvance();
     496                        GeomIterator git = map.new GeomIterator(Rules.feature.geom);
    497497                        while (git.hasComp()) {
    498498                                git.nextComp();
     
    548548        }
    549549       
    550         public static void lightSector(Feature feature, Color col1, Color col2, double radius, double s1, double s2, Double dir, String str) {
     550        public static void lightSector(Color col1, Color col2, double radius, double s1, double s2, Double dir, String str) {
    551551                if ((zoom >= 16) && (radius > 0.2)) {
    552552                        radius /= (Math.pow(2, zoom-15));
     
    555555                g2.setStroke(new BasicStroke((float) (3.0 * sScale), BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1, new float[] {20 * (float)sScale, 20 * (float)sScale}, 0));
    556556                g2.setPaint(Color.black);
    557                 Point2D.Double centre = (Point2D.Double) context.getPoint(feature.geom.centre);
    558                 double radial = radius * context.mile(feature);
     557                Point2D.Double centre = (Point2D.Double) context.getPoint(Rules.feature.geom.centre);
     558                double radial = radius * context.mile(Rules.feature);
    559559                if (dir != null) {
    560560                        g2.draw(new Line2D.Double(centre.x, centre.y, centre.x - radial * Math.sin(Math.toRadians(dir)), centre.y + radial * Math.cos(Math.toRadians(dir))));
     
    585585                        if (gv.getLogicalBounds().getWidth() < awidth) {
    586586                                at.rotate(Math.toRadians(mid + (hand ? 0 : 180)));
    587                                 Renderer.labelText(feature, str, font, Color.black, new Delta(Handle.CC, at));
     587                                Renderer.labelText(str, font, Color.black, new Delta(Handle.CC, at));
    588588                        } else if (gv.getLogicalBounds().getHeight() < awidth) {
    589589                                hand = (mid < 180);
    590590                                at.rotate(Math.toRadians(mid + (hand ? -90 : 90)));
    591                                 Renderer.labelText(feature, str, font, Color.black, hand ? new Delta(Handle.RC, at) : new Delta(Handle.LC, at));
     591                                Renderer.labelText(str, font, Color.black, hand ? new Delta(Handle.RC, at) : new Delta(Handle.LC, at));
    592592                        }
    593593                        if (dir != null) {
     
    599599                                at = AffineTransform.getTranslateInstance(-radial * Math.sin(phi) / sScale, radial * Math.cos(phi) / sScale);
    600600                                at.rotate(Math.toRadians(dir + (hand ? 90 : -90)));
    601                                 Renderer.labelText(feature, str, font, Color.black, hand ? new Delta(Handle.BR, at) : new Delta(Handle.BL, at));
     601                                Renderer.labelText(str, font, Color.black, hand ? new Delta(Handle.BR, at) : new Delta(Handle.BL, at));
    602602                        }
    603603                }
Note: See TracChangeset for help on using the changeset viewer.