Changeset 4134 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2011-06-11T00:23:38+02:00 (13 years ago)
Author:
bastiK
Message:

see #67 - new parallel way drawing mode (patch by Ole Jørgen Brønner)

Location:
trunk/src/org/openstreetmap/josm
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/coor/EastNorth.java

    r3837 r4134  
    2525    public EastNorth add(double dx, double dy) {
    2626        return new EastNorth(x+dx, y+dy);
     27    }
     28
     29    public EastNorth add(EastNorth other) {
     30        return new EastNorth(x+other.x, y+other.y);
     31    }
     32
     33    public EastNorth scale(double s) {
     34        return new EastNorth(s * x, s * y);
    2735    }
    2836
  • trunk/src/org/openstreetmap/josm/gui/MapFrame.java

    r4127 r4134  
    4141import org.openstreetmap.josm.actions.mapmode.ExtrudeAction;
    4242import org.openstreetmap.josm.actions.mapmode.MapMode;
     43import org.openstreetmap.josm.actions.mapmode.ParallelWayAction;
    4344import org.openstreetmap.josm.actions.mapmode.SelectAction;
    4445import org.openstreetmap.josm.actions.mapmode.ZoomAction;
     
    129130        addMapMode(new IconToggleButton(new SelectAction(this)));
    130131        addMapMode(new IconToggleButton(new DrawAction(this)));
    131         addMapMode(new IconToggleButton(new ExtrudeAction(this)));
    132132        addMapMode(new IconToggleButton(new ZoomAction(this)));
    133133        addMapMode(new IconToggleButton(new DeleteAction(this)));
     134        addMapMode(new IconToggleButton(new ExtrudeAction(this)));
     135        addMapMode(new IconToggleButton(new ParallelWayAction(this)));
    134136
    135137        toolGroup.setSelected(((AbstractButton)toolBarActions.getComponent(0)).getModel(), true);
  • trunk/src/org/openstreetmap/josm/tools/Geometry.java

    r4126 r4134  
    334334    }
    335335
     336    public static EastNorth closestPointToLine(EastNorth lineP1, EastNorth lineP2, EastNorth point) {
     337        double ldx = lineP2.getX() - lineP1.getX();
     338        double ldy = lineP2.getY() - lineP1.getY();
     339
     340        if (ldx == 0 && ldy == 0) //segment zero length
     341            return lineP1;
     342
     343        double pdx = point.getX() - lineP1.getX();
     344        double pdy = point.getY() - lineP1.getY();
     345
     346        double offset = (pdx * ldx + pdy * ldy) / (ldx * ldx + ldy * ldy);
     347        return new EastNorth(lineP1.getX() + ldx * offset, lineP1.getY() + ldy * offset);
     348    }
     349
    336350    /**
    337351     * This method tests if secondNode is clockwise to first node.
Note: See TracChangeset for help on using the changeset viewer.