diff options
author | Jeremias Maerki <jeremias@apache.org> | 2003-03-07 10:47:51 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2003-03-07 10:47:51 +0000 |
commit | b6dc3aa0602b54985d16f36e92a60c7742e4159f (patch) | |
tree | 072be760fe808e7da5a657af4524700d57c4ed95 /examples/plan/src | |
parent | c24aba310fa547801100871b2333636628518e7c (diff) | |
download | xmlgraphics-fop-b6dc3aa0602b54985d16f36e92a60c7742e4159f.tar.gz xmlgraphics-fop-b6dc3aa0602b54985d16f36e92a60c7742e4159f.zip |
Switched to long licence
Some general checkstyle fixing
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196043 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'examples/plan/src')
11 files changed, 782 insertions, 208 deletions
diff --git a/examples/plan/src/org/apache/fop/plan/ActionInfo.java b/examples/plan/src/org/apache/fop/plan/ActionInfo.java index 07cdde241..975bc1db4 100644 --- a/examples/plan/src/org/apache/fop/plan/ActionInfo.java +++ b/examples/plan/src/org/apache/fop/plan/ActionInfo.java @@ -1,23 +1,69 @@ -/* $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <jtauber@jtauber.com>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + */ package org.apache.fop.plan; import java.util.Date; public class ActionInfo { - Date startDate; - Date endDate; - String owner; - String label; - int type = TASK; + public static final int TASK = 1; public static final int MILESTONE = 2; public static final int GROUPING = 3; - String dependant = ""; + + private Date startDate; + private Date endDate; + private String owner; + private String label; + private int type = TASK; + private String dependant = ""; public void setType(int t) { type = t; diff --git a/examples/plan/src/org/apache/fop/plan/EventList.java b/examples/plan/src/org/apache/fop/plan/EventList.java index 93418d9e1..e6247951f 100644 --- a/examples/plan/src/org/apache/fop/plan/EventList.java +++ b/examples/plan/src/org/apache/fop/plan/EventList.java @@ -1,15 +1,60 @@ -/* $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <jtauber@jtauber.com>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + */ package org.apache.fop.plan; -import java.util.ArrayList; +import java.util.List; public class EventList { - ArrayList data = new ArrayList(); + + private List data = new java.util.ArrayList(); public void addGroupInfo(GroupInfo set) { data.add(set); diff --git a/examples/plan/src/org/apache/fop/plan/GroupInfo.java b/examples/plan/src/org/apache/fop/plan/GroupInfo.java index 5223ff38c..67f1c2f95 100644 --- a/examples/plan/src/org/apache/fop/plan/GroupInfo.java +++ b/examples/plan/src/org/apache/fop/plan/GroupInfo.java @@ -1,16 +1,61 @@ -/* $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <jtauber@jtauber.com>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + */ package org.apache.fop.plan; -import java.util.ArrayList; +import java.util.List; public class GroupInfo { - String name; - ArrayList actions = new ArrayList(); + + private String name; + private List actions = new java.util.ArrayList(); public GroupInfo(String n) { name = n; diff --git a/examples/plan/src/org/apache/fop/plan/Main.java b/examples/plan/src/org/apache/fop/plan/Main.java index cc2c12644..ae913fdf7 100644 --- a/examples/plan/src/org/apache/fop/plan/Main.java +++ b/examples/plan/src/org/apache/fop/plan/Main.java @@ -1,12 +1,58 @@ -/* $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <jtauber@jtauber.com>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + */ package org.apache.fop.plan; -import java.io.*; +import java.io.InputStream; +import java.io.Writer; + import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -14,28 +60,36 @@ import org.apache.batik.transcoder.svg2svg.SVGTranscoder; import org.apache.batik.transcoder.TranscoderInput; import org.apache.batik.transcoder.TranscoderOutput; +/** + * Sample command-line application for converting plan XML to SVG. + */ public class Main { + /** + * Main method. + * @param args command-line arguments + */ public static void main(String[] args) { Main main = new Main(); main.convert(args); System.exit(0); } - public Main() { - } - + /** + * Runs the conversion + * @param params command-line arguments + */ public void convert(String[] params) { if (params.length != 2) { System.out.println("arguments: plan.xml output.svg"); return; } try { - FileInputStream fis = new FileInputStream(params[0]); - Document doc = createSVGDocument(fis); + InputStream is = new java.io.FileInputStream(params[0]); + Document doc = createSVGDocument(is); SVGTranscoder svgT = new SVGTranscoder(); TranscoderInput input = new TranscoderInput(doc); - Writer ostream = new FileWriter(params[1]); + Writer ostream = new java.io.FileWriter(params[1]); TranscoderOutput output = new TranscoderOutput(ostream); svgT.transcode(input, output); ostream.flush(); @@ -46,6 +100,11 @@ public class Main { } } + /** + * Helper method to create the SVG document from the plan InputStream. + * @param is InputStream + * @return Document a DOM containing the SVG + */ public Document createSVGDocument(InputStream is) { Document doc = null; diff --git a/examples/plan/src/org/apache/fop/plan/PlanDrawer.java b/examples/plan/src/org/apache/fop/plan/PlanDrawer.java index 62932af48..31a801b05 100644 --- a/examples/plan/src/org/apache/fop/plan/PlanDrawer.java +++ b/examples/plan/src/org/apache/fop/plan/PlanDrawer.java @@ -1,16 +1,64 @@ -/* $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <jtauber@jtauber.com>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + */ package org.apache.fop.plan; import java.util.HashMap; import org.w3c.dom.Document; +/** + * This interface defines how a plan drawer is converted. + */ public interface PlanDrawer { - public Document createDocument(EventList data, float w, float h, + + Document createDocument(EventList data, float w, float h, HashMap hints); } diff --git a/examples/plan/src/org/apache/fop/plan/PlanElement.java b/examples/plan/src/org/apache/fop/plan/PlanElement.java index 6d4aaa662..93e27a8c0 100644 --- a/examples/plan/src/org/apache/fop/plan/PlanElement.java +++ b/examples/plan/src/org/apache/fop/plan/PlanElement.java @@ -1,9 +1,53 @@ -/* $Id$ - * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <jtauber@jtauber.com>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + */ package org.apache.fop.plan; import java.awt.geom.Point2D; @@ -14,34 +58,47 @@ import org.apache.fop.apps.FOPException; import org.w3c.dom.Document; import org.xml.sax.Attributes; +/** + * This class defines the plan element. + */ public class PlanElement extends PlanObj { - Document svgDoc = null; - float width; - float height; - boolean converted; + private Document svgDoc = null; + private float width; + private float height; + private boolean converted; + + /** + * @see org.apache.fop.fo.FONode#FONode(FONode) + */ public PlanElement(FONode parent) { super(parent); } + /** + * @see org.apache.fop.fo.FONode#handleAttrs(Attributes) + */ public void handleAttrs(Attributes attlist) throws FOPException { super.handleAttrs(attlist); createBasicDocument(); } + /** + * Converts the element to SVG. + */ public void convertToSVG() { try { - if(!converted) { - converted = true; - PlanRenderer pr = new PlanRenderer(); - pr.setFontInfo("Helvetica", 12); - svgDoc = pr.createSVGDocument(doc); - width = pr.getWidth(); - height = pr.getHeight(); - - doc = svgDoc; - } - } catch(Throwable t) { + if (!converted) { + converted = true; + PlanRenderer pr = new PlanRenderer(); + pr.setFontInfo("Helvetica", 12); + svgDoc = pr.createSVGDocument(doc); + width = pr.getWidth(); + height = pr.getHeight(); + + doc = svgDoc; + } + } catch (Throwable t) { getLogger().error("Could not convert Plan to SVG", t); width = 0; height = 0; @@ -49,18 +106,27 @@ public class PlanElement extends PlanObj { } + /** + * @see org.apache.fop.fo.XMLObj#getDocument() + */ public Document getDocument() { convertToSVG(); return doc; } + /** + * @see org.apache.fop.fo.XMLObj#getDocumentNamespace() + */ public String getDocumentNamespace() { - if(svgDoc == null) { + if (svgDoc == null) { return PlanElementMapping.URI; } return "http://www.w3.org/2000/svg"; } + /** + * @see org.apache.fop.fo.XMLObj#getDimension(Point2D) + */ public Point2D getDimension(Point2D view) { convertToSVG(); return new Point2D.Float(width, height); diff --git a/examples/plan/src/org/apache/fop/plan/PlanElementMapping.java b/examples/plan/src/org/apache/fop/plan/PlanElementMapping.java index 721cdbd2c..7a1fecb19 100644 --- a/examples/plan/src/org/apache/fop/plan/PlanElementMapping.java +++ b/examples/plan/src/org/apache/fop/plan/PlanElementMapping.java @@ -1,9 +1,53 @@ -/* $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <jtauber@jtauber.com>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + */ package org.apache.fop.plan; import org.apache.fop.fo.FOTreeBuilder; @@ -15,15 +59,19 @@ import org.w3c.dom.Document; import java.util.HashMap; +/** + * This class provides the element mapping for FOP. + */ public class PlanElementMapping implements ElementMapping { + /** The namespace for the plan extension */ public static final String URI = "http://xml.apache.org/fop/plan"; private static HashMap foObjs = null; private static synchronized void setupPlan() { if (foObjs == null) { - foObjs = new HashMap(); + foObjs = new java.util.HashMap(); foObjs.put("plan", new PE()); foObjs.put(DEFAULT, new PlanMaker()); @@ -31,6 +79,9 @@ public class PlanElementMapping implements ElementMapping { } } + /** + * @see org.apache.fop.fo.ElementMapping#addToBuilder(FOTreeBuilder) + */ public void addToBuilder(FOTreeBuilder builder) { setupPlan(); builder.addMapping(URI, foObjs); @@ -51,20 +102,20 @@ public class PlanElementMapping implements ElementMapping { static class PlanConverter implements XMLReader.Converter { public FopImage.ImageInfo convert(Document doc) { try { - PlanRenderer pr = new PlanRenderer(); - pr.setFontInfo("Helvetica", 12); - FopImage.ImageInfo info = new FopImage.ImageInfo(); - info.data = pr.createSVGDocument(doc); - info.width = (int)pr.getWidth(); - info.height = (int)pr.getHeight(); - info.mimeType = "image/svg+xml"; - info.str = "http://www.w3.org/2000/svg"; - - return info; - } catch(Throwable t) { + PlanRenderer pr = new PlanRenderer(); + pr.setFontInfo("Helvetica", 12); + FopImage.ImageInfo info = new FopImage.ImageInfo(); + info.data = pr.createSVGDocument(doc); + info.width = (int)pr.getWidth(); + info.height = (int)pr.getHeight(); + info.mimeType = "image/svg+xml"; + info.str = "http://www.w3.org/2000/svg"; + + return info; + } catch (Throwable t) { + /**@todo Log this properly! */ } return null; - } } diff --git a/examples/plan/src/org/apache/fop/plan/PlanHints.java b/examples/plan/src/org/apache/fop/plan/PlanHints.java index 1090cb48a..691f7bf8d 100644 --- a/examples/plan/src/org/apache/fop/plan/PlanHints.java +++ b/examples/plan/src/org/apache/fop/plan/PlanHints.java @@ -1,20 +1,77 @@ -/* $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <jtauber@jtauber.com>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + */ package org.apache.fop.plan; -public class PlanHints { +/** + * This interface defines some constants for use in the plan package. + */ +public interface PlanHints { + + /** Border attribute */ public static final String PLAN_BORDER = "border"; + /** Legend attribute */ public static final String PLAN_LEGEND = "legend"; + /** Font family attribute */ public static final String FONT_FAMILY = "font-family"; + /** Font size attribute */ public static final String FONT_SIZE = "font-size"; + /** Legent type attribute */ public static final String LEGEND_TYPE = "legendType"; + /** Locale attribute */ public static final String LOCALE = "locale"; + /** Label type attribute */ public static final String LABEL_TYPE = "labelType"; + /** Label font size attribute */ public static final String LABEL_FONT_SIZE = "labelFontSize"; + /** Label font attribute */ public static final String LABEL_FONT = "labelFont"; } diff --git a/examples/plan/src/org/apache/fop/plan/PlanObj.java b/examples/plan/src/org/apache/fop/plan/PlanObj.java index c2e46822e..fa87c56d3 100644 --- a/examples/plan/src/org/apache/fop/plan/PlanObj.java +++ b/examples/plan/src/org/apache/fop/plan/PlanObj.java @@ -1,9 +1,53 @@ -/* $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <jtauber@jtauber.com>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + */ package org.apache.fop.plan; // FOP @@ -18,13 +62,16 @@ import org.apache.fop.fo.XMLObj; public class PlanObj extends XMLObj { /** - * + * Creates a new Plan object. * @param parent the parent formatting object */ public PlanObj(FONode parent) { super(parent); } + /** + * @see org.apache.fop.fo.XMLObj#getNameSpace() + */ public String getNameSpace() { return "http://xml.apache.org/fop/plan"; } diff --git a/examples/plan/src/org/apache/fop/plan/PlanRenderer.java b/examples/plan/src/org/apache/fop/plan/PlanRenderer.java index 1aa3025ea..5ddbaf123 100644 --- a/examples/plan/src/org/apache/fop/plan/PlanRenderer.java +++ b/examples/plan/src/org/apache/fop/plan/PlanRenderer.java @@ -1,43 +1,87 @@ -/* $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <jtauber@jtauber.com>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + */ package org.apache.fop.plan; -import java.util.*; -import java.text.*; -import java.awt.*; -import java.awt.geom.AffineTransform; -import java.awt.geom.Rectangle2D; -import java.awt.font.FontRenderContext; -import org.w3c.dom.*; -import org.w3c.dom.svg.*; -import org.w3c.dom.css.*; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.Locale; +import java.util.StringTokenizer; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; import org.apache.batik.dom.svg.SVGDOMImplementation; public class PlanRenderer { - final static String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI; - String fontFamily = "sansserif"; - float fontSize = 12; + + private static final String SVG_NAMESPACE = SVGDOMImplementation.SVG_NAMESPACE_URI; + + private String fontFamily = "sansserif"; + private float fontSize = 12; private String type = ""; private String lang = ""; private String country = ""; private String variant = ""; - float width; - float height; - float topEdge; - float rightEdge; - HashMap hints = new HashMap(); + private float width; + private float height; + private float topEdge; + private float rightEdge; + private HashMap hints = new HashMap(); - String[] colours; - String[] darkcolours; - - public PlanRenderer() { - } + private String[] colours; + private String[] darkcolours; public void setFontInfo(String fam, float si) { fontFamily = fam; diff --git a/examples/plan/src/org/apache/fop/plan/SimplePlanDrawer.java b/examples/plan/src/org/apache/fop/plan/SimplePlanDrawer.java index 237a58749..dca24b6c8 100644 --- a/examples/plan/src/org/apache/fop/plan/SimplePlanDrawer.java +++ b/examples/plan/src/org/apache/fop/plan/SimplePlanDrawer.java @@ -1,52 +1,109 @@ -/* $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "FOP" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ============================================================================ + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation and was originally created by + * James Tauber <jtauber@jtauber.com>. For more information on the Apache + * Software Foundation, please see <http://www.apache.org/>. + */ package org.apache.fop.plan; -import org.apache.fop.svg.SVGUtilities; - -import java.util.*; -import java.text.*; -import java.awt.*; -import java.awt.geom.AffineTransform; -import java.awt.geom.Rectangle2D; -import java.awt.font.FontRenderContext; +import java.text.DateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; -import org.w3c.dom.*; -import org.w3c.dom.svg.*; -import org.w3c.dom.css.*; +import org.w3c.dom.DOMImplementation; +import org.w3c.dom.Document; +import org.w3c.dom.Element; import org.apache.batik.dom.svg.SVGDOMImplementation; +import org.apache.fop.svg.SVGUtilities; +/** + * Simple plan drawer implementation. + */ public class SimplePlanDrawer implements PlanDrawer { - final static String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI; - float fontSize; - HashMap hints; - java.awt.Font font = null; - boolean bord = false; - float lSpace = 15; - float width; - float height; - float topEdge; - float rightEdge; - - String[] colours; - String[] darkcolours; - - Date startDate; - Date endDate; - + + private static final String SVG_NAMESPACE = SVGDOMImplementation.SVG_NAMESPACE_URI; + + private float fontSize; + private HashMap hints; + private java.awt.Font font = null; + private boolean bord = false; + private float lSpace = 15; + private float width; + private float height; + private float topEdge; + private float rightEdge; + + private String[] colours; + private String[] darkcolours; + + private Date startDate; + private Date endDate; + + /** + * Sets the start date. + * @param sd start date + */ public void setStartDate(Date sd) { startDate = sd; } + /** + * Sets the end date. + * @param ed end date + */ public void setEndDate(Date ed) { endDate = ed; } + /** + * @see org.apache.fop.plan.PlanDrawer#createDocument(EventList, float, float, HashMap) + */ public Document createDocument(EventList data, float w, float h, HashMap hints) { this.width = w; @@ -58,22 +115,23 @@ public class SimplePlanDrawer implements PlanDrawer { String title = ""; DOMImplementation impl = - SVGDOMImplementation.getDOMImplementation(); - Document doc = impl.createDocument(svgNS, "svg", null); + SVGDOMImplementation.getDOMImplementation(); + Document doc = impl.createDocument(SVG_NAMESPACE, "svg", null); Element svgRoot = doc.getDocumentElement(); svgRoot.setAttributeNS(null, "width", "" + width); svgRoot.setAttributeNS(null, "height", "" + height); svgRoot.setAttributeNS(null, "style", - "font-size:" + 8 + ";font-family:" + - hints.get(PlanHints.FONT_FAMILY)); + "font-size:" + 8 + + ";font-family:" + + hints.get(PlanHints.FONT_FAMILY)); - font = new java.awt.Font( (String) hints.get(PlanHints.FONT_FAMILY), - java.awt.Font.PLAIN, (int) fontSize); + font = new java.awt.Font((String)hints.get(PlanHints.FONT_FAMILY), + java.awt.Font.PLAIN, (int)fontSize); if (bord) { Element border = - SVGUtilities.createRect(doc, 0, 0, width, height); + SVGUtilities.createRect(doc, 0, 0, width, height); border.setAttributeNS(null, "style", "stroke:black;fill:none"); svgRoot.appendChild(border); } @@ -104,7 +162,7 @@ public class SimplePlanDrawer implements PlanDrawer { Date lastWeek = startDate; Date future = endDate; Calendar lw = Calendar.getInstance(); - if(lastWeek == null || future == null) { + if (lastWeek == null || future == null) { int dow = lw.get(Calendar.DAY_OF_WEEK); lw.add(Calendar.DATE, -dow - 6); lastWeek = lw.getTime(); @@ -123,15 +181,15 @@ public class SimplePlanDrawer implements PlanDrawer { svgRoot.appendChild(line); Element clip1 = SVGUtilities.createClip(doc, - SVGUtilities.createPath(doc, - "m0 0l126 0l0 " + height + "l-126 0z"), "clip1"); + SVGUtilities.createPath(doc, + "m0 0l126 0l0 " + height + "l-126 0z"), "clip1"); Element clip2 = SVGUtilities.createClip(doc, - SVGUtilities.createPath(doc, - "m130 0l66 0l0 " + height + "l-66 0z"), "clip2"); + SVGUtilities.createPath(doc, + "m130 0l66 0l0 " + height + "l-66 0z"), "clip2"); Element clip3 = SVGUtilities.createClip(doc, - SVGUtilities.createPath(doc, - "m200 0l" + (width - 200) + " 0l0 " + height + "l-" + - (width - 200) + " 0z"), "clip3"); + SVGUtilities.createPath(doc, + "m200 0l" + (width - 200) + " 0l0 " + height + "l-" + + (width - 200) + " 0z"), "clip3"); svgRoot.appendChild(clip1); svgRoot.appendChild(clip2); svgRoot.appendChild(clip3); @@ -155,9 +213,10 @@ public class SimplePlanDrawer implements PlanDrawer { offset++; if (count % 7 == 0 || count % 7 == 1) { Element rect = SVGUtilities.createRect(doc, - 200 + (offset - 1) * (width - 200) / (totalDays - 2), - (float)(topEdge + 0.5), (width - 200) / (totalDays - 3), - height - 1 - topEdge); + 200 + (offset - 1) * (width - 200) / (totalDays - 2), + (float)(topEdge + 0.5), + (width - 200) / (totalDays - 3), + height - 1 - topEdge); rect.setAttributeNS(null, "style", "stroke:none;fill:rgb(230,230,230)"); svgRoot.appendChild(rect); } @@ -208,44 +267,51 @@ public class SimplePlanDrawer implements PlanDrawer { int left = 200; int right = 500; - int daysToStart = (int)((start.getTime() - - lastWeek.getTime() + 43200000) / 86400000); - int days = (int)((end.getTime() - start.getTime() + - 43200000) / 86400000); + int daysToStart = (int)((start.getTime() + - lastWeek.getTime() + 43200000) / 86400000); + int days = (int)((end.getTime() - start.getTime() + + 43200000) / 86400000); int daysFromEnd = - (int)((future.getTime() - end.getTime() + - 43200000) / 86400000); + (int)((future.getTime() - end.getTime() + + 43200000) / 86400000); Element taskGraphic; switch (type) { case ActionInfo.TASK: taskGraphic = SVGUtilities.createRect(doc, - left + daysToStart * 300 / (totalDays - 2), - topEdge + 2, days * 300 / (totalDays - 2), 10); - taskGraphic.setAttributeNS(null, "style", "stroke:black;fill:blue;stroke-width:1;clip-path:url(#clip3)"); + left + daysToStart * 300 / (totalDays - 2), + topEdge + 2, days * 300 / (totalDays - 2), 10); + taskGraphic.setAttributeNS(null, + "style", + "stroke:black;fill:blue;stroke-width:1;clip-path:url(#clip3)"); g.appendChild(taskGraphic); break; case ActionInfo.MILESTONE: taskGraphic = SVGUtilities.createPath(doc, - "m " + (left + - daysToStart * 300 / (totalDays - 2) - 6) + - " " + (topEdge + 6) + "l6 6l6-6l-6-6z"); - taskGraphic.setAttributeNS(null, "style", "stroke:black;fill:black;stroke-width:1;clip-path:url(#clip3)"); + "m " + (left + + daysToStart * 300 / (totalDays - 2) - 6) + + " " + (topEdge + 6) + "l6 6l6-6l-6-6z"); + taskGraphic.setAttributeNS(null, + "style", + "stroke:black;fill:black;stroke-width:1;clip-path:url(#clip3)"); g.appendChild(taskGraphic); text = SVGUtilities.createText(doc, - left + daysToStart * 300 / (totalDays - 2) + 8, - topEdge + 9, df.format(start)); + left + daysToStart * 300 / (totalDays - 2) + 8, + topEdge + 9, df.format(start)); g.appendChild(text); break; case ActionInfo.GROUPING: taskGraphic = SVGUtilities.createPath(doc, - "m " + (left + - daysToStart * 300 / (totalDays - 2) - 6) + - " " + (topEdge + 6) + "l6 -6l" + - (days * 300 / (totalDays - 2)) + - " 0l6 6l-6 6l-4-4l" + - - (days * 300 / (totalDays - 2) - 8) + " 0l-4 4l-6-6z"); - taskGraphic.setAttributeNS(null, "style", "stroke:black;fill:black;stroke-width:1;clip-path:url(#clip3)"); + "m " + (left + + daysToStart * 300 / (totalDays - 2) - 6) + + " " + (topEdge + 6) + "l6 -6l" + + (days * 300 / (totalDays - 2)) + + " 0l6 6l-6 6l-4-4l" + + -(days * 300 / (totalDays - 2) - 8) + + " 0l-4 4l-6-6z"); + taskGraphic.setAttributeNS(null, + "style", + "stroke:black;fill:black;stroke-width:1;clip-path:url(#clip3)"); g.appendChild(taskGraphic); break; default: @@ -262,8 +328,8 @@ public class SimplePlanDrawer implements PlanDrawer { } } int currentDays = - (int)((currentDate.getTime() - lastWeek.getTime() + - 43200000) / 86400000); + (int)((currentDate.getTime() - lastWeek.getTime() + + 43200000) / 86400000); text = SVGUtilities.createText(doc, (float)(200 + (currentDays + 0.5) * 300 / 35), |