├── lib └── jai_imageio.jar ├── manifest.mf ├── src ├── ika │ ├── geo │ │ ├── GeoPath.java │ │ ├── Symbol.java │ │ ├── GeoSetChangeListener.java │ │ ├── GeoSetSelectionChangeController.java │ │ ├── GeoSetSelectionChangeListener.java │ │ └── GeoControlPoint.java │ ├── icons │ │ ├── line1.gif │ │ ├── line2.gif │ │ ├── line3.gif │ │ ├── line4.gif │ │ ├── line5.gif │ │ ├── point1.gif │ │ ├── point2.gif │ │ ├── point3.gif │ │ ├── point4.gif │ │ ├── point5.gif │ │ ├── point6.gif │ │ ├── update.png │ │ ├── update2.png │ │ ├── Hand16x16.gif │ │ ├── Hand32x32.gif │ │ ├── Pen16x16.gif │ │ ├── Pen32x32.gif │ │ ├── logo32x32.gif │ │ ├── logo48x48.gif │ │ ├── Arrow16x16.gif │ │ ├── Black16x16.gif │ │ ├── Ruler16x16.gif │ │ ├── ShowAll16x16.gif │ │ ├── ShowAll20x14.png │ │ ├── ZoomIn16x16.gif │ │ ├── ZoomIn32x32.gif │ │ ├── ZoomOut16x16.gif │ │ ├── ZoomOut32x32.gif │ │ ├── logo128x128.gif │ │ ├── MovePoint16x16.gif │ │ ├── MovePoint32x32.gif │ │ ├── SetPoint16x16.gif │ │ ├── SetPoint32x32.gif │ │ ├── ClosedHand16x16.gif │ │ ├── ClosedHand32x32.gif │ │ ├── SelectPoints16x16.gif │ │ ├── SelectPoints32x32.gif │ │ └── IconLoader.java │ ├── gui │ │ ├── MainWindow.java │ │ ├── CoordinateInfoPanel.java │ │ ├── NumberFieldChecker.java │ │ ├── TransparentPanel.java │ │ ├── MacWindowsManager.java │ │ ├── ImageReferencerDialog.form │ │ ├── ImageReferencerDialog.java │ │ ├── SliderUtils.java │ │ ├── GeoObjectInfoPanel.form │ │ └── ImageReaderProgressDialog.form │ ├── utils │ │ ├── NumberFormatter.java │ │ ├── NumericalUtils.java │ │ ├── CoordinateFormatter.java │ │ ├── SwingThreadUtils.java │ │ ├── ReferenceDistanceFormatter.java │ │ ├── ColorUtils.java │ │ ├── XMLDOMPrinter.java │ │ ├── ErrorDialog.java │ │ └── Median.java │ ├── geoimport │ │ ├── ImageImporter.java │ │ ├── PointImporter.java │ │ └── UngenerateImporter.java │ ├── mapanalyst │ │ ├── MekenkampCircles.java │ │ ├── MapAnalyzer.java │ │ ├── Link.java │ │ ├── GeometryTransformer.java │ │ ├── ApplicationInfo.java │ │ └── Main.java │ ├── transformation │ │ ├── TransformationAffine6.java │ │ └── robustestimator │ │ │ ├── RobustEstimator.java │ │ │ ├── HuberEstimator.java │ │ │ ├── HampelEstimator.java │ │ │ └── VEstimator.java │ ├── map │ │ └── tools │ │ │ ├── MapToolMouseMotionListener.java │ │ │ ├── MapToolActionListener.java │ │ │ ├── MeasureToolListener.java │ │ │ ├── ZoomOutTool.java │ │ │ ├── PolygonTool.java │ │ │ ├── SingleSelectionPointSetterTool.java │ │ │ ├── PointSetterTool.java │ │ │ ├── SelectionTool.java │ │ │ ├── ZoomInTool.java │ │ │ ├── PanTool.java │ │ │ └── DoubleBufferedTool.java │ ├── geoexport │ │ ├── TableExporter.java │ │ ├── DisplayableTableColumn.java │ │ ├── GeoSetExporter.java │ │ ├── ESRIASCIIGridExporter.java │ │ ├── ImageExporter.java │ │ ├── UngenerateExporter.java │ │ ├── ShapeExporter.java │ │ └── RasterImageExporter.java │ ├── data │ │ └── projections.txt │ ├── proj │ │ └── ProjectionsManager.java │ └── mapanalystonline │ │ └── MapAnalystHeadless.java ├── org │ └── openstreetmap │ │ └── gui │ │ └── jmapviewer │ │ ├── images │ │ ├── plus.png │ │ ├── error.png │ │ ├── minus.png │ │ ├── bing_maps.png │ │ └── hourglass.png │ │ ├── interfaces │ │ ├── CachedTileLoader.java │ │ ├── TileClearController.java │ │ ├── TemplatedTileSource.java │ │ ├── JMapViewerEventListener.java │ │ ├── IProjected.java │ │ ├── TileJob.java │ │ ├── MapObject.java │ │ ├── TileLoaderListener.java │ │ ├── ICoordinate.java │ │ ├── MapPolygon.java │ │ ├── MapRectangle.java │ │ ├── TileLoader.java │ │ ├── MapMarker.java │ │ ├── Attributed.java │ │ └── TileCache.java │ │ ├── package.html │ │ ├── events │ │ └── JMVCommandEvent.java │ │ ├── JMapController.java │ │ ├── checkBoxTree │ │ ├── CheckBoxNodeData.java │ │ ├── CheckBoxNodePanel.java │ │ └── CheckBoxNodeEditor.java │ │ ├── Layer.java │ │ ├── TileXY.java │ │ ├── TileRange.java │ │ ├── MapMarkerDot.java │ │ ├── Projected.java │ │ ├── Style.java │ │ ├── tilesources │ │ ├── AbstractOsmTileSource.java │ │ ├── AbstractTileSource.java │ │ └── OsmTileSource.java │ │ ├── LayerGroup.java │ │ ├── Coordinate.java │ │ ├── TileController.java │ │ ├── MapRectangleImpl.java │ │ ├── AbstractLayer.java │ │ ├── MapPolygonImpl.java │ │ └── MapObjectImpl.java ├── convexhull │ ├── Comparator.java │ ├── ComparatorAdapter.java │ ├── CPoint.java │ ├── HullConverter.java │ └── Sort.java ├── Jama │ └── util │ │ └── Maths.java └── ternarysearchtree │ ├── CharUtility.java │ └── stylesheet.css ├── .gitignore ├── nbproject ├── genfiles.properties ├── project.xml └── project.properties └── ReadMe.txt /lib/jai_imageio.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/lib/jai_imageio.jar -------------------------------------------------------------------------------- /manifest.mf: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | X-COMMENT: Main-Class will be added automatically by build 3 | 4 | -------------------------------------------------------------------------------- /src/ika/geo/GeoPath.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/geo/GeoPath.java -------------------------------------------------------------------------------- /src/ika/icons/line1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/line1.gif -------------------------------------------------------------------------------- /src/ika/icons/line2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/line2.gif -------------------------------------------------------------------------------- /src/ika/icons/line3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/line3.gif -------------------------------------------------------------------------------- /src/ika/icons/line4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/line4.gif -------------------------------------------------------------------------------- /src/ika/icons/line5.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/line5.gif -------------------------------------------------------------------------------- /src/ika/icons/point1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/point1.gif -------------------------------------------------------------------------------- /src/ika/icons/point2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/point2.gif -------------------------------------------------------------------------------- /src/ika/icons/point3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/point3.gif -------------------------------------------------------------------------------- /src/ika/icons/point4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/point4.gif -------------------------------------------------------------------------------- /src/ika/icons/point5.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/point5.gif -------------------------------------------------------------------------------- /src/ika/icons/point6.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/point6.gif -------------------------------------------------------------------------------- /src/ika/icons/update.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/update.png -------------------------------------------------------------------------------- /src/ika/icons/update2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/update2.png -------------------------------------------------------------------------------- /src/ika/gui/MainWindow.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/gui/MainWindow.java -------------------------------------------------------------------------------- /src/ika/icons/Hand16x16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/Hand16x16.gif -------------------------------------------------------------------------------- /src/ika/icons/Hand32x32.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/Hand32x32.gif -------------------------------------------------------------------------------- /src/ika/icons/Pen16x16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/Pen16x16.gif -------------------------------------------------------------------------------- /src/ika/icons/Pen32x32.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/Pen32x32.gif -------------------------------------------------------------------------------- /src/ika/icons/logo32x32.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/logo32x32.gif -------------------------------------------------------------------------------- /src/ika/icons/logo48x48.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/logo48x48.gif -------------------------------------------------------------------------------- /src/ika/icons/Arrow16x16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/Arrow16x16.gif -------------------------------------------------------------------------------- /src/ika/icons/Black16x16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/Black16x16.gif -------------------------------------------------------------------------------- /src/ika/icons/Ruler16x16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/Ruler16x16.gif -------------------------------------------------------------------------------- /src/ika/icons/ShowAll16x16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/ShowAll16x16.gif -------------------------------------------------------------------------------- /src/ika/icons/ShowAll20x14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/ShowAll20x14.png -------------------------------------------------------------------------------- /src/ika/icons/ZoomIn16x16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/ZoomIn16x16.gif -------------------------------------------------------------------------------- /src/ika/icons/ZoomIn32x32.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/ZoomIn32x32.gif -------------------------------------------------------------------------------- /src/ika/icons/ZoomOut16x16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/ZoomOut16x16.gif -------------------------------------------------------------------------------- /src/ika/icons/ZoomOut32x32.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/ZoomOut32x32.gif -------------------------------------------------------------------------------- /src/ika/icons/logo128x128.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/logo128x128.gif -------------------------------------------------------------------------------- /src/ika/icons/MovePoint16x16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/MovePoint16x16.gif -------------------------------------------------------------------------------- /src/ika/icons/MovePoint32x32.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/MovePoint32x32.gif -------------------------------------------------------------------------------- /src/ika/icons/SetPoint16x16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/SetPoint16x16.gif -------------------------------------------------------------------------------- /src/ika/icons/SetPoint32x32.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/SetPoint32x32.gif -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.DS_Store 3 | 4 | *.class 5 | 6 | build/* 7 | dist/* 8 | mac/* 9 | win/* 10 | nbproject/private/* -------------------------------------------------------------------------------- /src/ika/icons/ClosedHand16x16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/ClosedHand16x16.gif -------------------------------------------------------------------------------- /src/ika/icons/ClosedHand32x32.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/ClosedHand32x32.gif -------------------------------------------------------------------------------- /src/ika/icons/SelectPoints16x16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/SelectPoints16x16.gif -------------------------------------------------------------------------------- /src/ika/icons/SelectPoints32x32.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/icons/SelectPoints32x32.gif -------------------------------------------------------------------------------- /src/ika/utils/NumberFormatter.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/utils/NumberFormatter.java -------------------------------------------------------------------------------- /src/ika/geoimport/ImageImporter.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/geoimport/ImageImporter.java -------------------------------------------------------------------------------- /src/ika/gui/CoordinateInfoPanel.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/gui/CoordinateInfoPanel.java -------------------------------------------------------------------------------- /src/ika/mapanalyst/MekenkampCircles.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/mapanalyst/MekenkampCircles.java -------------------------------------------------------------------------------- /src/ika/transformation/TransformationAffine6.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/transformation/TransformationAffine6.java -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/images/plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/org/openstreetmap/gui/jmapviewer/images/plus.png -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/images/error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/org/openstreetmap/gui/jmapviewer/images/error.png -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/images/minus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/org/openstreetmap/gui/jmapviewer/images/minus.png -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/images/bing_maps.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/org/openstreetmap/gui/jmapviewer/images/bing_maps.png -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/images/hourglass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/org/openstreetmap/gui/jmapviewer/images/hourglass.png -------------------------------------------------------------------------------- /src/ika/transformation/robustestimator/RobustEstimator.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/berniejenny/MapAnalyst/HEAD/src/ika/transformation/robustestimator/RobustEstimator.java -------------------------------------------------------------------------------- /src/convexhull/Comparator.java: -------------------------------------------------------------------------------- 1 | package convexhull; 2 | 3 | /** 4 | * This type was created in VisualAge. 5 | */ 6 | interface Comparator { 7 | public int compare(Object o1, Object o2); 8 | } -------------------------------------------------------------------------------- /src/ika/geo/Symbol.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Symbol.java 3 | * 4 | * Created on May 16, 2005, 12:37 PM 5 | */ 6 | 7 | package ika.geo; 8 | 9 | /** 10 | * 11 | * @author jenny 12 | */ 13 | public class Symbol implements java.io.Serializable { 14 | private static final long serialVersionUID = -7308893545390729292L; 15 | } 16 | -------------------------------------------------------------------------------- /src/convexhull/ComparatorAdapter.java: -------------------------------------------------------------------------------- 1 | package convexhull; 2 | 3 | /** 4 | * This type was created in VisualAge. 5 | */ 6 | public class ComparatorAdapter implements Comparator { 7 | /** 8 | * compare method comment. 9 | */ 10 | public int compare(Object o1, Object o2) { 11 | return 0; 12 | } 13 | } -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/interfaces/CachedTileLoader.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer.interfaces; 3 | 4 | /** 5 | * Interface that allow cleaning the tile cache without specifying exact type of loader 6 | */ 7 | public interface CachedTileLoader { 8 | void clearCache(TileSource source); 9 | } 10 | -------------------------------------------------------------------------------- /src/ika/map/tools/MapToolMouseMotionListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MapToolMouseMotionListener.java 3 | * 4 | * Created on May 15, 2005, 6:47 PM 5 | */ 6 | 7 | package ika.map.tools; 8 | 9 | import java.awt.geom.*; 10 | import ika.gui.MapComponent; 11 | 12 | /** 13 | * 14 | * @author jenny 15 | */ 16 | public interface MapToolMouseMotionListener { 17 | public void mouseMoved(Point2D.Double point, MapComponent mapComponent); 18 | } 19 | -------------------------------------------------------------------------------- /src/ika/map/tools/MapToolActionListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MapToolActionListener.java 3 | * 4 | * Created on August 28, 2005, 3:49 PM 5 | * 6 | */ 7 | 8 | package ika.map.tools; 9 | import ika.gui.*; 10 | 11 | /** 12 | * 13 | * @author jenny 14 | */ 15 | public interface MapToolActionListener { 16 | 17 | public void mapToolActionPerformed ( 18 | MapTool mapTool, 19 | MapComponent mapComponent, 20 | String description); 21 | } 22 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/interfaces/TileClearController.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer.interfaces; 3 | 4 | import java.io.File; 5 | 6 | public interface TileClearController { 7 | 8 | void initClearDir(File dir); 9 | 10 | void initClearFiles(File[] files); 11 | 12 | boolean cancel(); 13 | 14 | void fileDeleted(File file); 15 | 16 | void clearFinished(); 17 | } 18 | -------------------------------------------------------------------------------- /nbproject/genfiles.properties: -------------------------------------------------------------------------------- 1 | build.xml.data.CRC32=6c5f1163 2 | build.xml.script.CRC32=1f079ef9 3 | build.xml.stylesheet.CRC32=be360661 4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. 5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. 6 | nbproject/build-impl.xml.data.CRC32=9d7bc404 7 | nbproject/build-impl.xml.script.CRC32=1bc24562 8 | nbproject/build-impl.xml.stylesheet.CRC32=3a2fa800@1.89.1.48 9 | -------------------------------------------------------------------------------- /src/ika/geoexport/TableExporter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * TableExporter.java 3 | * 4 | * Created on April 13, 2007, 3:46 PM 5 | * 6 | */ 7 | 8 | package ika.geoexport; 9 | 10 | import java.io.IOException; 11 | import java.io.OutputStream; 12 | 13 | /** 14 | * 15 | * @author Bernhard Jenny, Institute of Cartography, ETH Zurich. 16 | */ 17 | public interface TableExporter { 18 | 19 | public void exportTable(OutputStream outputStream, Table table) 20 | throws IOException; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/Jama/util/Maths.java: -------------------------------------------------------------------------------- 1 | package Jama.util; 2 | 3 | public class Maths { 4 | 5 | /** sqrt(a^2 + b^2) without under/overflow. **/ 6 | 7 | public static double hypot(double a, double b) { 8 | double r; 9 | if (Math.abs(a) > Math.abs(b)) { 10 | r = b/a; 11 | r = Math.abs(a)*Math.sqrt(1+r*r); 12 | } else if (b != 0) { 13 | r = a/b; 14 | r = Math.abs(b)*Math.sqrt(1+r*r); 15 | } else { 16 | r = 0.0; 17 | } 18 | return r; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/ika/utils/NumericalUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * NumericalUtils.java 3 | * 4 | * Created on May 10, 2005, 3:21 PM 5 | */ 6 | 7 | package ika.utils; 8 | 9 | public class NumericalUtils { 10 | 11 | public static boolean numbersAreClose (double x, double y) { 12 | final double TOL = 0.000000001; 13 | return NumericalUtils.numbersAreClose (x, y, TOL); 14 | } 15 | public static boolean numbersAreClose (double x, double y, double tolerance) { 16 | return (Math.abs(x-y) < tolerance); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/interfaces/TemplatedTileSource.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer.interfaces; 3 | 4 | import java.util.Map; 5 | 6 | /** 7 | * Interface for template tile sources, @see TemplatedTMSTileSource 8 | * 9 | * @author Wiktor Niesiobędzki 10 | * @since 1.10 11 | */ 12 | public interface TemplatedTileSource extends TileSource { 13 | /** 14 | * 15 | * @return headers to be sent with http requests 16 | */ 17 | Map getHeaders(); 18 | } 19 | -------------------------------------------------------------------------------- /src/ika/gui/NumberFieldChecker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * NumberFieldChecker.java 3 | * 4 | * Created on September 15, 2005, 12:18 PM 5 | * 6 | * To change this template, choose Tools | Options and locate the template under 7 | * the Source Creation and Management node. Right-click the template and choose 8 | * Open. You can then make changes to the template in the Source Editor. 9 | */ 10 | 11 | package ika.gui; 12 | 13 | /** 14 | * 15 | * @author jenny 16 | */ 17 | public interface NumberFieldChecker { 18 | public abstract boolean testValue(NumberField numberField); 19 | } 20 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/interfaces/JMapViewerEventListener.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer.interfaces; 3 | 4 | import java.util.EventListener; 5 | 6 | import org.openstreetmap.gui.jmapviewer.events.JMVCommandEvent; 7 | 8 | /** 9 | * Must be implemented for processing commands while user 10 | * interacts with map viewer. 11 | * 12 | * @author Jason Huntley 13 | * 14 | */ 15 | public interface JMapViewerEventListener extends EventListener { 16 | void processCommand(JMVCommandEvent command); 17 | } 18 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/package.html: -------------------------------------------------------------------------------- 1 | 2 | org.openstreetmap.gui.jmapviewer 3 | 4 |

This package and all sub-packages are belonging to the Java 5 | component JMapViewer 6 |

7 |

JMapViewer is designed to run as stand-alone component without 8 | any further requirements. Therefore please do not add any code that 9 | depends on other libraries or applications. Only functions and methods 10 | provided by the runtime library of Java 8 should be used.

11 | 12 | 13 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/interfaces/IProjected.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer.interfaces; 3 | 4 | /** 5 | * Projected coordinates (east / north space). 6 | * 7 | * For most projections, one unit in projected space is roughly one meter, but 8 | * can also be degrees or feet. 9 | */ 10 | public interface IProjected { 11 | /** 12 | * Returns easting. 13 | * @return easting 14 | */ 15 | double getEast(); 16 | 17 | /** 18 | * Returns northing. 19 | * @return northing 20 | */ 21 | double getNorth(); 22 | } 23 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/interfaces/TileJob.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer.interfaces; 3 | 4 | /** 5 | * Interface for implementing a tile loading job. Tiles are usually loaded via HTTP 6 | * or from a file. 7 | * 8 | * @author Dirk Stöcker 9 | */ 10 | public interface TileJob extends Runnable { 11 | 12 | /** 13 | * submits download job to backend. 14 | */ 15 | void submit(); 16 | 17 | /** 18 | * submits download job to backend. 19 | * @param force true if the load should skip all the caches (local & remote) 20 | */ 21 | void submit(boolean force); 22 | } 23 | -------------------------------------------------------------------------------- /src/ika/geoexport/DisplayableTableColumn.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DisplayableTableColumn.java 3 | * 4 | * Created on June 15, 2006, 5:34 PM 5 | * 6 | */ 7 | 8 | package ika.geoexport; 9 | 10 | import javax.swing.table.TableColumn; 11 | /** 12 | * A TableColumn that overwrites toString to return the header value. 13 | * @author jenny 14 | */ 15 | public class DisplayableTableColumn extends TableColumn { 16 | 17 | /** 18 | * Creates a new instance of DisplayableTableColumn 19 | */ 20 | public DisplayableTableColumn(int modelIndex) { 21 | super(modelIndex); 22 | } 23 | 24 | public String toString() { 25 | return this.getHeaderValue().toString(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/ika/geo/GeoSetChangeListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MapChangeListener.java 3 | * 4 | * Created on March 5, 2005, 3:28 PM 5 | */ 6 | 7 | package ika.geo; 8 | 9 | /** 10 | * GeoSetChangeListener - a listener for change events triggered by GeoSets. 11 | * Whenever a GeoSet changes any of the GeoObjects that it contains, it calls 12 | * geoSetChanged to inform all its listeners. 13 | * @author Bernhard Jenny, Institute of Cartography, ETH Zurich. 14 | */ 15 | public interface GeoSetChangeListener { 16 | /** 17 | * geoSetChanged is called whenever the map changes. 18 | * @param geoSet The GeoSet that changed and triggered the call. 19 | */ 20 | public void geoSetChanged (GeoSet geoSet); 21 | } 22 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/interfaces/MapObject.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer.interfaces; 3 | 4 | import java.awt.Color; 5 | import java.awt.Font; 6 | import java.awt.Stroke; 7 | 8 | import org.openstreetmap.gui.jmapviewer.Layer; 9 | import org.openstreetmap.gui.jmapviewer.Style; 10 | 11 | public interface MapObject { 12 | 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(); 32 | } 33 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/interfaces/TileLoaderListener.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer.interfaces; 3 | 4 | import org.openstreetmap.gui.jmapviewer.Tile; 5 | 6 | /** 7 | * This listener listens to successful tile loads. 8 | */ 9 | @FunctionalInterface 10 | public interface TileLoaderListener { 11 | 12 | /** 13 | * Will be called if a new {@link Tile} has been loaded successfully. 14 | * Loaded can mean downloaded or loaded from file cache. 15 | * 16 | * @param tile The tile 17 | * @param success {@code true} if the tile has been loaded successfully, {@code false} otherwise 18 | */ 19 | void tileLoadingFinished(Tile tile, boolean success); 20 | } 21 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/interfaces/ICoordinate.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer.interfaces; 3 | 4 | /** 5 | * Latitude/Longitude coordinates. 6 | */ 7 | public interface ICoordinate { 8 | 9 | /** 10 | * Returns latitude. 11 | * @return latitude in degrees 12 | */ 13 | double getLat(); 14 | 15 | /** 16 | * Sets latitude. 17 | * @param lat latitude in degrees 18 | */ 19 | void setLat(double lat); 20 | 21 | /** 22 | * Returns longitude. 23 | * @return longitude in degrees 24 | */ 25 | double getLon(); 26 | 27 | /** 28 | * Sets longitude. 29 | * @param lon longitude in degrees 30 | */ 31 | void setLon(double lon); 32 | } 33 | -------------------------------------------------------------------------------- /src/ika/geo/GeoSetSelectionChangeController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GeoSetSelectionChangeController.java 3 | * 4 | * Created on May 14, 2005, 11:49 AM 5 | */ 6 | 7 | package ika.geo; 8 | 9 | /** 10 | * Before changing the selection state of any object, the parent GeoSet 11 | * asks its GeoSetSelectionChangeController for permission. 12 | * @author Bernhard Jenny, Institute of Cartography, ETH Zurich. 13 | */ 14 | public interface GeoSetSelectionChangeController { 15 | 16 | 17 | /** 18 | * Returns whether the selection state of any child can be changed. 19 | * @param geoSet The GeoSet that asks for permission to change the selection 20 | * state of a child. 21 | * @return True if the selection state can be changed, false otherwise. 22 | */ 23 | public boolean allowSelectionChange(GeoSet geoSet); 24 | } -------------------------------------------------------------------------------- /src/ika/geo/GeoSetSelectionChangeListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GeoSetSelectionChangeListener.java 3 | * 4 | * Created on June 6, 2005, 4:57 PM 5 | * 6 | */ 7 | 8 | package ika.geo; 9 | 10 | /** 11 | * GeoSetSelectionChangeListener - a listener for selection change events 12 | * triggered by GeoSets. 13 | * Whenever a GeoSet changes the selection of any of the GeoObjects that it 14 | * contains, it calls geoSetSelectionChanged to inform all its listeners. 15 | * @author Bernhard Jenny, Institute of Cartography, ETH Zurich. 16 | */ 17 | public interface GeoSetSelectionChangeListener { 18 | /** 19 | * geoSetSelectionChanged is called whenever the selection of an element 20 | * changes changes. 21 | * @param geoSet The parent GeoSet that changed the selection and triggered 22 | * the call. 23 | */ 24 | public void geoSetSelectionChanged (GeoSet geoSet); 25 | } 26 | 27 | -------------------------------------------------------------------------------- /src/ternarysearchtree/CharUtility.java: -------------------------------------------------------------------------------- 1 | package ternarysearchtree; 2 | // package com.wallyflint.util; 3 | // The package statement has been commented out so that every class can reside in the same package. This allows a java 1.1 demo applet to 4 | // run without throwing security exceptions. 5 | 6 | public class CharUtility { 7 | 8 | /** Returns an int value that is negative if cCompare comes before cRef in the alphabet, zero if 9 | * the two are equal, and positive if cCompare comes after cRef in the alphabet. 10 | */ 11 | public static int compareCharsAlphabetically(char cCompare, char cRef) { 12 | return (alphabetizeChar(cCompare) - alphabetizeChar(cRef)); 13 | } 14 | 15 | private static int alphabetizeChar(char c) { 16 | if(c < 65) return c; 17 | if(c < 89) return (2 * c) - 65; 18 | if(c < 97) return c + 24; 19 | if(c < 121) return (2 * c) - 128; 20 | return c; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/ika/map/tools/MeasureToolListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MeasureToolListener.java 3 | * 4 | * Created on April 22, 2005, 2:47 PM 5 | */ 6 | 7 | package ika.map.tools; 8 | 9 | import ika.gui.MapComponent; 10 | 11 | /** 12 | * MeasureToolListener - a listener for events generated by a MeasureTool. 13 | * @author Bernhard Jenny, Institute of Cartography, ETH Zurich. 14 | */ 15 | public interface MeasureToolListener { 16 | 17 | /** 18 | * The measure tool has been moved on the map. Update distance and angle. 19 | * @param x1 drag start x 20 | * @param y1 drag start y 21 | * @param x2 drag end x 22 | * @param y2 drag end y 23 | * @param mapComponent map 24 | */ 25 | void updateMeasureTool(double x1, double y1, double x2, double y2, MapComponent mapComponent); 26 | 27 | /** 28 | * The mouse has been released, the line is therefore not visible anymore 29 | * in the map. 30 | */ 31 | void clearDistance(); 32 | } 33 | -------------------------------------------------------------------------------- /src/ika/data/projections.txt: -------------------------------------------------------------------------------- 1 | // list projections by proj4 code in order of appearance in menu 2 | // only the proj4 code is used, the rest of the line is ignored 3 | // lines starting with two dashes are ignored 4 | apian1 Apian Globular I 5 | apian2 Apian Globular II 6 | bacon Bacon Globular 7 | bonne 8 | cass Cassini 9 | cea Cylindrical Equal-Area 10 | eqdc Equidistant Conic 11 | eqc Equidistant Cylindrical (Plate Carrée) 12 | euler 13 | four2 Fournier II 14 | // gnom Gnomonic Azimuthal buggy 15 | // lagrng Lagrange buggy 16 | lcc Lambert Conformal Conic 17 | laea Lambert Azimuthal Equal Area 18 | leac Lambert Equal Area Conic 19 | merc Mercator 20 | nicol Nicolosi Globular 21 | ortel Ortelius Oval 22 | // Ptolemy I (a combination of two equidistant conic projections), Snyder p. 10-14 23 | // Ptolemy II (pseudoconic), Snyder p. 10-14 24 | sinu Sinusoidal 25 | stere Stereographic Azimuthal 26 | tcea Transverse Cylindrical Equal Area 27 | // trapezoidal, see dissertation by D. Beineke for equations 28 | utm Transverse Mercator -------------------------------------------------------------------------------- /src/ika/geoexport/GeoSetExporter.java: -------------------------------------------------------------------------------- 1 | package ika.geoexport; 2 | 3 | import ika.geo.*; 4 | import ika.utils.FileUtils; 5 | import java.io.*; 6 | 7 | /** 8 | * 9 | * @author jenny 10 | */ 11 | abstract public class GeoSetExporter { 12 | 13 | protected double mapScale = 1; 14 | protected double flatness = 1; 15 | 16 | public GeoSetExporter(double mapScale) { 17 | this.mapScale = mapScale; 18 | } 19 | 20 | public void setPathFlatness(double flatness) { 21 | if (flatness <= 0.) { 22 | throw new IllegalArgumentException(); 23 | } 24 | this.flatness = flatness; 25 | } 26 | 27 | abstract protected void export(GeoSet geoSet, String filePath) throws IOException; 28 | 29 | abstract public String getFileExtension(); 30 | 31 | public void exportGeoSet(GeoSet geoSet, String filePath) throws IOException { 32 | filePath = FileUtils.forceFileNameExtension(filePath, getFileExtension()); 33 | this.export(geoSet, filePath); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /nbproject/project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.netbeans.modules.java.j2seproject 4 | 5 | 6 | MapAnalyst1_3 7 | 1.6.5 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | JMapProjLib 18 | jar 19 | 20 | jar 21 | clean 22 | jar 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/ika/gui/TransparentPanel.java: -------------------------------------------------------------------------------- 1 | package ika.gui; 2 | 3 | import ika.utils.Sys; 4 | import java.awt.LayoutManager; 5 | import javax.swing.JPanel; 6 | 7 | /** 8 | * Makes a JPanel transparent when on Mac OS X 10.5 or newer. This is needed for 9 | * panels in JTabbedPanes. 10 | * @author Bernhard Jenny, Institute of Cartography, ETH Zurich. 11 | */ 12 | public class TransparentPanel extends JPanel { 13 | 14 | private void conditionalTransparency() { 15 | if (Sys.isMacOSX_10_5_orHigherWithJava5()) { 16 | setOpaque(false); 17 | } 18 | } 19 | 20 | public TransparentPanel(LayoutManager layout, boolean isDoubleBuffered) { 21 | super(layout, isDoubleBuffered); 22 | conditionalTransparency(); 23 | } 24 | 25 | public TransparentPanel(LayoutManager layout) { 26 | super(layout); 27 | conditionalTransparency(); 28 | } 29 | 30 | public TransparentPanel(boolean isDoubleBuffered) { 31 | super(isDoubleBuffered); 32 | conditionalTransparency(); 33 | } 34 | 35 | public TransparentPanel() { 36 | conditionalTransparency(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /ReadMe.txt: -------------------------------------------------------------------------------- 1 | MapAnalyst 2 | 3 | This is the ReadMe file accompanying the free source code of MapAnalyst. 4 | Homepage: http://mapanalyst.org 5 | Source code: https://github.com/berniejenny/MapAnalyst 6 | 7 | MapAnalyst uses the following libraries: 8 | JMapProjLib for map projections: https://github.com/OSUCartography/JMapProjLib 9 | JMapViewer for OpenStreetMap loading and rendering: http://wiki.openstreetmap.org/wiki/JMapViewer 10 | JAMA Java Matrix Package: http://math.nist.gov/javanumerics/jama/ 11 | 12 | MapAnalyst comes as a NetBeans project. You can download the NetBeans IDE at http://www.netbeans.org 13 | 14 | Feel free to improve or extend MapAnalyst. Please let us know when you've made any changes, and e-mail us the improved source code or push your changes to GitHub. 15 | 16 | MapAnalyst is free software; you can distribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. MapAnalyst is Copyright 2005-2018 by Bernhard Jenny with contributions by Adrian Weber. 17 | 18 | Contact: 19 | Bernie Jenny 20 | Monash University, Melbourne, Australia 21 | bernie.jenny@monash.edu 22 | -------------------------------------------------------------------------------- /src/ika/geo/GeoControlPoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GeoControlPoint.java 3 | * 4 | * Created on May 13, 2005, 6:15 PM 5 | */ 6 | 7 | package ika.geo; 8 | 9 | import java.awt.geom.*; 10 | 11 | /** 12 | * 13 | */ 14 | public class GeoControlPoint extends GeoPoint{ 15 | 16 | private double destX = Double.NaN; 17 | private double destY = Double.NaN; 18 | 19 | /** 20 | * Create a new instance. 21 | * @param point The location of the point. 22 | * @param scaleInvariant Whether the point symbol should grow with the map 23 | * scale or not. 24 | */ 25 | public GeoControlPoint(Point2D point) { 26 | super (point, true); 27 | } 28 | 29 | public GeoControlPoint(double x, double y) { 30 | super (new Point2D.Double (x, y), true); 31 | } 32 | 33 | public double getDestX() { 34 | return destX; 35 | } 36 | 37 | public void setDestX(double destX) { 38 | this.destX = destX; 39 | } 40 | 41 | public double getDestY() { 42 | return destY; 43 | } 44 | 45 | public void setDestY(double destY) { 46 | this.destY = destY; 47 | } 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/events/JMVCommandEvent.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer.events; 3 | 4 | import java.util.EventObject; 5 | 6 | /** 7 | * Used for passing events between UI components and other 8 | * objects that register as a JMapViewerEventListener 9 | * 10 | * @author Jason Huntley 11 | * 12 | */ 13 | public class JMVCommandEvent extends EventObject { 14 | public enum COMMAND { 15 | MOVE, 16 | ZOOM 17 | } 18 | 19 | private COMMAND command; 20 | /** 21 | * 22 | */ 23 | private static final long serialVersionUID = 8701544867914969620L; 24 | 25 | public JMVCommandEvent(COMMAND cmd, Object source) { 26 | super(source); 27 | 28 | setCommand(cmd); 29 | } 30 | 31 | /** 32 | * @return the command 33 | */ 34 | public COMMAND getCommand() { 35 | return command; 36 | } 37 | 38 | /** 39 | * @param command the command to set 40 | */ 41 | public void setCommand(COMMAND command) { 42 | this.command = command; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/ika/map/tools/ZoomOutTool.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ZoomOutTool.java 3 | * 4 | * Created on April 8, 2005, 12:20 PM 5 | */ 6 | 7 | package ika.map.tools; 8 | 9 | import java.awt.*; 10 | import java.awt.geom.*; 11 | import java.awt.event.*; 12 | import ika.utils.*; 13 | import ika.gui.MapComponent; 14 | 15 | /** 16 | * ZoomOutTool - a MapTool to zoom out in a map. 17 | * @author Bernhard Jenny, Institute of Cartography, ETH Zurich. 18 | */ 19 | public class ZoomOutTool extends MapTool { 20 | 21 | /** 22 | * Creates a new instance of ZoomOutTool 23 | * @param mapComponent The MapComponent for which to zoom out. 24 | */ 25 | public ZoomOutTool(MapComponent mapComponent) { 26 | super (mapComponent); 27 | } 28 | 29 | /** 30 | * The mouse was clicked, while this MapTool was the active one. 31 | * @param point The location of the mouse in world coordinates. 32 | * @param evt The original event. 33 | */ 34 | public void mouseClicked (Point2D.Double point, MouseEvent evt) { 35 | mapComponent.zoomOut(point); 36 | } 37 | 38 | protected String getCursorName() { 39 | return "zoomout"; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/convexhull/CPoint.java: -------------------------------------------------------------------------------- 1 | package convexhull; 2 | 3 | /** 4 | * Type point. 5 | */ 6 | public class CPoint 7 | { 8 | /** X coordinate */ 9 | public float x; 10 | 11 | /** Y coordinate */ 12 | public float y; 13 | 14 | /** sets default coordinates to 0.0 */ 15 | public CPoint() 16 | { 17 | x = 0.0f; 18 | y = 0.0f; 19 | } 20 | 21 | /** sets coordinates as requested 22 | * 23 | * @param x new X coordinate 24 | * @param y new Y coordinate 25 | */ 26 | public CPoint(float x, float y) 27 | { 28 | this.x = x; 29 | this.y = y; 30 | } 31 | 32 | /** compares to another CPoint instance 33 | * 34 | * @param p2 35 | * - the other instance of CPoint 36 | * @return 37 | * - returns true if the two instances are the same points, 38 | * otherwise returns false 39 | */ 40 | public boolean isEqual(CPoint p2) 41 | { 42 | return (x == p2.x && y == p2.y); 43 | } 44 | 45 | /** converts the point coordinates to a string of format [x,y] 46 | * 47 | * @return String - string representation of the point 48 | */ 49 | public String toString() 50 | { 51 | return "[" + x + "," + y + "]"; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/interfaces/MapPolygon.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer.interfaces; 3 | 4 | import java.awt.Graphics; 5 | import java.awt.Point; 6 | import java.awt.Polygon; 7 | import java.util.List; 8 | 9 | /** 10 | * Interface to be implemented by polygons that can be displayed on the map. 11 | * 12 | * @author Vincent Privat 13 | */ 14 | public interface MapPolygon extends MapObject { 15 | 16 | /** 17 | * @return Latitude/Longitude of each point of polygon 18 | */ 19 | List getPoints(); 20 | 21 | /** 22 | * Paints the map polygon on the map. The points 23 | * are specifying the coordinates within g 24 | * 25 | * @param g graphics 26 | * @param points list of points defining the polygon to draw 27 | */ 28 | void paint(Graphics g, List points); 29 | 30 | /** 31 | * Paints the map polygon on the map. The polygon 32 | * is specifying the coordinates within g 33 | * 34 | * @param g graphics 35 | * @param polygon polygon to draw 36 | */ 37 | void paint(Graphics g, Polygon polygon); 38 | } 39 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/JMapController.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer; 3 | 4 | import java.awt.event.MouseListener; 5 | import java.awt.event.MouseMotionListener; 6 | import java.awt.event.MouseWheelListener; 7 | 8 | /** 9 | * Abstract base class for all mouse controller implementations. For 10 | * implementing your own controller create a class that derives from this one 11 | * and implements one or more of the following interfaces: 12 | * 17 | * 18 | * @author Jan Peter Stotz 19 | */ 20 | public abstract class JMapController { 21 | 22 | protected JMapViewer map; 23 | 24 | public JMapController(JMapViewer map) { 25 | this.map = map; 26 | if (this instanceof MouseListener) 27 | map.addMouseListener((MouseListener) this); 28 | if (this instanceof MouseWheelListener) 29 | map.addMouseWheelListener((MouseWheelListener) this); 30 | if (this instanceof MouseMotionListener) 31 | map.addMouseMotionListener((MouseMotionListener) this); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/ika/utils/CoordinateFormatter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CoordinateFormatter.java 3 | * 4 | * Created on August 12, 2005, 5:54 AM 5 | * 6 | */ 7 | package ika.utils; 8 | 9 | /** 10 | * 11 | * @author jenny 12 | */ 13 | public class CoordinateFormatter { 14 | 15 | /** 16 | * Coordinates are multiplied by scaleFactor before being converted to a 17 | * string. This scale factor can be used to transform between the global 18 | * mapping unit of the GeoObjects and the unit for displaying coordinates. 19 | * e.g. meter - centimeter -> scaleFactor = 100 20 | */ 21 | private double scaleFactor = 1.d; 22 | 23 | private final java.text.DecimalFormat decimalFormat; 24 | private final java.text.DecimalFormat shortDecimalFormat; 25 | 26 | public CoordinateFormatter(String format, String shortFormat, 27 | double scaleFactor) { 28 | decimalFormat = new java.text.DecimalFormat(format); 29 | shortDecimalFormat = new java.text.DecimalFormat(shortFormat); 30 | this.scaleFactor = scaleFactor; 31 | } 32 | 33 | public String format(double number) { 34 | return decimalFormat.format(number * scaleFactor); 35 | } 36 | 37 | public String formatShort(double number) { 38 | return shortDecimalFormat.format(number * scaleFactor); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/ika/utils/SwingThreadUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * SwingThreadUtils.java 3 | * 4 | * Created on December 3, 2006, 6:01 PM 5 | * 6 | */ 7 | 8 | package ika.utils; 9 | 10 | import java.lang.reflect.InvocationTargetException; 11 | import javax.swing.SwingUtilities; 12 | 13 | /** 14 | * 15 | * @author Bernhard Jenny, Institute of Cartography, ETH Zurich 16 | */ 17 | public class SwingThreadUtils { 18 | 19 | /** 20 | * A wrapper around SwingUtilities.invokeAndWait() that makes sure that 21 | * SwingUtilities.invokeAndWait() is only called when the current thread is 22 | * not the AWT event dispatching thread, as required by the documentation 23 | * of SwingUtilities.invokeAndWait(); plus catches exceptions thrown by 24 | * SwingUtilities.invokeAndWait(). 25 | * @param runnable The Runnable to call in the event dispatch thread. 26 | */ 27 | public static void invokeAndWait(Runnable runnable) { 28 | try { 29 | if (SwingUtilities.isEventDispatchThread()) 30 | runnable.run(); 31 | else 32 | SwingUtilities.invokeAndWait(runnable); 33 | } catch (InvocationTargetException ex) { 34 | ex.printStackTrace(); 35 | } catch (InterruptedException ex) { 36 | ex.printStackTrace(); 37 | } 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/ika/map/tools/PolygonTool.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PolygonTool.java 3 | * 4 | * Created on October 27, 2005, 12:02 PM 5 | * 6 | */ 7 | 8 | package ika.map.tools; 9 | 10 | import ika.gui.MapComponent; 11 | 12 | /** 13 | * Tool to draw GeoPaths 14 | * @author jenny 15 | */ 16 | public class PolygonTool extends PolygonToolBase { 17 | 18 | /** Creates a new instance of PolygonTool */ 19 | public PolygonTool(MapComponent mapComponent) { 20 | super(mapComponent); 21 | } 22 | 23 | /** 24 | * Finish drawing. Add the GeoPath to the map. 25 | */ 26 | protected void finishPath() { 27 | 28 | // add the GeoPath to the map. 29 | if (geoPath != null && geoPath.hasOneOrMoreSegments()) { 30 | //geoPath.setSelected(false); 31 | if (this.destinationGeoSet != null) 32 | this.destinationGeoSet.addGeoObject(geoPath); 33 | else 34 | this.mapComponent.addGeoObject(geoPath); 35 | } 36 | 37 | // inform MapToolActionListeners about action 38 | this.informMapToolActionListeners("Drawing"); 39 | 40 | // this will reset the GeoPath. So call this at the end of this method. 41 | super.finishPath(); 42 | } 43 | 44 | protected String getCursorName() { 45 | return "pen"; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/interfaces/MapRectangle.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer.interfaces; 3 | 4 | import java.awt.Graphics; 5 | import java.awt.Point; 6 | 7 | import org.openstreetmap.gui.jmapviewer.Coordinate; 8 | import org.openstreetmap.gui.jmapviewer.JMapViewer; 9 | 10 | /** 11 | * Interface to be implemented by rectangles that can be displayed on the map. 12 | * 13 | * @author Stefan Zeller 14 | * @see JMapViewer#addMapRectangle(MapRectangle) 15 | * @see JMapViewer#getMapRectangleList() 16 | */ 17 | public interface MapRectangle extends MapObject { 18 | 19 | /** 20 | * @return Latitude/Longitude of top left of rectangle 21 | */ 22 | Coordinate getTopLeft(); 23 | 24 | /** 25 | * @return Latitude/Longitude of bottom right of rectangle 26 | */ 27 | Coordinate getBottomRight(); 28 | 29 | /** 30 | * Paints the map rectangle on the map. The topLeft and 31 | * bottomRight are specifying the coordinates within g 32 | * 33 | * @param g graphics structure for painting 34 | * @param topLeft lop left edge of painting region 35 | * @param bottomRight bottom right edge of painting region 36 | */ 37 | void paint(Graphics g, Point topLeft, Point bottomRight); 38 | } 39 | -------------------------------------------------------------------------------- /src/ika/utils/ReferenceDistanceFormatter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * CoordinateFormatter.java 3 | * 4 | * Created on August 12, 2005, 5:54 AM 5 | * 6 | */ 7 | package ika.utils; 8 | 9 | import java.text.DecimalFormat; 10 | 11 | /** 12 | * Formatter for distances in meters or kilometers. 13 | * 14 | * @author Bernhard Jenny, Faculty of Information Technology, Monash University, 15 | * Melbourne, Australia 16 | */ 17 | public class ReferenceDistanceFormatter extends CoordinateFormatter { 18 | 19 | private static final double THRESHOLD_DIST = 100 * 1000; 20 | 21 | private final java.text.DecimalFormat kmFormat = new DecimalFormat("###,##0.000 km"); 22 | private final java.text.DecimalFormat shortKmFormat = new DecimalFormat("###,##0.### km"); 23 | 24 | public ReferenceDistanceFormatter() { 25 | super("###,##0.00 m", "###,##0.###", 1); 26 | } 27 | 28 | @Override 29 | public String format(double number) { 30 | if (number > THRESHOLD_DIST) { 31 | return kmFormat.format(number / 1000); 32 | } else { 33 | return super.format(number); 34 | } 35 | } 36 | 37 | @Override 38 | public String formatShort(double number) { 39 | if (number > THRESHOLD_DIST) { 40 | return shortKmFormat.format(number / 1000); 41 | } else { 42 | return super.formatShort(number); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/ternarysearchtree/stylesheet.css: -------------------------------------------------------------------------------- 1 | /* Javadoc style sheet */ 2 | 3 | /* Define colors, fonts and other style attributes here to override the defaults */ 4 | 5 | /* Page background color */ 6 | body { background-color: #FFFFFF } 7 | 8 | /* Table colors */ 9 | .TableHeadingColor { background: #CCCCFF } /* Dark mauve */ 10 | .TableSubHeadingColor { background: #EEEEFF } /* Light mauve */ 11 | .TableRowColor { background: #FFFFFF } /* White */ 12 | 13 | /* Font used in left-hand frame lists */ 14 | .FrameTitleFont { font-size: normal; font-family: normal } 15 | .FrameHeadingFont { font-size: normal; font-family: normal } 16 | .FrameItemFont { font-size: normal; font-family: normal } 17 | 18 | /* Example of smaller, sans-serif font in frames */ 19 | /* .FrameItemFont { font-size: 10pt; font-family: Helvetica, Arial, sans-serif } */ 20 | 21 | /* Navigation bar fonts and colors */ 22 | .NavBarCell1 { background-color:#EEEEFF;}/* Light mauve */ 23 | .NavBarCell1Rev { background-color:#00008B;}/* Dark Blue */ 24 | .NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;} 25 | .NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;} 26 | 27 | .NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} 28 | .NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} 29 | 30 | -------------------------------------------------------------------------------- /src/ika/utils/ColorUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ColorUtils.java 3 | * 4 | * Created on May 16, 2005, 8:47 PM 5 | */ 6 | 7 | package ika.utils; 8 | 9 | import java.awt.*; 10 | 11 | /** 12 | * Utility methods for color related stuff. 13 | * @author Bernhard Jenny, Institute of Cartography, ETH Zurich. 14 | */ 15 | public class ColorUtils { 16 | 17 | /** 18 | * Converts a Color to a CSS string of the format rgb(12,34,56) 19 | * @param color The color to convert. 20 | * @return The CSS string. 21 | */ 22 | public static String colorToCSSString(Color color) { 23 | StringBuffer str = new StringBuffer(); 24 | str.append("rgb("); 25 | str.append(color.getRed()); 26 | str.append(","); 27 | str.append(color.getGreen()); 28 | str.append(","); 29 | str.append(color.getBlue()); 30 | str.append(")"); 31 | return str.toString(); 32 | } 33 | 34 | /** 35 | * Returns a highlight-color that can be used to draw selected objects. 36 | * @return The color to use for selected objects. 37 | */ 38 | public static final java.awt.Color getSelectionColor() { 39 | return java.awt.Color.red; 40 | } 41 | 42 | /** 43 | * Returns a highlight-color that can be used to draw selected objects. 44 | * @return The color to use for selected objects. 45 | */ 46 | public static final java.awt.Color getHighlightColor() { 47 | return new java.awt.Color (75, 123, 181); 48 | } 49 | } -------------------------------------------------------------------------------- /src/convexhull/HullConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * HullConverter.java 3 | * 4 | * Created on July 10, 2005, 12:29 AM 5 | * 6 | */ 7 | 8 | package convexhull; 9 | 10 | import java.util.*; 11 | import ika.geo.*; 12 | 13 | /** 14 | * 15 | * @author jenny 16 | */ 17 | public class HullConverter { 18 | 19 | public static GeoPath hullArrayToGeoPath(Vector hull) { 20 | GeoPath hullPath = new GeoPath(); 21 | VectorSymbol symbol = new VectorSymbol(); 22 | symbol.setScaleInvariant(true); 23 | symbol.setStrokeWidth(3); 24 | symbol.setFilled(false); 25 | symbol.setStroked(true); 26 | hullPath.setVectorSymbol(symbol); 27 | 28 | convexhull.CPoint p = (convexhull.CPoint)hull.get(0); 29 | hullPath.moveTo(p.x, p.y); 30 | final int nbrPts = hull.size(); 31 | for (int i = 1; i < nbrPts; ++i) { 32 | p = (convexhull.CPoint)hull.get(i); 33 | hullPath.lineTo(p.x, p.y); 34 | } 35 | hullPath.closePath(); 36 | return hullPath; 37 | } 38 | 39 | public static double[][] hullArray(Vector hull) { 40 | final int nbrPts = hull.size(); 41 | double[][] a = new double [nbrPts+1][2]; 42 | for (int i = 0; i < nbrPts; ++i) { 43 | convexhull.CPoint p = (convexhull.CPoint)hull.get(i); 44 | a[i][0] = p.x; 45 | a[i][1] = p.y; 46 | } 47 | a[nbrPts][0] = a[0][0]; 48 | a[nbrPts][1] = a[0][1]; 49 | return a; 50 | } 51 | } -------------------------------------------------------------------------------- /src/ika/gui/MacWindowsManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MacWindowsManager.java 3 | * 4 | * Created on October 25, 2005, 12:09 PM 5 | * 6 | */ 7 | 8 | package ika.gui; 9 | 10 | import java.awt.*; 11 | 12 | /** 13 | * Mac OS X specific code. Integrates a Java application to the standard Mac 14 | * look and feel. 15 | * @author Bernhard Jenny, Institute of Cartography, ETH Zurich. 16 | */ 17 | public final class MacWindowsManager extends MainWindow { 18 | 19 | public static Frame emptyWindow; 20 | 21 | static void updateVisibilityOfEmptyWindow() { 22 | if (ika.utils.Sys.isMacOSX() && emptyWindow != null) { 23 | emptyWindow.setVisible(MainWindow.windows.isEmpty()); 24 | } 25 | } 26 | 27 | /** 28 | * Creates a new instance of MacWindowsManager 29 | */ 30 | public MacWindowsManager() { 31 | super("", false); 32 | 33 | // hide the window: make transparent, undecorate, move out of screen area. 34 | removeNotify(); // call this otherwise setUndecorated will fail. 35 | setUndecorated(true); 36 | setBackground(new Color(1.0F, 1.0F, 1.0F, 0.0F)); 37 | getContentPane().removeAll(); 38 | setFocusable(false); 39 | setLocation(0, 0); 40 | setSize(new Dimension(0, 0)); 41 | setResizable(false); 42 | getRootPane().putClientProperty("Window.style", "small"); 43 | getRootPane().putClientProperty("Window.alpha", new Float(0.0f)); 44 | setAlwaysOnTop(true); 45 | pack(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/checkBoxTree/CheckBoxNodeData.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer.checkBoxTree; 3 | 4 | import org.openstreetmap.gui.jmapviewer.AbstractLayer; 5 | import org.openstreetmap.gui.jmapviewer.LayerGroup; 6 | 7 | /** 8 | * Node Data for checkBox Tree 9 | * 10 | * @author galo 11 | */ 12 | public class CheckBoxNodeData { 13 | private AbstractLayer layer; 14 | 15 | public CheckBoxNodeData(final AbstractLayer layer) { 16 | this.layer = layer; 17 | } 18 | 19 | public CheckBoxNodeData(final String txt) { 20 | this(new LayerGroup(txt)); 21 | } 22 | 23 | public CheckBoxNodeData(final String txt, final Boolean selected) { 24 | this(new LayerGroup(txt)); 25 | layer.setVisible(selected); 26 | } 27 | 28 | public Boolean isSelected() { 29 | return layer.isVisible(); 30 | } 31 | 32 | public void setSelected(final Boolean newValue) { 33 | layer.setVisible(newValue); 34 | } 35 | 36 | public String getText() { 37 | return layer.getName(); 38 | } 39 | 40 | public AbstractLayer getAbstractLayer() { 41 | return layer; 42 | } 43 | 44 | public void setAbstractLayer(final AbstractLayer layer) { 45 | this.layer = layer; 46 | } 47 | 48 | @Override 49 | public String toString() { 50 | return getClass().getSimpleName() + '[' + getText() + '/' + isSelected() + ']'; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/Layer.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer; 3 | 4 | import java.util.List; 5 | 6 | import org.openstreetmap.gui.jmapviewer.interfaces.MapObject; 7 | 8 | public class Layer extends AbstractLayer { 9 | private List elements; 10 | 11 | public Layer(String name) { 12 | super(name); 13 | } 14 | 15 | public Layer(String name, String description) { 16 | super(name, description); 17 | } 18 | 19 | public Layer(String name, Style style) { 20 | super(name, style); 21 | } 22 | 23 | public Layer(String name, String description, Style style) { 24 | super(name, description, style); 25 | } 26 | 27 | public Layer(LayerGroup parent, String name) { 28 | super(parent, name); 29 | } 30 | 31 | public Layer(LayerGroup parent, String name, Style style) { 32 | super(parent, name, style); 33 | } 34 | 35 | public Layer(LayerGroup parent, String name, String description, Style style) { 36 | super(parent, name, description, style); 37 | } 38 | 39 | public List getElements() { 40 | return elements; 41 | } 42 | 43 | public void setElements(List elements) { 44 | this.elements = elements; 45 | } 46 | 47 | public Layer add(MapObject element) { 48 | element.setLayer(this); 49 | elements = add(elements, element); 50 | return this; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/TileXY.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer; 3 | 4 | /** 5 | * @author w 6 | * 7 | */ 8 | public class TileXY { 9 | /** 10 | * x index of the tile (horizontal) 11 | */ 12 | private final double x; 13 | 14 | /** 15 | * y number of the tile (vertical) 16 | */ 17 | private final double y; 18 | 19 | /** 20 | * Returns an instance of coordinates. 21 | * 22 | * @param x number of the tile 23 | * @param y number of the tile 24 | */ 25 | public TileXY(double x, double y) { 26 | this.x = x; 27 | this.y = y; 28 | } 29 | 30 | /** 31 | * @return x index of the tile as integer 32 | */ 33 | public int getXIndex() { 34 | return x < 0 ? (int) Math.ceil(x) : (int) Math.floor(x); 35 | } 36 | 37 | /** 38 | * @return y index of the tile as integer 39 | */ 40 | public int getYIndex() { 41 | return y < 0 ? (int) Math.ceil(y) : (int) Math.floor(y); 42 | } 43 | 44 | /** 45 | * @return x index as double, might be non integral, when the point is not topleft corner of the tile 46 | */ 47 | public double getX() { 48 | return x; 49 | } 50 | 51 | /** 52 | * @return y index as double, might be non integral, when the point is not topleft corner of the tile 53 | */ 54 | public double getY() { 55 | return y; 56 | } 57 | 58 | @Override 59 | public String toString() { 60 | return "TileXY{" + x + ", " + y + "}"; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/interfaces/TileLoader.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer.interfaces; 3 | 4 | import org.openstreetmap.gui.jmapviewer.Tile; 5 | 6 | /** 7 | * Interface for implementing a tile loader. Tiles are usually loaded via HTTP 8 | * or from a file. 9 | * 10 | * @author Jan Peter Stotz 11 | */ 12 | public interface TileLoader { 13 | 14 | /** 15 | * A typical implementation of this function should create and return a 16 | * new {@link TileJob} instance that performs the load action. 17 | * 18 | * @param tile the tile to be loaded 19 | * @return {@link TileJob} implementation that performs the desired load 20 | * action. 21 | */ 22 | TileJob createTileLoaderJob(Tile tile); 23 | 24 | /** 25 | * cancels all outstanding tasks in the queue. This should rollback the state of the tiles in the queue 26 | * to loading = false / loaded = false 27 | */ 28 | void cancelOutstandingTasks(); 29 | 30 | /** 31 | * Determines whether this {@link TileLoader} has tasks which have not completed. 32 | * @return whether this {@link TileLoader} has tasks which have not completed. This answer may well be 33 | * "approximate" given that many implementations will be using mechanisms where a queue's state can change 34 | * during the computation. 35 | */ 36 | default boolean hasOutstandingTasks() { 37 | // default implementation supplied just to make transition easier for external implementors 38 | throw new UnsupportedOperationException("Not implemented"); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/TileRange.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer; 3 | 4 | /** 5 | * This is a rectangular range of tiles. 6 | */ 7 | public class TileRange { 8 | protected int minX; 9 | protected int maxX; 10 | protected int minY; 11 | protected int maxY; 12 | protected int zoom; 13 | 14 | protected TileRange() { 15 | } 16 | 17 | /** 18 | * Constructs a new {@code TileRange}. 19 | * @param t1 first tile 20 | * @param t2 second tile 21 | * @param zoom zoom level 22 | */ 23 | public TileRange(TileXY t1, TileXY t2, int zoom) { 24 | minX = (int) Math.floor(Math.min(t1.getX(), t2.getX())); 25 | minY = (int) Math.floor(Math.min(t1.getY(), t2.getY())); 26 | maxX = (int) Math.ceil(Math.max(t1.getX(), t2.getX())); 27 | maxY = (int) Math.ceil(Math.max(t1.getY(), t2.getY())); 28 | this.zoom = zoom; 29 | } 30 | 31 | /** 32 | * Constructs a new {@code TileRange}. 33 | * @param r existing tile range to copy 34 | */ 35 | public TileRange(TileRange r) { 36 | minX = r.minX; 37 | minY = r.minY; 38 | maxX = r.maxX; 39 | maxY = r.maxY; 40 | zoom = r.zoom; 41 | } 42 | 43 | protected double tilesSpanned() { 44 | return Math.sqrt(1.0 * this.size()); 45 | } 46 | 47 | /** 48 | * Returns size 49 | * @return size 50 | */ 51 | public int size() { 52 | int xSpan = maxX - minX + 1; 53 | int ySpan = maxY - minY + 1; 54 | return xSpan * ySpan; 55 | } 56 | } 57 | 58 | -------------------------------------------------------------------------------- /src/ika/gui/ImageReferencerDialog.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/checkBoxTree/CheckBoxNodePanel.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer.checkBoxTree; 3 | 4 | import java.awt.BorderLayout; 5 | import java.awt.Insets; 6 | 7 | import javax.swing.JCheckBox; 8 | import javax.swing.JLabel; 9 | import javax.swing.JPanel; 10 | 11 | /** 12 | * Node Panel for checkBox Tree 13 | * 14 | * @author galo 15 | */ 16 | public class CheckBoxNodePanel extends JPanel { 17 | /** Serial Version UID */ 18 | private static final long serialVersionUID = -7236481597785619029L; 19 | private final JLabel label = new JLabel(); 20 | private CheckBoxNodeData data; 21 | public final JCheckBox check = new JCheckBox(); 22 | 23 | public CheckBoxNodePanel() { 24 | this.check.setMargin(new Insets(0, 0, 0, 0)); 25 | setLayout(new BorderLayout()); 26 | add(check, BorderLayout.WEST); 27 | add(label, BorderLayout.CENTER); 28 | } 29 | 30 | public void setSelected(Boolean bool) { 31 | if (bool == null) { 32 | check.getModel().setPressed(true); 33 | check.getModel().setArmed(true); 34 | } else { 35 | check.setSelected(bool.booleanValue()); 36 | check.getModel().setArmed(false); 37 | } 38 | } 39 | 40 | public CheckBoxNodeData getData() { 41 | data.setSelected(check.isSelected()); 42 | return data; 43 | } 44 | 45 | public void setData(CheckBoxNodeData data) { 46 | this.data = data; 47 | label.setText(data.getText()); 48 | } 49 | 50 | public JLabel getLabel() { 51 | return label; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/interfaces/MapMarker.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer.interfaces; 3 | 4 | import java.awt.Graphics; 5 | import java.awt.Point; 6 | 7 | import org.openstreetmap.gui.jmapviewer.Coordinate; 8 | import org.openstreetmap.gui.jmapviewer.JMapViewer; 9 | 10 | /** 11 | * Interface to be implemented by all one dimensional elements that can be displayed on the map. 12 | * 13 | * @author Jan Peter Stotz 14 | * @see JMapViewer#addMapMarker(MapMarker) 15 | * @see JMapViewer#getMapMarkerList() 16 | */ 17 | public interface MapMarker extends MapObject, ICoordinate { 18 | 19 | enum STYLE { 20 | FIXED, 21 | VARIABLE 22 | } 23 | 24 | /** 25 | * @return Latitude and Longitude of the map marker position 26 | */ 27 | Coordinate getCoordinate(); 28 | 29 | /** 30 | * @return Latitude of the map marker position 31 | */ 32 | @Override 33 | double getLat(); 34 | 35 | /** 36 | * @return Longitude of the map marker position 37 | */ 38 | @Override 39 | double getLon(); 40 | 41 | /** 42 | * @return Radius of the map marker position 43 | */ 44 | double getRadius(); 45 | 46 | /** 47 | * @return Style of the map marker 48 | */ 49 | STYLE getMarkerStyle(); 50 | 51 | /** 52 | * Paints the map marker on the map. The position specifies the 53 | * coordinates within g 54 | * 55 | * @param g graphics 56 | * @param position coordinates 57 | * @param radius radius 58 | */ 59 | void paint(Graphics g, Point position, int radius); 60 | } 61 | -------------------------------------------------------------------------------- /src/ika/geoexport/ESRIASCIIGridExporter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ESRIASCIIGridExporter.java 3 | * 4 | * Created on August 14, 2005, 4:17 PM 5 | * 6 | */ 7 | 8 | package ika.geoexport; 9 | 10 | import ika.geo.*; 11 | import java.io.*; 12 | 13 | /** 14 | * 15 | * @author jenny 16 | */ 17 | public class ESRIASCIIGridExporter { 18 | 19 | /** Creates a new instance of ESRIASCIIGridExporter */ 20 | public ESRIASCIIGridExporter() { 21 | } 22 | 23 | public void export(GeoGrid geoGrid, String filePath) 24 | throws java.io.IOException { 25 | 26 | PrintWriter writer = new PrintWriter(new BufferedWriter( 27 | new FileWriter(filePath))); 28 | 29 | String lineSeparator = System.getProperty("line.separator"); 30 | writer.write("ncols " + geoGrid.getCols() + lineSeparator); 31 | writer.write("nrows " + geoGrid.getRows() + lineSeparator); 32 | writer.write("xllcorner " + geoGrid.getWest() + lineSeparator); 33 | writer.write("yllcorner" + geoGrid.getSouth() + lineSeparator); 34 | writer.write("cellsize " + geoGrid.getMeshSize() + lineSeparator); 35 | writer.write("nodata_value " + Float.MIN_VALUE + lineSeparator); 36 | float[][] grid = geoGrid.getGrid(); 37 | for (int r = 0; r < grid.length; ++r) { 38 | for (int c = 0; c < grid[0].length; ++c) { 39 | float v = grid[r][c]; 40 | // A "NaN" value is not equal to itself. So use isNan(). 41 | if (Float.isNaN(v)) { 42 | v = Float.MIN_VALUE; 43 | } 44 | writer.write(Float.toString(v)); 45 | writer.write (" "); 46 | } 47 | writer.write (lineSeparator); 48 | } 49 | writer.close(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/interfaces/Attributed.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer.interfaces; 3 | 4 | import java.awt.Image; 5 | 6 | public interface Attributed { 7 | /** 8 | * @return True if the tile source requires attribution in text or image form. 9 | */ 10 | boolean requiresAttribution(); 11 | 12 | /** 13 | * @param zoom The optional zoom level for the view. 14 | * @param botRight The bottom right of the bounding box for attribution. 15 | * @param topLeft The top left of the bounding box for attribution. 16 | * @return Attribution text for the image source. 17 | */ 18 | String getAttributionText(int zoom, ICoordinate topLeft, ICoordinate botRight); 19 | 20 | /** 21 | * @return The URL to open when the user clicks the attribution text. 22 | */ 23 | String getAttributionLinkURL(); 24 | 25 | /** 26 | * @return The URL for the attribution image. Null if no image should be displayed. 27 | */ 28 | Image getAttributionImage(); 29 | 30 | /** 31 | * @return The URL to open when the user clicks the attribution image. 32 | * When return value is null, the image is still displayed (provided getAttributionImage() 33 | * returns a value other than null), but the image does not link to a website. 34 | */ 35 | String getAttributionImageURL(); 36 | 37 | /** 38 | * @return The attribution "Terms of Use" text. 39 | * In case it returns null, but getTermsOfUseURL() is not null, a default 40 | * terms of use text is used. 41 | */ 42 | String getTermsOfUseText(); 43 | 44 | /** 45 | * @return The URL to open when the user clicks the attribution "Terms of Use" text. 46 | */ 47 | String getTermsOfUseURL(); 48 | } 49 | -------------------------------------------------------------------------------- /src/ika/geoimport/PointImporter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PointImporter.java 3 | * 4 | * Created on June 29, 2005, 4:28 PM 5 | * 6 | */ 7 | 8 | package ika.geoimport; 9 | 10 | import java.io.*; 11 | import ika.geo.*; 12 | import java.awt.Component; 13 | import java.util.*; 14 | 15 | 16 | /** 17 | * 18 | * @author jenny 19 | */ 20 | public class PointImporter { 21 | 22 | /** 23 | * Reads an ASCII file with points. 24 | * @param filePath path to the file. 25 | */ 26 | public static GeoSet importPoints (String filePath, Component parentComponent) { 27 | 28 | GeoSet geoSet = new GeoSet(); 29 | 30 | BufferedReader in = null; 31 | try { 32 | in = new BufferedReader(new FileReader(filePath)); 33 | String str; 34 | while ((str = in.readLine()) != null) { 35 | StringTokenizer tokenizer = new StringTokenizer(str, " \t,;"); 36 | String name = (String)tokenizer.nextToken(); 37 | double x = Double.parseDouble((String)tokenizer.nextToken()); 38 | double y = Double.parseDouble((String)tokenizer.nextToken()); 39 | 40 | GeoPoint point = new GeoPoint(x, y); 41 | point.setName (name); 42 | geoSet.addGeoObject(point); 43 | } 44 | } catch (Exception e) { 45 | String msg = "The points could not be imported.\n" + e.toString(); 46 | javax.swing.JOptionPane.showMessageDialog(parentComponent, msg, 47 | "Import Error", javax.swing.JOptionPane.ERROR_MESSAGE); 48 | } finally { 49 | if (in != null) 50 | try { 51 | in.close(); 52 | } catch (Exception e) { 53 | } 54 | } 55 | return geoSet; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/interfaces/TileCache.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer.interfaces; 3 | 4 | import org.openstreetmap.gui.jmapviewer.JMapViewer; 5 | import org.openstreetmap.gui.jmapviewer.Tile; 6 | 7 | /** 8 | * Implement this interface for creating your custom tile cache for 9 | * {@link JMapViewer}. 10 | * 11 | * @author Jan Peter Stotz 12 | */ 13 | public interface TileCache { 14 | 15 | /** 16 | * Retrieves a tile from the cache if present, otherwise null 17 | * will be returned. 18 | * 19 | * @param source 20 | * the tile source 21 | * @param x 22 | * tile number on the x axis of the tile to be retrieved 23 | * @param y 24 | * tile number on the y axis of the tile to be retrieved 25 | * @param z 26 | * zoom level of the tile to be retrieved 27 | * @return the requested tile or null if the tile is not 28 | * present in the cache 29 | */ 30 | Tile getTile(TileSource source, int x, int y, int z); 31 | 32 | /** 33 | * Adds a tile to the cache. How long after adding a tile can be retrieved 34 | * via {@link #getTile(TileSource, int, int, int)} is unspecified and depends on the 35 | * implementation. 36 | * 37 | * @param tile the tile to be added 38 | */ 39 | void addTile(Tile tile); 40 | 41 | /** 42 | * @return the number of tiles hold by the cache 43 | */ 44 | int getTileCount(); 45 | 46 | /** 47 | * Clears the cache deleting all tiles from memory. 48 | */ 49 | void clear(); 50 | 51 | /** 52 | * Size of the cache. 53 | * @return maximum number of tiles in cache 54 | */ 55 | int getCacheSize(); 56 | } 57 | -------------------------------------------------------------------------------- /src/convexhull/Sort.java: -------------------------------------------------------------------------------- 1 | package convexhull; 2 | 3 | import java.util.*; 4 | public class Sort 5 | { 6 | public static void quick(Vector objs, Comparator c) 7 | { 8 | quickSort(objs, 0, objs.size() - 1, c); 9 | } 10 | /** 11 | * This method was created in VisualAge. 12 | * @param o java.lang.Object[] 13 | * @param lo int 14 | * @param hi int 15 | * @param c Comparator 16 | */ 17 | private static void quickSort(Vector objs, int lo0, int hi0, Comparator c) 18 | { 19 | int lo = lo0; 20 | int hi = hi0; 21 | Object mid; 22 | if (hi0 > lo0) 23 | { 24 | // pick the medium value 25 | mid = objs.elementAt((lo0 + hi0) / 2); 26 | 27 | // loop through the array until indices cross 28 | while (lo <= hi) 29 | { 30 | // find the first element that is greater than or equal to 31 | // the partition element starting from the left Index. 32 | // 33 | // Nasty to have to cast here. Would it be quicker 34 | // to copy the vectors into arrays and sort the arrays? 35 | while ((lo < hi0) && (c.compare(objs.elementAt(lo), mid) == 1)) 36 | { 37 | ++lo; 38 | } 39 | 40 | // find an element that is smaller than or equal to 41 | // the partition element starting from the right Index. 42 | while ((hi > lo0) && (c.compare(mid, objs.elementAt(hi)) == 1)) 43 | { 44 | --hi; 45 | } 46 | 47 | // if the indexes have not crossed, swap 48 | if (lo <= hi) 49 | { 50 | Object tmp = objs.elementAt(lo); 51 | objs.setElementAt(objs.elementAt(hi), lo); 52 | objs.setElementAt(tmp, hi); 53 | ++lo; 54 | --hi; 55 | } 56 | } 57 | 58 | // If the right index has not reached the left side of array 59 | // must now sort the left partition. 60 | if (lo0 < hi) 61 | quickSort(objs, lo0, hi, c); 62 | 63 | // If the left index has not reached the right side of array 64 | // must now sort the right partition. 65 | if (lo < hi0) 66 | quickSort(objs, lo, hi0, c); 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /src/ika/geoexport/ImageExporter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ImageExporter.java 3 | * 4 | * Created on May 13, 2005, 6:47 PM 5 | */ 6 | 7 | package ika.geoexport; 8 | 9 | import ika.geo.*; 10 | import java.io.*; 11 | import java.awt.image.*; 12 | import javax.imageio.*; 13 | import ika.utils.*; 14 | 15 | /** 16 | * 17 | * @author jenny 18 | */ 19 | public class ImageExporter { 20 | 21 | public static void exportGeoImage(GeoImage geoImage, String filePath) 22 | throws IOException { 23 | if (filePath == null || geoImage == null) 24 | return; 25 | filePath = FileUtils.forceFileNameExtension(filePath, "jpg"); 26 | File file = new File(filePath); 27 | 28 | BufferedImage image = geoImage.getBufferedImage(); 29 | BufferedImage exportImage = new BufferedImage(image.getWidth(), 30 | image.getHeight(), BufferedImage.TYPE_INT_RGB); 31 | // draw the passed image into the exportImage 32 | exportImage.getGraphics().drawImage(image, 0, 0, null); 33 | 34 | ImageIO.write(exportImage, "jpeg", file); 35 | 36 | String worldFilePath = ImageExporter.constructWorldFilePath(filePath); 37 | ImageExporter.writeWorldFile(worldFilePath, geoImage); 38 | } 39 | 40 | private static String constructWorldFilePath(String imageFilePath) { 41 | return FileUtils.replaceExtension(imageFilePath, "jgw"); 42 | } 43 | 44 | private static void writeWorldFile(String worldFilePath, GeoImage geoImage) 45 | throws IOException{ 46 | 47 | try (PrintWriter writer = new PrintWriter(new BufferedWriter( 48 | new FileWriter(worldFilePath)))) { 49 | writer.println(geoImage.getPixelSizeX()); 50 | writer.println(0); 51 | writer.println(0); 52 | writer.println(-geoImage.getPixelSizeY()); 53 | writer.println(geoImage.getX()); 54 | writer.println(geoImage.getY()); 55 | } 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/MapMarkerDot.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer; 3 | 4 | import java.awt.Color; 5 | 6 | import org.openstreetmap.gui.jmapviewer.interfaces.MapMarker; 7 | 8 | /** 9 | * A simple implementation of the {@link MapMarker} interface. Each map marker 10 | * is painted as a circle with a black border line and filled with a specified 11 | * color. 12 | * 13 | * @author Jan Peter Stotz 14 | * 15 | */ 16 | public class MapMarkerDot extends MapMarkerCircle { 17 | 18 | public static final int DOT_RADIUS = 5; 19 | 20 | public MapMarkerDot(Coordinate coord) { 21 | this(null, null, coord); 22 | } 23 | 24 | public MapMarkerDot(String name, Coordinate coord) { 25 | this(null, name, coord); 26 | } 27 | 28 | public MapMarkerDot(Layer layer, Coordinate coord) { 29 | this(layer, null, coord); 30 | } 31 | 32 | public MapMarkerDot(Layer layer, String name, Coordinate coord) { 33 | this(layer, name, coord, getDefaultStyle()); 34 | } 35 | 36 | public MapMarkerDot(Color color, double lat, double lon) { 37 | this(null, null, lat, lon); 38 | setColor(color); 39 | } 40 | 41 | public MapMarkerDot(double lat, double lon) { 42 | this(null, null, lat, lon); 43 | } 44 | 45 | public MapMarkerDot(Layer layer, double lat, double lon) { 46 | this(layer, null, lat, lon); 47 | } 48 | 49 | public MapMarkerDot(Layer layer, String name, double lat, double lon) { 50 | this(layer, name, new Coordinate(lat, lon), getDefaultStyle()); 51 | } 52 | 53 | public MapMarkerDot(Layer layer, String name, Coordinate coord, Style style) { 54 | super(layer, name, coord, DOT_RADIUS, STYLE.FIXED, style); 55 | } 56 | 57 | public static Style getDefaultStyle() { 58 | return new Style(Color.BLACK, Color.YELLOW, null, getDefaultFont()); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/ika/map/tools/SingleSelectionPointSetterTool.java: -------------------------------------------------------------------------------- 1 | /* 2 | * SingleSelectionPointSetterTool.java 3 | * 4 | * Created on June 30, 2005, 9:48 AM 5 | * 6 | */ 7 | 8 | package ika.map.tools; 9 | 10 | import ika.gui.*; 11 | import ika.geo.*; 12 | import java.awt.geom.*; 13 | import java.awt.event.*; 14 | 15 | /** 16 | * SingleSelectionPointSetterTool extends PointSetterTool and allows for a new 17 | * point to be set only when the currently selected point can first be deselected. 18 | * @author jenny 19 | */ 20 | public class SingleSelectionPointSetterTool extends PointSetterTool { 21 | 22 | /** 23 | * Create a new instance. 24 | * @param mapComponent The MapComponent for which this MapTool provides its services. 25 | * @param destinationGeoSet The GeoSet that will receive the newly created points. 26 | */ 27 | public SingleSelectionPointSetterTool(MapComponent mapComponent) { 28 | super(mapComponent); 29 | } 30 | 31 | /** 32 | * Create a new instance. 33 | * @param mapComponent The MapComponent for which this MapTool provides its services. 34 | * @param destinationGeoSet The GeoSet that will receive the newly created points. 35 | * @param pointSymbol The PointSymbol used to draw newly created points. 36 | */ 37 | public SingleSelectionPointSetterTool(MapComponent mapComponent, 38 | PointSymbol pointSymbol) { 39 | super(mapComponent, pointSymbol); 40 | } 41 | 42 | /** 43 | * The mouse was clicked, while this MapTool was the active one. 44 | * @param point The location of the mouse in world coordinates. 45 | * @param evt The original event. 46 | */ 47 | public void mouseClicked(Point2D.Double point, MouseEvent evt) { 48 | if (this.getDestinationGeoSet() == null) 49 | return; 50 | 51 | // test if the currently selected point can be deselected. 52 | if (this.getDestinationGeoSet().canChangeSelectionOfChildren()) 53 | super.mouseClicked(point, evt); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/Projected.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer; 3 | 4 | import java.awt.geom.Point2D; 5 | import java.io.IOException; 6 | import java.io.ObjectInputStream; 7 | import java.io.ObjectOutputStream; 8 | import java.util.Objects; 9 | 10 | import org.openstreetmap.gui.jmapviewer.interfaces.IProjected; 11 | 12 | /** 13 | * Projected coordinates represented by an encapsulates a Point2D.Double value. 14 | */ 15 | public class Projected implements IProjected { 16 | private transient Point2D.Double data; 17 | 18 | /** 19 | * Constructs a new {@code Projected}. 20 | * @param east easting 21 | * @param north northing 22 | */ 23 | public Projected(double east, double north) { 24 | data = new Point2D.Double(east, north); 25 | } 26 | 27 | @Override 28 | public double getEast() { 29 | return data.x; 30 | } 31 | 32 | @Override 33 | public double getNorth() { 34 | return data.y; 35 | } 36 | 37 | private void writeObject(ObjectOutputStream out) throws IOException { 38 | out.writeObject(data.x); 39 | out.writeObject(data.y); 40 | } 41 | 42 | private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { 43 | data = new Point2D.Double(); 44 | data.x = (Double) in.readObject(); 45 | data.y = (Double) in.readObject(); 46 | } 47 | 48 | @Override 49 | public String toString() { 50 | return "Projected[" + data.y + ", " + data.x + ']'; 51 | } 52 | 53 | @Override 54 | public int hashCode() { 55 | return Objects.hashCode(data); 56 | } 57 | 58 | @Override 59 | public boolean equals(Object obj) { 60 | if (this == obj) 61 | return true; 62 | if (obj == null || !(obj instanceof Projected)) 63 | return false; 64 | final Projected other = (Projected) obj; 65 | return Objects.equals(data, other.data); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/Style.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer; 3 | 4 | import java.awt.AlphaComposite; 5 | import java.awt.Color; 6 | import java.awt.Font; 7 | import java.awt.Stroke; 8 | 9 | public class Style { 10 | private Color color; 11 | private Color backColor; 12 | private Stroke stroke; 13 | private Font font; 14 | 15 | private static final AlphaComposite TRANSPARENCY = AlphaComposite.getInstance(AlphaComposite.SRC_OVER); 16 | private static final AlphaComposite OPAQUE = AlphaComposite.getInstance(AlphaComposite.SRC); 17 | 18 | public Style() { 19 | super(); 20 | } 21 | 22 | public Style(Color color, Color backColor, Stroke stroke, Font font) { 23 | super(); 24 | this.color = color; 25 | this.backColor = backColor; 26 | this.stroke = stroke; 27 | this.font = font; 28 | } 29 | 30 | public Color getColor() { 31 | return color; 32 | } 33 | 34 | public void setColor(Color color) { 35 | this.color = color; 36 | } 37 | 38 | public Color getBackColor() { 39 | return backColor; 40 | } 41 | 42 | public void setBackColor(Color backColor) { 43 | this.backColor = backColor; 44 | } 45 | 46 | public Stroke getStroke() { 47 | return stroke; 48 | } 49 | 50 | public void setStroke(Stroke stroke) { 51 | this.stroke = stroke; 52 | } 53 | 54 | public Font getFont() { 55 | return font; 56 | } 57 | 58 | public void setFont(Font font) { 59 | this.font = font; 60 | } 61 | 62 | private static AlphaComposite getAlphaComposite(Color color) { 63 | return color.getAlpha() == 255 ? OPAQUE : TRANSPARENCY; 64 | } 65 | 66 | public AlphaComposite getAlphaComposite() { 67 | return getAlphaComposite(color); 68 | } 69 | 70 | public AlphaComposite getBackAlphaComposite() { 71 | return getAlphaComposite(backColor); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractOsmTileSource.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer.tilesources; 3 | 4 | import java.awt.Image; 5 | 6 | import org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate; 7 | 8 | /** 9 | * Abstract class for OSM Tile sources 10 | */ 11 | public abstract class AbstractOsmTileSource extends TMSTileSource { 12 | 13 | /** 14 | * The OSM attribution. Must be always in line with 15 | * https://www.openstreetmap.org/copyright/en 16 | */ 17 | public static final String DEFAULT_OSM_ATTRIBUTION = "\u00a9 OpenStreetMap contributors"; 18 | 19 | /** 20 | * Constructs a new OSM tile source 21 | * @param name Source name as displayed in GUI 22 | * @param baseUrl Source URL 23 | * @param id unique id for the tile source; contains only characters that 24 | * are safe for file names; can be null 25 | */ 26 | public AbstractOsmTileSource(String name, String baseUrl, String id) { 27 | super(new TileSourceInfo(name, baseUrl, id)); 28 | } 29 | 30 | @Override 31 | public int getMaxZoom() { 32 | return 19; 33 | } 34 | 35 | @Override 36 | public boolean requiresAttribution() { 37 | return true; 38 | } 39 | 40 | @Override 41 | public String getAttributionText(int zoom, ICoordinate topLeft, ICoordinate botRight) { 42 | return DEFAULT_OSM_ATTRIBUTION; 43 | } 44 | 45 | @Override 46 | public String getAttributionLinkURL() { 47 | return "https://openstreetmap.org/"; 48 | } 49 | 50 | @Override 51 | public Image getAttributionImage() { 52 | return null; 53 | } 54 | 55 | @Override 56 | public String getAttributionImageURL() { 57 | return null; 58 | } 59 | 60 | @Override 61 | public String getTermsOfUseText() { 62 | return null; 63 | } 64 | 65 | @Override 66 | public String getTermsOfUseURL() { 67 | return "https://www.openstreetmap.org/copyright"; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/LayerGroup.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer; 3 | 4 | import java.util.List; 5 | 6 | public class LayerGroup extends AbstractLayer { 7 | private List layers; 8 | 9 | public LayerGroup(String name) { 10 | super(name); 11 | } 12 | 13 | public LayerGroup(String name, String description) { 14 | super(name, description); 15 | } 16 | 17 | public LayerGroup(String name, Style style) { 18 | super(name, style); 19 | } 20 | 21 | public LayerGroup(String name, String description, Style style) { 22 | super(name, description, style); 23 | } 24 | 25 | public LayerGroup(LayerGroup parent, String name) { 26 | super(parent, name); 27 | } 28 | 29 | public LayerGroup(LayerGroup parent, String name, String description, Style style) { 30 | super(name, description, style); 31 | } 32 | 33 | public List getLayers() { 34 | return layers; 35 | } 36 | 37 | public void setElements(List layers) { 38 | this.layers = layers; 39 | } 40 | 41 | public Layer addLayer(String name) { 42 | Layer layer = new Layer(this, name); 43 | layers = add(layers, layer); 44 | return layer; 45 | } 46 | 47 | public LayerGroup add(AbstractLayer layer) { 48 | layer.setParent(this); 49 | layers = add(layers, layer); 50 | return this; 51 | } 52 | 53 | public void calculateVisibleTexts() { 54 | Boolean calculate = null; 55 | if (layers != null && !layers.isEmpty()) { 56 | calculate = layers.get(0).isVisibleTexts(); 57 | for (int i = 1; i < layers.size(); i++) { 58 | calculate = resultOf(calculate, layers.get(i).isVisibleTexts()); 59 | } 60 | } 61 | setVisibleTexts(calculate); 62 | if (getParent() != null) getParent().calculateVisibleTexts(); 63 | } 64 | 65 | public Boolean resultOf(Boolean b1, Boolean b2) { 66 | if (b1 != null && b1.equals(b2)) { 67 | return b1; 68 | } 69 | return Boolean.FALSE; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/Coordinate.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer; 3 | 4 | import java.awt.geom.Point2D; 5 | import java.io.IOException; 6 | import java.io.ObjectInputStream; 7 | import java.io.ObjectOutputStream; 8 | import java.util.Objects; 9 | 10 | import org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate; 11 | 12 | /** 13 | * This class encapsulates a Point2D.Double and provide access 14 | * via lat and lon. 15 | * 16 | * @author Jan Peter Stotz 17 | * 18 | */ 19 | public class Coordinate implements ICoordinate { 20 | private transient Point2D.Double data; 21 | 22 | /** 23 | * Constructs a new {@code Coordinate}. 24 | * @param lat latitude in degrees 25 | * @param lon longitude in degrees 26 | */ 27 | public Coordinate(double lat, double lon) { 28 | data = new Point2D.Double(lon, lat); 29 | } 30 | 31 | @Override 32 | public double getLat() { 33 | return data.y; 34 | } 35 | 36 | @Override 37 | public void setLat(double lat) { 38 | data.y = lat; 39 | } 40 | 41 | @Override 42 | public double getLon() { 43 | return data.x; 44 | } 45 | 46 | @Override 47 | public void setLon(double lon) { 48 | data.x = lon; 49 | } 50 | 51 | private void writeObject(ObjectOutputStream out) throws IOException { 52 | out.writeObject(data.x); 53 | out.writeObject(data.y); 54 | } 55 | 56 | private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { 57 | data = new Point2D.Double(); 58 | data.x = (Double) in.readObject(); 59 | data.y = (Double) in.readObject(); 60 | } 61 | 62 | @Override 63 | public String toString() { 64 | return "Coordinate[" + data.y + ", " + data.x + ']'; 65 | } 66 | 67 | @Override 68 | public int hashCode() { 69 | return Objects.hashCode(data); 70 | } 71 | 72 | @Override 73 | public boolean equals(Object obj) { 74 | if (this == obj) 75 | return true; 76 | if (obj == null || !(obj instanceof Coordinate)) 77 | return false; 78 | final Coordinate other = (Coordinate) obj; 79 | return Objects.equals(data, other.data); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/ika/map/tools/PointSetterTool.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PointTool.java 3 | * 4 | * Created on April 8, 2005, 7:59 AM 5 | */ 6 | 7 | package ika.map.tools; 8 | 9 | import java.awt.geom.*; 10 | import java.awt.event.*; 11 | import javax.swing.*; 12 | import ika.geo.*; 13 | import ika.gui.MapComponent; 14 | 15 | /** 16 | * PointSetterTool - a tool that adds GeoPoints to a map by simple clicks. 17 | * @author Bernhard Jenny, Institute of Cartography, ETH Zurich. 18 | */ 19 | public class PointSetterTool extends MapTool { 20 | 21 | private PointSymbol pointSymbol; 22 | 23 | /** 24 | * Create a new instance. 25 | * @param mapComponent The MapComponent for which this MapTool provides its services. 26 | */ 27 | public PointSetterTool(MapComponent mapComponent) { 28 | super(mapComponent); 29 | } 30 | 31 | /** 32 | * Create a new instance. 33 | * @param mapComponent The MapComponent for which this MapTool provides its services. 34 | * @param pointSymbol The PointSymbol used to draw newly created points. 35 | */ 36 | public PointSetterTool(MapComponent mapComponent, 37 | PointSymbol pointSymbol) { 38 | super(mapComponent); 39 | this.pointSymbol = pointSymbol; 40 | } 41 | 42 | /** 43 | * The mouse was clicked, while this MapTool was the active one. 44 | * @param point The location of the mouse in world coordinates. 45 | * @param evt The original event. 46 | */ 47 | public void mouseClicked(Point2D.Double point, MouseEvent evt) { 48 | // add a new point 49 | GeoPoint geoPoint = new GeoControlPoint(point); 50 | if (this.pointSymbol != null) 51 | geoPoint.setPointSymbol(this.pointSymbol); 52 | geoPoint.setSelected(true); 53 | 54 | // deselect all current GeoObjects in destination GeoSet 55 | this.destinationGeoSet.setSelected(false); 56 | 57 | // add point 58 | this.destinationGeoSet.addGeoObject(geoPoint); 59 | 60 | // inform MapToolActionListeners about action 61 | this.informMapToolActionListeners ("Set Point"); 62 | } 63 | 64 | public PointSymbol getPointSymbol() { 65 | return pointSymbol; 66 | } 67 | 68 | public void setPointSymbol(PointSymbol pointSymbol) { 69 | this.pointSymbol = pointSymbol; 70 | } 71 | 72 | protected String getCursorName() { 73 | return "setpointarrow"; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/ika/mapanalyst/MapAnalyzer.java: -------------------------------------------------------------------------------- 1 | package ika.mapanalyst; 2 | 3 | import java.io.*; 4 | import ika.geo.*; 5 | 6 | public abstract class MapAnalyzer implements Serializable { 7 | 8 | private static final long serialVersionUID = 3190984104408150328L; 9 | 10 | /* The resulting graphics for the old map has to be added to oldGeoSet */ 11 | protected GeoSet oldGeoSet; 12 | 13 | /* The resulting graphics for the new map has to be added to newGeoSet */ 14 | protected GeoSet newGeoSet; 15 | 16 | protected transient VisualizationParameters params; 17 | 18 | public MapAnalyzer() { 19 | this.oldGeoSet = new GeoSet(); 20 | this.oldGeoSet.setName(this.getName() + " old"); 21 | this.newGeoSet = new GeoSet(); 22 | this.newGeoSet.setName(this.getName() + " new"); 23 | } 24 | 25 | abstract public String getName(); 26 | 27 | /** 28 | * Analyze a map and store the visual result. 29 | * Derived classes should throw a MapAnalyzerException, if the visualization 30 | * cannot be generated. 31 | * @param params 32 | */ 33 | abstract public void analyzeMap () 34 | throws MapAnalyzerException; 35 | 36 | public boolean isVisible() { 37 | return this.oldGeoSet.isVisible(); 38 | } 39 | 40 | public void setVisible(boolean visible) { 41 | this.oldGeoSet.setVisible(visible); 42 | this.newGeoSet.setVisible(visible); 43 | } 44 | 45 | public void clearAll(){ 46 | this.newGeoSet.removeAllGeoObjects(); 47 | this.oldGeoSet.removeAllGeoObjects(); 48 | } 49 | 50 | public GeoSet getOldGeoSet() { 51 | return oldGeoSet; 52 | } 53 | 54 | public GeoSet getNewGeoSet() { 55 | return newGeoSet; 56 | } 57 | 58 | /** 59 | * @param params the params to set 60 | */ 61 | public void setVisualizationParameters(VisualizationParameters params) { 62 | this.params = params; 63 | } 64 | 65 | public class MapAnalyzerException extends Exception { 66 | public final String mapAnalyzerName; 67 | public MapAnalyzerException (String msg, MapAnalyzer mapAnalyzer) { 68 | super(msg); 69 | this.mapAnalyzerName = mapAnalyzer.getName(); 70 | } 71 | 72 | public MapAnalyzerException (String msg) { 73 | super(msg); 74 | mapAnalyzerName = null; 75 | } 76 | } 77 | } -------------------------------------------------------------------------------- /src/ika/utils/XMLDOMPrinter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * XMLDOMPrinter.java 3 | * 4 | * Created on May 31, 2005, 2:32 PM 5 | * 6 | * To change this template, choose Tools | Options and locate the template under 7 | * the Source Creation and Management node. Right-click the template and choose 8 | * Open. You can then make changes to the template in the Source Editor. 9 | */ 10 | 11 | package ika.utils; 12 | 13 | import java.io.*; 14 | import org.w3c.dom.*; 15 | import javax.xml.transform.*; 16 | import javax.xml.transform.dom.*; 17 | import javax.xml.transform.stream.*; 18 | 19 | /** 20 | * Outputs a XML DOM to a file or to a PrtinStream. 21 | */ 22 | public class XMLDOMPrinter { 23 | 24 | /** 25 | * Writes a DOM to a file. 26 | * @param filename The path of the file that will be generated. 27 | * @param document The DOM to write. 28 | */ 29 | public static void writeXML(String filename, Document document) 30 | throws TransformerConfigurationException, TransformerException{ 31 | // Prepare the output file 32 | File file = new File(filename); 33 | Result result = new StreamResult(file); 34 | XMLDOMPrinter.outputXML(result, document); 35 | } 36 | 37 | /** 38 | * Prints a DOM to a PrintStream. 39 | * Use with standard output: XMLDOMPrinter.printXML(document, System.out); 40 | * @param document The DOM to print. 41 | * @param printer The printer to print to. 42 | */ 43 | public static void printXML(Document document, PrintStream printer) 44 | throws TransformerConfigurationException, TransformerException{ 45 | // First write to a StringWriter, then print to the printer. 46 | StringWriter w = new StringWriter(); 47 | Result result = new StreamResult(w); 48 | XMLDOMPrinter.outputXML(result, document); 49 | printer.println(w.getBuffer().toString()); 50 | } 51 | 52 | /** 53 | * Outputs a DOM to a Result object. 54 | * @param result The destination to write to. 55 | * @param document The DOM to output. 56 | */ 57 | public static void outputXML(Result result, Document document) 58 | throws TransformerConfigurationException, TransformerException { 59 | // Prepare the DOM document for writing 60 | Source source = new DOMSource(document); 61 | // Get Transformer 62 | Transformer xformer = TransformerFactory.newInstance().newTransformer(); 63 | // Write 64 | xformer.transform(source, result); 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /src/ika/mapanalyst/Link.java: -------------------------------------------------------------------------------- 1 | package ika.mapanalyst; 2 | 3 | import java.io.*; 4 | import ika.geo.*; 5 | 6 | public class Link implements Serializable { 7 | 8 | private static final long serialVersionUID = -4482453568064537680L; 9 | 10 | private GeoPoint ptOld; 11 | 12 | private GeoPoint ptNew; 13 | 14 | private String name; 15 | 16 | /** 17 | * Constructs a link with name and the specified points for the old and 18 | * the new map. 19 | */ 20 | public Link(GeoPoint ptOld, GeoPoint ptNew, String name) { 21 | this.ptOld = ptOld; 22 | this.ptNew = ptNew; 23 | this.setName(name); 24 | } 25 | 26 | /** 27 | * Returns the linked control point from the old map. 28 | * @return the linked control point from the old map 29 | */ 30 | public GeoPoint getPtOld(){ 31 | return this.ptOld; 32 | } 33 | 34 | /** 35 | * Returns the linked control point form the new map. 36 | * @return the linked control point from the new map 37 | */ 38 | public GeoPoint getPtNew(){ 39 | return this.ptNew; 40 | } 41 | 42 | /** 43 | * Sets the linkname. 44 | * @param name the linkname 45 | */ 46 | public void setName(String name) { 47 | this.name = name; 48 | if (this.ptOld != null) 49 | this.ptOld.setName(name); 50 | if (this.ptNew != null) 51 | this.ptNew.setName(name); 52 | } 53 | 54 | public String getName() { 55 | return this.name; 56 | } 57 | 58 | public String toString() { 59 | 60 | StringBuffer str = new StringBuffer(128); 61 | str.append("name: "); 62 | str.append(this.name); 63 | str.append("\n"); 64 | str.append("old point: \n"); 65 | str.append("x: " + this.ptOld.getX() + "\n"); 66 | str.append("y: " + this.ptOld.getY() + "\n"); 67 | str.append("new point: \n"); 68 | str.append("x: " + this.ptNew.getX() + "\n"); 69 | str.append("y: " + this.ptNew.getY() + "\n"); 70 | return str.toString(); 71 | } 72 | 73 | public void setSelected(boolean selected) { 74 | this.ptOld.setSelected(selected); 75 | this.ptNew.setSelected(selected); 76 | } 77 | 78 | public boolean isSelected() { 79 | return this.ptOld.isSelected() 80 | || this.ptNew.isSelected(); 81 | } 82 | 83 | public void setPointSymbol(PointSymbol pointSymbol) { 84 | ptOld.setPointSymbol(pointSymbol); 85 | ptNew.setPointSymbol(pointSymbol); 86 | } 87 | } -------------------------------------------------------------------------------- /nbproject/project.properties: -------------------------------------------------------------------------------- 1 | debug.modulepath=\ 2 | ${run.modulepath} 3 | debug.test.modulepath=\ 4 | ${run.test.modulepath} 5 | #Tue Jan 19 22:16:38 EST 2016 6 | excludes= 7 | javac.deprecation=true 8 | build.test.results.dir=${build.dir}/test/results 9 | javac.modulepath= 10 | javac.processormodulepath= 11 | javac.test.modulepath=\ 12 | ${javac.modulepath} 13 | project.JMapProjLib=../JMapProjLib 14 | reference.JMapProjLib.jar=${project.JMapProjLib}/dist/JMapProjLib.jar 15 | run.classpath=\ 16 | ${javac.classpath}:\ 17 | ${build.classes.dir} 18 | javadoc.nonavbar=false 19 | javac.external.vm=false 20 | file.reference.jai_imageio.jar=lib/jai_imageio.jar 21 | run.modulepath=\ 22 | ${javac.modulepath} 23 | run.test.classpath=\ 24 | ${javac.test.classpath}:\ 25 | ${build.test.classes.dir} 26 | javac.processorpath=\ 27 | ${javac.classpath} 28 | javac.target=1.8 29 | annotation.processing.processors.list= 30 | javadoc.noindex=false 31 | javadoc.additionalparam= 32 | includes=** 33 | build.classes.dir=${build.dir}/classes 34 | run.test.modulepath=\ 35 | ${javac.test.modulepath} 36 | source.encoding=x-MacRoman 37 | javadoc.author=true 38 | test.src.dir=test 39 | build.dir=build 40 | build.test.classes.dir=${build.dir}/test/classes 41 | platform.active=default_platform 42 | javac.compilerargs= 43 | main.class=ika.mapanalyst.Main 44 | file.reference.ostermillerutils_1_04_03_for_java_1_4.jar=libs/ostermillerutils_1_04_03_for_java_1_4.jar 45 | dist.jar=${dist.dir}/MapAnalyst1_3.jar 46 | javadoc.use=true 47 | build.sysclasspath=ignore 48 | debug.test.classpath=${run.test.classpath} 49 | dist.dir=dist 50 | build.classes.excludes=**/*.java,**/*.form 51 | javadoc.splitindex=true 52 | javadoc.encoding= 53 | javac.source=1.8 54 | application.vendor=jenny 55 | junit.selected.version=3 56 | debug.classpath=${run.classpath} 57 | run.jvmargs=-Xmx1024m 58 | jaxbwiz.endorsed.dirs="${netbeans.home}/../ide12/modules/ext/jaxb/api" 59 | jar.compress=true 60 | javac.test.classpath=\ 61 | ${javac.classpath}:\ 62 | ${build.classes.dir}:\ 63 | ${libs.junit_4.classpath}:\ 64 | ${libs.hamcrest.classpath} 65 | javadoc.private=true 66 | annotation.processing.run.all.processors=true 67 | application.title=MapAnalyst1_2_3 68 | manifest.file=manifest.mf 69 | annotation.processing.enabled=true 70 | dist.javadoc.dir=${dist.dir}/javadoc 71 | src.dir=src 72 | mkdist.disabled=false 73 | endorsed.classpath= 74 | javac.classpath=\ 75 | ${file.reference.jai_imageio.jar}:\ 76 | ${reference.JMapProjLib.jar} 77 | annotation.processing.enabled.in.editor=false 78 | build.generated.sources.dir=${build.dir}/generated-sources 79 | application.args= 80 | javadoc.version=false 81 | javadoc.windowtitle=MapAnalyst Documentation 82 | javadoc.notree=false 83 | -------------------------------------------------------------------------------- /src/ika/gui/ImageReferencerDialog.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ImageReferencerDialog.java 3 | * 4 | * Created on July 1, 2005, 11:58 AM 5 | */ 6 | 7 | package ika.gui; 8 | 9 | import ika.geo.*; 10 | 11 | /** 12 | * 13 | * @author jenny 14 | */ 15 | public class ImageReferencerDialog extends javax.swing.JDialog { 16 | 17 | /** Creates new form ImageReferencerDialog */ 18 | public ImageReferencerDialog(java.awt.Frame parent, boolean modal) { 19 | super(parent, modal); 20 | initComponents(); 21 | } 22 | 23 | /** This method is called from within the constructor to 24 | * initialize the form. 25 | * WARNING: Do NOT modify this code. The content of this method is 26 | * always regenerated by the Form Editor. 27 | */ 28 | // //GEN-BEGIN:initComponents 29 | private void initComponents() { 30 | imageReferencerPanel = new ika.gui.ImageReferencerPanel(); 31 | 32 | setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); 33 | setTitle("Reference Image"); 34 | setModal(true); 35 | addWindowListener(new java.awt.event.WindowAdapter() { 36 | public void windowClosing(java.awt.event.WindowEvent evt) { 37 | formWindowClosing(evt); 38 | } 39 | }); 40 | 41 | getContentPane().add(imageReferencerPanel, java.awt.BorderLayout.CENTER); 42 | 43 | pack(); 44 | } 45 | // //GEN-END:initComponents 46 | 47 | private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing 48 | if (this.imageReferencerPanel.askUserForAborting()) 49 | this.dispose(); 50 | }//GEN-LAST:event_formWindowClosing 51 | 52 | public void referenceImage(GeoImage geoImage, GeoSet destinationGeoSet) { 53 | if (geoImage == null) 54 | throw new IllegalArgumentException(); 55 | 56 | geoImage.setSelectable(false); 57 | 58 | this.imageReferencerPanel.setImage(geoImage); 59 | this.imageReferencerPanel.setDestinationGeoSet(destinationGeoSet); 60 | this.setVisible(true); 61 | } 62 | 63 | /** 64 | * @param args the command line arguments 65 | */ 66 | public static void main(String args[]) { 67 | java.awt.EventQueue.invokeLater(new Runnable() { 68 | public void run() { 69 | new ImageReferencerDialog(new javax.swing.JFrame(), true).setVisible(true); 70 | } 71 | }); 72 | } 73 | 74 | // Variables declaration - do not modify//GEN-BEGIN:variables 75 | private ika.gui.ImageReferencerPanel imageReferencerPanel; 76 | // End of variables declaration//GEN-END:variables 77 | 78 | } 79 | -------------------------------------------------------------------------------- /src/ika/mapanalyst/GeometryTransformer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GeometryTransformer.java 3 | * 4 | * Created on June 27, 2005, 6:08 PM 5 | * 6 | */ 7 | 8 | package ika.mapanalyst; 9 | 10 | import ika.geo.*; 11 | import ika.transformation.Transformation; 12 | 13 | /** 14 | * 15 | * @author jenny 16 | */ 17 | public class GeometryTransformer extends MapAnalyzer implements java.io.Serializable { 18 | static final long serialVersionUID = -8896023758644042810L; 19 | 20 | private GeoSet oldSourceGeoSet; 21 | private GeoSet newSourceGeoSet; 22 | 23 | /** Creates a new instance of GeometryTransformer */ 24 | public GeometryTransformer() { 25 | this.oldSourceGeoSet = new GeoSet(); 26 | this.newSourceGeoSet = new GeoSet(); 27 | } 28 | 29 | public String getName() { 30 | return "Geometry Transformer"; 31 | } 32 | 33 | 34 | public void analyzeMap() { 35 | 36 | GeoSet destGeoSet, sourceGeoSet; 37 | if(params.isAnalyzeOldMap()){ 38 | destGeoSet = this.oldGeoSet; 39 | sourceGeoSet = this.newSourceGeoSet; 40 | } else{ 41 | destGeoSet = this.newGeoSet; 42 | sourceGeoSet = this.oldSourceGeoSet; 43 | } 44 | if (sourceGeoSet == null || destGeoSet == null) 45 | return; 46 | 47 | final Transformation transformation = params.getTransformation(); 48 | final MultiquadricInterpolation multiQuadra = 49 | params.getMultiquadricInterpolation(); 50 | GeoSet transformedGeoSet= transformation.transform(sourceGeoSet); 51 | if (transformation == null 52 | || multiQuadra == null 53 | || transformedGeoSet == null) 54 | return; 55 | 56 | transformedGeoSet = multiQuadra.transform(transformedGeoSet); 57 | if (transformedGeoSet == null) 58 | return; 59 | 60 | final int nbrGeoObj = transformedGeoSet.getNumberOfChildren(); 61 | for (int i = 0; i < nbrGeoObj; ++i) { 62 | destGeoSet.addGeoObject(transformedGeoSet.getGeoObject(i)); 63 | } 64 | } 65 | 66 | public void addDrawing(GeoObject geoObject, boolean addToOldMap) { 67 | if (addToOldMap) 68 | this.oldSourceGeoSet.addGeoObject(geoObject); 69 | else 70 | this.newSourceGeoSet.addGeoObject(geoObject); 71 | } 72 | 73 | public void removeDrawing(boolean removeFromOldMap) { 74 | if (removeFromOldMap) 75 | this.oldSourceGeoSet.removeAllGeoObjects(); 76 | else 77 | this.newSourceGeoSet.removeAllGeoObjects(); 78 | } 79 | 80 | public GeoSet getOldSourceGeoSet() { 81 | return oldSourceGeoSet; 82 | } 83 | 84 | public GeoSet getNewSourceGeoSet() { 85 | return newSourceGeoSet; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/ika/geoimport/UngenerateImporter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * UngenerateImporter.java 3 | * 4 | * Created on April 1, 2005, 12:02 PM 5 | */ 6 | 7 | package ika.geoimport; 8 | 9 | import ika.geo.*; 10 | import java.util.*; 11 | import java.io.*; 12 | 13 | /** 14 | * An importer for the Ungenerate file format. 15 | * @author Bernhard Jenny, Institute of Cartography, ETH Zurich. 16 | */ 17 | public class UngenerateImporter { 18 | 19 | /** 20 | * Reads an Ungenerate file and returns the found GeoObjects in a GeoSet. 21 | * @param filePath The file to import. 22 | * @return A GeoSet containing all read GeoObjects. 23 | */ 24 | public static GeoSet read(String filePath) throws IOException { 25 | GeoSet geoSet = new GeoSet(); 26 | boolean foundEnd = false; 27 | BufferedReader in = new BufferedReader(new FileReader(filePath)); 28 | try { 29 | String str; 30 | boolean firstPoint; 31 | while ((str = in.readLine()) != null) { 32 | GeoPath geoPath = new GeoPath(); 33 | firstPoint = true; 34 | 35 | while (true) { 36 | str = in.readLine(); 37 | if (str == null || str.length() == 0) 38 | break; 39 | str = str.trim().toLowerCase(); 40 | foundEnd |= str.startsWith("end"); 41 | 42 | if (str.startsWith("end") ) 43 | break; 44 | try { 45 | StringTokenizer tokenizer = new StringTokenizer(str, " \t"); 46 | float x = Float.parseFloat((String)tokenizer.nextToken()); 47 | float y = Float.parseFloat((String)tokenizer.nextToken()); 48 | if (firstPoint) { 49 | geoPath.moveTo(x, y); 50 | firstPoint = false; 51 | } else 52 | geoPath.lineTo(x, y); 53 | } catch (NoSuchElementException e) { 54 | // found a line without any readable data. Just read the next line 55 | } 56 | } 57 | 58 | if (geoPath.hasOneOrMoreSegments()) { 59 | VectorSymbol symbol = new VectorSymbol(java.awt.Color.blue, java.awt.Color.black, 1); 60 | symbol.setScaleInvariant(true); 61 | geoPath.setVectorSymbol(symbol); 62 | geoSet.addGeoObject(geoPath); 63 | } 64 | } 65 | // test if last line was "end" 66 | if (!foundEnd) 67 | throw new IOException("Invalid Ungenerate file"); 68 | 69 | } finally { 70 | in.close(); 71 | } 72 | 73 | return geoSet; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTileSource.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer.tilesources; 3 | 4 | import java.awt.Image; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | import org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate; 9 | import org.openstreetmap.gui.jmapviewer.interfaces.TileSource; 10 | 11 | public abstract class AbstractTileSource implements TileSource { 12 | 13 | protected String attributionText; 14 | protected String attributionLinkURL; 15 | protected Image attributionImage; 16 | protected String attributionImageURL; 17 | protected String termsOfUseText; 18 | protected String termsOfUseURL; 19 | 20 | @Override 21 | public boolean requiresAttribution() { 22 | return attributionText != null || attributionLinkURL != null || attributionImage != null 23 | || termsOfUseText != null || termsOfUseURL != null; 24 | } 25 | 26 | @Override 27 | public String getAttributionText(int zoom, ICoordinate topLeft, ICoordinate botRight) { 28 | return attributionText; 29 | } 30 | 31 | @Override 32 | public String getAttributionLinkURL() { 33 | return attributionLinkURL; 34 | } 35 | 36 | @Override 37 | public Image getAttributionImage() { 38 | return attributionImage; 39 | } 40 | 41 | @Override 42 | public String getAttributionImageURL() { 43 | return attributionImageURL; 44 | } 45 | 46 | @Override 47 | public String getTermsOfUseText() { 48 | return termsOfUseText; 49 | } 50 | 51 | @Override 52 | public String getTermsOfUseURL() { 53 | return termsOfUseURL; 54 | } 55 | 56 | public void setAttributionText(String attributionText) { 57 | this.attributionText = attributionText; 58 | } 59 | 60 | public void setAttributionLinkURL(String attributionLinkURL) { 61 | this.attributionLinkURL = attributionLinkURL; 62 | } 63 | 64 | public void setAttributionImage(Image attributionImage) { 65 | this.attributionImage = attributionImage; 66 | } 67 | 68 | public void setAttributionImageURL(String attributionImageURL) { 69 | this.attributionImageURL = attributionImageURL; 70 | } 71 | 72 | public void setTermsOfUseText(String termsOfUseText) { 73 | this.termsOfUseText = termsOfUseText; 74 | } 75 | 76 | public void setTermsOfUseURL(String termsOfUseURL) { 77 | this.termsOfUseURL = termsOfUseURL; 78 | } 79 | 80 | @Override 81 | public boolean isNoTileAtZoom(Map> headers, int statusCode, byte[] content) { 82 | // default handler - when HTTP 404 is returned, then treat this situation as no tile at this zoom level 83 | return statusCode == 404; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/ika/icons/IconLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * IconLoader.java 3 | * 4 | * Created on April 14, 2005, 11:24 AM 5 | */ 6 | 7 | package ika.icons; 8 | 9 | import javax.swing.*; 10 | 11 | /** 12 | * From the SUN Tutorial "How to Use Icons"
13 | * 14 | * The first argument to the ImageIcon constructor is relative to the location of 15 | * the class, and will be resolved to an absolute URL. The description argument is 16 | * a string that allows assistive technologies to help a visually impaired user 17 | * understand what information the icon conveys.
18 | * 19 | * Generally, applications provide their own set of images used as part of the 20 | * application, as is the case with the images used by many of our demos. You 21 | * should use the Class getResource method to obtain the path to the image. 22 | * This allows the application to verify that the image is available and to provide 23 | * sensible error handling if it is not. When the image is not part of the 24 | * application, getResource should not be used and the ImageIcon constructor is 25 | * used directly. For example:
26 | * 27 | * ImageIcon icon = new ImageIcon("/home/sharonz/images/middle.gif", 28 | * "a pretty but meaningless splat"); 29 | * 30 | *
31 | * When you specify a filename or URL to an ImageIcon constructor, processing 32 | * is blocked until after the image data is completely loaded or the data location 33 | * has proven to be invalid. If the data location is invalid (but non-null), an 34 | * ImageIcon is still successfully created; it just has no size and, therefore, 35 | * paints nothing. As we showed in the createImageIcon method, it's wise to first 36 | * verify that the URL points to an existing file before passing it to the 37 | * ImageIcon constructor. 38 | */ 39 | public class IconLoader { 40 | 41 | /** 42 | * Returns an ImageIcon, or null if the path was invalid. 43 | * @param path Path to the file relative to this class! 44 | * @param description String that allows assistive technologies to help a visually impaired user 45 | * understand what information the icon conveys 46 | * @return The loaded ImageIcon or null if the icon cannot be loaded. 47 | */ 48 | public static ImageIcon createImageIcon(String path, 49 | String description) { 50 | 51 | try { 52 | java.net.URL imgURL = IconLoader.class.getResource(path); 53 | if (imgURL != null) { 54 | ImageIcon imageIcon = new ImageIcon(imgURL, description); 55 | if (imageIcon.getIconWidth() == 0 56 | || imageIcon.getIconHeight() == 0) 57 | imageIcon = null; 58 | return imageIcon; 59 | } else { 60 | System.err.println("Couldn't find file: " + path); 61 | return null; 62 | } 63 | } catch (Exception exc) { 64 | return null; 65 | } 66 | } 67 | 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/ika/mapanalyst/ApplicationInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ApplicationInfo.java 3 | * 4 | * Created on March 29, 2005, 11:39 PM 5 | */ 6 | 7 | package ika.mapanalyst; 8 | 9 | import java.text.DateFormat; 10 | import java.util.Locale; 11 | 12 | /** 13 | * Information about this application. 14 | * @author Bernhard Jenny, Institute of Cartography, ETH Zurich. 15 | */ 16 | public class ApplicationInfo { 17 | 18 | /** 19 | * Returns the name of this application. 20 | * @return The name of this application. 21 | */ 22 | public static String getApplicationName() { 23 | return "MapAnalyst"; 24 | } 25 | 26 | /** 27 | * Returns a string containing version information about this application. 28 | * @return The version of this application. 29 | */ 30 | public static String getApplicationVersion() { 31 | return "1.3.35"; 32 | } 33 | 34 | /** 35 | * Returns an icon for this application. 36 | * @return The icon of this application. 37 | */ 38 | public static javax.swing.Icon getApplicationIcon() { 39 | return ika.icons.IconLoader.createImageIcon("logo48x48.gif", null); 40 | } 41 | 42 | /** 43 | * Returns a copyright string for this application. 44 | * @return The copyright description of this application. 45 | */ 46 | public static String getCopyright() { 47 | String info = "
"; 48 | info += "MapAnalyst is Copyright 2005-2019 by
" + 49 | "Bernhard Jenny, Monash University, Australia

"; 50 | info += "This program is free software;
"; 51 | info += "you can redistribute it and/or modify it
" + 52 | "under the terms of the GNU General Public
" + 53 | "License version 2 as published by the
" + 54 | "Free Software Foundation.

"; 55 | info += "
"; 56 | return info; 57 | } 58 | 59 | /** 60 | * Returns the home page (a html web address) for this application. 61 | * @return The home page of this application. 62 | */ 63 | public static String getHomepage() { 64 | return "http://mapanalyst.org/"; 65 | } 66 | 67 | /** 68 | * Returns the file extension for documents created by this application. 69 | * @return The file extension. 70 | */ 71 | public static String getDocumentExtension() { 72 | return "pma"; 73 | } 74 | 75 | /** 76 | * Returns the current time and date in a formatted string. 77 | * @return The string containing time and date. 78 | */ 79 | public static String getCurrentTimeAndDate() { 80 | return java.text.DateFormat.getDateTimeInstance( 81 | DateFormat.LONG, DateFormat.LONG, 82 | Locale.US) // require US locale since the GUI is in English and 83 | // to avoid issues with missing glyphs for certain scripts (e.g. cyrillic) 84 | .format(new java.util.Date()); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/TileController.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer; 3 | 4 | import org.openstreetmap.gui.jmapviewer.interfaces.TileCache; 5 | import org.openstreetmap.gui.jmapviewer.interfaces.TileLoader; 6 | import org.openstreetmap.gui.jmapviewer.interfaces.TileLoaderListener; 7 | import org.openstreetmap.gui.jmapviewer.interfaces.TileSource; 8 | 9 | public class TileController { 10 | protected TileLoader tileLoader; 11 | protected TileCache tileCache; 12 | protected TileSource tileSource; 13 | 14 | public TileController(TileSource source, TileCache tileCache, TileLoaderListener listener) { 15 | this.tileSource = source; 16 | this.tileLoader = new OsmTileLoader(listener); 17 | this.tileCache = tileCache; 18 | } 19 | 20 | /** 21 | * retrieves a tile from the cache. If the tile is not present in the cache 22 | * a load job is added to the working queue of {@link TileLoader}. 23 | * 24 | * @param tilex the X position of the tile 25 | * @param tiley the Y position of the tile 26 | * @param zoom the zoom level of the tile 27 | * @return specified tile from the cache or null if the tile 28 | * was not found in the cache. 29 | */ 30 | public Tile getTile(int tilex, int tiley, int zoom) { 31 | int max = 1 << zoom; 32 | if (tilex < 0 || tilex >= max || tiley < 0 || tiley >= max) 33 | return null; 34 | Tile tile = tileCache.getTile(tileSource, tilex, tiley, zoom); 35 | if (tile == null) { 36 | tile = new Tile(tileSource, tilex, tiley, zoom); 37 | tileCache.addTile(tile); 38 | tile.loadPlaceholderFromCache(tileCache); 39 | } 40 | if (tile.error) { 41 | tile.loadPlaceholderFromCache(tileCache); 42 | } 43 | if (!tile.isLoaded()) { 44 | tileLoader.createTileLoaderJob(tile).submit(); 45 | } 46 | return tile; 47 | } 48 | 49 | public TileCache getTileCache() { 50 | return tileCache; 51 | } 52 | 53 | public void setTileCache(TileCache tileCache) { 54 | this.tileCache = tileCache; 55 | } 56 | 57 | public TileLoader getTileLoader() { 58 | return tileLoader; 59 | } 60 | 61 | public void setTileLoader(TileLoader tileLoader) { 62 | this.tileLoader = tileLoader; 63 | } 64 | 65 | public TileSource getTileLayerSource() { 66 | return tileSource; 67 | } 68 | 69 | public TileSource getTileSource() { 70 | return tileSource; 71 | } 72 | 73 | public void setTileSource(TileSource tileSource) { 74 | this.tileSource = tileSource; 75 | } 76 | 77 | /** 78 | * Removes all jobs from the queue that are currently not being processed. 79 | * 80 | */ 81 | public void cancelOutstandingJobs() { 82 | tileLoader.cancelOutstandingTasks(); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/MapRectangleImpl.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer; 3 | 4 | import java.awt.BasicStroke; 5 | import java.awt.Color; 6 | import java.awt.Graphics; 7 | import java.awt.Graphics2D; 8 | import java.awt.Point; 9 | import java.awt.Stroke; 10 | 11 | import org.openstreetmap.gui.jmapviewer.interfaces.MapRectangle; 12 | 13 | public class MapRectangleImpl extends MapObjectImpl implements MapRectangle { 14 | 15 | private Coordinate topLeft; 16 | private Coordinate bottomRight; 17 | 18 | public MapRectangleImpl(Coordinate topLeft, Coordinate bottomRight) { 19 | this(null, null, topLeft, bottomRight); 20 | } 21 | 22 | public MapRectangleImpl(String name, Coordinate topLeft, Coordinate bottomRight) { 23 | this(null, name, topLeft, bottomRight); 24 | } 25 | 26 | public MapRectangleImpl(Layer layer, Coordinate topLeft, Coordinate bottomRight) { 27 | this(layer, null, topLeft, bottomRight); 28 | } 29 | 30 | public MapRectangleImpl(Layer layer, String name, Coordinate topLeft, Coordinate bottomRight) { 31 | this(layer, name, topLeft, bottomRight, getDefaultStyle()); 32 | } 33 | 34 | public MapRectangleImpl(Layer layer, String name, Coordinate topLeft, Coordinate bottomRight, Style style) { 35 | super(layer, name, style); 36 | this.topLeft = topLeft; 37 | this.bottomRight = bottomRight; 38 | } 39 | 40 | @Override 41 | public Coordinate getTopLeft() { 42 | return topLeft; 43 | } 44 | 45 | @Override 46 | public Coordinate getBottomRight() { 47 | return bottomRight; 48 | } 49 | 50 | @Override 51 | public void paint(Graphics g, Point topLeft, Point bottomRight) { 52 | // Prepare graphics 53 | Color oldColor = g.getColor(); 54 | g.setColor(getColor()); 55 | Stroke oldStroke = null; 56 | if (g instanceof Graphics2D) { 57 | Graphics2D g2 = (Graphics2D) g; 58 | oldStroke = g2.getStroke(); 59 | g2.setStroke(getStroke()); 60 | } 61 | // Draw 62 | g.drawRect(topLeft.x, topLeft.y, bottomRight.x - topLeft.x, bottomRight.y - topLeft.y); 63 | // Restore graphics 64 | g.setColor(oldColor); 65 | if (g instanceof Graphics2D) { 66 | ((Graphics2D) g).setStroke(oldStroke); 67 | } 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); 72 | } 73 | 74 | public static Style getDefaultStyle() { 75 | return new Style(Color.BLUE, null, new BasicStroke(2), getDefaultFont()); 76 | } 77 | 78 | @Override 79 | public String toString() { 80 | return "MapRectangle from " + getTopLeft() + " to " + getBottomRight(); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/ika/transformation/robustestimator/HuberEstimator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * HuberEstimator.java 3 | * 4 | * Created on April 5, 2005, 8:40 AM 5 | */ 6 | 7 | package ika.transformation.robustestimator; 8 | 9 | /** 10 | * Robust estimator according to Huber 11 | * @author Bernhard Jenny, Institute of Cartography, ETH Zurich 12 | */ 13 | public class HuberEstimator extends RobustEstimator implements java.io.Serializable { 14 | 15 | private static final long serialVersionUID = 7601561936358246963L; 16 | 17 | /** 18 | * Tuning constant k. Estimates the qualtiy of the dataset.
19 | * As with the value of the standard deviation:
20 | * k = 1: 66% of all points are compensated with least squares estimation,
21 | * the error on the other 34% has a lesser wheight. 22 | * k = 3: 99.5% 23 | */ 24 | private double k = 1.5; 25 | 26 | private double minK = 0.0; 27 | 28 | private double maxK = 4.0; 29 | 30 | /** Creates a new instance of HuberEstimator */ 31 | public HuberEstimator() { 32 | } 33 | 34 | /** 35 | * Returns a description of the estimator. 36 | * The description does not contain any numerical values. 37 | * @return The description. 38 | */ 39 | public String getDescription() { 40 | String nl = System.getProperty("line.separator"); 41 | String str = "Robust Huber-Estimator" + nl; 42 | str += "Split Point k" + nl; 43 | return str; 44 | } 45 | 46 | /** 47 | * Returns the name of this robust estimator. 48 | * @return Returns a String 49 | */ 50 | public String getName(){ 51 | String str = "Huber Estimator"; 52 | return str; 53 | } 54 | 55 | /** 56 | * Returns a description of the estimator. 57 | * The description does contain numerical values. 58 | * @return The description. 59 | */ 60 | public String getDescriptionOfValues() { 61 | String nl = System.getProperty("line.separator"); 62 | return "Split Point k:\t" + this.k + nl; 63 | } 64 | 65 | /** 66 | * weight function of the estimator 67 | * @param u residual scaled by s. 68 | * @return The weight for u. 69 | */ 70 | public double w(double u) { 71 | final double u_abs = Math.abs(u); 72 | return u_abs < this.k ? 1. : this.k / u_abs; 73 | } 74 | 75 | /** 76 | * Returns the tuning constant k. 77 | * @return The tuning constant k. 78 | */ 79 | public double getK() { 80 | return k; 81 | } 82 | 83 | /** 84 | * Sets the tuning constant k. 85 | * @param k The new value of the tuning constant k. 86 | */ 87 | public void setK(double k) { 88 | if (k <= 0.) 89 | throw new IllegalArgumentException(); 90 | this.k = k; 91 | } 92 | 93 | public String getShortReport(){ 94 | String str = "Huber Estimator\n"; 95 | str += this.getK(); 96 | return str; 97 | } 98 | 99 | public double getMinK() { 100 | return minK; 101 | } 102 | 103 | public double getMaxK() { 104 | return maxK; 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/AbstractLayer.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer; 3 | 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | public class AbstractLayer { 8 | private LayerGroup parent; 9 | private String name; 10 | private String description; 11 | private Style style; 12 | private Boolean visible; 13 | private Boolean visibleTexts = Boolean.TRUE; 14 | 15 | public AbstractLayer(String name) { 16 | this(name, (String) null); 17 | } 18 | 19 | public AbstractLayer(String name, String description) { 20 | this(name, description, MapMarkerCircle.getDefaultStyle()); 21 | } 22 | 23 | public AbstractLayer(String name, Style style) { 24 | this(name, null, style); 25 | } 26 | 27 | public AbstractLayer(String name, String description, Style style) { 28 | this(null, name, description, style); 29 | } 30 | 31 | public AbstractLayer(LayerGroup parent, String name) { 32 | this(parent, name, MapMarkerCircle.getDefaultStyle()); 33 | } 34 | 35 | public AbstractLayer(LayerGroup parent, String name, Style style) { 36 | this(parent, name, null, style); 37 | } 38 | 39 | public AbstractLayer(LayerGroup parent, String name, String description, Style style) { 40 | setParent(parent); 41 | setName(name); 42 | setDescription(description); 43 | setStyle(style); 44 | setVisible(Boolean.TRUE); 45 | 46 | if (parent != null) parent.add(this); 47 | } 48 | 49 | public LayerGroup getParent() { 50 | return parent; 51 | } 52 | 53 | public void setParent(LayerGroup parent) { 54 | this.parent = parent; 55 | } 56 | 57 | public String getName() { 58 | return name; 59 | } 60 | 61 | public void setName(String name) { 62 | this.name = name; 63 | } 64 | 65 | public String getDescription() { 66 | return description; 67 | } 68 | 69 | public void setDescription(String description) { 70 | this.description = description; 71 | } 72 | 73 | public Style getStyle() { 74 | return style; 75 | } 76 | 77 | public void setStyle(Style style) { 78 | this.style = style; 79 | } 80 | 81 | public Boolean isVisible() { 82 | return visible; 83 | } 84 | 85 | public void setVisible(Boolean visible) { 86 | this.visible = visible; 87 | } 88 | 89 | public static List add(List list, E element) { 90 | if (element != null) { 91 | if (list == null) list = new ArrayList<>(); 92 | if (!list.contains(element)) list.add(element); 93 | } 94 | return list; 95 | } 96 | 97 | public Boolean isVisibleTexts() { 98 | return visibleTexts; 99 | } 100 | 101 | public void setVisibleTexts(Boolean visibleTexts) { 102 | this.visibleTexts = visibleTexts; 103 | } 104 | 105 | @Override 106 | public String toString() { 107 | return name; 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /src/ika/gui/SliderUtils.java: -------------------------------------------------------------------------------- 1 | package ika.gui; 2 | 3 | import java.awt.Component; 4 | import java.awt.Font; 5 | import java.util.Dictionary; 6 | import java.util.Enumeration; 7 | import java.util.Hashtable; 8 | import javax.swing.JLabel; 9 | import javax.swing.JSlider; 10 | 11 | public class SliderUtils { 12 | 13 | private SliderUtils() { 14 | } 15 | 16 | /** 17 | * Apply the font size to the labels of a slider. This must be called after 18 | * the labels of a slider are changed. 19 | * 20 | * First set up the label hash table and add it to the slider. Then, after 21 | * the slider has been added to a parent window and had its UI assigned, 22 | * call this method to change the label sizes. 23 | * 24 | * http://nadeausoftware.com/node/93#Settingsliderlabelfontsizes 25 | * 26 | * @param slider 27 | */ 28 | public static void reapplyFontSize(JSlider slider) { 29 | 30 | Font font = slider.getFont(); 31 | Dictionary dict = slider.getLabelTable(); 32 | Enumeration keys = dict.keys(); 33 | while (keys.hasMoreElements()) { 34 | Object key = keys.nextElement(); 35 | Component label = (Component) dict.get(key); 36 | label.setFont(font); 37 | label.setSize(label.getPreferredSize()); 38 | } 39 | 40 | } 41 | 42 | /** 43 | * Set the labels of a slider. 44 | * @param slider 45 | * @param values 46 | * @param labels 47 | */ 48 | public static void setSliderLabels(JSlider slider, int[] values, String[] labels) { 49 | 50 | assert (slider != null && values != null && labels != null); 51 | assert (values.length == labels.length); 52 | 53 | Hashtable labelTable = new Hashtable(); 54 | for (int i = 0; i < values.length; i++) { 55 | assert (values[i] >= slider.getMinimum()); 56 | assert (values[i] <= slider.getMaximum()); 57 | JLabel label = new JLabel(labels[i]); 58 | labelTable.put(new Integer(values[i]), label); 59 | } 60 | slider.setLabelTable(labelTable); 61 | } 62 | 63 | public static void addSuffixToSliderLabels(JSlider slider, String suffix) { 64 | 65 | assert (slider != null && suffix != null); 66 | 67 | Dictionary oldLabels = slider.getLabelTable(); 68 | Enumeration oldKeys = oldLabels.keys(); 69 | Hashtable newLabelTable = new Hashtable(); 70 | while (oldKeys.hasMoreElements()) { 71 | Object key = oldKeys.nextElement(); 72 | Object value = oldLabels.get(key); 73 | assert (value instanceof String); 74 | String str = ((String)value).concat(suffix); 75 | JLabel label = new JLabel(str); 76 | newLabelTable.put(key, label); 77 | } 78 | 79 | slider.setLabelTable(newLabelTable); 80 | } 81 | 82 | /** 83 | * Set the label for the minimum and the maximum value of a slider. The slider 84 | * will not show values for intermediate labels. 85 | * @param slider 86 | * @param labels 87 | */ 88 | public static void setMinMaxSliderLabels(JSlider slider, String[] labels) { 89 | setSliderLabels(slider, new int[] {slider.getMinimum(), slider.getMaximum()}, labels); 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /src/ika/map/tools/SelectionTool.java: -------------------------------------------------------------------------------- 1 | /* 2 | * SelectionTool.java 3 | * 4 | * Created on April 7, 2005, 7:21 PM 5 | */ 6 | 7 | package ika.map.tools; 8 | 9 | import java.awt.geom.*; 10 | import java.awt.event.*; 11 | import ika.geo.*; 12 | import ika.gui.MapComponent; 13 | 14 | /** 15 | * SelectionTool - a tool to select GeoObjects by mouse clicks and mouse drags. 16 | * @author Bernhard Jenny, Institute of Cartography, ETH Zurich. 17 | */ 18 | public class SelectionTool extends RectangleTool { 19 | 20 | /** 21 | * Tolerance for selection of objects by mouse clicks. 22 | */ 23 | protected static final int CLICK_PIXEL_TOLERANCE = 2; 24 | 25 | /** 26 | * Create a new instance. 27 | * @param mapComponent The MapComponent for which this MapTool provides its services. 28 | */ 29 | public SelectionTool(MapComponent mapComponent) { 30 | super(mapComponent); 31 | } 32 | 33 | /** 34 | * A drag ends, while this MapTool was the active one. 35 | * @param point The location of the mouse in world coordinates. 36 | * @param evt The original event. 37 | */ 38 | public void endDrag(Point2D.Double point, MouseEvent evt) { 39 | Rectangle2D.Double rect = this.getRectangle(); 40 | super.endDrag(point, evt); 41 | 42 | final GeoSet geoSet = mapComponent.getGeoSet(); 43 | final double scale = mapComponent.getScaleFactor(); 44 | final boolean extendSelection = evt.isShiftDown(); 45 | if (geoSet != null && rect != null) { 46 | geoSet.selectByRectangle(rect, scale, extendSelection); 47 | 48 | // inform MapToolActionListeners about action 49 | this.informMapToolActionListeners("Select"); 50 | } 51 | setDefaultCursor(); 52 | } 53 | 54 | /** 55 | * The mouse was clicked, while this MapTool was the active one. 56 | * @param point The location of the mouse in world coordinates. 57 | * @param evt The original event. 58 | */ 59 | public void mouseClicked(Point2D.Double point, MouseEvent evt) { 60 | //super.mouseClicked(point, evt); 61 | 62 | // try selecting objects close to the mouse click. 63 | final boolean selectionChanged = selectWithMouseClick(point, evt); 64 | 65 | // inform MapToolActionListeners about action 66 | if (selectionChanged) 67 | this.informMapToolActionListeners("Select"); 68 | } 69 | 70 | /** 71 | * Utility method that selects GeoObjects close to a mouse click. 72 | * @param point The location of the mouse in world coordinates. 73 | * @param evt The original event. 74 | * @return true if the selection state of any object has been changed. This 75 | * method also returns true, when an object has been deselected. 76 | */ 77 | protected boolean selectWithMouseClick(Point2D.Double point, MouseEvent evt) { 78 | GeoSet geoSet = mapComponent.getGeoSet(); 79 | if (geoSet == null) 80 | return false; 81 | final double scale = mapComponent.getScaleFactor(); 82 | final boolean extendSelection = evt.isShiftDown(); 83 | final double worldCoordTol = CLICK_PIXEL_TOLERANCE/scale; 84 | return geoSet.selectByPoint(point, scale, extendSelection, worldCoordTol); 85 | } 86 | 87 | protected String getCursorName() { 88 | return "selectionarrow"; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/ika/map/tools/ZoomInTool.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ZoomInTool.java 3 | * 4 | * Created on April 8, 2005, 12:16 PM 5 | */ 6 | 7 | package ika.map.tools; 8 | 9 | import java.awt.*; 10 | import java.awt.geom.*; 11 | import java.awt.event.*; 12 | import ika.utils.*; 13 | import ika.gui.MapComponent; 14 | import java.util.Timer; 15 | import java.util.TimerTask; 16 | 17 | /** 18 | * ZoomInTool - a tool to zoom in a map. 19 | * @author Bernhard Jenny, Institute of Cartography, ETH Zurich. 20 | */ 21 | public class ZoomInTool extends RectangleTool { 22 | 23 | /** 24 | * If the user presses the right mouse button, zoom out and show the 25 | * zoom-out cursor for this long. Unit: milliseconds. 26 | */ 27 | private static final long ZOOM_OUT_CURSOR_VISIBLE_TIME = 500; 28 | 29 | /** 30 | * Create a new instance. 31 | * @param mapComponent The MapComponent for which this MapTool provides its services. 32 | */ 33 | public ZoomInTool(MapComponent mapComponent) { 34 | super(mapComponent); 35 | } 36 | 37 | /** 38 | * The mouse was clicked, while this MapTool was the active one. 39 | * @param point The location of the mouse in world coordinates. 40 | * @param evt The original event. 41 | */ 42 | public void mouseClicked(Point2D.Double point, MouseEvent evt) { 43 | super.mouseClicked(point, evt); 44 | // make behaviour dependent on mousebutton (thanks to Geert Kloosterman) 45 | if (evt.getButton() == MouseEvent.BUTTON1) 46 | mapComponent.zoomIn(point); 47 | else if (evt.getButton() != MouseEvent.NOBUTTON){ 48 | this.showTemporaryZoomOutCursorIcon(); 49 | mapComponent.zoomOut(point); 50 | } 51 | } 52 | 53 | /** 54 | * A drag ends, while this MapTool was the active one. 55 | * @param point The location of the mouse in world coordinates. 56 | * @param evt The original event. 57 | */ 58 | public void endDrag(Point2D.Double point, MouseEvent evt) { 59 | Rectangle2D.Double rect = this.getRectangle(); 60 | boolean rectangleIsLargeEnough = isRectangleLargeEnough(); 61 | super.endDrag(point, evt); 62 | 63 | // Geert Kloosterman: make behaviour dependent on mousebutton 64 | if (rectangleIsLargeEnough) { 65 | if (evt.getButton() == MouseEvent.BUTTON1) { 66 | mapComponent.zoomOnRectangle(rect); 67 | } else if (evt.getButton() != MouseEvent.NOBUTTON) { 68 | this.showTemporaryZoomOutCursorIcon(); 69 | mapComponent.zoomOut(point); 70 | } 71 | } 72 | } 73 | 74 | private void showTemporaryZoomOutCursorIcon() { 75 | // temporarily change the mouse-cursor to the zoom-out icon 76 | CursorUtils.setCursor("zoomout", this.mapComponent); 77 | final String zoomoutCursorName = mapComponent.getCursor().getName(); 78 | System.out.println(zoomoutCursorName); 79 | new Timer().schedule(new TimerTask(){ 80 | public void run() { 81 | Cursor currentCursor = mapComponent.getCursor(); 82 | if (zoomoutCursorName.equals(currentCursor.getName())) 83 | CursorUtils.setCursor("zoomin", mapComponent); 84 | } 85 | }, ZOOM_OUT_CURSOR_VISIBLE_TIME); 86 | } 87 | 88 | protected String getCursorName() { 89 | return "zoomin"; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/ika/proj/ProjectionsManager.java: -------------------------------------------------------------------------------- 1 | package ika.proj; 2 | 3 | import com.jhlabs.map.Ellipsoid; 4 | import com.jhlabs.map.proj.MercatorProjection; 5 | import com.jhlabs.map.proj.Projection; 6 | import com.jhlabs.map.proj.ProjectionFactory; 7 | import ika.geo.osm.OpenStreetMap; 8 | import java.io.BufferedInputStream; 9 | import java.io.BufferedReader; 10 | import java.io.IOException; 11 | import java.io.InputStreamReader; 12 | import java.util.Vector; 13 | 14 | /** 15 | * 16 | * @author Bernhard Jenny, Institute of Cartography, ETH Zurich 17 | */ 18 | public class ProjectionsManager { 19 | 20 | private static Vector list; 21 | 22 | private ProjectionsManager() { 23 | } 24 | 25 | public static int getProjectionID(String name) { 26 | if (ProjectionsManager.list == null) { 27 | loadProjectionsFromFile(); 28 | } 29 | return list.indexOf(name); 30 | } 31 | 32 | public static String getProjectionName(int id) { 33 | if (ProjectionsManager.list == null) { 34 | loadProjectionsFromFile(); 35 | } 36 | return list.get(id).toString(); 37 | } 38 | 39 | public static Vector getProjections() { 40 | if (ProjectionsManager.list == null) { 41 | loadProjectionsFromFile(); 42 | } 43 | return list; 44 | } 45 | 46 | private static void loadProjectionsFromFile() { 47 | BufferedReader reader = null; 48 | try { 49 | list = new Vector<>(); 50 | 51 | // load projection description 52 | java.net.URL url = ProjectionsManager.class.getResource("/ika/data/projections.txt"); 53 | BufferedInputStream bis = new BufferedInputStream(url.openStream()); 54 | InputStreamReader isr = new InputStreamReader(bis, "UTF-8"); 55 | reader = new BufferedReader(isr); 56 | String line; 57 | while ((line = reader.readLine()) != null) { 58 | line = line.trim(); 59 | // double slash is a comment 60 | if (line.startsWith("//")) { 61 | continue; 62 | } 63 | String proj4Code = line.split(" ")[0]; 64 | Projection p = ProjectionFactory.getNamedPROJ4Projection(proj4Code); 65 | if (p != null) { 66 | list.add(p); 67 | } 68 | } 69 | } catch (IOException e) { 70 | e.printStackTrace(); 71 | list = null; 72 | } finally { 73 | if (reader != null) { 74 | try { 75 | reader.close(); 76 | } catch (IOException ex) { 77 | ex.printStackTrace(); 78 | } 79 | } 80 | } 81 | } 82 | 83 | /** 84 | * Creates and initializes a Mercator projection with a spherical coordinate 85 | * system commonly used by web map services, such as OpenStreetMap. 86 | * 87 | * @return a new Mercator projection for web maps 88 | */ 89 | public static MercatorProjection createWebMercatorProjection() { 90 | MercatorProjection mercator = new MercatorProjection(); 91 | mercator.setMaxLatitude(OpenStreetMap.MAX_LAT); 92 | mercator.setMinLatitude(OpenStreetMap.MIN_LAT); 93 | Ellipsoid osmSphere = new Ellipsoid("osm", OpenStreetMap.R, OpenStreetMap.R, 0.0, "OSM Sphere"); 94 | mercator.setEllipsoid(osmSphere); 95 | mercator.initialize(); 96 | return mercator; 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/ika/map/tools/PanTool.java: -------------------------------------------------------------------------------- 1 | /* 2 | * SelectionTool.java 3 | * 4 | * Created on April 7, 2005, 7:21 PM 5 | */ 6 | 7 | package ika.map.tools; 8 | 9 | import java.awt.geom.*; 10 | import java.awt.event.*; 11 | import ika.utils.*; 12 | import ika.gui.MapComponent; 13 | 14 | /** 15 | * PanTool - a tool to pan a map with the mouse. 16 | * @author Bernhard Jenny, Institute of Cartography, ETH Zurich. 17 | */ 18 | public class PanTool extends MapTool{ 19 | 20 | /** 21 | * Store the start position of the panning. 22 | */ 23 | private Point2D.Double dragStartPos; 24 | 25 | /** Creates a new instance of SelectionTool 26 | * @param mapComponent The MapComponent for which this MapTool provides its services. 27 | */ 28 | public PanTool(MapComponent mapComponent) { 29 | super(mapComponent); 30 | } 31 | 32 | /** 33 | * Utility method to set the cursor icon to a closed hand. 34 | */ 35 | private void setClosedHandCursor() { 36 | final String iconName = "panclicked"; 37 | CursorUtils.setCursor(iconName, mapComponent); 38 | } 39 | 40 | /** 41 | * The mouse was pressed down, while this MapTool was the active one. 42 | * @param point The location of the mouse in world coordinates. 43 | * @param evt The original event. 44 | */ 45 | public void mouseDown(Point2D.Double point, MouseEvent evt) { 46 | // change cursor to closed hand 47 | setClosedHandCursor(); 48 | } 49 | 50 | /** 51 | * The mouse was clicked, while this MapTool was the active one. 52 | * @param point The location of the mouse in world coordinates. 53 | * @param evt The original event. 54 | */ 55 | public void mouseClicked(Point2D.Double point, MouseEvent evt) { 56 | setDefaultCursor(); 57 | } 58 | 59 | /** 60 | * The mouse starts a drag, while this MapTool is the active one. 61 | * @param point The location of the mouse in world coordinates. 62 | * @param evt The original event. 63 | */ 64 | public void startDrag(Point2D.Double point, MouseEvent evt) { 65 | // store the start location of the drag. 66 | this.dragStartPos = (Point2D.Double)point.clone(); 67 | } 68 | 69 | /** 70 | * The mouse location changed during a drag, while this MapTool was the 71 | * active tool. 72 | * @param point The location of the mouse in world coordinates. 73 | * @param evt The original event. 74 | */ 75 | public void updateDrag(Point2D.Double point, MouseEvent evt) { 76 | // just in case we didn't get a mousePressed-Event 77 | if (dragStartPos == null) { 78 | dragStartPos = (Point2D.Double)point.clone(); 79 | return; 80 | } 81 | 82 | // do the panning 83 | final double dx = dragStartPos.getX() - point.getX(); 84 | final double dy = dragStartPos.getY() - point.getY(); 85 | mapComponent.offsetVisibleArea(dx, dy); 86 | } 87 | 88 | /** 89 | * A drag ends, while this MapTool was the active one. 90 | * @param point The location of the mouse in world coordinates. 91 | * @param evt The original event. 92 | */ 93 | public void endDrag(Point2D.Double point, MouseEvent evt) { 94 | this.dragStartPos = null; 95 | 96 | // change cursor to open hand 97 | setDefaultCursor(); 98 | } 99 | 100 | protected String getCursorName() { 101 | return "pan"; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/ika/mapanalyst/Main.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Main.java 3 | * 4 | * Created on November 1, 2005, 10:19 AM 5 | * 6 | */ 7 | package ika.mapanalyst; 8 | 9 | import javax.swing.*; 10 | import ika.gui.*; 11 | import ika.utils.ErrorDialog; 12 | import ika.utils.TextWindow; 13 | import java.io.PrintWriter; 14 | import java.io.StringWriter; 15 | import java.util.logging.Level; 16 | import java.util.logging.Logger; 17 | 18 | /** 19 | * Main entry point for MapAnalyst. 20 | * 21 | * @author Bernie Jenny, Faculty of Information Technology, Monash University 22 | */ 23 | public class Main { 24 | 25 | /** 26 | * main routine for the application. 27 | * @param args the command line arguments 28 | */ 29 | public static void main(String args[]) { 30 | 31 | // on Mac OS X: take the menu bar out of the window and put it on top 32 | // of the main screen. 33 | if (ika.utils.Sys.isMacOSX()) { 34 | System.setProperty("apple.laf.useScreenMenuBar", "true"); 35 | } 36 | 37 | try { 38 | // use the standard look and feel 39 | UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 40 | } catch (Throwable ex) { 41 | Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); 42 | } 43 | 44 | // set icon for JOptionPane dialogs. This is done automatically on Mac 10.5 and later 45 | Main.setOptionPaneIcons("logo48x48.gif"); 46 | 47 | SwingUtilities.invokeLater(new Runnable() { 48 | 49 | @Override 50 | public void run() { 51 | try { 52 | if (ika.utils.Sys.isMacOSX()) { 53 | MacWindowsManager.emptyWindow = new MacWindowsManager(); 54 | } 55 | MainWindow.newProject(); 56 | } catch (Exception exc) { 57 | Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, exc); 58 | String msg = "An error occured."; 59 | String title = "MapAnalyst Error"; 60 | ErrorDialog.showErrorDialog(msg, title, exc, null); 61 | 62 | StringWriter sw = new StringWriter(); 63 | sw.write(title); 64 | sw.write(System.getProperty("line.separator")); 65 | sw.write("Please send this report to the author of MapAnalyst."); 66 | sw.write(System.getProperty("line.separator")); 67 | PrintWriter pw = new PrintWriter(sw); 68 | exc.printStackTrace(pw); 69 | pw.flush(); 70 | new TextWindow(null, true, true, sw.toString(), title); 71 | } 72 | } 73 | }); 74 | } 75 | 76 | /** 77 | * Changes the icon displayed in JOptionPane dialogs to the passed icon. 78 | * Error, information, question and warning dialogs will show this icon. 79 | * This will also replace the icon in ProgressMonitor dialogs. 80 | */ 81 | private static void setOptionPaneIcons(String iconName) { 82 | String iconPath = "/ika/icons/" + iconName; 83 | LookAndFeel lf = UIManager.getLookAndFeel(); 84 | if (lf != null) { 85 | Class iconBaseClass = lf.getClass(); 86 | Object appIcon = LookAndFeel.makeIcon(iconBaseClass, iconPath); 87 | UIManager.put("OptionPane.errorIcon", appIcon); 88 | UIManager.put("OptionPane.informationIcon", appIcon); 89 | UIManager.put("OptionPane.questionIcon", appIcon); 90 | UIManager.put("OptionPane.warningIcon", appIcon); 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/ika/geoexport/UngenerateExporter.java: -------------------------------------------------------------------------------- 1 | package ika.geoexport; 2 | 3 | import java.io.*; 4 | import java.awt.geom.*; 5 | import ika.geo.*; 6 | 7 | /** 8 | * Exporter for the ESRI Ungenerate file format.
9 | * Ungenerate is a very simple text format for spaghetti data. 10 | * @author Bernhard Jenny, Institute of Cartography, ETH Zurich. 11 | */ 12 | public class UngenerateExporter extends GeoSetExporter { 13 | 14 | public UngenerateExporter(double mapScale){ 15 | super (mapScale); 16 | } 17 | 18 | public void export(GeoSet geoSet, String filePath) throws IOException { 19 | if (geoSet == null || filePath == null) 20 | throw new IllegalArgumentException(); 21 | this.writeLines(geoSet, filePath); 22 | } 23 | 24 | /** 25 | * An internal helper method that writes to a PrintWriter. 26 | */ 27 | private int writeLines(GeoSet geoSet, PrintWriter writer, int id) { 28 | if (geoSet.isVisible() == false) 29 | return id; 30 | 31 | final int numberOfChildren = geoSet.getNumberOfChildren(); 32 | for (int i = 0; i < numberOfChildren; i++) { 33 | GeoObject geoObject = geoSet.getGeoObject(i); 34 | 35 | // only write visible objects 36 | if (geoObject.isVisible() == false) 37 | continue; 38 | 39 | if (geoObject instanceof GeoPath) { 40 | GeoPath geoPath = (GeoPath)geoObject; 41 | if (geoPath.getNumberOfSegments() < 2) { 42 | continue; 43 | } 44 | PathIterator iterator = geoPath.getPathIterator(null, flatness); 45 | double [] coordinates = new double [6]; 46 | boolean firstMove = true; 47 | while (!iterator.isDone()) { 48 | final int type = iterator.currentSegment(coordinates); 49 | switch (type) { 50 | case PathIterator.SEG_MOVETO: 51 | if (firstMove) 52 | firstMove = false; 53 | else 54 | writer.println("end"); 55 | writer.println(id++); 56 | // fall thru 57 | case PathIterator.SEG_LINETO: 58 | writer.println(Double.toString(coordinates[0]) 59 | + "\t" + Double.toString(coordinates[1])); 60 | break; 61 | } 62 | iterator.next(); 63 | } 64 | writer.println("end"); 65 | } else if (geoObject instanceof GeoSet) { 66 | GeoSet childGeoSet = (GeoSet)geoObject; 67 | id = writeLines(childGeoSet, writer, id); 68 | } 69 | } 70 | return id; 71 | } 72 | 73 | /** 74 | * Writes GeoPaths contained in a GeoSet to an Ungenerate file. 75 | * @param geoSet The GeoSet containing the GeoPaths to export. 76 | * @param filePath The path to the file. 77 | */ 78 | private void writeLines(GeoSet geoSet, String filePath) 79 | throws IOException { 80 | if (geoSet.getNumberOfChildren() == 0) 81 | throw new IllegalArgumentException(); 82 | 83 | PrintWriter writer = new PrintWriter(new BufferedWriter( 84 | new FileWriter(filePath))); 85 | this.writeLines(geoSet, writer, 0); 86 | writer.println("end"); 87 | writer.close(); 88 | } 89 | 90 | @Override 91 | public String getFileExtension() { 92 | return "lin"; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/ika/geoexport/ShapeExporter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ShapeExporter.java 3 | * 4 | * Created on April 13, 2007, 3:41 PM 5 | * 6 | */ 7 | 8 | package ika.geoexport; 9 | 10 | import ika.geo.GeoSet; 11 | import java.io.FileOutputStream; 12 | import java.io.IOException; 13 | import java.io.OutputStream; 14 | 15 | /** 16 | * 17 | * @author Bernhard Jenny, Institute of Cartography, ETH Zurich. 18 | */ 19 | public class ShapeExporter extends GeoSetExporter { 20 | 21 | private ShapeGeometryExporter shapeGeometryExporter; 22 | 23 | private boolean shapeTypeSet = false; 24 | 25 | /** Creates a new instance of ShapeExporter */ 26 | public ShapeExporter(double mapScale){ 27 | super(mapScale); 28 | this.shapeGeometryExporter = new ShapeGeometryExporter(mapScale); 29 | } 30 | 31 | public String getFileFormatName() { 32 | return "Shape"; 33 | } 34 | 35 | public String getFileExtension() { 36 | return "shp"; 37 | } 38 | 39 | protected void export(GeoSet geoSet, OutputStream outputStream) 40 | throws IOException { 41 | 42 | if (!this.shapeTypeSet) 43 | shapeGeometryExporter.setShapeTypeFromFirstGeoObject(geoSet); 44 | shapeGeometryExporter.export(geoSet, outputStream); 45 | 46 | } 47 | 48 | public int getFeatureCount() { 49 | return this.shapeGeometryExporter.getWrittenRecordCount(); 50 | } 51 | 52 | public void exportTableForGeometry(String geometryFilePath, 53 | Table table, GeoSet geoSet) throws IOException { 54 | 55 | FileOutputStream dbfOutputStream = null; 56 | FileOutputStream shxOutputStream = null; 57 | 58 | try { 59 | String dbfPath = ika.utils.FileUtils.replaceExtension(geometryFilePath, "dbf"); 60 | dbfOutputStream = new FileOutputStream(dbfPath); 61 | new DBFExporter().exportTable(dbfOutputStream, table); 62 | 63 | String shxPath = ika.utils.FileUtils.replaceExtension(geometryFilePath, "shx"); 64 | shxOutputStream = new FileOutputStream(shxPath); 65 | shapeGeometryExporter.writeSHXFile(shxOutputStream, geoSet); 66 | 67 | } finally { 68 | if (dbfOutputStream != null) 69 | dbfOutputStream.close(); 70 | if (shxOutputStream != null) 71 | shxOutputStream.close(); 72 | } 73 | } 74 | 75 | @Override 76 | public void setPathFlatness(double flatness) { 77 | super.setPathFlatness(flatness); 78 | this.shapeGeometryExporter.setPathFlatness(flatness); 79 | } 80 | 81 | /** 82 | * Set the type of shape file that will be generated. Valid values are 83 | * POINT_SHAPE_TYPE, POLYLINE_SHAPE_TYPE, and POLYGON_SHAPE_TYPE. 84 | * The default value is POLYLINE_SHAPE_TYPE. 85 | */ 86 | public void setShapeType(int shapeType) { 87 | 88 | this.shapeTypeSet = true; 89 | this.shapeGeometryExporter.setShapeType(shapeType); 90 | 91 | } 92 | 93 | public final void export (GeoSet geoSet, String filePath) throws IOException { 94 | 95 | if (geoSet == null || filePath == null) 96 | throw new IllegalArgumentException(); 97 | 98 | OutputStream outputStream = null; 99 | try { 100 | outputStream = new FileOutputStream(filePath); 101 | this.export(geoSet, outputStream); 102 | } finally { 103 | if (outputStream != null) 104 | outputStream.close(); 105 | } 106 | 107 | } 108 | 109 | } 110 | -------------------------------------------------------------------------------- /src/ika/gui/GeoObjectInfoPanel.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /src/ika/geoexport/RasterImageExporter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * RasterImageExporter.java 3 | * 4 | * Created on June 29, 2005, 12:01 PM 5 | */ 6 | 7 | package ika.geoexport; 8 | 9 | import java.io.*; 10 | import java.awt.*; 11 | import java.awt.geom.*; 12 | import java.awt.image.*; 13 | import javax.imageio.*; 14 | import ika.geo.*; 15 | import ika.utils.FileUtils; 16 | 17 | /** 18 | * 19 | * @author jenny 20 | */ 21 | public class RasterImageExporter extends GeoSetExporter { 22 | 23 | private static final int MAX_IMAGE_DIM = 32000; 24 | 25 | private int imageWidth; 26 | private String format; 27 | 28 | /** Creates a new instance of RasterImageExporter */ 29 | public RasterImageExporter(double mapScale) { 30 | super (mapScale); 31 | imageWidth = 1000; 32 | format = "jpg"; 33 | } 34 | 35 | public void export(GeoSet geoSet, String filePath) throws IOException { 36 | if (geoSet == null || filePath == null) 37 | throw new IllegalArgumentException(); 38 | 39 | filePath = FileUtils.forceFileNameExtension(filePath, format); 40 | 41 | // Create an image to save 42 | Rectangle2D bounds = geoSet.getBounds2D(true); 43 | final int imageHeight = 44 | (int)Math.ceil(bounds.getHeight() / bounds.getWidth() * imageWidth); 45 | 46 | if (imageWidth > MAX_IMAGE_DIM || imageHeight > MAX_IMAGE_DIM) { 47 | throw new IOException("The raster image is too large to export."); 48 | } 49 | 50 | // Create a buffered image in which to draw 51 | BufferedImage bufferedImage = new BufferedImage(imageWidth, imageHeight, 52 | BufferedImage.TYPE_INT_RGB); 53 | 54 | // Create a graphics context on the buffered image 55 | Graphics2D g2d = bufferedImage.createGraphics(); 56 | 57 | // set white background 58 | g2d.setColor(Color.white); 59 | g2d.fillRect(0, 0, imageWidth, imageHeight); 60 | 61 | // enable antialiasing 62 | g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, 63 | RenderingHints.VALUE_ANTIALIAS_ON); 64 | // enable high quality rendering 65 | g2d.setRenderingHint(RenderingHints.KEY_RENDERING, 66 | RenderingHints.VALUE_RENDER_QUALITY); 67 | // enable bicubic interpolation of images 68 | g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, 69 | RenderingHints.VALUE_INTERPOLATION_BILINEAR); 70 | g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, 71 | RenderingHints.VALUE_STROKE_PURE); 72 | 73 | final double scale = imageWidth / bounds.getWidth(); 74 | g2d.translate(-bounds.getMinX() * scale, bounds.getMaxY() * scale); 75 | g2d.scale(scale, -scale); 76 | 77 | // set default appearance of vector elements 78 | g2d.setStroke(new BasicStroke(1)); 79 | g2d.setColor(Color.black); 80 | 81 | 82 | // draw the map tree 83 | geoSet.draw(g2d, this.mapScale, false); 84 | 85 | // Graphics context no longer needed so dispose it 86 | g2d.dispose(); 87 | 88 | // Write generated image to a raster image file 89 | File file = new File(filePath); 90 | ImageIO.write(bufferedImage, format, file); 91 | } 92 | 93 | public int getImageWidth() { 94 | return imageWidth; 95 | } 96 | 97 | public void setImageWidth(int imageWidth) { 98 | this.imageWidth = imageWidth; 99 | } 100 | 101 | public String getFormat() { 102 | return format; 103 | } 104 | 105 | public void setFormat(String format) { 106 | this.format = format; 107 | } 108 | 109 | @Override 110 | public String getFileExtension() { 111 | return this.format; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/ika/mapanalystonline/MapAnalystHeadless.java: -------------------------------------------------------------------------------- 1 | package ika.mapanalystonline; 2 | 3 | import ika.geo.GeoSet; 4 | import ika.geoexport.GeoJSONExporter; 5 | import ika.mapanalyst.Manager; 6 | import ika.mapanalyst.MapAnalyzer; 7 | import ika.transformation.Transformation; 8 | import ika.utils.CoordinateFormatter; 9 | import ika.utils.NumberFormatter; 10 | import java.io.PrintWriter; 11 | import java.text.SimpleDateFormat; 12 | import java.util.Calendar; 13 | 14 | /** 15 | * 16 | * @author Bernhard Jenny, Institute of Cartography, ETH Zurich 17 | */ 18 | public class MapAnalystHeadless { 19 | 20 | public static final String DATE_FORMAT_NOW = "yyyy-MM-dd HH:mm:ss"; 21 | 22 | public enum VisType { 23 | 24 | GRID, VECTOR, SCALE_ROT 25 | }; 26 | 27 | private static String getScaleRotInfo(Manager manager) { 28 | Transformation trans = manager.getTransformation(); 29 | if (trans == null || !manager.isTransformationInitialized()) { 30 | return "-; -"; 31 | } 32 | final boolean invert = manager.isShowInOldMap(); 33 | String scaleStr = NumberFormatter.formatScale(null, trans.getScale(invert)); 34 | String rotStr = trans.formatRotation(null, trans.getRotation(invert)); 35 | return scaleStr + "; " + rotStr; 36 | } 37 | 38 | public static void computeVisualization( 39 | String points, 40 | VisType visType, 41 | boolean forOldMap, 42 | double dpi, 43 | double bezierTolerance, 44 | double gridCellSize, 45 | boolean oldPointsInPixel, 46 | PrintWriter writer) throws Exception { 47 | 48 | double pixelSize = 2.54 / 100. / dpi; 49 | Manager manager = new Manager(); 50 | 51 | // import the points 52 | manager.importLinksFromString(points, null); 53 | if(!manager.getLinkManager().hasEnoughLinkedPointsForComputation()) { 54 | throw new IllegalStateException("not enough points"); 55 | } 56 | 57 | // convert from pixels to meters if necessary 58 | if (oldPointsInPixel) { 59 | manager.getLinkManager().scaleLinkedPointsInOldMap(pixelSize); 60 | } 61 | 62 | // compute visualization for coordinate system of old or new map 63 | manager.setShowInOldMap(forOldMap); 64 | 65 | // init visualzations 66 | CoordinateFormatter cf = new CoordinateFormatter("###,##0.00", "###,##0", 1); 67 | manager.getDistortionGrid().setMeshSize(gridCellSize); 68 | manager.analyzeMap(cf, cf, null); 69 | MapAnalyzer analyser = null; 70 | switch (visType) { 71 | case GRID: 72 | analyser = manager.getDistortionGrid(); 73 | break; 74 | case VECTOR: 75 | analyser = manager.getErrorVectors(); 76 | break; 77 | case SCALE_ROT: 78 | // return simple string 79 | writer.println(MapAnalystHeadless.getScaleRotInfo(manager)); 80 | return; 81 | } 82 | 83 | // compute visualizations 84 | GeoSet visGeoSet = forOldMap ? analyser.getOldGeoSet() : analyser.getNewGeoSet(); 85 | 86 | // scale geometry to convert from meter to pixels 87 | if (forOldMap && oldPointsInPixel) { 88 | visGeoSet.scale(1. / pixelSize); 89 | } 90 | 91 | // export to GeoJSON 92 | GeoJSONExporter exporter = new GeoJSONExporter(1); 93 | exporter.setPathFlatness(bezierTolerance); 94 | exporter.addProperty("title", analyser.getName()); 95 | exporter.addProperty("author", "MapAnalystOnline"); 96 | SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW); 97 | String date = sdf.format(Calendar.getInstance().getTime()); 98 | exporter.addProperty("date", date); 99 | exporter.export(visGeoSet, writer, true); 100 | 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/tilesources/OsmTileSource.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer.tilesources; 3 | 4 | import java.io.IOException; 5 | 6 | import org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate; 7 | 8 | /** 9 | * OSM Tile source. 10 | */ 11 | public class OsmTileSource { 12 | 13 | /** 14 | * The default "Mapnik" OSM tile source. 15 | */ 16 | public static class Mapnik extends AbstractOsmTileSource { 17 | 18 | private static final String PATTERN = "https://%s.tile.openstreetmap.org"; 19 | 20 | private static final String[] SERVER = {"a", "b", "c"}; 21 | 22 | private int serverNum; 23 | 24 | /** 25 | * Constructs a new {@code "Mapnik"} tile source. 26 | */ 27 | public Mapnik() { 28 | super("OpenStreetMap Carto", PATTERN, "standard"); 29 | modTileFeatures = true; 30 | } 31 | 32 | @Override 33 | public String getBaseUrl() { 34 | String url = String.format(this.baseUrl, new Object[] {SERVER[serverNum]}); 35 | serverNum = (serverNum + 1) % SERVER.length; 36 | return url; 37 | } 38 | } 39 | 40 | /** 41 | * The "Cycle Map" OSM tile source. 42 | */ 43 | public abstract static class CycleMap extends AbstractOsmTileSource { 44 | 45 | private static final String PATTERN = "https://%s.tile.thunderforest.com/cycle"; 46 | 47 | private static final String[] SERVER = {"a", "b", "c"}; 48 | 49 | private int serverNum; 50 | 51 | /** 52 | * Constructs a new {@code CycleMap} tile source. 53 | */ 54 | public CycleMap() { 55 | super("OpenCycleMap", PATTERN, "opencyclemap"); 56 | } 57 | 58 | @Override 59 | public String getBaseUrl() { 60 | String url = String.format(this.baseUrl, new Object[] {SERVER[serverNum]}); 61 | serverNum = (serverNum + 1) % SERVER.length; 62 | return url; 63 | } 64 | 65 | /** 66 | * Get the thunderforest API key. 67 | * 68 | * Needs to be registered at their web site. 69 | * @return the API key 70 | */ 71 | protected abstract String getApiKey(); 72 | 73 | @Override 74 | public int getMaxZoom() { 75 | return 18; 76 | } 77 | 78 | @Override 79 | public String getTileUrl(int zoom, int tilex, int tiley) throws IOException { 80 | return this.getBaseUrl() + getTilePath(zoom, tilex, tiley) + "?apikey=" + getApiKey(); 81 | } 82 | 83 | @Override 84 | public String getTermsOfUseText() { 85 | return "Maps © Thunderforest"; 86 | } 87 | 88 | @Override 89 | public String getTermsOfUseURL() { 90 | return "https://thunderforest.com/terms/"; 91 | } 92 | } 93 | 94 | /** 95 | * The "Transport Map" OSM tile source. 96 | */ 97 | public static class TransportMap extends AbstractOsmTileSource { 98 | 99 | /** 100 | * Constructs a new {@code TransportMap} tile source. 101 | */ 102 | public TransportMap() { 103 | super("Public Transport", "https://tile.memomaps.de/tilegen", "public_transport_oepnv"); 104 | } 105 | 106 | @Override 107 | public int getMaxZoom() { 108 | return 18; 109 | } 110 | 111 | @Override 112 | public String getAttributionText(int zoom, ICoordinate topLeft, ICoordinate botRight) { 113 | return "© OpenStreetMap contributors, CC-BY-SA"; 114 | } 115 | 116 | @Override 117 | public String getAttributionLinkURL() { 118 | return "https://öpnvkarte.de/<"; 119 | } 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/checkBoxTree/CheckBoxNodeEditor.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer.checkBoxTree; 3 | 4 | import java.awt.Component; 5 | import java.awt.event.ItemEvent; 6 | import java.awt.event.ItemListener; 7 | import java.awt.event.MouseAdapter; 8 | import java.awt.event.MouseEvent; 9 | import java.util.EventObject; 10 | 11 | import javax.swing.AbstractCellEditor; 12 | import javax.swing.JTree; 13 | import javax.swing.tree.DefaultMutableTreeNode; 14 | import javax.swing.tree.TreeCellEditor; 15 | import javax.swing.tree.TreePath; 16 | 17 | /** 18 | * Editor for checkBox Tree 19 | * 20 | * @author galo 21 | */ 22 | public class CheckBoxNodeEditor extends AbstractCellEditor implements TreeCellEditor { 23 | /** SerialVersionUID */ 24 | private static final long serialVersionUID = -8921320784224636657L; 25 | 26 | private final CheckBoxNodeRenderer renderer = new CheckBoxNodeRenderer(); 27 | 28 | private final CheckBoxTree theTree; 29 | 30 | public CheckBoxNodeEditor(final CheckBoxTree tree) { 31 | theTree = tree; 32 | } 33 | 34 | @Override 35 | public Object getCellEditorValue() { 36 | final CheckBoxNodePanel panel = renderer.getPanel(); 37 | /*final CheckBoxNodeData checkBoxNode = 38 | new CheckBoxNodeData(panel.label.getText(), panel.check.isSelected()); 39 | return checkBoxNode; 40 | CheckBoxNodeData data = search(theTree.rootNode(), panel.label.getText()); 41 | data.setSelected(panel.check.isSelected());*/ 42 | return panel.getData(); 43 | } 44 | /*public CheckBoxNodeData search(DefaultMutableTreeNode node, String name){ 45 | CheckBoxNodeData data = CheckBoxTree.data(node); 46 | if(data.getText().equals(name)) return data; 47 | else{ 48 | data = null; 49 | for(int i=0; i points; 23 | 24 | public MapPolygonImpl(ICoordinate... points) { 25 | this(null, null, points); 26 | } 27 | 28 | public MapPolygonImpl(List points) { 29 | this(null, null, points); 30 | } 31 | 32 | public MapPolygonImpl(String name, List points) { 33 | this(null, name, points); 34 | } 35 | 36 | public MapPolygonImpl(String name, ICoordinate... points) { 37 | this(null, name, points); 38 | } 39 | 40 | public MapPolygonImpl(Layer layer, List points) { 41 | this(layer, null, points); 42 | } 43 | 44 | public MapPolygonImpl(Layer layer, String name, List points) { 45 | this(layer, name, points, getDefaultStyle()); 46 | } 47 | 48 | public MapPolygonImpl(Layer layer, String name, ICoordinate... points) { 49 | this(layer, name, Arrays.asList(points), getDefaultStyle()); 50 | } 51 | 52 | public MapPolygonImpl(Layer layer, String name, List points, Style style) { 53 | super(layer, name, style); 54 | this.points = points; 55 | } 56 | 57 | @Override 58 | public List getPoints() { 59 | return this.points; 60 | } 61 | 62 | @Override 63 | public void paint(Graphics g, List points) { 64 | Polygon polygon = new Polygon(); 65 | for (Point p : points) { 66 | polygon.addPoint(p.x, p.y); 67 | } 68 | paint(g, polygon); 69 | } 70 | 71 | @Override 72 | public void paint(Graphics g, Polygon polygon) { 73 | // Prepare graphics 74 | Color oldColor = g.getColor(); 75 | g.setColor(getColor()); 76 | 77 | Stroke oldStroke = null; 78 | if (g instanceof Graphics2D) { 79 | Graphics2D g2 = (Graphics2D) g; 80 | oldStroke = g2.getStroke(); 81 | g2.setStroke(getStroke()); 82 | } 83 | // Draw 84 | g.drawPolygon(polygon); 85 | if (g instanceof Graphics2D && getBackColor() != null) { 86 | Graphics2D g2 = (Graphics2D) g; 87 | Composite oldComposite = g2.getComposite(); 88 | g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER)); 89 | g2.setPaint(getBackColor()); 90 | g2.fillPolygon(polygon); 91 | g2.setComposite(oldComposite); 92 | } 93 | // Restore graphics 94 | g.setColor(oldColor); 95 | if (g instanceof Graphics2D) { 96 | ((Graphics2D) g).setStroke(oldStroke); 97 | } 98 | Rectangle rec = polygon.getBounds(); 99 | Point corner = rec.getLocation(); 100 | Point p = new Point(corner.x+(rec.width/2), corner.y+(rec.height/2)); 101 | if (getLayer() == null || getLayer().isVisibleTexts()) paintText(g, p); 102 | } 103 | 104 | public static Style getDefaultStyle() { 105 | return new Style(Color.BLUE, new Color(100, 100, 100, 50), new BasicStroke(2), getDefaultFont()); 106 | } 107 | 108 | @Override 109 | public String toString() { 110 | return "MapPolygon [points=" + points + ']'; 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /src/ika/transformation/robustestimator/HampelEstimator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * HampelEstimator.java 3 | * 4 | * Created on April 18, 2005, 6:40 PM 5 | */ 6 | 7 | package ika.transformation.robustestimator; 8 | 9 | 10 | 11 | /** 12 | * Robust Hampel estimator 13 | * @author Bernhard Jenny
14 | * Institute of Cartography
15 | * ETH Zurich
16 | */ 17 | public class HampelEstimator extends RobustEstimator implements java.io.Serializable { 18 | 19 | private static final long serialVersionUID = -4205700373276056184L; 20 | 21 | /** 22 | * Parameter a 23 | */ 24 | private double a = 1; 25 | 26 | private double minA = 0.0; 27 | 28 | private double maxA = 4.0; 29 | 30 | /** 31 | * Parameter b 32 | */ 33 | private double b = 2; 34 | 35 | private double minB = 1.0; 36 | 37 | private double maxB = 6.0; 38 | 39 | /** 40 | * Parameter c 41 | */ 42 | private double c = 4; 43 | 44 | private double minC = 2.0; 45 | 46 | private double maxC = 12.0; 47 | 48 | /** Creates a new instance of HampelEstimator */ 49 | public HampelEstimator() { 50 | } 51 | 52 | /** 53 | * Returns a description of the estimator. 54 | * The description does not contain any numerical values. 55 | * @return The description. 56 | */ 57 | public String getDescription() { 58 | String str = "Hampel Estimator\n"; 59 | str += "Parameters a, b, c"; 60 | return str; 61 | } 62 | 63 | /** 64 | * Returns the name of this robust estimator. 65 | * @return Returns a String 66 | */ 67 | public String getName(){ 68 | String str = "Hampel Estimator"; 69 | return str; 70 | } 71 | 72 | /** 73 | * Returns a description of the estimator. 74 | * The description does contain numerical values. 75 | * @return The description. 76 | */ 77 | public String getDescriptionOfValues() { 78 | String str = "a:\t" + a; 79 | str += " b:\t" + b; 80 | str += " c:\t" + c; 81 | return str; 82 | } 83 | 84 | /** 85 | * weight function of the estimator 86 | * @param u residual scaled by s. 87 | * @return The weight for u. 88 | */ 89 | public double w(double u) { 90 | final double uabs = Math.abs(u); 91 | if (uabs < a) 92 | return 1; 93 | if (uabs < b) 94 | return a / uabs; 95 | if (uabs < c) 96 | return a/uabs * c/(c-b)-a/(c-b); 97 | return 0; 98 | } 99 | 100 | /** 101 | * Get parameter a 102 | * @return Parameter a. 103 | */ 104 | public double getA() { 105 | return a; 106 | } 107 | 108 | /** 109 | * Set parameter a 110 | * @param a Parameter a. 111 | */ 112 | public void setA(double a) { 113 | this.a = a; 114 | } 115 | 116 | /** 117 | * Get parameter b 118 | * @return Parameter b. 119 | */ 120 | public double getB() { 121 | return b; 122 | } 123 | 124 | /** 125 | * Set parameter b 126 | * @param b Parameter b. 127 | */ 128 | public void setB(double b) { 129 | this.b = b; 130 | } 131 | 132 | /** 133 | * Get parameter c 134 | * @return Parameter c. 135 | */ 136 | public double getC() { 137 | return c; 138 | } 139 | 140 | /** 141 | * Set parameter c 142 | * @param c Parameter c. 143 | */ 144 | public void setC(double c) { 145 | this.c = c; 146 | } 147 | 148 | public double getMinA() { 149 | return minA; 150 | } 151 | 152 | public double getMaxA() { 153 | return maxA; 154 | } 155 | 156 | public double getMinB() { 157 | return minB; 158 | } 159 | 160 | public double getMaxB() { 161 | return maxB; 162 | } 163 | 164 | public double getMinC() { 165 | return minC; 166 | } 167 | 168 | public double getMaxC() { 169 | return maxC; 170 | } 171 | 172 | } 173 | -------------------------------------------------------------------------------- /src/ika/map/tools/DoubleBufferedTool.java: -------------------------------------------------------------------------------- 1 | /* 2 | * DoubleBufferedTool.java 3 | * 4 | * Created on April 11, 2005, 3:19 PM 5 | */ 6 | 7 | package ika.map.tools; 8 | 9 | import java.awt.image.*; 10 | import java.awt.*; 11 | import ika.utils.ImageUtils; 12 | import ika.gui.MapComponent; 13 | 14 | /** 15 | * DoubleBuffereTool - an abstract tool class that provides quick drawing of the map 16 | * background based on a double buffered image. 17 | * @author Bernhard Jenny, Institute of Cartography, ETH Zurich. 18 | */ 19 | public abstract class DoubleBufferedTool extends MapTool { 20 | 21 | /** 22 | * Static flag to toggle debugging information on and off. 23 | */ 24 | private static final boolean VERBOSE = false; 25 | 26 | /** 27 | * The image that contains the map background. 28 | */ 29 | private BufferedImage backImg = null; 30 | 31 | /** 32 | * A VolatileImage offers hardware supported drawing. Should be faster. 33 | */ 34 | private VolatileImage volImage = null; 35 | 36 | /** Creates a new instance of DoubleBufferedTool 37 | * @param mapComponent The MapComponent for which this MapTool provides its services. 38 | */ 39 | protected DoubleBufferedTool(MapComponent mapComponent) { 40 | super(mapComponent); 41 | } 42 | 43 | /** 44 | * Captures the current map background. It will be used be subsequent calls to 45 | * drawBackground to draw the map, until releaseBackground is called. 46 | */ 47 | protected void captureBackground() { 48 | backImg = mapComponent.getDoubleBuffer(); 49 | if (VERBOSE) 50 | System.out.println("captured background"); 51 | } 52 | 53 | /** 54 | * Relases the previously captured background. 55 | */ 56 | protected void releaseBackground() { 57 | if (backImg != null) 58 | backImg.flush(); 59 | backImg = null; 60 | if (volImage != null) 61 | volImage.flush(); 62 | volImage = null; 63 | if (VERBOSE) 64 | System.out.println("released background"); 65 | } 66 | 67 | /** 68 | * Returns whether this MapTool is currently drawing a double buffered background image. 69 | * @return True if double buffered background image is used for drawing. 70 | */ 71 | public boolean isDrawingBackground() { 72 | return (this.backImg != null); 73 | } 74 | 75 | /** 76 | * Draws the previously captured double-buffered background image. 77 | * @param g2d The destination to draw to. 78 | */ 79 | public void drawBackground(Graphics2D g2d) { 80 | if (backImg != null) { 81 | g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, 82 | RenderingHints.VALUE_ANTIALIAS_OFF); 83 | g2d.setRenderingHint(RenderingHints.KEY_RENDERING, 84 | RenderingHints.VALUE_RENDER_SPEED); 85 | g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, 86 | RenderingHints.VALUE_COLOR_RENDER_SPEED); 87 | g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, 88 | RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR); 89 | g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, 90 | RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED); 91 | 92 | volImage = ImageUtils.drawVolatileImage(g2d, volImage, 0, 0, backImg); 93 | if (VERBOSE) 94 | System.out.println("drawing captured background"); 95 | } 96 | } 97 | 98 | public void pause() { 99 | // don't release this.backImg yet. It will be used in resume() to 100 | // determine whether this tool had the background previously captured. 101 | this.releaseBackground(); 102 | this.mapComponent.repaint(); 103 | } 104 | 105 | public void resume() { 106 | // capture the background on resume (background could have been changed 107 | // by previous tool). Only capture background if it previously was 108 | // captured too. 109 | if (backImg != null) 110 | this.captureBackground(); 111 | this.mapComponent.repaint(); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/ika/utils/ErrorDialog.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ErrorDialog.java 3 | * 4 | * Created on January 9, 2006, 10:37 AM 5 | */ 6 | package ika.utils; 7 | 8 | import javax.swing.*; 9 | import java.awt.*; 10 | 11 | /** 12 | * A utility class with static methods to display simple error dialogs. 13 | * @author Bernhard Jenny, Institute of Cartography, ETH Zurich 14 | */ 15 | public class ErrorDialog { 16 | 17 | /** 18 | * Displays a simple error dialog to let the user know about some bad 19 | * situation. 20 | * Makes sure the dialog is displayed in the event dispatch thread. Does not 21 | * throw any exception. 22 | * @param msg The message that is displayed by the dialog. 23 | * @param title The title of the dialog. 24 | * @param e If e is not null, its message is appended on a new line to msg. 25 | * @param parentComponent The frame for which the dialog is displayed. 26 | */ 27 | public static void showErrorDialog(final String msg, 28 | final String title, 29 | final Throwable e, 30 | Component parentComponent) { 31 | 32 | try { 33 | if (GraphicsEnvironment.isHeadless()) { 34 | System.err.println(title); 35 | System.err.println(msg); 36 | System.err.println(e); 37 | return; 38 | } 39 | 40 | // try finding a parent component if none is specified 41 | if (parentComponent == null) { 42 | parentComponent = ika.utils.GUIUtil.getFrontMostFrame(); 43 | } 44 | final Component component = parentComponent; 45 | 46 | // make sure we run in the event dispatch thread. 47 | SwingUtilities.invokeLater(new Runnable() { 48 | 49 | public void run() { 50 | String message = msg; 51 | if (e != null && e.getMessage() != null) { 52 | message += "\n" + e.getClass().getName() + ": " + e.getMessage().trim(); 53 | } 54 | JOptionPane.showMessageDialog(component, message, 55 | title, JOptionPane.ERROR_MESSAGE); 56 | } 57 | }); 58 | 59 | } catch (Exception exc) { 60 | } 61 | 62 | } 63 | 64 | /** 65 | * Displays a simple error dialog to let the user know about some bad 66 | * situation. 67 | * Makes sure the dialog is displayed in the event dispatch thread. 68 | * @param msg The message that is displayed by the dialog. 69 | * @param title The title of the dialog. 70 | */ 71 | public static void showErrorDialog(String msg, String title) { 72 | ErrorDialog.showErrorDialog(msg, title, null, null); 73 | } 74 | 75 | /** 76 | * Displays a simple error dialog to let the user know about some bad 77 | * situation. Uses a default title "Error". 78 | * Makes sure the dialog is displayed in the event dispatch thread. 79 | * @param msg The message that is displayed by the dialog. 80 | */ 81 | public static void showErrorDialog(String msg) { 82 | ErrorDialog.showErrorDialog(msg, "Error", null, null); 83 | } 84 | 85 | /** 86 | * Displays a simple error dialog to let the user know about some bad 87 | * situation. Uses a default title "Error". 88 | * Makes sure the dialog is displayed in the event dispatch thread. 89 | * @param msg The message that is displayed by the dialog. 90 | * @param parentComponent Determines the frame for which the dialog is displayed. 91 | */ 92 | public static void showErrorDialog(String msg, Component parentComponent) { 93 | ErrorDialog.showErrorDialog(msg, "Error", null, parentComponent); 94 | } 95 | 96 | /** 97 | * Displays a simple error dialog to let the user know about some bad 98 | * situation. Uses a default title "Error". 99 | * Makes sure the dialog is displayed in the event dispatch thread. 100 | * @param msg The message that is displayed by the dialog. 101 | * @param e The Exception that occured. 102 | */ 103 | public static void showErrorDialog(String msg, Throwable e) { 104 | ErrorDialog.showErrorDialog(msg, "Error", e, null); 105 | } 106 | } -------------------------------------------------------------------------------- /src/ika/utils/Median.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Median.java 3 | * 4 | * Created on March 27, 2005, 2:05 PM 5 | */ 6 | package ika.utils; 7 | 8 | /** 9 | * Algorithm from N. Wirth's book,
10 | * implementation by N. Devillard in C,
11 | * port to Java by B. Jenny.
12 | * This code is in public domain.
13 | * 14 | * Reference:
15 | * Author: Wirth, Niklaus
16 | * Title: Algorithms + data structures = programs
17 | * Publisher: Englewood Cliffs: Prentice-Hall, 1976
18 | * Physical description: 366 p.
19 | * Series: Prentice-Hall Series in Automatic Computation
20 | */ 21 | public class Median { 22 | 23 | /** 24 | * Find the kth smallest element in the array
25 | * Notice: use median() to get the median.
26 | * Important: The passed array will be altered. The order of its elements 27 | * will change!
28 | * 29 | * @param a Array of elements. The order of the elements will be changed! 30 | * @param k rank k, starting with 0, up to a.length-1 31 | * @return kth element in array a 32 | */ 33 | public static double kth_smallest(double[] a, int k) { 34 | final int n = a.length; 35 | int i, j, l, m; 36 | double x; 37 | l = 0; 38 | m = n - 1; 39 | while (l < m) { 40 | x = a[k]; 41 | i = l; 42 | j = m; 43 | do { 44 | while (a[i] < x) { 45 | i++; 46 | } 47 | while (x < a[j]) { 48 | j--; 49 | } 50 | if (i <= j) { 51 | // ELEM_SWAP(a[i],a[j]); 52 | final double temp = a[i]; 53 | a[i] = a[j]; 54 | a[j] = temp; 55 | 56 | i++; 57 | j--; 58 | } 59 | } while (i <= j); 60 | if (j < k) { 61 | l = i; 62 | } 63 | if (k < i) { 64 | m = j; 65 | } 66 | } 67 | return a[k]; 68 | } 69 | 70 | /** 71 | * Find the median of an array.
72 | * Important: The passed array will be altered if preserveOrder is false. 73 | * The order of its elements will change!
74 | * 75 | * @param a The array of values 76 | * @param preserveOrder If true, the order of the values in a is guaranteed 77 | * to remain the same. Passing true for preserveOrder forces median() to 78 | * allocate a copy of a, and thus slows it down. 79 | * @return The median value of a. 80 | */ 81 | public static double median(double[] a, boolean preserveOrder) { 82 | final int n = a.length; 83 | double[] a_copy; 84 | if (preserveOrder) { 85 | /* 86 | a_copy = new double [n]; 87 | for (int i = 0; i < n; i++) 88 | a_copy[i] = a[i]; 89 | */ 90 | a_copy = (double[]) (a.clone()); 91 | } else { 92 | a_copy = a; 93 | } 94 | return Median.kth_smallest(a_copy, (n % 2 == 0) ? n / 2 - 1 : n / 2); 95 | } 96 | 97 | public static double quantile(double[] a, double quantile) { 98 | final int n = a.length; 99 | int k = (int)Math.round((n - 1) * quantile); 100 | return Median.kth_smallest(a, k); 101 | } 102 | 103 | /** 104 | * A few tests. 105 | */ 106 | /* 107 | public static void main(String[]args) { 108 | double[] a = {1, 2, 3}; 109 | System.out.println(Median.median(a, false)); 110 | double[] b = {4, 1, 3, 2}; 111 | System.out.println(Median.median(b, false)); 112 | double[] c = {2, 4, 1, 3}; 113 | System.out.println(Median.kth_smallest(c, 0)); 114 | System.out.println(Median.kth_smallest(c, 1)); 115 | System.out.println(Median.kth_smallest(c, 2)); 116 | System.out.println(Median.kth_smallest(c, 3)); 117 | System.out.println(); 118 | 119 | double[] d = {0, -9, 2, -3, 5, -999, 0.1, -6, 11332, -6.366, 456}; 120 | System.out.println("Median: " + Median.median(d, true)); 121 | MatrixUtils.printVector (d); 122 | System.out.println("Median: " + Median.median(d, false)); 123 | MatrixUtils.printVector (d); 124 | }*/ 125 | } 126 | -------------------------------------------------------------------------------- /src/ika/gui/ImageReaderProgressDialog.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 |
70 | -------------------------------------------------------------------------------- /src/org/openstreetmap/gui/jmapviewer/MapObjectImpl.java: -------------------------------------------------------------------------------- 1 | // License: GPL. For details, see Readme.txt file. 2 | package org.openstreetmap.gui.jmapviewer; 3 | 4 | import java.awt.Color; 5 | import java.awt.Font; 6 | import java.awt.Graphics; 7 | import java.awt.Point; 8 | import java.awt.Stroke; 9 | 10 | import javax.swing.UIManager; 11 | 12 | public abstract class MapObjectImpl { 13 | private Layer layer; 14 | private String name; 15 | private Style style; 16 | private Boolean visible; 17 | 18 | public MapObjectImpl(String name) { 19 | this(null, name, null); 20 | } 21 | 22 | public MapObjectImpl(Layer layer) { 23 | this(layer, null, null); 24 | } 25 | 26 | public MapObjectImpl(Layer layer, String name, Style style) { 27 | super(); 28 | this.layer = layer; 29 | this.name = name; 30 | this.style = style; 31 | } 32 | 33 | public Layer getLayer() { 34 | return layer; 35 | } 36 | 37 | public void setLayer(Layer layer) { 38 | this.layer = layer; 39 | } 40 | 41 | public Style getStyle() { 42 | return style; 43 | } 44 | 45 | public Style getStyleAssigned() { 46 | return style == null ? (layer == null ? null : layer.getStyle()) : style; 47 | } 48 | 49 | public void setStyle(Style style) { 50 | this.style = style; 51 | } 52 | 53 | public Color getColor() { 54 | Style styleAssigned = getStyleAssigned(); 55 | return styleAssigned == null ? null : getStyleAssigned().getColor(); 56 | } 57 | 58 | public void setColor(Color color) { 59 | if (style == null && color != null) style = new Style(); 60 | if (style != null) style.setColor(color); 61 | } 62 | 63 | public Color getBackColor() { 64 | Style styleAssigned = getStyleAssigned(); 65 | return styleAssigned == null ? null : getStyleAssigned().getBackColor(); 66 | } 67 | 68 | public void setBackColor(Color backColor) { 69 | if (style == null && backColor != null) style = new Style(); 70 | if (style != null) style.setBackColor(backColor); 71 | } 72 | 73 | public Stroke getStroke() { 74 | Style styleAssigned = getStyleAssigned(); 75 | return styleAssigned == null ? null : getStyleAssigned().getStroke(); 76 | } 77 | 78 | public void setStroke(Stroke stroke) { 79 | if (style == null && stroke != null) style = new Style(); 80 | if (style != null) style.setStroke(stroke); 81 | } 82 | 83 | public Font getFont() { 84 | Style styleAssigned = getStyleAssigned(); 85 | return styleAssigned == null ? null : getStyleAssigned().getFont(); 86 | } 87 | 88 | public void setFont(Font font) { 89 | if (style == null && font != null) style = new Style(); 90 | if (style != null) style.setFont(font); 91 | } 92 | 93 | private boolean isVisibleLayer() { 94 | return layer == null || layer.isVisible() == null ? true : layer.isVisible(); 95 | } 96 | 97 | public boolean isVisible() { 98 | return visible == null ? isVisibleLayer() : visible.booleanValue(); 99 | } 100 | 101 | public void setVisible(Boolean visible) { 102 | this.visible = visible; 103 | } 104 | 105 | public String getName() { 106 | return name; 107 | } 108 | 109 | public void setName(String txt) { 110 | this.name = txt; 111 | } 112 | 113 | public static Font getDefaultFont() { 114 | Font f = UIManager.getDefaults().getFont("TextField.font"); 115 | if (f == null) { 116 | f = Font.decode(null); 117 | } 118 | return new Font(f.getName(), Font.BOLD, f.getSize()); 119 | } 120 | 121 | public void paintText(Graphics g, Point position) { 122 | if (name != null && g != null && position != null) { 123 | if (getFont() == null) { 124 | Font f = getDefaultFont(); 125 | setFont(new Font(f.getName(), Font.BOLD, f.getSize())); 126 | } 127 | g.setColor(Color.DARK_GRAY); 128 | g.setFont(getFont()); 129 | g.drawString(name, position.x+MapMarkerDot.DOT_RADIUS+2, position.y+MapMarkerDot.DOT_RADIUS); 130 | } 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /src/ika/transformation/robustestimator/VEstimator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * VEstimator.java 3 | * 4 | * Created on March 26, 2005, 5:15 PM 5 | */ 6 | 7 | package ika.transformation.robustestimator; 8 | 9 | /** 10 | * V-estimator as developed by D. Beineke in:
11 | * Beineke, D. 2001. Verfahren zur Genauigkeitsanalyse fuer Altkarten. Universitaet 12 | * der Bundeswehr, Muenchen.
13 | * 14 | * The V-estimator has been developed for the analysis of old maps. It uses two 15 | * tuning contants: k and e.
16 | * k is similar to k of the Huber estimator.
17 | * e is the degree of contamination in 0 .. 1
18 | * e in 0.0 .. 0.3: low contamination
19 | * e in 0.3 .. 0.7: medium contamination
20 | * e in 0.7 .. 1.0: high contamination.
21 | * The contamination constant c is derived from k and e:
22 | * c = k * e
23 | * with c in 0 .. k
24 | * @author Bernhard Jenny, Institute of Cartography, ETH Zurich 25 | */ 26 | public class VEstimator extends RobustEstimator implements java.io.Serializable { 27 | 28 | static final long serialVersionUID = 7940786881681576077L; 29 | 30 | /** 31 | * The degree of contamination e in 0 .. 1 32 | */ 33 | private double e = 0.6; 34 | 35 | private double minE = 0.0; 36 | 37 | private double maxE = 1.0; 38 | 39 | /** 40 | * The tuning constant k. 41 | */ 42 | private double k = 1.5; 43 | 44 | private double minK = 0.0; 45 | 46 | private double maxK = 4.0; 47 | 48 | /** Creates a new instance of VEstimator */ 49 | public VEstimator(){ 50 | } 51 | 52 | /** 53 | * Weight function of the estimator 54 | * @param u residual scaled by s. 55 | * @return The weight for u. 56 | */ 57 | public final double w(double u) { 58 | final double u_abs = Math.abs(u); 59 | if (u_abs < k) 60 | return 1; 61 | else { 62 | final double c = e * k; 63 | return (k - c) / (u_abs - c); 64 | } 65 | } 66 | 67 | /** 68 | * Returns the degree of contamination e. 69 | * @return The degree of contamination e. 70 | */ 71 | public double getE() { 72 | return e; 73 | } 74 | 75 | /** 76 | * Sets the degree of contamination. 77 | * @param contamination_e The degree of contamination. 78 | */ 79 | public void setE(double e) { 80 | this.e = e; 81 | } 82 | 83 | /** 84 | * Returns the tuning constant k. 85 | * @return The tuning constant k. 86 | */ 87 | public double getK() { 88 | return k; 89 | } 90 | 91 | /** 92 | * Sets the tuning constant k. 93 | * @param splitPoint_k The tuning constant k. 94 | */ 95 | 96 | public void setK(double k) { 97 | this.k = k; 98 | } 99 | 100 | /** 101 | * Returns a description of the estimator. 102 | * The description does not contain any numerical values. 103 | * @return The description. 104 | */ 105 | public String getDescription() { 106 | String nl = System.getProperty("line.separator"); 107 | String str = "Robust V-Estimator" + nl; 108 | str += "Split Point k" + nl; 109 | str += "Contamination: 0..1" + nl; 110 | return str; 111 | } 112 | 113 | /** 114 | * Returns the name of this robust estimator. 115 | * @return Returns a String 116 | */ 117 | public String getName(){ 118 | String str = "V Estimator"; 119 | return str; 120 | } 121 | 122 | /** 123 | * Returns a description of the estimator. 124 | * The description does contain numerical values. 125 | * @return The description. 126 | */ 127 | public String getDescriptionOfValues() { 128 | String nl = System.getProperty("line.separator"); 129 | String str = ("Split Point k:\t"); 130 | str += this.k + nl; 131 | str += ("Degree of contamination e:\t"); 132 | str += this.e + nl; 133 | return str; 134 | } 135 | 136 | public double getMinE() { 137 | return minE; 138 | } 139 | 140 | public double getMaxE() { 141 | return maxE; 142 | } 143 | 144 | public double getMinK() { 145 | return minK; 146 | } 147 | 148 | public double getMaxK() { 149 | return maxK; 150 | } 151 | } 152 | --------------------------------------------------------------------------------