Ignore:
Timestamp:
2013-04-01T19:03:38+02:00 (12 years ago)
Author:
akks
Message:

'JOSM/FastDraw: line stroke and point size customization'

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

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/FastDraw/src/org/openstreetmap/josm/plugins/fastdraw/FDSettings.java

    r29453 r29457  
    22
    33import java.awt.Color;
     4import java.awt.Stroke;
    45import java.io.IOException;
    56import org.openstreetmap.josm.Main;
     7import org.openstreetmap.josm.gui.util.GuiHelper;
    68import static org.openstreetmap.josm.tools.I18n.tr;
    79
     
    3638    public boolean drawClosed;
    3739    public int simplifyMode;
    38     public float lineWidth;
    3940    public String autoTags;
     41    public Stroke normalStroke;
     42    public Stroke simplifiedStroke;
     43    public Stroke deleteStroke;
     44    public int dotSize;
     45    public int bigDotSize;
    4046   
    4147    public void loadPrefs() {
     
    4652        COLOR_SELECTEDFRAGMENT = Main.pref.getColor("fastdraw.color.select", Color.blue);
    4753        COLOR_SIMPLIFIED = Main.pref.getColor("fastdraw.color.simplified", Color.orange);
     54       
     55        normalStroke = GuiHelper.getCustomizedStroke(Main.pref.get("fastdraw.stroke.normal", "2"));
     56        deleteStroke = GuiHelper.getCustomizedStroke(Main.pref.get("fastdraw.stroke.delete", "3"));
     57        simplifiedStroke = GuiHelper.getCustomizedStroke(Main.pref.get("fastdraw.stroke.simplified", "2"));
     58       
     59        bigDotSize = Main.pref.getInteger("fastdraw.point.bigsize", 7);
     60        dotSize = Main.pref.getInteger("fastdraw.point.normalsize", 5);
     61       
    4862        maxDist = Main.pref.getDouble("fastdraw.maxdist", 5);
    4963        epsilonMult = Main.pref.getDouble("fastdraw.epsilonmult", 1.1);
     
    5973        drawClosed =  Main.pref.getBoolean("fastdraw.drawclosed", false);
    6074        simplifyMode = Main.pref.getInteger("fastdraw.simplifymode", 0);
    61         lineWidth = (float) Main.pref.getDouble("fastdraw.linewidth", 2);
    6275        autoTags = Main.pref.get("fastdraw.autotags");
    6376    }
    6477
    6578    public void savePrefs() {
    66          Main.pref.putColor("fastdraw.color.delete", COLOR_DELETE );
    67          Main.pref.putColor("fastdraw.color.edit", COLOR_EDITEDFRAGMENT);
    68          Main.pref.putColor("fastdraw.color.fixed", COLOR_FIXED);
    69          Main.pref.putColor("fastdraw.color.normal", COLOR_NORMAL);
    70          Main.pref.putColor("fastdraw.color.select", COLOR_SELECTEDFRAGMENT);
    71          Main.pref.getColor("fastdraw.color.simplified", COLOR_SIMPLIFIED);
    7279         Main.pref.putDouble("fastdraw.maxdist", maxDist);
    7380         Main.pref.putDouble("fastdraw.epsilonmult", epsilonMult);
     
    8390         Main.pref.put("fastdraw.drawclosed", drawClosed);
    8491         Main.pref.putInteger("fastdraw.simplifymode", simplifyMode);
    85          Main.pref.putDouble("fastdraw.linewidth",(double)lineWidth);
    8692         Main.pref.put("fastdraw.autotags", autoTags);
    8793         try {Main.pref.save();} catch (IOException e) {
  • applications/editors/josm/plugins/FastDraw/src/org/openstreetmap/josm/plugins/fastdraw/FastDrawingMode.java

    r29453 r29457  
    88
    99import java.awt.AWTEvent;
    10 import java.awt.BasicStroke;
    1110import java.awt.Color;
    1211import java.awt.Cursor;
    1312import java.awt.Graphics2D;
    1413import java.awt.Point;
    15 import java.awt.Stroke;
    1614import java.awt.Toolkit;
    1715import java.awt.event.*;
     
    6159    private boolean shift;
    6260    private double eps;
    63     private Stroke strokeForSimplified;
    64     private Stroke strokeForOriginal;
    6561    private final Cursor cursorDraw;
    6662    private final Cursor cursorCtrl;
     
    7268    private LatLon highlighted;
    7369    private int nearestIdx;
    74     private Stroke strokeForDelete;
    7570    private int dragNode=-1;
    7671    private SequenceCommand delCmd;
     
    113108        settings.savePrefs();
    114109
    115         strokeForOriginal = new BasicStroke(settings.lineWidth);
    116         strokeForDelete = new BasicStroke(3);
    117         //strokeForSimplified = new BasicStroke(1,BasicStroke.CAP_ROUND,BasicStroke.JOIN_BEVEL,5f,
    118         //        new float[]{5.f,5f},0f);
    119         strokeForSimplified = strokeForOriginal;
    120        
    121110        eps=settings.startingEps;
    122111        mv = Main.map.mapView;
     
    187176        if (line.wasSimplified()) {
    188177            // we are drawing simplified version, that exists
    189             g.setStroke(strokeForSimplified);
     178            g.setStroke(settings.simplifiedStroke);
    190179        } else {
    191             g.setStroke(strokeForOriginal);
    192         }
    193        
     180            g.setStroke(settings.normalStroke);
     181        }
     182       
     183        int bigDotSize = settings.bigDotSize;
     184
    194185        Point p1, p2;
    195186        LatLon pp1, pp2;
    196187        p1 = line.getPoint(pts.get(0));
    197188        g.setColor(settings.COLOR_FIXED);
    198         g.fillOval(p1.x - 3, p1.y - 3, 7, 7);
     189        g.fillOval(p1.x - bigDotSize/2, p1.y - bigDotSize/2, bigDotSize, bigDotSize);
    199190        Color lineColor,initLineColor;
    200191        initLineColor = line.wasSimplified() ? settings.COLOR_SIMPLIFIED: settings.COLOR_NORMAL;
    201192        lineColor = initLineColor;
    202193        int rp,dp;
    203         dp=line.wasSimplified() ? 7:(int)(3+((int) settings.lineWidth)/2*2);  rp=dp/2;
     194        dp=line.wasSimplified() ? settings.bigDotSize : settings.dotSize;  rp=dp/2;
    204195        if (pts.size() > 1) {
    205196        Iterator<LatLon> it1,it2;
     
    218209                    lineColor=initLineColor;
    219210                    g.setColor(settings.COLOR_FIXED);
    220                     g.fillOval(p2.x - 3, p2.y - 3, 7, 7);
     211                    g.fillOval(p2.x - bigDotSize/2, p2.y - bigDotSize/2, bigDotSize, bigDotSize);
    221212                } else {
    222213                    g.fillRect(p2.x - rp, p2.y - rp, dp, dp);
     
    226217                    if (shift) {
    227218                        // highlight node to delete
    228                         g.setStroke(strokeForDelete);
     219                        g.setStroke(settings.deleteStroke);
    229220                        g.setColor(settings.COLOR_DELETE);
    230221                        g.drawLine(p2.x - 5, p2.y - 5,p2.x + 5, p2.y + 5);
    231222                        g.drawLine(p2.x - 5, p2.y + 5,p2.x + 5, p2.y - 5);
    232                         g.setStroke(strokeForOriginal);
     223                        g.setStroke(settings.normalStroke);
    233224                    } else if (ctrl) {
    234225                        // highlight node to toggle fixation
    235                         g.setStroke(strokeForDelete);
     226                        g.setStroke(settings.deleteStroke);
    236227                        g.setColor( line.isFixed(pp2) ? settings.COLOR_NORMAL: settings.COLOR_FIXED);
    237                         g.drawOval(p2.x - 5, p2.y - 5, 11, 11);
    238                         g.setStroke(strokeForOriginal);
     228                        g.fillOval(p2.x - bigDotSize/2-2, p2.y - bigDotSize/2-2, bigDotSize+4, bigDotSize+4);
     229                        g.setStroke(settings.normalStroke);
    239230                    }
    240231                    }
Note: See TracChangeset for help on using the changeset viewer.