Changeset 10787 in josm


Ignore:
Timestamp:
2016-08-12T03:16:58+02:00 (8 years ago)
Author:
Don-vip
Message:

fix #13291 - upgrade to svgSalamander v1.1.0 (patched)

now detects two invalid SVG files: presets/sport/volleyball.svg and presets/shop/diy_store.svg

Location:
trunk/src/com/kitfox/svg
Files:
4 deleted
10 edited

Legend:

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

    r8084 r10787  
    3838import com.kitfox.svg.xml.StyleAttribute;
    3939import java.awt.Color;
     40import java.awt.LinearGradientPaint;
     41import java.awt.MultipleGradientPaint;
    4042import java.awt.Paint;
    4143import java.awt.geom.AffineTransform;
     
    9799    public Paint getPaint(Rectangle2D bounds, AffineTransform xform)
    98100    {
    99         com.kitfox.svg.batik.MultipleGradientPaint.CycleMethodEnum method;
     101        MultipleGradientPaint.CycleMethod method;
    100102        switch (spreadMethod)
    101103        {
    102104            default:
    103105            case SM_PAD:
    104                 method = com.kitfox.svg.batik.MultipleGradientPaint.NO_CYCLE;
     106                method = MultipleGradientPaint.CycleMethod.NO_CYCLE;
    105107                break;
    106108            case SM_REPEAT:
    107                 method = com.kitfox.svg.batik.MultipleGradientPaint.REPEAT;
     109                method = MultipleGradientPaint.CycleMethod.REPEAT;
    108110                break;
    109111            case SM_REFLECT:
    110                 method = com.kitfox.svg.batik.MultipleGradientPaint.REFLECT;
     112                method = MultipleGradientPaint.CycleMethod.REFLECT;
    111113                break;
    112114        }
     
    121123        } else if (gradientUnits == GU_USER_SPACE_ON_USE)
    122124        {
    123             paint = new com.kitfox.svg.batik.LinearGradientPaint(
     125            paint = new LinearGradientPaint(
    124126                pt1,
    125127                pt2,
     
    127129                getStopColors(),
    128130                method,
    129                 com.kitfox.svg.batik.MultipleGradientPaint.SRGB,
     131                MultipleGradientPaint.ColorSpaceType.SRGB,
    130132                gradientTransform == null
    131133                ? new AffineTransform()
     
    146148            }
    147149
    148             paint = new com.kitfox.svg.batik.LinearGradientPaint(
     150            paint = new LinearGradientPaint(
    149151                pt1,
    150152                pt2,
     
    152154                getStopColors(),
    153155                method,
    154                 com.kitfox.svg.batik.MultipleGradientPaint.SRGB,
     156                MultipleGradientPaint.ColorSpaceType.SRGB,
    155157                viewXform);
    156158        }
  • trunk/src/com/kitfox/svg/Path.java

    r8084 r10787  
    4242import java.awt.geom.Rectangle2D;
    4343
    44 //import org.apache.batik.ext.awt.geom.ExtendedGeneralPath;
    4544/**
    4645 * @author Mark McKay
  • trunk/src/com/kitfox/svg/RadialGradient.java

    r8084 r10787  
    44 * All rights reserved.
    55 *
    6  * Redistribution and use in source and binary forms, with or 
     6 * Redistribution and use in source and binary forms, with or
    77 * without modification, are permitted provided that the following
    88 * conditions are met:
    99 *
    10  *   - Redistributions of source code must retain the above 
     10 *   - Redistributions of source code must retain the above
    1111 *     copyright notice, this list of conditions and the following
    1212 *     disclaimer.
    1313 *   - Redistributions in binary form must reproduce the above
    1414 *     copyright notice, this list of conditions and the following
    15  *     disclaimer in the documentation and/or other materials 
     15 *     disclaimer in the documentation and/or other materials
    1616 *     provided with the distribution.
    1717 *
     
    2727 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    2828 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
    29  * OF THE POSSIBILITY OF SUCH DAMAGE. 
    30  * 
     29 * OF THE POSSIBILITY OF SUCH DAMAGE.
     30 *
    3131 * Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
    3232 * projects can be found at http://www.kitfox.com
     
    3636package com.kitfox.svg;
    3737
    38 import com.kitfox.svg.xml.StyleAttribute;
    39 import java.awt.Color;
     38import java.awt.MultipleGradientPaint;
    4039import java.awt.Paint;
     40import java.awt.RadialGradientPaint;
    4141import java.awt.geom.AffineTransform;
    4242import java.awt.geom.Point2D;
    4343import java.awt.geom.Rectangle2D;
     44import java.util.Arrays;
     45
     46import com.kitfox.svg.xml.StyleAttribute;
    4447
    4548/**
     
    5356    float cx = 0.5f;
    5457    float cy = 0.5f;
    55     float fx = 0.5f;
    56     float fy = 0.5f;
     58    boolean hasFocus = false;
     59    float fx = 0f;
     60    float fy = 0f;
    5761    float r = 0.5f;
    5862
     
    6468    }
    6569
     70    @Override
    6671    public String getTagName()
    6772    {
     
    6974    }
    7075
     76    @Override
    7177    protected void build() throws SVGException
    7278    {
     
    8591        }
    8692
     93        hasFocus = false;
    8794        if (getPres(sty.setName("fx")))
    8895        {
    8996            fx = sty.getFloatValueWithUnits();
     97            hasFocus = true;
    9098        }
    9199
     
    93101        {
    94102            fy = sty.getFloatValueWithUnits();
     103            hasFocus = true;
    95104        }
    96105
     
    101110    }
    102111
     112    @Override
    103113    public Paint getPaint(Rectangle2D bounds, AffineTransform xform)
    104114    {
    105         com.kitfox.svg.batik.MultipleGradientPaint.CycleMethodEnum method;
     115        MultipleGradientPaint.CycleMethod method;
    106116        switch (spreadMethod)
    107117        {
    108118            default:
    109119            case SM_PAD:
    110                 method = com.kitfox.svg.batik.MultipleGradientPaint.NO_CYCLE;
     120                method = MultipleGradientPaint.CycleMethod.NO_CYCLE;
    111121                break;
    112122            case SM_REPEAT:
    113                 method = com.kitfox.svg.batik.MultipleGradientPaint.REPEAT;
     123                method = MultipleGradientPaint.CycleMethod.REPEAT;
    114124                break;
    115125            case SM_REFLECT:
    116                 method = com.kitfox.svg.batik.MultipleGradientPaint.REFLECT;
     126                method = MultipleGradientPaint.CycleMethod.REFLECT;
    117127                break;
    118128        }
     
    120130        Paint paint;
    121131        Point2D.Float pt1 = new Point2D.Float(cx, cy);
    122         Point2D.Float pt2 = new Point2D.Float(fx, fy);
     132        Point2D.Float pt2 = hasFocus ? new Point2D.Float(fx, fy) : pt1;
    123133        if (gradientUnits == GU_USER_SPACE_ON_USE)
    124134        {
    125             paint = new com.kitfox.svg.batik.RadialGradientPaint(
     135            paint = new RadialGradientPaint(
    126136                pt1,
    127137                r,
     
    130140                getStopColors(),
    131141                method,
    132                 com.kitfox.svg.batik.MultipleGradientPaint.SRGB,
     142                MultipleGradientPaint.ColorSpaceType.SRGB,
    133143                gradientTransform);
    134144        } else
     
    140150            viewXform.concatenate(gradientTransform);
    141151
    142             paint = new com.kitfox.svg.batik.RadialGradientPaint(
     152            paint = new RadialGradientPaint(
    143153                pt1,
    144154                r,
     
    147157                getStopColors(),
    148158                method,
    149                 com.kitfox.svg.batik.MultipleGradientPaint.SRGB,
     159                MultipleGradientPaint.ColorSpaceType.SRGB,
    150160                viewXform);
    151161        }
     
    161171     * update
    162172     */
     173    @Override
    163174    public boolean updateTime(double curTime) throws SVGException
    164175    {
  • trunk/src/com/kitfox/svg/SVGRoot.java

    r8084 r10787  
    263263        prepareViewport();
    264264
     265        Rectangle targetViewport = g.getClipBounds();
     266
     267        Rectangle deviceViewport = diagram.getDeviceViewport();
     268        if (width != null && height != null)
     269        {
     270            float xx, yy, ww, hh;
     271           
     272            xx = (x == null) ? 0 : StyleAttribute.convertUnitsToPixels(x.getUnits(), x.getValue());
     273            if (width.getUnits() == NumberWithUnits.UT_PERCENT)
     274            {
     275                ww = width.getValue() * deviceViewport.width;
     276            }
     277            else
     278            {
     279                ww = StyleAttribute.convertUnitsToPixels(width.getUnits(), width.getValue());
     280            }
     281           
     282            yy = (y == null) ? 0 : StyleAttribute.convertUnitsToPixels(y.getUnits(), y.getValue());
     283            if (height.getUnits() == NumberWithUnits.UT_PERCENT)
     284            {
     285                hh = height.getValue() * deviceViewport.height;
     286            }
     287            else
     288            {
     289                hh = StyleAttribute.convertUnitsToPixels(height.getUnits(), height.getValue());
     290            }
     291           
     292            targetViewport = new Rectangle((int)xx, (int)yy, (int)ww, (int)hh);
     293        }
     294        else
     295        {
     296            targetViewport = new Rectangle(deviceViewport);
     297        }
     298        clipRect.setRect(targetViewport);
     299
    265300        if (viewBox == null)
    266301        {
     
    269304        else
    270305        {
    271             Rectangle deviceViewport = g.getClipBounds();
    272             //If viewport window is set, we are drawing to entire viewport
    273             clipRect.setRect(deviceViewport);
    274            
    275306            viewXform.setToIdentity();
    276             viewXform.setToTranslation(deviceViewport.x, deviceViewport.y);
    277             viewXform.scale(deviceViewport.width, deviceViewport.height);
     307            viewXform.setToTranslation(targetViewport.x, targetViewport.y);
     308            viewXform.scale(targetViewport.width, targetViewport.height);
    278309            viewXform.scale(1 / viewBox.width, 1 / viewBox.height);
    279310            viewXform.translate(-viewBox.x, -viewBox.y);
  • trunk/src/com/kitfox/svg/ShapeElement.java

    r8084 r10787  
    7676    }
    7777
     78    @Override
    7879    abstract public void render(java.awt.Graphics2D g) throws SVGException;
    7980
     
    8586     */
    8687
     88    @Override
    8789    void pick(Point2D point, boolean boundingBox, List retVec) throws SVGException
    8890    {
     
    9597    }
    9698
     99    @Override
    97100    void pick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List retVec) throws SVGException
    98101    {
     
    161164                        if (ele != null)
    162165                        {
    163                             fillPaint = ((FillElement)ele).getPaint(bounds, xform);
     166                            try {
     167                                fillPaint = ((FillElement)ele).getPaint(bounds, xform);
     168                            } catch (IllegalArgumentException e) {
     169                                throw new SVGException(e);
     170                            }
    164171                        }
    165172                    }
  • trunk/src/com/kitfox/svg/Text.java

    r8084 r10787  
    3737
    3838import com.kitfox.svg.util.FontSystem;
    39 import com.kitfox.svg.util.TextBuilder;
    4039import com.kitfox.svg.xml.StyleAttribute;
    4140import java.awt.Graphics2D;
    4241import java.awt.Shape;
    43 import java.awt.font.FontRenderContext;
    4442import java.awt.geom.AffineTransform;
    4543import java.awt.geom.GeneralPath;
     
    5149import java.util.regex.Pattern;
    5250
    53 //import org.apache.batik.ext.awt.geom.ExtendedGeneralPath;
    5451/**
    5552 * @author Mark McKay
     
    265262    protected void buildText() throws SVGException
    266263    {
    267 
    268264        //Get font
    269         Font font = diagram.getUniverse().getFont(fontFamily);
     265        String[] families = fontFamily.split(",");
     266        Font font = null;
     267        for (int i = 0; i < families.length; ++i)
     268        {
     269            font = diagram.getUniverse().getFont(fontFamily);
     270            if (font != null)
     271            {
     272                break;
     273            }
     274        }
     275
    270276        if (font == null)
    271277        {
    272 //            System.err.println("Could not load font");
    273 
    274278            font = new FontSystem(fontFamily, fontStyle, fontWeight, (int)fontSize);
    275 //            java.awt.Font sysFont = new java.awt.Font(fontFamily, style | weight, (int)fontSize);
    276 //            buildSysFont(sysFont);
    277 //            return;
    278         }
    279 
    280 //        font = new java.awt.Font(font.getFamily(), style | weight, font.getSize());
    281 
    282 //        Area textArea = new Area();
     279        }
     280
    283281        GeneralPath textPath = new GeneralPath();
    284282        textShape = textPath;
     
    286284        float cursorX = x, cursorY = y;
    287285
    288         FontFace fontFace = font.getFontFace();
    289         //int unitsPerEm = fontFace.getUnitsPerEm();
    290         int ascent = fontFace.getAscent();
    291         float fontScale = fontSize / (float) ascent;
    292 
    293 //        AffineTransform oldXform = g.getTransform();
    294 //        TextBuilder builder = new TextBuilder();
    295 //       
    296 //        for (Iterator it = content.iterator(); it.hasNext();)
    297 //        {
    298 //            Object obj = it.next();
    299 //
    300 //            if (obj instanceof String)
    301 //            {
    302 //                String text = (String) obj;
    303 //                if (text != null)
    304 //                {
    305 //                    text = text.trim();
    306 //                }
    307 //               
    308 //                for (int i = 0; i < text.length(); i++)
    309 //                {
    310 //                    String unicode = text.substring(i, i + 1);
    311 //                    MissingGlyph glyph = font.getGlyph(unicode);
    312 //                   
    313 //                    builder.appendGlyph(glyph);
    314 //                }
    315 //            }
    316 //            else if (obj instanceof Tspan)
    317 //            {
    318 //                Tspan tspan = (Tspan)obj;
    319 //                tspan.buildGlyphs(builder);
    320 //            }
    321 //        }
    322 //
    323 //        builder.formatGlyphs();
    324        
    325        
    326 
    327                
    328                
    329        
    330        
    331        
    332286        AffineTransform xform = new AffineTransform();
    333287
     
    344298                }
    345299
    346                 strokeWidthScalar = 1f / fontScale;
    347 
    348300                for (int i = 0; i < text.length(); i++)
    349301                {
    350302                    xform.setToIdentity();
    351303                    xform.setToTranslation(cursorX, cursorY);
    352                     xform.scale(fontScale, fontScale);
    353 //                    g.transform(xform);
    354304
    355305                    String unicode = text.substring(i, i + 1);
     
    362312                        textPath.append(path, false);
    363313                    }
    364 //                    else glyph.render(g);
    365 
    366                     cursorX += fontScale * glyph.getHorizAdvX();
    367 
    368 //                    g.setTransform(oldXform);
     314
     315                    cursorX += glyph.getHorizAdvX();
    369316                }
    370317
  • trunk/src/com/kitfox/svg/Tspan.java

    r8084 r10787  
    231231        {
    232232            font = new FontSystem(fontFamily, fontStyle, fontWeight, (int)fontSize);
    233 //            addShapeSysFont(addShape, font, fontFamily, fontSize, letterSpacing, cursor);
    234 //            return;
    235         }
    236 
    237         FontFace fontFace = font.getFontFace();
    238         int ascent = fontFace.getAscent();
    239         float fontScale = fontSize / (float) ascent;
     233        }
    240234
    241235        AffineTransform xform = new AffineTransform();
    242 
    243         strokeWidthScalar = 1f / fontScale;
    244236
    245237        float cursorX = (float)cursor.getX();
    246238        float cursorY = (float)cursor.getY();
    247239   
    248 //        int i = 0;
    249 
    250240        String drawText = this.text;
    251241        drawText = drawText.trim();
     
    267257                cursorY += dy[i];
    268258            }
    269   //          i++;
    270259           
    271260            xform.setToIdentity();
    272261            xform.setToTranslation(cursorX, cursorY);
    273             xform.scale(fontScale, fontScale);
    274262            if (rotate != null)
    275263            {
     
    287275            }
    288276
    289             cursorX += fontScale * glyph.getHorizAdvX() + letterSpacing;
     277            cursorX += glyph.getHorizAdvX() + letterSpacing;
    290278        }
    291279
  • trunk/src/com/kitfox/svg/app/beans/SVGIcon.java

    r8084 r10787  
    3737package com.kitfox.svg.app.beans;
    3838
    39 import com.kitfox.svg.*;
    40 import java.awt.*;
    41 import java.awt.geom.*;
    42 import java.beans.*;
    43 import java.net.*;
    44 import javax.swing.*;
     39import com.kitfox.svg.SVGCache;
     40import com.kitfox.svg.SVGDiagram;
     41import com.kitfox.svg.SVGException;
     42import com.kitfox.svg.SVGUniverse;
     43import java.awt.Component;
     44import java.awt.Dimension;
     45import java.awt.Graphics;
     46import java.awt.Graphics2D;
     47import java.awt.Image;
     48import java.awt.Rectangle;
     49import java.awt.RenderingHints;
     50import java.awt.geom.AffineTransform;
     51import java.awt.geom.Rectangle2D;
     52import java.awt.image.BufferedImage;
     53import java.beans.PropertyChangeListener;
     54import java.beans.PropertyChangeSupport;
     55import java.net.URI;
     56import javax.swing.ImageIcon;
     57
    4558
    4659/**
     
    4861 * @author kitfox
    4962 */
    50 public class SVGIcon implements Icon
     63public class SVGIcon extends ImageIcon
    5164{
    5265    public static final long serialVersionUID = 1;
     
    94107    }
    95108   
     109    public Image getImage()
     110    {
     111        BufferedImage bi = new BufferedImage(getIconWidth(), getIconHeight(), BufferedImage.TYPE_INT_ARGB);
     112        paintIcon(null, bi.getGraphics(), 0, 0);
     113        return bi;
     114    }
     115
    96116    /**
    97117     * @return height of this icon
  • trunk/src/com/kitfox/svg/util/FontSystem.java

    r8084 r10787  
    11/*
    2  * To change this license header, choose License Headers in Project Properties.
    3  * To change this template file, choose Tools | Templates
    4  * and open the template in the editor.
     2 * SVG Salamander
     3 * Copyright (c) 2004, Mark McKay
     4 * All rights reserved.
     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:
     9 *
     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.
     17 *
     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
     33 *
     34 * Created on April 24, 2015
    535 */
    636package com.kitfox.svg.util;
  • trunk/src/com/kitfox/svg/util/TextBuilder.java

    r8084 r10787  
    11/*
    2  * To change this license header, choose License Headers in Project Properties.
    3  * To change this template file, choose Tools | Templates
    4  * and open the template in the editor.
     2 * SVG Salamander
     3 * Copyright (c) 2004, Mark McKay
     4 * All rights reserved.
     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:
     9 *
     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.
     17 *
     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
     33 *
     34 * Created on April 24, 2015
    535 */
    636package com.kitfox.svg.util;
Note: See TracChangeset for help on using the changeset viewer.