Changeset 1340 in josm for trunk/src/org


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

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

Location:
trunk/src/org/openstreetmap/josm
Files:
3 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        }
  • trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyleHandler.java

    r1333 r1340  
    110110                    }               
    111111                }
    112             } else if(atts.getQName(count).equals("priority"))
     112            } else if (atts.getQName(count).equals("dashedcolour"))
     113                line.dashedColor=convertColor(atts.getValue(count));
     114            else if(atts.getQName(count).equals("priority"))
    113115                line.priority = Integer.parseInt(atts.getValue(count));
    114116            else if(atts.getQName(count).equals("mode"))
  • trunk/src/org/openstreetmap/josm/gui/mappaint/LineElemStyle.java

    r1333 r1340  
    1010    public Color color;
    1111    public int dashed;
     12    public Color dashedColor;
    1213
    1314    public boolean over;
     
    2223        this.color = s.color;
    2324        this.dashed = s.dashed;
     25        this.dashedColor = s.dashedColor;
    2426        this.over = s.over;
    2527        this.widthMode = s.widthMode;
     
    3537        this.color = s.color;
    3638        this.dashed = s.dashed;
     39        this.dashedColor = s.dashedColor;
    3740        this.over = s.over;
    3841        this.widthMode = s.widthMode;
     
    5558        realWidth = 0;
    5659        dashed = 0;
     60        dashedColor = null;
    5761        priority = 0;
    5862        color = null;
Note: See TracChangeset for help on using the changeset viewer.