From 86ece1cb42537370a924c96591b8f76d6cac1d61 Mon Sep 17 00:00:00 2001 From: kitfox Date: Sat, 8 Jun 2013 15:58:48 +0000 Subject: Tspan should now handle setting the x without the y also being specified. git-svn-id: https://svn.java.net/svn/svgsalamander~svn/trunk/svg-core@157 7dc7fa77-23fb-e6ad-8e2e-c86bd48ed22b --- src/main/java/com/kitfox/svg/SVGElement.java | 49 ++- src/main/java/com/kitfox/svg/SVGRoot.java | 26 +- src/main/java/com/kitfox/svg/SVGUniverse.java | 341 +++++++++++---------- src/main/java/com/kitfox/svg/Style.java | 15 + src/main/java/com/kitfox/svg/Tspan.java | 10 +- .../java/com/kitfox/svg/app/beans/SVGPanel.java | 14 - src/main/java/com/kitfox/svg/xml/StyleSheet.java | 11 + 7 files changed, 269 insertions(+), 197 deletions(-) diff --git a/src/main/java/com/kitfox/svg/SVGElement.java b/src/main/java/com/kitfox/svg/SVGElement.java index 377ac5f..269a717 100644 --- a/src/main/java/com/kitfox/svg/SVGElement.java +++ b/src/main/java/com/kitfox/svg/SVGElement.java @@ -35,17 +35,41 @@ */ package com.kitfox.svg; +import com.kitfox.svg.animation.AnimationElement; +import com.kitfox.svg.animation.TrackBase; +import com.kitfox.svg.animation.TrackManager; +import com.kitfox.svg.pathcmd.Arc; +import com.kitfox.svg.pathcmd.BuildHistory; +import com.kitfox.svg.pathcmd.Cubic; +import com.kitfox.svg.pathcmd.CubicSmooth; +import com.kitfox.svg.pathcmd.Horizontal; +import com.kitfox.svg.pathcmd.LineTo; +import com.kitfox.svg.pathcmd.MoveTo; +import com.kitfox.svg.pathcmd.PathCommand; +import com.kitfox.svg.pathcmd.Quadratic; +import com.kitfox.svg.pathcmd.QuadraticSmooth; +import com.kitfox.svg.pathcmd.Terminal; +import com.kitfox.svg.pathcmd.Vertical; +import com.kitfox.svg.xml.StyleAttribute; import com.kitfox.svg.xml.StyleSheet; -import java.util.*; -import java.util.regex.*; -import java.net.*; -import java.awt.geom.*; - -import org.xml.sax.*; -import com.kitfox.svg.animation.*; -import com.kitfox.svg.pathcmd.*; -import com.kitfox.svg.xml.*; +import com.kitfox.svg.xml.XMLParseUtil; +import java.awt.geom.AffineTransform; +import java.awt.geom.GeneralPath; import java.io.Serializable; +import java.net.URI; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; + /** * @author Mark McKay @@ -571,7 +595,7 @@ abstract public class SVGElement implements Serializable String styName = attrib.getName(); //Check for local inline styles - StyleAttribute styAttr = (StyleAttribute) inlineStyles.get(styName); + StyleAttribute styAttr = (StyleAttribute)inlineStyles.get(styName); attrib.setStringValue(styAttr == null ? "" : styAttr.getStringValue()); @@ -590,11 +614,8 @@ abstract public class SVGElement implements Serializable } - - //Implement style sheet lookup later - //Check for presentation attribute - StyleAttribute presAttr = (StyleAttribute) presAttribs.get(styName); + StyleAttribute presAttr = (StyleAttribute)presAttribs.get(styName); attrib.setStringValue(presAttr == null ? "" : presAttr.getStringValue()); diff --git a/src/main/java/com/kitfox/svg/SVGRoot.java b/src/main/java/com/kitfox/svg/SVGRoot.java index 08740b9..5edc476 100644 --- a/src/main/java/com/kitfox/svg/SVGRoot.java +++ b/src/main/java/com/kitfox/svg/SVGRoot.java @@ -36,11 +36,14 @@ package com.kitfox.svg; -import com.kitfox.svg.xml.StyleSheet; import com.kitfox.svg.xml.NumberWithUnits; import com.kitfox.svg.xml.StyleAttribute; -import java.awt.*; -import java.awt.geom.*; +import com.kitfox.svg.xml.StyleSheet; +import java.awt.Graphics2D; +import java.awt.Rectangle; +import java.awt.Shape; +import java.awt.geom.AffineTransform; +import java.awt.geom.Rectangle2D; /** * The root element of an SVG tree. @@ -142,7 +145,10 @@ public class SVGRoot extends Group { parSpecifier = PS_MEET; } - else if (contains(preserve, "slice")) parSpecifier = PS_SLICE; + else if (contains(preserve, "slice")) + { + parSpecifier = PS_SLICE; + } } prepareViewport(); @@ -362,6 +368,18 @@ public class SVGRoot extends Group */ public StyleSheet getStyleSheet() { + if (styleSheet == null) + { + for (int i = 0; i < getNumChildren(); ++i) + { + SVGElement ele = getChild(i); + if (ele instanceof Style) + { + return ((Style)ele).getStyleSheet(); + } + } + } + return styleSheet; } diff --git a/src/main/java/com/kitfox/svg/SVGUniverse.java b/src/main/java/com/kitfox/svg/SVGUniverse.java index 398d85a..a8e5f76 100644 --- a/src/main/java/com/kitfox/svg/SVGUniverse.java +++ b/src/main/java/com/kitfox/svg/SVGUniverse.java @@ -33,7 +33,6 @@ * * Created on February 18, 2004, 11:43 PM */ - package com.kitfox.svg; import com.kitfox.svg.app.beans.SVGIcon; @@ -71,59 +70,54 @@ import org.xml.sax.XMLReader; import org.xml.sax.helpers.XMLReaderFactory; /** - * Many SVG files can be loaded at one time. These files will quite likely - * need to reference one another. The SVG universe provides a container for - * all these files and the means for them to relate to each other. + * Many SVG files can be loaded at one time. These files will quite likely need + * to reference one another. The SVG universe provides a container for all these + * files and the means for them to relate to each other. * * @author Mark McKay * @author Mark McKay */ public class SVGUniverse implements Serializable { + public static final long serialVersionUID = 0; - transient private PropertyChangeSupport changes = new PropertyChangeSupport(this); - /** - * Maps document URIs to their loaded SVG diagrams. Note that URIs for + * Maps document URIs to their loaded SVG diagrams. Note that URIs for * documents loaded from URLs will reflect their URLs and URIs for documents * initiated from streams will have the scheme svgSalamander. */ final HashMap loadedDocs = new HashMap(); - final HashMap loadedFonts = new HashMap(); - final HashMap loadedImages = new HashMap(); - public static final String INPUTSTREAM_SCHEME = "svgSalamander"; - /** - * Current time in this universe. Used for resolving attributes that - * are influenced by track information. Time is in milliseconds. Time - * 0 coresponds to the time of 0 in each member diagram. + * Current time in this universe. Used for resolving attributes that are + * influenced by track information. Time is in milliseconds. Time 0 + * coresponds to the time of 0 in each member diagram. */ protected double curTime = 0.0; - private boolean verbose = false; - //Cache reader for efficiency XMLReader cachedReader; - - /** Creates a new instance of SVGUniverse */ + + /** + * Creates a new instance of SVGUniverse + */ public SVGUniverse() { } - + public void addPropertyChangeListener(PropertyChangeListener l) { changes.addPropertyChangeListener(l); } - + public void removePropertyChangeListener(PropertyChangeListener l) { changes.removePropertyChangeListener(l); } - + /** * Release all loaded SVG document from memory */ @@ -133,22 +127,22 @@ public class SVGUniverse implements Serializable loadedFonts.clear(); loadedImages.clear(); } - + /** * Returns the current animation time in milliseconds. */ public double getCurTime() - { - return curTime; + { + return curTime; } - + public void setCurTime(double curTime) { double oldTime = this.curTime; - this.curTime = curTime; + this.curTime = curTime; changes.firePropertyChange("curTime", new Double(oldTime), new Double(curTime)); } - + /** * Updates all time influenced style and presentation attributes in all SVG * documents in this universe. @@ -157,11 +151,11 @@ public class SVGUniverse implements Serializable { for (Iterator it = loadedDocs.values().iterator(); it.hasNext();) { - SVGDiagram dia = (SVGDiagram)it.next(); + SVGDiagram dia = (SVGDiagram) it.next(); dia.updateTime(curTime); } } - + /** * Called by the Font element to let the universe know that a font has been * loaded and is available. @@ -170,19 +164,19 @@ public class SVGUniverse implements Serializable { loadedFonts.put(font.getFontFace().getFontFamily(), font); } - + public Font getDefaultFont() { for (Iterator it = loadedFonts.values().iterator(); it.hasNext();) { - return (Font)it.next(); + return (Font) it.next(); } return null; } - + public Font getFont(String fontName) { - return (Font)loadedFonts.get(fontName); + return (Font) loadedFonts.get(fontName); } URL registerImage(URI imageURI) @@ -198,7 +192,8 @@ public class SVGUniverse implements Serializable if (content.startsWith("base64")) { content = content.substring(6); - try { + try + { byte[] buf = new sun.misc.BASE64Decoder().decodeBuffer(content); ByteArrayInputStream bais = new ByteArrayInputStream(buf); BufferedImage img = ImageIO.read(bais); @@ -219,21 +214,23 @@ public class SVGUniverse implements Serializable loadedImages.put(url, ref); return url; - } catch (IOException ex) { - Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, + } catch (IOException ex) + { + Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, "Could not decode inline image", ex); } } return null; - } - else + } else { - try { + try + { URL url = imageURI.toURL(); registerImage(url); return url; - } catch (MalformedURLException ex) { - Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, + } catch (MalformedURLException ex) + { + Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, "Bad url", ex); } return null; @@ -242,8 +239,11 @@ public class SVGUniverse implements Serializable void registerImage(URL imageURL) { - if (loadedImages.containsKey(imageURL)) return; - + if (loadedImages.containsKey(imageURL)) + { + return; + } + SoftReference ref; try { @@ -252,81 +252,80 @@ public class SVGUniverse implements Serializable { SVGIcon icon = new SVGIcon(); icon.setSvgURI(imageURL.toURI()); - + BufferedImage img = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB); Graphics2D g = img.createGraphics(); icon.paintIcon(null, g, 0, 0); g.dispose(); ref = new SoftReference(img); - } - else + } else { BufferedImage img = ImageIO.read(imageURL); ref = new SoftReference(img); } loadedImages.put(imageURL, ref); - } - catch (Exception e) + } catch (Exception e) { - Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, + Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, "Could not load image: " + imageURL, e); } } - + BufferedImage getImage(URL imageURL) { - SoftReference ref = (SoftReference)loadedImages.get(imageURL); - if (ref == null) return null; - - BufferedImage img = (BufferedImage)ref.get(); + SoftReference ref = (SoftReference) loadedImages.get(imageURL); + if (ref == null) + { + return null; + } + + BufferedImage img = (BufferedImage) ref.get(); //If image was cleared from memory, reload it if (img == null) { try { img = ImageIO.read(imageURL); - } - catch (Exception e) + } catch (Exception e) { - Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, + Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, "Could not load image", e); } ref = new SoftReference(img); loadedImages.put(imageURL, ref); } - + return img; } - + /** - * Returns the element of the document at the given URI. If the document - * is not already loaded, it will be. + * Returns the element of the document at the given URI. If the document is + * not already loaded, it will be. */ public SVGElement getElement(URI path) { return getElement(path, true); } - + public SVGElement getElement(URL path) { try { URI uri = new URI(path.toString()); return getElement(uri, true); - } - catch (Exception e) + } catch (Exception e) { - Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, + Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, "Could not parse url " + path, e); } return null; } - + /** - * Looks up a href within our universe. If the href refers to a document that - * is not loaded, it will be loaded. The URL #target will then be checked - * against the SVG diagram's index and the coresponding element returned. - * If there is no coresponding index, null is returned. + * Looks up a href within our universe. If the href refers to a document + * that is not loaded, it will be loaded. The URL #target will then be + * checked against the SVG diagram's index and the coresponding element + * returned. If there is no coresponding index, null is returned. */ public SVGElement getElement(URI path, boolean loadIfAbsent) { @@ -334,46 +333,54 @@ public class SVGUniverse implements Serializable { //Strip fragment from URI URI xmlBase = new URI(path.getScheme(), path.getSchemeSpecificPart(), null); - - SVGDiagram dia = (SVGDiagram)loadedDocs.get(xmlBase); + + SVGDiagram dia = (SVGDiagram) loadedDocs.get(xmlBase); if (dia == null && loadIfAbsent) { //System.err.println("SVGUnivserse: " + xmlBase.toString()); //javax.swing.JOptionPane.showMessageDialog(null, xmlBase.toString()); URL url = xmlBase.toURL(); - + loadSVG(url, false); - dia = (SVGDiagram)loadedDocs.get(xmlBase); - if (dia == null) return null; + dia = (SVGDiagram) loadedDocs.get(xmlBase); + if (dia == null) + { + return null; + } } - + String fragment = path.getFragment(); return fragment == null ? dia.getRoot() : dia.getElement(fragment); - } - catch (Exception e) + } catch (Exception e) { - Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, + Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, "Could not parse path " + path, e); return null; } } - + public SVGDiagram getDiagram(URI xmlBase) { return getDiagram(xmlBase, true); } - + /** - * Returns the diagram that has been loaded from this root. If diagram is + * Returns the diagram that has been loaded from this root. If diagram is * not already loaded, returns null. */ public SVGDiagram getDiagram(URI xmlBase, boolean loadIfAbsent) { - if (xmlBase == null) return null; + if (xmlBase == null) + { + return null; + } + + SVGDiagram dia = (SVGDiagram) loadedDocs.get(xmlBase); + if (dia != null || !loadIfAbsent) + { + return dia; + } - SVGDiagram dia = (SVGDiagram)loadedDocs.get(xmlBase); - if (dia != null || !loadIfAbsent) return dia; - //Load missing diagram try { @@ -389,24 +396,23 @@ public class SVGUniverse implements Serializable url = xmlBase.toURL(); } - + loadSVG(url, false); - dia = (SVGDiagram)loadedDocs.get(xmlBase); + dia = (SVGDiagram) loadedDocs.get(xmlBase); return dia; - } - catch (Exception e) + } catch (Exception e) { - Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, + Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, "Could not parse", e); } - + return null; } - + /** - * Wraps input stream in a BufferedInputStream. If it is detected that this + * Wraps input stream in a BufferedInputStream. If it is detected that this * input stream is GZIPped, also wraps in a GZIPInputStream for inflation. - * + * * @param is Raw input stream * @return Uncompressed stream of SVG data * @throws java.io.IOException @@ -424,23 +430,23 @@ public class SVGUniverse implements Serializable { GZIPInputStream iis = new GZIPInputStream(bin); return iis; - } - else + } else { //Plain text return bin; } } - + public URI loadSVG(URL docRoot) { return loadSVG(docRoot, false); } - + /** * Loads an SVG file and all the files it references from the URL provided. * If a referenced file already exists in the SVG universe, it is not * reloaded. + * * @param docRoot - URL to the location where this SVG file can be found. * @param forceLoad - if true, ignore cached diagram and reload * @return - The URI that refers to the loaded document @@ -454,68 +460,69 @@ public class SVGUniverse implements Serializable { return uri; } - + InputStream is = docRoot.openStream(); return loadSVG(uri, new InputSource(createDocumentInputStream(is))); - } - catch (URISyntaxException ex) + } catch (URISyntaxException ex) { - Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, + Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, "Could not parse", ex); - } - catch (IOException e) + } catch (IOException e) { - Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, + Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, "Could not parse", e); } - + return null; } - - + public URI loadSVG(InputStream is, String name) throws IOException { return loadSVG(is, name, false); } - + public URI loadSVG(InputStream is, String name, boolean forceLoad) throws IOException { URI uri = getStreamBuiltURI(name); - if (uri == null) return null; - if (loadedDocs.containsKey(uri) && !forceLoad) return uri; - + if (uri == null) + { + return null; + } + if (loadedDocs.containsKey(uri) && !forceLoad) + { + return uri; + } + return loadSVG(uri, new InputSource(createDocumentInputStream(is))); } - + public URI loadSVG(Reader reader, String name) { return loadSVG(reader, name, false); } - + /** * This routine allows you to create SVG documents from data streams that - * may not necessarily have a URL to load from. Since every SVG document - * must be identified by a unique URL, Salamander provides a method to - * fake this for streams by defining it's own protocol - svgSalamander - - * for SVG documents without a formal URL. + * may not necessarily have a URL to load from. Since every SVG document + * must be identified by a unique URL, Salamander provides a method to fake + * this for streams by defining it's own protocol - svgSalamander - for SVG + * documents without a formal URL. * * @param reader - A stream containing a valid SVG document - * @param name -

A unique name for this document. It will be used to + * @param name -

A unique name for this document. It will be used to * construct a unique URI to refer to this document and perform resolution - * with relative URIs within this document.

- *

For example, a name of "/myScene" will produce the URI - * svgSalamander:/myScene. "/maps/canada/toronto" will produce - * svgSalamander:/maps/canada/toronto. If this second document then - * contained the href "../uk/london", it would resolve by default to - * svgSalamander:/maps/uk/london. That is, SVG Salamander defines the - * URI scheme svgSalamander for it's own internal use and uses it - * for uniquely identfying documents loaded by stream.

- *

If you need to link to documents outside of this scheme, you can - * either supply full hrefs (eg, href="url(http://www.kitfox.com/index.html)") - * or put the xml:base attribute in a tag to change the defaultbase - * URIs are resolved against

- *

If a name does not start with the character '/', it will be automatically - * prefixed to it.

+ * with relative URIs within this document.

For example, a name of + * "/myScene" will produce the URI svgSalamander:/myScene. + * "/maps/canada/toronto" will produce svgSalamander:/maps/canada/toronto. + * If this second document then contained the href "../uk/london", it would + * resolve by default to svgSalamander:/maps/uk/london. That is, SVG + * Salamander defines the URI scheme svgSalamander for it's own internal use + * and uses it for uniquely identfying documents loaded by stream.

If + * you need to link to documents outside of this scheme, you can either + * supply full hrefs (eg, href="url(http://www.kitfox.com/index.html)") or + * put the xml:base attribute in a tag to change the defaultbase URIs are + * resolved against

If a name does not start with the character '/', + * it will be automatically prefixed to it.

* @param forceLoad - if true, ignore cached diagram and reload * * @return - The URI that refers to the loaded document @@ -525,35 +532,47 @@ public class SVGUniverse implements Serializable //System.err.println(url.toString()); //Synthesize URI for this stream URI uri = getStreamBuiltURI(name); - if (uri == null) return null; - if (loadedDocs.containsKey(uri) && !forceLoad) return uri; - + if (uri == null) + { + return null; + } + if (loadedDocs.containsKey(uri) && !forceLoad) + { + return uri; + } + return loadSVG(uri, new InputSource(reader)); } - + /** * Synthesize a URI for an SVGDiagram constructed from a stream. + * * @param name - Name given the document constructed from a stream. */ public URI getStreamBuiltURI(String name) { - if (name == null || name.length() == 0) return null; - - if (name.charAt(0) != '/') name = '/' + name; - + if (name == null || name.length() == 0) + { + return null; + } + + if (name.charAt(0) != '/') + { + name = '/' + name; + } + try { //Dummy URL for SVG documents built from image streams return new URI(INPUTSTREAM_SCHEME, name, null); - } - catch (Exception e) + } catch (Exception e) { - Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, + Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, "Could not parse", e); return null; } } - + private XMLReader getXMLReaderCached() throws SAXException { if (cachedReader == null) @@ -562,17 +581,17 @@ public class SVGUniverse implements Serializable } return cachedReader; } - + protected URI loadSVG(URI xmlBase, InputSource is) { // Use an instance of ourselves as the SAX event handler SVGLoader handler = new SVGLoader(xmlBase, this, verbose); - + //Place this docment in the universe before it is completely loaded // so that the load process can refer to references within it's current // document loadedDocs.put(xmlBase, handler.getLoadedDiagram()); - + try { // Parse the input @@ -585,31 +604,28 @@ public class SVGUniverse implements Serializable //Ignore all DTDs return new InputSource(new ByteArrayInputStream(new byte[0])); } - } - ); + }); reader.setContentHandler(handler); reader.parse(is); - + handler.getLoadedDiagram().updateTime(curTime); return xmlBase; - } - catch (SAXParseException sex) + } catch (SAXParseException sex) { System.err.println("Error processing " + xmlBase); System.err.println(sex.getMessage()); - + loadedDocs.remove(xmlBase); return null; - } - catch (Throwable e) + } catch (Throwable e) { - Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, + Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, "Could not load SVG " + xmlBase, e); } - + return null; } - + // public static void main(String argv[]) // { // try @@ -649,7 +665,6 @@ public class SVGUniverse implements Serializable // "Could not parse", e); // } // } - public boolean isVerbose() { return verbose; @@ -659,7 +674,7 @@ public class SVGUniverse implements Serializable { this.verbose = verbose; } - + /** * Uses serialization to duplicate this universe. */ @@ -672,7 +687,7 @@ public class SVGUniverse implements Serializable ByteArrayInputStream bin = new ByteArrayInputStream(bs.toByteArray()); ObjectInputStream is = new ObjectInputStream(bin); - SVGUniverse universe = (SVGUniverse)is.readObject(); + SVGUniverse universe = (SVGUniverse) is.readObject(); is.close(); return universe; diff --git a/src/main/java/com/kitfox/svg/Style.java b/src/main/java/com/kitfox/svg/Style.java index 24bf2cd..eac0e04 100644 --- a/src/main/java/com/kitfox/svg/Style.java +++ b/src/main/java/com/kitfox/svg/Style.java @@ -36,6 +36,7 @@ package com.kitfox.svg; import com.kitfox.svg.xml.StyleAttribute; +import com.kitfox.svg.xml.StyleSheet; /** * Holds title textual information within tree @@ -51,6 +52,8 @@ public class Style extends SVGElement String type; StringBuffer text = new StringBuffer(); + StyleSheet styleSheet; + /** * Creates a new instance of Stop */ @@ -69,6 +72,9 @@ public class Style extends SVGElement public void loaderAddText(SVGLoaderHelper helper, String text) { this.text.append(text); + + //Invalidate style sheet + styleSheet = null; } protected void build() throws SVGException @@ -88,4 +94,13 @@ public class Style extends SVGElement //Style sheet doesn't change return false; } + + public StyleSheet getStyleSheet() + { + if (styleSheet == null && text.length() > 0) + { + styleSheet = StyleSheet.parseSheet(text.toString()); + } + return styleSheet; + } } diff --git a/src/main/java/com/kitfox/svg/Tspan.java b/src/main/java/com/kitfox/svg/Tspan.java index 1dbc734..ef017ec 100644 --- a/src/main/java/com/kitfox/svg/Tspan.java +++ b/src/main/java/com/kitfox/svg/Tspan.java @@ -51,8 +51,8 @@ import java.awt.geom.Rectangle2D; */ public class Tspan extends ShapeElement { + public static final String TAG_NAME = "tspan"; - float[] x = null; float[] y = null; float[] dx = null; @@ -169,10 +169,16 @@ public class Tspan extends ShapeElement if (x != null) { cursorX = x[0]; - cursorY = y[0]; } else if (dx != null) { cursorX += dx[0]; + } + + if (y != null) + { + cursorY = y[0]; + } else if (dy != null) + { cursorY += dy[0]; } diff --git a/src/main/java/com/kitfox/svg/app/beans/SVGPanel.java b/src/main/java/com/kitfox/svg/app/beans/SVGPanel.java index e494867..5682b74 100644 --- a/src/main/java/com/kitfox/svg/app/beans/SVGPanel.java +++ b/src/main/java/com/kitfox/svg/app/beans/SVGPanel.java @@ -135,20 +135,6 @@ public class SVGPanel extends JPanel Dimension dim = getSize(); final int width = dim.width; final int height = dim.height; -// int width = getWidth(); -// int height = getHeight(); - -// if (width == 0 || height == 0) -// { -// //Chances are we're rendering offscreen -// Dimension dim = getSize(); -// width = dim.width; -// height = dim.height; -// return; -// } - -// g.setClip(0, 0, dim.width, dim.height); - final Rectangle2D.Double rect = new Rectangle2D.Double(); diagram.getViewRect(rect); diff --git a/src/main/java/com/kitfox/svg/xml/StyleSheet.java b/src/main/java/com/kitfox/svg/xml/StyleSheet.java index da3db2e..6d58273 100644 --- a/src/main/java/com/kitfox/svg/xml/StyleSheet.java +++ b/src/main/java/com/kitfox/svg/xml/StyleSheet.java @@ -4,7 +4,10 @@ */ package com.kitfox.svg.xml; +import com.kitfox.svg.SVGConst; import java.util.HashMap; +import java.util.logging.Level; +import java.util.logging.Logger; /** * @@ -14,6 +17,14 @@ public class StyleSheet { HashMap ruleMap = new HashMap(); + public static StyleSheet parseSheet(String src) + { + //Implement CS parser later + Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, + "CSS parser not implemented yet"); + return null; + } + public void addStyleRule(StyleSheetRule rule, String value) { ruleMap.put(rule, value); -- cgit v1.2.3-55-g7522