Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/server/ChartOutputServiceImpl.java @ 1344:51d4b51a51ed
Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
flys-client/trunk@2998 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 17 Oct 2011 17:33:27 +0000 |
parents | e74bf6bfeeb6 |
children | ab8eb2f544f2 |
comparison
equal
deleted
inserted
replaced
1343:0d3d3860beb5 | 1344:51d4b51a51ed |
---|---|
36 String serverUrl = req.getParameter("server"); | 36 String serverUrl = req.getParameter("server"); |
37 String uuid = req.getParameter("uuid"); | 37 String uuid = req.getParameter("uuid"); |
38 String type = req.getParameter("type"); | 38 String type = req.getParameter("type"); |
39 String locale = req.getParameter("locale"); | 39 String locale = req.getParameter("locale"); |
40 | 40 |
41 prepareHeader(req, resp); | |
42 | |
41 Document request = ClientProtocolUtils.newOutCollectionDocument( | 43 Document request = ClientProtocolUtils.newOutCollectionDocument( |
42 uuid, type, type, | 44 uuid, type, type, |
43 ChartServiceHelper.getChartAttributes(prepareChartAttributes(req))); | 45 ChartServiceHelper.getChartAttributes(prepareChartAttributes(req))); |
44 | 46 |
45 HttpClient client = new HttpClientImpl(serverUrl, locale); | 47 HttpClient client = new HttpClientImpl(serverUrl, locale); |
68 attr.put("height", req.getParameter("height")); | 70 attr.put("height", req.getParameter("height")); |
69 attr.put("minx", req.getParameter("minx")); | 71 attr.put("minx", req.getParameter("minx")); |
70 attr.put("maxx", req.getParameter("maxx")); | 72 attr.put("maxx", req.getParameter("maxx")); |
71 attr.put("miny", req.getParameter("miny")); | 73 attr.put("miny", req.getParameter("miny")); |
72 attr.put("maxy", req.getParameter("maxy")); | 74 attr.put("maxy", req.getParameter("maxy")); |
75 attr.put("format", req.getParameter("format")); | |
73 | 76 |
74 return attr; | 77 return attr; |
75 } | 78 } |
79 | |
80 | |
81 protected void prepareHeader( | |
82 HttpServletRequest req, | |
83 HttpServletResponse resp | |
84 ) { | |
85 String export = req.getParameter("export"); | |
86 | |
87 if (export != null && export.equals("true")) { | |
88 String format = req.getParameter("format"); | |
89 | |
90 if (format == null || format.length() == 0) { | |
91 format = "png"; | |
92 } | |
93 | |
94 String fn = "chart_export" + getFileExtension(format); | |
95 | |
96 resp.setHeader("Content-Disposition", "attachment;filename=" + fn); | |
97 resp.setHeader("Content-Type", getMimeType(format)); | |
98 } | |
99 } | |
100 | |
101 | |
102 protected String getFileExtension(String format) { | |
103 if (format.equals("png")) { | |
104 return ".png"; | |
105 } | |
106 else if (format.equals("pdf")) { | |
107 return ".pdf"; | |
108 } | |
109 else if (format.equals("svg")) { | |
110 return ".svg"; | |
111 } | |
112 | |
113 return ".png"; | |
114 } | |
115 | |
116 | |
117 protected String getMimeType(String format) { | |
118 if (format.equals("png")) { | |
119 return "image/png"; | |
120 } | |
121 else if (format.equals("pdf")) { | |
122 return "application/pdf"; | |
123 } | |
124 else if (format.equals("svg")) { | |
125 return "svg+xml"; | |
126 } | |
127 | |
128 return "image/png"; | |
129 } | |
76 } | 130 } |
77 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 131 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |