Ignore:
Timestamp:
2011-02-09T19:13:04+01:00 (13 years ago)
Author:
bastiK
Message:

mapcss: improve shape & area style generation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/NodeElemStyle.java

    r3871 r3879  
    240240            return null;
    241241
    242         Float size = c.get("symbol-size", null, Float.class);
    243         if (size == null || size <= 0)
     242        float size = c.get("symbol-size", 10f, Float.class);
     243        if (size <= 0)
    244244            return null;
    245245
    246246        Float strokeWidth = c.get("symbol-stroke-width", null, Float.class);
     247        if (strokeWidth != null && strokeWidth <= 0) {
     248            strokeWidth = null;
     249        }
    247250        Color strokeColor = c.get("symbol-stroke-color", null, Color.class);
     251
     252        if (strokeWidth == null && strokeColor != null) {
     253            strokeWidth = 1f;
     254        } else if (strokeWidth != null && strokeColor == null) {
     255            strokeColor = Color.ORANGE;
     256        }
     257
     258        Stroke stroke = null;
    248259        if (strokeColor != null) {
    249260            float strokeAlpha = c.get("symbol-stroke-opacity", 1f, Float.class);
    250261            strokeColor = new Color(strokeColor.getRed(), strokeColor.getGreen(),
    251262                    strokeColor.getBlue(), Utils.color_float2int(strokeAlpha));
    252         }
    253         Stroke stroke = null;
    254         if (strokeWidth != null && strokeWidth > 0 && strokeColor != null) {
    255263            stroke = new BasicStroke(strokeWidth);
    256264        }
    257265
    258266        Color fillColor = c.get("symbol-fill-color", null, Color.class);
     267        if (stroke == null && fillColor == null)
     268            fillColor = Color.BLUE;
     269
    259270        if (fillColor != null) {
    260271            float fillAlpha = c.get("symbol-fill-opacity", 1f, Float.class);
     
    263274        }
    264275
    265         if ((stroke == null || strokeColor == null) && fillColor == null)
    266             return null;
    267 
    268         return new Symbol(shape, size.intValue(), stroke, strokeColor, fillColor);
     276        return new Symbol(shape, Math.round(size), stroke, strokeColor, fillColor);
    269277    }
    270278
     
    277285                        Utils.color_int2float(iconAlpha), selected, member, text);
    278286            } else if (symbol != null) {
    279                 painter.drawNodeSymbol(n, symbol, selected, member, text);
     287                Color fillColor = symbol.fillColor;
     288                if (fillColor != null) {
     289                    if (n.isHighlighted()) {
     290                        fillColor = settings.getHighlightColor();
     291                    } else {
     292                        if (painter.isInactive() || n.isDisabled()) {
     293                            fillColor = settings.getInactiveColor();
     294                        } else if (selected) {
     295                            fillColor = settings.getSelectedColor(fillColor.getAlpha());
     296                        } else if (member) {
     297                            fillColor = settings.getRelationSelectedColor(fillColor.getAlpha());
     298                        }
     299                    }
     300                }
     301                Color strokeColor = symbol.strokeColor;
     302                if (strokeColor != null) {
     303                    if (n.isHighlighted()) {
     304                        strokeColor = settings.getHighlightColor();
     305                    } else {
     306                        if (painter.isInactive() || n.isDisabled()) {
     307                            strokeColor = settings.getInactiveColor();
     308                        } else if (selected) {
     309                            strokeColor = settings.getSelectedColor(strokeColor.getAlpha());
     310                        } else if (member) {
     311                            strokeColor = settings.getRelationSelectedColor(strokeColor.getAlpha());
     312                        }
     313                    }
     314                }
     315                painter.drawNodeSymbol(n, symbol, fillColor, strokeColor, text);
    280316            } else {
    281317                if (n.isHighlighted()) {
Note: See TracChangeset for help on using the changeset viewer.