Changeset 31429 in osm for applications/viewer/jmapviewer


Ignore:
Timestamp:
2015-08-01T21:26:26+02:00 (9 years ago)
Author:
donvip
Message:

[jmapviewer] fix checkstyle issues

Location:
applications/viewer/jmapviewer
Files:
48 edited

Legend:

Unmodified
Added
Removed
  • applications/viewer/jmapviewer/.checkstyle

    r31428 r31429  
    88    <file-match-pattern match-pattern="." include-pattern="true"/>
    99  </fileset>
     10  <filter name="FilesFromPackage" enabled="true">
     11    <filter-data value="src/org/openstreetmap/gui/jmapviewer/images"/>
     12  </filter>
    1013</fileset-config>
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/AbstractLayer.java

    r30900 r31429  
    1111    private Style style;
    1212    private Boolean visible;
    13     private Boolean visibleTexts=true;
     13    private Boolean visibleTexts = true;
    1414
    15     public AbstractLayer(String name){
    16         this(name, (String)null);
     15    public AbstractLayer(String name) {
     16        this(name, (String) null);
    1717    }
    18     public AbstractLayer(String name, String description){
     18
     19    public AbstractLayer(String name, String description) {
    1920        this(name, description, MapMarkerCircle.getDefaultStyle());
    2021    }
    21     public AbstractLayer(String name, Style style){
     22
     23    public AbstractLayer(String name, Style style) {
    2224        this(name, null, style);
    2325    }
    24     public AbstractLayer(String name, String description, Style style){
     26
     27    public AbstractLayer(String name, String description, Style style) {
    2528        this(null, name, description, style);
    2629    }
    27     public AbstractLayer(LayerGroup parent, String name){
     30
     31    public AbstractLayer(LayerGroup parent, String name) {
    2832        this(parent, name, MapMarkerCircle.getDefaultStyle());
    2933    }
    30     public AbstractLayer(LayerGroup parent, String name, Style style){
     34
     35    public AbstractLayer(LayerGroup parent, String name, Style style) {
    3136        this(parent, name, null, style);
    3237    }
    33     public AbstractLayer(LayerGroup parent, String name, String description, Style style){
     38
     39    public AbstractLayer(LayerGroup parent, String name, String description, Style style) {
    3440        setParent(parent);
    3541        setName(name);
     
    3844        setVisible(true);
    3945
    40         if(parent!=null) parent.add(this);
     46        if (parent != null) parent.add(this);
    4147    }
     48
    4249    public LayerGroup getParent() {
    4350        return parent;
    4451    }
     52
    4553    public void setParent(LayerGroup parent) {
    4654        this.parent = parent;
    4755    }
     56
    4857    public String getName() {
    4958        return name;
    5059    }
     60
    5161    public void setName(String name) {
    5262        this.name = name;
    5363    }
     64
    5465    public String getDescription() {
    5566        return description;
    5667    }
     68
    5769    public void setDescription(String description) {
    5870        this.description = description;
    5971    }
     72
    6073    public Style getStyle() {
    6174        return style;
    6275    }
     76
    6377    public void setStyle(Style style) {
    6478        this.style = style;
    6579    }
     80
    6681    public Boolean isVisible() {
    6782        return visible;
    6883    }
     84
    6985    public void setVisible(Boolean visible) {
    7086        this.visible = visible;
    7187    }
     88
    7289    public static <E> List<E> add(List<E> list, E element) {
    73         if(element!=null){
    74             if(list==null) list = new ArrayList<>();
    75             if(!list.contains(element)) list.add(element);
     90        if (element != null) {
     91            if (list == null) list = new ArrayList<>();
     92            if (!list.contains(element)) list.add(element);
    7693        }
    7794        return list;
    7895    }
     96
    7997    public Boolean isVisibleTexts() {
    8098        return visibleTexts;
    8199    }
     100
    82101    public void setVisibleTexts(Boolean visibleTexts) {
    83102        this.visibleTexts = visibleTexts;
    84103    }
    85     public String toString(){
     104
     105    public String toString() {
    86106        return name;
    87107    }
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/AttributionSupport.java

    r31301 r31429  
    5454    }
    5555
    56     public void paintAttribution(Graphics g, int width, int height, ICoordinate topLeft, ICoordinate bottomRight, int zoom, ImageObserver observer) {
     56    public void paintAttribution(Graphics g, int width, int height, ICoordinate topLeft, ICoordinate bottomRight,
     57            int zoom, ImageObserver observer) {
    5758        if (source == null || !source.requiresAttribution()) {
    5859            attrToUBounds = null;
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/DefaultMapController.java

    r31293 r31429  
    4343            return;
    4444        // Is only the selected mouse button pressed?
    45         if ((e.getModifiersEx() & MOUSE_BUTTONS_MASK) == movementMouseButtonMask || isPlatformOsx() && e.getModifiersEx() == MAC_MOUSE_BUTTON3_MASK) {
     45        if ((e.getModifiersEx() & MOUSE_BUTTONS_MASK) == movementMouseButtonMask
     46                || isPlatformOsx() && e.getModifiersEx() == MAC_MOUSE_BUTTON3_MASK) {
    4647            Point p = e.getPoint();
    4748            if (lastDragPoint != null) {
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Demo.java

    r31293 r31429  
    4141    private JMapViewerTree treeMap = null;
    4242
    43     private JLabel zoomLabel=null;
    44     private JLabel zoomValue=null;
    45 
    46     private JLabel mperpLabelName=null;
     43    private JLabel zoomLabel = null;
     44    private JLabel zoomValue = null;
     45
     46    private JLabel mperpLabelName = null;
    4747    private JLabel mperpLabelValue = null;
    4848
     
    6868        JPanel helpPanel = new JPanel();
    6969
    70         mperpLabelName=new JLabel("Meters/Pixels: ");
    71         mperpLabelValue=new JLabel(String.format("%s",map().getMeterPerPixel()));
    72 
    73         zoomLabel=new JLabel("Zoom: ");
    74         zoomValue=new JLabel(String.format("%s", map().getZoom()));
     70        mperpLabelName = new JLabel("Meters/Pixels: ");
     71        mperpLabelValue = new JLabel(String.format("%s", map().getMeterPerPixel()));
     72
     73        zoomLabel = new JLabel("Zoom: ");
     74        zoomValue = new JLabel(String.format("%s", map().getZoom()));
    7575
    7676        add(panel, BorderLayout.NORTH);
     
    101101        });
    102102        JComboBox<TileLoader> tileLoaderSelector;
    103         tileLoaderSelector = new JComboBox<>(new TileLoader[] { new OsmTileLoader(map()) });
     103        tileLoaderSelector = new JComboBox<>(new TileLoader[] {new OsmTileLoader(map())});
    104104        tileLoaderSelector.addItemListener(new ItemListener() {
    105105            public void itemStateChanged(ItemEvent e) {
     
    187187        treeMap.addLayer(germanyEastLayer);
    188188
    189         MapPolygon bermudas = new MapPolygonImpl(c(49,1), c(45,10), c(40,5));
    190         map().addMapPolygon( bermudas );
    191         map().addMapPolygon( new MapPolygonImpl(germanyEastLayer, "Riedstadt", ebersheim, darmstadt, eberstadt, empty));
     189        MapPolygon bermudas = new MapPolygonImpl(c(49, 1), c(45, 10), c(40, 5));
     190        map().addMapPolygon(bermudas);
     191        map().addMapPolygon(new MapPolygonImpl(germanyEastLayer, "Riedstadt", ebersheim, darmstadt, eberstadt, empty));
    192192
    193193        map().addMapMarker(new MapMarkerCircle(germanyWestLayer, "North of Suisse", new Coordinate(48, 7), .5));
     
    197197
    198198        Layer wales = treeMap.addLayer("UK");
    199         map().addMapRectangle(new MapRectangleImpl(wales, "Wales", c(53.35,-4.57), c(51.64,-2.63)));
     199        map().addMapRectangle(new MapRectangleImpl(wales, "Wales", c(53.35, -4.57), c(51.64, -2.63)));
    200200
    201201        // map.setDisplayPosition(new Coordinate(49.807, 8.6), 11);
     
    221221                    map().setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    222222                }
    223                 if(showToolTip.isSelected()) map().setToolTipText(map().getPosition(p).toString());
    224             }
    225         });
    226     }
    227     private JMapViewer map(){
     223                if (showToolTip.isSelected()) map().setToolTipText(map().getPosition(p).toString());
     224            }
     225        });
     226    }
     227
     228    private JMapViewer map() {
    228229        return treeMap.getViewer();
    229230    }
    230     private static Coordinate c(double lat, double lon){
     231
     232    private static Coordinate c(double lat, double lon) {
    231233        return new Coordinate(lat, lon);
    232234    }
     
    240242
    241243    private void updateZoomParameters() {
    242         if (mperpLabelValue!=null)
    243             mperpLabelValue.setText(String.format("%s",map().getMeterPerPixel()));
    244         if (zoomValue!=null)
     244        if (mperpLabelValue != null)
     245            mperpLabelValue.setText(String.format("%s", map().getMeterPerPixel()));
     246        if (zoomValue != null)
    245247            zoomValue.setText(String.format("%s", map().getZoom()));
    246248    }
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/FeatureAdapter.java

    r30848 r31429  
    99import java.util.logging.Logger;
    1010
    11 public class FeatureAdapter {
     11public final class FeatureAdapter {
    1212
    13     public static interface BrowserAdapter {
     13    private FeatureAdapter() {
     14        // private constructor for utility classes
     15    }
     16   
     17    public interface BrowserAdapter {
    1418        void openLink(String url);
    1519    }
    1620
    17     public static interface TranslationAdapter {
     21    public interface TranslationAdapter {
    1822        String tr(String text, Object... objects);
    1923        // TODO: more i18n functions
    2024    }
    2125
    22     public static interface LoggingAdapter {
     26    public interface LoggingAdapter {
    2327        Logger getLogger(String name);
    2428    }
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java

    r31427 r31429  
    4949     * Vectors for clock-wise tile painting
    5050     */
    51     protected static final Point[] move = { new Point(1, 0), new Point(0, 1), new Point(-1, 0), new Point(0, -1) };
     51    protected static final Point[] move = {new Point(1, 0), new Point(0, 1), new Point(-1, 0), new Point(0, -1)};
    5252
    5353    public static final int MAX_ZOOM = 22;
     
    424424     * @param lon longitude
    425425     * @param offset Offset respect Latitude
    426      * @param checkOutside
     426     * @param checkOutside check if the point is outside the displayed area
    427427     * @return Integer the radius in pixels
    428428     */
     
    444444     * @param checkOutside check if the point is outside the displayed area
    445445     * @return Integer the radius in pixels
     446     * @deprecated use {@link #getLatOffset(double, double, double, boolean)}
    446447     */
    447448    @Deprecated
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/JMapViewerTree.java

    r31427 r31429  
    3535    private JSplitPane splitPane;
    3636
    37     public JMapViewerTree(String name){
     37    public JMapViewerTree(String name) {
    3838        this(name, false);
    3939    }
    40     public JMapViewerTree(String name, boolean treeVisible){
     40
     41    public JMapViewerTree(String name, boolean treeVisible) {
    4142        super();
    4243        splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
     
    6465                maybeShowPopup(e);
    6566            }
     67
    6668            @Override
    6769            public void mouseReleased(MouseEvent e) {
    6870                maybeShowPopup(e);
    6971            }
     72
    7073            private void maybeShowPopup(MouseEvent e) {
    7174                if (e.isPopupTrigger()) {
    72                     AbstractLayer layer = ((CheckBoxNodePanel)e.getComponent()).getData().getAbstractLayer();
    73                     if(layer!=null)
     75                    AbstractLayer layer = ((CheckBoxNodePanel) e.getComponent()).getData().getAbstractLayer();
     76                    if (layer != null)
    7477                        JMapViewerTree.this.createPopupMenu(layer).show(e.getComponent(), e.getX(), e.getY());
    7578                }
     
    7780        });
    7881    }
     82
    7983    private JPopupMenu createPopupMenu(final AbstractLayer layer) {
    8084        JMenuItem menuItemShow = new JMenuItem("show texts");
     
    8589
    8690        // Create items
    87         if(layer.isVisibleTexts()==null){
     91        if (layer.isVisibleTexts() == null) {
    8892            popup.add(menuItemShow);
    8993            popup.add(menuItemHide);
    90         }else if(layer.isVisibleTexts()) popup.add(menuItemHide);
     94        } else if (layer.isVisibleTexts()) popup.add(menuItemHide);
    9195        else popup.add(menuItemShow);
    9296
     
    9599            public void actionPerformed(ActionEvent arg0) {
    96100                setVisibleTexts(layer, true);
    97                 if(layer.getParent()!=null) layer.getParent().calculateVisibleTexts();
     101                if (layer.getParent() != null) layer.getParent().calculateVisibleTexts();
    98102                map.repaint();
    99103            }
     
    103107            public void actionPerformed(ActionEvent arg0) {
    104108                setVisibleTexts(layer, false);
    105                 if(layer.getParent()!=null) layer.getParent().calculateVisibleTexts();
     109                if (layer.getParent() != null) layer.getParent().calculateVisibleTexts();
    106110                map.repaint();
    107111            }
     
    110114        return popup;
    111115    }
    112     private void setVisibleTexts(AbstractLayer layer, boolean visible){
     116
     117    private void setVisibleTexts(AbstractLayer layer, boolean visible) {
    113118        layer.setVisibleTexts(visible);
    114         if(layer instanceof LayerGroup){
    115             LayerGroup group = (LayerGroup)layer;
    116             if(group.getLayers()!=null) for(AbstractLayer al: group.getLayers()) setVisibleTexts(al, visible);
     119        if (layer instanceof LayerGroup) {
     120            LayerGroup group = (LayerGroup) layer;
     121            if (group.getLayers() != null)
     122                for (AbstractLayer al: group.getLayers()) {
     123                    setVisibleTexts(al, visible);
     124                }
    117125        }
    118126    }
    119     public Layer addLayer(String name){
     127
     128    public Layer addLayer(String name) {
    120129        Layer layer = new Layer(name);
    121130        this.addLayer(layer);
    122131        return layer;
    123132    }
    124     public JMapViewerTree addLayer(Layer layer){
     133
     134    public JMapViewerTree addLayer(Layer layer) {
    125135        tree.addLayer(layer);
    126136        return this;
    127137    }
    128     public JMapViewerTree addLayer(MapObject element){
     138
     139    public JMapViewerTree addLayer(MapObject element) {
    129140        //element.getLayer().add(element);
    130141        return addLayer(element.getLayer());
    131142    }
    132     public Layer removeFromLayer(MapObject element){
     143
     144    public Layer removeFromLayer(MapObject element) {
    133145        element.getLayer().getElements().remove(element);
    134146        return element.getLayer();
    135147    }
    136     public static int size(List<?> list){
    137         return list==null?0:list.size();
     148
     149    public static int size(List<?> list) {
     150        return list == null ? 0 : list.size();
    138151    }
    139     public JMapViewer getViewer(){
     152
     153    public JMapViewer getViewer() {
    140154        return map;
    141155    }
    142     public CheckBoxTree getTree(){
     156
     157    public CheckBoxTree getTree() {
    143158        return tree;
    144159    }
     160
    145161    public void addMapObject(MapObject o){
    146162
    147163    }
    148     public void setTreeVisible(boolean visible){
     164
     165    public void setTreeVisible(boolean visible) {
    149166        removeAll();
    150167        revalidate();
    151         if(visible){
     168        if (visible) {
    152169            splitPane.setLeftComponent(treePanel);
    153170            splitPane.setRightComponent(map);
    154171            add(splitPane, BorderLayout.CENTER);
    155         }else add(map, BorderLayout.CENTER);
     172        } else add(map, BorderLayout.CENTER);
    156173        repaint();
    157174    }
    158     private void createRefresh(){
     175
     176    private void createRefresh() {
    159177        tree.getModel().addTreeModelListener(new TreeModelListener() {
    160178            @Override
     
    162180                repaint();
    163181            }
     182
    164183            @Override
    165184            public void treeNodesInserted(TreeModelEvent arg0) {
    166185                // TODO Auto-generated method stub
    167186            }
     187
    168188            @Override
    169189            public void treeNodesRemoved(TreeModelEvent arg0) {
    170190                // TODO Auto-generated method stub
    171191            }
     192
    172193            @Override
    173194            public void treeStructureChanged(TreeModelEvent arg0) {
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/JobDispatcher.java

    r31427 r31429  
    1717 * @author Jan Peter Stotz
    1818 */
    19 public class JobDispatcher {
     19public final class JobDispatcher {
    2020
    2121    private static final JobDispatcher instance = new JobDispatcher();
     
    7474     * Function to set the maximum number of workers for tile loading.
    7575     */
    76     static public void setMaxWorkers(int workers) {
     76    public static void setMaxWorkers(int workers) {
    7777        workerThreadMaxCount = workers;
    7878    }
     
    9696    public void addJob(TileJob job) {
    9797        try {
    98             if(job.getTile() != null) {
    99                 for(TileJob oldJob : jobQueue) {
     98            if (job.getTile() != null) {
     99                for (TileJob oldJob : jobQueue) {
    100100                    if (job.getTile().equals(oldJob.getTile())) {
    101101                        return;
     
    109109            }
    110110        } catch (InterruptedException e) {
     111            System.err.println("InterruptedException: " + e.getMessage());
    111112        }
    112113    }
     
    146147                        workerThreadIdleCount++;
    147148                    }
    148                     if(modeLIFO) {
     149                    if (modeLIFO) {
    149150                        if (firstThread)
    150151                            job = jobQueue.takeLast();
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Layer.java

    r30900 r31429  
    99    private List<MapObject> elements;
    1010   
    11     public Layer(String name){
     11    public Layer(String name) {
    1212        super(name);
    1313    }
    14     public Layer(String name, String description){
     14
     15    public Layer(String name, String description) {
    1516        super(name, description);
    1617    }
    17     public Layer(String name, Style style){
     18
     19    public Layer(String name, Style style) {
    1820        super(name, style);
    1921    }
    20     public Layer(String name, String description, Style style){
     22
     23    public Layer(String name, String description, Style style) {
    2124        super(name, description, style);
    2225    }
    23     public Layer(LayerGroup parent, String name){
     26
     27    public Layer(LayerGroup parent, String name) {
    2428        super(parent, name);
    2529    }
    26     public Layer(LayerGroup parent, String name, Style style){
     30
     31    public Layer(LayerGroup parent, String name, Style style) {
    2732        super(parent, name, style);
    2833    }
    29     public Layer(LayerGroup parent, String name, String description, Style style){
     34
     35    public Layer(LayerGroup parent, String name, String description, Style style) {
    3036        super(parent, name, description, style);
    3137    }
     38
    3239    public List<MapObject> getElements() {
    3340        return elements;
    3441    }
     42
    3543    public void setElements(List<MapObject> elements) {
    3644        this.elements = elements;
    3745    }
     46
    3847    public Layer add(MapObject element) {
    3948        element.setLayer(this);
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/LayerGroup.java

    r31427 r31429  
    77    private List<AbstractLayer> layers;
    88
    9     public LayerGroup(String name){
     9    public LayerGroup(String name) {
    1010        super(name);
    1111    }
    12     public LayerGroup(String name, String description){
     12
     13    public LayerGroup(String name, String description) {
    1314        super(name, description);
    1415    }
    15     public LayerGroup(String name, Style style){
     16
     17    public LayerGroup(String name, Style style) {
    1618        super(name, style);
    1719    }
    18     public LayerGroup(String name, String description, Style style){
     20
     21    public LayerGroup(String name, String description, Style style) {
    1922        super(name, description, style);
    2023    }
    21     public LayerGroup(LayerGroup parent, String name){
     24
     25    public LayerGroup(LayerGroup parent, String name) {
    2226        super(parent, name);
    2327    }
    24     public LayerGroup(LayerGroup parent, String name, String description, Style style){
     28
     29    public LayerGroup(LayerGroup parent, String name, String description, Style style) {
    2530        super(name, description, style);
    2631    }
     32
    2733    public List<AbstractLayer> getLayers() {
    2834        return layers;
    2935    }
     36
    3037    public void setElements(List<AbstractLayer> layers) {
    3138        this.layers = layers;
    3239    }
     40
    3341    public Layer addLayer(String name) {
    3442        Layer layer = new Layer(this, name);
     
    3644        return layer;
    3745    }
     46
    3847    public LayerGroup add(AbstractLayer layer) {
    3948        layer.setParent(this);
     
    4150        return this;
    4251    }
     52
    4353    public void calculateVisibleTexts() {
    44         Boolean calculate=null;
    45         if (layers!=null&&layers.size()>0){
    46             calculate=layers.get(0).isVisibleTexts();
    47             for (int i=1;i<layers.size(); i++){
     54        Boolean calculate = null;
     55        if (layers != null && layers.size() > 0) {
     56            calculate = layers.get(0).isVisibleTexts();
     57            for (int i = 1; i < layers.size(); i++) {
    4858                calculate = resultOf(calculate, layers.get(i).isVisibleTexts());
    4959            }
    5060        }
    5161        setVisibleTexts(calculate);
    52         if(getParent()!=null) getParent().calculateVisibleTexts();
     62        if (getParent() != null) getParent().calculateVisibleTexts();
    5363    }
     64
    5465    public Boolean resultOf(Boolean b1, Boolean b2) {
    5566        if (b1 != null && b1.equals(b2)) {
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/MapMarkerCircle.java

    r31293 r31429  
    2828        this(null, null, coord, radius);
    2929    }
     30
    3031    public MapMarkerCircle(String name, Coordinate coord, double radius) {
    3132        this(null, name, coord, radius);
    3233    }
     34
    3335    public MapMarkerCircle(Layer layer, Coordinate coord, double radius) {
    3436        this(layer, null, coord, radius);
    3537    }
     38
    3639    public MapMarkerCircle(double lat, double lon, double radius) {
    37         this(null, null, new Coordinate(lat,lon), radius);
     40        this(null, null, new Coordinate(lat, lon), radius);
    3841    }
     42
    3943    public MapMarkerCircle(Layer layer, double lat, double lon, double radius) {
    40         this(layer, null, new Coordinate(lat,lon), radius);
     44        this(layer, null, new Coordinate(lat, lon), radius);
    4145    }
     46
    4247    public MapMarkerCircle(Layer layer, String name, Coordinate coord, double radius) {
    4348        this(layer, name, coord, radius, STYLE.VARIABLE, getDefaultStyle());
    4449    }
     50
    4551    public MapMarkerCircle(Layer layer, String name, Coordinate coord, double radius, STYLE markerStyle, Style style) {
    4652        super(layer, name, style);
     
    5056    }
    5157
    52     public Coordinate getCoordinate(){
     58    public Coordinate getCoordinate() {
    5359        return coord;
    5460    }
     61
    5562    public double getLat() {
    5663        return coord.getLat();
     
    7380        int size = size_h * 2;
    7481
    75         if (g instanceof Graphics2D && getBackColor()!=null) {
     82        if (g instanceof Graphics2D && getBackColor() != null) {
    7683            Graphics2D g2 = (Graphics2D) g;
    7784            Composite oldComposite = g2.getComposite();
     
    8491        g.drawOval(position.x - size_h, position.y - size_h, size, size);
    8592
    86         if(getLayer()==null||getLayer().isVisibleTexts()) paintText(g, position);
     93        if (getLayer() == null || getLayer().isVisibleTexts()) paintText(g, position);
    8794    }
    8895
    89     public static Style getDefaultStyle(){
    90         return new Style(Color.ORANGE, new Color(200,200,200,200), null, getDefaultFont());
     96    public static Style getDefaultStyle() {
     97        return new Style(Color.ORANGE, new Color(200, 200, 200, 200), null, getDefaultFont());
    9198    }
     99
    92100    @Override
    93101    public String toString() {
    94102        return "MapMarker at " + getLat() + " " + getLon();
    95103    }
     104
    96105    @Override
    97106    public void setLat(double lat) {
    98         if(coord==null) coord = new Coordinate(lat,0);
     107        if (coord == null) coord = new Coordinate(lat, 0);
    99108        else coord.setLat(lat);
    100109    }
     110
    101111    @Override
    102112    public void setLon(double lon) {
    103         if(coord==null) coord = new Coordinate(0,lon);
     113        if (coord == null) coord = new Coordinate(0, lon);
    104114        else coord.setLon(lon);
    105115    }
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/MapMarkerDot.java

    r30900 r31429  
    2121        this(null, null, coord);
    2222    }
     23
    2324    public MapMarkerDot(String name, Coordinate coord) {
    2425        this(null, name, coord);
    2526    }
     27
    2628    public MapMarkerDot(Layer layer, Coordinate coord) {
    2729        this(layer, null, coord);
    2830    }
     31
    2932    public MapMarkerDot(Layer layer, String name, Coordinate coord) {
    3033        this(layer, name, coord, getDefaultStyle());
    3134    }
     35
    3236    public MapMarkerDot(Color color, double lat, double lon) {
    3337        this(null, null, lat, lon);
    3438        setColor(color);
    3539    }
     40
    3641    public MapMarkerDot(double lat, double lon) {
    3742        this(null, null, lat, lon);
    3843    }
     44
    3945    public MapMarkerDot(Layer layer, double lat, double lon) {
    4046        this(layer, null, lat, lon);
    4147    }
     48
    4249    public MapMarkerDot(Layer layer, String name, double lat, double lon) {
    4350        this(layer, name, new Coordinate(lat, lon), getDefaultStyle());
    4451    }
     52
    4553    public MapMarkerDot(Layer layer, String name, Coordinate coord, Style style) {
    4654        super(layer, name, coord, DOT_RADIUS, STYLE.FIXED, style);
    4755    }
    4856
    49     public static Style getDefaultStyle(){
     57    public static Style getDefaultStyle() {
    5058        return new Style(Color.BLACK, Color.YELLOW, null, getDefaultFont());
    5159    }
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/MapObjectImpl.java

    r31427 r31429  
    1919        this(null, name, null);
    2020    }
     21
    2122    public MapObjectImpl(Layer layer) {
    2223        this(layer, null, null);
    2324    }
     25
    2426    public MapObjectImpl(Layer layer, String name, Style style) {
    2527        super();
     
    2830        this.style = style;
    2931    }
     32
    3033    public Layer getLayer() {
    3134        return layer;
    3235    }
     36
    3337    public void setLayer(Layer layer) {
    3438        this.layer = layer;
    3539    }
    36     public Style getStyle(){
     40
     41    public Style getStyle() {
    3742        return style;
    3843    }
    39     public Style getStyleAssigned(){
     44
     45    public Style getStyleAssigned() {
    4046        return style == null ? (layer == null ? null : layer.getStyle()) : style;
    4147    }
    42     public void setStyle(Style style){
     48
     49    public void setStyle(Style style) {
    4350        this.style = style;
    4451    }
     52
    4553    public Color getColor() {
    4654        Style styleAssigned = getStyleAssigned();
    4755        return styleAssigned == null ? null : getStyleAssigned().getColor();
    4856    }
     57
    4958    public void setColor(Color color) {
    50         if(style==null&&color!=null) style=new Style();
    51         if(style!=null) style.setColor(color);
     59        if (style == null && color != null) style = new Style();
     60        if (style != null) style.setColor(color);
    5261    }
    5362
     
    5665        return styleAssigned == null ? null : getStyleAssigned().getBackColor();
    5766    }
     67
    5868    public void setBackColor(Color backColor) {
    59         if(style==null&&backColor!=null) style=new Style();
    60         if(style!=null) style.setBackColor(backColor);
     69        if (style == null && backColor != null) style = new Style();
     70        if (style != null) style.setBackColor(backColor);
    6171    }
    6272
     
    6575        return styleAssigned == null ? null : getStyleAssigned().getStroke();
    6676    }
     77
    6778    public void setStroke(Stroke stroke) {
    68         if(style==null&&stroke!=null) style=new Style();
    69         if(style!=null) style.setStroke(stroke);
     79        if (style == null && stroke != null) style = new Style();
     80        if (style != null) style.setStroke(stroke);
    7081    }
    7182
     
    7485        return styleAssigned == null ? null : getStyleAssigned().getFont();
    7586    }
     87
    7688    public void setFont(Font font) {
    77         if(style==null&&font!=null) style=new Style();
    78         if(style!=null) style.setFont(font);
     89        if (style == null && font != null) style = new Style();
     90        if (style != null) style.setFont(font);
    7991    }
    80     private boolean isVisibleLayer(){
    81         return layer==null||layer.isVisible()==null?true:layer.isVisible();
     92
     93    private boolean isVisibleLayer() {
     94        return layer == null || layer.isVisible() == null ? true : layer.isVisible();
    8295    }
     96
    8397    public boolean isVisible() {
    84         return visible==null?isVisibleLayer():visible.booleanValue();
     98        return visible == null ? isVisibleLayer() : visible.booleanValue();
    8599    }
     100
    86101    public void setVisible(Boolean visible) {
    87102        this.visible = visible;
    88103    }
     104
    89105    public String getName() {
    90106        return name;
    91107    }
     108
    92109    public void setName(String txt) {
    93110        this.name = txt;
    94111    }
    95     public static Font getDefaultFont(){
     112
     113    public static Font getDefaultFont() {
    96114        Font f = UIManager.getDefaults().getFont("TextField.font");
    97115        if (f == null) {
     
    102120
    103121    public void paintText(Graphics g, Point position) {
    104         if(name!=null && g!=null && position!=null){
    105             if(getFont()==null){
     122        if (name != null && g != null && position != null) {
     123            if (getFont() == null) {
    106124                Font f = getDefaultFont();
    107125                setFont(new Font(f.getName(), Font.BOLD, f.getSize()));
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/MapPolygonImpl.java

    r30223 r31429  
    2525        this(null, null, points);
    2626    }
     27
    2728    public MapPolygonImpl(List<? extends ICoordinate> points) {
    2829        this(null, null, points);
    2930    }
     31
    3032    public MapPolygonImpl(String name, List<? extends ICoordinate> points) {
    3133        this(null, name, points);
    3234    }
     35
    3336    public MapPolygonImpl(String name, ICoordinate ... points) {
    3437        this(null, name, points);
    3538    }
     39
    3640    public MapPolygonImpl(Layer layer, List<? extends ICoordinate> points) {
    3741        this(layer, null, points);
    3842    }
     43
    3944    public MapPolygonImpl(Layer layer, String name, List<? extends ICoordinate> points) {
    4045        this(layer, name, points, getDefaultStyle());
    4146    }
     47
    4248    public MapPolygonImpl(Layer layer, String name, ICoordinate ... points) {
    4349        this(layer, name, Arrays.asList(points), getDefaultStyle());
    4450    }
     51
    4552    public MapPolygonImpl(Layer layer, String name, List<? extends ICoordinate> points, Style style) {
    4653        super(layer, name, style);
     
    7683        // Draw
    7784        g.drawPolygon(polygon);
    78         if (g instanceof Graphics2D && getBackColor()!=null) {
     85        if (g instanceof Graphics2D && getBackColor() != null) {
    7986            Graphics2D g2 = (Graphics2D) g;
    8087            Composite oldComposite = g2.getComposite();
     
    9198        Rectangle rec = polygon.getBounds();
    9299        Point corner = rec.getLocation();
    93         Point p= new Point(corner.x+(rec.width/2), corner.y+(rec.height/2));
    94         if(getLayer()==null||getLayer().isVisibleTexts()) paintText(g, p);
     100        Point p = new Point(corner.x+(rec.width/2), corner.y+(rec.height/2));
     101        if (getLayer() == null || getLayer().isVisibleTexts()) paintText(g, p);
    95102    }
    96103
    97     public static Style getDefaultStyle(){
    98         return new Style(Color.BLUE, new Color(100,100,100,50), new BasicStroke(2), getDefaultFont());
     104    public static Style getDefaultStyle() {
     105        return new Style(Color.BLUE, new Color(100, 100, 100, 50), new BasicStroke(2), getDefaultFont());
    99106    }
    100107
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/MapRectangleImpl.java

    r30223 r31429  
    1919        this(null, null, topLeft, bottomRight);
    2020    }
     21
    2122    public MapRectangleImpl(String name, Coordinate topLeft, Coordinate bottomRight) {
    2223        this(null, name, topLeft, bottomRight);
    2324    }
     25
    2426    public MapRectangleImpl(Layer layer, Coordinate topLeft, Coordinate bottomRight) {
    2527        this(layer, null, topLeft, bottomRight);
    2628    }
     29
    2730    public MapRectangleImpl(Layer layer, String name, Coordinate topLeft, Coordinate bottomRight) {
    2831        this(layer, name, topLeft, bottomRight, getDefaultStyle());
    2932    }
     33
    3034    public MapRectangleImpl(Layer layer, String name, Coordinate topLeft, Coordinate bottomRight, Style style) {
    3135        super(layer, name, style);
     
    6266            ((Graphics2D) g).setStroke(oldStroke);
    6367        }
    64         int width=bottomRight.x-topLeft.x;
    65         int height=bottomRight.y-topLeft.y;
    66         Point p= new Point(topLeft.x+(width/2), topLeft.y+(height/2));
    67         if(getLayer()==null||getLayer().isVisibleTexts()) paintText(g, p);
     68        int width = bottomRight.x-topLeft.x;
     69        int height = bottomRight.y-topLeft.y;
     70        Point p = new Point(topLeft.x+(width/2), topLeft.y+(height/2));
     71        if (getLayer() == null || getLayer().isVisibleTexts()) paintText(g, p);
    6872    }
    6973
    70     public static Style getDefaultStyle(){
     74    public static Style getDefaultStyle() {
    7175        return new Style(Color.BLUE, null, new BasicStroke(2), getDefaultFont());
    7276    }
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmMercator.java

    r31293 r31429  
    101101        double aStartLat = Math.toRadians(la1);
    102102        double aStartLong = Math.toRadians(lo1);
    103         double aEndLat =Math.toRadians(la2);
     103        double aEndLat = Math.toRadians(la2);
    104104        double aEndLong = Math.toRadians(lo2);
    105105
     
    130130    public double LonToX(double aLongitude, int aZoomlevel) {
    131131        int mp = getMaxPixels(aZoomlevel);
    132         double x = (mp * (aLongitude + 180l)) / 360l;
     132        double x = (mp * (aLongitude + 180L)) / 360L;
    133133        return Math.min(x, mp);
    134134    }
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java

    r31145 r31429  
    2222public class OsmTileLoader implements TileLoader {
    2323
     24    private final class OsmTileJob implements TileJob {
     25        private final Tile tile;
     26        InputStream input = null;
     27        boolean force = false;
     28
     29        private OsmTileJob(Tile tile) {
     30            this.tile = tile;
     31        }
     32
     33        public void run() {
     34            synchronized (tile) {
     35                if ((tile.isLoaded() && !tile.hasError()) || tile.isLoading())
     36                    return;
     37                tile.loaded = false;
     38                tile.error = false;
     39                tile.loading = true;
     40            }
     41            try {
     42                URLConnection conn = loadTileFromOsm(tile);
     43                if (force) {
     44                    conn.setUseCaches(false);
     45                }
     46                loadTileMetadata(tile, conn);
     47                if ("no-tile".equals(tile.getValue("tile-info"))) {
     48                    tile.setError("No tile at this zoom level");
     49                } else {
     50                    input = conn.getInputStream();
     51                    try {
     52                        tile.loadImage(input);
     53                    } finally {
     54                        input.close();
     55                        input = null;
     56                    }
     57                }
     58                tile.setLoaded(true);
     59                listener.tileLoadingFinished(tile, true);
     60            } catch (Exception e) {
     61                tile.setError(e.getMessage());
     62                listener.tileLoadingFinished(tile, false);
     63                if (input == null) {
     64                    try {
     65                        System.err.println("Failed loading " + tile.getUrl() +": "
     66                                +e.getClass() + ": " + e.getMessage());
     67                    } catch (IOException ioe) {
     68                        ioe.printStackTrace();
     69                    }
     70                }
     71            } finally {
     72                tile.loading = false;
     73                tile.setLoaded(true);
     74            }
     75        }
     76
     77        public Tile getTile() {
     78            return tile;
     79        }
     80
     81        @Override
     82        public void submit() {
     83            submit(false);
     84        }
     85
     86        @Override
     87        public void submit(boolean force) {
     88            this.force = force;
     89            run();
     90        }
     91    }
     92
    2493    /**
    2594     * Holds the HTTP headers. Insert e.g. User-Agent here when default should not be used.
     
    38107
    39108    public TileJob createTileLoaderJob(final Tile tile) {
    40         return new TileJob() {
    41 
    42             InputStream input = null;
    43             boolean force = false;
    44 
    45             public void run() {
    46                 synchronized (tile) {
    47                     if ((tile.isLoaded() && !tile.hasError()) || tile.isLoading())
    48                         return;
    49                     tile.loaded = false;
    50                     tile.error = false;
    51                     tile.loading = true;
    52                 }
    53                 try {
    54                     URLConnection conn = loadTileFromOsm(tile);
    55                     if (force) {
    56                         conn.setUseCaches(false);
    57                     }
    58                     loadTileMetadata(tile, conn);
    59                     if ("no-tile".equals(tile.getValue("tile-info"))) {
    60                         tile.setError("No tile at this zoom level");
    61                     } else {
    62                         input = conn.getInputStream();
    63                         try {
    64                             tile.loadImage(input);
    65                         } finally {
    66                             input.close();
    67                             input = null;
    68                         }
    69                     }
    70                     tile.setLoaded(true);
    71                     listener.tileLoadingFinished(tile, true);
    72                 } catch (Exception e) {
    73                     tile.setError(e.getMessage());
    74                     listener.tileLoadingFinished(tile, false);
    75                     if (input == null) {
    76                         try {
    77                             System.err.println("Failed loading " + tile.getUrl() +": "
    78                                     +e.getClass() + ": " + e.getMessage());
    79                         } catch (IOException ioe) {
    80                             ioe.printStackTrace();
    81                         }
    82                     }
    83                 } finally {
    84                     tile.loading = false;
    85                     tile.setLoaded(true);
    86                 }
    87             }
    88 
    89             public Tile getTile() {
    90                 return tile;
    91             }
    92 
    93             @Override
    94             public void submit() {
    95                 submit(false);
    96 
    97             }
    98 
    99             @Override
    100             public void submit(boolean force) {
    101                 this.force = force;
    102                 run();
    103             }
    104 
    105         };
     109        return new OsmTileJob(tile);
    106110    }
    107111
     
    111115        URLConnection urlConn = url.openConnection();
    112116        if (urlConn instanceof HttpURLConnection) {
    113             prepareHttpUrlConnection((HttpURLConnection)urlConn);
     117            prepareHttpUrlConnection((HttpURLConnection) urlConn);
    114118        }
    115119        return urlConn;
     
    138142                    }
    139143                }
    140             } catch (NumberFormatException e) {} //ignore malformed Cache-Control headers
     144            } catch (NumberFormatException e) {
     145                // ignore malformed Cache-Control headers
     146                if (JMapViewer.debug) {
     147                    System.err.println(e.getMessage());
     148                }
     149            }
    141150        }
    142151        if (!lng.equals(0L)) {
     
    146155
    147156    protected void prepareHttpUrlConnection(HttpURLConnection urlConn) {
    148         for(Entry<String, String> e : headers.entrySet()) {
     157        for (Entry<String, String> e : headers.entrySet()) {
    149158            urlConn.setRequestProperty(e.getKey(), e.getValue());
    150159        }
    151         if(timeoutConnect != 0)
     160        if (timeoutConnect != 0)
    152161            urlConn.setConnectTimeout(timeoutConnect);
    153         if(timeoutRead != 0)
     162        if (timeoutRead != 0)
    154163            urlConn.setReadTimeout(timeoutRead);
    155164    }
     
    159168        return getClass().getSimpleName();
    160169    }
    161 
    162170}
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Style.java

    r30900 r31429  
    1616    private static final AlphaComposite OPAQUE = AlphaComposite.getInstance(AlphaComposite.SRC);
    1717
    18     public Style(){
     18    public Style() {
    1919        super();
    2020    }
     21
    2122    public Style(Color color, Color backColor, Stroke stroke, Font font) {
    2223        super();
     
    3031        return color;
    3132    }
     33
    3234    public void setColor(Color color) {
    3335        this.color = color;
    3436    }
     37
    3538    public Color getBackColor() {
    3639        return backColor;
    3740    }
     41
    3842    public void setBackColor(Color backColor) {
    3943        this.backColor = backColor;
    4044    }
     45
    4146    public Stroke getStroke() {
    4247        return stroke;
    4348    }
     49
    4450    public void setStroke(Stroke stroke) {
    4551        this.stroke = stroke;
    4652    }
     53
    4754    public Font getFont() {
    4855        return font;
    4956    }
     57
    5058    public void setFont(Font font) {
    5159        this.font = font;
    5260    }
    53     private AlphaComposite getAlphaComposite(Color color){
    54         return color.getAlpha()==255?OPAQUE:TRANSPARENCY;
     61
     62    private AlphaComposite getAlphaComposite(Color color) {
     63        return color.getAlpha() == 255 ? OPAQUE : TRANSPARENCY;
    5564    }
    56     public AlphaComposite getAlphaComposite(){
     65
     66    public AlphaComposite getAlphaComposite() {
    5767        return getAlphaComposite(color);
    5868    }
    59     public AlphaComposite getBackAlphaComposite(){
     69
     70    public AlphaComposite getBackAlphaComposite() {
    6071        return getAlphaComposite(backColor);
    6172    }
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Tile.java

    r31427 r31429  
    236236    }
    237237
    238 
    239238    @Override
    240239    public String toString() {
     
    348347     * @return metadata of the tile
    349348     */
    350     public Map<String,String> getMetadata() {
     349    public Map<String, String> getMetadata() {
    351350        if (metadata == null) {
    352351            metadata = new HashMap<>();
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/TileXY.java

    r31339 r31429  
    1 // License: GPL. For details, see LICENSE file.
     1// License: GPL. For details, see Readme.txt file.
    22package org.openstreetmap.gui.jmapviewer;
    33
     
    5454        return y;
    5555    }
    56 
    5756}
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/checkBoxTree/CheckBoxNodeData.java

    r30900 r31429  
    1616        this.layer = layer;
    1717    }
     18
    1819    public CheckBoxNodeData(final String txt) {
    1920        this(new LayerGroup(txt));
    2021    }
     22
    2123    public CheckBoxNodeData(final String txt, final Boolean selected) {
    2224        this(new LayerGroup(txt));
    2325        layer.setVisible(selected);
    2426    }
     27
    2528    public Boolean isSelected() {
    2629            return layer.isVisible();
    2730    }
     31
    2832    public void setSelected(final Boolean newValue) {
    2933        layer.setVisible(newValue);
    3034    }
     35
    3136    public String getText() {
    3237            return layer.getName();
    3338    }
     39
    3440    public AbstractLayer getAbstractLayer() {
    3541        return layer;
    36 }
     42    }
     43
    3744    public void setAbstractLayer(final AbstractLayer layer) {
    3845            this.layer = layer;
    3946    }
     47
    4048    @Override
    4149    public String toString() {
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/checkBoxTree/CheckBoxNodeEditor.java

    r30900 r31429  
    5353        }
    5454    }*/
    55     public void addNodeListener(MouseAdapter listener){
     55
     56    public void addNodeListener(MouseAdapter listener) {
    5657        renderer.addNodeListener(listener);
    5758    }
     59
    5860    @Override
    5961    public boolean isCellEditable(final EventObject event) {
     
    7678    public Component getTreeCellEditorComponent(final JTree tree,
    7779        final Object value, final boolean selected, final boolean expanded,
    78         final boolean leaf, final int row)
    79     {
     80        final boolean leaf, final int row) {
    8081
    8182        final Component editor =
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/checkBoxTree/CheckBoxNodePanel.java

    r30900 r31429  
    2727        add(label, BorderLayout.CENTER);
    2828    }
    29     public void setSelected(Boolean bool){
    30         if(bool==null){
     29
     30    public void setSelected(Boolean bool) {
     31        if (bool == null) {
    3132            check.getModel().setPressed(true);
    3233            check.getModel().setArmed(true);
    33         }else{
     34        } else {
    3435            check.setSelected(bool.booleanValue());
    3536            check.getModel().setArmed(false);
    3637        }
    3738    }
     39
    3840    public CheckBoxNodeData getData() {
    3941        data.setSelected(check.isSelected());
    4042        return data;
    4143    }
     44
    4245    public void setData(CheckBoxNodeData data) {
    4346        this.data = data;
    4447        label.setText(data.getText());
    4548    }
     49
    4650    public JLabel getLabel() {
    4751        return label;
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/checkBoxTree/CheckBoxNodeRenderer.java

    r30900 r31429  
    55import java.awt.Component;
    66import java.awt.Font;
    7 import java.awt.event.ActionEvent;
    8 import java.awt.event.ActionListener;
    97import java.awt.event.MouseAdapter;
    108
    11 import javax.swing.JMenuItem;
    12 import javax.swing.JPopupMenu;
    139import javax.swing.JTree;
    1410import javax.swing.UIManager;
     
    1612import javax.swing.tree.DefaultTreeCellRenderer;
    1713import javax.swing.tree.TreeCellRenderer;
    18 
    19 import org.openstreetmap.gui.jmapviewer.AbstractLayer;
    20 import org.openstreetmap.gui.jmapviewer.LayerGroup;
    2114
    2215/**
     
    4942        textBackground = UIManager.getColor("Tree.textBackground");
    5043    }
    51     public void addNodeListener(MouseAdapter listener){
     44
     45    public void addNodeListener(MouseAdapter listener) {
    5246        panel.addMouseListener(listener);
    5347    }
     
    5751    public Component getTreeCellRendererComponent(final JTree tree,
    5852        final Object value, final boolean selected, final boolean expanded,
    59         final boolean leaf, final int row, final boolean hasFocus)
    60     {
     53        final boolean leaf, final int row, final boolean hasFocus) {
    6154        CheckBoxNodeData data = null;
    6255        if (value instanceof DefaultMutableTreeNode) {
     
    8174            panel.getLabel().setForeground(selectionForeground);
    8275            panel.getLabel().setBackground(selectionBackground);
    83         }
    84         else {
     76        } else {
    8577            panel.setForeground(textForeground);
    8678            panel.setBackground(textBackground);
     
    10193        return panel;
    10294    }
     95/*
    10396    private JPopupMenu createPopupMenu(final AbstractLayer layer) {
    10497        JMenuItem menuItem;
    10598 
    10699        //Create the popup menu.
    107         if(layer.isVisibleTexts()) menuItem = new JMenuItem("hide texts");
     100        if (layer.isVisibleTexts()) menuItem = new JMenuItem("hide texts");
    108101        else menuItem = new JMenuItem("show texts");
    109102        JPopupMenu popup = new JPopupMenu();
     
    118111        return popup;
    119112    }
    120     private void setVisibleTexts(AbstractLayer layer, boolean visible){
     113
     114    private void setVisibleTexts(AbstractLayer layer, boolean visible) {
    121115        layer.setVisibleTexts(visible);
    122         if(layer instanceof LayerGroup){
    123             LayerGroup group = (LayerGroup)layer;
    124             if(group.getLayers()!=null) for(AbstractLayer al: group.getLayers()) setVisibleTexts(al, visible);
     116        if (layer instanceof LayerGroup) {
     117            LayerGroup group = (LayerGroup) layer;
     118            if (group.getLayers() != null)
     119                for (AbstractLayer al : group.getLayers()) {
     120                    setVisibleTexts(al, visible);
     121                }
    125122        }
    126123    }
     124*/
    127125}
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/checkBoxTree/CheckBoxTree.java

    r31427 r31429  
    3030    private final CheckBoxNodeEditor editor;
    3131
    32     public CheckBoxTree(AbstractLayer layer){
     32    public CheckBoxTree(AbstractLayer layer) {
    3333        this(new CheckBoxNodeData(layer));
    3434    }
    35     public CheckBoxTree(String rootName){
     35
     36    public CheckBoxTree(String rootName) {
    3637        this(new CheckBoxNodeData(rootName));
    3738    }
    38     public CheckBoxTree(CheckBoxNodeData root ){
     39
     40    public CheckBoxTree(CheckBoxNodeData root) {
    3941        this(new DefaultMutableTreeNode(root));
    4042    }
    41     public CheckBoxTree(DefaultMutableTreeNode node){
     43
     44    public CheckBoxTree(DefaultMutableTreeNode node) {
    4245        super(new DefaultTreeModel(node));
    4346
     
    5356            @Override
    5457            public void treeNodesChanged(final TreeModelEvent e) {
    55                 DefaultTreeModel model = (DefaultTreeModel)e.getSource();
     58                DefaultTreeModel model = (DefaultTreeModel) e.getSource();
    5659                Object[] nodes = e.getChildren();
    5760                DefaultMutableTreeNode node;
    58                 if(nodes==null||nodes.length==0){
     61                if (nodes == null || nodes.length == 0) {
    5962                    node = node(model.getRoot());
    60                 }else{
     63                } else {
    6164                    node = node(nodes[0]);
    6265                }
     
    8184        });
    8285    }
    83     public void addNodeListener(MouseAdapter listener){
     86
     87    public void addNodeListener(MouseAdapter listener) {
    8488        editor.addNodeListener(listener);
    8589    }
    86     public static void main(final String args[]) {
    87         final DefaultMutableTreeNode root = new DefaultMutableTreeNode(new CheckBoxNodeData("Root",true));
     90
     91    public static void main(final String[] args) {
     92        final DefaultMutableTreeNode root = new DefaultMutableTreeNode(new CheckBoxNodeData("Root", true));
    8893
    8994        final DefaultMutableTreeNode accessibility =
     
    102107
    103108        final CheckBoxTree tree = new CheckBoxTree(root);
    104         ((DefaultMutableTreeNode)tree.getModel().getRoot()).add(new DefaultMutableTreeNode(new CheckBoxNodeData("gggg", null)));
    105         ((DefaultTreeModel)tree.getModel()).reload();
     109        ((DefaultMutableTreeNode) tree.getModel().getRoot()).add(new DefaultMutableTreeNode(new CheckBoxNodeData("gggg", null)));
     110        ((DefaultTreeModel) tree.getModel()).reload();
    106111        // listen for changes in the selection
    107112        tree.addTreeSelectionListener(new TreeSelectionListener() {
     
    119124        frame.setVisible(true);
    120125    }
    121     private static Boolean childStatus(DefaultMutableTreeNode node){
     126
     127    private static Boolean childStatus(DefaultMutableTreeNode node) {
    122128        Boolean status = data(node.getChildAt(0)).isSelected();
    123         for (int i=1; i<node.getChildCount() && status!=null; i++){
     129        for (int i = 1; i < node.getChildCount() && status != null; i++) {
    124130            if (!status.equals(
    125131                    data(node.getChildAt(i)).isSelected()
     
    129135        return status;
    130136    }
    131     private static void changeParents(DefaultMutableTreeNode node){
    132         if(node!=null){
     137
     138    private static void changeParents(DefaultMutableTreeNode node) {
     139        if (node != null) {
    133140            DefaultMutableTreeNode parent = node(node.getParent());
    134             if(parent!=null){
     141            if (parent != null) {
    135142                CheckBoxNodeData dataParent = data(parent);
    136143                Boolean childStatus = childStatus(parent);
    137                 if(childStatus != null && !childStatus.equals(dataParent.isSelected())) {
     144                if (childStatus != null && !childStatus.equals(dataParent.isSelected())) {
    138145                    dataParent.setSelected(childStatus);
    139146                    changeParents(parent);
     
    142149        }
    143150    }
    144     private static void nodeChanged(DefaultMutableTreeNode node){
    145         if(node!=null){
     151
     152    private static void nodeChanged(DefaultMutableTreeNode node) {
     153        if (node != null) {
    146154            changeParents(node);
    147155            setChildrens(node, data(node).isSelected());
    148156        }
    149157    }
    150     private static void setChildrens(DefaultMutableTreeNode node, Boolean value){
    151         for(int i=0; i<node.getChildCount(); i++){
     158
     159    private static void setChildrens(DefaultMutableTreeNode node, Boolean value) {
     160        for (int i = 0; i < node.getChildCount(); i++) {
    152161            DefaultMutableTreeNode childNode = node(node.getChildAt(i));
    153             if (!data(childNode).isSelected().equals(data(node).isSelected())){
     162            if (!data(childNode).isSelected().equals(data(node).isSelected())) {
    154163                data(childNode).setSelected(data(node).isSelected());
    155164                setChildrens(childNode, value);
     
    157166        }
    158167    }
    159     public DefaultMutableTreeNode rootNode(){
     168
     169    public DefaultMutableTreeNode rootNode() {
    160170        return node(getModel().getRoot());
    161171    }
    162     public LayerGroup rootLayer(){
    163         return (LayerGroup)rootData().getAbstractLayer();
    164     }
    165     public CheckBoxNodeData rootData(){
     172
     173    public LayerGroup rootLayer() {
     174        return (LayerGroup) rootData().getAbstractLayer();
     175    }
     176
     177    public CheckBoxNodeData rootData() {
    166178        return data(rootNode());
    167179    }
    168     private static DefaultMutableTreeNode node(Object node){
    169         return (DefaultMutableTreeNode)node;
    170     }
    171     public static CheckBoxNodeData data(DefaultMutableTreeNode node){
    172         return node==null?null:(CheckBoxNodeData)node.getUserObject();
    173     }
    174     private static CheckBoxNodeData data(Object node){
     180
     181    private static DefaultMutableTreeNode node(Object node) {
     182        return (DefaultMutableTreeNode) node;
     183    }
     184
     185    public static CheckBoxNodeData data(DefaultMutableTreeNode node) {
     186        return node == null ? null : (CheckBoxNodeData) node.getUserObject();
     187    }
     188
     189    private static CheckBoxNodeData data(Object node) {
    175190        return data(node(node));
    176191    }
    177     private static DefaultMutableTreeNode add(final DefaultMutableTreeNode parent, final String text, final boolean checked){
     192
     193    private static DefaultMutableTreeNode add(final DefaultMutableTreeNode parent, final String text, final boolean checked) {
    178194        final CheckBoxNodeData data = new CheckBoxNodeData(text, checked);
    179195        final DefaultMutableTreeNode node = new DefaultMutableTreeNode(data);
     
    181197        return node;
    182198    }
    183     public static CheckBoxNodeData createNodeData(AbstractLayer layer){
     199
     200    public static CheckBoxNodeData createNodeData(AbstractLayer layer) {
    184201        return new CheckBoxNodeData(layer);
    185202    }
    186     public static DefaultMutableTreeNode createNode(AbstractLayer layer){
     203
     204    public static DefaultMutableTreeNode createNode(AbstractLayer layer) {
    187205        return new DefaultMutableTreeNode(createNodeData(layer));
    188206    }
    189     /*public DefaultMutableTreeNode addLayerGroup(LayerGroup group){
    190         if(group!=null){
    191             if(group.getParent()==null){
     207
     208    /*public DefaultMutableTreeNode addLayerGroup(LayerGroup group) {
     209        if (group != null){
     210            if (group.getParent() == null){
    192211                return add(rootNode(), group);
    193             }else{
     212            } else {
    194213                DefaultMutableTreeNode parentGroup = searchNode(group.getParent());
    195214                if(parentGroup==null) parentGroup = addLayerGroup(group.getParent());
     
    199218        }else return null;
    200219    }*/
    201     public Layer addLayer(String name){
     220
     221    public Layer addLayer(String name) {
    202222        Layer layer = new Layer(name);
    203223        addLayer(layer);
    204224        return layer;
    205225    }
    206     public DefaultMutableTreeNode addLayer(AbstractLayer layer){
    207         if (layer!=null){
     226
     227    public DefaultMutableTreeNode addLayer(AbstractLayer layer) {
     228        if (layer != null) {
    208229            DefaultMutableTreeNode parent;
    209             if(layer.getParent()==null){
     230            if (layer.getParent() == null) {
    210231                rootLayer().add(layer);
    211232                parent = rootNode();
    212             }else{
     233            } else {
    213234                parent = searchNode(layer.getParent());
    214                 if(parent==null) parent=addLayer(layer.getParent());
     235                if (parent == null)
     236                    parent = addLayer(layer.getParent());
    215237            }
    216238            return add(parent, layer);
    217         }else return null;
    218     }
    219     public DefaultMutableTreeNode add(DefaultMutableTreeNode parent, final AbstractLayer layer){
     239        } else return null;
     240    }
     241
     242    public DefaultMutableTreeNode add(DefaultMutableTreeNode parent, final AbstractLayer layer) {
    220243        layer.setVisible(data(parent).isSelected());
    221244        DefaultMutableTreeNode node = createNode(layer);
    222245        parent.add(node);
    223         ((DefaultTreeModel)getModel()).reload();
     246        ((DefaultTreeModel) getModel()).reload();
    224247        //System.out.println("Created node "+layer+" upper of "+data(parent));
    225248        return node;
    226249    }
    227     public DefaultMutableTreeNode searchNode(AbstractLayer layer){
     250
     251    public DefaultMutableTreeNode searchNode(AbstractLayer layer) {
    228252        return searchNode(rootNode(), layer);
    229253    }
    230     public DefaultMutableTreeNode searchNode(DefaultMutableTreeNode node, AbstractLayer layer){
     254
     255    public DefaultMutableTreeNode searchNode(DefaultMutableTreeNode node, AbstractLayer layer) {
    231256        CheckBoxNodeData data = CheckBoxTree.data(node);
    232         if(data.getAbstractLayer() == layer) return node;
    233         else{
     257        if (data.getAbstractLayer() == layer) return node;
     258        else {
    234259            DefaultMutableTreeNode found = null;
    235             for(int i=0; i<node.getChildCount() && found==null; i++){
    236                 found = searchNode((DefaultMutableTreeNode)node.getChildAt(i), layer);
     260            for (int i = 0; i < node.getChildCount() && found == null; i++) {
     261                found = searchNode((DefaultMutableTreeNode) node.getChildAt(i), layer);
    237262            }
    238263            return found;
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/CachedTileLoader.java

    r31082 r31429  
    66 */
    77public interface CachedTileLoader {
    8     public void clearCache(TileSource source);
     8    void clearCache(TileSource source);
    99}
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/ICoordinate.java

    r30900 r31429  
    33
    44public interface ICoordinate {
    5     public double getLat();
    6     public void setLat(double lat);
    7     public double getLon();
    8     public void setLon(double lon);
     5
     6    double getLat();
     7
     8    void setLat(double lat);
     9
     10    double getLon();
     11
     12    void setLon(double lon);
    913}
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/JMapViewerEventListener.java

    r30223 r31429  
    1414 */
    1515public interface JMapViewerEventListener extends EventListener {
    16     public void processCommand(JMVCommandEvent command);
     16    void processCommand(JMVCommandEvent command);
    1717}
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/MapMarker.java

    r31293 r31429  
    2222     * @return Latitude and Longitude of the map marker position
    2323     */
    24     public Coordinate getCoordinate();
     24    Coordinate getCoordinate();
     25
    2526    /**
    2627     * @return Latitude of the map marker position
    2728     */
    28     public double getLat();
     29    double getLat();
    2930
    3031    /**
    3132     * @return Longitude of the map marker position
    3233     */
    33     public double getLon();
     34    double getLon();
    3435
    3536    /**
    3637     * @return Radius of the map marker position
    3738     */
    38     public double getRadius();
     39    double getRadius();
    3940
    4041    /**
    4142     * @return Style of the map marker
    4243     */
    43     public STYLE getMarkerStyle();
     44    STYLE getMarkerStyle();
    4445
    4546    /**
     
    5152     * @param radius radius
    5253     */
    53     public void paint(Graphics g, Point position, int radius);
     54    void paint(Graphics g, Point position, int radius);
    5455}
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/MapObject.java

    r30900 r31429  
    1111public interface MapObject {
    1212
    13     public Layer getLayer();
    14     public void setLayer(Layer layer);
    15     public Style getStyle();
    16     public Style getStyleAssigned();
    17     public Color getColor();
    18     public Color getBackColor();
    19     public Stroke getStroke();
    20     public Font getFont();
    21     public String getName();
    22     public boolean isVisible();
     13    Layer getLayer();
     14
     15    void setLayer(Layer layer);
     16
     17    Style getStyle();
     18
     19    Style getStyleAssigned();
     20
     21    Color getColor();
     22
     23    Color getBackColor();
     24
     25    Stroke getStroke();
     26
     27    Font getFont();
     28
     29    String getName();
     30
     31    boolean isVisible();
    2332}
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/MapPolygon.java

    r31293 r31429  
    1717     * @return Latitude/Longitude of each point of polygon
    1818     */
    19     public List<? extends ICoordinate> getPoints();
     19    List<? extends ICoordinate> getPoints();
    2020
    2121    /**
     
    2626     * @param points list of points defining the polygon to draw
    2727     */
    28     public void paint(Graphics g, List<Point> points);
     28    void paint(Graphics g, List<Point> points);
    2929
    3030    /**
     
    3535     * @param polygon polygon to draw
    3636     */
    37     public void paint(Graphics g, Polygon polygon);
     37    void paint(Graphics g, Polygon polygon);
    3838}
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/MapRectangle.java

    r30900 r31429  
    2020     * @return Latitude/Longitude of top left of rectangle
    2121     */
    22     public Coordinate getTopLeft();
     22    Coordinate getTopLeft();
    2323
    2424    /**
    2525     * @return Latitude/Longitude of bottom right of rectangle
    2626     */
    27     public Coordinate getBottomRight();
     27    Coordinate getBottomRight();
    2828
    2929    /**
     
    3535     * @param bottomRight bottom right edge of painting region
    3636     */
    37     public void paint(Graphics g, Point topLeft, Point bottomRight);
     37    void paint(Graphics g, Point topLeft, Point bottomRight);
    3838}
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/TemplatedTileSource.java

    r31310 r31429  
    1 // License: GPL. For details, see LICENSE file.
     1// License: GPL. For details, see Readme.txt file.
    22package org.openstreetmap.gui.jmapviewer.interfaces;
    33
     
    1515     * @return headers to be sent with http requests
    1616     */
    17     public Map<String, String> getHeaders();
     17    Map<String, String> getHeaders();
    1818}
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/TileCache.java

    r30900 r31429  
    2828     *         present in the cache
    2929     */
    30     public Tile getTile(TileSource source, int x, int y, int z);
     30    Tile getTile(TileSource source, int x, int y, int z);
    3131
    3232    /**
     
    3737     * @param tile the tile to be added
    3838     */
    39     public void addTile(Tile tile);
     39    void addTile(Tile tile);
    4040
    4141    /**
    4242     * @return the number of tiles hold by the cache
    4343     */
    44     public int getTileCount();
     44    int getTileCount();
    4545
    4646    /**
    4747     * Clears the cache deleting all tiles from memory.
    4848     */
    49     public void clear();
     49    void clear();
    5050}
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/TileJob.java

    r31174 r31429  
    1717     * @return {@link Tile} to be handled
    1818     */
    19     public Tile getTile();
     19    Tile getTile();
    2020
    2121    /**
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/TileLoader.java

    r30900 r31429  
    2020     *          action.
    2121     */
    22     public TileJob createTileLoaderJob(Tile tile);
     22    TileJob createTileLoaderJob(Tile tile);
    2323}
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/TileLoaderListener.java

    r30900 r31429  
    1313     * @param success {@code true} if the tile has been loaded successfully, {@code false} otherwise
    1414     */
    15     public void tileLoadingFinished(Tile tile, boolean success);
     15    void tileLoadingFinished(Tile tile, boolean success);
    1616}
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/TileSource.java

    r31371 r31429  
    3838     * </ul>
    3939     *
    40      */
    41     @Deprecated //not used anymore
     40     * @deprecated not used anymore
     41     */
     42    @Deprecated
    4243    public enum TileUpdate {
    4344        IfNoneMatch, ETag, IfModifiedSince, LastModified, None
     
    100101     * get the same identifier. Used for creation of cache key.
    101102     *
    102      * @param zoom
    103      * @param tilex
    104      * @param tiley
     103     * @param zoom zoom level
     104     * @param tilex X coordinate
     105     * @param tiley Y coordinate
    105106     * @return tile identifier
    106107     */
     
    117118     * TODO: @since
    118119     */
    119     public int getDefaultTileSize();
     120    int getDefaultTileSize();
    120121
    121122    /**
     
    131132    /**
    132133     * Transform longitude to pixelspace.
    133      * @param aLongitude
    134      * @param aZoomlevel
     134     * @param aLongitude longitude
     135     * @param aZoomlevel zoom level
    135136     * @return [0..2^Zoomlevel*TILE_SIZE[
     137     * @deprecated use {@link #latLonToXY(double, double, int)} instead
    136138     */
    137139    @Deprecated
     
    140142    /**
    141143     * Transforms latitude to pixelspace.
    142      * @param aLat
    143      * @param aZoomlevel
     144     * @param aLat latitude
     145     * @param aZoomlevel zoom level
    144146     * @return [0..2^Zoomlevel*TILE_SIZE[
    145      * @deprecated use lonLatToXY instead
     147     * @deprecated use {@link #latLonToXY(double, double, int)} instead
    146148     */
    147149    @Deprecated
     
    149151
    150152    /**
    151      * @param lon
    152      * @param lat
    153      * @param zoom
     153     * @param lon longitude
     154     * @param lat latitude
     155     * @param zoom zoom level
    154156     * @return transforms longitude and latitude to pixel space (as if all tiles at specified zoom level where joined)
    155157     */
    156     public Point latLonToXY(double lat, double lon, int zoom);
    157 
    158     /**
    159      * @param point
    160      * @param zoom
     158    Point latLonToXY(double lat, double lon, int zoom);
     159
     160    /**
     161     * @param point point
     162     * @param zoom zoom level
    161163     * @return transforms longitude and latitude to pixel space (as if all tiles at specified zoom level where joined)
    162164     */
    163     public Point latLonToXY(ICoordinate point, int zoom);
     165    Point latLonToXY(ICoordinate point, int zoom);
    164166
    165167    /**
    166168     * Transforms pixel coordinate X to longitude
    167      * @param aX
    168      * @param aZoomlevel
     169     * @param aX X coordinate
     170     * @param aZoomlevel zoom level
    169171     * @return ]-180..180[
     172     * @deprecated use {@link #XYToLatLon(int, int, int)} instead
    170173     */
    171174    @Deprecated
     
    174177    /**
    175178     * Transforms pixel coordinate Y to latitude.
    176      * @param aY
    177      * @param aZoomlevel
     179     * @param aY Y coordinate
     180     * @param aZoomlevel zoom level
    178181     * @return [MIN_LAT..MAX_LAT]
     182     * @deprecated use {@link #XYToLatLon(int, int, int)} instead
    179183     */
    180184    @Deprecated
     
    182186
    183187    /**
    184      * @param point
    185      * @param zoom
     188     * @param point point
     189     * @param zoom zoom level
    186190     * @return WGS84 Coordinates of given point
    187191     */
    188     public ICoordinate XYToLatLon(Point point, int zoom);
    189 
    190     /**
    191      *
    192      * @param x
    193      * @param y
    194      * @param zoom
     192    ICoordinate XYToLatLon(Point point, int zoom);
     193
     194    /**
     195     *
     196     * @param x X coordinate
     197     * @param y Y coordinate
     198     * @param zoom zoom level
    195199     * @return WGS84 Coordinates of given point
    196200     */
    197     public ICoordinate XYToLatLon(int x, int y, int zoom);
     201    ICoordinate XYToLatLon(int x, int y, int zoom);
    198202
    199203    /**
    200204     * Transforms longitude to X tile coordinate.
    201      * @param lon
    202      * @param zoom
     205     * @param lon longitude
     206     * @param zoom zoom level
    203207     * @return [0..2^Zoomlevel[
     208     * @deprecated use {@link #latLonToTileXY(int, int, int)} instead
    204209     */
    205210    @Deprecated
     
    208213    /**
    209214     * Transforms latitude to Y tile coordinate.
    210      * @param lat
    211      * @param zoom
     215     * @param lat latitude
     216     * @param zoom zoom level
    212217     * @return [0..2^Zoomlevel[
     218     * @deprecated use {@link #latLonToTileXY(int, int, int)} instead
    213219     */
    214220    @Deprecated
     
    216222
    217223    /**
    218      * @param lon
    219      * @param lat
    220      * @param zoom
     224     * @param lon longitude
     225     * @param lat latitude
     226     * @param zoom zoom level
    221227     * @return x and y tile indices
    222228     */
    223     public TileXY latLonToTileXY(double lat, double lon, int zoom);
    224 
    225     /**
    226      *
    227      * @param point
    228      * @param zoom
     229    TileXY latLonToTileXY(double lat, double lon, int zoom);
     230
     231    /**
     232     *
     233     * @param point point
     234     * @param zoom zoom level
    229235     * @return x and y tile indices
    230236     */
    231     public TileXY latLonToTileXY(ICoordinate point, int zoom);
     237    TileXY latLonToTileXY(ICoordinate point, int zoom);
    232238
    233239    /**
    234240     * Transforms tile X coordinate to longitude.
    235      * @param x
    236      * @param zoom
     241     * @param x X coordinate
     242     * @param zoom zoom level
    237243     * @return ]-180..180[
     244     * @deprecated use {@link #tileXYToLatLon(int, int, int)} instead
    238245     */
    239246    @Deprecated
     
    242249    /**
    243250     * Transforms tile Y coordinate to latitude.
    244      * @param y
    245      * @param zoom
     251     * @param y Y coordinate
     252     * @param zoom zoom level
    246253     * @return [MIN_LAT..MAX_LAT]
     254     * @deprecated use {@link #tileXYToLatLon(int, int, int)} instead
    247255     */
    248256    @Deprecated
     
    250258
    251259    /**
    252      * @param xy
    253      * @param zoom
     260     * @param xy X/Y coordinates
     261     * @param zoom zoom level
    254262     * @return WGS84 coordinates of given tile
    255263     */
    256     public ICoordinate tileXYToLatLon(TileXY xy, int zoom);
    257 
    258     /**
    259      *
    260      * @param tile
     264    ICoordinate tileXYToLatLon(TileXY xy, int zoom);
     265
     266    /**
     267     *
     268     * @param tile Tile
    261269     * @return WGS84 coordinates of given tile
    262270     */
    263     public ICoordinate tileXYToLatLon(Tile tile);
    264 
    265     /**
    266      *
    267      * @param x
    268      * @param y
    269      * @param zoom
     271    ICoordinate tileXYToLatLon(Tile tile);
     272
     273    /**
     274     *
     275     * @param x X coordinate
     276     * @param y Y coordinate
     277     * @param zoom zoom level
    270278     * @return WGS84 coordinates of given tile
    271279     */
    272     public ICoordinate tileXYToLatLon(int x, int y, int zoom);
    273 
    274     /**
    275      * @param zoom
     280    ICoordinate tileXYToLatLon(int x, int y, int zoom);
     281
     282    /**
     283     * @param zoom zoom level
    276284     * @return maximum X index of tile for specified zoom level
    277285     */
    278     public int getTileXMax(int zoom);
    279 
    280     /**
    281      *
    282      * @param zoom
     286    int getTileXMax(int zoom);
     287
     288    /**
     289     *
     290     * @param zoom zoom level
    283291     * @return minimum X index of tile for specified zoom level
    284292     */
    285     public int getTileXMin(int zoom);
    286 
    287     /**
    288      *
    289      * @param zoom
     293    int getTileXMin(int zoom);
     294
     295    /**
     296     *
     297     * @param zoom zoom level
    290298     * @return maximum Y index of tile for specified zoom level
    291299     */
    292     public int getTileYMax(int zoom);
    293 
    294     /**
    295      * @param zoom
     300    int getTileYMax(int zoom);
     301
     302    /**
     303     * @param zoom zoom level
    296304     * @return minimum Y index of tile for specified zoom level
    297305     */
    298     public int getTileYMin(int zoom);
     306    int getTileYMin(int zoom);
    299307
    300308    /**
     
    307315     * @return true, if "no tile at this zoom level" situation detected
    308316     */
    309     public boolean isNoTileAtZoom(Map<String, List<String>> headers, int statusCode, byte[] content);
     317    boolean isNoTileAtZoom(Map<String, List<String>> headers, int statusCode, byte[] content);
    310318
    311319    /**
     
    315323     * @return tile metadata
    316324     */
    317     public Map<String, String> getMetadata(Map<String, List<String>> headers);
    318 
    319 
     325    Map<String, String> getMetadata(Map<String, List<String>> headers);
    320326}
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractOsmTileSource.java

    r31301 r31429  
    1212   
    1313    /**
    14      * The OSM attribution. Must be always in line with <a href="https://www.openstreetmap.org/copyright/en">https://www.openstreetmap.org/copyright/en</a>
     14     * The OSM attribution. Must be always in line with
     15     * <a href="https://www.openstreetmap.org/copyright/en">https://www.openstreetmap.org/copyright/en</a>
    1516     */
    1617    public static final String DEFAULT_OSM_ATTRIBUTION = "\u00a9 OpenStreetMap contributors";
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTMSTileSource.java

    r31371 r31429  
    3939        this.name = info.getName();
    4040        this.baseUrl = info.getUrl();
    41         if(baseUrl != null && baseUrl.endsWith("/")) {
    42             baseUrl = baseUrl.substring(0,baseUrl.length()-1);
     41        if (baseUrl != null && baseUrl.endsWith("/")) {
     42            baseUrl = baseUrl.substring(0, baseUrl.length()-1);
    4343        }
    4444        this.id = info.getUrl();
     
    129129    @Override
    130130    public int lonToX(double lon, int zoom) {
    131         return (int )osmMercator.LonToX(lon, zoom);
     131        return (int) osmMercator.LonToX(lon, zoom);
    132132    }
    133133
    134134    @Override
    135135    public int latToY(double lat, int zoom) {
    136         return (int )osmMercator.LatToY(lat, zoom);
     136        return (int) osmMercator.LatToY(lat, zoom);
    137137    }
    138138
     
    140140    public Point latLonToXY(double lat, double lon, int zoom) {
    141141        return new Point(
    142                 (int)osmMercator.LonToX(lon, zoom),
    143                 (int)osmMercator.LatToY(lat, zoom)
     142                (int) osmMercator.LonToX(lon, zoom),
     143                (int) osmMercator.LatToY(lat, zoom)
    144144                );
    145145    }
     
    243243        return 0;
    244244    }
    245 
    246245
    247246    @Override
     
    284283
    285284    private int getTileMax(int zoom) {
    286         return (int)Math.pow(2.0, zoom) - 1;
     285        return (int) Math.pow(2.0, zoom) - 1;
    287286    }
    288287}
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTileSource.java

    r31301 r31429  
    99import org.openstreetmap.gui.jmapviewer.interfaces.TileSource;
    1010
    11 abstract public class AbstractTileSource implements TileSource {
     11public abstract class AbstractTileSource implements TileSource {
    1212
    1313    protected String attributionText;
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java

    r31427 r31429  
    102102            imageryZoomMax = Integer.parseInt(xpath.compile("//ImageryMetadata/ZoomMax/text()").evaluate(document));
    103103
    104             NodeList subdomainTxt = (NodeList) xpath.compile("//ImageryMetadata/ImageUrlSubdomains/string/text()").evaluate(document, XPathConstants.NODESET);
     104            NodeList subdomainTxt = (NodeList) xpath.compile("//ImageryMetadata/ImageUrlSubdomains/string/text()")
     105                    .evaluate(document, XPathConstants.NODESET);
    105106            subdomains = new String[subdomainTxt.getLength()];
    106             for(int i = 0; i < subdomainTxt.getLength(); i++) {
     107            for (int i = 0; i < subdomainTxt.getLength(); i++) {
    107108                subdomains[i] = subdomainTxt.item(i).getNodeValue();
    108109            }
     
    119120            XPathExpression eastLonXpath = xpath.compile("BoundingBox/EastLongitude/text()");
    120121
    121             NodeList imageryProviderNodes = (NodeList) xpath.compile("//ImageryMetadata/ImageryProvider").evaluate(document, XPathConstants.NODESET);
     122            NodeList imageryProviderNodes = (NodeList) xpath.compile("//ImageryMetadata/ImageryProvider")
     123                    .evaluate(document, XPathConstants.NODESET);
    122124            List<Attribution> attributions = new ArrayList<>(imageryProviderNodes.getLength());
    123125            for (int i = 0; i < imageryProviderNodes.getLength(); i++) {
     
    127129
    128130                NodeList coverageAreaNodes = (NodeList) coverageAreaXpath.evaluate(providerNode, XPathConstants.NODESET);
    129                 for(int j = 0; j < coverageAreaNodes.getLength(); j++) {
     131                for (int j = 0; j < coverageAreaNodes.getLength(); j++) {
    130132                    Node areaNode = coverageAreaNodes.item(j);
    131133                    Attribution attr = new Attribution();
     
    160162    @Override
    161163    public int getMaxZoom() {
    162         if(imageryZoomMax != null)
     164        if (imageryZoomMax != null)
    163165            return imageryZoomMax;
    164166        else
     
    194196                for (int i = 0; i < 5 && getAttribution() == null; i++) {
    195197                    // Makes sure attribution is loaded
     198                    if (JMapViewer.debug) {
     199                        System.out.println("Bing attribution attempt " + (i+1));
     200                    }
    196201                }
    197202                if (brandLogoUri != null && !brandLogoUri.isEmpty()) {
     
    259264            throw new RuntimeException(ex.getCause());
    260265        } catch (InterruptedException ign) {
     266            System.err.println("InterruptedException: " + ign.getMessage());
    261267        }
    262268        return null;
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/OsmTileSource.java

    r30900 r31429  
    1414        private static final String PATTERN = "https://%s.tile.openstreetmap.org";
    1515
    16         private static final String[] SERVER = { "a", "b", "c" };
     16        private static final String[] SERVER = {"a", "b", "c"};
    1717
    1818        private int SERVER_NUM = 0;
     
    2727        @Override
    2828        public String getBaseUrl() {
    29             String url = String.format(this.baseUrl, new Object[] { SERVER[SERVER_NUM] });
     29            String url = String.format(this.baseUrl, new Object[] {SERVER[SERVER_NUM]});
    3030            SERVER_NUM = (SERVER_NUM + 1) % SERVER.length;
    3131            return url;
     
    4949        private static final String PATTERN = "http://%s.tile.opencyclemap.org/cycle";
    5050
    51         private static final String[] SERVER = { "a", "b", "c" };
     51        private static final String[] SERVER = {"a", "b", "c"};
    5252
    5353        private int SERVER_NUM = 0;
     
    6262        @Override
    6363        public String getBaseUrl() {
    64             String url = String.format(this.baseUrl, new Object[] { SERVER[SERVER_NUM] });
     64            String url = String.format(this.baseUrl, new Object[] {SERVER[SERVER_NUM]});
    6565            SERVER_NUM = (SERVER_NUM + 1) % SERVER.length;
    6666            return url;
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/ScanexTileSource.java

    r31310 r31429  
    1 // License: BSD or GPL. For details, see Readme.txt file.
     1// License: GPL. For details, see Readme.txt file.
    22package org.openstreetmap.gui.jmapviewer.tilesources;
    33
     
    66import org.openstreetmap.gui.jmapviewer.OsmMercator;
    77
    8 /*
     8/**
    99 * This tilesource uses different to OsmMercator projection.
    1010 *
     
    1818 * TODO: correct getDistance() method.
    1919 */
    20 
    2120public class ScanexTileSource extends TMSTileSource {
    2221    private static final String DEFAULT_URL = "http://maps.kosmosnimki.ru";
     
    3534            this.uri = uri;
    3635        }
     36
    3737        public String getName() {
    3838            return name;
    3939        }
     40
    4041        public String getUri() {
    4142            return uri;
     
    6667    @Override
    6768    public String getExtension() {
    68         return("jpeg");
     69        return "jpeg";
    6970    }
    7071
    7172    @Override
    7273    public String getTilePath(int zoom, int tilex, int tiley) {
    73         int tmp = (int)Math.pow(2.0, zoom - 1);
     74        int tmp = (int) Math.pow(2.0, zoom - 1);
    7475
    7576        tilex = tilex - tmp;
     
    8485    }
    8586
    86 
    8787    /*
    8888     * Latitude to Y and back calculations.
     
    9494    @Override
    9595    public int latToY(double lat, int zoom) {
    96         return (int )(latToTileY(lat, zoom) * tileSize);
     96        return (int) (latToTileY(lat, zoom) * tileSize);
    9797    }
    9898
    9999    @Override
    100100    public double YToLat(int y, int zoom) {
    101         return tileYToLat((double )y / tileSize, zoom);
     101        return tileYToLat((double) y / tileSize, zoom);
    102102    }
    103103
     
    112112    @Override
    113113    public double tileYToLat(int y, int zoom) {
    114         return tileYToLat((double )y, zoom);
     114        return tileYToLat((double) y, zoom);
    115115    }
    116116
     
    133133                Random r = new Random();
    134134                lat = OsmMercator.MIN_LAT +
    135                   r.nextInt((int )(OsmMercator.MAX_LAT - OsmMercator.MIN_LAT));
     135                  r.nextInt((int) (OsmMercator.MAX_LAT - OsmMercator.MIN_LAT));
    136136            }
    137137        } while ((Math.abs(lat0 - lat) > 0.000001));
     
    144144    /* Next term in Newton's polynomial */
    145145    private double NextTerm(double lat, double y, int zoom) {
    146         double sinl=Math.sin(lat);
    147         double cosl=Math.cos(lat);
     146        double sinl = Math.sin(lat);
     147        double cosl = Math.cos(lat);
    148148        double ec, f, df;
    149149
    150         zoom = (int )Math.pow(2.0, zoom - 1);
     150        zoom = (int) Math.pow(2.0, zoom - 1);
    151151        ec = Math.exp((1 - y/zoom)*Math.PI);
    152152
     
    154154            ec * Math.pow(Math.tan(Math.PI/4 + Math.asin(E * sinl)/2), E));
    155155        df = 1/(1 - sinl) - ec * E * cosl/((1 - E * sinl) *
    156             (Math.sqrt (1 - E * E * sinl * sinl)));
     156            (Math.sqrt(1 - E * E * sinl * sinl)));
    157157
    158158        return (f/df);
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/TemplatedTMSTileSource.java

    r31301 r31429  
    5252    /**
    5353     * Creates Templated TMS Tile Source based on ImageryInfo
    54      * @param info
     54     * @param info imagery info
    5555     */
    5656    public TemplatedTMSTileSource(TileSourceInfo info) {
     
    7373        Matcher matcher = pattern.matcher(baseUrl);
    7474        while (matcher.find()) {
    75             headers.put(matcher.group(1),matcher.group(2));
     75            headers.put(matcher.group(1), matcher.group(2));
    7676            matcher.appendReplacement(output, "");
    7777        }
     
    8989        Matcher m = Pattern.compile(".*"+PATTERN_ZOOM+".*").matcher(this.baseUrl);
    9090        if (m.matches()) {
    91             if(m.group(1) != null) {
     91            if (m.group(1) != null) {
    9292                finalZoom = Integer.valueOf(m.group(1))-zoom;
    9393            }
    94             if(m.group(2) != null) {
     94            if (m.group(2) != null) {
    9595                String ofs = m.group(2);
    96                 if(ofs.startsWith("+"))
     96                if (ofs.startsWith("+"))
    9797                    ofs = ofs.substring(1);
    9898                finalZoom += Integer.valueOf(ofs);
     
    103103            .replaceAll(PATTERN_X, Integer.toString(tilex))
    104104            .replaceAll(PATTERN_Y, Integer.toString(tiley))
    105             .replaceAll(PATTERN_Y_YAHOO, Integer.toString((int)Math.pow(2, zoom-1)-1-tiley))
    106             .replaceAll(PATTERN_NEG_Y, Integer.toString((int)Math.pow(2, zoom)-1-tiley));
     105            .replaceAll(PATTERN_Y_YAHOO, Integer.toString((int) Math.pow(2, zoom-1)-1-tiley))
     106            .replaceAll(PATTERN_NEG_Y, Integer.toString((int) Math.pow(2, zoom)-1-tiley));
    107107        if (rand != null) {
    108108            r = r.replaceAll(PATTERN_SWITCH, randomParts[rand.nextInt(randomParts.length)]);
     
    113113    /**
    114114     * Checks if url is acceptable by this Tile Source
    115      * @param url
     115     * @param url URL to check
    116116     */
    117117    public static void checkUrl(String url) {
    118         assert url != null && !"".equals(url): "URL cannot be null or empty";
     118        assert url != null && !"".equals(url) : "URL cannot be null or empty";
    119119        Matcher m = Pattern.compile("\\{[^}]*\\}").matcher(url);
    120120        while (m.find()) {
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/TileSourceInfo.java

    r31427 r31429  
    1 // License: GPL. For details, see LICENSE file.
     1// License: GPL. For details, see Readme.txt file.
    22package org.openstreetmap.gui.jmapviewer.tilesources;
    33
  • applications/viewer/jmapviewer/tools/checkstyle/jmapviewer_checks.xml

    r31428 r31429  
    9797  </module>
    9898  <module name="Header">
    99     <property name="header" value="// License: GPL. For details, see LICENSE file."/>
     99    <property name="header" value="// License: GPL. For details, see Readme.txt file."/>
    100100    <property name="fileExtensions" value=".java"/>
    101101  </module>
Note: See TracChangeset for help on using the changeset viewer.