Ignore:
Timestamp:
2016-07-02T03:55:03+02:00 (10 years ago)
Author:
donvip
Message:

checkstyle

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/imagery_offset_db/src/iodb/OffsetInfoAction.java

    r29434 r32528  
     1// License: WTFPL. For details, see LICENSE file.
    12package iodb;
     3
     4import static org.openstreetmap.josm.tools.I18n.tr;
    25
    36import java.awt.event.ActionEvent;
     
    58import java.net.URLEncoder;
    69import java.text.SimpleDateFormat;
     10
    711import javax.swing.AbstractAction;
    812import javax.swing.JOptionPane;
     13
    914import org.openstreetmap.josm.Main;
    10 import static org.openstreetmap.josm.tools.I18n.tr;
    1115import org.openstreetmap.josm.tools.ImageProvider;
    1216
    1317/**
    1418 * Display an information box for an offset.
    15  * 
     19 *
    1620 * @author Zverik
    1721 * @license WTFPL
     
    2125
    2226    ImageryOffsetBase offset;
    23    
     27
    2428    /**
    2529     * Initializes the action with an offset object.
    2630     * Calls {@link #getInformationObject(iodb.ImageryOffsetBase)}.
    2731     */
    28     public OffsetInfoAction( ImageryOffsetBase offset ) {
     32    public OffsetInfoAction(ImageryOffsetBase offset) {
    2933        super(tr("Offset Information"));
    3034        putValue(SMALL_ICON, ImageProvider.get("info"));
     
    3741     * to report the given offset.
    3842     */
     43    @Override
    3944    public void actionPerformed(ActionEvent e) {
    4045        Object info = offset == null ? null : getInformationObject(offset);
    41         if( offset.isFlagged() )
     46        if (offset.isFlagged())
    4247            JOptionPane.showMessageDialog(Main.parent, info, ImageryOffsetTools.DIALOG_TITLE, JOptionPane.PLAIN_MESSAGE);
    4348        else {
    4449            int result = JOptionPane.showOptionDialog(Main.parent, info, ImageryOffsetTools.DIALOG_TITLE,
    4550                    JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null,
    46                     new String[] { "OK", tr("Report this offset") }, null);
    47             if( result == 1 ) {
     51                    new String[] {"OK", tr("Report this offset")}, null);
     52            if (result == 1) {
    4853                // ask for a reason
    4954                Object reason = JOptionPane.showInputDialog(Main.parent,
    5055                        tr("You are to notify moderators of this offset. Why?"),
    5156                        ImageryOffsetTools.DIALOG_TITLE, JOptionPane.PLAIN_MESSAGE);
    52                 if( reason != null && reason.toString().length() > 0 ) {
     57                if (reason != null && reason.toString().length() > 0) {
    5358                    try {
    5459                        String query = "report?id=" + offset.getId()
    55                                 + "&reason=" + URLEncoder.encode(reason.toString(), "UTF8");
     60                        + "&reason=" + URLEncoder.encode(reason.toString(), "UTF8");
    5661                        SimpleOffsetQueryTask reportTask =
    5762                                new SimpleOffsetQueryTask(query, tr("Reporting the offset..."));
    5863                        Main.worker.submit(reportTask);
    59                     } catch( UnsupportedEncodingException ex ) {
    60                         // WTF
     64                    } catch (UnsupportedEncodingException ex) {
     65                        Main.error(ex);
    6166                    }
    6267                }
     
    6873     * Constructs a string with all information about the given offset.
    6974     */
    70     public static Object getInformationObject( ImageryOffsetBase offset ) {
     75    public static Object getInformationObject(ImageryOffsetBase offset) {
    7176        StringBuilder sb = new StringBuilder();
    72         if( offset instanceof ImageryOffset ) {
    73             double odist = ((ImageryOffset)offset).getImageryPos().greatCircleDistance(offset.getPosition());
    74             if( odist < 1e-2 ) odist = 0.0;
     77        if (offset instanceof ImageryOffset) {
     78            double odist = ((ImageryOffset) offset).getImageryPos().greatCircleDistance(offset.getPosition());
     79            if (odist < 1e-2) odist = 0.0;
    7580            sb.append(tr("An imagery offset of {0}", ImageryOffsetTools.formatDistance(odist))).append('\n');
    76             sb.append(tr("Imagery ID")).append(": ").append(((ImageryOffset)offset).getImagery()).append('\n');
     81            sb.append(tr("Imagery ID")).append(": ").append(((ImageryOffset) offset).getImagery()).append('\n');
    7782        } else {
    78             sb.append(tr("A calibration geometry of {0} nodes", ((CalibrationObject)offset).getGeometry().length)).append('\n');
     83            sb.append(tr("A calibration geometry of {0} nodes", ((CalibrationObject) offset).getGeometry().length)).append('\n');
    7984        }
    80        
     85
    8186        double dist = ImageryOffsetTools.getMapCenter().greatCircleDistance(offset.getPosition());
    8287        sb.append(dist < 50 ? tr("Determined right here") : tr("Determined {0} away",
    8388                ImageryOffsetTools.formatDistance(dist)));
    84        
     89
    8590        sb.append("\n\n");
    8691        sb.append(tr("Created by {0} on {1}", offset.getAuthor(),
    8792                DATE_FORMAT.format(offset.getDate()))).append('\n');
    8893        sb.append(tr("Description")).append(": ").append(offset.getDescription());
    89        
    90         if( offset.isDeprecated() ) {
     94
     95        if (offset.isDeprecated()) {
    9196            sb.append("\n\n");
    92             sb.append(tr("Deprecated by {0} on {1}",offset.getAbandonAuthor(),
     97            sb.append(tr("Deprecated by {0} on {1}", offset.getAbandonAuthor(),
    9398                    DATE_FORMAT.format(offset.getAbandonDate()))).append('\n');
    9499            sb.append(tr("Reason")).append(": ").append(offset.getAbandonReason());
    95100        }
    96101
    97         if( offset.isFlagged() ) {
     102        if (offset.isFlagged()) {
    98103            sb.append("\n\n").append(tr("This entry has been reported."));
    99104        }
Note: See TracChangeset for help on using the changeset viewer.