Ignore:
Timestamp:
2018-06-13T01:33:47+02:00 (6 years ago)
Author:
Don-vip
Message:

add AbstractOsmDataLayer, MainLayerManager.getActiveData, Main.getInProgressISelection

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDataText.java

    r13761 r13926  
    1515import org.openstreetmap.josm.data.osm.BBox;
    1616import org.openstreetmap.josm.data.osm.DataSet;
    17 import org.openstreetmap.josm.data.osm.Node;
     17import org.openstreetmap.josm.data.osm.INode;
     18import org.openstreetmap.josm.data.osm.IPrimitive;
     19import org.openstreetmap.josm.data.osm.IRelation;
     20import org.openstreetmap.josm.data.osm.IRelationMember;
     21import org.openstreetmap.josm.data.osm.IWay;
     22import org.openstreetmap.josm.data.osm.OsmData;
    1823import org.openstreetmap.josm.data.osm.OsmPrimitive;
    19 import org.openstreetmap.josm.data.osm.Relation;
    20 import org.openstreetmap.josm.data.osm.RelationMember;
    2124import org.openstreetmap.josm.data.osm.Way;
    2225import org.openstreetmap.josm.data.projection.proj.TransverseMercator;
     
    3639
    3740    private final StringBuilder s = new StringBuilder();
    38     private final DataSet ds;
    39 
    40     InspectPrimitiveDataText(DataSet ds) {
     41    private final OsmData<?, ?, ?, ?> ds;
     42
     43    InspectPrimitiveDataText(OsmData<?, ?, ?, ?> ds) {
    4144        this.ds = ds;
    4245    }
     
    6366     * @param o primitive to add
    6467     */
    65     public void addPrimitive(OsmPrimitive o) {
     68    public void addPrimitive(IPrimitive o) {
    6669
    6770        addHeadline(o);
     
    8285        addSpecial(o);
    8386        addReferrers(s, o);
    84         addConflicts(o);
     87        if (o instanceof OsmPrimitive) {
     88            addConflicts((OsmPrimitive) o);
     89        }
    8590        s.append(NL);
    8691    }
    8792
    88     void addHeadline(OsmPrimitive o) {
     93    void addHeadline(IPrimitive o) {
    8994        addType(o);
    9095        addNameAndId(o);
    9196    }
    9297
    93     void addType(OsmPrimitive o) {
    94         if (o instanceof Node) {
     98    void addType(IPrimitive o) {
     99        if (o instanceof INode) {
    95100            s.append(tr("Node: "));
    96         } else if (o instanceof Way) {
     101        } else if (o instanceof IWay) {
    97102            s.append(tr("Way: "));
    98         } else if (o instanceof Relation) {
     103        } else if (o instanceof IRelation) {
    99104            s.append(tr("Relation: "));
    100105        }
    101106    }
    102107
    103     void addNameAndId(OsmPrimitive o) {
     108    void addNameAndId(IPrimitive o) {
    104109        String name = o.get("name");
    105110        if (name == null) {
     
    110115    }
    111116
    112     void addState(OsmPrimitive o) {
     117    void addState(IPrimitive o) {
    113118        StringBuilder sb = new StringBuilder(INDENT);
    114119        /* selected state is left out: not interesting as it is always selected */
     
    141146    }
    142147
    143     void addCommon(OsmPrimitive o) {
     148    void addCommon(IPrimitive o) {
    144149        add(tr("Data Set: "), Integer.toHexString(o.getDataSet().hashCode()));
    145150        add(tr("Edited at: "), o.isTimestampEmpty() ? tr("<new object>")
     
    151156    }
    152157
    153     void addAttributes(OsmPrimitive o) {
     158    void addAttributes(IPrimitive o) {
    154159        if (o.hasKeys()) {
    155160            add(tr("Tags: "));
     
    161166    }
    162167
    163     void addSpecial(OsmPrimitive o) {
    164         if (o instanceof Node) {
    165             addCoordinates((Node) o);
    166         } else if (o instanceof Way) {
     168    void addSpecial(IPrimitive o) {
     169        if (o instanceof INode) {
     170            addCoordinates((INode) o);
     171        } else if (o instanceof IWay) {
    167172            addBbox(o);
    168173            add(tr("Centroid: "),
    169174                    toStringCSV(", ", Main.getProjection().eastNorth2latlon(
    170175                            Geometry.getCentroid(((Way) o).getNodes()))));
    171             addWayNodes((Way) o);
    172         } else if (o instanceof Relation) {
     176            addWayNodes((IWay<?>) o);
     177        } else if (o instanceof IRelation) {
    173178            addBbox(o);
    174             addRelationMembers((Relation) o);
    175         }
    176     }
    177 
    178     void addRelationMembers(Relation r) {
     179            addRelationMembers((IRelation<?>) o);
     180        }
     181    }
     182
     183    void addRelationMembers(IRelation<?> r) {
    179184        add(trn("{0} Member: ", "{0} Members: ", r.getMembersCount(), r.getMembersCount()));
    180         for (RelationMember m : r.getMembers()) {
     185        for (IRelationMember<?> m : r.getMembers()) {
    181186            s.append(INDENT).append(INDENT);
    182187            addHeadline(m.getMember());
     
    186191    }
    187192
    188     void addWayNodes(Way w) {
     193    void addWayNodes(IWay<?> w) {
    189194        add(tr("{0} Nodes: ", w.getNodesCount()));
    190         for (Node n : w.getNodes()) {
     195        for (INode n : w.getNodes()) {
    191196            s.append(INDENT).append(INDENT);
    192197            addNameAndId(n);
     
    195200    }
    196201
    197     void addBbox(OsmPrimitive o) {
     202    void addBbox(IPrimitive o) {
    198203        BBox bbox = o.getBBox();
    199204        if (bbox != null) {
     
    210215    }
    211216
    212     void addCoordinates(Node n) {
     217    void addCoordinates(INode n) {
    213218        if (n.isLatLonKnown()) {
    214219            add(tr("Coordinates:"), " ",
     
    225230    }
    226231
    227     void addReferrers(StringBuilder s, OsmPrimitive o) {
    228         List<OsmPrimitive> refs = o.getReferrers();
     232    void addReferrers(StringBuilder s, IPrimitive o) {
     233        List<? extends IPrimitive> refs = o.getReferrers();
    229234        if (!refs.isEmpty()) {
    230235            add(tr("Part of: "));
    231             for (OsmPrimitive p : refs) {
     236            for (IPrimitive p : refs) {
    232237                s.append(INDENT).append(INDENT);
    233238                addHeadline(p);
     
    238243
    239244    void addConflicts(OsmPrimitive o) {
    240         Conflict<?> c = ds.getConflicts().getConflictForMy(o);
     245        Conflict<?> c = ((DataSet) ds).getConflicts().getConflictForMy(o);
    241246        if (c != null) {
    242247            add(tr("In conflict with: "));
Note: See TracChangeset for help on using the changeset viewer.