Ignore:
Timestamp:
2009-11-14T21:37:38+01:00 (14 years ago)
Author:
jttt
Message:
  • removed mappaintVisibleCode from OsmPrimitive (should not be necessary now when MappaintVisitor use QuadBuckets.search())
  • moved OsmPrimitive.errors to Dataset (it was waste of memory)
Location:
trunk/src/org/openstreetmap/josm/data/osm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/DataSet.java

    r2450 r2452  
    233233        allPrimitives.remove(primitive);
    234234        primitive.setDataset(null);
     235        errors.remove(primitive);
    235236        firePrimitivesRemoved(Collections.singletonList(primitive));
    236237    }
     
    871872        allPrimitives.clear();
    872873    }
     874
     875
     876    // TODO Should be part of validator
     877    // This used to be OsmPrimitive.errors. I don't really like that such information is kept here,
     878    // but at least it's not such memory waste as having it in (every) OsmPrimitive
     879    private Map<OsmPrimitive, List<String>> errors = new HashMap<OsmPrimitive, List<String>>();
     880
     881    void setErrors(OsmPrimitive primitive, List<String> errors) {
     882        if (errors != null && !errors.isEmpty()) {
     883            this.errors.put(primitive, errors);
     884        } else {
     885            this.errors.remove(primitive);
     886        }
     887    }
     888
     889    public List<String> getErrors(OsmPrimitive primitive) {
     890        return errors.get(primitive);
     891    }
    873892}
  • trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    r2450 r2452  
    9797    /* mappaint data */
    9898    public ElemStyle mappaintStyle = null;
    99     public Integer mappaintVisibleCode = 0;
    10099    public Integer mappaintDrawnCode = 0;
    101     public Collection<String> errors;
    102 
    103     public void putError(String text, Boolean isError)
     100
     101    public void putError(String text, boolean isError)
    104102    {
    105         if(errors == null) {
     103        checkDataset();
     104        List<String> errors = dataSet.getErrors(this);
     105        if (errors == null) {
    106106            errors = new ArrayList<String>();
    107107        }
    108108        String s = isError ? tr("Error: {0}", text) : tr("Warning: {0}", text);
    109109        errors.add(s);
     110        dataSet.setErrors(this, errors);
    110111    }
    111112    public void clearErrors()
    112113    {
    113         errors = null;
     114        if (dataSet != null) {
     115            dataSet.setErrors(this, null);
     116        }
     117    }
     118
     119    public List<String> getErrors() {
     120        if (dataSet == null)
     121            return null;
     122        else
     123            return dataSet.getErrors(this);
    114124    }
    115125    /* This should not be called from outside. Fixing the UI to add relevant
     
    118128    protected void clearCached()
    119129    {
    120         mappaintVisibleCode = 0;
    121130        mappaintDrawnCode = 0;
    122131        mappaintStyle = null;
     
    798807        user= osm.user;
    799808        clearCached();
    800         clearErrors();
    801809    }
    802810
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java

    r2450 r2452  
    148148                (n.getEastNorth().east()  < minEN.east() ) ||
    149149                (n.getEastNorth().north() < minEN.north()))
    150         {
    151             n.mappaintVisibleCode = viewid;
    152150            return;
    153         }
    154         n.mappaintVisibleCode = 0;
    155151
    156152        IconElemStyle nodeStyle = (IconElemStyle)getPrimitiveStyle(n);
     
    186182    public void drawWay(Way w, int fillAreas) {
    187183        if(w.getNodesCount() < 2)
    188         {
    189             w.mappaintVisibleCode = viewid;
    190184            return;
    191         }
    192185
    193186        /* check, if the way is visible at all */
     
    217210                (maxx < minEN.east()) ||
    218211                (maxy < minEN.north()))
    219         {
    220             w.mappaintVisibleCode = viewid;
    221212            return;
    222         }
    223213
    224214        ElemStyle wayStyle = getPrimitiveStyle(w);
    225215
    226216        if(!isZoomOk(wayStyle))
    227         {
    228             w.mappaintVisibleCode = viewid;
    229217            return;
    230         }
    231 
    232         w.mappaintVisibleCode = 0;
     218
    233219        if(fillAreas > dist) {
    234220            w.clearErrors();
     
    540526    public void visit(Relation r) {};
    541527    public void paintUnselectedRelation(Relation r) {
    542         r.mappaintVisibleCode = 0;
    543528
    544529        if (drawMultipolygon && "multipolygon".equals(r.get("type")))
     
    10461031                }
    10471032            }
    1048             if(!visible) /* nothing visible, so disable relation and all its ways */
    1049             {
    1050                 r.mappaintVisibleCode = viewid;
    1051                 for (Way wInner : inner) {
    1052                     wInner.mappaintVisibleCode = viewid;
    1053                 }
    1054                 for (Way wOuter : outer) {
    1055                     wOuter.mappaintVisibleCode = viewid;
    1056                 }
     1033            if(!visible)
    10571034                return drawn;
    1058             }
    10591035            for (Way wInner : inner)
    10601036            {
     
    15101486            //    profilerN = 0;
    15111487            for (final Relation osm: data.getRelations()) {
    1512                 if (drawable(osm) && osm.mappaintVisibleCode != viewid) {
     1488                if (drawable(osm)) {
    15131489                    paintUnselectedRelation(osm);
    15141490                    //            profilerN++;
     
    15251501            //    profilerN = 0;
    15261502            for (final Way osm : selectedLast(data, data.searchWays(bbox))) {
    1527                 if (drawable(osm)
    1528                         && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid) {
     1503                if (drawable(osm) && osm.mappaintDrawnCode != paintid) {
    15291504                    if (isPrimitiveArea(osm) && osm.mappaintDrawnAreaCode != paintid) {
    15301505                        drawWay(osm, fillAreas);
     
    15601535            //    profilerN = 0;
    15611536            for (final Way way: data.getWays()) {
    1562                 if (drawable(way) && !data.isSelected(way)
    1563                         && way.mappaintVisibleCode != viewid) {
     1537                if (drawable(way) && !data.isSelected(way)) {
    15641538                    drawWay(way, 0);
    15651539                    //            profilerN++;
     
    15791553        for (final OsmPrimitive osm : data.getSelected()) {
    15801554            if (!osm.incomplete && !osm.isDeleted() && !(osm instanceof Node)
    1581                     && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid
     1555                    && osm.mappaintDrawnCode != paintid
    15821556            ) {
    15831557                osm.visit(new AbstractVisitor() {
     
    15941568                        //if(profilerOmitDraw)
    15951569                        //    return;
    1596                         r.mappaintVisibleCode = 0;
    15971570                        for (RelationMember m : r.getMembers()) {
    15981571                            if (m.isNode() && drawable(m.getMember())) {
     
    16191592        for (final Node osm: data.searchNodes(bbox)) {
    16201593            if (!osm.incomplete && !osm.isDeleted() && (data.isSelected(osm) || !osm.isFiltered())
    1621                     && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid)
     1594                    && osm.mappaintDrawnCode != paintid)
    16221595            {
    16231596                drawNode(osm);
     
    16381611            currentColor = nodeColor;
    16391612            for (final OsmPrimitive osm: data.searchWays(bbox)) {
    1640                 if (osm.isUsable() && !osm.isFiltered()
    1641                         && osm.mappaintVisibleCode != viewid )
     1613                if (osm.isUsable() && !osm.isFiltered())
    16421614                {
    16431615                    /* TODO: move this into the SimplePaint code? */
Note: See TracChangeset for help on using the changeset viewer.