Ignore:
Timestamp:
2013-06-11T01:01:28+02:00 (11 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/RenderableElement.java

    r4256 r6002  
    11/*
    2  * BoundedElement.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, 9:00 AM
    2635 */
    27 
    2836package com.kitfox.svg;
    2937
     
    3846import java.util.List;
    3947
    40 
    41 
    4248/**
    4349 * Maintains bounding box for this element
     
    4652 * @author <a href="mailto:mark@kitfox.com">Mark McKay</a>
    4753 */
    48 abstract public class RenderableElement extends TransformableElement 
     54abstract public class RenderableElement extends TransformableElement
    4955{
    50 
    5156    AffineTransform cachedXform = null;
     57   
    5258    Shape cachedClip = null;
    53    
    5459    public static final int VECTOR_EFFECT_NONE = 0;
    5560    public static final int VECTOR_EFFECT_NON_SCALING_STROKE = 1;
    5661    int vectorEffect;
    5762
    58     /** Creates a new instance of BoundedElement */
    59     public RenderableElement() {
     63    /**
     64     * Creates a new instance of BoundedElement
     65     */
     66    public RenderableElement()
     67    {
    6068    }
    6169
     
    6876    {
    6977        super.build();
    70        
     78
    7179        StyleAttribute sty = new StyleAttribute();
    72        
     80
    7381        if (getPres(sty.setName("vector-effect")))
    7482        {
     
    7684            {
    7785                vectorEffect = VECTOR_EFFECT_NON_SCALING_STROKE;
    78             }
    79             else
     86            } else
    8087            {
    8188                vectorEffect = VECTOR_EFFECT_NONE;
    8289            }
    83         }
    84         else
     90        } else
    8591        {
    8692            vectorEffect = VECTOR_EFFECT_NONE;
    8793        }
    8894    }
    89    
     95
    9096    abstract public void render(Graphics2D g) throws SVGException;
    91    
     97
    9298    abstract void pick(Point2D point, boolean boundingBox, List retVec) throws SVGException;
    93    
     99
    94100    abstract void pick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List retVec) throws SVGException;
    95    
     101
    96102    abstract public Rectangle2D getBoundingBox() throws SVGException;
    97 /*
    98     public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent)
    99     {
    100         super.loaderStartElement(helper, attrs, parent);
    101     }
    102 */
     103    /*
     104     public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent)
     105     {
     106     super.loaderStartElement(helper, attrs, parent);
     107     }
     108     */
     109
    103110    /**
    104111     * Pushes transform stack, transforms to local coordinates and sets up
     
    114121
    115122        StyleAttribute styleAttrib = new StyleAttribute();
    116        
     123
    117124        //Get clipping path
    118125//        StyleAttribute styleAttrib = getStyle("clip-path", false);
    119126        Shape clipPath = null;
    120127        int clipPathUnits = ClipPath.CP_USER_SPACE_ON_USE;
    121         if (getStyle(styleAttrib.setName("clip-path")))
     128        if (getStyle(styleAttrib.setName("clip-path"), false)
     129             && !"none".equals(styleAttrib.getStringValue()))
    122130        {
    123131            URI uri = styleAttrib.getURIValue(getXMLBase());
    124132            if (uri != null)
    125133            {
    126                 ClipPath ele = (ClipPath)diagram.getUniverse().getElement(uri);
     134                ClipPath ele = (ClipPath) diagram.getUniverse().getElement(uri);
    127135                clipPath = ele.getClipPathShape();
    128136                clipPathUnits = ele.getClipPathUnits();
     
    135143            if (clipPathUnits == ClipPath.CP_OBJECT_BOUNDING_BOX && (this instanceof ShapeElement))
    136144            {
    137                 Rectangle2D rect = ((ShapeElement)this).getBoundingBox();
     145                Rectangle2D rect = ((ShapeElement) this).getBoundingBox();
    138146                AffineTransform at = new AffineTransform();
    139147                at.scale(rect.getWidth(), rect.getHeight());
     
    142150
    143151            cachedClip = g.getClip();
    144             Area newClip = new Area(cachedClip);
    145             newClip.intersect(new Area(clipPath));
    146             g.setClip(newClip);
     152            if (cachedClip == null)
     153            {
     154                g.setClip(clipPath);
     155            } else
     156            {
     157                Area newClip = new Area(cachedClip);
     158                newClip.intersect(new Area(clipPath));
     159                g.setClip(newClip);
     160            }
    147161        }
    148162    }
    149163
    150164    /**
    151      * Restores transform and clipping values to the way they were before
    152      * this layer was drawn.
     165     * Restores transform and clipping values to the way they were before this
     166     * layer was drawn.
    153167     */
    154168    protected void finishLayer(Graphics2D g)
     
    164178        }
    165179    }
    166 
    167180}
Note: See TracChangeset for help on using the changeset viewer.