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/Rect.java

    r4256 r6002  
    11/*
    2  * Rect.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, 5:25 PM
    2635 */
    27 
    2836package com.kitfox.svg;
    2937
    3038import com.kitfox.svg.xml.StyleAttribute;
    31 
    32 import java.awt.*;
    33 import java.awt.geom.*;
     39import java.awt.Graphics2D;
     40import java.awt.Shape;
     41import java.awt.geom.Rectangle2D;
     42import java.awt.geom.RectangularShape;
     43import java.awt.geom.RoundRectangle2D;
    3444import java.io.IOException;
    3545import java.io.ObjectInputStream;
     
    4050 * @author <a href="mailto:mark@kitfox.com">Mark McKay</a>
    4151 */
    42 public class Rect extends ShapeElement {
     52public class Rect extends ShapeElement
     53{
     54    public static final String TAG_NAME = "rect";
    4355
    4456    float x = 0f;
     
    4860    float rx = 0f;
    4961    float ry = 0f;
    50 
    5162    RectangularShape rect;
    5263
    53     /** Creates a new instance of Rect */
    54     public Rect() {
    55     }
    56 
    57     private void writeObject(ObjectOutputStream out) throws IOException   
     64    /**
     65     * Creates a new instance of Rect
     66     */
     67    public Rect()
     68    {
     69    }
     70
     71    public String getTagName()
     72    {
     73        return TAG_NAME;
     74    }
     75
     76    private void writeObject(ObjectOutputStream out) throws IOException
    5877    {
    5978        out.writeFloat(x);
     
    6483        out.writeFloat(ry);
    6584    }
    66    
     85
    6786    private void readObject(ObjectInputStream in) throws IOException
    6887    {
     
    7392        rx = in.readFloat();
    7493        ry = in.readFloat();
    75        
     94
    7695        if (rx == 0f && ry == 0f)
    7796        {
    7897            rect = new Rectangle2D.Float(x, y, width, height);
    79         }
    80         else
     98        } else
    8199        {
    82100            rect = new RoundRectangle2D.Float(x, y, width, height, rx * 2, ry * 2);
    83101        }
    84102    }
    85    
     103
    86104    /*
    87     public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent)
    88     {
    89                 //Load style string
    90         super.loaderStartElement(helper, attrs, parent);
    91 
    92         String x = attrs.getValue("x");
    93         String y = attrs.getValue("y");
    94         String width = attrs.getValue("width");
    95         String height = attrs.getValue("height");
    96         String rx = attrs.getValue("rx");
    97         String ry = attrs.getValue("ry");
    98 
    99         if (rx == null) rx = ry;
    100         if (ry == null) ry = rx;
    101 
    102         this.x = XMLParseUtil.parseFloat(x);
    103         this.y = XMLParseUtil.parseFloat(y);
    104         this.width = XMLParseUtil.parseFloat(width);
    105         this.height = XMLParseUtil.parseFloat(height);
    106         if (rx != null)
    107         {
    108             this.rx = XMLParseUtil.parseFloat(rx);
    109             this.ry = XMLParseUtil.parseFloat(ry);
    110         }
    111 
    112         build();
    113 //        setBounds(this.x, this.y, this.width, this.height);
    114     }
    115 */
    116    
     105     public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent)
     106     {
     107     //Load style string
     108     super.loaderStartElement(helper, attrs, parent);
     109
     110     String x = attrs.getValue("x");
     111     String y = attrs.getValue("y");
     112     String width = attrs.getValue("width");
     113     String height = attrs.getValue("height");
     114     String rx = attrs.getValue("rx");
     115     String ry = attrs.getValue("ry");
     116
     117     if (rx == null) rx = ry;
     118     if (ry == null) ry = rx;
     119
     120     this.x = XMLParseUtil.parseFloat(x);
     121     this.y = XMLParseUtil.parseFloat(y);
     122     this.width = XMLParseUtil.parseFloat(width);
     123     this.height = XMLParseUtil.parseFloat(height);
     124     if (rx != null)
     125     {
     126     this.rx = XMLParseUtil.parseFloat(rx);
     127     this.ry = XMLParseUtil.parseFloat(ry);
     128     }
     129
     130     build();
     131     //        setBounds(this.x, this.y, this.width, this.height);
     132     }
     133     */
    117134    protected void build() throws SVGException
    118135    {
    119136        super.build();
    120        
     137
    121138        StyleAttribute sty = new StyleAttribute();
    122        
     139
    123140//        SVGElement parent = this.getParent();
    124141//        if (parent instanceof RenderableElement)
     
    128145//            bounds = null;
    129146//        }
    130        
    131        
    132         if (getPres(sty.setName("x"))) x = sty.getFloatValueWithUnits();
    133        
    134         if (getPres(sty.setName("y"))) y = sty.getFloatValueWithUnits();
    135        
    136         if (getPres(sty.setName("width"))) width = sty.getFloatValueWithUnits();
    137        
    138         if (getPres(sty.setName("height"))) height = sty.getFloatValueWithUnits();
     147
     148
     149        if (getPres(sty.setName("x")))
     150        {
     151            x = sty.getFloatValueWithUnits();
     152        }
     153
     154        if (getPres(sty.setName("y")))
     155        {
     156            y = sty.getFloatValueWithUnits();
     157        }
     158
     159        if (getPres(sty.setName("width")))
     160        {
     161            width = sty.getFloatValueWithUnits();
     162        }
     163
     164        if (getPres(sty.setName("height")))
     165        {
     166            height = sty.getFloatValueWithUnits();
     167        }
    139168
    140169        boolean rxSet = false;
    141         if (getPres(sty.setName("rx"))) { rx = sty.getFloatValueWithUnits(); rxSet = true; }
    142        
     170        if (getPres(sty.setName("rx")))
     171        {
     172            rx = sty.getFloatValueWithUnits();
     173            rxSet = true;
     174        }
     175
    143176        boolean rySet = false;
    144         if (getPres(sty.setName("ry"))) { ry = sty.getFloatValueWithUnits(); rySet = true; }
    145        
    146         if (!rxSet) rx = ry;
    147         if (!rySet) ry = rx;
    148 
    149        
     177        if (getPres(sty.setName("ry")))
     178        {
     179            ry = sty.getFloatValueWithUnits();
     180            rySet = true;
     181        }
     182
     183        if (!rxSet)
     184        {
     185            rx = ry;
     186        }
     187        if (!rySet)
     188        {
     189            ry = rx;
     190        }
     191
     192
    150193        if (rx == 0f && ry == 0f)
    151194        {
    152195            rect = new Rectangle2D.Float(x, y, width, height);
    153         }
    154         else
     196        } else
    155197        {
    156198            rect = new RoundRectangle2D.Float(x, y, width, height, rx * 2, ry * 2);
     
    176218
    177219    /**
    178      * Updates all attributes in this diagram associated with a time event.
    179      * Ie, all attributes with track information.
     220     * Updates all attributes in this diagram associated with a time event. Ie,
     221     * all attributes with track information.
     222     *
    180223     * @return - true if this node has changed state as a result of the time
    181224     * update
     
    189232        StyleAttribute sty = new StyleAttribute();
    190233        boolean shapeChange = false;
    191        
     234
    192235        if (getPres(sty.setName("x")))
    193236        {
     
    263306//            return true;
    264307        }
    265        
     308
    266309        return changeState || shapeChange;
    267310    }
Note: See TracChangeset for help on using the changeset viewer.