Changeset 12153 in josm


Ignore:
Timestamp:
2017-05-15T13:27:12+02:00 (2 months ago)
Author:
michael2402
Message:

Use a data counter + StringBuilder to create the data set tooltip. Add a new line after each nodes/ways/relations item.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r12152 r12153  
    108108import org.openstreetmap.josm.tools.ImageProvider;
    109109import org.openstreetmap.josm.tools.ImageProvider.ImageSizes;
    110 import org.openstreetmap.josm.tools.SubclassFilteredCollection;
    111110import org.openstreetmap.josm.tools.date.DateUtils;
    112111
     
    481480
    482481    @Override public String getToolTipText() {
    483         int nodes = new SubclassFilteredCollection<>(data.getNodes(), p -> !p.isDeleted()).size();
    484         int ways = new SubclassFilteredCollection<>(data.getWays(), p -> !p.isDeleted()).size();
    485         int rels = new SubclassFilteredCollection<>(data.getRelations(), p -> !p.isDeleted()).size();
    486 
    487         String tool = trn("{0} node", "{0} nodes", nodes, nodes)+", ";
    488         tool += trn("{0} way", "{0} ways", ways, ways)+", ";
    489         tool += trn("{0} relation", "{0} relations", rels, rels);
     482        DataCountVisitor counter = new DataCountVisitor();
     483        for (final OsmPrimitive osm : data.allPrimitives()) {
     484            osm.accept(counter);
     485        }
     486        int nodes = counter.nodes - counter.deletedNodes;
     487        int ways = counter.ways - counter.deletedWays;
     488        int rels = counter.relations - counter.deletedRelations;
     489
     490        StringBuilder tooltip = new StringBuilder();
     491        tooltip.append("<html>");
     492        tooltip.append(trn("{0} node", "{0} nodes", nodes, nodes));
     493        tooltip.append("<br>");
     494        tooltip.append(trn("{0} way", "{0} ways", ways, ways));
     495        tooltip.append("<br>");
     496        tooltip.append(trn("{0} relation", "{0} relations", rels, rels));
    490497
    491498        File f = getAssociatedFile();
    492499        if (f != null) {
    493             tool = "<html>"+tool+"<br>"+f.getPath()+"</html>";
    494         }
    495         return tool;
     500            tooltip.append("<br>");
     501            tooltip.append(f.getPath());
     502        }
     503        tooltip.append("</html>");
     504        return tooltip.toString();
    496505    }
    497506
Note: See TracChangeset for help on using the changeset viewer.