public static MapViewController create(MapView mapView, Model model) { MapViewController mapViewController = new MapViewController(mapView); model.mapViewPosition.addObserver(mapViewController); return mapViewController; }
public static LayerManagerController create(LayerManager layerManager, Model model) { LayerManagerController layerManagerController = new LayerManagerController(layerManager); model.mapViewDimension.addObserver(layerManagerController); model.mapViewPosition.addObserver(layerManagerController); return layerManagerController; }
public MapView() { super(); this.model = new Model(); this.fpsCounter = new FpsCounter(GRAPHIC_FACTORY, this.model.displayModel); this.frameBuffer = new FrameBufferHA2(this.model.frameBufferModel, this.model.displayModel, GRAPHIC_FACTORY); this.frameBufferController = FrameBufferController.create(this.frameBuffer, this.model); this.layerManager = new LayerManager(this, this.model.mapViewPosition, GRAPHIC_FACTORY); this.layerManager.start(); LayerManagerController.create(this.layerManager, this.model); MapViewController.create(this, this.model); this.mapScaleBar = new DefaultMapScaleBar(this.model.mapViewPosition, this.model.mapViewDimension, GRAPHIC_FACTORY, this.model.displayModel); this.mapViewProjection = new MapViewProjection(this); addListeners(); }
if (dimensionChangeNeeded(mapViewDimension, overdrawFactor)) { Dimension newDimension = calculateFrameBufferDimension(mapViewDimension, overdrawFactor); if (!Parameters.SQUARE_FRAME_BUFFER || frameBuffer.getDimension() == null || newDimension.width > frameBuffer.getDimension().width double scaleFactor = this.model.mapViewPosition.getScaleFactor(); LatLong pivot = this.model.mapViewPosition.getPivot(); adjustFrameBufferMatrix(mapPositionFrameBuffer, mapViewDimension, scaleFactor, pivot);
@Test public void repaintTest() { DummyMapView dummyMapView = new DummyMapView(); Model model = new Model(); MapViewController.create(dummyMapView, model); Assert.assertEquals(0, dummyMapView.repaintCounter); model.mapViewPosition.setZoomLevel((byte) 1); // this does not hold with zoom animation // Assert.assertEquals(1, dummyMapView.repaintCounter); } }
/** * Clear map view. */ @Override public void destroy() { this.layerManager.finish(); this.frameBufferController.destroy(); this.frameBuffer.destroy(); if (this.mapScaleBar != null) { this.mapScaleBar.destroy(); } this.getModel().mapViewPosition.destroy(); }
/** * Compute the minimum cache size for a view, using the size of the map view. * For the view size we use the frame buffer calculated dimension. * * @param tileSize the tile size * @param overdrawFactor the overdraw factor applied to the mapview * @param width the width of the map view * @param height the height of the map view * @return the minimum cache size for the view */ public static int getMinimumCacheSize(int tileSize, double overdrawFactor, int width, int height) { // height * overdrawFactor / tileSize calculates the number of tiles that would cover // the view port, adding 1 is required since we can have part tiles on either side, // adding 2 adds another row/column as spare and ensures that we will generally have // a larger number of tiles in the cache than a TileLayer will render for a view. // For any size we need a minimum of 4 (as the intersection of 4 tiles can always be in the // middle of a view. Dimension dimension = FrameBufferController.calculateFrameBufferDimension(new Dimension(width, height), overdrawFactor); return Math.max(4, (2 + (dimension.height / tileSize)) * (2 + (dimension.width / tileSize))); }
public static FrameBufferController create(FrameBuffer frameBuffer, Model model) { FrameBufferController frameBufferController = new FrameBufferController(frameBuffer, model); model.frameBufferModel.addObserver(frameBufferController); model.mapViewDimension.addObserver(frameBufferController); model.mapViewPosition.addObserver(frameBufferController); model.displayModel.addObserver(frameBufferController); return frameBufferController; }
public AwtGraphicMapView() { super(); this.model = new Model(); this.fpsCounter = new FpsCounter(GRAPHIC_FACTORY, model.displayModel); this.frameBuffer = new FrameBuffer(model.frameBufferModel, model.displayModel, GRAPHIC_FACTORY); this.frameBufferController = FrameBufferController.create(frameBuffer, model); this.layerManager = new LayerManager(this, model.mapViewPosition, GRAPHIC_FACTORY); this.layerManager.start(); LayerManagerController.create(layerManager, model); MapViewController.create(this, model); this.mapScaleBar = new DefaultMapScaleBar(model.mapViewPosition, model.mapViewDimension, GRAPHIC_FACTORY, model.displayModel); this.mapViewProjection = new MapViewProjection(this); }
if (dimensionChangeNeeded(mapViewDimension, overdrawFactor)) { Dimension newDimension = calculateFrameBufferDimension(mapViewDimension, overdrawFactor); if (!Parameters.SQUARE_FRAME_BUFFER || frameBuffer.getDimension() == null || newDimension.width > frameBuffer.getDimension().width double scaleFactor = this.model.mapViewPosition.getScaleFactor(); LatLong pivot = this.model.mapViewPosition.getPivot(); adjustFrameBufferMatrix(mapPositionFrameBuffer, mapViewDimension, scaleFactor, pivot);
public void destroy() { layerManager.interrupt(); frameBufferController.destroy(); frameBuffer.destroy(); if (mapScaleBar != null) mapScaleBar.destroy(); getModel().mapViewPosition.destroy(); }
Dimension dimension = FrameBufferController.calculateFrameBufferDimension(new Dimension(width, height), overdrawFactor); return (int) Math.max(4, screenRatio * (2 + (dimension.height / tileSize)) * (2 + (dimension.width / tileSize)));
public static MapViewController create(MapView mapView, Model model) { MapViewController mapViewController = new MapViewController(mapView); model.mapViewPosition.addObserver(mapViewController); return mapViewController; }
public static LayerManagerController create(LayerManager layerManager, Model model) { LayerManagerController layerManagerController = new LayerManagerController(layerManager); model.mapViewDimension.addObserver(layerManagerController); model.mapViewPosition.addObserver(layerManagerController); return layerManagerController; }
public static FrameBufferController create(FrameBuffer frameBuffer, Model model) { FrameBufferController frameBufferController = new FrameBufferController(frameBuffer, model); model.frameBufferModel.addObserver(frameBufferController); model.mapViewDimension.addObserver(frameBufferController); model.mapViewPosition.addObserver(frameBufferController); model.displayModel.addObserver(frameBufferController); return frameBufferController; }
public MapView() { super(); this.model = new Model(); this.fpsCounter = new FpsCounter(GRAPHIC_FACTORY, this.model.displayModel); this.frameBuffer = new FrameBufferHA2(this.model.frameBufferModel, this.model.displayModel, GRAPHIC_FACTORY); this.frameBufferController = FrameBufferController.create(this.frameBuffer, this.model); this.layerManager = new LayerManager(this, this.model.mapViewPosition, GRAPHIC_FACTORY); this.layerManager.start(); LayerManagerController.create(this.layerManager, this.model); MapViewController.create(this, this.model); this.mapScaleBar = new DefaultMapScaleBar(this.model.mapViewPosition, this.model.mapViewDimension, GRAPHIC_FACTORY, this.model.displayModel); this.mapViewProjection = new MapViewProjection(this); addListeners(); }
/** * Clear map view. */ @Override public void destroy() { this.layerManager.finish(); this.frameBufferController.destroy(); this.frameBuffer.destroy(); if (this.mapScaleBar != null) { this.mapScaleBar.destroy(); } this.getModel().mapViewPosition.destroy(); }
public MapView(Context context, AttributeSet attributeSet) { super(context, attributeSet); setDescendantFocusability(FOCUS_BLOCK_DESCENDANTS); setWillNotDraw(false); this.model = new Model(); this.fpsCounter = new FpsCounter(GRAPHIC_FACTORY, this.model.displayModel); this.frameBuffer = new FrameBufferHA2(this.model.frameBufferModel, this.model.displayModel, GRAPHIC_FACTORY); this.frameBufferController = FrameBufferController.create(this.frameBuffer, this.model); this.layerManager = new LayerManager(this, this.model.mapViewPosition, GRAPHIC_FACTORY); this.layerManager.start(); LayerManagerController.create(this.layerManager, this.model); MapViewController.create(this, this.model); this.touchGestureHandler = new TouchGestureHandler(this); this.gestureDetector = new GestureDetector(context, touchGestureHandler); this.scaleGestureDetector = new ScaleGestureDetector(context, touchGestureHandler); this.mapZoomControls = new MapZoomControls(context, this); this.addView(this.mapZoomControls, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); this.mapScaleBar = new DefaultMapScaleBar(this.model.mapViewPosition, this.model.mapViewDimension, GRAPHIC_FACTORY, this.model.displayModel); this.mapViewProjection = new MapViewProjection(this); model.mapViewPosition.addObserver(this); }
/** * Clear map view. */ @Override public void destroy() { this.touchGestureHandler.destroy(); this.layoutHandler.removeCallbacksAndMessages(null); this.layerManager.finish(); this.frameBufferController.destroy(); this.frameBuffer.destroy(); if (this.mapScaleBar != null) { this.mapScaleBar.destroy(); } this.mapZoomControls.destroy(); this.getModel().mapViewPosition.destroy(); }