- Timestamp:
- 06/29/11 07:17:42 (11 months ago)
- Location:
- print/trunk
- Files:
-
- 12 modified
-
.gitignore (modified) (1 diff)
-
build.gradle (modified) (1 diff)
-
src/main/java/org/mapfish/print/PDFUtils.java (modified) (3 diffs)
-
src/main/java/org/mapfish/print/config/Config.java (modified) (1 diff)
-
src/main/java/org/mapfish/print/config/layout/ColumnsBlock.java (modified) (6 diffs)
-
src/main/java/org/mapfish/print/config/layout/LegendsBlock.java (modified) (5 diffs)
-
src/main/java/org/mapfish/print/config/layout/MapBlock.java (modified) (2 diffs)
-
src/main/java/org/mapfish/print/map/readers/WMSServerInfo.java (modified) (1 diff)
-
src/main/java/org/mapfish/print/map/renderers/SVGTileRenderer.java (modified) (3 diffs)
-
src/main/java/org/mapfish/print/servlet/BaseMapServlet.java (modified) (6 diffs)
-
src/main/webapp/WEB-INF/web.xml (modified) (1 diff)
-
src/main/webapp/config.yaml (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
print/trunk/.gitignore
r3404 r3826 1 .gradle 1 .gradle/ 2 2 build/ 3 3 .DS_Store 4 4 .classpath 5 .project 5 .project/ 6 6 .settings/ 7 depfile.txt 8 docs 9 lib/ 10 print-lib/ 11 print-servlet/ 12 print-standalone/ 13 samples/ 14 todo 15 .svn/ 16 src/main/webapp/.smap.yaml.swp 17 src/main/webapp/Copy of configVector.yaml 18 src/main/webapp/portal.yaml~ 19 src/main/webapp/smap.yaml~ 20 build.sbt -
print/trunk/build.gradle
r3825 r3826 57 57 } 58 58 59 task standalone ( dependsOn: test,type: Jar) {59 task standalone (type: Jar) { 60 60 baseName = "print-standalone" 61 61 -
print/trunk/src/main/java/org/mapfish/print/PDFUtils.java
r3789 r3826 36 36 import org.apache.batik.gvt.GraphicsNode; 37 37 import org.apache.batik.util.XMLResourceDescriptor; 38 import org.apache.commons.httpclient.*;39 38 import org.apache.commons.httpclient.Header; 40 39 import org.apache.commons.httpclient.cookie.CookiePolicy; … … 51 50 import java.net.URI; 52 51 import java.net.URL; 53 import java.net.URLConnection;54 52 import java.text.SimpleDateFormat; 55 53 import java.util.Date; … … 484 482 } 485 483 return myOffset; 484 } 485 486 public static Chunk createImageChunkFromSVG(RenderingContext context, String iconItem, double maxIconWidth, double maxIconHeight) throws IOException { 487 return new Chunk(PDFUtils.createImageFromSVG(context, iconItem, maxIconWidth, maxIconHeight), 0f, 0f, true); 486 488 } 487 489 -
print/trunk/src/main/java/org/mapfish/print/config/Config.java
r3789 r3826 75 75 private int globalParallelFetches = 5; 76 76 private int perHostParallelFetches = 5; 77 private int socketTimeout = 3*60*1000;78 private int connectionTimeout = 30*1000;77 private int socketTimeout = 40*60*1000; // 40 minutes //3*60*1000; 78 private int connectionTimeout = 40*60*1000; // 40 minutes //30*1000; 79 79 80 80 private boolean tilecacheMerging = false; -
print/trunk/src/main/java/org/mapfish/print/config/layout/ColumnsBlock.java
r3789 r3826 44 44 private int width = Integer.MIN_VALUE; 45 45 */ 46 private float absoluteX = Float.MIN_VALUE;47 private float absoluteY = Float.MIN_VALUE;48 private float width = Float.MIN_VALUE;46 private double absoluteX = Double.MIN_VALUE; 47 private double absoluteY = Double.MIN_VALUE; 48 private double width = Double.MIN_VALUE; 49 49 private int nbColumns = Integer.MIN_VALUE; 50 50 private TableConfig config = null; … … 57 57 final PdfPTable table = PDFUtils.buildTable(items, params, context, nbColumns, config); 58 58 if (table != null) { 59 table.setTotalWidth( width);59 table.setTotalWidth((float) width); 60 60 table.setLockedWidth(true); 61 61 … … 64 64 } 65 65 66 table.writeSelectedRows(0, -1, absoluteX,absoluteY, dc);66 table.writeSelectedRows(0, -1, (float) absoluteX, (float) absoluteY, dc); 67 67 } 68 68 } … … 89 89 } 90 90 91 public void setAbsoluteX( floatabsoluteX) {91 public void setAbsoluteX(double absoluteX) { 92 92 this.absoluteX = absoluteX; 93 93 } 94 94 95 public void setAbsoluteY( floatabsoluteY) {95 public void setAbsoluteY(double absoluteY) { 96 96 this.absoluteY = absoluteY; 97 97 } … … 106 106 107 107 public boolean isAbsolute() { 108 return absoluteX != Float.MIN_VALUE &&109 absoluteY != Float.MIN_VALUE &&110 width != Float.MIN_VALUE;108 return absoluteX != Double.MIN_VALUE && 109 absoluteY != Double.MIN_VALUE && 110 width != Double.MIN_VALUE; 111 111 } 112 112 … … 130 130 if (items.size() < 1) throw new InvalidValueException("items", "[]"); 131 131 132 if (!((absoluteX != Float.MIN_VALUE && absoluteY != Float.MIN_VALUE && width != Float.MIN_VALUE) ||133 (absoluteX == Float.MIN_VALUE && absoluteY == Float.MIN_VALUE && width == Float.MIN_VALUE))) {132 if (!((absoluteX != Double.MIN_VALUE && absoluteY != Double.MIN_VALUE && width != Double.MIN_VALUE) || 133 (absoluteX == Double.MIN_VALUE && absoluteY == Double.MIN_VALUE && width == Double.MIN_VALUE))) { 134 134 throw new InvalidValueException("absoluteX, absoluteY or width", "all of them must be defined or none"); 135 135 } -
print/trunk/src/main/java/org/mapfish/print/config/layout/LegendsBlock.java
r3789 r3826 23 23 import com.lowagie.text.Font; 24 24 import com.lowagie.text.FontFactory; 25 import com.lowagie.text.Image;26 25 import com.lowagie.text.Paragraph; 27 26 import com.lowagie.text.pdf.BaseFont; … … 94 93 final PJsonArray icons = node.optJSONArray("icons"); 95 94 96 Image image = null;97 98 95 final Paragraph result = new Paragraph(); 99 96 result.setFont(pdfFont); 100 97 if (icon != null) { 101 result.add(PDFUtils.createImageChunk(context, maxIconWidth, maxIconHeight, URI.create(icon), 0.0f)); 102 result.add(" "); 98 try { 99 if (icon.indexOf("image%2Fsvg%2Bxml") != -1) { // TaODO: make this cleaner 100 result.add(PDFUtils.createImageChunkFromSVG(context, icon, maxIconWidth, maxIconHeight)); 101 } else { 102 result.add(PDFUtils.createImageChunk(context, maxIconWidth, maxIconHeight, URI.create(icon), 0.0f)); 103 } 104 result.add(" "); 105 } catch (IOException ioe) { 106 LOGGER.warn("Failed to load " + icon + " with " + ioe.getMessage()); 107 } catch (InvalidValueException e) { 108 LOGGER.warn("Failed to create image chunk: " + e.getMessage()); 109 } 103 110 } 104 111 if (icons != null) { … … 107 114 try { 108 115 if (iconItem.indexOf("image%2Fsvg%2Bxml") != -1) { // TaODO: make this cleaner 109 image = PDFUtils.createImageFromSVG(context, iconItem, maxIconWidth, maxIconHeight);116 result.add(PDFUtils.createImageChunkFromSVG(context, iconItem, maxIconWidth, maxIconHeight)); 110 117 } else { 111 118 result.add(PDFUtils.createImageChunk(context, maxIconWidth, maxIconHeight, URI.create(iconItem), 0.0f)); … … 119 126 } 120 127 } 121 result.add(name);122 128 123 129 final PdfPCell cell = new PdfPCell(result); … … 125 131 cell.setPadding(0f); 126 132 cell.setPaddingLeft((float) indent); 127 if (image != null) { 128 cell.addElement(image); 129 } 133 134 result.add(name); 130 135 131 136 if (getBackgroundColorVal(context, params) != null) { -
print/trunk/src/main/java/org/mapfish/print/config/layout/MapBlock.java
r3789 r3826 186 186 187 187 public void printClientConfig(JSONWriter json) throws JSONException { 188 /** 189 * Changed width and height to be double from int to accomodate double values in yaml config 190 */ 188 191 json.object(); 189 int w;192 double w; //int w; 190 193 try { 191 w = Integer.parseInt(width);194 w = Math.round(Double.parseDouble(width)); //w = Integer.parseInt(width); 192 195 } catch (NumberFormatException e) { 193 196 w = 0; … … 195 198 json.key("width").value(w); 196 199 197 int h;200 double h; //int h; 198 201 try { 199 h = Integer.parseInt(height);202 h = Math.round(Double.parseDouble(height)); //h = Integer.parseInt(height); 200 203 } catch (NumberFormatException e) { 201 204 h = 0; -
print/trunk/src/main/java/org/mapfish/print/map/readers/WMSServerInfo.java
r3789 r3826 88 88 } catch (Exception e) { 89 89 LOGGER.info("Error while getting capabilities for "+uri+". The print module will assume it's a standard WMS."); 90 String stackTrace = ""; 91 for (StackTraceElement el : e.getStackTrace()) { 92 stackTrace += el.toString() +"\n"; 93 } 94 LOGGER.info(stackTrace); 90 95 result = new WMSServerInfo(); 91 96 } -
print/trunk/src/main/java/org/mapfish/print/map/renderers/SVGTileRenderer.java
r3789 r3826 56 56 public static final Logger LOGGER = Logger.getLogger(SVGTileRenderer.class); 57 57 58 private static finalDocument svgZoomOut;58 private static Document svgZoomOut; 59 59 60 60 static { 61 makeSvgZoomOut(); 62 } 63 private static void makeSvgZoomOut() { 61 64 DOMParser parser = new DOMParser(); 62 65 String svgZoomFileName = "svgZoomOut.xsl"; … … 140 143 final float zoomFactor = transformer.getSvgFactor() * context.getStyleFactor(); 141 144 if (svgZoomOut != null && zoomFactor != 1.0f) { 145 javax.xml.transform.Transformer xslt = null; 142 146 try { 143 147 DOMResult transformedSvg = new DOMResult(); 144 148 final TransformerFactory factory = TransformerFactory.newInstance(); 145 javax.xml.transform.Transformer xslt = factory.newTransformer(new DOMSource(svgZoomOut)); 149 if (svgZoomOut.getTextContent() == null) { 150 makeSvgZoomOut(); // a bit of a hack 151 } 152 xslt = factory.newTransformer(new DOMSource(svgZoomOut)); 146 153 147 154 //TODO: may want a different zoom factor in function of the layer and the type (symbol, line or font) … … 168 175 169 176 } catch (Exception e) { 177 if (xslt == null) { 178 // some more information about the error 179 LOGGER.error("xslt = NULL, zoomFactor = "+ 180 zoomFactor +", svgZoomOut = "+ svgZoomOut 181 +"\nsvgZoomOut.getTextContent() = "+ svgZoomOut.getTextContent() 182 +"\nsvgZoomOut.getChildNodes().getLength() = "+ svgZoomOut.getChildNodes().getLength()); 183 } 184 170 185 context.addError(e); 171 186 return null; -
print/trunk/src/main/java/org/mapfish/print/servlet/BaseMapServlet.java
r3789 r3826 41 41 private Map<String, MapPrinter> printers = null; 42 42 private long lastModified = 0L; 43 private long defaultLastModified = 0L; 43 44 private Map<String,Long> lastModifieds = null; 44 45 … … 58 59 throw new ServletException("Missing configuration in web.xml 'web-app/servlet/init-param[param-name=config]' or 'web-app/context-param[param-name=config]'"); 59 60 } 61 //String debugPath = ""; 60 62 61 63 File configFile = null; … … 63 65 if (lastModifieds == null) { 64 66 lastModifieds = new HashMap<String, Long>(); 67 //debugPath += "new HashMap\n"; 65 68 } 66 try { 67 printer = printers.get(app); 68 } catch (Exception e) { 69 printer = null; 70 } 69 if (printers instanceof HashMap && printers.containsKey(app)) { 70 printer = printers.get(app); 71 //debugPath += "get printer from hashmap\n"; 72 } else { 73 printer = null; 74 //debugPath += "printer = null 1\n"; 75 } 71 76 configFile = new File(app +".yaml"); 72 77 } else { 73 78 configFile = new File(configPath); 79 //debugPath += "configFile = new ..., 1\n"; 74 80 } 75 81 if (!configFile.isAbsolute()) { 76 82 if (app != null) { 83 //debugPath += "config is absolute app = "+app+"\n"; 77 84 configFile = new File(getServletContext().getRealPath(app +".yaml")); 78 85 } else { 79 86 configFile = new File(getServletContext().getRealPath(configPath)); 87 //debugPath += "config is absolute app DEFAULT\n"; 80 88 } 81 89 } 82 90 if (app != null) { 83 try{91 if (lastModifieds instanceof HashMap && lastModifieds.containsKey(app)) { 84 92 lastModified = lastModifieds.get(app); 85 } catch (Exception e) { 86 lastModified = 0L; 87 } 93 //debugPath += "app = "+app+" lastModifieds has key and gotten: "+ lastModified +"\n"; 94 } else { 95 lastModified = 0L; 96 //debugPath += "app = "+app+" lastModifieds has NOT key and gotten: "+ lastModified +" (0L)\n"; 97 } 98 } else { 99 lastModified = defaultLastModified; // this is a fix for when configuration files have changed 100 //debugPath += "app = NULL lastModifieds from defaultLastModified: "+ lastModified +"\n"; 88 101 } 89 102 … … 93 106 try { 94 107 printer.stop(); 108 109 //debugPath += "printer stopped, setting NULL\n"; 95 110 } catch (NullPointerException npe) { 96 LOGGER.info("BaseMapServlet.java: printer was not stopped. This happens when a switch between applications happens. ");111 LOGGER.info("BaseMapServlet.java: printer was not stopped. This happens when a switch between applications happens.\n"+ npe); 97 112 } 98 113 99 114 printer = null; 115 if (app != null) { 116 LOGGER.info("Printer for "+ app +" stopped"); 117 printers.put(app, null); 118 } 100 119 } 101 120 102 121 if (printer == null) { 103 122 lastModified = configFile.lastModified(); 123 //debugPath += "printer == null, lastModified from configFile = "+lastModified+"\n"; 104 124 try { 105 125 LOGGER.info("Loading configuration file: " + configFile.getAbsolutePath()); … … 108 128 if (printers == null) { 109 129 printers = new HashMap<String, MapPrinter>(); 130 //debugPath += "printers = new HashMap , printer == null, app = "+app+"\n"; 110 131 } 111 132 printers.put(app, printer); 112 133 lastModifieds.put(app, lastModified); 134 //debugPath += "putting app = "+app+" HashMaps: printer and lastModified: "+lastModified+"\n"; 135 } else { 136 defaultLastModified = lastModified; // need this for default application 137 //debugPath += "defaultLastModified = "+defaultLastModified+" 123\n"; 113 138 } 114 139 } catch (FileNotFoundException e) { … … 116 141 } 117 142 } 143 144 //LOGGER.info(debugPath); 145 /* 146 try { 147 if (app == null) { 148 throw new Exception("Just to see the stack trace"); 149 } 150 throw new Exception("Just to see the stack trace"); 151 } catch (Exception e) { 152 StackTraceElement stelements[] = e.getStackTrace(); 153 for (StackTraceElement s : stelements) { 154 LOGGER.warn("StackTraceElement ASD: "+ s.toString()); 155 } 156 //LOGGER.warn("app == NULL:\n"+ e.getStackTrace()); 157 } 158 */ 118 159 return printer; 119 160 } -
print/trunk/src/main/webapp/WEB-INF/web.xml
r3397 r3826 9 9 <init-param> 10 10 <param-name>config</param-name> 11 <param-value>config .yaml</param-value>11 <param-value>configVector.yaml</param-value> 12 12 </init-param> 13 13 </servlet> -
print/trunk/src/main/webapp/config.yaml
r3649 r3826 45 45 host: demo.mapfish.org 46 46 port: 80 47 - !dnsMatch 48 host: basemap-web.zen.landcareresearch.co.nz 49 port: 80 47 50 48 51 # the default fileName for the files downloaded from the servlet
