Changeset 6002 in josm for trunk/src/com/kitfox/svg/ClipPath.java
- Timestamp:
- 2013-06-11T01:01:28+02:00 (13 years ago)
- File:
-
- 1 edited
-
trunk/src/com/kitfox/svg/ClipPath.java (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/com/kitfox/svg/ClipPath.java
r4256 r6002 1 1 /* 2 * Stop.java 2 * SVG Salamander 3 * Copyright (c) 2004, Mark McKay 4 * All rights reserved. 3 5 * 6 * Redistribution and use in source and binary forms, with or 7 * without modification, are permitted provided that the following 8 * conditions are met: 4 9 * 5 * The Salamander Project - 2D and 3D graphics libraries in Java 6 * Copyright (C) 2004 Mark McKay 10 * - Redistributions of source code must retain the above 11 * copyright notice, this list of conditions and the following 12 * disclaimer. 13 * - Redistributions in binary form must reproduce the above 14 * copyright notice, this list of conditions and the following 15 * disclaimer in the documentation and/or other materials 16 * provided with the distribution. 7 17 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public 10 * License as published by the Free Software Foundation; either 11 * version 2.1 of the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this library; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * 22 * Mark McKay can be contacted at mark@kitfox.com. Salamander and other 23 * projects can be found at http://www.kitfox.com 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 29 * OF THE POSSIBILITY OF SUCH DAMAGE. 30 * 31 * Mark McKay can be contacted at mark@kitfox.com. Salamander and other 32 * projects can be found at http://www.kitfox.com 24 33 * 25 34 * Created on January 26, 2004, 1:56 AM 26 35 */ 27 28 36 package com.kitfox.svg; 29 37 … … 37 45 * @author <a href="mailto:mark@kitfox.com">Mark McKay</a> 38 46 */ 39 public class ClipPath extends SVGElement 47 public class ClipPath extends SVGElement 40 48 { 41 49 50 public static final String TAG_NAME = "clippath"; 42 51 public static final int CP_USER_SPACE_ON_USE = 0; 43 52 public static final int CP_OBJECT_BOUNDING_BOX = 1; 44 45 53 int clipPathUnits = CP_USER_SPACE_ON_USE; 46 54 47 /** Creates a new instance of Stop */ 48 public ClipPath() { 55 /** 56 * Creates a new instance of Stop 57 */ 58 public ClipPath() 59 { 49 60 } 50 /* 51 public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent)61 62 public String getTagName() 52 63 { 53 //Load style string 54 super.loaderStartElement(helper, attrs, parent);64 return TAG_NAME; 65 } 55 66 56 String clipPathUnits = attrs.getValue("clipPathUnits");57 58 if (clipPathUnits.equals("objectBoundingBox")) this.clipPathUnits = CP_OBJECT_BOUNDING_BOX;59 60 }61 */62 67 /** 63 68 * Called after the start element but before the end element to indicate … … 66 71 public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException 67 72 { 68 super.loaderAddChild(helper, child); 69 70 // if (child instanceof ShapeElement) members.add(child); 73 super.loaderAddChild(helper, child); 71 74 } 72 75 73 /*74 public void loaderEndElement(SVGLoaderHelper helper)75 {76 // super.loaderEndElement(helper);77 78 // build();79 }80 */81 82 76 protected void build() throws SVGException 83 77 { 84 78 super.build(); 85 79 86 80 StyleAttribute sty = new StyleAttribute(); 87 81 88 82 clipPathUnits = (getPres(sty.setName("clipPathUnits")) 89 && sty.getStringValue().equals("objectBoundingBox")) 90 ? CP_OBJECT_BOUNDING_BOX 83 && sty.getStringValue().equals("objectBoundingBox")) 84 ? CP_OBJECT_BOUNDING_BOX 91 85 : CP_USER_SPACE_ON_USE; 92 86 } 93 87 94 88 public int getClipPathUnits() 95 89 { … … 99 93 public Shape getClipPathShape() 100 94 { 101 if (children.size() == 0) return null; 102 if (children.size() == 1) return ((ShapeElement)children.get(0)).getShape(); 95 if (children.isEmpty()) 96 { 97 return null; 98 } 99 if (children.size() == 1) 100 { 101 return ((ShapeElement) children.get(0)).getShape(); 102 } 103 103 104 104 Area clipArea = null; 105 105 for (Iterator it = children.iterator(); it.hasNext();) 106 106 { 107 ShapeElement se = (ShapeElement)it.next(); 107 ShapeElement se = (ShapeElement) it.next(); 108 108 109 109 if (clipArea == null) 110 110 { 111 111 Shape shape = se.getShape(); 112 if (shape != null) clipArea = new Area(se.getShape()); 112 if (shape != null) 113 { 114 clipArea = new Area(se.getShape()); 115 } 113 116 continue; 114 117 } 115 118 116 119 Shape shape = se.getShape(); 117 if (shape != null) clipArea.intersect(new Area(shape)); 120 if (shape != null) 121 { 122 clipArea.intersect(new Area(shape)); 123 } 118 124 } 119 125 … … 122 128 123 129 /** 124 * Updates all attributes in this diagram associated with a time event. 125 * Ie, all attributes with track information. 130 * Updates all attributes in this diagram associated with a time event. Ie, 131 * all attributes with track information. 132 * 126 133 * @return - true if this node has changed state as a result of the time 127 134 * update … … 129 136 public boolean updateTime(double curTime) throws SVGException 130 137 { 131 // if (trackManager.getNumTracks() == 0) return false;132 133 138 //Get current values for parameters 134 139 StyleAttribute sty = new StyleAttribute(); 135 140 boolean shapeChange = false; 136 141 137 142 138 143 if (getPres(sty.setName("clipPathUnits"))) 139 144 { 140 145 String newUnitsStrn = sty.getStringValue(); 141 146 int newUnits = newUnitsStrn.equals("objectBoundingBox") 142 ? CP_OBJECT_BOUNDING_BOX 147 ? CP_OBJECT_BOUNDING_BOX 143 148 : CP_USER_SPACE_ON_USE; 144 149 145 150 if (newUnits != clipPathUnits) 146 151 {
Note:
See TracChangeset
for help on using the changeset viewer.
