Ignore:
Timestamp:
2014-07-14T04:18:06+02:00 (10 years ago)
Author:
donvip
Message:

[josm_plugins] fix compilation warnings

Location:
applications/editors/josm/plugins/utilsplugin2/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/utilsplugin2/src/edu/princeton/cs/algs4/EdgeWeightedDigraph.java

    r28116 r30532  
    2121 *  <i>Algorithms, 4th Edition</i> by Robert Sedgewick and Kevin Wayne.
    2222 */
    23 
    24 
    25 
    2623public class EdgeWeightedDigraph {
    2724    private final int V;
     
    3229     * Create an empty edge-weighted digraph with V vertices.
    3330     */
     31    @SuppressWarnings("unchecked")
    3432    public EdgeWeightedDigraph(int V) {
    3533        if (V < 0) throw new RuntimeException("Number of vertices must be nonnegative");
     
    102100    }
    103101
    104 
    105102   /**
    106103     * Add the edge e to this digraph.
     
    111108        E++;
    112109    }
    113 
    114110
    115111   /**
     
    144140    }
    145141
    146 
    147 
    148142   /**
    149143     * Return a string representation of this graph.
     
    162156        return s.toString();
    163157    }
    164 
    165     /**
    166      * Test client.
    167      */
    168 //    public static void main(String[] args) {
    169 //        In in = new In(args[0]);
    170 //        EdgeWeightedDigraph G = new EdgeWeightedDigraph(in);
    171 //        StdOut.println(G);
    172 //    }
    173 
    174158}
  • applications/editors/josm/plugins/utilsplugin2/src/edu/princeton/cs/algs4/IndexMinPQ.java

    r28116 r30532  
    1919    private Key[] keys;      // keys[i] = priority of i
    2020
     21    @SuppressWarnings("unchecked")
    2122    public IndexMinPQ(int NMAX) {
    2223        keys = (Key[]) new Comparable[NMAX + 1];    // make this of length NMAX??
     
    186187        }
    187188    }
    188 
    189 
    190 //    public static void main(String[] args) {
    191 //        // insert a bunch of strings
    192 //        String[] strings = { "it", "was", "the", "best", "of", "times", "it", "was", "the", "worst" };
    193 //
    194 //        IndexMinPQ<String> pq = new IndexMinPQ<String>(strings.length);
    195 //        for (int i = 0; i < strings.length; i++) {
    196 //            pq.insert(i, strings[i]);
    197 //        }
    198 //
    199 //        // delete and print each key
    200 //        while (!pq.isEmpty()) {
    201 //            int i = pq.delMin();
    202 //            StdOut.println(i + " " + strings[i]);
    203 //        }
    204 //        StdOut.println();
    205 //
    206 //        // reinsert the same strings
    207 //        for (int i = 0; i < strings.length; i++) {
    208 //            pq.insert(i, strings[i]);
    209 //        }
    210 //
    211 //        // print each key using the iterator
    212 //        for (int i : pq) {
    213 //            StdOut.println(i + " " + strings[i]);
    214 //        }
    215 //        while (!pq.isEmpty()) {
    216 //            pq.delMin();
    217 //        }
    218 //
    219 //    }
    220189}
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/customurl/ChooseURLAction.java

    r29769 r30532  
    5454        }
    5555        final JLabel label1=new JLabel(tr("Please select one of custom URLs (configured in Preferences)"));
    56         final JList list1=new JList(names);
     56        final JList<String> list1=new JList<>(names);
    5757        final JTextField editField=new JTextField();
    5858        final JCheckBox check1=new JCheckBox(tr("Ask every time"));
  • applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/replacegeometry/ReplaceGeometryUtils.java

    r30177 r30532  
    88import java.util.Arrays;
    99import java.util.Collection;
     10import java.util.Collections;
    1011import java.util.HashMap;
    1112import java.util.HashSet;
     
    1314import java.util.List;
    1415import java.util.Map;
    15 import java.util.Set;
    1616
    1717import javax.swing.JOptionPane;
     
    2424import org.openstreetmap.josm.command.DeleteCommand;
    2525import org.openstreetmap.josm.command.MoveCommand;
     26import org.openstreetmap.josm.corrector.UserCancelException;
    2627import org.openstreetmap.josm.data.coor.LatLon;
    2728import org.openstreetmap.josm.data.osm.Node;
     
    2930import org.openstreetmap.josm.data.osm.Relation;
    3031import org.openstreetmap.josm.data.osm.RelationMember;
    31 import org.openstreetmap.josm.data.osm.RelationToChildReference;
    3232import org.openstreetmap.josm.data.osm.TagCollection;
    3333import org.openstreetmap.josm.data.osm.Way;
    3434import org.openstreetmap.josm.gui.DefaultNameFormatter;
     35import org.openstreetmap.josm.gui.Notification;
    3536import org.openstreetmap.josm.gui.conflict.tags.CombinePrimitiveResolverDialog;
    36 import org.openstreetmap.josm.gui.conflict.tags.TagConflictResolutionUtil;
    3737
    3838import edu.princeton.cs.algs4.AssignmentProblem;
    39 import org.openstreetmap.josm.gui.Notification;
    40 import static org.openstreetmap.josm.tools.I18n.tr;
    4139
    4240/**
     
    4543 */
    4644public final class ReplaceGeometryUtils {
    47     private static final String TITLE = tr("Replace Geometry");
    4845    /**
    4946     * Replace new or uploaded object with new object
     
    168165
    169166        // merge tags
    170         Collection<Command> tagResolutionCommands = getTagConflictResolutionCommands(subjectNode, referenceObject);
    171         if (tagResolutionCommands == null) {
     167        try {
     168            commands.addAll(getTagConflictResolutionCommands(subjectNode, referenceObject));
     169        } catch (UserCancelException e) {
    172170            // user canceled tag merge dialog
    173171            return null;
    174172        }
    175         commands.addAll(tagResolutionCommands);
    176173
    177174        // replace sacrificial node in way with node that is being upgraded
     
    254251               
    255252        // merge tags
    256         Collection<Command> tagResolutionCommands = getTagConflictResolutionCommands(referenceWay, subjectWay);
    257         if (tagResolutionCommands == null) {
     253        try {
     254            commands.addAll(getTagConflictResolutionCommands(referenceWay, subjectWay));
     255        } catch (UserCancelException e) {
    258256            // user canceled tag merge dialog
    259257            return null;
    260258        }
    261         commands.addAll(tagResolutionCommands);
    262259       
    263260        // Prepare a list of nodes that are not used anywhere except in the way
     
    452449     * @param source object tags are merged from
    453450     * @param target object tags are merged to
    454      * @return
    455      */
    456     protected static List<Command> getTagConflictResolutionCommands(OsmPrimitive source, OsmPrimitive target) {
    457         // determine if the same key in each object has different values
    458         boolean keysWithMultipleValues;
    459         Set<OsmPrimitive> set = new HashSet<OsmPrimitive>();
    460         set.add(source);
    461         set.add(target);
    462         TagCollection tagCol = TagCollection.unionOfAllPrimitives(set);
    463         Set<String> keys = tagCol.getKeysWithMultipleValues();
    464         keysWithMultipleValues = !keys.isEmpty();
    465            
     451     * @return The list of {@link Command commands} needed to apply resolution actions.
     452     * @throws UserCancelException If the user cancelled a dialog.
     453     */
     454    protected static List<Command> getTagConflictResolutionCommands(OsmPrimitive source, OsmPrimitive target) throws UserCancelException {
    466455        Collection<OsmPrimitive> primitives = Arrays.asList(source, target);
    467        
    468         Set<RelationToChildReference> relationToNodeReferences = RelationToChildReference.getRelationToChildReferences(primitives);
    469 
    470         // build the tag collection
    471         TagCollection tags = TagCollection.unionOfAllPrimitives(primitives);
    472         TagConflictResolutionUtil.combineTigerTags(tags);
    473         TagConflictResolutionUtil.normalizeTagCollectionBeforeEditing(tags, primitives);
    474         TagCollection tagsToEdit = new TagCollection(tags);
    475         TagConflictResolutionUtil.completeTagCollectionForEditing(tagsToEdit);
    476 
    477456        // launch a conflict resolution dialog, if necessary
    478         CombinePrimitiveResolverDialog dialog = CombinePrimitiveResolverDialog.getInstance();
    479         dialog.getTagConflictResolverModel().populate(tagsToEdit, tags.getKeysWithMultipleValues());
    480         dialog.getRelationMemberConflictResolverModel().populate(relationToNodeReferences);
    481         dialog.setTargetPrimitive(target);
    482         dialog.prepareDefaultDecisions();
    483 
    484         // conflict resolution is necessary if there are conflicts in the merged tags
    485         // or if both objects have relation memberships
    486         if (keysWithMultipleValues ||
    487                 (!RelationToChildReference.getRelationToChildReferences(source).isEmpty() &&
    488                  !RelationToChildReference.getRelationToChildReferences(target).isEmpty())) {
    489             dialog.setVisible(true);
    490             if (dialog.isCanceled()) {
    491                 return null;
    492             }
    493         }
    494         return dialog.buildResolutionCommands();
    495     }
    496 
     457        return CombinePrimitiveResolverDialog.launchIfNecessary(
     458                TagCollection.unionOfAllPrimitives(primitives), primitives, Collections.singleton(target));
     459    }
    497460   
    498461    /**
Note: See TracChangeset for help on using the changeset viewer.