Ticket #12634: patch-validation-layer-color.patch

File patch-validation-layer-color.patch, 3.1 KB (added by michael2402, 9 years ago)
  • src/org/openstreetmap/josm/data/validation/PaintVisitor.java

    diff --git a/src/org/openstreetmap/josm/data/validation/PaintVisitor.java b/src/org/openstreetmap/josm/data/validation/PaintVisitor.java
    index 42c0b9b..795b6c1 100644
    a b public class PaintVisitor extends AbstractVisitor implements ValidatorVisitor {  
    120120
    121121        if (!paintedPoints.contains(pp)) {
    122122            Point p = mv.getPoint(n);
    123             g.setColor(color);
    124123
    125124            if (selected) {
     125                g.setColor(getHighlightColor());
    126126                g.fillOval(p.x - 5, p.y - 5, 10, 10);
    127             } else {
    128                 g.drawOval(p.x - 5, p.y - 5, 10, 10);
    129127            }
     128            g.setColor(color);
     129            g.drawOval(p.x - 5, p.y - 5, 10, 10);
    130130            paintedPoints.add(pp);
    131131        }
    132132    }
    public class PaintVisitor extends AbstractVisitor implements ValidatorVisitor {  
    139139     * @param color The color
    140140     */
    141141    protected void drawSegment(Point p1, Point p2, Color color) {
    142         g.setColor(color);
    143142
    144143        double t = Math.atan2(p2.x - p1.x, p2.y - p1.y);
    145144        double cosT = 5 * Math.cos(t);
    146145        double sinT = 5 * Math.sin(t);
    147146        int deg = (int) Math.toDegrees(t);
    148147        if (selected) {
     148            g.setColor(getHighlightColor());
    149149            int[] x = new int[] {(int) (p1.x + cosT), (int) (p2.x + cosT),
    150150                                 (int) (p2.x - cosT), (int) (p1.x - cosT)};
    151151            int[] y = new int[] {(int) (p1.y - sinT), (int) (p2.y - sinT),
    public class PaintVisitor extends AbstractVisitor implements ValidatorVisitor {  
    153153            g.fillPolygon(x, y, 4);
    154154            g.fillArc(p1.x - 5, p1.y - 5, 10, 10, deg,  180);
    155155            g.fillArc(p2.x - 5, p2.y - 5, 10, 10, deg, -180);
    156         } else {
    157             g.drawLine((int) (p1.x + cosT), (int) (p1.y - sinT),
    158                        (int) (p2.x + cosT), (int) (p2.y - sinT));
    159             g.drawLine((int) (p1.x - cosT), (int) (p1.y + sinT),
    160                        (int) (p2.x - cosT), (int) (p2.y + sinT));
    161             g.drawArc(p1.x - 5, p1.y - 5, 10, 10, deg,  180);
    162             g.drawArc(p2.x - 5, p2.y - 5, 10, 10, deg, -180);
    163156        }
     157        g.setColor(color);
     158        g.drawLine((int) (p1.x + cosT), (int) (p1.y - sinT),
     159                (int) (p2.x + cosT), (int) (p2.y - sinT));
     160        g.drawLine((int) (p1.x - cosT), (int) (p1.y + sinT),
     161                (int) (p2.x - cosT), (int) (p2.y + sinT));
     162        g.drawArc(p1.x - 5, p1.y - 5, 10, 10, deg,  180);
     163        g.drawArc(p2.x - 5, p2.y - 5, 10, 10, deg, -180);
    164164    }
    165165
    166166    /**
    public class PaintVisitor extends AbstractVisitor implements ValidatorVisitor {  
    258258    }
    259259
    260260    /**
     261     * Gets the color to draw highlight markers with.
     262     * @return The color.
     263     */
     264    private Color getHighlightColor() {
     265        return new Color(color.getRed(), color.getGreen(), color.getBlue(), (int) (color.getAlpha() * .4));
     266    }
     267
     268    /**
    261269     * Clears the internal painted objects collections.
    262270     */
    263271    public void clearPaintedObjects() {