comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java @ 4473:6db783627137

Map print does now submit additional parameters to MapPrintServiceImpl.
author Christian Lins <christian.lins@intevation.de>
date Sat, 10 Nov 2012 23:47:38 +0100
parents dc7e41efd5ba
children bd78d2b0e309
comparison
equal deleted inserted replaced
4472:dc7e41efd5ba 4473:6db783627137
16 import de.intevation.flys.client.client.FLYSConstants; 16 import de.intevation.flys.client.client.FLYSConstants;
17 import de.intevation.flys.client.client.ui.ImgLink; 17 import de.intevation.flys.client.client.ui.ImgLink;
18 import de.intevation.flys.client.client.ui.Toolbar; 18 import de.intevation.flys.client.client.ui.Toolbar;
19 import de.intevation.flys.client.client.utils.EnableDisableCmd; 19 import de.intevation.flys.client.client.utils.EnableDisableCmd;
20 import de.intevation.flys.client.shared.model.Collection; 20 import de.intevation.flys.client.shared.model.Collection;
21 import de.intevation.flys.client.shared.model.Property;
22 import de.intevation.flys.client.shared.model.PropertySetting;
23 import de.intevation.flys.client.shared.model.Settings;
21 import de.intevation.flys.client.shared.model.ThemeList; 24 import de.intevation.flys.client.shared.model.ThemeList;
25
26 import java.util.List;
22 27
23 import org.gwtopenmaps.openlayers.client.Bounds; 28 import org.gwtopenmaps.openlayers.client.Bounds;
24 import org.gwtopenmaps.openlayers.client.Map; 29 import org.gwtopenmaps.openlayers.client.Map;
25 import org.gwtopenmaps.openlayers.client.control.DragPan; 30 import org.gwtopenmaps.openlayers.client.control.DragPan;
26 import org.gwtopenmaps.openlayers.client.control.SelectFeature; 31 import org.gwtopenmaps.openlayers.client.control.SelectFeature;
286 291
287 getMap().addMapZoomListener(this); 292 getMap().addMapZoomListener(this);
288 293
289 return new ImgLink( 294 return new ImgLink(
290 baseUrl + MSG.downloadPDF(), 295 baseUrl + MSG.downloadPDF(),
291 getPrintUrl(), 296 createPrintUrl(),
292 20, 20, 297 20, 20,
293 true); 298 true);
294 } 299 }
295 300
296 301
686 return epsgLabel; 691 return epsgLabel;
687 } 692 }
688 693
689 @Override 694 @Override
690 public void onMapZoom(MapZoomListener.MapZoomEvent e) { 695 public void onMapZoom(MapZoomListener.MapZoomEvent e) {
691 printMapLink.setSource(getPrintUrl()); 696 printMapLink.setSource(createPrintUrl());
692 } 697 }
693 698
694 public String getPrintUrl() { 699 protected void appendPrintSettingsToUrl(Collection collection, StringBuilder url) {
700 Settings settings = collection.getSettings("print-settings");
701 if (settings != null) {
702 List<Property> properties = settings.getSettings("default");
703 for (Property prop : properties) {
704 GWT.log("prop=" + prop.getName());
705 PropertySetting props = (PropertySetting)prop;
706 if (props.getName().equals("page-format")) {
707
708 }
709 else if (props.getName().equals("page-title")) {
710 url.append("&page-title=");
711 url.append(props.getValue());
712 GWT.log(props.getName() + "=" + props.getValue());
713 }
714 }
715 }
716 }
717
718 public String createPrintUrl() {
695 MapOutputTab ot = (MapOutputTab)getOutputTab(); 719 MapOutputTab ot = (MapOutputTab)getOutputTab();
696 Collection collection = ot.getCollection(); 720 Collection collection = ot.getCollection();
697 String uuid = collection.identifier(); 721 String uuid = collection.identifier();
698 722
699 String mapType = collection.getOutputModes().containsKey("floodmap") 723 String mapType = collection.getOutputModes().containsKey("floodmap")
700 ? "floodmap" 724 ? "floodmap"
701 : "map"; 725 : "map";
702 726
703 String url = GWT.getModuleBaseURL() + "map-print?"; 727 StringBuilder url = new StringBuilder();
728 url.append(GWT.getModuleBaseURL());
729 url.append("map-print?");
704 730
705 Map map = getMap(); 731 Map map = getMap();
706 Bounds bounds = map.getExtent(); 732 Bounds bounds = map.getExtent();
707 733
708 if (bounds != null) { 734 if (bounds != null) {
709 try { 735 try {
710 double minX = bounds.getLowerLeftX(); 736 url.append("minx=");
711 double maxX = bounds.getUpperRightX(); 737 url.append(bounds.getLowerLeftX());
712 double minY = bounds.getLowerLeftY(); 738 url.append("&");
713 double maxY = bounds.getUpperRightY(); 739
714 url += "minx=" + minX + "&"; 740 url.append("maxx=");
715 url += "maxx=" + maxX + "&"; 741 url.append(bounds.getUpperRightX());
716 url += "miny=" + minY + "&"; 742 url.append("&");
717 url += "maxy=" + maxY + "&"; 743
744 url.append("miny=");
745 url.append(bounds.getLowerLeftY());
746 url.append("&");
747
748 url.append("maxy=");
749 url.append(bounds.getUpperRightY());
750 url.append("&");
718 } 751 }
719 catch (Exception e) { 752 catch (Exception e) {
720 // XXX: Ignore it. bounds.getXXX() throw 753 // XXX: Ignore it. bounds.getXXX() throw
721 // exceptions when bound is invalid. :-/ 754 // exceptions when bound is invalid. :-/
722 } 755 }
723 } 756 }
724 757
725 url += "uuid=" + uuid + "&maptype=" + mapType; 758 url.append("uuid=");
726 759 url.append(uuid);
727 return url; 760 url.append("&maptype=");
761 url.append(mapType);
762
763 appendPrintSettingsToUrl(collection, url);
764
765 return url.toString();
728 } 766 }
729 767
730 768
731 public void updateThemes(ThemeList themeList) { 769 public void updateThemes(ThemeList themeList) {
732 if (legendWindow != null) { 770 if (legendWindow != null) {

http://dive4elements.wald.intevation.org