Changeset 7676 in josm for trunk/src/com/kitfox/svg


Ignore:
Timestamp:
2014-10-30T11:39:47+01:00 (9 years ago)
Author:
stoecker
Message:

update SVG code to current SVN (fix line endings), see #10479

Location:
trunk/src/com/kitfox/svg
Files:
18 edited

Legend:

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

    r6002 r7676  
    131131     * all attributes with track information.
    132132     *
     133     * @param curTime
    133134     * @return - true if this node has changed state as a result of the time
    134135     * update
     136     * @throws com.kitfox.svg.SVGException
    135137     */
    136138    public boolean updateTime(double curTime) throws SVGException
     
    160162        }
    161163
     164        for (int i = 0; i < children.size(); ++i)
     165        {
     166            SVGElement ele = (SVGElement) children.get(i);
     167            ele.updateTime(curTime);
     168        }
     169       
    162170        return shapeChange;
    163171    }
  • trunk/src/com/kitfox/svg/Group.java

    r6002 r7676  
    160160        //Do not process offscreen groups
    161161        boolean ignoreClip = diagram.ignoringClipHeuristic();
    162         if (!ignoreClip && outsideClip(g))
    163         {
    164             return;
    165         }
     162//        if (!ignoreClip && outsideClip(g))
     163//        {
     164//            return;
     165//        }
    166166
    167167        beginLayer(g);
     
    271271                RenderableElement rendEle = (RenderableElement) ele;
    272272                Rectangle2D bounds = rendEle.getBoundingBox();
    273                 if (bounds != null)
     273                if (bounds != null && (bounds.getWidth() != 0 || bounds.getHeight() != 0))
    274274                {
    275275                    if (retRect == null)
    276276                    {
    277277                        retRect = bounds;
    278                     } else
     278                    }
     279                    else
    279280                    {
    280                         retRect = retRect.createUnion(bounds);
     281                        if (retRect.getWidth() != 0 || retRect.getHeight() != 0)
     282                        {
     283                            retRect = retRect.createUnion(bounds);
     284                        }
    281285                    }
    282286                }
  • trunk/src/com/kitfox/svg/ImageSVG.java

    r6002 r7676  
    124124                    {
    125125                        Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
    126                             "Could not parse xlink:href", e);
     126                            "Could not parse xlink:href " + src, e);
    127127//                        e.printStackTrace();
    128128                        imageSrc = null;
  • trunk/src/com/kitfox/svg/RadialGradient.java

    r6002 r7676  
    121121        Point2D.Float pt1 = new Point2D.Float(cx, cy);
    122122        Point2D.Float pt2 = new Point2D.Float(fx, fy);
    123         if (pt1.equals(pt2))
    124         {
    125             Color[] colors = getStopColors();
    126             paint = colors.length > 0 ? colors[0] : Color.black;
    127         } else if (gradientUnits == GU_USER_SPACE_ON_USE)
     123        if (gradientUnits == GU_USER_SPACE_ON_USE)
    128124        {
    129125            paint = new com.kitfox.svg.batik.RadialGradientPaint(
  • trunk/src/com/kitfox/svg/SVGDiagram.java

    r6002 r7676  
    103103    public void render(Graphics2D g) throws SVGException
    104104    {
    105         root.render(g);
     105        root.renderToViewport(g);
    106106    }
    107107   
  • trunk/src/com/kitfox/svg/SVGElement.java

    r6002 r7676  
    588588    static public AffineTransform parseSingleTransform(String val) throws SVGException
    589589    {
    590         final Matcher matchWord = Pattern.compile("[-.\\w]+").matcher("");
     590        final Matcher matchWord = Pattern.compile("([a-zA-Z]+|-?\\d+(\\.\\d+)?|-?\\.\\d+)").matcher("");
    591591
    592592        AffineTransform retXform = new AffineTransform();
  • trunk/src/com/kitfox/svg/SVGRoot.java

    r6002 r7676  
    4444import java.awt.Shape;
    4545import java.awt.geom.AffineTransform;
     46import java.awt.geom.NoninvertibleTransformException;
     47import java.awt.geom.Point2D;
    4648import java.awt.geom.Rectangle2D;
     49import java.util.List;
    4750
    4851/**
     
    239242        clipRect.setRect(xx, yy, ww, hh);
    240243
     244//        if (viewBox == null)
     245//        {
     246//            viewXform.setToIdentity();
     247//        }
     248//        else
     249//        {
     250//            //If viewport window is set, we are drawing to entire viewport
     251//            clipRect.setRect(deviceViewport);
     252//           
     253//            viewXform.setToIdentity();
     254//            viewXform.setToTranslation(deviceViewport.x, deviceViewport.y);
     255//            viewXform.scale(deviceViewport.width, deviceViewport.height);
     256//            viewXform.scale(1 / viewBox.width, 1 / viewBox.height);
     257//            viewXform.translate(-viewBox.x, -viewBox.y);
     258//        }
     259    }
     260
     261    public void renderToViewport(Graphics2D g) throws SVGException
     262    {
     263        prepareViewport();
     264
    241265        if (viewBox == null)
    242266        {
     
    245269        else
    246270        {
    247             viewXform.setToTranslation(clipRect.x, clipRect.y);
    248             viewXform.scale(clipRect.width, clipRect.height);
     271            Rectangle deviceViewport = g.getClipBounds();
     272            //If viewport window is set, we are drawing to entire viewport
     273            clipRect.setRect(deviceViewport);
     274           
     275            viewXform.setToIdentity();
     276            viewXform.setToTranslation(deviceViewport.x, deviceViewport.y);
     277            viewXform.scale(deviceViewport.width, deviceViewport.height);
    249278            viewXform.scale(1 / viewBox.width, 1 / viewBox.height);
    250279            viewXform.translate(-viewBox.x, -viewBox.y);
    251280        }
    252     }
    253 
    254     public void render(Graphics2D g) throws SVGException
    255     {
    256         prepareViewport();
    257281       
    258282        AffineTransform cachedXform = g.getTransform();
     
    262286       
    263287        g.setTransform(cachedXform);
     288    }
     289
     290    public void pick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List retVec) throws SVGException
     291    {
     292        if (viewXform != null)
     293        {
     294            ltw = new AffineTransform(ltw);
     295            ltw.concatenate(viewXform);
     296        }
     297       
     298        super.pick(pickArea, ltw, boundingBox, retVec);
     299    }
     300   
     301    public void pick(Point2D point, boolean boundingBox, List retVec) throws SVGException
     302    {
     303        Point2D xPoint = new Point2D.Double(point.getX(), point.getY());
     304        if (viewXform != null)
     305        {
     306            try
     307            {
     308                viewXform.inverseTransform(point, xPoint);
     309            } catch (NoninvertibleTransformException ex)
     310            {
     311                throw new SVGException(ex);
     312            }
     313        }
     314       
     315        super.pick(xPoint, boundingBox, retVec);
    264316    }
    265317
  • trunk/src/com/kitfox/svg/SVGUniverse.java

    r6617 r7676  
    5555import java.net.URISyntaxException;
    5656import java.net.URL;
    57 import java.net.URLConnection;
    58 import java.net.URLStreamHandler;
     57import java.util.ArrayList;
    5958import java.util.HashMap;
    6059import java.util.Iterator;
     
    389388            {
    390389                //Workaround for resources stored in jars loaded by Webstart.
    391                 //https://bugs.openjdk.java.net/browse/JDK-6753651
     390                //http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6753651
    392391                url = SVGUniverse.class.getResource("xmlBase.getPath()");
    393392            }
     
    627626    }
    628627
    629 //    public static void main(String argv[])
    630 //    {
    631 //        try
    632 //        {
    633 //            URL url = new URL("svgSalamander", "localhost", -1, "abc.svg",
    634 //                    new URLStreamHandler()
    635 //            {
    636 //                protected URLConnection openConnection(URL u)
    637 //                {
    638 //                    return null;
    639 //                }
    640 //            }
    641 //            );
    642 ////            URL url2 = new URL("svgSalamander", "localhost", -1, "abc.svg");
    643 //           
    644 //            //Investigate URI resolution
    645 //            URI uriA, uriB, uriC, uriD, uriE;
    646 //           
    647 //            uriA = new URI("svgSalamander", "/names/mySpecialName", null);
    648 ////            uriA = new URI("http://www.kitfox.com/salamander");
    649 ////            uriA = new URI("svgSalamander://mySpecialName/grape");
    650 //            System.err.println(uriA.toString());
    651 //            System.err.println(uriA.getScheme());
    652 //           
    653 //            uriB = uriA.resolve("#begin");
    654 //            System.err.println(uriB.toString());
    655 //           
    656 //            uriC = uriA.resolve("tree#boing");
    657 //            System.err.println(uriC.toString());
    658 //           
    659 //            uriC = uriA.resolve("../tree#boing");
    660 //            System.err.println(uriC.toString());
    661 //        }
    662 //        catch (Exception e)
    663 //        {
    664 //            Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
    665 //                "Could not parse", e);
    666 //        }
    667 //    }
     628    /**
     629     * Get list of uris of all loaded documents and subdocuments.
     630     * @return
     631     */
     632    public ArrayList getLoadedDocumentURIs()
     633    {
     634        return new ArrayList(loadedDocs.keySet());
     635    }
     636   
     637    /**
     638     * Remove loaded document from cache.
     639     * @param uri
     640     */
     641    public void removeDocument(URI uri)
     642    {
     643        loadedDocs.remove(uri);
     644    }
     645   
    668646    public boolean isVerbose()
    669647    {
  • trunk/src/com/kitfox/svg/ShapeElement.java

    r6002 r7676  
    8787    void pick(Point2D point, boolean boundingBox, List retVec) throws SVGException
    8888    {
    89         StyleAttribute styleAttrib = new StyleAttribute();
     89//        StyleAttribute styleAttrib = new StyleAttribute();
    9090//        if (getStyle(styleAttrib.setName("fill")) && getShape().contains(point))
    9191        if ((boundingBox ? getBoundingBox() : getShape()).contains(point))
  • trunk/src/com/kitfox/svg/Text.java

    r6002 r7676  
    4242import java.awt.geom.AffineTransform;
    4343import java.awt.geom.GeneralPath;
     44import java.awt.geom.Point2D;
    4445import java.awt.geom.Rectangle2D;
    4546import java.util.Iterator;
     
    209210        } else
    210211        {
    211             fontWeight = TXWE_BOLD;
     212            fontWeight = TXWE_NORMAL;
    212213        }
    213214
     
    352353            {
    353354                AffineTransform at = new AffineTransform();
    354                 at.translate(-textPath.getBounds2D().getWidth() / 2, 0);
     355                at.translate(-textPath.getBounds().getWidth() / 2, 0);
    355356                textPath.transform(at);
    356357                break;
     
    359360            {
    360361                AffineTransform at = new AffineTransform();
    361                 at.translate(-textPath.getBounds2D().getWidth(), 0);
     362                at.translate(-textPath.getBounds().getWidth(), 0);
    362363                textPath.transform(at);
    363364                break;
     
    390391            if (obj instanceof String)
    391392            {
    392                 String text = (String) obj;
     393                String text = (String)obj;
     394                text = text.trim();
    393395
    394396                Shape textShape = font.createGlyphVector(frc, text).getOutline(cursorX, cursorY);
     
    415417
    416418
    417                 Tspan tspan = (Tspan) obj;
    418                 tspan.setCursorX(cursorX);
    419                 tspan.setCursorY(cursorY);
    420                 tspan.addShape(textPath);
    421                 cursorX = tspan.getCursorX();
    422                 cursorY = tspan.getCursorY();
     419                Tspan tspan = (Tspan)obj;
     420                Point2D cursor = new Point2D.Float(cursorX, cursorY);
     421//                tspan.setCursorX(cursorX);
     422//                tspan.setCursorY(cursorY);
     423                tspan.appendToShape(textPath, cursor);
     424//                cursorX = tspan.getCursorX();
     425//                cursorY = tspan.getCursorY();
     426                cursorX = (float)cursor.getX();
     427                cursorY = (float)cursor.getY();
    423428
    424429            }
     
    430435            {
    431436                AffineTransform at = new AffineTransform();
    432                 at.translate(-textPath.getBounds2D().getWidth() / 2, 0);
     437                at.translate(-textPath.getBounds().getWidth() / 2, 0);
    433438                textPath.transform(at);
    434439                break;
     
    437442            {
    438443                AffineTransform at = new AffineTransform();
    439                 at.translate(-textPath.getBounds2D().getWidth(), 0);
     444                at.translate(-Math.ceil(textPath.getBounds().getWidth()), 0);
    440445                textPath.transform(at);
    441446                break;
  • trunk/src/com/kitfox/svg/TransformableElement.java

    r6002 r7676  
    7171    public AffineTransform getXForm()
    7272    {
    73         return xform != null ? new AffineTransform(xform) : null;
     73        return xform == null ? null : new AffineTransform(xform);
    7474    }
    7575    /*
  • trunk/src/com/kitfox/svg/Tspan.java

    r6002 r7676  
    4444import java.awt.geom.AffineTransform;
    4545import java.awt.geom.GeneralPath;
     46import java.awt.geom.Point2D;
    4647import java.awt.geom.Rectangle2D;
    4748
     
    6061    float[] rotate = null;
    6162    private String text = "";
    62     float cursorX;
    63     float cursorY;
     63//    float cursorX;
     64//    float cursorY;
    6465
    6566//    Shape tspanShape;
     
    7677    }
    7778
    78     public float getCursorX()
    79     {
    80         return cursorX;
    81     }
    82 
    83     public float getCursorY()
    84     {
    85         return cursorY;
    86     }
    87 
    88     public void setCursorX(float cursorX)
    89     {
    90         this.cursorX = cursorX;
    91     }
    92 
    93     public void setCursorY(float cursorY)
    94     {
    95         this.cursorY = cursorY;
    96     }
     79//    public float getCursorX()
     80//    {
     81//        return cursorX;
     82//    }
     83//
     84//    public float getCursorY()
     85//    {
     86//        return cursorY;
     87//    }
     88//
     89//    public void setCursorX(float cursorX)
     90//    {
     91//        this.cursorX = cursorX;
     92//    }
     93//
     94//    public void setCursorY(float cursorY)
     95//    {
     96//        this.cursorY = cursorY;
     97//    }
    9798    /*
    9899     public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent)
     
    165166    }
    166167
    167     public void addShape(GeneralPath addShape) throws SVGException
    168     {
    169         if (x != null)
    170         {
    171             cursorX = x[0];
    172         } else if (dx != null)
    173         {
    174             cursorX += dx[0];
    175         }
    176 
    177         if (y != null)
    178         {
    179             cursorY = y[0];
    180         } else if (dy != null)
    181         {
    182             cursorY += dy[0];
    183         }
     168    public void appendToShape(GeneralPath addShape, Point2D cursor) throws SVGException
     169    {
     170//        if (x != null)
     171//        {
     172//            cursorX = x[0];
     173//        } else if (dx != null)
     174//        {
     175//            cursorX += dx[0];
     176//        }
     177//
     178//        if (y != null)
     179//        {
     180//            cursorY = y[0];
     181//        } else if (dy != null)
     182//        {
     183//            cursorY += dy[0];
     184//        }
    184185
    185186        StyleAttribute sty = new StyleAttribute();
     
    209210        if (font == null)
    210211        {
    211             addShapeSysFont(addShape, font, fontFamily, fontSize, letterSpacing);
     212            addShapeSysFont(addShape, font, fontFamily, fontSize, letterSpacing, cursor);
    212213            return;
    213214        }
     
    221222        strokeWidthScalar = 1f / fontScale;
    222223
    223         int posPtr = 1;
    224 
    225         for (int i = 0; i < text.length(); i++)
    226         {
     224        float cursorX = (float)cursor.getX();
     225        float cursorY = (float)cursor.getY();
     226   
     227//        int i = 0;
     228
     229        String drawText = this.text;
     230        drawText = drawText.trim();
     231        for (int i = 0; i < drawText.length(); i++)
     232        {
     233            if (x != null && i < x.length)
     234            {
     235                cursorX = x[i];
     236            } else if (dx != null && i < dx.length)
     237            {
     238                cursorX += dx[i];
     239            }
     240           
     241            if (y != null && i < y.length)
     242            {
     243                cursorY = y[i];
     244            } else if (dy != null && i < dy.length)
     245            {
     246                cursorY += dy[i];
     247            }
     248  //          i++;
     249           
    227250            xform.setToIdentity();
    228251            xform.setToTranslation(cursorX, cursorY);
     
    230253            if (rotate != null)
    231254            {
    232                 xform.rotate(rotate[posPtr]);
    233             }
    234 
    235             String unicode = text.substring(i, i + 1);
     255                xform.rotate(rotate[i]);
     256            }
     257
     258            String unicode = drawText.substring(i, i + 1);
    236259            MissingGlyph glyph = font.getGlyph(unicode);
    237260
     
    243266            }
    244267
    245             if (x != null && posPtr < x.length)
    246             {
    247                 cursorX = x[posPtr];
    248                 cursorY = y[posPtr++];
    249             } else if (dx != null && posPtr < dx.length)
    250             {
    251                 cursorX += dx[posPtr];
    252                 cursorY += dy[posPtr++];
    253             }
    254 
    255268            cursorX += fontScale * glyph.getHorizAdvX() + letterSpacing;
    256269        }
    257270
     271        //Save final draw point so calling method knows where to begin next
     272        // text draw
     273        cursor.setLocation(cursorX, cursorY);
    258274        strokeWidthScalar = 1f;
    259275    }
    260276
    261277    private void addShapeSysFont(GeneralPath addShape, Font font,
    262         String fontFamily, float fontSize, float letterSpacing)
    263     {
     278        String fontFamily, float fontSize, float letterSpacing, Point2D cursor)
     279    {
     280
    264281        java.awt.Font sysFont = new java.awt.Font(fontFamily, java.awt.Font.PLAIN, (int) fontSize);
    265282
    266283        FontRenderContext frc = new FontRenderContext(null, true, true);
    267         GlyphVector textVector = sysFont.createGlyphVector(frc, text);
     284        String renderText = this.text.trim();
    268285
    269286        AffineTransform xform = new AffineTransform();
    270287
    271         int posPtr = 1;
    272         for (int i = 0; i < text.length(); i++)
    273         {
     288        float cursorX = (float)cursor.getX();
     289        float cursorY = (float)cursor.getY();
     290//        int i = 0;
     291        for (int i = 0; i < renderText.length(); i++)
     292        {
     293            if (x != null && i < x.length)
     294            {
     295                cursorX = x[i];
     296            } else if (dx != null && i < dx.length)
     297            {
     298                cursorX += dx[i];
     299            }
     300
     301            if (y != null && i < y.length)
     302            {
     303                cursorY = y[i];
     304            } else if (dy != null && i < dy.length)
     305            {
     306                cursorY += dy[i];
     307            }
     308//            i++;
     309           
    274310            xform.setToIdentity();
    275             xform.setToTranslation(cursorX + i * letterSpacing, cursorY);
     311            xform.setToTranslation(cursorX, cursorY);
    276312            if (rotate != null)
    277313            {
     
    279315            }
    280316
    281             String unicode = text.substring(i, i + 1);
    282             Shape glyphOutline = textVector.getGlyphOutline(i);
    283             GlyphMetrics glyphMetrics = textVector.getGlyphMetrics(i);
     317//            String unicode = renderText.substring(i, i + 1);
     318            GlyphVector textVector = sysFont.createGlyphVector(frc, renderText.substring(i, i + 1));
     319            Shape glyphOutline = textVector.getGlyphOutline(0);
     320            GlyphMetrics glyphMetrics = textVector.getGlyphMetrics(0);
    284321
    285322            glyphOutline = xform.createTransformedShape(glyphOutline);
    286323            addShape.append(glyphOutline, false);
    287324
    288             if (x != null && posPtr < x.length)
    289             {
    290                 cursorX = x[posPtr];
    291                 cursorY = y[posPtr++];
    292             } else if (dx != null && posPtr < dx.length)
    293             {
    294                 cursorX += dx[posPtr];
    295                 cursorY += dy[posPtr++];
    296             }
    297         }
     325
     326//            cursorX += fontScale * glyph.getHorizAdvX() + letterSpacing;
     327            cursorX += glyphMetrics.getAdvance() + letterSpacing;
     328        }
     329       
     330        cursor.setLocation(cursorX, cursorY);
    298331    }
    299332
    300333    public void render(Graphics2D g) throws SVGException
    301334    {
     335        float cursorX = 0;
     336        float cursorY = 0;
     337   
    302338        if (x != null)
    303339        {
     
    385421    protected void renderSysFont(Graphics2D g, java.awt.Font font) throws SVGException
    386422    {
     423        float cursorX = 0;
     424        float cursorY = 0;
     425   
    387426        int posPtr = 1;
    388427        FontRenderContext frc = g.getFontRenderContext();
  • trunk/src/com/kitfox/svg/Use.java

    r6002 r7676  
    124124        }
    125125
    126         RenderableElement rendEle = (RenderableElement) ref;
     126        RenderableElement rendEle = (RenderableElement)ref;
    127127        rendEle.pushParentContext(this);
    128128        rendEle.render(g);
  • trunk/src/com/kitfox/svg/app/beans/SVGIcon.java

    r6002 r7676  
    5151{
    5252    public static final long serialVersionUID = 1;
    53    
    54     private PropertyChangeSupport changes = new PropertyChangeSupport(this);
     53
     54    public static final String PROP_AUTOSIZE = "PROP_AUTOSIZE";
     55   
     56    private final PropertyChangeSupport changes = new PropertyChangeSupport(this);
    5557   
    5658    SVGUniverse svgUniverse = SVGCache.getSVGUniverse();
     
    6365    private boolean clipToViewbox;
    6466   
    65 //    private String svgPath;
    6667    URI svgURI;
    6768   
    68     private boolean scaleToFit;
     69//    private boolean scaleToFit;
    6970    AffineTransform scaleXform = new AffineTransform();
    70    
    71 //    Dimension preferredSize = new Dimension(100, 100);
     71
     72    public static final int AUTOSIZE_NONE = 0;
     73    public static final int AUTOSIZE_HORIZ = 1;
     74    public static final int AUTOSIZE_VERT = 2;
     75    public static final int AUTOSIZE_BESTFIT = 3;
     76    public static final int AUTOSIZE_STRETCH = 4;
     77    private int autosize = AUTOSIZE_NONE;
     78   
    7279    Dimension preferredSize;
    7380   
     
    9299    public int getIconHeight()
    93100    {
    94         if (scaleToFit && preferredSize != null)
     101        if (preferredSize != null &&
     102                (autosize == AUTOSIZE_VERT || autosize == AUTOSIZE_STRETCH
     103                || autosize == AUTOSIZE_BESTFIT))
    95104        {
    96105            return preferredSize.height;
     
    110119    public int getIconWidth()
    111120    {
    112         if (scaleToFit && preferredSize != null)
     121        if (preferredSize != null &&
     122                (autosize == AUTOSIZE_HORIZ || autosize == AUTOSIZE_STRETCH
     123                || autosize == AUTOSIZE_BESTFIT))
    113124        {
    114125            return preferredSize.width;
     
    172183       
    173184       
    174        
    175         if (!scaleToFit)
     185        if (autosize == AUTOSIZE_NONE)
    176186        {
    177187            try
     
    210220       
    211221       
    212         final Rectangle2D.Double rect = new Rectangle2D.Double();
    213         diagram.getViewRect(rect);
    214        
    215         scaleXform.setToScale(width / rect.width, height / rect.height);
     222//        final Rectangle2D.Double rect = new Rectangle2D.Double();
     223//        diagram.getViewRect(rect);
     224//       
     225//        scaleXform.setToScale(width / rect.width, height / rect.height);
     226        double diaWidth = diagram.getWidth();
     227        double diaHeight = diagram.getHeight();
     228       
     229        double scaleW = 1;
     230        double scaleH = 1;
     231        if (autosize == AUTOSIZE_BESTFIT)
     232        {
     233            scaleW = scaleH = (height / diaHeight < width / diaWidth)
     234                    ? height / diaHeight : width / diaWidth;
     235        }
     236        else if (autosize == AUTOSIZE_HORIZ)
     237        {
     238            scaleW = scaleH = width / diaWidth;
     239        }
     240        else if (autosize == AUTOSIZE_VERT)
     241        {
     242            scaleW = scaleH = height / diaHeight;
     243        }
     244        else if (autosize == AUTOSIZE_STRETCH)
     245        {
     246            scaleW = width / diaWidth;
     247            scaleH = height / diaHeight;
     248        }
     249        scaleXform.setToScale(scaleW, scaleH);
    216250       
    217251        AffineTransform oldXform = g.getTransform();
     
    315349     * If this SVG document has a viewbox, if scaleToFit is set, will scale the viewbox to match the
    316350     * preferred size of this icon
     351     * @deprecated
     352     * @return
    317353     */
    318354    public boolean isScaleToFit()
    319355    {
    320         return scaleToFit;
    321     }
    322    
     356        return autosize == AUTOSIZE_STRETCH;
     357    }
     358   
     359    /**
     360     * @deprecated
     361     * @return
     362     */
    323363    public void setScaleToFit(boolean scaleToFit)
    324364    {
    325         boolean old = this.scaleToFit;
    326         this.scaleToFit = scaleToFit;
    327         changes.firePropertyChange("scaleToFit", old, scaleToFit);
     365        setAutosize(AUTOSIZE_STRETCH);
     366//        boolean old = this.scaleToFit;
     367//        this.scaleToFit = scaleToFit;
     368//        firePropertyChange("scaleToFit", old, scaleToFit);
    328369    }
    329370   
     
    429470        this.clipToViewbox = clipToViewbox;
    430471    }
    431    
     472
     473    /**
     474     * @return the autosize
     475     */
     476    public int getAutosize()
     477    {
     478        return autosize;
     479    }
     480
     481    /**
     482     * @param autosize the autosize to set
     483     */
     484    public void setAutosize(int autosize)
     485    {
     486        int oldAutosize = this.autosize;
     487        this.autosize = autosize;
     488        changes.firePropertyChange(PROP_AUTOSIZE, oldAutosize, autosize);
     489    }
     490       
    432491}
  • trunk/src/com/kitfox/svg/pattern/PatternPaintContext.java

    r6002 r7676  
    9797    {
    9898//System.err.println("" + x + ", " + y + ", " + w + ", " + h);
    99         if (buf == null || buf.getWidth() != w || buf.getHeight() != buf.getHeight())
     99        if (buf == null || buf.getWidth() != w || buf.getHeight() != h)
    100100        {
    101101            buf = new BufferedImage(w, h, source.getType());
  • trunk/src/com/kitfox/svg/xml/ColorTable.java

    r6002 r7676  
    225225        Color retVal = null;
    226226
     227        if ("".equals(val))
     228        {
     229            return null;
     230        }
     231       
    227232        if (val.charAt(0) == '#')
    228233        {
  • trunk/src/com/kitfox/svg/xml/cpx/CPXInputStream.java

    r6002 r7676  
    3939import com.kitfox.svg.SVGConst;
    4040import java.io.*;
    41 import java.util.*;
    4241import java.util.zip.*;
    4342import java.security.*;
    4443import java.util.logging.Level;
    4544import java.util.logging.Logger;
    46 import javax.crypto.*;
    4745
    4846/**
  • trunk/src/com/kitfox/svg/xml/cpx/CPXOutputStream.java

    r6002 r7676  
    3939import java.io.*;
    4040import java.util.zip.*;
    41 import java.security.*;
    42 import javax.crypto.*;
    4341
    4442/**
Note: See TracChangeset for help on using the changeset viewer.