Ignore:
Timestamp:
2018-05-21T20:42:27+02:00 (6 years ago)
Author:
Don-vip
Message:

support rendering of IPrimitive

File:
1 edited

Legend:

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

    r13636 r13810  
    1212import java.util.Optional;
    1313
     14import org.openstreetmap.josm.data.osm.IPrimitive;
    1415import org.openstreetmap.josm.data.osm.Node;
    15 import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1616import org.openstreetmap.josm.data.osm.Relation;
    1717import org.openstreetmap.josm.data.osm.Way;
     
    4545 * There are several steps to derive the list of elements for display:
    4646 * <ol>
    47  * <li>{@link #generateStyles(OsmPrimitive, double, boolean)} applies the
     47 * <li>{@link #generateStyles(IPrimitive, double, boolean)} applies the
    4848 * {@link StyleSource}s one after another to get a key-value map of MapCSS
    4949 * properties. Then a preliminary set of StyleElements is derived from the
    5050 * properties map.</li>
    51  * <li>{@link #getImpl(OsmPrimitive, double, NavigatableComponent)} handles the
     51 * <li>{@link #getImpl(IPrimitive, double, NavigatableComponent)} handles the
    5252 * different forms of multipolygon tagging.</li>
    53  * <li>{@link #getStyleCacheWithRange(OsmPrimitive, double, NavigatableComponent)}
     53 * <li>{@link #getStyleCacheWithRange(IPrimitive, double, NavigatableComponent)}
    5454 * adds a default StyleElement for primitives that would be invisible otherwise.
    5555 * (For example untagged nodes and ways.)</li>
     
    131131     * @param nc display component
    132132     * @return list of styles
    133      */
    134     public StyleElementList get(OsmPrimitive osm, double scale, NavigatableComponent nc) {
     133     * @since 13810 (signature)
     134     */
     135    public StyleElementList get(IPrimitive osm, double scale, NavigatableComponent nc) {
    135136        return getStyleCacheWithRange(osm, scale, nc).a;
    136137    }
     
    145146     * @param nc navigatable component
    146147     * @return pair containing style list and range
    147      */
    148     public Pair<StyleElementList, Range> getStyleCacheWithRange(OsmPrimitive osm, double scale, NavigatableComponent nc) {
     148     * @since 13810 (signature)
     149     */
     150    public Pair<StyleElementList, Range> getStyleCacheWithRange(IPrimitive osm, double scale, NavigatableComponent nc) {
    149151        if (!osm.isCachedStyleUpToDate() || scale <= 0) {
    150152            osm.setCachedStyle(StyleCache.EMPTY_STYLECACHE);
     
    232234     * @return pair containing style list and range
    233235     */
    234     private Pair<StyleElementList, Range> getImpl(OsmPrimitive osm, double scale, NavigatableComponent nc) {
     236    private Pair<StyleElementList, Range> getImpl(IPrimitive osm, double scale, NavigatableComponent nc) {
    235237        if (osm instanceof Node)
    236238            return generateStyles(osm, scale, false);
     
    242244
    243245            // FIXME: Maybe in the future outer way styles apply to outers ignoring the multipolygon?
    244             for (OsmPrimitive referrer : osm.getReferrers()) {
     246            for (IPrimitive referrer : osm.getReferrers()) {
    245247                Relation r = (Relation) referrer;
    246248                if (!drawMultipolygon || !r.isMultipolygon() || !r.isUsable()) {
     
    310312            if (!isDefaultLines()) return p;
    311313
    312             for (OsmPrimitive referrer : osm.getReferrers()) {
     314            for (IPrimitive referrer : osm.getReferrers()) {
    313315                Relation ref = (Relation) referrer;
    314316                if (!drawMultipolygon || !ref.isMultipolygon() || !ref.isUsable()) {
     
    362364     * outer ways of a multipolygon.
    363365     * @return the generated styles and the valid range as a pair
    364      */
    365     public Pair<StyleElementList, Range> generateStyles(OsmPrimitive osm, double scale, boolean pretendWayIsClosed) {
     366     * @since 13810 (signature)
     367     */
     368    public Pair<StyleElementList, Range> generateStyles(IPrimitive osm, double scale, boolean pretendWayIsClosed) {
    366369
    367370        List<StyleElement> sl = new ArrayList<>();
     
    522525     * outer ways of a multipolygon.
    523526     * @return first AreaElement found or {@code null}.
    524      */
    525     public static AreaElement getAreaElemStyle(OsmPrimitive p, boolean pretendWayIsClosed) {
     527     * @since 13810 (signature)
     528     */
     529    public static AreaElement getAreaElemStyle(IPrimitive p, boolean pretendWayIsClosed) {
    526530        MapCSSStyleSource.STYLE_SOURCE_LOCK.readLock().lock();
    527531        try {
     
    545549     * outer ways of a multipolygon.
    546550     * @return {@code true} if primitive has an AreaElement
    547      */
    548     public static boolean hasAreaElemStyle(OsmPrimitive p, boolean pretendWayIsClosed) {
     551     * @since 13810 (signature)
     552     */
     553    public static boolean hasAreaElemStyle(IPrimitive p, boolean pretendWayIsClosed) {
    549554        return getAreaElemStyle(p, pretendWayIsClosed) != null;
    550555    }
     
    558563     * @return {@code true} if primitive has area elements, but no line elements
    559564     * @since 12700
    560      */
    561     public static boolean hasOnlyAreaElements(OsmPrimitive p) {
     565     * @since 13810 (signature)
     566     */
     567    public static boolean hasOnlyAreaElements(IPrimitive p) {
    562568        MapCSSStyleSource.STYLE_SOURCE_LOCK.readLock().lock();
    563569        try {
Note: See TracChangeset for help on using the changeset viewer.