Ignore:
Timestamp:
2013-06-11T01:01:28+02:00 (13 years ago)
Author:
Don-vip
Message:

fix #8742 - update svgsalamander to release 0.1.18+patch (fix bug SVGSALAMANDER-26) -> allow to open more SVG files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/com/kitfox/svg/ClipPath.java

    r4256 r6002  
    11/*
    2  * Stop.java
     2 * SVG Salamander
     3 * Copyright (c) 2004, Mark McKay
     4 * All rights reserved.
    35 *
     6 * Redistribution and use in source and binary forms, with or
     7 * without modification, are permitted provided that the following
     8 * conditions are met:
    49 *
    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.
    717 *
    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
    2433 *
    2534 * Created on January 26, 2004, 1:56 AM
    2635 */
    27 
    2836package com.kitfox.svg;
    2937
     
    3745 * @author <a href="mailto:mark@kitfox.com">Mark McKay</a>
    3846 */
    39 public class ClipPath extends SVGElement 
     47public class ClipPath extends SVGElement
    4048{
    4149
     50    public static final String TAG_NAME = "clippath";
    4251    public static final int CP_USER_SPACE_ON_USE = 0;
    4352    public static final int CP_OBJECT_BOUNDING_BOX = 1;
    44 
    4553    int clipPathUnits = CP_USER_SPACE_ON_USE;
    4654
    47     /** Creates a new instance of Stop */
    48     public ClipPath() {
     55    /**
     56     * Creates a new instance of Stop
     57     */
     58    public ClipPath()
     59    {
    4960    }
    50 /*
    51     public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent)
     61
     62    public String getTagName()
    5263    {
    53                 //Load style string
    54         super.loaderStartElement(helper, attrs, parent);
     64        return TAG_NAME;
     65    }
    5566
    56         String clipPathUnits = attrs.getValue("clipPathUnits");
    57 
    58         if (clipPathUnits.equals("objectBoundingBox")) this.clipPathUnits = CP_OBJECT_BOUNDING_BOX;
    59 
    60     }
    61 */
    6267    /**
    6368     * Called after the start element but before the end element to indicate
     
    6671    public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException
    6772    {
    68                 super.loaderAddChild(helper, child);
    69 
    70 //        if (child instanceof ShapeElement) members.add(child);
     73        super.loaderAddChild(helper, child);
    7174    }
    7275
    73     /*
    74     public void loaderEndElement(SVGLoaderHelper helper)
    75     {
    76 //        super.loaderEndElement(helper);
    77 
    78 //        build();
    79     }
    80     */
    81    
    8276    protected void build() throws SVGException
    8377    {
    8478        super.build();
    85        
     79
    8680        StyleAttribute sty = new StyleAttribute();
    87        
     81
    8882        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
    9185            : CP_USER_SPACE_ON_USE;
    9286    }
    93    
     87
    9488    public int getClipPathUnits()
    9589    {
     
    9993    public Shape getClipPathShape()
    10094    {
    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        }
    103103
    104104        Area clipArea = null;
    105105        for (Iterator it = children.iterator(); it.hasNext();)
    106106        {
    107             ShapeElement se = (ShapeElement)it.next();
     107            ShapeElement se = (ShapeElement) it.next();
    108108
    109109            if (clipArea == null)
    110110            {
    111111                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                }
    113116                continue;
    114117            }
    115118
    116119            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            }
    118124        }
    119125
     
    122128
    123129    /**
    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     *
    126133     * @return - true if this node has changed state as a result of the time
    127134     * update
     
    129136    public boolean updateTime(double curTime) throws SVGException
    130137    {
    131 //        if (trackManager.getNumTracks() == 0) return false;
    132 
    133138        //Get current values for parameters
    134139        StyleAttribute sty = new StyleAttribute();
    135140        boolean shapeChange = false;
    136141
    137        
     142
    138143        if (getPres(sty.setName("clipPathUnits")))
    139144        {
    140145            String newUnitsStrn = sty.getStringValue();
    141146            int newUnits = newUnitsStrn.equals("objectBoundingBox")
    142                 ? CP_OBJECT_BOUNDING_BOX 
     147                ? CP_OBJECT_BOUNDING_BOX
    143148                : CP_USER_SPACE_ON_USE;
    144                
     149
    145150            if (newUnits != clipPathUnits)
    146151            {
Note: See TracChangeset for help on using the changeset viewer.