Changeset 7527 in josm for trunk/src


Ignore:
Timestamp:
2014-09-11T19:27:03+02:00 (5 years ago)
Author:
Don-vip
Message:

see #10462 - more debug stuff, improve javadoc

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/history/History.java

    r7005 r7527  
    1717 * Represents the history of an OSM primitive. The history consists
    1818 * of a list of object snapshots with a specific version.
    19  *
     19 * @since 1670
    2020 */
    21 public class History{
     21public class History {
     22
    2223    private static interface FilterPredicate {
    2324        boolean matches(HistoryOsmPrimitive primitive);
     
    3839    /** the object id */
    3940    private final long id;
     41    /** the object type */
    4042    private final OsmPrimitiveType type;
    4143
    4244    /**
    43      * Creates a new history for an OSM primitive
     45     * Creates a new history for an OSM primitive.
    4446     *
    4547     * @param id the id. > 0 required.
     
    6264    }
    6365
     66    /**
     67     * Returns a new copy of this history, sorted in ascending order.
     68     * @return a new copy of this history, sorted in ascending order
     69     */
    6470    public History sortAscending() {
    6571        List<HistoryOsmPrimitive> copy = new ArrayList<>(versions);
     
    7278                    }
    7379                }
    74                 );
     80            );
    7581        return new History(id, type, copy);
    7682    }
    7783
     84    /**
     85     * Returns a new copy of this history, sorted in descending order.
     86     * @return a new copy of this history, sorted in descending order
     87     */
    7888    public History sortDescending() {
    7989        List<HistoryOsmPrimitive> copy = new ArrayList<>(versions);
     
    8696                    }
    8797                }
    88                 );
     98            );
    8999        return new History(id, type,copy);
    90100    }
    91101
     102    /**
     103     * Returns a new partial copy of this history, from the given date
     104     * @param fromDate the starting date
     105     * @return a new partial copy of this history, from the given date
     106     */
    92107    public History from(final Date fromDate) {
    93108        return filter(
     
    99114                    }
    100115                }
    101                 );
    102     }
    103 
     116            );
     117    }
     118
     119    /**
     120     * Returns a new partial copy of this history, until the given date
     121     * @param untilDate the end date
     122     * @return a new partial copy of this history, until the given date
     123     */
    104124    public History until(final Date untilDate) {
    105125        return filter(
     
    111131                    }
    112132                }
    113                 );
    114     }
    115 
     133            );
     134    }
     135
     136    /**
     137     * Returns a new partial copy of this history, between the given dates
     138     * @param fromDate the starting date
     139     * @param untilDate the end date
     140     * @return a new partial copy of this history, between the given dates
     141     */
    116142    public History between(Date fromDate, Date untilDate) {
    117143        return this.from(fromDate).until(untilDate);
    118144    }
    119145
     146    /**
     147     * Returns a new partial copy of this history, from the given version number
     148     * @param fromVersion the starting version number
     149     * @return a new partial copy of this history, from the given version number
     150     */
    120151    public History from(final long fromVersion) {
    121152        return filter(
     
    127158                    }
    128159                }
    129                 );
    130     }
    131 
     160            );
     161    }
     162
     163    /**
     164     * Returns a new partial copy of this history, to the given version number
     165     * @param untilVersion the ending version number
     166     * @return a new partial copy of this history, to the given version number
     167     */
    132168    public History until(final long untilVersion) {
    133169        return filter(
     
    139175                    }
    140176                }
    141                 );
    142     }
    143 
     177            );
     178    }
     179
     180    /**
     181     * Returns a new partial copy of this history, betwwen the given version numbers
     182     * @param fromVersion the starting version number
     183     * @param untilVersion the ending version number
     184     * @return a new partial copy of this history, between the given version numbers
     185     */
    144186    public History between(long fromVersion, long untilVersion) {
    145187        return this.from(fromVersion).until(untilVersion);
    146188    }
    147189
     190    /**
     191     * Returns a new partial copy of this history, for the given user id
     192     * @param uid the user id
     193     * @return a new partial copy of this history, for the given user id
     194     */
    148195    public History forUserId(final long uid) {
    149196        return filter(
     
    155202                    }
    156203                }
    157                 );
    158     }
    159 
     204            );
     205    }
     206
     207    /**
     208     * Replies the primitive id for this history.
     209     *
     210     * @return the primitive id
     211     * @see #getPrimitiveId
     212     * @see #getType
     213     */
    160214    public long getId() {
    161215        return id;
     
    166220     *
    167221     * @return the primitive id
     222     * @see #getId
    168223     */
    169224    public PrimitiveId getPrimitiveId() {
     
    171226    }
    172227
    173     public boolean contains(long version){
     228    /**
     229     * Determines if this history contains a specific version number.
     230     * @param version the version number to look for
     231     * @return {@code true} if this history contains {@code version}, {@code false} otherwise
     232     */
     233    public boolean contains(long version) {
    174234        for (HistoryOsmPrimitive primitive: versions) {
    175235            if (primitive.matches(id,version))
     
    194254    }
    195255
     256    /**
     257     * Replies the history primitive at given <code>date</code>. null,
     258     * if no such primitive exists.
     259     *
     260     * @param date the date
     261     * @return the history primitive at given <code>date</code>
     262     */
    196263    public HistoryOsmPrimitive getByDate(Date date) {
    197264        History h = sortAscending();
     
    209276    }
    210277
     278    /**
     279     * Replies the history primitive at index <code>idx</code>.
     280     *
     281     * @param idx the index
     282     * @return the history primitive at index <code>idx</code>
     283     * @throws IndexOutOfBoundsException if index out or range
     284     */
    211285    public HistoryOsmPrimitive get(int idx) throws IndexOutOfBoundsException {
    212286        if (idx < 0 || idx >= versions.size())
    213             throw new IndexOutOfBoundsException(MessageFormat.format("Parameter ''{0}'' in range 0..{1} expected. Got ''{2}''.", "idx", versions.size()-1, idx));
     287            throw new IndexOutOfBoundsException(MessageFormat.format(
     288                    "Parameter ''{0}'' in range 0..{1} expected. Got ''{2}''.", "idx", versions.size()-1, idx));
    214289        return versions.get(idx);
    215290    }
    216291
     292    /**
     293     * Replies the earliest entry of this history.
     294     * @return the earliest entry of this history
     295     */
    217296    public HistoryOsmPrimitive getEarliest() {
    218297        if (isEmpty())
     
    221300    }
    222301
     302    /**
     303     * Replies the latest entry of this history.
     304     * @return the latest entry of this history
     305     */
    223306    public HistoryOsmPrimitive getLatest() {
    224307        if (isEmpty())
     
    227310    }
    228311
     312    /**
     313     * Replies the number of versions.
     314     * @return the number of versions
     315     */
    229316    public int getNumVersions() {
    230317        return versions.size();
     
    239326    }
    240327
     328    /**
     329     * Replies the primitive type for this history.
     330     * @return the primitive type
     331     * @see #getId
     332     */
    241333    public OsmPrimitiveType getType() {
    242334        return type;
  • trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserDialogManager.java

    r7524 r7527  
    2929import org.openstreetmap.josm.tools.WindowGeometry;
    3030
     31/**
     32 * Manager allowing to show/hide history dialogs.
     33 * @since 2019
     34 */
    3135public class HistoryBrowserDialogManager implements MapView.LayerChangeListener {
     36
    3237    private static HistoryBrowserDialogManager instance;
     38
     39    /**
     40     * Replies the unique instance.
     41     * @return the unique instance
     42     */
    3343    public static HistoryBrowserDialogManager getInstance() {
    3444        if (instance == null) {
     
    4555    }
    4656
     57    /**
     58     * Determines if an history dialog exists for the given object id.
     59     * @param id the object id
     60     * @return {@code true} if an history dialog exists for the given object id, {@code false} otherwise
     61     */
    4762    public boolean existsDialog(long id) {
    4863        return dialogs.containsKey(id);
    4964    }
    5065
    51     public void show(long id, HistoryBrowserDialog dialog) {
     66    protected void show(long id, HistoryBrowserDialog dialog) {
    5267        if (dialogs.values().contains(dialog)) {
    5368            show(id);
     
    6075                Main.debug("#10462 - JFrame.isDefaultLookAndFeelDecorated: "+JFrame.isDefaultLookAndFeelDecorated());
    6176                Main.debug("#10462 - dialog.isUndecorated: "+dialog.isUndecorated());
     77                Main.debug("#10462 - UIManager.getLookAndFeel: "+UIManager.getLookAndFeel());
    6278                Main.debug("#10462 - LookAndFeel.getSupportsWindowDecorations: "+UIManager.getLookAndFeel().getSupportsWindowDecorations());
    6379                Main.debug("#10462 - JRootPane.getWindowDecorationStyle: "+dialog.getRootPane().getWindowDecorationStyle());
    6480                Main.debug("#10462 - Window.getIconImages: "+dialog.getIconImages());
    6581                Main.debug("#10462 - Dialog.getTitle: "+dialog.getTitle());
     82                Main.debug("#10462 - Dialog.getInsets: "+dialog.getInsets());
    6683            }
    6784            dialogs.put(id, dialog);
     
    6986    }
    7087
    71     public void show(long id) {
     88    protected void show(long id) {
    7289        if (dialogs.keySet().contains(id)) {
    7390            dialogs.get(id).toFront();
     
    87104    final String WINDOW_GEOMETRY_PREF = getClass().getName() + ".geometry";
    88105
    89     public void placeOnScreen(HistoryBrowserDialog dialog) {
     106    protected void placeOnScreen(HistoryBrowserDialog dialog) {
    90107        WindowGeometry geometry = new WindowGeometry(WINDOW_GEOMETRY_PREF, WindowGeometry.centerOnScreen(new Dimension(850, 500)));
    91108        geometry.applySafe(dialog);
    92109        Point p = dialog.getLocation();
    93         while(hasDialogWithCloseUpperLeftCorner(p)) {
     110        while (hasDialogWithCloseUpperLeftCorner(p)) {
    94111            p.x += 20;
    95112            p.y += 20;
     
    98115    }
    99116
     117    /**
     118     * Hides the specified history dialog and cleans associated resources.
     119     * @param dialog History dialog to hide
     120     */
    100121    public void hide(HistoryBrowserDialog dialog) {
    101122        long id = 0;
     
    129150    }
    130151
     152    /**
     153     * Show history dialog for the given history.
     154     * @param h History to show
     155     */
    131156    public void show(History h) {
    132157        if (h == null)
     
    151176    public void layerRemoved(Layer oldLayer) {
    152177        // remove all history browsers if the number of layers drops to 0
    153         //
    154178        if (Main.isDisplayingMapView() && Main.map.mapView.getNumLayers() == 0) {
    155179            hideAll();
     
    157181    }
    158182
     183    /**
     184     * Show history dialog(s) for the given primitive(s).
     185     * @param primitives The primitive(s) for which history will be displayed
     186     */
    159187    public void showHistory(final Collection<? extends PrimitiveId> primitives) {
    160188        final Collection<? extends PrimitiveId> notNewPrimitives = Utils.filter(primitives, notNewPredicate);
Note: See TracChangeset for help on using the changeset viewer.