Ignore:
Timestamp:
2015-08-15T12:30:33+02:00 (9 years ago)
Author:
nokutu
Message:

Improved javadoc and code style.

Location:
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
Files:
19 edited
2 moved

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java

    r31500 r31501  
    1111
    1212/**
    13  * Database class for all the MapillaryImage objects.
     13 * Database class for all the {@link MapillaryAbstractImage} objects.
    1414 *
    1515 * @author nokutu
     
    2121
    2222  private List<MapillaryAbstractImage> images;
     23  /** The image currently selected, this is the one being shown. */
    2324  private MapillaryAbstractImage selectedImage;
    24   /** The image under the cursor */
     25  /** The image under the cursor. */
    2526  private MapillaryAbstractImage highlightedImage;
     27  /** All the images selected, can be more than one. */
    2628  private final List<MapillaryAbstractImage> multiSelectedImages;
    27 
     29  /** Listeners of the class. */
    2830  private CopyOnWriteArrayList<MapillaryDataListener> listeners = new CopyOnWriteArrayList<>();
    2931
     
    3941    this.selectedImage = null;
    4042
     43    // Adds the basic set of listeners.
    4144    addListener(MapillaryPlugin.walkAction);
    4245    addListener(MapillaryPlugin.zoomAction);
     
    6770
    6871  /**
    69    * Removes an image from the database. From the ArrayList in this object and
    70    * from its {@link MapillarySequence}.
     72   * Removes an image from the database. From the {@link List} in this object
     73   * and from its {@link MapillarySequence}.
    7174   *
    7275   * @param image
     
    120123
    121124  /**
    122    * Adds a set of MapillaryImages to the object, but doesn't repaint mapView.
    123    * This is needed for concurrency.
     125   * Adds a set of {link MapillaryAbstractImage} objects to this object.
    124126   *
    125127   * @param images
    126128   *          The set of images to be added.
    127129   * @param update
    128    *          Whether the map must be updated or no.
     130   *          Whether the map must be updated or not.
    129131   */
    130132  public synchronized void add(List<MapillaryAbstractImage> images,
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImage.java

    r31445 r31501  
    1414  /** Unique identifier of the object */
    1515  private final String key;
    16 
    1716  /** The user that made the image */
    1817  private String user;
     
    2423   * Returns the location where the image was taken.
    2524   *
    26    * @return A String containing the location where the picture was taken.
     25   * @return A {@code String} containing the location where the picture was taken.
    2726   */
    2827  public String getLocation() {
     
    3433   *
    3534   * @param location
    36    *          A String object containing the place where the image was taken.
     35   *          A {@code String} object containing the place where the image was taken.
    3736   */
    3837  public void setLocation(String location) {
     
    6160   * Returns the unique identifier of the object.
    6261   *
    63    * @return A String containing the unique identifier of the object.
     62   * @return A {@code String} containing the unique identifier of the object.
    6463   */
    6564  public String getKey() {
     
    7170   *
    7271   * @param sign
    73    *          A String that identifies the type of sign.
     72   *          A {@code String} that identifies the type of sign.
    7473   */
    7574  public void addSign(String sign) {
     
    7877
    7978  /**
    80    * Returns a List containing the signs assigned to this image.
     79   * Returns a {@link List} containing the signs assigned to this image.
    8180   *
    82    * @return A List object containing the signs assigned to this image.
     81   * @return A {@link List} object containing the signs assigned to this image.
    8382   */
    8483  public List<String> getSigns() {
     
    9089   *
    9190   * @param user
    92    *          A String containing the username of the person who took the image.
     91   *          A {@code String} containing the username of the person who took the image.
    9392   */
    9493  public void setUser(String user) {
     
    9998   * Returns the username of the person who took the picture.
    10099   *
    101    * @return A String containing the username of the person who took the
     100   * @return A {@code String} containing the username of the person who took the
    102101   *         picture.
    103102   */
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImportedImage.java

    r31496 r31501  
    55import java.io.IOException;
    66import java.text.ParseException;
    7 import java.text.SimpleDateFormat;
    8 import java.util.Calendar;
    97
    108import javax.imageio.ImageIO;
     9
     10import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils;
    1111
    1212/**
     
    2424
    2525  /**
    26    * Creates a new MapillaryImportedImage object using as date the current date,
    27    * because it is missing in the file.
     26   * Creates a new MapillaryImportedImage object using as date the current date.
     27   * Using when the EXIF tags doesn't contain that info.
    2828   *
    2929   * @param lat
     
    3737   */
    3838  public MapillaryImportedImage(double lat, double lon, double ca, File file) {
    39     this(lat, lon, ca, file, currentDate());
     39    this(lat, lon, ca, file, MapillaryUtils.currentDate());
    4040  }
    4141
     
    7373   * Returns the pictures of the file.
    7474   *
    75    * @return A BufferedImage object containing the picture, or null if the
    76    *         {@link File} given in the constructor was null.
     75   * @return A {@link BufferedImage} object containing the picture, or null if
     76   *         the {@link File} given in the constructor was null.
    7777   * @throws IOException
    7878   *           If the file parameter of the object isn't an image.
     
    8585
    8686  /**
    87    * Returns the File object where the picture is located.
     87   * Returns the {@link File} object where the picture is located.
    8888   *
    89    * @return The File object where the picture is located.
     89   * @return The {@link File} object where the picture is located.
    9090   */
    9191  public File getFile() {
     
    104104    return this.file.hashCode();
    105105  }
    106 
    107   private static String currentDate() {
    108     Calendar cal = Calendar.getInstance();
    109     SimpleDateFormat formatter = new SimpleDateFormat("yyyy:MM:dd hh:mm:ss");
    110     return formatter.format(cal.getTime());
    111   }
    112106}
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java

    r31495 r31501  
    8686  /** The image pointed by the red line. */
    8787  public static MapillaryImage RED;
    88 
    8988  /** {@link MapillaryData} object that stores the database. */
    9089  private final MapillaryData data;
     
    519518    public void run() {
    520519      try {
    521         sleep(1000);
     520        sleep(1500);
    522521      } catch (InterruptedException e) {
    523522        Main.error(e);
     
    529528  @Override
    530529  public void primitivesAdded(PrimitivesAddedEvent event) {
    531     // Nothing
    532530  }
    533531
    534532  @Override
    535533  public void primitivesRemoved(PrimitivesRemovedEvent event) {
    536     // Nothing
    537534  }
    538535
    539536  @Override
    540537  public void tagsChanged(TagsChangedEvent event) {
    541     // Nothing
    542538  }
    543539
    544540  @Override
    545541  public void nodeMoved(NodeMovedEvent event) {
    546     // Nothing
    547542  }
    548543
    549544  @Override
    550545  public void wayNodesChanged(WayNodesChangedEvent event) {
    551     // Nothing
    552546  }
    553547
    554548  @Override
    555549  public void relationMembersChanged(RelationMembersChangedEvent event) {
    556     // Nothing
    557550  }
    558551
    559552  @Override
    560553  public void otherDatasetChange(AbstractDatasetChangedEvent event) {
    561     // Nothing
    562554  }
    563555
    564556  @Override
    565557  public void visitBoundingBox(BoundingXYVisitor v) {
    566     // Nothing
    567558  }
    568559
     
    598589    @Override
    599590    public void actionPerformed(ActionEvent e) {
    600       if (INSTANCE != null) {
     591      if (INSTANCE != null)
    601592        MapillaryRecord.getInstance().addCommand(
    602593            new CommandDelete(getData().getMultiSelectedImages()));
    603       }
    604594    }
    605595  }
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java

    r31491 r31501  
    175175
    176176  /**
    177    * Enables/disables a JMenuItem.
     177   * Enables/disables a {@link JMenuItem}.
    178178   *
    179179   * @param menu
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillarySequence.java

    r31460 r31501  
    55
    66/**
    7  * Class that stores a sequence of MapillaryImage objects.
     7 * Class that stores a sequence of {@link MapillaryAbstractImage} objects.
    88 *
    99 * @author nokutu
    10  * @see MapillaryImage
     10 * @see MapillaryAbstractImage
    1111 *
    1212 */
     
    2525
    2626  /**
    27    * Creates a sequence object with the given parameters
     27   * Creates a sequence object with the given parameters.
    2828   *
    2929   * @param key
     
    3939
    4040  /**
    41    * Returns all MapillaryImages objects contained by this object.
     41   * Returns all {@link MapillaryAbstractImage} objects contained by this
     42   * object.
    4243   *
    4344   * @return A List object containing all the {@link MapillaryAbstractImage}
     
    101102
    102103  /**
    103    * Returns the next {@link MapillaryAbstractImage} in the sequence.
     104   * Returns the next {@link MapillaryAbstractImage} in the sequence of a given
     105   * {@link MapillaryAbstractImage} object.
    104106   *
    105107   * @param image
     
    121123
    122124  /**
    123    * Returns the previous {@link MapillaryAbstractImage} in the sequence.
     125   * Returns the previous {@link MapillaryAbstractImage} in the sequence of a given
     126   * {@link MapillaryAbstractImage} object.
    124127   *
    125128   * @param image
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/WalkThread.java

    r31460 r31501  
    8282        try {
    8383          synchronized (this) {
     84            // Waits for full quality picture.
    8485            if (this.waitForFullQuality && image instanceof MapillaryImage) {
    8586              while (MapillaryMainDialog.getInstance().mapillaryImageDisplay
     
    9091                      .getImage().getWidth() < 2048)
    9192                wait(100);
    92             } else {
     93            }
     94            // Waits for thumbnail.
     95            else {
    9396              while (MapillaryMainDialog.getInstance().mapillaryImageDisplay
    9497                  .getImage() == this.lastImage
     
    135138      this.lock.unlock();
    136139    }
    137 
    138140  }
    139141
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/cache/CacheUtils.java

    r31457 r31501  
    7474    public void loadingFinished(CacheEntry arg0, CacheEntryAttributes arg1,
    7575        LoadResult arg2) {
    76       // Nothing
    7776    }
    7877  }
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/cache/MapillaryCache.java

    r31445 r31501  
    3030    /** Full quality image */
    3131    FULL_IMAGE,
    32 
    3332    /** Low quality image */
    3433    THUMBNAIL
     
    4140   *          The key of the image.
    4241   * @param type
    43    *          The type of image that must be downloaded (THUMNAIL or
     42   *          The type of image that must be downloaded (THUMBNAIL or
    4443   *          FULL_IMAGE).
    4544   */
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryDownloader.java

    r31473 r31501  
    4949  public final static String CLIENT_ID = "T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz";
    5050  /** Executor that will run the petitions. */
    51   private static ThreadPoolExecutor EXECUTOR = new ThreadPoolExecutor(3, 5, 100, TimeUnit.SECONDS,
    52       new ArrayBlockingQueue<Runnable>(100));;
     51  private static ThreadPoolExecutor EXECUTOR = new ThreadPoolExecutor(3, 5,
     52      100, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(100));;
    5353
    5454  /**
     
    114114
    115115  /**
    116    * Checks if the given {@LatLon} object lies inside the bounds of the
     116   * Checks if the given {@link LatLon} object lies inside the bounds of the
    117117   * image.
    118118   *
    119119   * @param latlon
     120   *          The coordinates to check.
    120121   * @return true if it lies inside the bounds; false otherwise;
    121122   */
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryExportDownloadThread.java

    r31445 r31501  
    1212import org.openstreetmap.josm.data.cache.CacheEntryAttributes;
    1313import org.openstreetmap.josm.data.cache.ICachedLoaderListener;
    14 import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    1514import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage;
    1615import org.openstreetmap.josm.plugins.mapillary.MapillaryImage;
     
    2827    ICachedLoaderListener {
    2928
    30   String url;
    31   ArrayBlockingQueue<BufferedImage> queue;
    32   ArrayBlockingQueue<MapillaryAbstractImage> queueImages;
     29  private ArrayBlockingQueue<BufferedImage> queue;
     30  private ArrayBlockingQueue<MapillaryAbstractImage> queueImages;
    3331
    34   ProgressMonitor monitor;
    35   MapillaryImage image;
     32  private MapillaryImage image;
    3633
    3734  /**
     
    5047      ArrayBlockingQueue<BufferedImage> queue,
    5148      ArrayBlockingQueue<MapillaryAbstractImage> queueImages) {
    52     this.url = "https://d1cuyjsrcm0gby.cloudfront.net/" + image.getKey()
    53         + "/thumb-2048.jpg";
    5449    this.queue = queue;
    5550    this.image = image;
     
    5954  @Override
    6055  public void run() {
    61     new MapillaryCache(this.image.getKey(), MapillaryCache.Type.FULL_IMAGE).submit(
    62         this, false);
     56    new MapillaryCache(this.image.getKey(), MapillaryCache.Type.FULL_IMAGE)
     57        .submit(this, false);
    6358  }
    6459
    6560  @Override
    66   public void loadingFinished(CacheEntry data, CacheEntryAttributes attributes,
    67       LoadResult result) {
     61  public synchronized void loadingFinished(CacheEntry data,
     62      CacheEntryAttributes attributes, LoadResult result) {
    6863    try {
    69       this.queue.put(ImageIO.read(new ByteArrayInputStream(data.getContent())));
    70       this.queueImages.put(this.image);
     64      synchronized (this.getClass()) {
     65        this.queue
     66            .put(ImageIO.read(new ByteArrayInputStream(data.getContent())));
     67        this.queueImages.put(this.image);
     68      }
    7169    } catch (InterruptedException e) {
    7270      Main.error(e);
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryExportManager.java

    r31445 r31501  
    2828 *
    2929 * @author nokutu
    30  *
     30 * @see MapillaryExportWriterThread
     31 * @see MapillaryExportDownloadThread
    3132 */
    3233public class MapillaryExportManager extends PleaseWaitRunnable {
    3334
    34   ArrayBlockingQueue<BufferedImage> queue;
    35   ArrayBlockingQueue<MapillaryAbstractImage> queueImages;
     35  private ArrayBlockingQueue<BufferedImage> queue;
     36  private ArrayBlockingQueue<MapillaryAbstractImage> queueImages;
    3637
    37   final int amount;
    38   List<MapillaryAbstractImage> images;
    39   String path;
     38  private final int amount;
     39  private List<MapillaryAbstractImage> images;
     40  private String path;
    4041
    4142  private Thread writer;
     
    137138      Main.error(e);
    138139    }
    139 
    140140  }
    141141
    142142  @Override
    143143  protected void finish() {
    144     // TODO Auto-generated method stub
    145144  }
    146145}
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryImageInfoDownloadThread.java

    r31500 r31501  
    2323 * @see MapillarySquareDownloadManagerThread
    2424 */
    25 public class MapillaryImageInfoDownloaderThread extends Thread {
     25public class MapillaryImageInfoDownloadThread extends Thread {
    2626  private static final String URL = MapillaryDownloader.BASE_URL + "search/im/";
    2727  private final String queryString;
     
    3636   *          A String containing the parameters for the download.
    3737   */
    38   public MapillaryImageInfoDownloaderThread(ExecutorService ex,
     38  public MapillaryImageInfoDownloadThread(ExecutorService ex,
    3939      String queryString) {
    4040    this.ex = ex;
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySquareDownloadManagerThread.java

    r31472 r31501  
    2424 *
    2525 * @see MapillaryDownloader
     26 * @see MapillarySequenceDownloadThread
     27 * @see MapillaryImageInfoDownloadThread
     28 * @see MapillaryTrafficSignDownloadThread
    2629 */
    2730public class MapillarySquareDownloadManagerThread extends Thread {
     
    109112    int page = 0;
    110113    while (!this.completeExecutor.isShutdown()) {
    111       this.completeExecutor.execute(new MapillaryImageInfoDownloaderThread(
     114      this.completeExecutor.execute(new MapillaryImageInfoDownloadThread(
    112115          this.completeExecutor, this.imageQueryString + "&page=" + page
    113116              + "&limit=20"));
     
    122125    int page = 0;
    123126    while (!this.signsExecutor.isShutdown()) {
    124       this.signsExecutor.execute(new MapillaryTrafficSignDownloaderThread(
     127      this.signsExecutor.execute(new MapillaryTrafficSignDownloadThread(
    125128          this.signsExecutor, this.signQueryString + "&page=" + page
    126129              + "&limit=20"));
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryTrafficSignDownloadThread.java

    r31500 r31501  
    2323 *
    2424 */
    25 public class MapillaryTrafficSignDownloaderThread extends Thread {
     25public class MapillaryTrafficSignDownloadThread extends Thread {
    2626  private static final String URL = MapillaryDownloader.BASE_URL
    2727      + "search/im/or/";
     
    3737   *          A String containing the parameter for the download.
    3838   */
    39   public MapillaryTrafficSignDownloaderThread(ExecutorService ex,
     39  public MapillaryTrafficSignDownloadThread(ExecutorService ex,
    4040      String queryString) {
    4141    this.ex = ex;
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/HyperlinkLabel.java

    r31473 r31501  
    2424
    2525/**
    26  * JLabel that acts as a hyperlink.
     26 * {@link JLabel} that acts as a hyperlink.
    2727 *
    2828 * @author nokutu
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryExportDialog.java

    r31460 r31501  
    168168        this.dlg.path.setText(this.lastPath);
    169169      }
    170 
    171170    }
    172 
    173171  }
    174172}
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryFilterDialog.java

    r31451 r31501  
    4949      tr("Months"), tr("Days") };
    5050
    51   private final JPanel panel = new JPanel();
     51  private final JPanel panel;
    5252
    5353  /** Spinner to choose the range of dates. */
     
    9393            KeyEvent.VK_M, Shortcut.NONE), 200);
    9494
     95    this.panel = new JPanel();
     96
    9597    this.signChooser.setEnabled(false);
    9698    JPanel signChooserPanel = new JPanel();
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryHistoryDialog.java

    r31495 r31501  
    4444 * allows the user to revert them.
    4545 *
     46 * @author nokutu
    4647 * @see MapillaryRecord
    4748 * @see MapillaryCommand
    48  * @author nokutu
    4949 *
    5050 */
     
    211211      MapillaryRecord.getInstance().undo();
    212212    }
    213 
    214213  }
    215214
     
    227226      MapillaryRecord.getInstance().redo();
    228227    }
    229 
    230228  }
    231229
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/history/MapillaryRecordListener.java

    r31490 r31501  
    33/**
    44 * Interface for the listener of the {@link MapillaryRecord} class
    5  * 
     5 *
    66 * @author nokutu
    77 * @see MapillaryRecord
    88 */
    99public interface MapillaryRecordListener {
     10
    1011  /**
    1112   * Fired when any command is undone or redone.
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryUtils.java

    r31500 r31501  
    77import java.net.URISyntaxException;
    88import java.net.URL;
     9import java.text.SimpleDateFormat;
    910import java.util.ArrayList;
     11import java.util.Calendar;
    1012import java.util.List;
    1113
     
    266268    showPictures(MapillaryLayer.getInstance().getData().getImages(), false);
    267269  }
     270
     271  /**
     272   * Returns the current date.
     273   * @return A {@code String} object containing the current date.
     274   */
     275  public static String currentDate() {
     276    Calendar cal = Calendar.getInstance();
     277    SimpleDateFormat formatter = new SimpleDateFormat("yyyy:MM:dd hh:mm:ss");
     278    return formatter.format(cal.getTime());
     279  }
    268280}
Note: See TracChangeset for help on using the changeset viewer.