teichmann@5861: /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde teichmann@5861: * Software engineering by Intevation GmbH teichmann@5861: * teichmann@5861: * This file is Free Software under the GNU AGPL (>=v3) teichmann@5861: * and comes with ABSOLUTELY NO WARRANTY! Check out the teichmann@5861: * documentation coming with Dive4Elements River for details. teichmann@5861: */ teichmann@5861: teichmann@5835: package org.dive4elements.river.client.client.ui.map; ingo@832: christian@4475: import com.google.gwt.core.client.GWT; christian@5538: import com.google.gwt.user.client.ui.AbsolutePanel; ingo@832: teichmann@5835: import org.dive4elements.river.client.shared.model.BBox; teichmann@5835: import org.dive4elements.river.client.shared.model.MapInfo; ingo@832: christian@3347: import org.gwtopenmaps.openlayers.client.Bounds; christian@4475: import org.gwtopenmaps.openlayers.client.MapWidget; christian@3347: christian@4475: /** christian@4475: * Panel that contains a MapWidget and a MapToolbar. christian@4475: * This panel is used by the flood map calculation input helper. christian@4475: */ christian@5538: public class MapPanel extends AbsolutePanel { ingo@832: ingo@832: protected MapToolbar toolbar; ingo@832: christian@4475: protected FloodMap floodMap; christian@4475: protected MapWidget floodMapWidget; christian@4475: protected boolean digitizeEnabled; ingo@832: ingo@832: public MapPanel(MapInfo mapInfo, boolean digitizeEnabled) { ingo@832: BBox bbox = mapInfo.getBBox(); ingo@832: ingo@832: this.digitizeEnabled = digitizeEnabled; ingo@832: this.floodMap = new FloodMap( ingo@832: String.valueOf(mapInfo.getSrid()), ingo@832: new Bounds( ingo@832: bbox.getLowerX(), ingo@832: bbox.getLowerY(), ingo@832: bbox.getUpperX(), christian@4402: bbox.getUpperY()), christian@4476: 640, 480); ingo@832: ingo@832: initLayout(); ingo@832: } ingo@832: ingo@832: ingo@832: private void initLayout() { christian@5538: setWidth("100%"); christian@5538: setHeight("100%"); ingo@832: christian@4475: floodMapWidget = floodMap.getMapWidget(); raimund@1386: toolbar = new MapToolbar(floodMap, digitizeEnabled); ingo@832: christian@5538: add(toolbar); christian@5538: add(floodMapWidget); christian@4475: } christian@4475: christian@5538: public void doLayout(int w, int h) { christian@5538: int width = w; christian@5538: int height = h; christian@4541: GWT.log("MapPanel.size: " + width + "x" + height); christian@4475: christian@4541: width -= 2; // minus black borders christian@4541: height -= toolbar.getHeight() + 4; christian@4541: christian@4571: if (width < 0 || height < 0) { christian@4571: GWT.log("MapPanel: Oops what a size!"); christian@4571: return; christian@4571: } christian@4571: christian@4553: floodMapWidget.setSize(Integer.toString(width), Integer.toString(height)); christian@4553: floodMapWidget.getMap().updateSize(); ingo@832: } ingo@832: ingo@832: ingo@832: public FloodMap getFloodMap() { ingo@832: return floodMap; ingo@832: } raimund@1389: raimund@1389: public MapToolbar getMapToolbar () { raimund@1389: return toolbar; raimund@1389: } ingo@832: } ingo@832: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :