Changeset 7402 in josm for trunk/src


Ignore:
Timestamp:
2014-08-15T18:53:18+02:00 (5 years ago)
Author:
Don-vip
Message:

fix some Sonar issues

Location:
trunk/src/org/openstreetmap/josm
Files:
22 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/Main.java

    r7358 r7402  
    7777import org.openstreetmap.josm.gui.io.SaveLayersDialog;
    7878import org.openstreetmap.josm.gui.layer.Layer;
    79 import org.openstreetmap.josm.gui.layer.ModifiableLayer;
     79import org.openstreetmap.josm.gui.layer.AbstractModifiableLayer;
    8080import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    8181import org.openstreetmap.josm.gui.layer.OsmDataLayer.CommandQueueListener;
     
    891891
    892892    /**
    893      * Asks user to perform "save layer" operations (save on disk and/or upload data to server) for all {@link ModifiableLayer} before JOSM exits.
     893     * Asks user to perform "save layer" operations (save on disk and/or upload data to server) for all {@link AbstractModifiableLayer} before JOSM exits.
    894894     * @return {@code true} if there was nothing to save, or if the user wants to proceed to save operations. {@code false} if the user cancels.
    895895     * @since 2025
     
    897897    public static boolean saveUnsavedModifications() {
    898898        if (!isDisplayingMapView()) return true;
    899         return saveUnsavedModifications(map.mapView.getLayersOfType(ModifiableLayer.class), true);
     899        return saveUnsavedModifications(map.mapView.getLayersOfType(AbstractModifiableLayer.class), true);
    900900    }
    901901
     
    903903     * Asks user to perform "save layer" operations (save on disk and/or upload data to server) before data layers deletion.
    904904     *
    905      * @param selectedLayers The layers to check. Only instances of {@link ModifiableLayer} are considered.
     905     * @param selectedLayers The layers to check. Only instances of {@link AbstractModifiableLayer} are considered.
    906906     * @param exit {@code true} if JOSM is exiting, {@code false} otherwise.
    907907     * @return {@code true} if there was nothing to save, or if the user wants to proceed to save operations. {@code false} if the user cancels.
     
    910910    public static boolean saveUnsavedModifications(Iterable<? extends Layer> selectedLayers, boolean exit) {
    911911        SaveLayersDialog dialog = new SaveLayersDialog(parent);
    912         List<ModifiableLayer> layersWithUnmodifiedChanges = new ArrayList<>();
     912        List<AbstractModifiableLayer> layersWithUnmodifiedChanges = new ArrayList<>();
    913913        for (Layer l: selectedLayers) {
    914             if (!(l instanceof ModifiableLayer)) {
     914            if (!(l instanceof AbstractModifiableLayer)) {
    915915                continue;
    916916            }
    917             ModifiableLayer odl = (ModifiableLayer)l;
     917            AbstractModifiableLayer odl = (AbstractModifiableLayer)l;
    918918            if ((odl.requiresSaveToFile() || (odl.requiresUploadToServer() && !odl.isUploadDiscouraged())) && odl.isModified()) {
    919919                layersWithUnmodifiedChanges.add(odl);
  • trunk/src/org/openstreetmap/josm/actions/UploadAction.java

    r7358 r7402  
    2727import org.openstreetmap.josm.gui.io.UploadDialog;
    2828import org.openstreetmap.josm.gui.io.UploadPrimitivesTask;
    29 import org.openstreetmap.josm.gui.layer.ModifiableLayer;
     29import org.openstreetmap.josm.gui.layer.AbstractModifiableLayer;
    3030import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    3131import org.openstreetmap.josm.gui.util.GuiHelper;
     
    143143    }
    144144
    145     public static boolean checkPreUploadConditions(ModifiableLayer layer) {
     145    public static boolean checkPreUploadConditions(AbstractModifiableLayer layer) {
    146146        return checkPreUploadConditions(layer,
    147147                layer instanceof OsmDataLayer ? new APIDataSet(((OsmDataLayer)layer).data) : null);
     
    164164     * want to continue
    165165     */
    166     public static boolean warnUploadDiscouraged(ModifiableLayer layer) {
     166    public static boolean warnUploadDiscouraged(AbstractModifiableLayer layer) {
    167167        return GuiHelper.warnUser(tr("Upload discouraged"),
    168168                "<html>" +
     
    184184     * @return true, if the preconditions are met; false, otherwise
    185185     */
    186     public static boolean checkPreUploadConditions(ModifiableLayer layer, APIDataSet apiData) {
     186    public static boolean checkPreUploadConditions(AbstractModifiableLayer layer, APIDataSet apiData) {
    187187        if (layer.isUploadDiscouraged()) {
    188188            if (warnUploadDiscouraged(layer)) {
  • trunk/src/org/openstreetmap/josm/data/osm/MultipolygonBuilder.java

    r7395 r7402  
    5959            List<Node> nodes = new ArrayList<>();
    6060
    61             for(int waypos = 0; waypos < this.ways.size(); waypos ++) {
     61            for (int waypos = 0; waypos < this.ways.size(); waypos ++) {
    6262                Way way = this.ways.get(waypos);
    6363                boolean reversed = this.reversed.get(waypos).booleanValue();
     
    6767                        nodes.add(way.getNode(pos));
    6868                    }
    69                 }
    70                 else {
     69                } else {
    7170                    for (int pos = way.getNodesCount() - 1; pos > 0; pos--) {
    7271                        nodes.add(way.getNode(pos));
     
    8887        public List<JoinedPolygon> innerWays;
    8988
    90         public PolygonLevel(JoinedPolygon _pol, int _level) {
    91             this.outerWay = _pol;
    92             this.level = _level;
     89        public PolygonLevel(JoinedPolygon pol, int level) {
     90            this.outerWay = pol;
     91            this.level = level;
    9392            this.innerWays = new ArrayList<>();
    9493        }
     
    161160        Set<Way> usedWays = new HashSet<>();
    162161
    163         for(Way w: ways) {
     162        for (Way w: ways) {
    164163            if (w.getNodesCount() < 2) {
    165164                throw new JoinedPolygonCreationException(tr("Cannot add a way with only {0} nodes.", w.getNodesCount()));
     
    171170                joinedWays.add(jw);
    172171                usedWays.add(w);
    173             }
    174             else {
     172            } else {
    175173                nodesWithConnectedWays.put(w.lastNode(), w);
    176174                nodesWithConnectedWays.put(w.firstNode(), w);
     
    249247            if (pol.level % 2 == 0) {
    250248                this.outerWays.add(pol.outerWay);
    251             }
    252             else {
     249            } else {
    253250                this.innerWays.add(pol.outerWay);
    254251            }
  • trunk/src/org/openstreetmap/josm/data/projection/Ellipsoid.java

    r6987 r7402  
    1111
    1212/**
    13  * the reference ellipsoids
     13 * Reference ellipsoids.
    1414 */
    1515public final class Ellipsoid {
     16
    1617    /**
    1718     * Clarke 1880 IGN (French national geographic institute)
    1819     */
    1920    public static final Ellipsoid clarkeIGN = Ellipsoid.create_a_b(6378249.2, 6356515.0);
    20     /**
    21      * Hayford's ellipsoid 1909 (ED50 system)
     21
     22    /**
     23     * Hayford's ellipsoid 1909 (ED50 system)<br>
    2224     * Proj.4 code: intl
    2325     */
    2426    public static final Ellipsoid hayford = Ellipsoid.create_a_rf(6378388.0, 297.0);
     27
    2528    /**
    2629     * GRS67 ellipsoid
    2730     */
    2831    public static final Ellipsoid GRS67 = Ellipsoid.create_a_rf(6378160.0, 298.247167472);
     32
    2933    /**
    3034     * GRS80 ellipsoid
     
    4650     */
    4751    public final double a;
     52
    4853    /**
    4954     * half short axis
    5055     */
    5156    public final double b;
     57
    5258    /**
    5359     * first eccentricity
    5460     */
    5561    public final double e;
     62
    5663    /**
    5764     * first eccentricity squared
     
    8693     * @param a semimajor radius of the ellipsoid axis (in meters)
    8794     * @param b semiminor radius of the ellipsoid axis (in meters)
     95     * @return the new ellipsoid
    8896     */
    8997    public static Ellipsoid create_a_b(double a, double b) {
     
    99107     * @param a semimajor radius of the ellipsoid axis (in meters)
    100108     * @param es first eccentricity squared
     109     * @return the new ellipsoid
    101110     */
    102111    public static Ellipsoid create_a_es(double a, double es) {
     
    112121     * @param a semimajor radius of the ellipsoid axis (in meters)
    113122     * @param f flattening ( = (a - b) / a)
     123     * @return the new ellipsoid
    114124     */
    115125    public static Ellipsoid create_a_f(double a, double f) {
     
    126136     * @param a semimajor radius of the ellipsoid axis (in meters)
    127137     * @param rf inverse flattening
     138     * @return the new ellipsoid
    128139     */
    129140    public static Ellipsoid create_a_rf(double a, double rf) {
     
    217228    }
    218229
    219     /*
     230    /**
    220231     * Returns geographic latitude of isometric latitude of first eccentricity (e)
     232     * and epsilon precision
     233     * @return geographic latitude of isometric latitude of first eccentricity (e)
    221234     * and epsilon precision
    222235     */
  • trunk/src/org/openstreetmap/josm/data/projection/datum/Datum.java

    r6069 r7402  
    1818
    1919    /**
    20      * @return the Proj.4 identifier
    21      * (as reported by cs2cs -ld)
     20     * Replies the Proj.4 identifier.
     21     * @return the Proj.4 identifier (as reported by cs2cs -ld)
    2222     * If no id exists, return null.
    2323     */
  • trunk/src/org/openstreetmap/josm/gui/io/SaveLayerInfo.java

    r7358 r7402  
    44import java.io.File;
    55
    6 import org.openstreetmap.josm.gui.layer.ModifiableLayer;
     6import org.openstreetmap.josm.gui.layer.AbstractModifiableLayer;
    77import org.openstreetmap.josm.tools.CheckParameterUtil;
    88
     
    1515
    1616    /** the modifiable layer */
    17     private ModifiableLayer layer;
     17    private AbstractModifiableLayer layer;
    1818    private boolean doCheckSaveConditions;
    1919    private boolean doSaveToFile;
     
    2828     * @throws IllegalArgumentException thrown if layer is null
    2929     */
    30     public SaveLayerInfo(ModifiableLayer layer) {
     30    public SaveLayerInfo(AbstractModifiableLayer layer) {
    3131        CheckParameterUtil.ensureParameterNotNull(layer, "layer");
    3232        this.layer = layer;
     
    4242     * @return the layer this info objects holds information for
    4343     */
    44     public ModifiableLayer getLayer() {
     44    public AbstractModifiableLayer getLayer() {
    4545        return layer;
    4646    }
  • trunk/src/org/openstreetmap/josm/gui/io/SaveLayerTask.java

    r7358 r7402  
    1111
    1212/**
    13  * SaveLayerTask saves the data managed by an {@link org.openstreetmap.josm.gui.layer.ModifiableLayer} to the
     13 * SaveLayerTask saves the data managed by an {@link org.openstreetmap.josm.gui.layer.AbstractModifiableLayer} to the
    1414 * {@link org.openstreetmap.josm.gui.layer.Layer#getAssociatedFile()}.
    1515 *
  • trunk/src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java

    r7358 r7402  
    4646import org.openstreetmap.josm.gui.ExceptionDialogUtil;
    4747import org.openstreetmap.josm.gui.io.SaveLayersModel.Mode;
    48 import org.openstreetmap.josm.gui.layer.ModifiableLayer;
     48import org.openstreetmap.josm.gui.layer.AbstractModifiableLayer;
    4949import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    5050import org.openstreetmap.josm.gui.progress.SwingRenderingProgressMonitor;
     
    449449        protected void uploadLayers(List<SaveLayerInfo> toUpload) {
    450450            for (final SaveLayerInfo layerInfo: toUpload) {
    451                 ModifiableLayer layer = layerInfo.getLayer();
     451                AbstractModifiableLayer layer = layerInfo.getLayer();
    452452                if (canceled) {
    453453                    model.setUploadState(layer, UploadOrSaveState.CANCELED);
  • trunk/src/org/openstreetmap/josm/gui/io/SaveLayersModel.java

    r7358 r7402  
    1212import javax.swing.table.DefaultTableModel;
    1313
    14 import org.openstreetmap.josm.gui.layer.ModifiableLayer;
     14import org.openstreetmap.josm.gui.layer.AbstractModifiableLayer;
    1515import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1616
     
    6565     * @since 7358
    6666     */
    67     public void populate(List<? extends ModifiableLayer> layers) {
     67    public void populate(List<? extends AbstractModifiableLayer> layers) {
    6868        layerInfo = new ArrayList<>();
    6969        if (layers == null) return;
    70         for (ModifiableLayer layer: layers) {
     70        for (AbstractModifiableLayer layer: layers) {
    7171            layerInfo.add(new SaveLayerInfo(layer));
    7272        }
     
    143143        List<SaveLayerInfo> ret = new ArrayList<>();
    144144        for (SaveLayerInfo info: layerInfo) {
    145             ModifiableLayer l = info.getLayer();
     145            AbstractModifiableLayer l = info.getLayer();
    146146            if (info.isDoUploadToServer() && l instanceof OsmDataLayer && !((OsmDataLayer)l).getConflicts().isEmpty()) {
    147147                ret.add(info);
     
    171171    }
    172172
    173     public void setUploadState(ModifiableLayer layer, UploadOrSaveState state) {
     173    public void setUploadState(AbstractModifiableLayer layer, UploadOrSaveState state) {
    174174        SaveLayerInfo info = getSaveLayerInfo(layer);
    175175        if (info != null) {
     
    179179    }
    180180
    181     public void setSaveState(ModifiableLayer layer, UploadOrSaveState state) {
     181    public void setSaveState(AbstractModifiableLayer layer, UploadOrSaveState state) {
    182182        SaveLayerInfo info = getSaveLayerInfo(layer);
    183183        if (info != null) {
     
    187187    }
    188188
    189     public SaveLayerInfo getSaveLayerInfo(ModifiableLayer layer) {
     189    public SaveLayerInfo getSaveLayerInfo(AbstractModifiableLayer layer) {
    190190        for (SaveLayerInfo info: this.layerInfo) {
    191191            if (info.getLayer() == layer)
  • trunk/src/org/openstreetmap/josm/gui/layer/AbstractModifiableLayer.java

    r7401 r7402  
    1010 * @since 7358
    1111 */
    12 public abstract class ModifiableLayer extends Layer {
     12public abstract class AbstractModifiableLayer extends Layer {
    1313
    1414    /**
     
    1616     * @param name Layer name
    1717     */
    18     public ModifiableLayer(String name) {
     18    public AbstractModifiableLayer(String name) {
    1919        super(name);
    2020    }
  • trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java

    r7320 r7402  
    263263            if (t==null) continue;
    264264            long tm = t[1].getTime();
    265             trackVisibility[i]= (tm==0 && showWithoutDate) || (from<=tm && tm <= to);
     265            trackVisibility[i]= (tm==0 && showWithoutDate) || (from <= tm && tm <= to);
    266266            i++;
    267267        }
     
    280280        lastTracks.addAll(data.tracks);
    281281
    282         LinkedList<WayPoint> visibleSegments = listVisibleSegments(box);
    283         if(!visibleSegments.isEmpty()) {
     282        List<WayPoint> visibleSegments = listVisibleSegments(box);
     283        if (!visibleSegments.isEmpty()) {
    284284            drawHelper.readPreferences(getName());
    285285            drawHelper.drawAll(g, mv, visibleSegments);
     
    288288            }
    289289        }
    290 
    291     }
    292 
    293     private LinkedList<WayPoint> listVisibleSegments(Bounds box) {
     290    }
     291
     292    private List<WayPoint> listVisibleSegments(Bounds box) {
    294293        WayPoint last = null;
    295294        LinkedList<WayPoint> visibleSegments = new LinkedList<>();
     
    298297        for (Collection<WayPoint> segment : data.getLinesIterable(trackVisibility)) {
    299298
    300             for(WayPoint pt : segment)
    301             {
     299            for (WayPoint pt : segment) {
    302300                Bounds b = new Bounds(pt.getCoor());
    303                 // last should never be null when this is true!
    304                 if(pt.drawLine) {
     301                if (pt.drawLine && last != null) {
    305302                    b.extend(last.getCoor());
    306303                }
    307                 if(b.intersects(box))
    308                 {
    309                     if(last != null && (visibleSegments.isEmpty()
     304                if (b.intersects(box)) {
     305                    if (last != null && (visibleSegments.isEmpty()
    310306                            || visibleSegments.getLast() != last)) {
    311                         if(last.drawLine) {
     307                        if (last.drawLine) {
    312308                            WayPoint l = new WayPoint(last);
    313309                            l.drawLine = false;
  • trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r7358 r7402  
    9696 * @author imi
    9797 */
    98 public class OsmDataLayer extends ModifiableLayer implements Listener, SelectionChangedListener {
     98public class OsmDataLayer extends AbstractModifiableLayer implements Listener, SelectionChangedListener {
    9999    public static final String REQUIRES_SAVE_TO_DISK_PROP = OsmDataLayer.class.getName() + ".requiresSaveToDisk";
    100100    public static final String REQUIRES_UPLOAD_TO_SERVER_PROP = OsmDataLayer.class.getName() + ".requiresUploadToServer";
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java

    r7345 r7402  
    11// License: GPL. See LICENSE file for details.
    2 
    32package org.openstreetmap.josm.gui.layer.gpx;
    43
     
    2221import org.openstreetmap.josm.gui.MapView;
    2322import org.openstreetmap.josm.tools.ColorScale;
    24 
    2523
    2624/**
     
    106104    }
    107105
     106    /**
     107     * Constructs a new {@code GpxDrawHelper}.
     108     * @param gpxData GPX data
     109     */
    108110    public GpxDrawHelper(GpxData gpxData) {
    109111        data = gpxData;
    110112        setupColors();
     113    }
     114
     115    private static String specName(String layerName) {
     116        return "layer " + layerName;
    111117    }
    112118
     
    118124     */
    119125    public Color getColor(String layerName, boolean ignoreCustom) {
    120         Color c = Main.pref.getColor(marktr("gps point"), "layer " + layerName, Color.gray);
     126        Color c = Main.pref.getColor(marktr("gps point"), specName(layerName), Color.gray);
    121127        return ignoreCustom || getColorMode(layerName) == ColorMode.NONE ? c : null;
    122128    }
     
    129135    public ColorMode getColorMode(String layerName) {
    130136        try {
    131             int i=Main.pref.getInteger("draw.rawgps.colors", "layer " + layerName, 0);
     137            int i = Main.pref.getInteger("draw.rawgps.colors", specName(layerName), 0);
    132138            return ColorMode.values()[i];
    133139        } catch (Exception e) {
     
    149155     **/
    150156    public void readPreferences(String layerName) {
    151         String spec = "layer " + layerName;
     157        String spec = specName(layerName);
    152158        forceLines = Main.pref.getBoolean("draw.rawgps.lines.force", spec, false);
    153159        direction = Main.pref.getBoolean("draw.rawgps.direction", spec, false);
     
    198204                    RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF);
    199205
    200         if(lineWidth != 0) {
    201            g.setStroke(new BasicStroke(lineWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
     206        if (lineWidth != 0) {
     207            g.setStroke(new BasicStroke(lineWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
    202208        }
    203209        fixColors(visibleSegments);
     
    205211        drawArrows(g, mv, visibleSegments);
    206212        drawPoints(g, mv, visibleSegments);
    207         if(lineWidth != 0) {
     213        if (lineWidth != 0) {
    208214            g.setStroke(storedStroke);
    209215        }
     
    298304
    299305                if (colored == ColorMode.HDOP) {
    300                     Float hdop = ((Float) trkPnt.attr.get("hdop"));
     306                    Float hdop = (Float) trkPnt.attr.get("hdop");
    301307                    color = hdopScale.getColor(hdop);
    302308                }
     
    346352    }
    347353
    348 
    349 
    350354    private void drawLines(Graphics2D g, MapView mv, List<WayPoint> visibleSegments) {
    351355        if (lines) {
     
    357361                }
    358362                Point screen = mv.getPoint(trkPnt.getEastNorth());
    359                 if (trkPnt.drawLine) {
    360                     // skip points that are on the same screenposition
    361                     if (old != null && ((old.x != screen.x) || (old.y != screen.y))) {
    362                         g.setColor(trkPnt.customColoring);
    363                         g.drawLine(old.x, old.y, screen.x, screen.y);
    364                     }
     363                // skip points that are on the same screenposition
     364                if (trkPnt.drawLine && old != null && ((old.x != screen.x) || (old.y != screen.y))) {
     365                    g.setColor(trkPnt.customColoring);
     366                    g.drawLine(old.x, old.y, screen.x, screen.y);
    365367                }
    366368                old = screen;
     
    446448                if (hdopCircle && trkPnt.attr.get("hdop") != null) {
    447449                    // hdop value
    448                     float hdop = ((Float)trkPnt.attr.get("hdop"));
     450                    float hdop = (Float)trkPnt.attr.get("hdop");
    449451                    if (hdop < 0) {
    450452                        hdop = 0;
     
    534536    public void drawColorBar(Graphics2D g, MapView mv) {
    535537        int w = mv.getWidth();
    536         int h = mv.getHeight();
    537538        if (colored == ColorMode.HDOP) {
    538539            hdopScale.drawColorBar(g, w-30, 50, 20, 100, 1.0);
     
    543544        }
    544545    }
    545 
    546546}
  • trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java

    r7383 r7402  
    4242     */
    4343    public void clearCached() {
    44         // run in EDT to make sure this isn't called during rendering run 
     44        // run in EDT to make sure this isn't called during rendering run
    4545        // {@link org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer#render}
    4646        GuiHelper.runInEDT(new Runnable() {
     
    335335            }
    336336            env.layer = e.getKey();
    337             Cascade c = e.getValue();
    338337            if (osm instanceof Way) {
    339338                addIfNotNull(sl, AreaElemStyle.create(env));
  • trunk/src/org/openstreetmap/josm/gui/mappaint/TextElement.java

    r7383 r7402  
    1616/**
    1717 * Represents the rendering style for a textual label placed somewhere on the map.
    18  *
     18 * @since 3880
    1919 */
    2020public class TextElement implements StyleKeys {
     
    7373
    7474    /**
    75      * Derives a suitable label composition strategy from the style properties in
    76      * {@code c}.
     75     * Derives a suitable label composition strategy from the style properties in {@code c}.
    7776     *
    7877     * @param c the style properties
     
    108107     * default text color {@code defaultTextColor}
    109108     *
    110      * @param c the style properties
     109     * @param env the environment
    111110     * @param defaultTextColor the default text color. Must not be null.
    112111     * @param defaultAnnotate true, if a text label shall be rendered by default, even if the style sheet
  • trunk/src/org/openstreetmap/josm/gui/preferences/display/ColorPreference.java

    r7319 r7402  
    3838import org.openstreetmap.josm.gui.conflict.ConflictColors;
    3939import org.openstreetmap.josm.gui.dialogs.ConflictDialog;
    40 import org.openstreetmap.josm.gui.layer.gpx.GpxDrawHelper;
    41 import org.openstreetmap.josm.gui.layer.GpxLayer;
    4240import org.openstreetmap.josm.gui.layer.ImageryLayer;
    4341import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     42import org.openstreetmap.josm.gui.layer.gpx.GpxDrawHelper;
    4443import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
    4544import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
  • trunk/src/org/openstreetmap/josm/gui/preferences/map/MapPaintPreference.java

    r7333 r7402  
    4343
    4444    private static final List<SourceProvider> styleSourceProviders = new ArrayList<>();
     45
     46    private static final String OLD_ELEMSTYLES_XML = "resource://styles/standard/elemstyles.xml";
    4547
    4648    /**
     
    250252            }
    251253            // XML style is not bundled anymore
    252             knownDefaults.remove("resource://styles/standard/elemstyles.xml");
     254            knownDefaults.remove(OLD_ELEMSTYLES_XML);
    253255            Main.pref.putCollection("mappaint.style.known-defaults", knownDefaults);
    254256
     
    261263                        @Override
    262264                        public boolean evaluate(SourceEntry se) {
    263                             return "resource://styles/standard/elemstyles.xml".equals(se.url);
     265                            return OLD_ELEMSTYLES_XML.equals(se.url);
    264266                        }
    265267                    });
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/DNSName.java

    r7347 r7402  
    102102     */
    103103    public int getType() {
    104         return (GeneralNameInterface.NAME_DNS);
     104        return GeneralNameInterface.NAME_DNS;
    105105    }
    106106
     
    128128    @Override
    129129    public String toString() {
    130         return ("DNSName: " + name);
     130        return "DNSName: " + name;
    131131    }
    132132
     
    192192     *          not supported for this name type.
    193193     */
    194     public int constrains(GeneralNameInterface inputName) throws UnsupportedOperationException {
     194    @Override
     195    public int constrains(GeneralNameInterface inputName) {
    195196        int constraintType;
    196197        if (inputName == null)
     
    231232     * @throws UnsupportedOperationException if not supported for this name type
    232233     */
    233     public int subtreeDepth() throws UnsupportedOperationException {
     234    @Override
     235    public int subtreeDepth() {
    234236        String subtree=name;
    235237        int i=1;
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/RemoteControlHttpsServer.java

    r7347 r7402  
    136136        X509CertInfo info = new X509CertInfo();
    137137        Date from = new Date();
    138         Date to = new Date(from.getTime() + days * 86400000l);
     138        Date to = new Date(from.getTime() + days * 86400000L);
    139139        CertificateValidity interval = new CertificateValidity(from, to);
    140140        BigInteger sn = new BigInteger(64, new SecureRandom());
  • trunk/src/org/openstreetmap/josm/tools/ColorScale.java

    r7319 r7402  
    11// License: GPL. For details, see LICENSE file.
    2 
    32package org.openstreetmap.josm.tools;
    43
     
    87
    98/**
    10  * Utility class that helps to work with color scale
    11  * for coloring GPX tracks etc.
     9 * Utility class that helps to work with color scale for coloring GPX tracks etc.
    1210 * @since 7319
    1311 */
     
    1715    private Color belowMinColor;
    1816    private Color aboveMaxColor;
    19    
     17
    2018    private Color[] colors;
    2119    private String title = "";
    2220    private int intervalCount = 5;
    23    
     21
    2422    private ColorScale() {
    25        
     23
    2624    }
    27    
     25
    2826    public static ColorScale createHSBScale(int count) {
    2927        ColorScale sc = new ColorScale();
     
    3634        return sc;
    3735    }
    38    
     36
    3937    public static ColorScale createCyclicScale(int count) {
    4038        ColorScale sc = new ColorScale();
     
    4644        sc.colors = new Color[count];
    4745        for (int i = 0; i < sc.colors.length; i++) {
    48  
     46
    4947            float angle = 4 - i / 256f * 4;
    5048            int quadrant = (int) angle;
     
    6260        return sc;
    6361    }
    64    
     62
    6563    /**
    6664     * transition function:
     
    8078        this.max = max;
    8179    }
    82    
     80
    8381    /**
    8482     * Add standard colors for values below min or above max value
     
    8886        belowMinColor = colors[0];
    8987    }
    90    
     88
    9189    public final Color getColor(double value) {
    9290        if (value<min) return belowMinColor;
     
    10098            return colors[n-1]; // this happens when value==max
    10199        }
    102         // int hdoplvl =(int) Math.round(colorModeDynamic ? ((hdop-minval)*255/(maxval-minval))
    103         //            : (hdop <= 0 ? 0 : hdop * hdopfactor));
    104         // int hdopcolor = 255 - (hdoplvl > 255 ? 255 : hdoplvl);
    105100    }
    106    
     101
    107102    public final Color getColor(Number value) {
    108103        return (value==null)? noDataColor : getColor(value.doubleValue());
     
    110105
    111106    public Color getNoDataColor() {
    112        
    113107        return noDataColor;
    114108    }
     
    117111        this.noDataColor = noDataColor;
    118112    }
    119    
     113
    120114    public ColorScale makeTransparent(int alpha) {
    121115        for (int i = 0; i < colors.length; i++) {
     
    124118        return this;
    125119    }
    126    
     120
    127121    public ColorScale addTitle(String title) {
    128122        this.title = title;
    129123        return this;
    130124    }
    131    
     125
    132126    public ColorScale setIntervalCount(int intervalCount) {
    133127        this.intervalCount = intervalCount;
    134128        return this;
    135129    }
    136    
     130
    137131    public ColorScale makeReversed() {
    138132        int n = colors.length;
     
    148142        return this;
    149143    }
    150    
     144
    151145    public void drawColorBar(Graphics2D g, int x, int y, int w, int h, double valueScale) {
    152146        int n=colors.length;
    153        
     147
    154148        for (int i=0; i<n; i++) {
    155149            g.setColor(colors[i]);
     
    160154            }
    161155        }
    162        
     156
    163157        int fw, fh;
    164         FontMetrics fm = g.getFontMetrics(); 
     158        FontMetrics fm = g.getFontMetrics();
    165159        fh = fm.getHeight()/2;
    166160        fw = fm.stringWidth(String.valueOf(Math.max((int)Math.abs(max*valueScale), (int)Math.abs(min*valueScale)))) + fm.stringWidth("0.123");
  • trunk/src/org/openstreetmap/josm/tools/FontsManager.java

    r7383 r7402  
    99import java.util.Arrays;
    1010import java.util.Collection;
    11 import java.util.Map;
     11
    1212import org.openstreetmap.josm.io.CachedFile;
    1313
     14/**
     15 * Custom fonts manager that provides some embedded fonts to ensure
     16 * a common rendering on different platforms.
     17 * @since 7383
     18 */
    1419public class FontsManager {
    1520
    16     public static Map<String, Font> fonts;
    17     public static Collection<String> includedFonts = Arrays.asList(
     21    /**
     22     * List of fonts embedded into JOSM jar.
     23     */
     24    public static final Collection<String> INCLUDED_FONTS = Arrays.asList(
    1825            "DroidSans.ttf",
    1926            "DroidSans-Bold.ttf"
    2027    );
    21    
     28
     29    private FontsManager() {
     30        // Hide constructor for utility classes
     31    }
     32
     33    /**
     34     * Initializes the fonts manager.
     35     */
    2236    public static void initialize() {
    2337        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    24         for (String fontFile : includedFonts) {
     38        for (String fontFile : INCLUDED_FONTS) {
    2539            String url = "resource://data/fonts/"+fontFile;
    26             try (InputStream i = new CachedFile(url).getInputStream())
    27             {
     40            try (InputStream i = new CachedFile(url).getInputStream()) {
    2841                Font f = Font.createFont(Font.TRUETYPE_FONT, i);
    2942                if (f == null) {
  • trunk/src/org/openstreetmap/josm/tools/ImageProvider.java

    r7313 r7402  
    9393    /**
    9494     * Position of an overlay icon
    95      * @author imi
    9695     */
    9796    public static enum OverlayPosition {
     
    12771276                                    Node item = list.item(0);
    12781277                                    if (item instanceof Element) {
    1279                                         String value = ((Element)item).getAttribute("value");
    1280                                         String[] s = value.split(" ");
     1278                                        String[] s = ((Element)item).getAttribute("value").split(" ");
    12811279                                        if (s.length == 3) {
    1282                                             int[] rgb = new int[3];
    1283                                             try {
    1284                                                 for (int i = 0; i<3; i++) {
    1285                                                     rgb[i] = Integer.parseInt(s[i]);
    1286                                                 }
    1287                                                 return new Color(rgb[0], rgb[1], rgb[2]);
    1288                                             } catch (IllegalArgumentException e) {
    1289                                                 Main.error(e);
    1290                                             }
     1280                                            return parseRGB(s);
    12911281                                        }
    1292                                 }
     1282                                    }
    12931283                                }
    12941284                            }
     
    13031293        }
    13041294        return null;
     1295    }
     1296
     1297    private static Color parseRGB(String[] s) {
     1298        int[] rgb = new int[3];
     1299        try {
     1300            for (int i = 0; i<3; i++) {
     1301                rgb[i] = Integer.parseInt(s[i]);
     1302            }
     1303            return new Color(rgb[0], rgb[1], rgb[2]);
     1304        } catch (IllegalArgumentException e) {
     1305            Main.error(e);
     1306            return null;
     1307        }
    13051308    }
    13061309
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java

    r7344 r7402  
    5656
    5757    private static final byte[] INSECURE_PUBLIC_KEY = new byte[] {
    58         0x30, (byte) 0x82, 0x1, 0x22, 0x30, 0xd, 0x6, 0x9, 0x2a, (byte) 0x86, 0x48, (byte) 0x86, (byte) 0xf7, 0xd, 0x1, 0x1, 0x1, 0x5, 0x0, 0x3, (byte) 0x82, 0x1, 0xf, 0x0,
     58        0x30, (byte) 0x82, 0x1, 0x22, 0x30, 0xd, 0x6, 0x9, 0x2a, (byte) 0x86, 0x48,
     59        (byte) 0x86, (byte) 0xf7, 0xd, 0x1, 0x1, 0x1, 0x5, 0x0, 0x3, (byte) 0x82, 0x1, 0xf, 0x0,
    5960        0x30, (byte) 0x82, 0x01, 0x0a, 0x02, (byte) 0x82, 0x01, 0x01, 0x00, (byte) 0x95, (byte) 0x95, (byte) 0x88,
    60         (byte) 0x84, (byte) 0xc8, (byte) 0xd9, 0x6b, (byte) 0xc5, (byte) 0xda, 0x0b, 0x69, (byte) 0xbf, (byte) 0xfc, 0x7e, (byte) 0xb9, (byte) 0x96, 0x2c, (byte) 0xeb, (byte) 0x8f,
    61         (byte) 0xbc, 0x6e, 0x40, (byte) 0xe6, (byte) 0xe2, (byte) 0xfc, (byte) 0xf1, 0x7f, 0x73, (byte) 0xa7, (byte) 0x9d, (byte) 0xde, (byte) 0xc7, (byte) 0x88,
    62         0x57, 0x51, (byte) 0x84, (byte) 0xed, (byte) 0x96, (byte) 0xfb, (byte) 0xe1, 0x38, (byte) 0xef, 0x08, 0x2b, (byte) 0xf3, (byte) 0xc7, (byte) 0xc3,
    63         0x5d, (byte) 0xfe, (byte) 0xf9, 0x51, (byte) 0xe6, 0x29, (byte) 0xfc, (byte) 0xe5, 0x0d, (byte) 0xa1, 0x0d, (byte) 0xa8, (byte) 0xb4, (byte) 0xae,
    64         0x26, 0x18, 0x19, 0x4d, 0x6c, 0x0c, 0x3b, 0x12, (byte) 0xba, (byte) 0xbc, 0x5f, 0x32, (byte) 0xb3, (byte) 0xbe,
    65         (byte) 0x9d, 0x17, 0x0d, 0x4d, 0x2f, 0x1a, 0x48, (byte) 0xb7, (byte) 0xac, (byte) 0xf7, 0x1a, 0x43, 0x01, (byte) 0x97,
    66         (byte) 0xf4, (byte) 0xf8, 0x4c, (byte) 0xbb, 0x6a, (byte) 0xbc, 0x33, (byte) 0xe1, 0x73, 0x1e, (byte) 0x86, (byte) 0xfb, 0x2e, (byte) 0xb1,
    67         0x63, 0x75, (byte) 0x85, (byte) 0xdc, (byte) 0x82, 0x6c, 0x28, (byte) 0xf1, (byte) 0xe3, (byte) 0x90, 0x63, (byte) 0x9d, 0x3d, 0x48,
    68         (byte) 0x8a, (byte) 0x8c, 0x47, (byte) 0xe2, 0x10, 0x0b, (byte) 0xef, (byte) 0x91, (byte) 0x94, (byte) 0xb0, 0x6c, 0x4c, (byte) 0x80, 0x76,
    69         0x03, (byte) 0xe1, (byte) 0xb6, (byte) 0x90, (byte) 0x87, (byte) 0xd9, (byte) 0xae, (byte) 0xf4, (byte) 0x8e, (byte) 0xe0, (byte) 0x9f, (byte) 0xe7, 0x3a, 0x2c,
    70         0x2f, 0x21, (byte) 0xd4, 0x46, (byte) 0xba, (byte) 0x95, 0x70, (byte) 0xa9, 0x5b, 0x20, 0x2a, (byte) 0xfa, 0x52, 0x3e,
    71         (byte) 0x9d, (byte) 0xd9, (byte) 0xef, 0x28, (byte) 0xc5, (byte) 0xd1, 0x60, (byte) 0x89, 0x68, 0x6e, 0x7f, (byte) 0xd7, (byte) 0x9e, (byte) 0x89,
    72         0x4c, (byte) 0xeb, 0x4d, (byte) 0xd2, (byte) 0xc6, (byte) 0xf4, 0x2d, 0x02, 0x5d, (byte) 0xda, (byte) 0xde, 0x33, (byte) 0xfe, (byte) 0xc1,
    73         0x7e, (byte) 0xde, 0x4f, 0x1f, (byte) 0x9b, 0x6e, 0x6f, 0x0f, 0x66, 0x71, 0x19, (byte) 0xe9, 0x43, 0x3c,
    74         (byte) 0x83, 0x0a, 0x0f, 0x28, 0x21, (byte) 0xc8, 0x38, (byte) 0xd3, 0x4e, 0x48, (byte) 0xdf, (byte) 0xd4, (byte) 0x99, (byte) 0xb5,
    75         (byte) 0xc6, (byte) 0x8d, (byte) 0xd4, (byte) 0xc1, 0x69, 0x58, 0x79, (byte) 0x82, 0x32, (byte) 0x82, (byte) 0xd4, (byte) 0x86, (byte) 0xe2, 0x04,
    76         0x08, 0x63, (byte) 0x87, (byte) 0xf0, 0x2a, (byte) 0xf6, (byte) 0xec, 0x3e, 0x51, 0x0f, (byte) 0xda, (byte) 0xb4, 0x67, 0x19,
    77         0x5e, 0x16, 0x02, (byte) 0x9f, (byte) 0xf1, 0x19, 0x0c, 0x3e, (byte) 0xb8, 0x04, 0x49, 0x07, 0x53, 0x02,
    78         0x03, 0x01, 0x00, 0x01
     61        (byte) 0x84, (byte) 0xc8, (byte) 0xd9, 0x6b, (byte) 0xc5, (byte) 0xda, 0x0b, 0x69, (byte) 0xbf, (byte) 0xfc,
     62        0x7e, (byte) 0xb9, (byte) 0x96, 0x2c, (byte) 0xeb, (byte) 0x8f, (byte) 0xbc, 0x6e, 0x40, (byte) 0xe6, (byte) 0xe2,
     63        (byte) 0xfc, (byte) 0xf1, 0x7f, 0x73, (byte) 0xa7, (byte) 0x9d, (byte) 0xde, (byte) 0xc7, (byte) 0x88, 0x57, 0x51,
     64        (byte) 0x84, (byte) 0xed, (byte) 0x96, (byte) 0xfb, (byte) 0xe1, 0x38, (byte) 0xef, 0x08, 0x2b, (byte) 0xf3,
     65        (byte) 0xc7, (byte) 0xc3,  0x5d, (byte) 0xfe, (byte) 0xf9, 0x51, (byte) 0xe6, 0x29, (byte) 0xfc, (byte) 0xe5, 0x0d,
     66        (byte) 0xa1, 0x0d, (byte) 0xa8, (byte) 0xb4, (byte) 0xae, 0x26, 0x18, 0x19, 0x4d, 0x6c, 0x0c, 0x3b, 0x12, (byte) 0xba,
     67        (byte) 0xbc, 0x5f, 0x32, (byte) 0xb3, (byte) 0xbe, (byte) 0x9d, 0x17, 0x0d, 0x4d, 0x2f, 0x1a, 0x48, (byte) 0xb7,
     68        (byte) 0xac, (byte) 0xf7, 0x1a, 0x43, 0x01, (byte) 0x97, (byte) 0xf4, (byte) 0xf8, 0x4c, (byte) 0xbb, 0x6a, (byte) 0xbc,
     69        0x33, (byte) 0xe1, 0x73, 0x1e, (byte) 0x86, (byte) 0xfb, 0x2e, (byte) 0xb1, 0x63, 0x75, (byte) 0x85, (byte) 0xdc,
     70        (byte) 0x82, 0x6c, 0x28, (byte) 0xf1, (byte) 0xe3, (byte) 0x90, 0x63, (byte) 0x9d, 0x3d, 0x48, (byte) 0x8a, (byte) 0x8c,
     71        0x47, (byte) 0xe2, 0x10, 0x0b, (byte) 0xef, (byte) 0x91, (byte) 0x94, (byte) 0xb0, 0x6c, 0x4c, (byte) 0x80, 0x76, 0x03,
     72        (byte) 0xe1, (byte) 0xb6, (byte) 0x90, (byte) 0x87, (byte) 0xd9, (byte) 0xae, (byte) 0xf4, (byte) 0x8e, (byte) 0xe0,
     73        (byte) 0x9f, (byte) 0xe7, 0x3a, 0x2c, 0x2f, 0x21, (byte) 0xd4, 0x46, (byte) 0xba, (byte) 0x95, 0x70, (byte) 0xa9, 0x5b,
     74        0x20, 0x2a, (byte) 0xfa, 0x52, 0x3e, (byte) 0x9d, (byte) 0xd9, (byte) 0xef, 0x28, (byte) 0xc5, (byte) 0xd1, 0x60,
     75        (byte) 0x89, 0x68, 0x6e, 0x7f, (byte) 0xd7, (byte) 0x9e, (byte) 0x89, 0x4c, (byte) 0xeb, 0x4d, (byte) 0xd2, (byte) 0xc6,
     76        (byte) 0xf4, 0x2d, 0x02, 0x5d, (byte) 0xda, (byte) 0xde, 0x33, (byte) 0xfe, (byte) 0xc1, 0x7e, (byte) 0xde, 0x4f, 0x1f,
     77        (byte) 0x9b, 0x6e, 0x6f, 0x0f, 0x66, 0x71, 0x19, (byte) 0xe9, 0x43, 0x3c, (byte) 0x83, 0x0a, 0x0f, 0x28, 0x21, (byte) 0xc8,
     78        0x38, (byte) 0xd3, 0x4e, 0x48, (byte) 0xdf, (byte) 0xd4, (byte) 0x99, (byte) 0xb5, (byte) 0xc6, (byte) 0x8d, (byte) 0xd4,
     79        (byte) 0xc1, 0x69, 0x58, 0x79, (byte) 0x82, 0x32, (byte) 0x82, (byte) 0xd4, (byte) 0x86, (byte) 0xe2, 0x04, 0x08, 0x63,
     80        (byte) 0x87, (byte) 0xf0, 0x2a, (byte) 0xf6, (byte) 0xec, 0x3e, 0x51, 0x0f, (byte) 0xda, (byte) 0xb4, 0x67, 0x19, 0x5e,
     81        0x16, 0x02, (byte) 0x9f, (byte) 0xf1, 0x19, 0x0c, 0x3e, (byte) 0xb8, 0x04, 0x49, 0x07, 0x53, 0x02, 0x03, 0x01, 0x00, 0x01
    7982    };
    8083
     
    226229        if (!insecureCertificates.isEmpty()) {
    227230            StringBuilder message = new StringBuilder("<html>");
    228             message.append(tr("A previous version of JOSM has installed a custom certificate in order to provide HTTPS support for Remote Control:"));
     231            message.append(tr("A previous version of JOSM has installed a custom certificate "+
     232                    "in order to provide HTTPS support for Remote Control:"));
    229233            message.append("<br><ul>");
    230234            for (String alias : insecureCertificates) {
     
    235239            message.append("</ul>");
    236240            message.append(tr("It appears it could be an important <b>security risk</b>.<br><br>"+
    237                     "You are now going to be prompted by Windows to remove this insecure certificate.<br>For your own safety, <b>please click Yes</b> in next dialog."));
     241                    "You are now going to be prompted by Windows to remove this insecure certificate.<br>"+
     242                    "For your own safety, <b>please click Yes</b> in next dialog."));
    238243            message.append("</html>");
    239244            JOptionPane.showMessageDialog(Main.parent, message.toString(), tr("Warning"), JOptionPane.WARNING_MESSAGE);
     
    268273                "If unsure, you can also click No then disable HTTPS support in Remote Control preferences."));
    269274        message.append("</html>");
    270         JOptionPane.showMessageDialog(Main.parent, message.toString(), tr("HTTPS support in Remote Control"), JOptionPane.INFORMATION_MESSAGE);
     275        JOptionPane.showMessageDialog(Main.parent, message.toString(),
     276                tr("HTTPS support in Remote Control"), JOptionPane.INFORMATION_MESSAGE);
    271277        // install it to Windows-ROOT keystore, used by IE, Chrome and Safari, but not by Firefox
    272278        Main.info(tr("Adding JOSM localhost certificate to {0} keystore", WINDOWS_ROOT));
Note: See TracChangeset for help on using the changeset viewer.