All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.albertus82.jface.maps.google.GoogleMapBoundsDialog Maven / Gradle / Ivy

Go to download

Java SWT/JFace Utility Library including a Preferences Framework, Lightweight HTTP Server and macOS support.

There is a newer version: 20.1.0
Show newest version
package io.github.albertus82.jface.maps.google;

import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.Shell;

import io.github.albertus82.jface.maps.MapBounds;
import io.github.albertus82.jface.maps.MapBoundsDialog;
import io.github.albertus82.jface.maps.MapBoundsDialogCreationHelper;

public class GoogleMapBoundsDialog extends GoogleMapDialog implements MapBoundsDialog {

	private MapBounds bounds = new MapBounds();

	private final MapBoundsDialogCreationHelper helper = new MapBoundsDialogCreationHelper(this);

	public GoogleMapBoundsDialog(final Shell parent) {
		super(parent);
	}

	public GoogleMapBoundsDialog(final Shell parent, final int style) {
		super(parent, style);
	}

	@Override
	protected Layout getLayout() {
		return helper.getLayout();
	}

	@Override
	protected Browser createBrowser(final Composite parent) {
		return helper.createBrowser(parent, getMapPage(parent));
	}

	@Override
	public Composite createButtonBox(final Browser browser) {
		return helper.createButtonBox(browser);
	}

	@Override
	public MapBounds getBounds() {
		return bounds;
	}

	@Override
	public void setOptionValues(final Browser browser) {
		getOptions().setZoom(((Number) browser.evaluate("return map.getZoom();")).intValue());
		getOptions().setCenterLat((Double) browser.evaluate("return map.getCenter().lat();"));
		getOptions().setCenterLng((Double) browser.evaluate("return map.getCenter().lng();"));
	}

	@Override
	public void setBoundValues(final Browser browser) {
		final Double northEastLat = (Double) browser.evaluate("return map.getBounds().getNorthEast().lat();");
		final Double southWestLat = (Double) browser.evaluate("return map.getBounds().getSouthWest().lat();");
		final Double northEastLng = (Double) browser.evaluate("return map.getBounds().getNorthEast().lng();");
		final Double southWestLng = (Double) browser.evaluate("return map.getBounds().getSouthWest().lng();");
		bounds = new MapBounds(northEastLat, southWestLat, northEastLng, southWestLng);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy