Changeset 6035 in josm


Ignore:
Timestamp:
2013-06-27T11:35:15+02:00 (11 years ago)
Author:
akks
Message:

Allow customization of highlight width (mappaint.highlight.*)
+ wider highlight when map (or some button) is not focused

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java

    r5835 r6035  
    55import java.awt.BasicStroke;
    66import java.awt.Color;
     7import java.awt.Component;
    78import java.awt.Font;
    89import java.awt.FontMetrics;
     
    2829import java.util.Iterator;
    2930import java.util.List;
    30 
     31import javax.swing.AbstractButton;
     32import javax.swing.FocusManager;
    3133import javax.swing.ImageIcon;
    3234
     
    319321
    320322    private Collection<WaySegment> highlightWaySegments;
     323   
     324    // highlight customization fields
     325    private int highlightLineWidth;
     326    private int highlightPointRadius;
     327    private int widerHighlight;
     328    private int highlightStep;
     329   
     330    //flag that activate wider highlight mode
     331    private boolean useWiderHighlight;
    321332
    322333    private boolean useStrokes;
     
    331342    public StyledMapRenderer(Graphics2D g, NavigatableComponent nc, boolean isInactiveMode) {
    332343        super(g, nc, isInactiveMode);
     344
     345        if (nc!=null) {
     346            Component focusOwner = FocusManager.getCurrentManager().getFocusOwner();
     347            useWiderHighlight = !(focusOwner instanceof AbstractButton || focusOwner == nc);
     348        }
    333349    }
    334350
     
    732748        if (selected || member)
    733749        {
    734             Color color = null;
     750            Color color;
    735751            if (isInactiveMode || n.isDisabled()) {
    736752                color = inactiveColor;
     
    845861            return;
    846862        g.setColor(highlightColorTransparent);
    847         float w = (line.getLineWidth() + 4);
     863        float w = (line.getLineWidth() + highlightLineWidth);
     864        if (useWiderHighlight) w+=widerHighlight;
    848865        while(w >= line.getLineWidth()) {
    849866            g.setStroke(new BasicStroke(w, line.getEndCap(), line.getLineJoin(), line.getMiterLimit()));
    850867            g.draw(path);
    851             w -= 4;
     868            w -= highlightStep;
    852869        }
    853870    }
     
    858875    private void drawPointHighlight(Point p, int size) {
    859876        g.setColor(highlightColorTransparent);
    860         int s = size + 7;
     877        int s = size + highlightPointRadius;
     878        if (useWiderHighlight) s+=widerHighlight;
    861879        while(s >= size) {
    862880            int r = (int) Math.floor(s/2);
    863881            g.fillRoundRect(p.x-r, p.y-r, s, s, r, r);
    864             s -= 4;
    865         }
    866     }
    867 
     882            s -= highlightStep;
     883        }
     884    }
     885   
    868886    public void drawRestriction(Image img, Point pVia, double vx, double vx2, double vy, double vy2, double angle, boolean selected) {
    869887        /* rotate image with direction last node in from to */
     
    966984
    967985        /* find the "direct" nodes before the via node */
    968         Node fromNode = null;
     986        Node fromNode;
    969987        if(fromWay.firstNode() == via) {
    970988            fromNode = fromWay.getNode(1);
     
    13051323                Main.pref.getBoolean("mappaint.use-antialiasing", true) ?
    13061324                        RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF);
     1325
     1326        highlightLineWidth = Main.pref.getInteger("mappaint.highlight.width", 4);
     1327        highlightPointRadius = Main.pref.getInteger("mappaint.highlight.radius", 7);
     1328        widerHighlight = Main.pref.getInteger("mappaint.highlight.bigger-increment", 5);
     1329        highlightStep = Main.pref.getInteger("mappaint.highlight.step", 4);
    13071330    }
    13081331
Note: See TracChangeset for help on using the changeset viewer.