Changeset 26106 in osm


Ignore:
Timestamp:
2011-06-07T15:27:57+02:00 (14 years ago)
Author:
akks
Message:

FastDraw: better highlighting, added ability to paste tags automatically, customize colors

Location:
applications/editors/josm/plugins/turbopen/src/org/openstreetmap/josm/plugins/fastdraw
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/turbopen/src/org/openstreetmap/josm/plugins/fastdraw/DrawnPolyLine.java

    r26101 r26106  
    273273    }
    274274
    275    
    276 
    277    
    278        
    279        
    280    
    281 
    282    
    283        
    284275}
  • applications/editors/josm/plugins/turbopen/src/org/openstreetmap/josm/plugins/fastdraw/FastDrawingMode.java

    r26101 r26106  
    1616import java.awt.event.MouseEvent;
    1717import org.openstreetmap.josm.data.coor.LatLon;
     18import org.openstreetmap.josm.data.osm.Tag;
    1819import static org.openstreetmap.josm.tools.I18n.tr;
    1920
     
    2728import java.awt.event.KeyEvent;
    2829import java.io.IOException;
     30import java.lang.annotation.Target;
    2931import java.util.*;
    3032import javax.swing.JOptionPane;
    3133
    3234import org.openstreetmap.josm.Main;
     35import org.openstreetmap.josm.actions.PasteTagsAction.TagPaster;
    3336import org.openstreetmap.josm.actions.mapmode.MapMode;
    3437import org.openstreetmap.josm.command.AddCommand;
     
    5053        AWTEventListener {
    5154    private static final String SIMPLIFYMODE_MESSAGE=
    52             "Press Enter to simplify or save, Up/Down to tune simplification";
     55            "Press Enter to simplify or save, Ctrl-Enter to save with tags, Up/Down to tune simplification";
    5356    private static final String DRAWINGMODE_MESSAGE=
    54     "Click or Click&drag to continue, Ctrl-Click to add fixed node, Shift-Click to start new line";
    55    
    56     private static final Color COLOR_FIXED = Color.green;
    57     private static final Color COLOR_NORMAL = Color.white;
    58     private static final Color COLOR_DELETE = Color.red;
    59     private static final Color COLOR_SELECTEDFRAGMENT = Color.red;
    60     private static final Color COLOR_EDITEDFRAGMENT = Color.orange;
     57    "Click or Click&drag to continue, Ctrl-Click to add fixed node, Shift-Click to delete, Enter to simplify or save, Ctrl-Shift-Click to start new line";
     58   
     59    private Color COLOR_FIXED;
     60    private Color COLOR_NORMAL;
     61    private Color COLOR_DELETE;
     62    private Color COLOR_SELECTEDFRAGMENT;
     63    private Color COLOR_EDITEDFRAGMENT;
    6164   
    6265    private double maxDist;
     
    191194                pp2 = it2.next();
    192195                p2 = line.getPoint(pp2);
    193                 if (highlighted==pp1) {lineColor=COLOR_SELECTEDFRAGMENT;}
     196                if (shift && highlighted==pp1 && nearestIdx<0) {lineColor=COLOR_SELECTEDFRAGMENT;}
    194197                if (line.isLastPoint(i)) { lineColor=COLOR_EDITEDFRAGMENT; }
    195198                g.setColor(lineColor);
     
    212215                }
    213216                if (ctrl && !line.wasSimplified() && nearestIdx==i+1 ) {
    214                     // highlight node to delete
     217                    // highlight node to toggle fixation
    215218                    g.setStroke(strokeForDelete);
    216219                    g.setColor( line.isFixed(pp2) ? COLOR_NORMAL: COLOR_FIXED);
     
    293296        if (e.getButton() != MouseEvent.BUTTON1) return;
    294297        drawing = false;
    295         if (!ready) setStatusLine(tr(DRAWINGMODE_MESSAGE)
    296                         + tr(SIMPLIFYMODE_MESSAGE));
     298        highlighted=null;
     299        if (!ready) setStatusLine(tr(DRAWINGMODE_MESSAGE));
    297300        repaint();
    298301    }
     
    435438            w.addNode(nd);
    436439            i++;
     440        }
     441        if (ctrl) {
     442            // paste tags - from ctrl-shift-v
     443            Set <OsmPrimitive> ts = new HashSet<OsmPrimitive>();
     444            ts.add(w);
     445            TagPaster tp = new TagPaster(Main.pasteBuffer.getDirectlyAdded(), ts);
     446            List<Tag> execute = tp.execute();
     447            Map<String,String> tgs=new HashMap<String,String>();
     448            for (Tag t : execute) {
     449                w.put(t.getKey(), t.getValue());
     450            }
    437451        }
    438452        cmds.add(new AddCommand(w));
     
    487501   
    488502    void loadPrefs() {
     503        COLOR_DELETE = Main.pref.getColor("fastdraw.color.delete", Color.red);
     504        COLOR_EDITEDFRAGMENT = Main.pref.getColor("fastdraw.color.edit", Color.orange);
     505        COLOR_FIXED = Main.pref.getColor("fastdraw.color.fixed", Color.green);
     506        COLOR_NORMAL = Main.pref.getColor("fastdraw.color.normal", Color.red);
     507        COLOR_SELECTEDFRAGMENT = Main.pref.getColor("fastdraw.color.select", Color.blue);
    489508        maxDist = Main.pref.getDouble("fastdraw.maxdist", 5);
    490509        epsilonMult = Main.pref.getDouble("fastdraw.epsilonmult", 1.1);
     
    496515   
    497516    void savePrefs() {
     517         Main.pref.putColor("fastdraw.color.delete", COLOR_DELETE );
     518         Main.pref.putColor("fastdraw.color.edit", COLOR_EDITEDFRAGMENT);
     519         Main.pref.putColor("fastdraw.color.fixed", COLOR_FIXED);
     520         Main.pref.putColor("fastdraw.color.normal", COLOR_NORMAL);
     521         Main.pref.putColor("fastdraw.color.select", COLOR_SELECTEDFRAGMENT);
    498522         Main.pref.putDouble("fastdraw.maxdist", maxDist);
    499523         Main.pref.putDouble("fastdraw.epsilonmult", epsilonMult);
Note: See TracChangeset for help on using the changeset viewer.