Search in sources :

Example 1 with TileSet

use of org.netxms.ui.eclipse.osm.tools.TileSet in project netxms by netxms.

the class ExtendedGraphViewer method reloadMapBackground.

/**
 * Reload map background
 */
private void reloadMapBackground() {
    final Rectangle controlSize = graph.getClientArea();
    final org.eclipse.draw2d.geometry.Rectangle rootLayerSize = graph.getZestRootLayer().getClientArea();
    final Point mapSize = new Point(Math.min(controlSize.width, rootLayerSize.width), Math.max(controlSize.height, rootLayerSize.height));
    ConsoleJob job = new ConsoleJob(Messages.get().ExtendedGraphViewer_DownloadTilesJob, null, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            final TileSet tiles = mapLoader.getAllTiles(mapSize, backgroundLocation, MapLoader.TOP_LEFT, backgroundZoom, false);
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    if ((backgroundLocation == null) || graph.isDisposed())
                        return;
                    final org.eclipse.draw2d.geometry.Rectangle rootLayerSize = graph.getZestRootLayer().getClientArea();
                    if ((mapSize.x != rootLayerSize.width) || (mapSize.y != rootLayerSize.height))
                        return;
                    if (backgroundImage != null) {
                        backgroundImage.dispose();
                        backgroundImage = null;
                    }
                    backgroundTiles = tiles;
                    backgroundFigure.setSize(mapSize.x, mapSize.y);
                    backgroundFigure.repaint();
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().ExtendedGraphViewer_DownloadTilesError;
        }
    };
    job.setUser(false);
    job.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) TileSet(org.netxms.ui.eclipse.osm.tools.TileSet)

Example 2 with TileSet

use of org.netxms.ui.eclipse.osm.tools.TileSet in project netxms by netxms.

the class AbstractGeoMapViewer method reloadMap.

/**
 * Reload current map
 */
public void reloadMap() {
    Rectangle rect = this.getClientArea();
    accessor.setMapWidth(rect.width);
    accessor.setMapHeight(rect.height);
    if (!accessor.isValid())
        return;
    final Point mapSize = new Point(accessor.getMapWidth(), accessor.getMapHeight());
    final GeoLocation centerPoint = accessor.getCenterPoint();
    ConsoleJob job = new ConsoleJob(Messages.get().GeoMapViewer_DownloadJob_Title, viewPart, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            final TileSet tiles = mapLoader.getAllTiles(mapSize, centerPoint, MapLoader.CENTER, accessor.getZoom(), true);
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    if (isDisposed())
                        return;
                    if (currentTileSet != null)
                        currentTileSet.dispose();
                    currentTileSet = tiles;
                    if ((tiles != null) && (tiles.missingTiles > 0))
                        loadMissingTiles(tiles);
                    Rectangle clientArea = getClientArea();
                    Point mapSize = new Point(clientArea.width, clientArea.height);
                    coverage = GeoLocationCache.calculateCoverage(mapSize, accessor.getCenterPoint(), GeoLocationCache.CENTER, accessor.getZoom());
                    onMapLoad();
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().GeoMapViewer_DownloadError;
        }
    };
    job.setUser(false);
    job.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point) GeoLocation(org.netxms.base.GeoLocation) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) TileSet(org.netxms.ui.eclipse.osm.tools.TileSet)

Aggregations

IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 Point (org.eclipse.swt.graphics.Point)2 Rectangle (org.eclipse.swt.graphics.Rectangle)2 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)2 TileSet (org.netxms.ui.eclipse.osm.tools.TileSet)2 GeoLocation (org.netxms.base.GeoLocation)1