Ignore:
Timestamp:
2011-02-06T10:19:47+01:00 (14 years ago)
Author:
bastiK
Message:

LineElemStyle refactoring (more caching and additional properties)

File:
1 edited

Legend:

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

    r3859 r3860  
    100100    }
    101101
    102     public void drawWay(Way way, Color color, float width, float dashed[], float dashesOffset, Color dashedColor, boolean showDirection,
     102    public void drawWay(Way way, Color color, BasicStroke line, BasicStroke dashes, Color dashedColor, boolean showDirection,
    103103            boolean reversedDirection, boolean showHeadArrowOnly) {
    104104
     
    156156            lastPoint = p;
    157157        }
    158         displaySegments(path, arrows, color, width, dashed, dashesOffset, dashedColor);
    159     }
    160 
    161     private void displaySegments(GeneralPath path, GeneralPath arrows, Color color, float width, float dashed[], float dashesOffset, Color dashedColor) {
     158        displaySegments(path, arrows, color, line, dashes, dashedColor);
     159    }
     160
     161    private void displaySegments(GeneralPath path, GeneralPath arrows, Color color, BasicStroke line, BasicStroke dashes, Color dashedColor) {
    162162        g.setColor(inactive ? inactiveColor : color);
    163163        if (useStrokes) {
    164             if (dashed != null && dashed.length > 0) {
    165                 g.setStroke(new BasicStroke(width,BasicStroke.CAP_BUTT,BasicStroke.JOIN_ROUND,0,dashed,dashesOffset));
    166             } else {
    167                 g.setStroke(new BasicStroke(width,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
    168             }
     164            g.setStroke(line);
    169165        }
    170166        g.draw(path);
    171167        g.draw(arrows);
    172168
    173         if(!inactive && useStrokes && dashedColor != null) {
     169        if(!inactive && useStrokes && dashes != null) {
    174170            g.setColor(dashedColor);
    175             if (dashed != null && dashed.length > 0) {
    176                 float[] dashedOffset = new float[dashed.length];
    177                 System.arraycopy(dashed, 0, dashedOffset, 1, dashed.length - 1);
    178                 dashedOffset[0] = dashed[dashed.length-1];
    179                 float offset = dashedOffset[0] + dashesOffset;
    180                 g.setStroke(new BasicStroke(width,BasicStroke.CAP_BUTT,BasicStroke.JOIN_ROUND,0,dashedOffset, offset));
    181             } else {
    182                 g.setStroke(new BasicStroke(width,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
    183             }
     171            g.setStroke(dashes);
    184172            g.draw(path);
    185173            g.draw(arrows);
Note: See TracChangeset for help on using the changeset viewer.