Search in sources :

Example 1 with TileProvider

use of org.jdesktop.swingx.mapviewer.TileProvider in project hale by halestudio.

the class MapFileServerFactory method loadServer.

/**
 * Load a map file server with the given name
 *
 * @param name the server name
 * @return the map server or null
 */
private MapServer loadServer(String name) {
    String filename = mapFiles.get(name, null);
    if (filename == null) {
        mapFiles.remove(name);
    } else {
        File file = new File(filename);
        if (file.exists()) {
            TileProvider tp;
            try {
                tp = MapFileTileProvider.createMapFileTileProvider(file);
                MapServer server = new TileProviderMapServer(tp);
                server.setName(name);
                prefServers.put(server, name);
                return server;
            } catch (MalformedURLException e) {
                log.error("Invalid file name", e);
            } catch (IOException e) {
                log.error("Error loading map file", e);
            }
        } else {
            log.info("Map file not found, removing map: " + filename);
        }
    }
    return null;
}
Also used : TileProviderMapServer(de.fhg.igd.mapviewer.server.TileProviderMapServer) MalformedURLException(java.net.MalformedURLException) MapServer(de.fhg.igd.mapviewer.server.MapServer) TileProviderMapServer(de.fhg.igd.mapviewer.server.TileProviderMapServer) IOException(java.io.IOException) File(java.io.File) TileProvider(org.jdesktop.swingx.mapviewer.TileProvider)

Aggregations

MapServer (de.fhg.igd.mapviewer.server.MapServer)1 TileProviderMapServer (de.fhg.igd.mapviewer.server.TileProviderMapServer)1 File (java.io.File)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 TileProvider (org.jdesktop.swingx.mapviewer.TileProvider)1