Ignore:
Timestamp:
2009-01-25T18:27:54+01:00 (15 years ago)
Author:
ulfl
Message:

add a mappaint "dashedcolour", which controls the background color of a dashed line

File:
1 edited

Legend:

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

    r1333 r1340  
    5555    protected Color textColor;
    5656    protected int currentDashed = 0;
     57    protected Color currentDashedColor;
    5758    protected int currentWidth = 0;
    5859    protected Stroke currentStroke = null;
     
    247248        int realWidth = 0; //the real width of the element in meters
    248249        int dashed = 0;
     250        Color dashedColor = null;
    249251        Node lastN;
    250252
     
    255257            realWidth = l.realWidth;
    256258            dashed = l.dashed;
     259            dashedColor = l.dashedColor;
    257260        }
    258261        if(selected)
     
    279282                        {
    280283                            drawSeg(lastN, n, s.color != null  && !w.selected ? s.color : color,
    281                             false, s.getWidth(width), s.dashed);
     284                            false, s.getWidth(width), s.dashed, s.dashedColor);
    282285                        }
    283286                        lastN = n;
     
    295298            if(lastN != null)
    296299                drawSeg(lastN, n, color,
    297                     showOnlyHeadArrowOnly ? !it.hasNext() : showDirection, width, dashed);
     300                    showOnlyHeadArrowOnly ? !it.hasNext() : showDirection, width, dashed, dashedColor);
    298301            lastN = n;
    299302        }
     
    312315                        {
    313316                            drawSeg(lastN, n, s.color != null && !w.selected ? s.color : color,
    314                             false, s.getWidth(width), s.dashed);
     317                            false, s.getWidth(width), s.dashed, s.dashedColor);
    315318                        }
    316319                        lastN = n;
     
    10841087    }
    10851088
    1086     private void drawSeg(Node n1, Node n2, Color col, boolean showDirection, int width, int dashed) {
     1089    private void drawSeg(Node n1, Node n2, Color col, boolean showDirection, int width, int dashed, Color dashedColor) {
    10871090        profilerSegments++;
    1088         if (col != currentColor || width != currentWidth || dashed != currentDashed) {
    1089             displaySegments(col, width, dashed);
     1091        if (col != currentColor || width != currentWidth || dashed != currentDashed || dashedColor != currentDashedColor) {
     1092            displaySegments(col, width, dashed, dashedColor);
    10901093        }
    10911094        Point p1 = nc.getPoint(n1.eastNorth);
     
    11081111
    11091112    protected void displaySegments() {
    1110         displaySegments(null, 0, 0);
    1111     }
    1112 
    1113     protected void displaySegments(Color newColor, int newWidth, int newDash) {
     1113        displaySegments(null, 0, 0, null);
     1114    }
     1115
     1116    protected void displaySegments(Color newColor, int newWidth, int newDash, Color newDashedColor) {
    11141117        if (currentPath != null) {
    11151118            Graphics2D g2d = (Graphics2D)g;
     
    11221125            }
    11231126            g2d.draw(currentPath);
     1127
     1128            if(currentDashedColor != null) {
     1129                g2d.setColor(currentDashedColor);
     1130                if (currentStroke == null && useStrokes > dist) {
     1131                    if (currentDashed != 0)
     1132                        g2d.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_BUTT,BasicStroke.JOIN_ROUND,0,new float[] {currentDashed},currentDashed));
     1133                    else
     1134                        g2d.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
     1135                }
     1136                g2d.draw(currentPath);
     1137            }
     1138           
    11241139            if(useStrokes > dist)
    11251140                g2d.setStroke(new BasicStroke(1));
     
    11291144            currentWidth = newWidth;
    11301145            currentDashed = newDash;
     1146            currentDashedColor = newDashedColor;
    11311147            currentStroke = null;
    11321148        }
Note: See TracChangeset for help on using the changeset viewer.