Ignore:
Timestamp:
2013-10-18T11:30:13+02:00 (11 years ago)
Author:
malcolmh
Message:

save

File:
1 edited

Legend:

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

    r30024 r30025  
    6565        public enum LabelStyle { NONE, RRCT, RECT, ELPS, CIRC }
    6666
    67         static MapHelper helper;
     67        static MapContext context;
    6868        static SeaMap map;
    6969        static double sScale;
     
    7272        static int zoom;
    7373
    74         public static void reRender(Graphics2D g, int z, double factor, SeaMap m, MapHelper h) {
     74        public static void reRender(Graphics2D g, int z, double factor, SeaMap m, MapContext c) {
    7575                g2 = g;
    7676                zoom = z;
    77                 helper = h;
     77                context = c;
    7878                map = m;
    7979                sScale = symbolScale[zoom] * factor;
     
    107107
    108108        public static void symbol(Feature feature, Symbol symbol, Obj obj, Delta delta, Scheme scheme) {
    109                 Point2D point = helper.getPoint(feature.centre);
     109                Point2D point = context.getPoint(feature.centre);
    110110                if (obj == null) {
    111111                        Symbols.drawSymbol(g2, symbol, sScale, point.getX(), point.getY(), delta, scheme);
     
    177177                                while (bit.hasNext()) {
    178178                                        prev = next;
    179                                         next = helper.getPoint(bit.next());
     179                                        next = context.getPoint(bit.next());
    180180                                        angle = Math.atan2(next.getY() - prev.getY(), next.getX() - prev.getX());
    181181                                        piv = true;
     
    233233                case LINE:
    234234                        EdgeIterator eit = map.new EdgeIterator(map.edges.get(feature.refs), true);
    235                         point = helper.getPoint(eit.next());
     235                        point = context.getPoint(eit.next());
    236236                        p.moveTo(point.getX(), point.getY());
    237237                        while (eit.hasNext()) {
    238                                 point = helper.getPoint(eit.next());
     238                                point = context.getPoint(eit.next());
    239239                                p.lineTo(point.getX(), point.getY());
    240240                        }
     
    243243                        for (Bound bound : map.areas.get(feature.refs)) {
    244244                                BoundIterator bit = map.new BoundIterator(bound);
    245                                 point = helper.getPoint(bit.next());
     245                                point = context.getPoint(bit.next());
    246246                                p.moveTo(point.getX(), point.getY());
    247247                                while (bit.hasNext()) {
    248                                         point = helper.getPoint(bit.next());
     248                                        point = context.getPoint(bit.next());
    249249                                        p.lineTo(point.getX(), point.getY());
    250250                                }
     
    292292                        break;
    293293                }
    294                 radius *= helper.mile(feature);
     294                radius *= context.mile(feature);
    295295                Symbol circle = new Symbol();
    296296                if (style.fill != null) {
     
    301301                circle.add(new Instr(Prim.STRK, new BasicStroke(style.width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, style.dash, 0)));
    302302                circle.add(new Instr(Prim.ELPS, new Ellipse2D.Double(-radius,-radius,radius*2,radius*2)));
    303                 Point2D point = helper.getPoint(feature.centre);
    304                 Symbols.drawSymbol(g2, circle, sScale, point.getX(), point.getY(), null, null);
     303                Point2D point = context.getPoint(feature.centre);
     304                Symbols.drawSymbol(g2, circle, 1, point.getX(), point.getY(), null, null);
    305305        }
    306306
     
    312312                switch (feature.flag) {
    313313                case POINT:
    314                         point = helper.getPoint(feature.centre);
     314                        point = context.getPoint(feature.centre);
    315315                        g2.drawImage(image, new AffineTransformOp(AffineTransform.getScaleInstance(sScale, sScale), AffineTransformOp.TYPE_NEAREST_NEIGHBOR),
    316316                                        (int)(point.getX() - (50 * sScale)), (int)(point.getY() - (50 * sScale)));
     
    319319                        for (Bound bound : map.areas.get(feature.refs)) {
    320320                                BoundIterator bit = map.new BoundIterator(bound);
    321                                 point = helper.getPoint(bit.next());
     321                                point = context.getPoint(bit.next());
    322322                                p.moveTo(point.getX(), point.getY());
    323323                                while (bit.hasNext()) {
    324                                         point = helper.getPoint(bit.next());
     324                                        point = context.getPoint(bit.next());
    325325                                        p.lineTo(point.getX(), point.getY());
    326326                                }
     
    340340    GlyphVector gv = font.deriveFont((float)(font.getSize())).createGlyphVector(frc, str.equals(" ") ? "M" : str);
    341341    Rectangle2D bounds = gv.getVisualBounds();
    342     double width = bounds.getWidth() * 1.5;
    343     double height = bounds.getHeight() * 1.5;
    344     double dx = 0;
    345     double dy = 0;
     342    double width = bounds.getWidth();
     343    double height = bounds.getHeight();
     344    double dx = 0.25 * width;
     345    double dy = 0.25 * height;
    346346                switch (delta.h) {
    347347                case CC:
    348                         dx = width / 2.0;
    349                         dy = height / 2.0;
     348                        dx += width / 2.0;
     349                        dy += height / 2.0;
    350350                        break;
    351351                case TL:
    352                         dx = 0;
    353                         dy = 0;
     352                        dx += 0;
     353                        dy += 0;
    354354                        break;
    355355                case TR:
    356                         dx = width;
    357                         dy = 0;
     356                        dx += width;
     357                        dy += 0;
    358358                        break;
    359359                case TC:
    360                         dx = width / 2.0;
    361                         dy = 0;
     360                        dx += width / 2.0;
     361                        dy += 0;
    362362                        break;
    363363                case LC:
    364                         dx = 0;
    365                         dy = height / 2.0;
     364                        dx += 0;
     365                        dy += height / 2.0;
    366366                        break;
    367367                case RC:
    368                         dx = width;
    369                         dy = height / 2.0;
     368                        dx += width;
     369                        dy += height / 2.0;
    370370                        break;
    371371                case BL:
    372                         dx = 0;
    373                         dy = height;
     372                        dx += 0;
     373                        dy += height;
    374374                        break;
    375375                case BR:
    376                         dx = width;
    377                         dy = height;
     376                        dx += width;
     377                        dy += height;
    378378                        break;
    379379                case BC:
    380                         dx = width / 2.0;
    381                         dy = height;
     380                        dx += width / 2.0;
     381                        dy += height;
    382382                        break;
    383383                }
     
    386386                case RRCT:
    387387                        if (width < height) width = height;
     388                        width *= 1.5;
     389                        height *= 1.5;
    388390                        label.add(new Instr(Prim.FILL, bg));
    389                         label.add(new Instr(Prim.RSHP, new RoundRectangle2D.Double(-dx,-dy/1.25,width,height,height,height)));
     391                        label.add(new Instr(Prim.RSHP, new RoundRectangle2D.Double(-dx,-dy,width,height,height,height)));
    390392                        label.add(new Instr(Prim.FILL, fg));
    391393                        label.add(new Instr(Prim.STRK, new BasicStroke(1 + (int)(height/10), BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER)));
    392                         label.add(new Instr(Prim.RRCT, new RoundRectangle2D.Double(-dx,-dy/1.25,width,height,height,height)));
     394                        label.add(new Instr(Prim.RRCT, new RoundRectangle2D.Double(-dx,-dy,width,height,height,height)));
    393395                        break;
    394396                }
    395397                label.add(new Instr(Prim.TEXT, new Caption(str, font, fg, delta)));
    396                 Point2D point = helper.getPoint(feature.centre);
     398                Point2D point = context.getPoint(feature.centre);
    397399                Symbols.drawSymbol(g2, label, sScale, point.getX(), point.getY(), null, null);
    398400        }
     
    431433                                while (bit.hasNext()) {
    432434                                        prev = next;
    433                                         next = helper.getPoint(bit.next());
     435                                        next = context.getPoint(bit.next());
    434436                                        angle = Math.atan2(next.getY() - prev.getY(), next.getX() - prev.getX());
    435437                                        piv = true;
Note: See TracChangeset for help on using the changeset viewer.