Changeset 29263 in osm for applications/editors/josm


Ignore:
Timestamp:
2013-02-18T18:42:49+01:00 (12 years ago)
Author:
akks
Message:

'JOSM/FastDraw: add option (Q) to draw closed polygons'

Location:
applications/editors/josm/plugins/FastDraw
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/FastDraw/build.xml

    r28167 r29263  
    3030<project name="FastDraw" default="dist" basedir=".">
    3131    <!-- enter the SVN commit message -->
    32     <property name="commit.message" value="FastDraw: better shortcut handling after core changes"/>
     32    <property name="commit.message" value="JOSM/FastDraw: add option (Q) to draw closed polygons"/>
    3333    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    3434    <property name="plugin.main.version" value="5035"/>
  • applications/editors/josm/plugins/FastDraw/src/org/openstreetmap/josm/plugins/fastdraw/DrawnPolyLine.java

    r26522 r29263  
    88import java.util.ListIterator;
    99import java.util.Set;
    10 import javax.xml.stream.events.StartDocument;
    1110import org.openstreetmap.josm.data.coor.LatLon;
    1211import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    380379    }
    381380
     381    int getPointCount() {
     382        return points.size();
     383    }
     384
    382385}
  • applications/editors/josm/plugins/FastDraw/src/org/openstreetmap/josm/plugins/fastdraw/FDSettings.java

    r26501 r29263  
    3333    // option for simplifiction: 0="Autosimplify and wait",
    3434    //1="Simplify and wait", 2="Save as is"
     35
     36    public boolean drawClosed;
    3537    public int simplifyMode;
    3638    public float lineWidth;
     
    5456        fixedClick = Main.pref.getBoolean("fastdraw.fixedclick", false);
    5557        fixedSpacebar = Main.pref.getBoolean("fastdraw.fixedspacebar", false);
     58        drawClosed =  Main.pref.getBoolean("fastdraw.drawclosed", false);
    5659        simplifyMode = Main.pref.getInteger("fastdraw.simplifymode", 0);
    5760        lineWidth = (float) Main.pref.getDouble("fastdraw.linewidth", 2);
     
    7679         Main.pref.put("fastdraw.fixedclick", fixedClick);
    7780         Main.pref.put("fastdraw.fixedspacebar", fixedSpacebar);
     81         Main.pref.put("fastdraw.drawclosed", drawClosed);
    7882         Main.pref.putInteger("fastdraw.simplifymode", simplifyMode);
    7983         Main.pref.putDouble("fastdraw.linewidth",(double)lineWidth);
  • applications/editors/josm/plugins/FastDraw/src/org/openstreetmap/josm/plugins/fastdraw/FastDrawConfigDialog.java

    r26530 r29263  
    55package org.openstreetmap.josm.plugins.fastdraw;
    66
    7 import org.openstreetmap.josm.tools.GBC;
     7import java.awt.Component;
    88import java.awt.GridBagLayout;
    99import javax.swing.JOptionPane;
     10import org.openstreetmap.josm.tools.GBC;
    1011import java.text.NumberFormat;
    1112import java.text.ParseException;
     
    4243        JCheckBox fixedClickCb = new JCheckBox(tr("Add fixed points on click"));
    4344        JCheckBox fixedSpaceCb = new JCheckBox(tr("Add fixed points on spacebar"));
     45        JCheckBox drawClosedCb = new JCheckBox(tr("Draw closed polygons only"));
     46       
    4447        all.add(label1,GBC.std().insets(10,0,0,0));
    4548        all.add(text1, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
     
    5457        all.add(fixedClickCb,GBC.eop().insets(20,0,0,0));
    5558        all.add(fixedSpaceCb,GBC.eop().insets(20,0,0,0));
     59        all.add(drawClosedCb,GBC.eop().insets(20,0,0,0));
    5660       
    5761        text1.setValue(settings.epsilonMult);
     
    6165        fixedClickCb.setSelected(settings.fixedClick);
    6266        fixedSpaceCb.setSelected(settings.fixedSpacebar);
     67        drawClosedCb.setSelected(settings.drawClosed);
    6368        combo1.setSelectedIndex(settings.simplifyMode);
    64 
     69       
    6570        ExtendedDialog dialog = new ExtendedDialog(Main.parent,
    6671                tr("FastDraw settings"),
     
    8489            settings.fixedClick=fixedClickCb.isSelected();
    8590            settings.fixedSpacebar=fixedSpaceCb.isSelected();
     91            settings.drawClosed=drawClosedCb.isSelected();
    8692            settings.simplifyMode=combo1.getSelectedIndex();
    8793            settings.savePrefs();
  • applications/editors/josm/plugins/FastDraw/src/org/openstreetmap/josm/plugins/fastdraw/FastDrawingMode.java

    r28167 r29263  
    127127        mv = Main.map.mapView;
    128128        line.setMv(mv);
    129 
     129       
    130130        if (getCurrentDataSet() == null) return;
    131131
     
    195195            g.setStroke(strokeForOriginal);
    196196        }
    197 
     197       
    198198        Point p1, p2;
    199199        LatLon pp1, pp2;
     
    308308            return;
    309309        }
     310        autoCloseIfNeeded();
    310311
    311312        if (ctrl && shift) {newDrawing();repaint();return;}
     
    427428            }
    428429        }
    429         //statusText = getLatLon(e).toString();        updateStatusLine();
     430        autoCloseIfNeeded();
    430431    }
    431432
     
    721722        Main.map.mapView.repaint();
    722723    }
    723 // </editor-fold>
    724 
    725 // <editor-fold defaultstate="collapsed" desc="Helper functions">
    726 
    727     private Node getNearestNode(Point point, double maxDist) {
    728        Node nd = Main.map.mapView.getNearestNode(point, OsmPrimitive.isSelectablePredicate);
    729        if (nd!=null && line.getPoint(nd.getCoor()).distance(point)<=maxDist) return nd;
    730        else return null;
    731     }
    732 
    733     LatLon getLatLon(MouseEvent e) {
    734         return mv.getLatLon(e.getX(), e.getY());
    735     }
    736 // </editor-fold>
    737 
     724   
    738725    private void tryToLoadWay() {
    739726        updateCursor();
     
    749736    }
    750737
     738    private void autoCloseIfNeeded() {
     739        if (settings.drawClosed && line.getPointCount()>1 && !line.isClosed()) {
     740            line.closeLine();
     741        }
     742    }
     743// </editor-fold>
     744
     745// <editor-fold defaultstate="collapsed" desc="Helper functions">
     746
     747    private Node getNearestNode(Point point, double maxDist) {
     748       Node nd = Main.map.mapView.getNearestNode(point, OsmPrimitive.isSelectablePredicate);
     749       if (nd!=null && line.getPoint(nd.getCoor()).distance(point)<=maxDist) return nd;
     750       else return null;
     751    }
     752
     753    LatLon getLatLon(MouseEvent e) {
     754        return mv.getLatLon(e.getX(), e.getY());
     755    }
     756// </editor-fold>
    751757
    752758}
Note: See TracChangeset for help on using the changeset viewer.