Ignore:
Timestamp:
2015-12-11T17:36:59+01:00 (8 years ago)
Author:
bastiK
Message:

mapcss partial fill: move threshold parameter ([9063]) into the mapcss style
(new property fill-extent-threshold)

  • add support for this parameter when area is unclosed
  • smaller extent for unclosed areas

(see #12104)

Location:
trunk/src/org/openstreetmap/josm/gui/mappaint
Files:
4 edited

Legend:

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

    r9008 r9099  
    2626    public TextElement text;
    2727    public Float extent;
     28    public Float extentThreshold;
    2829
    29     protected AreaElemStyle(Cascade c, Color color, MapImage fillImage, Float extent, TextElement text) {
     30    protected AreaElemStyle(Cascade c, Color color, MapImage fillImage, Float extent, Float extentThreshold, TextElement text) {
    3031        super(c, 1f);
    3132        CheckParameterUtil.ensureParameterNotNull(color);
    3233        this.color = color;
     34        this.fillImage = fillImage;
    3335        this.extent = extent;
    34         this.fillImage = fillImage;
     36        this.extentThreshold = extentThreshold;
    3537        this.text = text;
    3638    }
     
    3941        final Cascade c = env.mc.getCascade(env.layer);
    4042        MapImage fillImage = null;
    41         Color color = null;
    42         Float extent = null;
     43        Color color;
    4344
    4445        IconReference iconRef = c.get(FILL_IMAGE, null, IconReference.class);
     
    8182        }
    8283
    83         extent = c.get(FILL_EXTENT, null, float.class);
     84        Float extent = c.get(FILL_EXTENT, null, float.class);
     85        Float extentThreshold = c.get(FILL_EXTENT_THRESHOLD, null, float.class);
    8486
    8587        if (color != null)
    86             return new AreaElemStyle(c, color, fillImage, extent, text);
     88            return new AreaElemStyle(c, color, fillImage, extent, extentThreshold, text);
    8789        else
    8890            return null;
     
    101103                }
    102104            }
    103             painter.drawArea((Way) osm, myColor, fillImage, extent, painter.isInactiveMode() || osm.isDisabled(), text);
     105            painter.drawArea((Way) osm, myColor, fillImage, extent, extentThreshold, painter.isInactiveMode() || osm.isDisabled(), text);
    104106        } else if (osm instanceof Relation) {
    105107            if (color != null && (selected || outermember)) {
    106108                myColor = paintSettings.getRelationSelectedColor(color.getAlpha());
    107109            }
    108             painter.drawArea((Relation) osm, myColor, fillImage, extent, painter.isInactiveMode() || osm.isDisabled(), text);
     110            painter.drawArea((Relation) osm, myColor, fillImage, extent, extentThreshold, painter.isInactiveMode() || osm.isDisabled(), text);
    109111        }
    110112    }
     
    124126        if (extent != other.extent)
    125127            return false;
     128        if (extentThreshold != other.extentThreshold)
     129            return false;
    126130        if (!Objects.equals(text, other.text))
    127131            return false;
     
    134138        hash = 61 * hash + color.hashCode();
    135139        hash = 61 * hash + (extent != null ? Float.floatToIntBits(extent) : 0);
     140        hash = 61 * hash + (extentThreshold != null ? Float.floatToIntBits(extent) : 0);
    136141        hash = 61 * hash + (fillImage != null ? fillImage.hashCode() : 0);
    137142        hash = 61 * hash + (text != null ? text.hashCode() : 0);
  • trunk/src/org/openstreetmap/josm/gui/mappaint/StyleKeys.java

    r9005 r9099  
    1111    String FILL_COLOR = "fill-color";
    1212    String FILL_EXTENT = "fill-extent";
     13    String FILL_EXTENT_THRESHOLD = "fill-extent-threshold";
    1314    String FILL_IMAGE = "fill-image";
    1415    String FILL_OPACITY = "fill-opacity";
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Condition.java

    r9087 r9099  
    633633            return IN_DOWNLOADED_AREA.evaluate(e.osm);
    634634        }
     635
     636        static boolean completely_downloaded(Environment e) {
     637            if (e.osm instanceof Relation) {
     638                return !((Relation) e.osm).hasIncompleteMembers();
     639            } else {
     640                return true;
     641            }
     642        }
     643
     644        static boolean closed2(Environment e) {
     645            if (e.osm instanceof Way && ((Way) e.osm).isClosed())
     646                return true;
     647            if (e.osm instanceof Relation && ((Relation) e.osm).isMultipolygon())
     648                return MultipolygonCache.getInstance().get(Main.map.mapView, (Relation) e.osm).getOpenEnds().isEmpty();
     649            return false;
     650        }
    635651    }
    636652
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParser.jj

    r8874 r9099  
    204204|   < ELEMENT_OF: "∈" >
    205205|   < CROSSING: "⧉" >
     206|   < PERCENT: "%" >
    206207|   < COMMENT_START: "/*" > : COMMENT
    207208|   < UNEXPECTED_CHAR : ~[] > // avoid TokenMgrErrors because they are hard to recover from
     
    11261127}
    11271128{
    1128     f=ufloat() ( u=ident() | <DEG> { u = "°"; } )
     1129    f=ufloat() ( u=ident() | <DEG> { u = "°"; } | <PERCENT> { u = "%"; } )
    11291130    {
    11301131        Double m = unit_factor(u);
     
    11431144        case "grad": return Math.PI / 200;
    11441145        case "turn": return 2 * Math.PI;
     1146        case "%": return 0.01;
    11451147        case "px": return 1.;
    11461148        case "cm": return 96/2.54;
Note: See TracChangeset for help on using the changeset viewer.