Changeset 5481 in josm


Ignore:
Timestamp:
2012-08-28T00:16:35+02:00 (12 years ago)
Author:
stoecker
Message:

some cleanup, mainly javadoc

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/build.xml

    r5392 r5481  
    140140                windowtitle="JOSM"
    141141                use="true"
     142                private="true"
    142143                linksource="true"
    143144                author="false">
  • trunk/src/org/openstreetmap/josm/Main.java

    r5460 r5481  
    1616import java.net.URI;
    1717import java.net.URISyntaxException;
     18import java.text.MessageFormat;
    1819import java.util.ArrayList;
    1920import java.util.Collection;
     
    151152    public MainMenu menu;
    152153
     154    /**
     155     * The data validation handler.
     156     */
    153157    public OsmValidator validator;
    154158    /**
     
    158162
    159163    /**
    160      * Print a message if logging is on.
     164     * Logging level (3 = debug, 2 = info, 1 = warn, 0 = none).
    161165     */
    162166    static public int log_level = 2;
     167    /**
     168     * Print a warning message if logging is on.
     169     * @param msg The message to print.
     170     */
    163171    static public void warn(String msg) {
    164172        if (log_level < 1)
     
    166174        System.out.println(msg);
    167175    }
     176    /**
     177     * Print an informational message if logging is on.
     178     * @param msg The message to print.
     179     */
    168180    static public void info(String msg) {
    169181        if (log_level < 2)
     
    171183        System.out.println(msg);
    172184    }
     185    /**
     186     * Print an debug message if logging is on.
     187     * @param msg The message to print.
     188     */
    173189    static public void debug(String msg) {
    174190        if (log_level < 3)
    175191            return;
    176192        System.out.println(msg);
     193    }
     194    /**
     195     * Print a formated warning message if logging is on. Calls {@link MessageFormat#format}
     196     * function to format text.
     197     * @param msg The formated message to print.
     198     * @param objects The objects to insert into format string.
     199     */
     200    static public void warn(String msg, Object... objects) {
     201        warn(MessageFormat.format(msg, objects));
     202    }
     203    /**
     204     * Print a formated informational message if logging is on. Calls {@link MessageFormat#format}
     205     * function to format text.
     206     * @param msg The formated message to print.
     207     * @param objects The objects to insert into format string.
     208     */
     209    static public void info(String msg, Object... objects) {
     210        info(MessageFormat.format(msg, objects));
     211    }
     212    /**
     213     * Print a formated debug message if logging is on. Calls {@link MessageFormat#format}
     214     * function to format text.
     215     * @param msg The formated message to print.
     216     * @param objects The objects to insert into format string.
     217     */
     218    static public void debug(String msg, Object... objects) {
     219        debug(MessageFormat.format(msg, objects));
    177220    }
    178221
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMergeModel.java

    r5266 r5481  
    2626 * the deleted or visible state of {@link OsmPrimitive}s.
    2727 *
    28  * This model is an {@link Observable}. It notifies registered {@link Observer}s whenever the
     28 * This model is an {@link Observable}. It notifies registered {@link java.util.Observer}s whenever the
    2929 * internal state changes.
    3030 *
     
    3333 *
    3434 * @see Node#getCoor()
    35  * @see OsmPrimitive#deleted
    36  * @see OsmPrimitive#visible
     35 * @see OsmPrimitive#isDeleted
     36 * @see OsmPrimitive#isVisible
    3737 *
    3838 */
     
    120120
    121121    /**
    122      * populates the model with the differences between my and their version
    123      *
    124      * @param my my version of the primitive
    125      * @param their their version of the primitive
     122     * Populates the model with the differences between local and server version
     123     *
     124     * @param conflict The conflict information
    126125     */
    127126    public void populate(Conflict<? extends OsmPrimitive> conflict) {
     
    151150    /**
    152151     * replies the coordinates of my {@link OsmPrimitive}. null, if my primitive hasn't
    153      * coordinates (i.e. because it is a {@link Way}).
     152     * coordinates (i.e. because it is a {@link org.openstreetmap.josm.data.osm.Way}).
    154153     *
    155154     * @return the coordinates of my {@link OsmPrimitive}. null, if my primitive hasn't
    156      *  coordinates (i.e. because it is a {@link Way}).
     155     *  coordinates (i.e. because it is a {@link org.openstreetmap.josm.data.osm.Way}).
    157156     */
    158157    public LatLon getMyCoords() {
     
    162161    /**
    163162     * replies the coordinates of their {@link OsmPrimitive}. null, if their primitive hasn't
    164      * coordinates (i.e. because it is a {@link Way}).
     163     * coordinates (i.e. because it is a {@link org.openstreetmap.josm.data.osm.Way}).
    165164     *
    166165     * @return the coordinates of my {@link OsmPrimitive}. null, if my primitive hasn't
    167      * coordinates (i.e. because it is a {@link Way}).
     166     * coordinates (i.e. because it is a {@link org.openstreetmap.josm.data.osm.Way}).
    168167     */
    169168    public LatLon getTheirCoords() {
     
    189188
    190189    /**
    191      * decides a conflict between my and their coordinates
     190     * Decides a conflict between local and server coordinates
    192191     *
    193192     * @param decision the decision
     
    201200
    202201    /**
    203      * replies my deleted state,
    204      * @return
     202     * Replies deleted state of local dataset
     203     * @return The state of deleted flag
    205204     */
    206205    public Boolean getMyDeletedState() {
     
    208207    }
    209208
     209    /**
     210     * Replies deleted state of Server dataset
     211     * @return The state of deleted flag
     212     */
    210213    public  Boolean getTheirDeletedState() {
    211214        return theirDeletedState;
    212215    }
    213216
     217    /**
     218     * Replies deleted state of combined dataset
     219     * @return The state of deleted flag
     220     */
    214221    public Boolean getMergedDeletedState() {
    215222        switch(deletedMergeDecision) {
     
    223230
    224231    /**
    225      * returns my referrers,
    226      * @return my referrers
     232     * Returns local referrers
     233     * @return The referrers
    227234     */
    228235    public List<OsmPrimitive> getMyReferrers() {
     
    231238
    232239    /**
    233      * returns their referrers,
    234      * @return their referrers
     240     * Returns server referrers
     241     * @return The referrers
    235242     */
    236243    public List<OsmPrimitive> getTheirReferrers() {
     
    289296     * their deleted states
    290297     *
    291      * @return true if my and their primitive have a conflict between
     298     * @return <code>true</code> if my and their primitive have a conflict between
    292299     * their deleted states
    293300     */
     
    299306     * replies true if all conflict in this model are resolved
    300307     *
    301      * @return true if all conflict in this model are resolved; false otherwise
     308     * @return <code>true</code> if all conflict in this model are resolved; <code>false</code> otherwise
    302309     */
    303310    public boolean isResolvedCompletely() {
     
    313320
    314321    /**
    315      * builds the command(s) to apply the conflict resolutions to my primitive
    316      *
    317      * @param my  my primitive
    318      * @param their their primitive
    319      * @return the list of commands
     322     * Builds the command(s) to apply the conflict resolutions to my primitive
     323     *
     324     * @param conflict The conflict information
     325     * @return The list of commands
    320326     */
    321327    public List<Command> buildResolveCommand(Conflict<? extends OsmPrimitive> conflict) {
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r5472 r5481  
    317317        p.add(Box.createHorizontalStrut(10), GBC.std());
    318318        p.add(values, GBC.eol().fill(GBC.HORIZONTAL));
    319         addFocusAdapter(row, keys, values, autocomplete, usedValuesAwareComparator);
     319        addFocusAdapter(keys, values, autocomplete, usedValuesAwareComparator);
    320320
    321321        final JOptionPane optionPane = new JOptionPane(panel, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION) {
     
    447447
    448448    /**
    449      * This simply fires up an relation editor for the relation shown; everything else
     449     * This simply fires up an {@link RelationEditor} for the relation shown; everything else
    450450     * is the editor's business.
    451451     *
     
    535535        }
    536536
    537         FocusAdapter focus = addFocusAdapter(-1, keys, values, autocomplete, defaultACItemComparator);
     537        FocusAdapter focus = addFocusAdapter(keys, values, autocomplete, defaultACItemComparator);
    538538        // fire focus event in advance or otherwise the popup list will be too small at first
    539539        focus.focusGained(null);
     
    617617                // performing this action leads to autocomplete to the next key (see #7671 comments)
    618618                for (int j = 0; j < propertyData.getRowCount(); ++j) {
    619                     System.out.println(propertyData.getValueAt(j, 0));
    620619                    if (t.getKey().equals(propertyData.getValueAt(j, 0))) {
    621620                        action.setEnabled(false);
     
    655654
    656655    /**
    657      * @param allData
    658      * @param keys
    659      * @param values
    660      */
    661     private FocusAdapter addFocusAdapter(final int row,
    662             final AutoCompletingComboBox keys, final AutoCompletingComboBox values,
     656     * Create a focus handling adapter and apply in to the editor component of value
     657     * autocompletion box.
     658     * @param keys Box for keys entering and autocompletion
     659     * @param values Box for values entering and autocompletion
     660     * @param autocomplete Manager handling the autocompletion
     661     * @param comparator Class to decide what values are offered on autocompletion
     662     * @return The created adapter
     663     */
     664    private FocusAdapter addFocusAdapter(final AutoCompletingComboBox keys, final AutoCompletingComboBox values,
    663665            final AutoCompletionManager autocomplete, final Comparator<AutoCompletionListItem> comparator) {
    664666        // get the combo box' editor component
     
    683685
    684686    /**
    685      * The property data.
     687     * The property data of selected objects.
    686688     */
    687689    private final DefaultTableModel propertyData = new DefaultTableModel() {
     
    695697
    696698    /**
    697      * The membership data.
     699     * The membership data of selected objects.
    698700     */
    699701    private final DefaultTableModel membershipData = new DefaultTableModel() {
     
    707709
    708710    /**
    709      * The properties list.
     711     * The properties table.
    710712     */
    711713    private final JTable propertyTable = new JTable(propertyData);
     714    /**
     715     * The membership table.
     716     */
    712717    private final JTable membershipTable = new JTable(membershipData);
    713718
    714719    /**
    715      * The Add/Edit/Delete buttons (needed to be able to disable them)
     720     * The Add button (needed to be able to disable it)
    716721     */
    717722    private final SideButton btnAdd;
     723    /**
     724     * The Edit button (needed to be able to disable it)
     725     */
    718726    private final SideButton btnEdit;
     727    /**
     728     * The Delete button (needed to be able to disable it)
     729     */
    719730    private final SideButton btnDel;
     731    /**
     732     * Matching preset display class
     733     */
    720734    private final PresetListPanel presets = new PresetListPanel();
    721735
     736    /**
     737     * Text to display when nothing selected.
     738     */
    722739    private final JLabel selectSth = new JLabel("<html><p>"
    723740            + tr("Select objects for which to change properties.") + "</p></html>");
     
    9961013    }
    9971014
    998     @Override public void setVisible(boolean b) {
     1015    @Override
     1016    public void setVisible(boolean b) {
    9991017        super.setVisible(b);
    10001018        if (b && Main.main.getCurrentDataSet() != null) {
     
    10301048    };
    10311049
     1050    @Override
    10321051    public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {
    10331052        if (!isVisible())
     
    11561175    }
    11571176
     1177    /**
     1178     * Update selection status, call @{link #selectionChanged} function.
     1179     */
    11581180    private void updateSelection() {
    11591181        if (Main.main.getCurrentDataSet() == null) {
     
    11651187
    11661188    /* ---------------------------------------------------------------------------------- */
    1167     /* EditLayerChangeListener                                                                */
     1189    /* EditLayerChangeListener                                                            */
    11681190    /* ---------------------------------------------------------------------------------- */
     1191    @Override
    11691192    public void editLayerChanged(OsmDataLayer oldLayer, OsmDataLayer newLayer) {
    11701193        updateSelection();
    11711194    }
    11721195
     1196    @Override
    11731197    public void processDatasetEvent(AbstractDatasetChangedEvent event) {
    11741198        updateSelection();
    11751199    }
    11761200
     1201    /**
     1202     * Action handling delete button press in properties dialog.
     1203     */
    11771204    class DeleteAction extends JosmAction implements ListSelectionListener {
    11781205
     
    12771304    }
    12781305
     1306    /**
     1307     * Action handling add button press in properties dialog.
     1308     */
    12791309    class AddAction extends JosmAction {
    12801310        public AddAction() {
     
    12901320    }
    12911321
     1322    /**
     1323     * Action handling edit button press in properties dialog.
     1324     */
    12921325    class EditAction extends JosmAction implements ListSelectionListener {
    12931326        public EditAction() {
     
    13811414
    13821415                                if (conn.getResponseCode() != 200) {
    1383                                     System.out.println("INFO: " + u + " does not exist");
     1416                                    Main.info("INFO: {0} does not exist", u);
    13841417                                    conn.disconnect();
    13851418                                } else {
     
    13981431                                     */
    13991432                                    if (Math.abs(conn.getContentLength() - osize) > 200) {
    1400                                         System.out.println("INFO: " + u + " is a mediawiki redirect");
     1433                                        Main.info("INFO: {0} is a mediawiki redirect", u);
    14011434                                        conn.disconnect();
    14021435                                    } else {
    1403                                         System.out.println("INFO: browsing to " + u);
     1436                                        Main.info("INFO: browsing to {0}", u);
    14041437                                        conn.disconnect();
    14051438
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/Marker.java

    r5478 r5481  
    1717import javax.swing.Icon;
    1818
     19import org.openstreetmap.josm.Main;
    1920import org.openstreetmap.josm.actions.search.SearchCompiler.Match;
    2021import org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent;
     
    108109                    cache.put(key, result);
    109110                } catch (ParseError e) {
    110                     System.out.println(String.format("Unable to parse template engine pattern '%s' for property %s", defaultValue, key));
     111                    Main.warn("Unable to parse template engine pattern ''{0}'' for property {1}", defaultValue, key);
    111112                }
    112113            }
     
    127128                    cache.put(key, result);
    128129                } catch (ParseError e) {
    129                     System.out.println(String.format("Unable to parse template engine pattern '%s' for property %s", defaultValue, key));
     130                    Main.warn("Unable to parse template engine pattern ''{0}'' for property {1}", defaultValue, key);
    130131                }
    131132            }
     
    147148                return new TemplateParser(s).parse();
    148149            } catch (ParseError e) {
    149                 System.out.println(String.format("Unable to parse template engine pattern '%s' for property %s. Using default ('%s') instead",
    150                         s, getKey(), super.getDefaultValueAsString()));
     150                Main.warn("Unable to parse template engine pattern ''{0}'' for property {1}. Using default (''{2}'') instead",
     151                        s, getKey(), super.getDefaultValueAsString());
    151152                return getDefaultValue();
    152153            }
     
    177178    public static final List<MarkerProducers> markerProducers = new LinkedList<MarkerProducers>();
    178179
    179     // Add one Maker specifying the default behaviour.
     180    // Add one Marker specifying the default behaviour.
    180181    static {
    181182        Marker.markerProducers.add(new MarkerProducers() {
     
    203204                                url = new File(relativePath.getParentFile(), uri).toURI().toURL();
    204205                            } catch (MalformedURLException e1) {
    205                                 System.err.println("Unable to convert uri " + uri + " to URL: "  + e1.getMessage());
     206                                Main.warn("Unable to convert uri {0} to URL: {1}", uri, e1.getMessage());
    206207                            }
    207208                        }
     
    217218                    return new Marker(wpt.getCoor(), wpt, symbolName, parentLayer, time, offset);
    218219                }
    219                 else if (url.toString().endsWith(".wav"))
     220                else if (url.toString().endsWith(".wav")) {
    220221                    return new AudioMarker(wpt.getCoor(), wpt, url, parentLayer, time, offset);
    221                 else if (url.toString().endsWith(".png") || url.toString().endsWith(".jpg") || url.toString().endsWith(".jpeg") || url.toString().endsWith(".gif"))
     222                } else if (url.toString().endsWith(".png") || url.toString().endsWith(".jpg") || url.toString().endsWith(".jpeg") || url.toString().endsWith(".gif")) {
    222223                    return new ImageMarker(wpt.getCoor(), url, parentLayer, time, offset);
    223                 else
     224                } else {
    224225                    return new WebMarker(wpt.getCoor(), url, parentLayer, time, offset);
     226                }
    225227            }
    226228        });
     
    366368    /**
    367369     * Returns the Text which should be displayed, depending on chosen preference
    368      * @return Text
     370     * @return Text of the label
    369371     */
    370372    public String getText() {
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java

    r4831 r5481  
    424424    }
    425425
     426    /**
     427     * Get state of text display.
     428     * @return <code>true</code> if text should be shown, <code>false</code> otherwise.
     429     */
    426430    private boolean isTextOrIconShown() {
    427431        String current = Main.pref.get("marker.show "+getName(),"show");
Note: See TracChangeset for help on using the changeset viewer.