Ignore:
Timestamp:
2009-11-02T07:51:28+01:00 (17 years ago)
Author:
jttt
Message:

Change most occurrences of Dataset.nodes/ways/relations with getNodes()/../.. or addPrimitive

Location:
trunk/src/org/openstreetmap/josm/data
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/conflict/ConflictCollection.java

    r2181 r2381  
    5454
    5555    protected void fireConflictAdded() {
    56         Iterator<IConflictListener> it = listeners.iterator();
    57         while(it.hasNext()) {
    58             it.next().onConflictsAdded(this);
     56        for (IConflictListener listener : listeners) {
     57            listener.onConflictsAdded(this);
    5958        }
    6059    }
  • trunk/src/org/openstreetmap/josm/data/osm/BackreferencedDataSet.java

    r2181 r2381  
    105105            throw new IllegalArgumentException(tr("Parameter ''{0}'' must not be null."));
    106106        this.source = source;
    107         int size = source.ways.size() + source.relations.size();
     107        int size = source.getWays().size() + source.getRelations().size();
    108108        referers = new HashMap<OsmPrimitive, Set<OsmPrimitive>>(size, 0.75f);
    109109    }
     
    131131     */
    132132    public void build() {
    133         for (Way w: source.ways) {
    134             for (Node n: w.getNodes()) {
    135                 remember(w,n);
    136             }
    137         }
    138         for (Relation r: source.relations) {
    139             for (RelationMember m: r.getMembers()) {
     133        for (Way w : source.getWays()) {
     134            for (Node n : w.getNodes()) {
     135                remember(w, n);
     136            }
     137        }
     138        for (Relation r : source.getRelations()) {
     139            for (RelationMember m : r.getMembers()) {
    140140                remember(r, m.getMember());
    141141            }
  • trunk/src/org/openstreetmap/josm/data/osm/DataSet.java

    r2352 r2381  
    11// License: GPL. Copyright 2007 by Immanuel Scholz and others
    22package org.openstreetmap.josm.data.osm;
     3
    34import java.awt.geom.Area;
    45import java.util.ArrayList;
    56import java.util.Arrays;
    67import java.util.Collection;
     8import java.util.Collections;
    79import java.util.Comparator;
    810import java.util.HashMap;
     
    2628 */
    2729public class DataSet implements Cloneable {
    28    
     30
    2931    /**
    3032     * A list of listeners to selection changed events. The list is static, as listeners register
     
    3335     */
    3436    public static Collection<SelectionChangedListener> selListeners = new LinkedList<SelectionChangedListener>();
    35    
     37
    3638    /**
    3739     * notifies all registered selection change listeners about the current selection of
     
    5456     * All nodes goes here, even when included in other data (ways etc). This enables the instant
    5557     * conversion of the whole DataSet by iterating over this data structure.
    56      */
     58     * @deprecated Use getNodes() for read-only operations, addPrimitive() and removePrimitive() for modifications
     59     */
     60    @Deprecated
    5761    public QuadBuckets<Node> nodes = new QuadBuckets<Node>();
    5862
     63    public Collection<Node> getNodes() {
     64        return Collections.unmodifiableCollection(nodes);
     65    }
     66
    5967    /**
    6068     * All ways (Streets etc.) in the DataSet.
    6169     *
    6270     * The way nodes are stored only in the way list.
    63      */
     71     * @deprecated Use getWays() for read-only operations, addPrimitive() and removePrimitive() for modifications
     72     */
     73    @Deprecated
    6474    public QuadBuckets<Way> ways = new QuadBuckets<Way>();
    6575
     76    public Collection<Way> getWays() {
     77        return Collections.unmodifiableCollection(ways);
     78    }
     79
    6680    /**
    6781     * All relations/relationships
    68      */
     82     * @deprecated Use getRelations() for read-only operations, addPrimitive() and removePrimitive() for modifications
     83     */
     84    @Deprecated
    6985    public Collection<Relation> relations = new LinkedList<Relation>();
    7086
     87    public Collection<Relation> getRelations() {
     88        return Collections.unmodifiableCollection(relations);
     89    }
     90
    7191    /**
    7292     * All data sources of this DataSet.
    7393     */
    7494    public Collection<DataSource> dataSources = new LinkedList<DataSource>();
    75    
     95
    7696    /**
    7797     * @return A collection containing all primitives of the dataset. The data is ordered after:
     
    255275
    256276    public boolean toggleSelected(Collection<OsmPrimitive> osm) {
    257         for (OsmPrimitive o : osm)
     277        for (OsmPrimitive o : osm) {
    258278            this.__toggleSelected(o);
     279        }
    259280        fireSelectionChanged();
    260281        return true;
     
    405426
    406427    /**
    407      * Notifies all registered {@see SelectionChangedListener} about the current selection in 
     428     * Notifies all registered {@see SelectionChangedListener} about the current selection in
    408429     * this dataset.
    409430     *
     
    491512        Collection<? extends OsmPrimitive> primitives = null;
    492513        switch(type) {
    493             case NODE: primitives = nodes; break;
    494             case WAY: primitives = ways; break;
    495             case RELATION: primitives = relations; break;
     514        case NODE: primitives = nodes; break;
     515        case WAY: primitives = ways; break;
     516        case RELATION: primitives = relations; break;
    496517        }
    497518        for (OsmPrimitive primitive : primitives) {
     
    502523            OsmPrimitive result = null;
    503524            switch (type) {
    504                 case NODE: result = new Node(id, true); break;
    505                 case WAY: result = new Way(id, true); break;
    506                 case RELATION: result = new Relation(id, true); break;
     525            case NODE: result = new Node(id, true); break;
     526            case WAY: result = new Way(id, true); break;
     527            case RELATION: result = new Relation(id, true); break;
    507528            }
    508529            addPrimitive(result);
  • trunk/src/org/openstreetmap/josm/data/osm/Relation.java

    r2363 r2381  
    158158        super.load(data, dataSet);
    159159
    160         RelationData relationData = (RelationData)data;
     160        RelationData relationData = (RelationData) data;
    161161
    162162        // TODO Make this faster
     
    169169        Map<Long, Relation> relations = new HashMap<Long, Relation>();
    170170
    171         for (RelationMemberData member:relationData.getMembers()) {
     171        for (RelationMemberData member : relationData.getMembers()) {
    172172            switch (member.getMemberType()) {
    173             case NODE:
    174                 nodes.put(member.getMemberId(), nodeMarker);
    175                 break;
    176             case WAY:
    177                 ways.put(member.getMemberId(), wayMarker);
    178                 break;
    179             case RELATION:
    180                 relations.put(member.getMemberId(), relationMarker);
    181                 break;
    182             }
    183         }
    184 
    185         for (Node node:dataSet.nodes) {
     173                case NODE:
     174                    nodes.put(member.getMemberId(), nodeMarker);
     175                    break;
     176                case WAY:
     177                    ways.put(member.getMemberId(), wayMarker);
     178                    break;
     179                case RELATION:
     180                    relations.put(member.getMemberId(), relationMarker);
     181                    break;
     182            }
     183        }
     184
     185        for (Node node : dataSet.getNodes()) {
    186186            if (nodes.get(node.getUniqueId()) == nodeMarker) {
    187187                nodes.put(node.getUniqueId(), node);
    188188            }
    189189        }
    190         for (Way way:dataSet.ways) {
     190        for (Way way : dataSet.getWays()) {
    191191            if (ways.get(way.getUniqueId()) == wayMarker) {
    192192                ways.put(way.getUniqueId(), way);
    193193            }
    194194        }
    195         for (Relation relation:dataSet.relations) {
     195        for (Relation relation : dataSet.getRelations()) {
    196196            if (relations.get(relation.getUniqueId()) == relationMarker) {
    197197                relations.put(relation.getUniqueId(), relation);
     
    200200
    201201        List<RelationMember> newMembers = new ArrayList<RelationMember>();
    202         for (RelationMemberData member:relationData.getMembers()) {
     202        for (RelationMemberData member : relationData.getMembers()) {
    203203            OsmPrimitive foundMember = null;
    204204            switch (member.getMemberType()) {
    205             case NODE:
    206                 foundMember = nodes.get(member.getMemberId());
    207                 if (foundMember == nodeMarker)
    208                     throw new AssertionError("Data consistency problem - relation with missing member detected");
    209                 break;
    210             case WAY:
    211                 foundMember = ways.get(member.getMemberId());
    212                 if (foundMember == wayMarker)
    213                     throw new AssertionError("Data consistency problem - relation with missing member detected");
    214                 break;
    215             case RELATION:
    216                 foundMember = relations.get(member.getMemberId());
    217                 if (foundMember == relationMarker)
    218                     throw new AssertionError("Data consistency problem - relation with missing member detected");
    219                 break;
     205                case NODE:
     206                    foundMember = nodes.get(member.getMemberId());
     207                    if (foundMember == nodeMarker)
     208                        throw new AssertionError("Data consistency problem - relation with missing member detected");
     209                    break;
     210                case WAY:
     211                    foundMember = ways.get(member.getMemberId());
     212                    if (foundMember == wayMarker)
     213                        throw new AssertionError("Data consistency problem - relation with missing member detected");
     214                    break;
     215                case RELATION:
     216                    foundMember = relations.get(member.getMemberId());
     217                    if (foundMember == relationMarker)
     218                        throw new AssertionError("Data consistency problem - relation with missing member detected");
     219                    break;
    220220            }
    221221            newMembers.add(new RelationMember(member.getRole(), foundMember));
  • trunk/src/org/openstreetmap/josm/data/osm/TagCollection.java

    r2305 r2381  
    111111        TagCollection tags = new TagCollection();
    112112        if (ds == null) return tags;
    113         tags.add(TagCollection.unionOfAllPrimitives(ds.nodes));
    114         tags.add(TagCollection.unionOfAllPrimitives(ds.ways));
    115         tags.add(TagCollection.unionOfAllPrimitives(ds.relations));
     113        tags.add(TagCollection.unionOfAllPrimitives(ds.getNodes()));
     114        tags.add(TagCollection.unionOfAllPrimitives(ds.getWays()));
     115        tags.add(TagCollection.unionOfAllPrimitives(ds.getRelations()));
    116116        return tags;
    117117    }
  • trunk/src/org/openstreetmap/josm/data/osm/Way.java

    r2363 r2381  
    177177        super.load(data, dataSet);
    178178
    179         WayData wayData = (WayData)data;
     179        WayData wayData = (WayData) data;
    180180
    181181        // TODO We should have some lookup by id mechanism in future to speed this up
    182182        Node marker = new Node(0);
    183183        Map<Long, Node> foundNodes = new HashMap<Long, Node>();
    184         for (Long nodeId:wayData.getNodes()) {
     184        for (Long nodeId : wayData.getNodes()) {
    185185            foundNodes.put(nodeId, marker);
    186186        }
    187         for (Node node:dataSet.nodes) {
     187        for (Node node : dataSet.getNodes()) {
    188188            if (foundNodes.get(node.getUniqueId()) == marker) {
    189189                foundNodes.put(node.getUniqueId(), node);
     
    192192
    193193        List<Node> newNodes = new ArrayList<Node>(wayData.getNodes().size());
    194         for (Long nodeId:wayData.getNodes()) {
     194        for (Long nodeId : wayData.getNodes()) {
    195195            Node node = foundNodes.get(nodeId);
    196196            if (node != marker) {
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/CollectBackReferencesVisitor.java

    r2166 r2381  
    5252    }
    5353   
    54     private void makeLookupTable(){
    55        for (Way w : ds.ways) {
    56           for (Node n : w.getNodes()) {
    57              if(!lookupTable.containsKey(n)) lookupTable.put(n, new HashSet<OsmPrimitive>());
    58              lookupTable.get(n).add(w);
    59           }
    60        }
    61        for (Relation r : ds.relations) {
    62           for (RelationMember m : r.getMembers()) {
    63              OsmPrimitive o = m.getMember();
    64              if(!lookupTable.containsKey(o)) lookupTable.put(o, new HashSet<OsmPrimitive>());
    65              lookupTable.get(o).add(r);
    66           }
    67        }
     54    private void makeLookupTable() {
     55        for (Way w : ds.getWays()) {
     56            for (Node n : w.getNodes()) {
     57                if (!lookupTable.containsKey(n)) lookupTable.put(n, new HashSet<OsmPrimitive>());
     58                lookupTable.get(n).add(w);
     59            }
     60        }
     61        for (Relation r : ds.getRelations()) {
     62            for (RelationMember m : r.getMembers()) {
     63                OsmPrimitive o = m.getMember();
     64                if (!lookupTable.containsKey(o)) lookupTable.put(o, new HashSet<OsmPrimitive>());
     65                lookupTable.get(o).add(r);
     66            }
     67        }
    6868    }
    6969
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java

    r2354 r2381  
    2424import java.util.Collection;
    2525import java.util.Collections;
     26import java.util.Comparator;
    2627import java.util.Iterator;
    2728import java.util.LinkedList;
    2829import java.util.List;
    29 import java.util.TreeSet;
    30 import java.util.Comparator;
    3130
    3231import javax.swing.ImageIcon;
     
    532531    }
    533532
     533    @Override
    534534    public void visit(Relation r) {};
    535535    public void paintUnselectedRelation(Relation r) {
     
    10311031                for (PolyData pd : outerPoly) {
    10321032                    Polygon p = pd.get();
    1033                     if(!isPolygonVisible(p))
     1033                    if(!isPolygonVisible(p)) {
    10341034                        continue;
     1035                    }
    10351036
    10361037                    boolean selected = pd.selected || data.isSelected(pd.way) || data.isSelected(r);
     
    10551056                if(innerStyle == null)
    10561057                {
    1057                     if (data.isSelected(wInner))
     1058                    if (data.isSelected(wInner)) {
    10581059                        continue;
     1060                    }
    10591061                    if(zoomok && (wInner.mappaintDrawnCode != paintid
    10601062                            || outer.size() == 0))
     
    10891091                {
    10901092                    // Selected ways are drawn at the very end
    1091                     if (data.isSelected(wOuter))
     1093                    if (data.isSelected(wOuter)) {
    10921094                        continue;
     1095                    }
    10931096                    if(zoomok)
    10941097                    {
     
    11341137    protected Point2D getCentroid(Polygon p)
    11351138    {
    1136         double cx = 0.0, cy = 0.0, a = 0.0;
    1137 
    1138         // usually requires points[0] == points[npoints] and can then use i+1 instead of j.
    1139         // Faked it slowly using j.  If this is really gets used, this should be fixed.
    1140         for (int i = 0;  i < p.npoints;  i++) {
    1141             int j = i+1 == p.npoints ? 0 : i+1;
    1142             a += (p.xpoints[i] * p.ypoints[j]) - (p.ypoints[i] * p.xpoints[j]);
    1143             cx += (p.xpoints[i] + p.xpoints[j]) * (p.xpoints[i] * p.ypoints[j] - p.ypoints[i] * p.xpoints[j]);
    1144             cy += (p.ypoints[i] + p.ypoints[j]) * (p.xpoints[i] * p.ypoints[j] - p.ypoints[i] * p.xpoints[j]);
    1145         }
    1146         return new Point2D.Double(cx / (3.0*a), cy / (3.0*a));
     1139        double cx = 0.0, cy = 0.0, a = 0.0;
     1140
     1141        // usually requires points[0] == points[npoints] and can then use i+1 instead of j.
     1142        // Faked it slowly using j.  If this is really gets used, this should be fixed.
     1143        for (int i = 0;  i < p.npoints;  i++) {
     1144            int j = i+1 == p.npoints ? 0 : i+1;
     1145            a += (p.xpoints[i] * p.ypoints[j]) - (p.ypoints[i] * p.xpoints[j]);
     1146            cx += (p.xpoints[i] + p.xpoints[j]) * (p.xpoints[i] * p.ypoints[j] - p.ypoints[i] * p.xpoints[j]);
     1147            cy += (p.ypoints[i] + p.ypoints[j]) * (p.xpoints[i] * p.ypoints[j] - p.ypoints[i] * p.xpoints[j]);
     1148        }
     1149        return new Point2D.Double(cx / (3.0*a), cy / (3.0*a));
    11471150    }
    11481151
    11491152    protected double getArea(Polygon p)
    11501153    {
    1151         double sum = 0.0;
    1152 
    1153         // usually requires points[0] == points[npoints] and can then use i+1 instead of j.
    1154         // Faked it slowly using j.  If this is really gets used, this should be fixed.
    1155         for (int i = 0;  i < p.npoints;  i++) {
    1156             int j = i+1 == p.npoints ? 0 : i+1;
    1157             sum = sum + (p.xpoints[i] * p.ypoints[j]) - (p.ypoints[i] * p.xpoints[j]);
    1158         }
    1159         return Math.abs(sum/2.0);
     1154        double sum = 0.0;
     1155
     1156        // usually requires points[0] == points[npoints] and can then use i+1 instead of j.
     1157        // Faked it slowly using j.  If this is really gets used, this should be fixed.
     1158        for (int i = 0;  i < p.npoints;  i++) {
     1159            int j = i+1 == p.npoints ? 0 : i+1;
     1160            sum = sum + (p.xpoints[i] * p.ypoints[j]) - (p.ypoints[i] * p.xpoints[j]);
     1161        }
     1162        return Math.abs(sum/2.0);
    11601163    }
    11611164
     
    11681171        g.fillPolygon(polygon);
    11691172
    1170         if (showNames > dist) {
    1171             String name = getWayName(w);
    1172             if (name!=null /* && annotate */) {
    1173                 Rectangle pb = polygon.getBounds();
    1174                 FontMetrics fontMetrics = g.getFontMetrics(orderFont); // if slow, use cache
    1175                 Rectangle2D nb = fontMetrics.getStringBounds(name, g); // if slow, approximate by strlen()*maxcharbounds(font)
    1176 
    1177                 // Point2D c = getCentroid(polygon);
    1178                 // Using the Centroid is Nicer for buildings like: +--------+
    1179                 // but this needs to be fast.  As most houses are  |   42   |
    1180                 // boxes anyway, the center of the bounding box    +---++---+
    1181                 // will have to do.                                    ++
    1182                 // Centroids are not optimal either, just imagine a U-shaped house.
    1183                 // Point2D c = new Point2D.Double(pb.x + pb.width / 2.0, pb.y + pb.height / 2.0);
    1184                 // Rectangle2D.Double centeredNBounds =
    1185                 //     new Rectangle2D.Double(c.getX() - nb.getWidth()/2,
    1186                 //                            c.getY() - nb.getHeight()/2,
    1187                 //                            nb.getWidth(),
    1188                 //                            nb.getHeight());
    1189 
    1190                 Rectangle centeredNBounds = new Rectangle(pb.x + (int)((pb.width - nb.getWidth())/2.0),
    1191                                                           pb.y + (int)((pb.height - nb.getHeight())/2.0),
    1192                                                           (int)nb.getWidth(),
    1193                                                           (int)nb.getHeight());
    1194 
    1195                 //// Draw name bounding box for debugging:
    1196                 // g.setColor(new Color(255,255,0,128));
    1197                 // g.drawRect((int)centeredNBounds.getMinX(),
    1198                 //         (int)centeredNBounds.getMinY(),
    1199                 //         (int)centeredNBounds.getWidth(),
    1200                 //         (int)centeredNBounds.getHeight());
    1201 
    1202                 if ((pb.width >= nb.getWidth() && pb.height >= nb.getHeight()) && // quick check
    1203                     polygon.contains(centeredNBounds) // slow but nice
    1204                     ) {
    1205                     g.setColor(areaTextColor);
    1206                     Font defaultFont = g.getFont();
    1207                     g.setFont (orderFont);
    1208                     g.drawString (name,
    1209                                   (int)(centeredNBounds.getMinX() - nb.getMinX()),
    1210                                   (int)(centeredNBounds.getMinY() - nb.getMinY()));
    1211                     g.setFont(defaultFont);
    1212                 }
    1213             }
    1214         }
     1173        if (showNames > dist) {
     1174            String name = getWayName(w);
     1175            if (name!=null /* && annotate */) {
     1176                Rectangle pb = polygon.getBounds();
     1177                FontMetrics fontMetrics = g.getFontMetrics(orderFont); // if slow, use cache
     1178                Rectangle2D nb = fontMetrics.getStringBounds(name, g); // if slow, approximate by strlen()*maxcharbounds(font)
     1179
     1180                // Point2D c = getCentroid(polygon);
     1181                // Using the Centroid is Nicer for buildings like: +--------+
     1182                // but this needs to be fast.  As most houses are  |   42   |
     1183                // boxes anyway, the center of the bounding box    +---++---+
     1184                // will have to do.                                    ++
     1185                // Centroids are not optimal either, just imagine a U-shaped house.
     1186                // Point2D c = new Point2D.Double(pb.x + pb.width / 2.0, pb.y + pb.height / 2.0);
     1187                // Rectangle2D.Double centeredNBounds =
     1188                //     new Rectangle2D.Double(c.getX() - nb.getWidth()/2,
     1189                //                            c.getY() - nb.getHeight()/2,
     1190                //                            nb.getWidth(),
     1191                //                            nb.getHeight());
     1192
     1193                Rectangle centeredNBounds = new Rectangle(pb.x + (int)((pb.width - nb.getWidth())/2.0),
     1194                        pb.y + (int)((pb.height - nb.getHeight())/2.0),
     1195                        (int)nb.getWidth(),
     1196                        (int)nb.getHeight());
     1197
     1198                //// Draw name bounding box for debugging:
     1199                // g.setColor(new Color(255,255,0,128));
     1200                // g.drawRect((int)centeredNBounds.getMinX(),
     1201                //         (int)centeredNBounds.getMinY(),
     1202                //         (int)centeredNBounds.getWidth(),
     1203                //         (int)centeredNBounds.getHeight());
     1204
     1205                if ((pb.width >= nb.getWidth() && pb.height >= nb.getHeight()) && // quick check
     1206                        polygon.contains(centeredNBounds) // slow but nice
     1207                ) {
     1208                    g.setColor(areaTextColor);
     1209                    Font defaultFont = g.getFont();
     1210                    g.setFont (orderFont);
     1211                    g.drawString (name,
     1212                            (int)(centeredNBounds.getMinX() - nb.getMinX()),
     1213                            (int)(centeredNBounds.getMinY() - nb.getMinY()));
     1214                    g.setFont(defaultFont);
     1215                }
     1216            }
     1217        }
    12151218    }
    12161219
    12171220    protected String getWayName(Way w) {
    1218         String name = null;
    1219         if (w.hasKeys()) {
    1220             for (String rn : regionalNameOrder) {
    1221                 name = w.get(rn);
    1222                 if (name != null) {
    1223                     break;
    1224                 }
    1225             }
    1226         }
    1227         return name;
     1221        String name = null;
     1222        if (w.hasKeys()) {
     1223            for (String rn : regionalNameOrder) {
     1224                name = w.get(rn);
     1225                if (name != null) {
     1226                    break;
     1227                }
     1228            }
     1229        }
     1230        return name;
    12281231    }
    12291232
     
    14101413        ArrayList<T> sorted = new ArrayList<T>(prims);
    14111414        Collections.sort(sorted,
    1412             new Comparator<T>() {
    1413                 public int compare(T o1, T o2) {
    1414                     boolean s1 = data.isSelected(o1);
    1415                     boolean s2 = data.isSelected(o2);
    1416                     if (s1 && !s2)
    1417                         return 1;
    1418                     if (!s1 && s2)
    1419                         return -1;
    1420                     return o1.compareTo(o2);
    1421                 }
    1422             });
     1415                new Comparator<T>() {
     1416            public int compare(T o1, T o2) {
     1417                boolean s1 = data.isSelected(o1);
     1418                boolean s2 = data.isSelected(o2);
     1419                if (s1 && !s2)
     1420                    return 1;
     1421                if (!s1 && s2)
     1422                    return -1;
     1423                return o1.compareTo(o2);
     1424            }
     1425        });
    14231426        return sorted;
    14241427    }
     
    14311434        //profilerOmitDraw = Main.pref.getBoolean("mappaint.profiler.omitdraw",false);
    14321435
    1433         useStyleCache = Main.pref.getBoolean("mappaint.cache",true);
     1436        useStyleCache = Main.pref.getBoolean("mappaint.cache", true);
    14341437        int fillAreas = Main.pref.getInteger("mappaint.fillareas", 10000000);
    14351438        fillAlpha = Math.min(255, Math.max(0, Integer.valueOf(Main.pref.getInteger("mappaint.fillalpha", 50))));
     
    14371440        showIcons = Main.pref.getInteger("mappaint.showicons", 10000000);
    14381441        useStrokes = Main.pref.getInteger("mappaint.strokes", 10000000);
    1439         LatLon ll1 = nc.getLatLon(0,0);
    1440         LatLon ll2 = nc.getLatLon(100,0);
     1442        LatLon ll1 = nc.getLatLon(0, 0);
     1443        LatLon ll2 = nc.getLatLon(100, 0);
    14411444        dist = ll1.greatCircleDistance(ll2);
    14421445
     
    14521455
    14531456        getSettings(virtual);
    1454         useRealWidth = Main.pref.getBoolean("mappaint.useRealWidth",false);
    1455         zoomLevelDisplay = Main.pref.getBoolean("mappaint.zoomLevelDisplay",false);
     1457        useRealWidth = Main.pref.getBoolean("mappaint.useRealWidth", false);
     1458        zoomLevelDisplay = Main.pref.getBoolean("mappaint.zoomLevelDisplay", false);
    14561459        circum = Main.map.mapView.getDist100Pixel();
    14571460        styles = MapPaintStyles.getStyles().getStyleSet();
    1458         drawMultipolygon = Main.pref.getBoolean("mappaint.multipolygon",true);
    1459         drawRestriction = Main.pref.getBoolean("mappaint.restriction",true);
     1461        drawMultipolygon = Main.pref.getBoolean("mappaint.multipolygon", true);
     1462        drawRestriction = Main.pref.getBoolean("mappaint.restriction", true);
    14601463        //restrictionDebug = Main.pref.getBoolean("mappaint.restriction.debug",false);
    1461         leftHandTraffic = Main.pref.getBoolean("mappaint.lefthandtraffic",false);
    1462         orderFont = new Font(Main.pref.get("mappaint.font","Helvetica"), Font.PLAIN, Main.pref.getInteger("mappaint.fontsize", 8));
    1463         String[] names = {"name:"+LanguageInfo.getJOSMLocaleCode(), "name", "int_name", "ref", "operator", "brand","addr:housenumber"};
     1464        leftHandTraffic = Main.pref.getBoolean("mappaint.lefthandtraffic", false);
     1465        orderFont = new Font(Main.pref.get("mappaint.font", "Helvetica"), Font.PLAIN, Main.pref.getInteger("mappaint.fontsize", 8));
     1466        String[] names = {"name:" + LanguageInfo.getJOSMLocaleCode(), "name", "int_name", "ref", "operator", "brand", "addr:housenumber"};
    14641467        regionalNameOrder = Main.pref.getCollection("mappaint.nameOrder", Arrays.asList(names));
    1465         minEN = nc.getEastNorth(0,nc.getHeight()-1);
    1466         maxEN = nc.getEastNorth(nc.getWidth()-1,0);
     1468        minEN = nc.getEastNorth(0, nc.getHeight() - 1);
     1469        maxEN = nc.getEastNorth(nc.getWidth() - 1, 0);
    14671470
    14681471
     
    14871490            /*** RELATIONS ***/
    14881491            //    profilerN = 0;
    1489             for (final Relation osm : data.relations)
    1490             {
    1491                 if(drawable(osm) && osm.mappaintVisibleCode != viewid)
    1492                 {
     1492            for (final Relation osm: data.getRelations()) {
     1493                if (drawable(osm) && osm.mappaintVisibleCode != viewid) {
    14931494                    paintUnselectedRelation(osm);
    14941495                    //            profilerN++;
     
    15041505            /*** AREAS ***/
    15051506            //    profilerN = 0;
    1506             for (final Way osm : selectedLast(data, data.ways)) {
     1507            for (final Way osm : selectedLast(data, data.getWays())) {
    15071508                if (drawable(osm)
    1508                         && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid)
    1509                 {
    1510                     if(isPrimitiveArea(osm) && osm.mappaintDrawnAreaCode != paintid)
    1511                     {
     1509                        && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid) {
     1510                    if (isPrimitiveArea(osm) && osm.mappaintDrawnAreaCode != paintid) {
    15121511                        drawWay(osm, fillAreas);
    15131512                        //                profilerN++;
    15141513                    }// else {
    1515                         noAreaWays.add(osm);
     1514                    noAreaWays.add(osm);
    15161515                    //}
    15171516                }
     
    15271526            /*** WAYS ***/
    15281527            //    profilerN = 0;
    1529             for (final Way osm : noAreaWays)
    1530             {
     1528            for (final Way osm : noAreaWays) {
    15311529                drawWay(osm, 0);
    15321530                //        profilerN++;
     
    15391537            //        profilerLast = java.lang.System.currentTimeMillis();
    15401538            //    }
    1541         }
    1542         else
    1543         {
     1539        } else {
    15441540            /*** WAYS (filling disabled)  ***/
    15451541            //    profilerN = 0;
    1546             for (final Way way : data.ways)
     1542            for (final Way way: data.getWays()) {
    15471543                if (drawable(way) && !data.isSelected(way)
    1548                         && way.mappaintVisibleCode != viewid )
    1549                 {
     1544                        && way.mappaintVisibleCode != viewid) {
    15501545                    drawWay(way, 0);
    15511546                    //            profilerN++;
    15521547                }
     1548            }
    15531549
    15541550            //    if(profiler)
     
    15651561            if (!osm.incomplete && !osm.isDeleted() && !(osm instanceof Node)
    15661562                    && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid
    1567                     )
    1568             {
     1563            ) {
    15691564                osm.visit(new AbstractVisitor() {
    15701565                    public void visit(Way w) {
    15711566                        drawWay(w, 0);
    15721567                    }
     1568
    15731569                    public void visit(Node n) {
    15741570                        drawNode(n);
    15751571                    }
     1572
    15761573                    public void visit(Relation r) {
    15771574                        /* TODO: is it possible to do this like the nodes/ways code? */
     
    16011598        /*** NODES ***/
    16021599        //profilerN = 0;
    1603         for (final Node osm : data.nodes)
     1600        for (final Node osm: data.getNodes()) {
    16041601            if (!osm.incomplete && !osm.isDeleted() && (data.isSelected(osm) || !osm.isFiltered())
    16051602                    && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid)
     
    16081605                //        profilerN++;
    16091606            }
     1607        }
    16101608
    16111609        //if(profiler)
     
    16171615
    16181616        /*** VIRTUAL  ***/
    1619         if (virtualNodeSize != 0)
    1620         {
     1617        if (virtualNodeSize != 0) {
    16211618            //    profilerN = 0;
    16221619            currentColor = nodeColor;
    1623             for (final OsmPrimitive osm : data.ways)
     1620            for (final OsmPrimitive osm: data.getWays()) {
    16241621                if (osm.isUsable() && !osm.isFiltered()
    16251622                        && osm.mappaintVisibleCode != viewid )
     
    16301627                    //            profilerN++;
    16311628                }
     1629            }
    16321630
    16331631            //    if(profiler)
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/MergeSourceBuildingVisitor.java

    r2273 r2381  
    228228        for (OsmPrimitive primitive : mappedPrimitives.keySet()) {
    229229            OsmPrimitive clone = mappedPrimitives.get(primitive);
    230             if (clone instanceof Node) {
    231                 hull.nodes.add((Node)clone);
    232             } else if (clone instanceof Way) {
    233                 hull.ways.add((Way)clone);
    234             } else if (clone instanceof Relation) {
    235                 hull.relations.add((Relation)clone);
    236             }
     230            hull.addPrimitive(clone);
    237231        }
    238232    }
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/MergeVisitor.java

    r2303 r2381  
    1 // License: GPL. Copyright 2007 by Immanuel Scholz and others
    21package org.openstreetmap.josm.data.osm.visitor;
    32
     
    6059        this.theirDataSet = theirDataSet;
    6160
    62         for (Node n : myDataSet.nodes) if (!n.isNew()) {
    63             nodeshash.put(n.getId(), n);
    64         }
    65         for (Way w : myDataSet.ways) if (!w.isNew()) {
    66             wayshash.put(w.getId(), w);
    67         }
    68         for (Relation r : myDataSet.relations) if (!r.isNew()) {
    69             relshash.put(r.getId(), r);
     61        for (Node n : myDataSet.getNodes()) {
     62            if (!n.isNew()) {
     63                nodeshash.put(n.getId(), n);
     64            }
     65        }
     66        for (Way w : myDataSet.getWays()) {
     67            if (!w.isNew()) {
     68                wayshash.put(w.getId(), w);
     69            }
     70        }
     71        for (Relation r : myDataSet.getRelations()) {
     72            if (!r.isNew()) {
     73                relshash.put(r.getId(), r);
     74            }
    7075        }
    7176        conflicts = new ConflictCollection();
     
    162167     */
    163168    public void fixReferences() {
    164         for (Way w : myDataSet.ways) {
     169        for (Way w : myDataSet.getWays()) {
    165170            fixWay(w);
    166171            fixIncomplete(w);
    167172        }
    168         for (Relation r : myDataSet.relations) {
     173        for (Relation r : myDataSet.getRelations()) {
    169174            fixRelation(r);
    170175        }
    171176        for (OsmPrimitive osm : conflicts.getMyConflictParties())
    172177            if (osm instanceof Way) {
    173                 fixWay((Way)osm);
     178                fixWay((Way) osm);
    174179            } else if (osm instanceof Relation) {
    175180                fixRelation((Relation) osm);
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java

    r2264 r2381  
    150150           require changing the colour while painting... */
    151151        //profilerN = 0;
    152         for (final OsmPrimitive osm : data.relations)
     152        for (final OsmPrimitive osm: data.getRelations()) {
     153            if (!osm.isDeleted() && !ds.isSelected(osm) && !osm.isFiltered()) {
     154                osm.visit(this);
     155                //        profilerN++;
     156            }
     157        }
     158
     159        //if(profiler)
     160        //{
     161        //    System.out.format("Relations: %4dms, n=%5d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN);
     162        //    profilerLast = java.lang.System.currentTimeMillis();
     163        //}
     164
     165        //profilerN = 0;
     166        for (final OsmPrimitive osm:data.getWays()){
     167            if (!osm.isDeleted() && !ds.isSelected(osm) && !osm.isFiltered() && osm.isTagged()) {
     168                osm.visit(this);
     169                //        profilerN++;
     170            }
     171        }
     172        displaySegments();
     173
     174        for (final OsmPrimitive osm:data.getWays()){
     175            if (!osm.isDeleted() && !ds.isSelected(osm) && !osm.isFiltered() && !osm.isTagged()) {
     176                osm.visit(this);
     177                //        profilerN++;
     178            }
     179        }
     180        displaySegments();
     181
     182        //if(profiler)
     183        //{
     184        //    System.out.format("Ways     : %4dms, n=%5d\n",
     185        //        (java.lang.System.currentTimeMillis()-profilerLast), profilerN);
     186        //    profilerLast = java.lang.System.currentTimeMillis();
     187        //}
     188
     189        //profilerN = 0;
     190        for (final OsmPrimitive osm : data.getSelected())
     191            if (!osm.isDeleted()) {
     192                osm.visit(this);
     193                //        profilerN++;
     194            }
     195        displaySegments();
     196
     197        //if(profiler)
     198        //{
     199        //    System.out.format("Selected : %4dms, n=%5d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN);
     200        //    profilerLast = java.lang.System.currentTimeMillis();
     201        //}
     202
     203        //profilerN = 0;
     204        for (final OsmPrimitive osm: data.getNodes()) {
    153205            if (!osm.isDeleted() && !ds.isSelected(osm) && !osm.isFiltered())
    154206            {
     
    156208                //        profilerN++;
    157209            }
    158 
    159         //if(profiler)
    160         //{
    161         //    System.out.format("Relations: %4dms, n=%5d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN);
    162         //    profilerLast = java.lang.System.currentTimeMillis();
    163         //}
    164 
    165         //profilerN = 0;
    166         for (final OsmPrimitive osm : data.ways)
    167             if (!osm.isDeleted() && !ds.isSelected(osm) && !osm.isFiltered() && osm.isTagged())
    168             {
    169                 osm.visit(this);
    170                 //        profilerN++;
    171             }
    172         displaySegments();
    173 
    174         for (final OsmPrimitive osm : data.ways)
    175             if (!osm.isDeleted() && !ds.isSelected(osm) && !osm.isFiltered() && !osm.isTagged())
    176             {
    177                 osm.visit(this);
    178                 //        profilerN++;
    179             }
    180         displaySegments();
    181 
    182         //if(profiler)
    183         //{
    184         //    System.out.format("Ways     : %4dms, n=%5d\n",
    185         //        (java.lang.System.currentTimeMillis()-profilerLast), profilerN);
    186         //    profilerLast = java.lang.System.currentTimeMillis();
    187         //}
    188 
    189         //profilerN = 0;
    190         for (final OsmPrimitive osm : data.getSelected())
    191             if (!osm.isDeleted())
    192             {
    193                 osm.visit(this);
    194                 //        profilerN++;
    195             }
    196         displaySegments();
    197 
    198         //if(profiler)
    199         //{
    200         //    System.out.format("Selected : %4dms, n=%5d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN);
    201         //    profilerLast = java.lang.System.currentTimeMillis();
    202         //}
    203 
    204         //profilerN = 0;
    205         for (final OsmPrimitive osm : data.nodes)
    206             if (!osm.isDeleted() && !ds.isSelected(osm) && !osm.isFiltered())
    207             {
    208                 osm.visit(this);
    209                 //        profilerN++;
    210             }
     210        }
    211211
    212212        //if(profiler)
     
    217217        //}
    218218
    219         if(virtualNodeSize != 0)
    220         {
     219        if (virtualNodeSize != 0) {
    221220            //    profilerN = 0;
    222221            currentColor = nodeColor;
    223             for (final OsmPrimitive osm : data.ways)
    224                 if (!osm.isDeleted() && !osm.isDisabled() && !osm.isFiltered())
    225                 {
    226                     visitVirtual((Way)osm);
     222            for (final OsmPrimitive osm:data.getWays()){
     223                if (!osm.isDeleted() && !osm.isDisabled() && !osm.isFiltered()) {
     224                    visitVirtual((Way) osm);
    227225                    //                profilerN++;
    228226                }
     227            }
    229228            displaySegments();
    230229
Note: See TracChangeset for help on using the changeset viewer.