Ignore:
Timestamp:
2011-01-31T14:18:47+01:00 (15 years ago)
Author:
bastiK
Message:

mappaint restructuring aimed at mapcss support:

  • area- and line style of multipolygon outer & inner ways are no longer determined by MapPaintVisitor, but the information is calculated in advance and cached
  • cache is aware of zoom level
  • z_index property to allow more fancy styles in future

Performance: when the style cache is filled, painting is the same or ~5% faster. The first painting, which includes style generation, takes ~30% longer than before. (There is potential for optimization, though.) Memory usage unchanged.

File:
1 edited

Legend:

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

    r3824 r3836  
    55
    66import org.openstreetmap.josm.data.osm.OsmPrimitive;
     7import org.openstreetmap.josm.data.osm.Relation;
    78import org.openstreetmap.josm.data.osm.Way;
    89import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings;
     
    1415    public Color color;
    1516
    16     public AreaElemStyle(long minScale, long maxScale, Color color) {
    17         super(minScale, maxScale);
     17    protected AreaElemStyle(Cascade c, Color color) {
     18        super(c);
    1819        this.color = color;
     20    }
     21
     22    public static AreaElemStyle create(Cascade c) {
     23        Color color = c.get("fill-color", null, Color.class);
     24        if (color == null)
     25            return null;
     26        return new AreaElemStyle(c, color);
    1927    }
    2028
     
    2533            String name = painter.isShowNames() ? painter.getAreaName(w) : null;
    2634            painter.drawArea(w, w.isSelected() ? paintSettings.getSelectedColor() : color, name);
    27             // line.paintPrimitive(way, paintSettings, painter, selected);
     35        } else if (primitive instanceof Relation) {
     36            painter.drawArea((Relation) primitive, selected ? paintSettings.getRelationSelectedColor() : color, painter.getAreaName(primitive));
    2837        }
    2938    }
     
    4049    @Override
    4150    public int hashCode() {
    42         return color.hashCode();
     51        return 11 * super.hashCode() + color.hashCode();
    4352    }
    4453
    4554    @Override
    4655    public String toString() {
    47         return "AreaElemStyle{" + "color=" + color + '}';
     56        return "AreaElemStyle{" + super.toString() + "color=" + color + '}';
    4857    }
    4958}
Note: See TracChangeset for help on using the changeset viewer.