Changeset 30025 in osm


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

save

Location:
applications/editors/josm/plugins/smed2/src
Files:
6 edited
1 moved

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/smed2/src/panels/ShowFrame.java

    r30024 r30025  
    1212import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1313
    14 import seamap.MapHelper;
     14import seamap.MapContext;
    1515import seamap.Renderer;
    1616import seamap.SeaMap;
     
    2222        Picture picture;
    2323
    24         class Picture extends JPanel implements MapHelper {
     24        class Picture extends JPanel implements MapContext {
    2525               
    2626                public void drawPicture(OsmPrimitive osm, SeaMap map) {
  • applications/editors/josm/plugins/smed2/src/seamap/Lights.java

    r29787 r30025  
    1717
    1818        private static Point2D.Double radial(Snode centre, double radius, double angle) {
    19                 Point2D origin = Renderer.helper.getPoint(centre);
    20                 double mile = Renderer.helper.getPoint(Renderer.map.new Snode((centre.lat + Math.toRadians(1/60)), centre.lon)).getY() - origin.getY();
     19                Point2D origin = Renderer.context.getPoint(centre);
     20                double mile = Renderer.context.getPoint(Renderer.map.new Snode((centre.lat + Math.toRadians(1/60)), centre.lon)).getY() - origin.getY();
    2121                return new Point2D.Double(origin.getX() - (radius * mile * Math.sin(angle)), origin.getY() - (radius * mile * Math.cos(angle)));
    2222        }
  • applications/editors/josm/plugins/smed2/src/seamap/MapContext.java

    r30024 r30025  
    55import seamap.SeaMap.*;
    66
    7 public interface MapHelper {
     7public interface MapContext {
    88        Point2D getPoint(Snode coord);
    99        double mile(Feature feature);
  • 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;
  • applications/editors/josm/plugins/smed2/src/seamap/Rules.java

    r30024 r30025  
    3434                ArrayList<Feature> objects;
    3535                if ((objects = map.features.get(Obj.SLCONS)) != null) for (Feature feature : objects) shoreline(feature);
    36                 if ((objects = map.features.get(Obj.SLCONS)) != null) for (Feature feature : objects) shoreline(feature);;
    3736                if ((objects = map.features.get(Obj.PIPSOL)) != null) for (Feature feature : objects) pipelines(feature);
    3837                if ((objects = map.features.get(Obj.CBLSUB)) != null) for (Feature feature : objects) cables(feature);
     
    6261                if ((objects = map.features.get(Obj.ACHARE)) != null) for (Feature feature : objects) harbours(feature);
    6362                if ((objects = map.features.get(Obj.ACHBRT)) != null) for (Feature feature : objects) harbours(feature);
     63                if ((objects = map.features.get(Obj.BERTHS)) != null) for (Feature feature : objects) harbours(feature);
    6464                if ((objects = map.features.get(Obj.LOKBSN)) != null) for (Feature feature : objects) locks(feature);
    6565                if ((objects = map.features.get(Obj.LKBSPT)) != null) for (Feature feature : objects) locks(feature);
     
    245245                       
    246246                }
    247 /*      Att_t *attv = getAtt(getObj(item, BRIDGE, 0), VERCLR);
     247/*    case BRIDGE: {
     248      Att_t *attv = getAtt(getObj(item, BRIDGE, 0), VERCLR);
    248249      if (attv == NULL) attv = getAtt(getObj(item, BRIDGE, 0), VERCSA);
    249250      Att_t *attc = getAtt(getObj(item, BRIDGE, 0), VERCCL);
     
    254255      }
    255256      else if ((attc != NULL) && (atto == NULL)) {
     257        char *string=strdup(stringValue(attc->val));
     258        string = realloc(string, strlen(string) + 3); strcat(string, "/-");
    256259        renderSymbol(item, obja, "clear_v", "", "", CC, 0, 0, 0);
    257         drawText(item, stringValue(attc->val), "font-family:Arial; font-weight:normal; font-size:70; text-anchor:middle", 0, 12);
     260        drawText(item, string, "font-family:Arial; font-weight:normal; font-size:70; text-anchor:middle", 0, 12);
     261        free(string);
    258262      }
    259263      else if ((attc != NULL) && (atto != NULL)) {
    260         renderSymbol(item, obja, "clear_v", "", "", RC, 5, 0, 0);
    261         drawText(item, stringValue(attc->val), "font-family:Arial; font-weight:normal; font-size:70; text-anchor:middle", -35, 12);
    262         renderSymbol(item, obja, "clear_v", "", "", LC, -5, 0, 0);
    263         drawText(item, stringValue(atto->val), "font-family:Arial; font-weight:normal; font-size:70; text-anchor:middle", 35, 12);
     264        char *string=strdup(stringValue(attc->val));
     265        string = realloc(string, strlen(string) + 2); strcat(string, "/");
     266        string = realloc(string, strlen(string) + strlen(stringValue(atto->val)) + 1); strcat(string, stringValue(atto->val));
     267        renderSymbol(item, obja, "clear_v", "", "", CC, 0, 0, 0);
     268        drawText(item, string, "font-family:Arial; font-weight:normal; font-size:60; text-anchor:middle", 0, 10);
     269        free(string);
    264270      }
    265271    }
     
    318324                        if (radius != 0) {
    319325                                UniHLU units = (UniHLU)Renderer.getAttVal(feature, Obj.ACHBRT, 0, Att.HUNITS);
    320                                 Renderer.lineCircle (feature, new LineStyle(new Color(0xc480ff), 10, new float[] { 25, 25 }, null), radius, units);
     326                                Renderer.lineCircle (feature, new LineStyle(new Color(0xc480ff), 4, new float[] { 10, 10 }, null), radius, units);
    321327                        }
    322328                        break;
     
    366372                                        break;
    367373                                }
     374                        }
     375                        break;
     376                case BERTHS:
     377                        if (zoom >= 14) {
     378                                Renderer.labelText(feature, name == null ? " " : (String) name.val, new Font("Arial", Font.PLAIN, 40), LabelStyle.RRCT, new Color(0xc480ff), Color.white, null);
    368379                        }
    369380                        break;
     
    895906                                                break;
    896907                                        case ROS_VAIS:
    897                                                 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 80)));
     908                                                Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
    898909                                                break;
    899910                                        case ROS_VANC:
    900                                                 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 80)));
     911                                                Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
    901912                                                Renderer.symbol(feature, Topmarks.TopNorth, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)), null);
    902913                                                break;
    903914                                        case ROS_VASC:
    904                                                 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 80)));
     915                                                Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
    905916                                                Renderer.symbol(feature, Topmarks.TopSouth, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)), null);
    906917                                                break;
    907918                                        case ROS_VAEC:
    908                                                 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 80)));
     919                                                Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
    909920                                                Renderer.symbol(feature, Topmarks.TopEast, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)), null);
    910921                                                break;
    911922                                        case ROS_VAWC:
    912                                                 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 80)));
     923                                                Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
    913924                                                Renderer.symbol(feature, Topmarks.TopWest, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)), null);
    914925                                                break;
    915926                                        case ROS_VAPL:
    916                                                 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 80)));
     927                                                Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
    917928                                                Renderer.symbol(feature, Topmarks.TopCan, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)), null);
    918929                                                break;
    919930                                        case ROS_VASL:
    920                                                 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 80)));
     931                                                Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
    921932                                                Renderer.symbol(feature, Topmarks.TopCone, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)), null);
    922933                                                break;
    923934                                        case ROS_VAID:
    924                                                 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 80)));
     935                                                Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
    925936                                                Renderer.symbol(feature, Topmarks.TopIsol, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)), null);
    926937                                                break;
    927938                                        case ROS_VASW:
    928                                                 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 80)));
     939                                                Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
    929940                                                Renderer.symbol(feature, Topmarks.TopSphere, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)), null);
    930941                                                break;
    931942                                        case ROS_VASP:
    932                                                 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 80)));
     943                                                Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
    933944                                                Renderer.symbol(feature, Topmarks.TopX, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)), null);
    934945                                                break;
    935946                                        case ROS_VAWK:
    936                                                 Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 80)));
     947                                                Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
    937948                                                Renderer.symbol(feature, Topmarks.TopCross, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)), null);
    938949                                                break;
    939950                                        }
    940951                                }
    941                                 if (!str.isEmpty()) Renderer.labelText(feature, str, new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BR, AffineTransform.getTranslateInstance(-30, -80)));
     952                                if (!str.isEmpty()) Renderer.labelText(feature, str, new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BR, AffineTransform.getTranslateInstance(-30, -70)));
    942953                                break;
    943954                        case RADSTA:
  • applications/editors/josm/plugins/smed2/src/smed2/MapImage.java

    r30024 r30025  
    2929import org.openstreetmap.josm.gui.layer.ImageryLayer;
    3030
    31 import seamap.MapHelper;
     31import seamap.MapContext;
    3232import seamap.Renderer;
    3333import seamap.SeaMap.*;
    3434
    35 public class MapImage extends ImageryLayer implements ZoomChangeListener, MapHelper {
     35public class MapImage extends ImageryLayer implements ZoomChangeListener, MapContext {
    3636
    3737        private Smed2Action dlg;
     
    102102
    103103        public double mile(Feature feature) {
    104                 return Math.pow(2, zoom) * 256 / (21600 * Math.abs(Math.cos(feature.centre.lat)));
     104                return 185000 / Main.map.mapView.getDist100Pixel();
    105105        }
    106106}
  • applications/editors/josm/plugins/smed2/src/smed2/Smed2Action.java

    r30023 r30025  
    1212import java.awt.*;
    1313import java.awt.event.*;
    14 import java.awt.image.BufferedImage;
    15 import java.io.File;
    1614import java.util.*;
    1715import java.util.Map.Entry;
    1816
    19 import javax.imageio.ImageIO;
    2017import javax.swing.*;
    2118
Note: See TracChangeset for help on using the changeset viewer.