Changeset 31429 in osm for applications/viewer/jmapviewer/src/org
- Timestamp:
- 2015-08-01T21:26:26+02:00 (9 years ago)
- Location:
- applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer
- Files:
-
- 46 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/AbstractLayer.java
r30900 r31429 11 11 private Style style; 12 12 private Boolean visible; 13 private Boolean visibleTexts =true;13 private Boolean visibleTexts = true; 14 14 15 public AbstractLayer(String name) {16 this(name, (String) null);15 public AbstractLayer(String name) { 16 this(name, (String) null); 17 17 } 18 public AbstractLayer(String name, String description){ 18 19 public AbstractLayer(String name, String description) { 19 20 this(name, description, MapMarkerCircle.getDefaultStyle()); 20 21 } 21 public AbstractLayer(String name, Style style){ 22 23 public AbstractLayer(String name, Style style) { 22 24 this(name, null, style); 23 25 } 24 public AbstractLayer(String name, String description, Style style){ 26 27 public AbstractLayer(String name, String description, Style style) { 25 28 this(null, name, description, style); 26 29 } 27 public AbstractLayer(LayerGroup parent, String name){ 30 31 public AbstractLayer(LayerGroup parent, String name) { 28 32 this(parent, name, MapMarkerCircle.getDefaultStyle()); 29 33 } 30 public AbstractLayer(LayerGroup parent, String name, Style style){ 34 35 public AbstractLayer(LayerGroup parent, String name, Style style) { 31 36 this(parent, name, null, style); 32 37 } 33 public AbstractLayer(LayerGroup parent, String name, String description, Style style){ 38 39 public AbstractLayer(LayerGroup parent, String name, String description, Style style) { 34 40 setParent(parent); 35 41 setName(name); … … 38 44 setVisible(true); 39 45 40 if (parent!=null) parent.add(this);46 if (parent != null) parent.add(this); 41 47 } 48 42 49 public LayerGroup getParent() { 43 50 return parent; 44 51 } 52 45 53 public void setParent(LayerGroup parent) { 46 54 this.parent = parent; 47 55 } 56 48 57 public String getName() { 49 58 return name; 50 59 } 60 51 61 public void setName(String name) { 52 62 this.name = name; 53 63 } 64 54 65 public String getDescription() { 55 66 return description; 56 67 } 68 57 69 public void setDescription(String description) { 58 70 this.description = description; 59 71 } 72 60 73 public Style getStyle() { 61 74 return style; 62 75 } 76 63 77 public void setStyle(Style style) { 64 78 this.style = style; 65 79 } 80 66 81 public Boolean isVisible() { 67 82 return visible; 68 83 } 84 69 85 public void setVisible(Boolean visible) { 70 86 this.visible = visible; 71 87 } 88 72 89 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); 76 93 } 77 94 return list; 78 95 } 96 79 97 public Boolean isVisibleTexts() { 80 98 return visibleTexts; 81 99 } 100 82 101 public void setVisibleTexts(Boolean visibleTexts) { 83 102 this.visibleTexts = visibleTexts; 84 103 } 85 public String toString(){ 104 105 public String toString() { 86 106 return name; 87 107 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/AttributionSupport.java
r31301 r31429 54 54 } 55 55 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) { 57 58 if (source == null || !source.requiresAttribution()) { 58 59 attrToUBounds = null; -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/DefaultMapController.java
r31293 r31429 43 43 return; 44 44 // 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) { 46 47 Point p = e.getPoint(); 47 48 if (lastDragPoint != null) { -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Demo.java
r31293 r31429 41 41 private JMapViewerTree treeMap = null; 42 42 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; 47 47 private JLabel mperpLabelValue = null; 48 48 … … 68 68 JPanel helpPanel = new JPanel(); 69 69 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())); 75 75 76 76 add(panel, BorderLayout.NORTH); … … 101 101 }); 102 102 JComboBox<TileLoader> tileLoaderSelector; 103 tileLoaderSelector = new JComboBox<>(new TileLoader[] { new OsmTileLoader(map())});103 tileLoaderSelector = new JComboBox<>(new TileLoader[] {new OsmTileLoader(map())}); 104 104 tileLoaderSelector.addItemListener(new ItemListener() { 105 105 public void itemStateChanged(ItemEvent e) { … … 187 187 treeMap.addLayer(germanyEastLayer); 188 188 189 MapPolygon bermudas = new MapPolygonImpl(c(49, 1), c(45,10), c(40,5));190 map().addMapPolygon( bermudas);191 map().addMapPolygon( 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)); 192 192 193 193 map().addMapMarker(new MapMarkerCircle(germanyWestLayer, "North of Suisse", new Coordinate(48, 7), .5)); … … 197 197 198 198 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))); 200 200 201 201 // map.setDisplayPosition(new Coordinate(49.807, 8.6), 11); … … 221 221 map().setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); 222 222 } 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() { 228 229 return treeMap.getViewer(); 229 230 } 230 private static Coordinate c(double lat, double lon){ 231 232 private static Coordinate c(double lat, double lon) { 231 233 return new Coordinate(lat, lon); 232 234 } … … 240 242 241 243 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) 245 247 zoomValue.setText(String.format("%s", map().getZoom())); 246 248 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/FeatureAdapter.java
r30848 r31429 9 9 import java.util.logging.Logger; 10 10 11 public class FeatureAdapter {11 public final class FeatureAdapter { 12 12 13 public static interface BrowserAdapter { 13 private FeatureAdapter() { 14 // private constructor for utility classes 15 } 16 17 public interface BrowserAdapter { 14 18 void openLink(String url); 15 19 } 16 20 17 public staticinterface TranslationAdapter {21 public interface TranslationAdapter { 18 22 String tr(String text, Object... objects); 19 23 // TODO: more i18n functions 20 24 } 21 25 22 public staticinterface LoggingAdapter {26 public interface LoggingAdapter { 23 27 Logger getLogger(String name); 24 28 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java
r31427 r31429 49 49 * Vectors for clock-wise tile painting 50 50 */ 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)}; 52 52 53 53 public static final int MAX_ZOOM = 22; … … 424 424 * @param lon longitude 425 425 * @param offset Offset respect Latitude 426 * @param checkOutside 426 * @param checkOutside check if the point is outside the displayed area 427 427 * @return Integer the radius in pixels 428 428 */ … … 444 444 * @param checkOutside check if the point is outside the displayed area 445 445 * @return Integer the radius in pixels 446 * @deprecated use {@link #getLatOffset(double, double, double, boolean)} 446 447 */ 447 448 @Deprecated -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/JMapViewerTree.java
r31427 r31429 35 35 private JSplitPane splitPane; 36 36 37 public JMapViewerTree(String name) {37 public JMapViewerTree(String name) { 38 38 this(name, false); 39 39 } 40 public JMapViewerTree(String name, boolean treeVisible){ 40 41 public JMapViewerTree(String name, boolean treeVisible) { 41 42 super(); 42 43 splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); … … 64 65 maybeShowPopup(e); 65 66 } 67 66 68 @Override 67 69 public void mouseReleased(MouseEvent e) { 68 70 maybeShowPopup(e); 69 71 } 72 70 73 private void maybeShowPopup(MouseEvent e) { 71 74 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) 74 77 JMapViewerTree.this.createPopupMenu(layer).show(e.getComponent(), e.getX(), e.getY()); 75 78 } … … 77 80 }); 78 81 } 82 79 83 private JPopupMenu createPopupMenu(final AbstractLayer layer) { 80 84 JMenuItem menuItemShow = new JMenuItem("show texts"); … … 85 89 86 90 // Create items 87 if (layer.isVisibleTexts()==null){91 if (layer.isVisibleTexts() == null) { 88 92 popup.add(menuItemShow); 89 93 popup.add(menuItemHide); 90 } else if(layer.isVisibleTexts()) popup.add(menuItemHide);94 } else if (layer.isVisibleTexts()) popup.add(menuItemHide); 91 95 else popup.add(menuItemShow); 92 96 … … 95 99 public void actionPerformed(ActionEvent arg0) { 96 100 setVisibleTexts(layer, true); 97 if (layer.getParent()!=null) layer.getParent().calculateVisibleTexts();101 if (layer.getParent() != null) layer.getParent().calculateVisibleTexts(); 98 102 map.repaint(); 99 103 } … … 103 107 public void actionPerformed(ActionEvent arg0) { 104 108 setVisibleTexts(layer, false); 105 if (layer.getParent()!=null) layer.getParent().calculateVisibleTexts();109 if (layer.getParent() != null) layer.getParent().calculateVisibleTexts(); 106 110 map.repaint(); 107 111 } … … 110 114 return popup; 111 115 } 112 private void setVisibleTexts(AbstractLayer layer, boolean visible){ 116 117 private void setVisibleTexts(AbstractLayer layer, boolean visible) { 113 118 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 } 117 125 } 118 126 } 119 public Layer addLayer(String name){ 127 128 public Layer addLayer(String name) { 120 129 Layer layer = new Layer(name); 121 130 this.addLayer(layer); 122 131 return layer; 123 132 } 124 public JMapViewerTree addLayer(Layer layer){ 133 134 public JMapViewerTree addLayer(Layer layer) { 125 135 tree.addLayer(layer); 126 136 return this; 127 137 } 128 public JMapViewerTree addLayer(MapObject element){ 138 139 public JMapViewerTree addLayer(MapObject element) { 129 140 //element.getLayer().add(element); 130 141 return addLayer(element.getLayer()); 131 142 } 132 public Layer removeFromLayer(MapObject element){ 143 144 public Layer removeFromLayer(MapObject element) { 133 145 element.getLayer().getElements().remove(element); 134 146 return element.getLayer(); 135 147 } 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(); 138 151 } 139 public JMapViewer getViewer(){ 152 153 public JMapViewer getViewer() { 140 154 return map; 141 155 } 142 public CheckBoxTree getTree(){ 156 157 public CheckBoxTree getTree() { 143 158 return tree; 144 159 } 160 145 161 public void addMapObject(MapObject o){ 146 162 147 163 } 148 public void setTreeVisible(boolean visible){ 164 165 public void setTreeVisible(boolean visible) { 149 166 removeAll(); 150 167 revalidate(); 151 if (visible){168 if (visible) { 152 169 splitPane.setLeftComponent(treePanel); 153 170 splitPane.setRightComponent(map); 154 171 add(splitPane, BorderLayout.CENTER); 155 } else add(map, BorderLayout.CENTER);172 } else add(map, BorderLayout.CENTER); 156 173 repaint(); 157 174 } 158 private void createRefresh(){ 175 176 private void createRefresh() { 159 177 tree.getModel().addTreeModelListener(new TreeModelListener() { 160 178 @Override … … 162 180 repaint(); 163 181 } 182 164 183 @Override 165 184 public void treeNodesInserted(TreeModelEvent arg0) { 166 185 // TODO Auto-generated method stub 167 186 } 187 168 188 @Override 169 189 public void treeNodesRemoved(TreeModelEvent arg0) { 170 190 // TODO Auto-generated method stub 171 191 } 192 172 193 @Override 173 194 public void treeStructureChanged(TreeModelEvent arg0) { -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/JobDispatcher.java
r31427 r31429 17 17 * @author Jan Peter Stotz 18 18 */ 19 public class JobDispatcher {19 public final class JobDispatcher { 20 20 21 21 private static final JobDispatcher instance = new JobDispatcher(); … … 74 74 * Function to set the maximum number of workers for tile loading. 75 75 */ 76 static public void setMaxWorkers(int workers) {76 public static void setMaxWorkers(int workers) { 77 77 workerThreadMaxCount = workers; 78 78 } … … 96 96 public void addJob(TileJob job) { 97 97 try { 98 if (job.getTile() != null) {99 for (TileJob oldJob : jobQueue) {98 if (job.getTile() != null) { 99 for (TileJob oldJob : jobQueue) { 100 100 if (job.getTile().equals(oldJob.getTile())) { 101 101 return; … … 109 109 } 110 110 } catch (InterruptedException e) { 111 System.err.println("InterruptedException: " + e.getMessage()); 111 112 } 112 113 } … … 146 147 workerThreadIdleCount++; 147 148 } 148 if (modeLIFO) {149 if (modeLIFO) { 149 150 if (firstThread) 150 151 job = jobQueue.takeLast(); -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Layer.java
r30900 r31429 9 9 private List<MapObject> elements; 10 10 11 public Layer(String name) {11 public Layer(String name) { 12 12 super(name); 13 13 } 14 public Layer(String name, String description){ 14 15 public Layer(String name, String description) { 15 16 super(name, description); 16 17 } 17 public Layer(String name, Style style){ 18 19 public Layer(String name, Style style) { 18 20 super(name, style); 19 21 } 20 public Layer(String name, String description, Style style){ 22 23 public Layer(String name, String description, Style style) { 21 24 super(name, description, style); 22 25 } 23 public Layer(LayerGroup parent, String name){ 26 27 public Layer(LayerGroup parent, String name) { 24 28 super(parent, name); 25 29 } 26 public Layer(LayerGroup parent, String name, Style style){ 30 31 public Layer(LayerGroup parent, String name, Style style) { 27 32 super(parent, name, style); 28 33 } 29 public Layer(LayerGroup parent, String name, String description, Style style){ 34 35 public Layer(LayerGroup parent, String name, String description, Style style) { 30 36 super(parent, name, description, style); 31 37 } 38 32 39 public List<MapObject> getElements() { 33 40 return elements; 34 41 } 42 35 43 public void setElements(List<MapObject> elements) { 36 44 this.elements = elements; 37 45 } 46 38 47 public Layer add(MapObject element) { 39 48 element.setLayer(this); -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/LayerGroup.java
r31427 r31429 7 7 private List<AbstractLayer> layers; 8 8 9 public LayerGroup(String name) {9 public LayerGroup(String name) { 10 10 super(name); 11 11 } 12 public LayerGroup(String name, String description){ 12 13 public LayerGroup(String name, String description) { 13 14 super(name, description); 14 15 } 15 public LayerGroup(String name, Style style){ 16 17 public LayerGroup(String name, Style style) { 16 18 super(name, style); 17 19 } 18 public LayerGroup(String name, String description, Style style){ 20 21 public LayerGroup(String name, String description, Style style) { 19 22 super(name, description, style); 20 23 } 21 public LayerGroup(LayerGroup parent, String name){ 24 25 public LayerGroup(LayerGroup parent, String name) { 22 26 super(parent, name); 23 27 } 24 public LayerGroup(LayerGroup parent, String name, String description, Style style){ 28 29 public LayerGroup(LayerGroup parent, String name, String description, Style style) { 25 30 super(name, description, style); 26 31 } 32 27 33 public List<AbstractLayer> getLayers() { 28 34 return layers; 29 35 } 36 30 37 public void setElements(List<AbstractLayer> layers) { 31 38 this.layers = layers; 32 39 } 40 33 41 public Layer addLayer(String name) { 34 42 Layer layer = new Layer(this, name); … … 36 44 return layer; 37 45 } 46 38 47 public LayerGroup add(AbstractLayer layer) { 39 48 layer.setParent(this); … … 41 50 return this; 42 51 } 52 43 53 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++) { 48 58 calculate = resultOf(calculate, layers.get(i).isVisibleTexts()); 49 59 } 50 60 } 51 61 setVisibleTexts(calculate); 52 if (getParent()!=null) getParent().calculateVisibleTexts();62 if (getParent() != null) getParent().calculateVisibleTexts(); 53 63 } 64 54 65 public Boolean resultOf(Boolean b1, Boolean b2) { 55 66 if (b1 != null && b1.equals(b2)) { -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/MapMarkerCircle.java
r31293 r31429 28 28 this(null, null, coord, radius); 29 29 } 30 30 31 public MapMarkerCircle(String name, Coordinate coord, double radius) { 31 32 this(null, name, coord, radius); 32 33 } 34 33 35 public MapMarkerCircle(Layer layer, Coordinate coord, double radius) { 34 36 this(layer, null, coord, radius); 35 37 } 38 36 39 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); 38 41 } 42 39 43 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); 41 45 } 46 42 47 public MapMarkerCircle(Layer layer, String name, Coordinate coord, double radius) { 43 48 this(layer, name, coord, radius, STYLE.VARIABLE, getDefaultStyle()); 44 49 } 50 45 51 public MapMarkerCircle(Layer layer, String name, Coordinate coord, double radius, STYLE markerStyle, Style style) { 46 52 super(layer, name, style); … … 50 56 } 51 57 52 public Coordinate getCoordinate() {58 public Coordinate getCoordinate() { 53 59 return coord; 54 60 } 61 55 62 public double getLat() { 56 63 return coord.getLat(); … … 73 80 int size = size_h * 2; 74 81 75 if (g instanceof Graphics2D && getBackColor() !=null) {82 if (g instanceof Graphics2D && getBackColor() != null) { 76 83 Graphics2D g2 = (Graphics2D) g; 77 84 Composite oldComposite = g2.getComposite(); … … 84 91 g.drawOval(position.x - size_h, position.y - size_h, size, size); 85 92 86 if (getLayer()==null||getLayer().isVisibleTexts()) paintText(g, position);93 if (getLayer() == null || getLayer().isVisibleTexts()) paintText(g, position); 87 94 } 88 95 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()); 91 98 } 99 92 100 @Override 93 101 public String toString() { 94 102 return "MapMarker at " + getLat() + " " + getLon(); 95 103 } 104 96 105 @Override 97 106 public void setLat(double lat) { 98 if (coord==null) coord = new Coordinate(lat,0);107 if (coord == null) coord = new Coordinate(lat, 0); 99 108 else coord.setLat(lat); 100 109 } 110 101 111 @Override 102 112 public void setLon(double lon) { 103 if (coord==null) coord = new Coordinate(0,lon);113 if (coord == null) coord = new Coordinate(0, lon); 104 114 else coord.setLon(lon); 105 115 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/MapMarkerDot.java
r30900 r31429 21 21 this(null, null, coord); 22 22 } 23 23 24 public MapMarkerDot(String name, Coordinate coord) { 24 25 this(null, name, coord); 25 26 } 27 26 28 public MapMarkerDot(Layer layer, Coordinate coord) { 27 29 this(layer, null, coord); 28 30 } 31 29 32 public MapMarkerDot(Layer layer, String name, Coordinate coord) { 30 33 this(layer, name, coord, getDefaultStyle()); 31 34 } 35 32 36 public MapMarkerDot(Color color, double lat, double lon) { 33 37 this(null, null, lat, lon); 34 38 setColor(color); 35 39 } 40 36 41 public MapMarkerDot(double lat, double lon) { 37 42 this(null, null, lat, lon); 38 43 } 44 39 45 public MapMarkerDot(Layer layer, double lat, double lon) { 40 46 this(layer, null, lat, lon); 41 47 } 48 42 49 public MapMarkerDot(Layer layer, String name, double lat, double lon) { 43 50 this(layer, name, new Coordinate(lat, lon), getDefaultStyle()); 44 51 } 52 45 53 public MapMarkerDot(Layer layer, String name, Coordinate coord, Style style) { 46 54 super(layer, name, coord, DOT_RADIUS, STYLE.FIXED, style); 47 55 } 48 56 49 public static Style getDefaultStyle() {57 public static Style getDefaultStyle() { 50 58 return new Style(Color.BLACK, Color.YELLOW, null, getDefaultFont()); 51 59 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/MapObjectImpl.java
r31427 r31429 19 19 this(null, name, null); 20 20 } 21 21 22 public MapObjectImpl(Layer layer) { 22 23 this(layer, null, null); 23 24 } 25 24 26 public MapObjectImpl(Layer layer, String name, Style style) { 25 27 super(); … … 28 30 this.style = style; 29 31 } 32 30 33 public Layer getLayer() { 31 34 return layer; 32 35 } 36 33 37 public void setLayer(Layer layer) { 34 38 this.layer = layer; 35 39 } 36 public Style getStyle(){ 40 41 public Style getStyle() { 37 42 return style; 38 43 } 39 public Style getStyleAssigned(){ 44 45 public Style getStyleAssigned() { 40 46 return style == null ? (layer == null ? null : layer.getStyle()) : style; 41 47 } 42 public void setStyle(Style style){ 48 49 public void setStyle(Style style) { 43 50 this.style = style; 44 51 } 52 45 53 public Color getColor() { 46 54 Style styleAssigned = getStyleAssigned(); 47 55 return styleAssigned == null ? null : getStyleAssigned().getColor(); 48 56 } 57 49 58 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); 52 61 } 53 62 … … 56 65 return styleAssigned == null ? null : getStyleAssigned().getBackColor(); 57 66 } 67 58 68 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); 61 71 } 62 72 … … 65 75 return styleAssigned == null ? null : getStyleAssigned().getStroke(); 66 76 } 77 67 78 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); 70 81 } 71 82 … … 74 85 return styleAssigned == null ? null : getStyleAssigned().getFont(); 75 86 } 87 76 88 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); 79 91 } 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(); 82 95 } 96 83 97 public boolean isVisible() { 84 return visible ==null?isVisibleLayer():visible.booleanValue();98 return visible == null ? isVisibleLayer() : visible.booleanValue(); 85 99 } 100 86 101 public void setVisible(Boolean visible) { 87 102 this.visible = visible; 88 103 } 104 89 105 public String getName() { 90 106 return name; 91 107 } 108 92 109 public void setName(String txt) { 93 110 this.name = txt; 94 111 } 95 public static Font getDefaultFont(){ 112 113 public static Font getDefaultFont() { 96 114 Font f = UIManager.getDefaults().getFont("TextField.font"); 97 115 if (f == null) { … … 102 120 103 121 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) { 106 124 Font f = getDefaultFont(); 107 125 setFont(new Font(f.getName(), Font.BOLD, f.getSize())); -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/MapPolygonImpl.java
r30223 r31429 25 25 this(null, null, points); 26 26 } 27 27 28 public MapPolygonImpl(List<? extends ICoordinate> points) { 28 29 this(null, null, points); 29 30 } 31 30 32 public MapPolygonImpl(String name, List<? extends ICoordinate> points) { 31 33 this(null, name, points); 32 34 } 35 33 36 public MapPolygonImpl(String name, ICoordinate ... points) { 34 37 this(null, name, points); 35 38 } 39 36 40 public MapPolygonImpl(Layer layer, List<? extends ICoordinate> points) { 37 41 this(layer, null, points); 38 42 } 43 39 44 public MapPolygonImpl(Layer layer, String name, List<? extends ICoordinate> points) { 40 45 this(layer, name, points, getDefaultStyle()); 41 46 } 47 42 48 public MapPolygonImpl(Layer layer, String name, ICoordinate ... points) { 43 49 this(layer, name, Arrays.asList(points), getDefaultStyle()); 44 50 } 51 45 52 public MapPolygonImpl(Layer layer, String name, List<? extends ICoordinate> points, Style style) { 46 53 super(layer, name, style); … … 76 83 // Draw 77 84 g.drawPolygon(polygon); 78 if (g instanceof Graphics2D && getBackColor() !=null) {85 if (g instanceof Graphics2D && getBackColor() != null) { 79 86 Graphics2D g2 = (Graphics2D) g; 80 87 Composite oldComposite = g2.getComposite(); … … 91 98 Rectangle rec = polygon.getBounds(); 92 99 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); 95 102 } 96 103 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()); 99 106 } 100 107 -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/MapRectangleImpl.java
r30223 r31429 19 19 this(null, null, topLeft, bottomRight); 20 20 } 21 21 22 public MapRectangleImpl(String name, Coordinate topLeft, Coordinate bottomRight) { 22 23 this(null, name, topLeft, bottomRight); 23 24 } 25 24 26 public MapRectangleImpl(Layer layer, Coordinate topLeft, Coordinate bottomRight) { 25 27 this(layer, null, topLeft, bottomRight); 26 28 } 29 27 30 public MapRectangleImpl(Layer layer, String name, Coordinate topLeft, Coordinate bottomRight) { 28 31 this(layer, name, topLeft, bottomRight, getDefaultStyle()); 29 32 } 33 30 34 public MapRectangleImpl(Layer layer, String name, Coordinate topLeft, Coordinate bottomRight, Style style) { 31 35 super(layer, name, style); … … 62 66 ((Graphics2D) g).setStroke(oldStroke); 63 67 } 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); 68 72 } 69 73 70 public static Style getDefaultStyle() {74 public static Style getDefaultStyle() { 71 75 return new Style(Color.BLUE, null, new BasicStroke(2), getDefaultFont()); 72 76 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmMercator.java
r31293 r31429 101 101 double aStartLat = Math.toRadians(la1); 102 102 double aStartLong = Math.toRadians(lo1); 103 double aEndLat = Math.toRadians(la2);103 double aEndLat = Math.toRadians(la2); 104 104 double aEndLong = Math.toRadians(lo2); 105 105 … … 130 130 public double LonToX(double aLongitude, int aZoomlevel) { 131 131 int mp = getMaxPixels(aZoomlevel); 132 double x = (mp * (aLongitude + 180 l)) / 360l;132 double x = (mp * (aLongitude + 180L)) / 360L; 133 133 return Math.min(x, mp); 134 134 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java
r31145 r31429 22 22 public class OsmTileLoader implements TileLoader { 23 23 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 24 93 /** 25 94 * Holds the HTTP headers. Insert e.g. User-Agent here when default should not be used. … … 38 107 39 108 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); 106 110 } 107 111 … … 111 115 URLConnection urlConn = url.openConnection(); 112 116 if (urlConn instanceof HttpURLConnection) { 113 prepareHttpUrlConnection((HttpURLConnection) urlConn);117 prepareHttpUrlConnection((HttpURLConnection) urlConn); 114 118 } 115 119 return urlConn; … … 138 142 } 139 143 } 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 } 141 150 } 142 151 if (!lng.equals(0L)) { … … 146 155 147 156 protected void prepareHttpUrlConnection(HttpURLConnection urlConn) { 148 for (Entry<String, String> e : headers.entrySet()) {157 for (Entry<String, String> e : headers.entrySet()) { 149 158 urlConn.setRequestProperty(e.getKey(), e.getValue()); 150 159 } 151 if (timeoutConnect != 0)160 if (timeoutConnect != 0) 152 161 urlConn.setConnectTimeout(timeoutConnect); 153 if (timeoutRead != 0)162 if (timeoutRead != 0) 154 163 urlConn.setReadTimeout(timeoutRead); 155 164 } … … 159 168 return getClass().getSimpleName(); 160 169 } 161 162 170 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Style.java
r30900 r31429 16 16 private static final AlphaComposite OPAQUE = AlphaComposite.getInstance(AlphaComposite.SRC); 17 17 18 public Style() {18 public Style() { 19 19 super(); 20 20 } 21 21 22 public Style(Color color, Color backColor, Stroke stroke, Font font) { 22 23 super(); … … 30 31 return color; 31 32 } 33 32 34 public void setColor(Color color) { 33 35 this.color = color; 34 36 } 37 35 38 public Color getBackColor() { 36 39 return backColor; 37 40 } 41 38 42 public void setBackColor(Color backColor) { 39 43 this.backColor = backColor; 40 44 } 45 41 46 public Stroke getStroke() { 42 47 return stroke; 43 48 } 49 44 50 public void setStroke(Stroke stroke) { 45 51 this.stroke = stroke; 46 52 } 53 47 54 public Font getFont() { 48 55 return font; 49 56 } 57 50 58 public void setFont(Font font) { 51 59 this.font = font; 52 60 } 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; 55 64 } 56 public AlphaComposite getAlphaComposite(){ 65 66 public AlphaComposite getAlphaComposite() { 57 67 return getAlphaComposite(color); 58 68 } 59 public AlphaComposite getBackAlphaComposite(){ 69 70 public AlphaComposite getBackAlphaComposite() { 60 71 return getAlphaComposite(backColor); 61 72 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Tile.java
r31427 r31429 236 236 } 237 237 238 239 238 @Override 240 239 public String toString() { … … 348 347 * @return metadata of the tile 349 348 */ 350 public Map<String, String> getMetadata() {349 public Map<String, String> getMetadata() { 351 350 if (metadata == null) { 352 351 metadata = new HashMap<>(); -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/TileXY.java
r31339 r31429 1 // License: GPL. For details, see LICENSEfile.1 // License: GPL. For details, see Readme.txt file. 2 2 package org.openstreetmap.gui.jmapviewer; 3 3 … … 54 54 return y; 55 55 } 56 57 56 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/checkBoxTree/CheckBoxNodeData.java
r30900 r31429 16 16 this.layer = layer; 17 17 } 18 18 19 public CheckBoxNodeData(final String txt) { 19 20 this(new LayerGroup(txt)); 20 21 } 22 21 23 public CheckBoxNodeData(final String txt, final Boolean selected) { 22 24 this(new LayerGroup(txt)); 23 25 layer.setVisible(selected); 24 26 } 27 25 28 public Boolean isSelected() { 26 29 return layer.isVisible(); 27 30 } 31 28 32 public void setSelected(final Boolean newValue) { 29 33 layer.setVisible(newValue); 30 34 } 35 31 36 public String getText() { 32 37 return layer.getName(); 33 38 } 39 34 40 public AbstractLayer getAbstractLayer() { 35 41 return layer; 36 } 42 } 43 37 44 public void setAbstractLayer(final AbstractLayer layer) { 38 45 this.layer = layer; 39 46 } 47 40 48 @Override 41 49 public String toString() { -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/checkBoxTree/CheckBoxNodeEditor.java
r30900 r31429 53 53 } 54 54 }*/ 55 public void addNodeListener(MouseAdapter listener){ 55 56 public void addNodeListener(MouseAdapter listener) { 56 57 renderer.addNodeListener(listener); 57 58 } 59 58 60 @Override 59 61 public boolean isCellEditable(final EventObject event) { … … 76 78 public Component getTreeCellEditorComponent(final JTree tree, 77 79 final Object value, final boolean selected, final boolean expanded, 78 final boolean leaf, final int row) 79 { 80 final boolean leaf, final int row) { 80 81 81 82 final Component editor = -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/checkBoxTree/CheckBoxNodePanel.java
r30900 r31429 27 27 add(label, BorderLayout.CENTER); 28 28 } 29 public void setSelected(Boolean bool){ 30 if(bool==null){ 29 30 public void setSelected(Boolean bool) { 31 if (bool == null) { 31 32 check.getModel().setPressed(true); 32 33 check.getModel().setArmed(true); 33 } else{34 } else { 34 35 check.setSelected(bool.booleanValue()); 35 36 check.getModel().setArmed(false); 36 37 } 37 38 } 39 38 40 public CheckBoxNodeData getData() { 39 41 data.setSelected(check.isSelected()); 40 42 return data; 41 43 } 44 42 45 public void setData(CheckBoxNodeData data) { 43 46 this.data = data; 44 47 label.setText(data.getText()); 45 48 } 49 46 50 public JLabel getLabel() { 47 51 return label; -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/checkBoxTree/CheckBoxNodeRenderer.java
r30900 r31429 5 5 import java.awt.Component; 6 6 import java.awt.Font; 7 import java.awt.event.ActionEvent;8 import java.awt.event.ActionListener;9 7 import java.awt.event.MouseAdapter; 10 8 11 import javax.swing.JMenuItem;12 import javax.swing.JPopupMenu;13 9 import javax.swing.JTree; 14 10 import javax.swing.UIManager; … … 16 12 import javax.swing.tree.DefaultTreeCellRenderer; 17 13 import javax.swing.tree.TreeCellRenderer; 18 19 import org.openstreetmap.gui.jmapviewer.AbstractLayer;20 import org.openstreetmap.gui.jmapviewer.LayerGroup;21 14 22 15 /** … … 49 42 textBackground = UIManager.getColor("Tree.textBackground"); 50 43 } 51 public void addNodeListener(MouseAdapter listener){ 44 45 public void addNodeListener(MouseAdapter listener) { 52 46 panel.addMouseListener(listener); 53 47 } … … 57 51 public Component getTreeCellRendererComponent(final JTree tree, 58 52 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) { 61 54 CheckBoxNodeData data = null; 62 55 if (value instanceof DefaultMutableTreeNode) { … … 81 74 panel.getLabel().setForeground(selectionForeground); 82 75 panel.getLabel().setBackground(selectionBackground); 83 } 84 else { 76 } else { 85 77 panel.setForeground(textForeground); 86 78 panel.setBackground(textBackground); … … 101 93 return panel; 102 94 } 95 /* 103 96 private JPopupMenu createPopupMenu(final AbstractLayer layer) { 104 97 JMenuItem menuItem; 105 98 106 99 //Create the popup menu. 107 if (layer.isVisibleTexts()) menuItem = new JMenuItem("hide texts");100 if (layer.isVisibleTexts()) menuItem = new JMenuItem("hide texts"); 108 101 else menuItem = new JMenuItem("show texts"); 109 102 JPopupMenu popup = new JPopupMenu(); … … 118 111 return popup; 119 112 } 120 private void setVisibleTexts(AbstractLayer layer, boolean visible){ 113 114 private void setVisibleTexts(AbstractLayer layer, boolean visible) { 121 115 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 } 125 122 } 126 123 } 124 */ 127 125 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/checkBoxTree/CheckBoxTree.java
r31427 r31429 30 30 private final CheckBoxNodeEditor editor; 31 31 32 public CheckBoxTree(AbstractLayer layer) {32 public CheckBoxTree(AbstractLayer layer) { 33 33 this(new CheckBoxNodeData(layer)); 34 34 } 35 public CheckBoxTree(String rootName){ 35 36 public CheckBoxTree(String rootName) { 36 37 this(new CheckBoxNodeData(rootName)); 37 38 } 38 public CheckBoxTree(CheckBoxNodeData root ){ 39 40 public CheckBoxTree(CheckBoxNodeData root) { 39 41 this(new DefaultMutableTreeNode(root)); 40 42 } 41 public CheckBoxTree(DefaultMutableTreeNode node){ 43 44 public CheckBoxTree(DefaultMutableTreeNode node) { 42 45 super(new DefaultTreeModel(node)); 43 46 … … 53 56 @Override 54 57 public void treeNodesChanged(final TreeModelEvent e) { 55 DefaultTreeModel model = (DefaultTreeModel) e.getSource();58 DefaultTreeModel model = (DefaultTreeModel) e.getSource(); 56 59 Object[] nodes = e.getChildren(); 57 60 DefaultMutableTreeNode node; 58 if (nodes==null||nodes.length==0){61 if (nodes == null || nodes.length == 0) { 59 62 node = node(model.getRoot()); 60 } else{63 } else { 61 64 node = node(nodes[0]); 62 65 } … … 81 84 }); 82 85 } 83 public void addNodeListener(MouseAdapter listener){ 86 87 public void addNodeListener(MouseAdapter listener) { 84 88 editor.addNodeListener(listener); 85 89 } 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)); 88 93 89 94 final DefaultMutableTreeNode accessibility = … … 102 107 103 108 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(); 106 111 // listen for changes in the selection 107 112 tree.addTreeSelectionListener(new TreeSelectionListener() { … … 119 124 frame.setVisible(true); 120 125 } 121 private static Boolean childStatus(DefaultMutableTreeNode node){ 126 127 private static Boolean childStatus(DefaultMutableTreeNode node) { 122 128 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++) { 124 130 if (!status.equals( 125 131 data(node.getChildAt(i)).isSelected() … … 129 135 return status; 130 136 } 131 private static void changeParents(DefaultMutableTreeNode node){ 132 if(node!=null){ 137 138 private static void changeParents(DefaultMutableTreeNode node) { 139 if (node != null) { 133 140 DefaultMutableTreeNode parent = node(node.getParent()); 134 if (parent!=null){141 if (parent != null) { 135 142 CheckBoxNodeData dataParent = data(parent); 136 143 Boolean childStatus = childStatus(parent); 137 if (childStatus != null && !childStatus.equals(dataParent.isSelected())) {144 if (childStatus != null && !childStatus.equals(dataParent.isSelected())) { 138 145 dataParent.setSelected(childStatus); 139 146 changeParents(parent); … … 142 149 } 143 150 } 144 private static void nodeChanged(DefaultMutableTreeNode node){ 145 if(node!=null){ 151 152 private static void nodeChanged(DefaultMutableTreeNode node) { 153 if (node != null) { 146 154 changeParents(node); 147 155 setChildrens(node, data(node).isSelected()); 148 156 } 149 157 } 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++) { 152 161 DefaultMutableTreeNode childNode = node(node.getChildAt(i)); 153 if (!data(childNode).isSelected().equals(data(node).isSelected())) {162 if (!data(childNode).isSelected().equals(data(node).isSelected())) { 154 163 data(childNode).setSelected(data(node).isSelected()); 155 164 setChildrens(childNode, value); … … 157 166 } 158 167 } 159 public DefaultMutableTreeNode rootNode(){ 168 169 public DefaultMutableTreeNode rootNode() { 160 170 return node(getModel().getRoot()); 161 171 } 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() { 166 178 return data(rootNode()); 167 179 } 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) { 175 190 return data(node(node)); 176 191 } 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) { 178 194 final CheckBoxNodeData data = new CheckBoxNodeData(text, checked); 179 195 final DefaultMutableTreeNode node = new DefaultMutableTreeNode(data); … … 181 197 return node; 182 198 } 183 public static CheckBoxNodeData createNodeData(AbstractLayer layer){ 199 200 public static CheckBoxNodeData createNodeData(AbstractLayer layer) { 184 201 return new CheckBoxNodeData(layer); 185 202 } 186 public static DefaultMutableTreeNode createNode(AbstractLayer layer){ 203 204 public static DefaultMutableTreeNode createNode(AbstractLayer layer) { 187 205 return new DefaultMutableTreeNode(createNodeData(layer)); 188 206 } 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){ 192 211 return add(rootNode(), group); 193 } else{212 } else { 194 213 DefaultMutableTreeNode parentGroup = searchNode(group.getParent()); 195 214 if(parentGroup==null) parentGroup = addLayerGroup(group.getParent()); … … 199 218 }else return null; 200 219 }*/ 201 public Layer addLayer(String name){ 220 221 public Layer addLayer(String name) { 202 222 Layer layer = new Layer(name); 203 223 addLayer(layer); 204 224 return layer; 205 225 } 206 public DefaultMutableTreeNode addLayer(AbstractLayer layer){ 207 if (layer!=null){ 226 227 public DefaultMutableTreeNode addLayer(AbstractLayer layer) { 228 if (layer != null) { 208 229 DefaultMutableTreeNode parent; 209 if (layer.getParent()==null){230 if (layer.getParent() == null) { 210 231 rootLayer().add(layer); 211 232 parent = rootNode(); 212 } else{233 } else { 213 234 parent = searchNode(layer.getParent()); 214 if(parent==null) parent=addLayer(layer.getParent()); 235 if (parent == null) 236 parent = addLayer(layer.getParent()); 215 237 } 216 238 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) { 220 243 layer.setVisible(data(parent).isSelected()); 221 244 DefaultMutableTreeNode node = createNode(layer); 222 245 parent.add(node); 223 ((DefaultTreeModel) getModel()).reload();246 ((DefaultTreeModel) getModel()).reload(); 224 247 //System.out.println("Created node "+layer+" upper of "+data(parent)); 225 248 return node; 226 249 } 227 public DefaultMutableTreeNode searchNode(AbstractLayer layer){ 250 251 public DefaultMutableTreeNode searchNode(AbstractLayer layer) { 228 252 return searchNode(rootNode(), layer); 229 253 } 230 public DefaultMutableTreeNode searchNode(DefaultMutableTreeNode node, AbstractLayer layer){ 254 255 public DefaultMutableTreeNode searchNode(DefaultMutableTreeNode node, AbstractLayer layer) { 231 256 CheckBoxNodeData data = CheckBoxTree.data(node); 232 if (data.getAbstractLayer() == layer) return node;233 else {257 if (data.getAbstractLayer() == layer) return node; 258 else { 234 259 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); 237 262 } 238 263 return found; -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/CachedTileLoader.java
r31082 r31429 6 6 */ 7 7 public interface CachedTileLoader { 8 publicvoid clearCache(TileSource source);8 void clearCache(TileSource source); 9 9 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/ICoordinate.java
r30900 r31429 3 3 4 4 public 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); 9 13 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/JMapViewerEventListener.java
r30223 r31429 14 14 */ 15 15 public interface JMapViewerEventListener extends EventListener { 16 publicvoid processCommand(JMVCommandEvent command);16 void processCommand(JMVCommandEvent command); 17 17 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/MapMarker.java
r31293 r31429 22 22 * @return Latitude and Longitude of the map marker position 23 23 */ 24 public Coordinate getCoordinate(); 24 Coordinate getCoordinate(); 25 25 26 /** 26 27 * @return Latitude of the map marker position 27 28 */ 28 publicdouble getLat();29 double getLat(); 29 30 30 31 /** 31 32 * @return Longitude of the map marker position 32 33 */ 33 publicdouble getLon();34 double getLon(); 34 35 35 36 /** 36 37 * @return Radius of the map marker position 37 38 */ 38 publicdouble getRadius();39 double getRadius(); 39 40 40 41 /** 41 42 * @return Style of the map marker 42 43 */ 43 publicSTYLE getMarkerStyle();44 STYLE getMarkerStyle(); 44 45 45 46 /** … … 51 52 * @param radius radius 52 53 */ 53 publicvoid paint(Graphics g, Point position, int radius);54 void paint(Graphics g, Point position, int radius); 54 55 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/MapObject.java
r30900 r31429 11 11 public interface MapObject { 12 12 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(); 23 32 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/MapPolygon.java
r31293 r31429 17 17 * @return Latitude/Longitude of each point of polygon 18 18 */ 19 publicList<? extends ICoordinate> getPoints();19 List<? extends ICoordinate> getPoints(); 20 20 21 21 /** … … 26 26 * @param points list of points defining the polygon to draw 27 27 */ 28 publicvoid paint(Graphics g, List<Point> points);28 void paint(Graphics g, List<Point> points); 29 29 30 30 /** … … 35 35 * @param polygon polygon to draw 36 36 */ 37 publicvoid paint(Graphics g, Polygon polygon);37 void paint(Graphics g, Polygon polygon); 38 38 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/MapRectangle.java
r30900 r31429 20 20 * @return Latitude/Longitude of top left of rectangle 21 21 */ 22 publicCoordinate getTopLeft();22 Coordinate getTopLeft(); 23 23 24 24 /** 25 25 * @return Latitude/Longitude of bottom right of rectangle 26 26 */ 27 publicCoordinate getBottomRight();27 Coordinate getBottomRight(); 28 28 29 29 /** … … 35 35 * @param bottomRight bottom right edge of painting region 36 36 */ 37 publicvoid paint(Graphics g, Point topLeft, Point bottomRight);37 void paint(Graphics g, Point topLeft, Point bottomRight); 38 38 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/TemplatedTileSource.java
r31310 r31429 1 // License: GPL. For details, see LICENSEfile.1 // License: GPL. For details, see Readme.txt file. 2 2 package org.openstreetmap.gui.jmapviewer.interfaces; 3 3 … … 15 15 * @return headers to be sent with http requests 16 16 */ 17 publicMap<String, String> getHeaders();17 Map<String, String> getHeaders(); 18 18 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/TileCache.java
r30900 r31429 28 28 * present in the cache 29 29 */ 30 publicTile getTile(TileSource source, int x, int y, int z);30 Tile getTile(TileSource source, int x, int y, int z); 31 31 32 32 /** … … 37 37 * @param tile the tile to be added 38 38 */ 39 publicvoid addTile(Tile tile);39 void addTile(Tile tile); 40 40 41 41 /** 42 42 * @return the number of tiles hold by the cache 43 43 */ 44 publicint getTileCount();44 int getTileCount(); 45 45 46 46 /** 47 47 * Clears the cache deleting all tiles from memory. 48 48 */ 49 publicvoid clear();49 void clear(); 50 50 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/TileJob.java
r31174 r31429 17 17 * @return {@link Tile} to be handled 18 18 */ 19 publicTile getTile();19 Tile getTile(); 20 20 21 21 /** -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/TileLoader.java
r30900 r31429 20 20 * action. 21 21 */ 22 publicTileJob createTileLoaderJob(Tile tile);22 TileJob createTileLoaderJob(Tile tile); 23 23 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/TileLoaderListener.java
r30900 r31429 13 13 * @param success {@code true} if the tile has been loaded successfully, {@code false} otherwise 14 14 */ 15 publicvoid tileLoadingFinished(Tile tile, boolean success);15 void tileLoadingFinished(Tile tile, boolean success); 16 16 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/TileSource.java
r31371 r31429 38 38 * </ul> 39 39 * 40 */ 41 @Deprecated //not used anymore 40 * @deprecated not used anymore 41 */ 42 @Deprecated 42 43 public enum TileUpdate { 43 44 IfNoneMatch, ETag, IfModifiedSince, LastModified, None … … 100 101 * get the same identifier. Used for creation of cache key. 101 102 * 102 * @param zoom 103 * @param tilex 104 * @param tiley 103 * @param zoom zoom level 104 * @param tilex X coordinate 105 * @param tiley Y coordinate 105 106 * @return tile identifier 106 107 */ … … 117 118 * TODO: @since 118 119 */ 119 publicint getDefaultTileSize();120 int getDefaultTileSize(); 120 121 121 122 /** … … 131 132 /** 132 133 * Transform longitude to pixelspace. 133 * @param aLongitude 134 * @param aZoomlevel 134 * @param aLongitude longitude 135 * @param aZoomlevel zoom level 135 136 * @return [0..2^Zoomlevel*TILE_SIZE[ 137 * @deprecated use {@link #latLonToXY(double, double, int)} instead 136 138 */ 137 139 @Deprecated … … 140 142 /** 141 143 * Transforms latitude to pixelspace. 142 * @param aLat 143 * @param aZoomlevel 144 * @param aLat latitude 145 * @param aZoomlevel zoom level 144 146 * @return [0..2^Zoomlevel*TILE_SIZE[ 145 * @deprecated use lonLatToXYinstead147 * @deprecated use {@link #latLonToXY(double, double, int)} instead 146 148 */ 147 149 @Deprecated … … 149 151 150 152 /** 151 * @param lon 152 * @param lat 153 * @param zoom 153 * @param lon longitude 154 * @param lat latitude 155 * @param zoom zoom level 154 156 * @return transforms longitude and latitude to pixel space (as if all tiles at specified zoom level where joined) 155 157 */ 156 publicPoint 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 161 163 * @return transforms longitude and latitude to pixel space (as if all tiles at specified zoom level where joined) 162 164 */ 163 publicPoint latLonToXY(ICoordinate point, int zoom);165 Point latLonToXY(ICoordinate point, int zoom); 164 166 165 167 /** 166 168 * Transforms pixel coordinate X to longitude 167 * @param aX 168 * @param aZoomlevel 169 * @param aX X coordinate 170 * @param aZoomlevel zoom level 169 171 * @return ]-180..180[ 172 * @deprecated use {@link #XYToLatLon(int, int, int)} instead 170 173 */ 171 174 @Deprecated … … 174 177 /** 175 178 * Transforms pixel coordinate Y to latitude. 176 * @param aY 177 * @param aZoomlevel 179 * @param aY Y coordinate 180 * @param aZoomlevel zoom level 178 181 * @return [MIN_LAT..MAX_LAT] 182 * @deprecated use {@link #XYToLatLon(int, int, int)} instead 179 183 */ 180 184 @Deprecated … … 182 186 183 187 /** 184 * @param point 185 * @param zoom 188 * @param point point 189 * @param zoom zoom level 186 190 * @return WGS84 Coordinates of given point 187 191 */ 188 publicICoordinate 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 195 199 * @return WGS84 Coordinates of given point 196 200 */ 197 publicICoordinate XYToLatLon(int x, int y, int zoom);201 ICoordinate XYToLatLon(int x, int y, int zoom); 198 202 199 203 /** 200 204 * Transforms longitude to X tile coordinate. 201 * @param lon 202 * @param zoom 205 * @param lon longitude 206 * @param zoom zoom level 203 207 * @return [0..2^Zoomlevel[ 208 * @deprecated use {@link #latLonToTileXY(int, int, int)} instead 204 209 */ 205 210 @Deprecated … … 208 213 /** 209 214 * Transforms latitude to Y tile coordinate. 210 * @param lat 211 * @param zoom 215 * @param lat latitude 216 * @param zoom zoom level 212 217 * @return [0..2^Zoomlevel[ 218 * @deprecated use {@link #latLonToTileXY(int, int, int)} instead 213 219 */ 214 220 @Deprecated … … 216 222 217 223 /** 218 * @param lon 219 * @param lat 220 * @param zoom 224 * @param lon longitude 225 * @param lat latitude 226 * @param zoom zoom level 221 227 * @return x and y tile indices 222 228 */ 223 publicTileXY 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 229 235 * @return x and y tile indices 230 236 */ 231 publicTileXY latLonToTileXY(ICoordinate point, int zoom);237 TileXY latLonToTileXY(ICoordinate point, int zoom); 232 238 233 239 /** 234 240 * Transforms tile X coordinate to longitude. 235 * @param x 236 * @param zoom 241 * @param x X coordinate 242 * @param zoom zoom level 237 243 * @return ]-180..180[ 244 * @deprecated use {@link #tileXYToLatLon(int, int, int)} instead 238 245 */ 239 246 @Deprecated … … 242 249 /** 243 250 * Transforms tile Y coordinate to latitude. 244 * @param y 245 * @param zoom 251 * @param y Y coordinate 252 * @param zoom zoom level 246 253 * @return [MIN_LAT..MAX_LAT] 254 * @deprecated use {@link #tileXYToLatLon(int, int, int)} instead 247 255 */ 248 256 @Deprecated … … 250 258 251 259 /** 252 * @param xy 253 * @param zoom 260 * @param xy X/Y coordinates 261 * @param zoom zoom level 254 262 * @return WGS84 coordinates of given tile 255 263 */ 256 publicICoordinate 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 261 269 * @return WGS84 coordinates of given tile 262 270 */ 263 publicICoordinate 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 270 278 * @return WGS84 coordinates of given tile 271 279 */ 272 publicICoordinate 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 276 284 * @return maximum X index of tile for specified zoom level 277 285 */ 278 publicint getTileXMax(int zoom);279 280 /** 281 * 282 * @param zoom 286 int getTileXMax(int zoom); 287 288 /** 289 * 290 * @param zoom zoom level 283 291 * @return minimum X index of tile for specified zoom level 284 292 */ 285 publicint getTileXMin(int zoom);286 287 /** 288 * 289 * @param zoom 293 int getTileXMin(int zoom); 294 295 /** 296 * 297 * @param zoom zoom level 290 298 * @return maximum Y index of tile for specified zoom level 291 299 */ 292 publicint getTileYMax(int zoom);293 294 /** 295 * @param zoom 300 int getTileYMax(int zoom); 301 302 /** 303 * @param zoom zoom level 296 304 * @return minimum Y index of tile for specified zoom level 297 305 */ 298 publicint getTileYMin(int zoom);306 int getTileYMin(int zoom); 299 307 300 308 /** … … 307 315 * @return true, if "no tile at this zoom level" situation detected 308 316 */ 309 publicboolean isNoTileAtZoom(Map<String, List<String>> headers, int statusCode, byte[] content);317 boolean isNoTileAtZoom(Map<String, List<String>> headers, int statusCode, byte[] content); 310 318 311 319 /** … … 315 323 * @return tile metadata 316 324 */ 317 public Map<String, String> getMetadata(Map<String, List<String>> headers); 318 319 325 Map<String, String> getMetadata(Map<String, List<String>> headers); 320 326 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractOsmTileSource.java
r31301 r31429 12 12 13 13 /** 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> 15 16 */ 16 17 public static final String DEFAULT_OSM_ATTRIBUTION = "\u00a9 OpenStreetMap contributors"; -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTMSTileSource.java
r31371 r31429 39 39 this.name = info.getName(); 40 40 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); 43 43 } 44 44 this.id = info.getUrl(); … … 129 129 @Override 130 130 public int lonToX(double lon, int zoom) { 131 return (int )osmMercator.LonToX(lon, zoom);131 return (int) osmMercator.LonToX(lon, zoom); 132 132 } 133 133 134 134 @Override 135 135 public int latToY(double lat, int zoom) { 136 return (int )osmMercator.LatToY(lat, zoom);136 return (int) osmMercator.LatToY(lat, zoom); 137 137 } 138 138 … … 140 140 public Point latLonToXY(double lat, double lon, int zoom) { 141 141 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) 144 144 ); 145 145 } … … 243 243 return 0; 244 244 } 245 246 245 247 246 @Override … … 284 283 285 284 private int getTileMax(int zoom) { 286 return (int) Math.pow(2.0, zoom) - 1;285 return (int) Math.pow(2.0, zoom) - 1; 287 286 } 288 287 } -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTileSource.java
r31301 r31429 9 9 import org.openstreetmap.gui.jmapviewer.interfaces.TileSource; 10 10 11 abstract publicclass AbstractTileSource implements TileSource {11 public abstract class AbstractTileSource implements TileSource { 12 12 13 13 protected String attributionText; -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java
r31427 r31429 102 102 imageryZoomMax = Integer.parseInt(xpath.compile("//ImageryMetadata/ZoomMax/text()").evaluate(document)); 103 103 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); 105 106 subdomains = new String[subdomainTxt.getLength()]; 106 for (int i = 0; i < subdomainTxt.getLength(); i++) {107 for (int i = 0; i < subdomainTxt.getLength(); i++) { 107 108 subdomains[i] = subdomainTxt.item(i).getNodeValue(); 108 109 } … … 119 120 XPathExpression eastLonXpath = xpath.compile("BoundingBox/EastLongitude/text()"); 120 121 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); 122 124 List<Attribution> attributions = new ArrayList<>(imageryProviderNodes.getLength()); 123 125 for (int i = 0; i < imageryProviderNodes.getLength(); i++) { … … 127 129 128 130 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++) { 130 132 Node areaNode = coverageAreaNodes.item(j); 131 133 Attribution attr = new Attribution(); … … 160 162 @Override 161 163 public int getMaxZoom() { 162 if (imageryZoomMax != null)164 if (imageryZoomMax != null) 163 165 return imageryZoomMax; 164 166 else … … 194 196 for (int i = 0; i < 5 && getAttribution() == null; i++) { 195 197 // Makes sure attribution is loaded 198 if (JMapViewer.debug) { 199 System.out.println("Bing attribution attempt " + (i+1)); 200 } 196 201 } 197 202 if (brandLogoUri != null && !brandLogoUri.isEmpty()) { … … 259 264 throw new RuntimeException(ex.getCause()); 260 265 } catch (InterruptedException ign) { 266 System.err.println("InterruptedException: " + ign.getMessage()); 261 267 } 262 268 return null; -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/OsmTileSource.java
r30900 r31429 14 14 private static final String PATTERN = "https://%s.tile.openstreetmap.org"; 15 15 16 private static final String[] SERVER = { "a", "b", "c"};16 private static final String[] SERVER = {"a", "b", "c"}; 17 17 18 18 private int SERVER_NUM = 0; … … 27 27 @Override 28 28 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]}); 30 30 SERVER_NUM = (SERVER_NUM + 1) % SERVER.length; 31 31 return url; … … 49 49 private static final String PATTERN = "http://%s.tile.opencyclemap.org/cycle"; 50 50 51 private static final String[] SERVER = { "a", "b", "c"};51 private static final String[] SERVER = {"a", "b", "c"}; 52 52 53 53 private int SERVER_NUM = 0; … … 62 62 @Override 63 63 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]}); 65 65 SERVER_NUM = (SERVER_NUM + 1) % SERVER.length; 66 66 return url; -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/ScanexTileSource.java
r31310 r31429 1 // License: BSD orGPL. For details, see Readme.txt file.1 // License: GPL. For details, see Readme.txt file. 2 2 package org.openstreetmap.gui.jmapviewer.tilesources; 3 3 … … 6 6 import org.openstreetmap.gui.jmapviewer.OsmMercator; 7 7 8 /* 8 /** 9 9 * This tilesource uses different to OsmMercator projection. 10 10 * … … 18 18 * TODO: correct getDistance() method. 19 19 */ 20 21 20 public class ScanexTileSource extends TMSTileSource { 22 21 private static final String DEFAULT_URL = "http://maps.kosmosnimki.ru"; … … 35 34 this.uri = uri; 36 35 } 36 37 37 public String getName() { 38 38 return name; 39 39 } 40 40 41 public String getUri() { 41 42 return uri; … … 66 67 @Override 67 68 public String getExtension() { 68 return ("jpeg");69 return "jpeg"; 69 70 } 70 71 71 72 @Override 72 73 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); 74 75 75 76 tilex = tilex - tmp; … … 84 85 } 85 86 86 87 87 /* 88 88 * Latitude to Y and back calculations. … … 94 94 @Override 95 95 public int latToY(double lat, int zoom) { 96 return (int )(latToTileY(lat, zoom) * tileSize);96 return (int) (latToTileY(lat, zoom) * tileSize); 97 97 } 98 98 99 99 @Override 100 100 public double YToLat(int y, int zoom) { 101 return tileYToLat((double )y / tileSize, zoom);101 return tileYToLat((double) y / tileSize, zoom); 102 102 } 103 103 … … 112 112 @Override 113 113 public double tileYToLat(int y, int zoom) { 114 return tileYToLat((double )y, zoom);114 return tileYToLat((double) y, zoom); 115 115 } 116 116 … … 133 133 Random r = new Random(); 134 134 lat = OsmMercator.MIN_LAT + 135 r.nextInt((int )(OsmMercator.MAX_LAT - OsmMercator.MIN_LAT));135 r.nextInt((int) (OsmMercator.MAX_LAT - OsmMercator.MIN_LAT)); 136 136 } 137 137 } while ((Math.abs(lat0 - lat) > 0.000001)); … … 144 144 /* Next term in Newton's polynomial */ 145 145 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); 148 148 double ec, f, df; 149 149 150 zoom = (int )Math.pow(2.0, zoom - 1);150 zoom = (int) Math.pow(2.0, zoom - 1); 151 151 ec = Math.exp((1 - y/zoom)*Math.PI); 152 152 … … 154 154 ec * Math.pow(Math.tan(Math.PI/4 + Math.asin(E * sinl)/2), E)); 155 155 df = 1/(1 - sinl) - ec * E * cosl/((1 - E * sinl) * 156 (Math.sqrt 156 (Math.sqrt(1 - E * E * sinl * sinl))); 157 157 158 158 return (f/df); -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/TemplatedTMSTileSource.java
r31301 r31429 52 52 /** 53 53 * Creates Templated TMS Tile Source based on ImageryInfo 54 * @param info 54 * @param info imagery info 55 55 */ 56 56 public TemplatedTMSTileSource(TileSourceInfo info) { … … 73 73 Matcher matcher = pattern.matcher(baseUrl); 74 74 while (matcher.find()) { 75 headers.put(matcher.group(1), matcher.group(2));75 headers.put(matcher.group(1), matcher.group(2)); 76 76 matcher.appendReplacement(output, ""); 77 77 } … … 89 89 Matcher m = Pattern.compile(".*"+PATTERN_ZOOM+".*").matcher(this.baseUrl); 90 90 if (m.matches()) { 91 if (m.group(1) != null) {91 if (m.group(1) != null) { 92 92 finalZoom = Integer.valueOf(m.group(1))-zoom; 93 93 } 94 if (m.group(2) != null) {94 if (m.group(2) != null) { 95 95 String ofs = m.group(2); 96 if (ofs.startsWith("+"))96 if (ofs.startsWith("+")) 97 97 ofs = ofs.substring(1); 98 98 finalZoom += Integer.valueOf(ofs); … … 103 103 .replaceAll(PATTERN_X, Integer.toString(tilex)) 104 104 .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)); 107 107 if (rand != null) { 108 108 r = r.replaceAll(PATTERN_SWITCH, randomParts[rand.nextInt(randomParts.length)]); … … 113 113 /** 114 114 * Checks if url is acceptable by this Tile Source 115 * @param url 115 * @param url URL to check 116 116 */ 117 117 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"; 119 119 Matcher m = Pattern.compile("\\{[^}]*\\}").matcher(url); 120 120 while (m.find()) { -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/TileSourceInfo.java
r31427 r31429 1 // License: GPL. For details, see LICENSEfile.1 // License: GPL. For details, see Readme.txt file. 2 2 package org.openstreetmap.gui.jmapviewer.tilesources; 3 3
Note:
See TracChangeset
for help on using the changeset viewer.