verbose - If true, prints out diagnostic information about processing.
+ * Defaults to false.
+ *
*
* Example:
* <SVGToImage destDir="${index.java}" format="jpg" verbose="true">
@@ -100,7 +100,7 @@
*/
public class SVGToImageAntTask extends Task
{
- private ArrayList filesets = new ArrayList();
+ private ArrayList filesets = new ArrayList();
boolean verbose = false;
File destDir;
private String format = "png";
@@ -175,6 +175,7 @@
/**
* Adds a set of files.
+ * @param set
*/
public void addFileset(FileSet set)
{
@@ -183,13 +184,12 @@
+ @Override
public void execute()
{
if (verbose) log("Building SVG images");
- for (Iterator it = filesets.iterator(); it.hasNext();)
- {
- FileSet fs = (FileSet)it.next();
+ for (FileSet fs : filesets) {
FileScanner scanner = fs.getDirectoryScanner(getProject());
String[] files = scanner.getIncludedFiles();
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/beans/ProportionalLayoutPanel.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/beans/ProportionalLayoutPanel.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/beans/ProportionalLayoutPanel.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/beans/ProportionalLayoutPanel.java 2022-02-26 23:40:50.000000000 +0000
@@ -37,7 +37,6 @@
package com.kitfox.svg.app.beans;
import java.awt.*;
-import java.util.*;
import javax.swing.*;
/**
@@ -63,6 +62,7 @@
initComponents();
}
+ @Override
public void addNotify()
{
super.addNotify();
@@ -86,10 +86,12 @@
addComponentListener(new java.awt.event.ComponentAdapter()
{
+ @Override
public void componentResized(java.awt.event.ComponentEvent evt)
{
formComponentResized(evt);
}
+ @Override
public void componentShown(java.awt.event.ComponentEvent evt)
{
formComponentShown(evt);
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/beans/SVGIcon.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/beans/SVGIcon.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/beans/SVGIcon.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/beans/SVGIcon.java 2022-02-26 23:40:50.000000000 +0000
@@ -106,6 +106,7 @@
changes.removePropertyChangeListener(p);
}
+ @Override
public Image getImage()
{
BufferedImage bi = new BufferedImage(getIconWidth(), getIconHeight(), BufferedImage.TYPE_INT_ARGB);
@@ -116,7 +117,7 @@
/**
* @return height of this icon
*/
- public int getIconHeight()
+ public int getIconHeightIgnoreAutosize()
{
if (preferredSize != null &&
(autosize == AUTOSIZE_VERT || autosize == AUTOSIZE_STRETCH
@@ -136,7 +137,8 @@
/**
* @return width of this icon
*/
- public int getIconWidth()
+
+ public int getIconWidthIgnoreAutosize()
{
if (preferredSize != null &&
(autosize == AUTOSIZE_HORIZ || autosize == AUTOSIZE_STRETCH
@@ -153,6 +155,49 @@
return (int)diagram.getWidth();
}
+ private boolean isAutoSizeBestFitUseFixedHeight(final int iconWidthIgnoreAutosize, final int iconHeightIgnoreAutosize,
+ final SVGDiagram diagram)
+ {
+ return iconHeightIgnoreAutosize/diagram.getHeight() < iconWidthIgnoreAutosize/diagram.getWidth();
+ }
+
+ @Override
+ public int getIconWidth()
+ {
+ final int iconWidthIgnoreAutosize = getIconWidthIgnoreAutosize();
+ final int iconHeightIgnoreAutosize = getIconHeightIgnoreAutosize();
+ final SVGDiagram diagram = svgUniverse.getDiagram(svgURI);
+ if (preferredSize != null && (autosize == AUTOSIZE_VERT ||
+ (autosize == AUTOSIZE_BESTFIT && isAutoSizeBestFitUseFixedHeight(iconWidthIgnoreAutosize, iconHeightIgnoreAutosize, diagram))))
+ {
+ final double aspectRatio = diagram.getHeight()/diagram.getWidth();
+ return (int)(iconHeightIgnoreAutosize / aspectRatio);
+ }
+ else
+ {
+ return iconWidthIgnoreAutosize;
+ }
+ }
+
+ @Override
+ public int getIconHeight()
+ {
+ final int iconWidthIgnoreAutosize = getIconWidthIgnoreAutosize();
+ final int iconHeightIgnoreAutosize = getIconHeightIgnoreAutosize();
+ final SVGDiagram diagram = svgUniverse.getDiagram(svgURI);
+ if (preferredSize != null && (autosize == AUTOSIZE_HORIZ ||
+ (autosize == AUTOSIZE_BESTFIT && !isAutoSizeBestFitUseFixedHeight(iconWidthIgnoreAutosize, iconHeightIgnoreAutosize, diagram))))
+ {
+ final double aspectRatio = diagram.getHeight()/diagram.getWidth();
+ return (int)(iconWidthIgnoreAutosize * aspectRatio);
+ }
+ else
+ {
+ return iconHeightIgnoreAutosize;
+ }
+ }
+
+
/**
* Draws the icon to the specified component.
* @param comp - Component to draw icon to. This is ignored by SVGIcon, and can be set to null; only gg is used for drawing the icon
@@ -160,6 +205,7 @@
* @param x - X coordinate to draw icon
* @param y - Y coordinate to draw icon
*/
+ @Override
public void paintIcon(Component comp, Graphics gg, int x, int y)
{
//Copy graphics object so that
@@ -217,8 +263,8 @@
return;
}
- final int width = getIconWidth();
- final int height = getIconHeight();
+ final int width = getIconWidthIgnoreAutosize();
+ final int height = getIconHeightIgnoreAutosize();
// int width = getWidth();
// int height = getHeight();
@@ -378,7 +424,6 @@
/**
* @deprecated
- * @return
*/
public void setScaleToFit(boolean scaleToFit)
{
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/beans/SVGPanel.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/beans/SVGPanel.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/beans/SVGPanel.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/beans/SVGPanel.java 2022-02-26 23:40:50.000000000 +0000
@@ -106,6 +106,7 @@
return (int)diagram.getWidth();
}
+ @Override
public void paintComponent(Graphics gg)
{
super.paintComponent(gg);
@@ -131,7 +132,7 @@
{
try
{
- diagram.render(g);
+ diagram.render(this, g);
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldAliasHint);
}
catch (SVGException e)
@@ -252,7 +253,6 @@
/**
* @deprecated
- * @return
*/
public void setScaleToFit(boolean scaleToFit)
{
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/data/Handler.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/data/Handler.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/data/Handler.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/data/Handler.java 2022-02-26 23:40:50.000000000 +0000
@@ -92,10 +92,12 @@
}
}
+ @Override
public void connect() throws IOException
{
}
+ @Override
public String getHeaderField(String name)
{
if ("content-type".equals(name))
@@ -106,6 +108,7 @@
return super.getHeaderField(name);
}
+ @Override
public InputStream getInputStream() throws IOException
{
return new ByteArrayInputStream(buf);
@@ -117,6 +120,7 @@
// }
}
+ @Override
protected URLConnection openConnection(URL u) throws IOException
{
return new Connection(u);
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/MainFrame.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/MainFrame.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/MainFrame.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/MainFrame.java 2022-02-26 23:40:50.000000000 +0000
@@ -66,6 +66,7 @@
setTitle("SVG Salamander - Application Launcher");
addWindowListener(new java.awt.event.WindowAdapter()
{
+ @Override
public void windowClosing(java.awt.event.WindowEvent evt)
{
exitForm(evt);
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/PlayerDialog.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/PlayerDialog.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/PlayerDialog.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/PlayerDialog.java 2022-02-26 23:40:50.000000000 +0000
@@ -96,6 +96,7 @@
setTitle("Player");
addWindowListener(new java.awt.event.WindowAdapter()
{
+ @Override
public void windowClosed(java.awt.event.WindowEvent evt)
{
formWindowClosed(evt);
@@ -157,6 +158,7 @@
});
text_curTime.addFocusListener(new java.awt.event.FocusAdapter()
{
+ @Override
public void focusLost(java.awt.event.FocusEvent evt)
{
text_curTimeFocusLost(evt);
@@ -194,6 +196,7 @@
});
text_timeStep.addFocusListener(new java.awt.event.FocusAdapter()
{
+ @Override
public void focusLost(java.awt.event.FocusEvent evt)
{
text_timeStepFocusLost(evt);
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/PlayerThread.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/PlayerThread.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/PlayerThread.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/PlayerThread.java 2022-02-26 23:40:50.000000000 +0000
@@ -45,7 +45,7 @@
*/
public class PlayerThread implements Runnable
{
- HashSet listeners = new HashSet();
+ HashSet listeners = new HashSet();
double curTime = 0;
double timeStep = .2;
@@ -129,9 +129,7 @@
private void fireTimeUpdateEvent()
{
- for (Iterator it = listeners.iterator(); it.hasNext();)
- {
- PlayerThreadListener listener = (PlayerThreadListener)it.next();
+ for (PlayerThreadListener listener : listeners) {
listener.updateTime(curTime, timeStep, playState);
}
}
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/SVGPlayer.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/SVGPlayer.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/SVGPlayer.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/SVGPlayer.java 2022-02-26 23:40:50.000000000 +0000
@@ -55,7 +55,6 @@
import java.security.AccessControlException;
import java.util.ArrayList;
import java.util.List;
-import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
@@ -89,6 +88,7 @@
new javax.swing.filechooser.FileFilter() {
final Matcher matchLevelFile = Pattern.compile(".*\\.svg[z]?").matcher("");
+ @Override
public boolean accept(File file)
{
if (file.isDirectory()) return true;
@@ -97,6 +97,7 @@
return matchLevelFile.matches();
}
+ @Override
public String getDescription() { return "SVG file (*.svg, *.svgz)"; }
}
);
@@ -132,6 +133,7 @@
svgDisplayPanel.setBgColor(Color.white);
svgDisplayPanel.addMouseListener(new MouseAdapter()
{
+ @Override
public void mouseClicked(MouseEvent evt)
{
SVGDiagram diagram = svgDisplayPanel.getDiagram();
@@ -140,11 +142,10 @@
System.out.println("Picking at cursor (" + evt.getX() + ", " + evt.getY() + ")");
try
{
- List paths = diagram.pick(new Point2D.Float(evt.getX(), evt.getY()), null);
+ List> paths = diagram.pick(new Point2D.Float(evt.getX(), evt.getY()), null);
for (int i = 0; i < paths.size(); i++)
{
- ArrayList path = (ArrayList)paths.get(i);
- System.out.println(pathToString(path));
+ System.out.println(pathToString(paths.get(i)));
}
}
catch (SVGException ex)
@@ -162,7 +163,7 @@
playerDialog = new PlayerDialog(this);
}
- private String pathToString(List path)
+ private String pathToString(List path)
{
if (path.size() == 0) return "";
@@ -171,7 +172,7 @@
for (int i = 1; i < path.size(); i++)
{
sb.append("/");
- sb.append(((SVGElement)path.get(i)).getId());
+ sb.append(path.get(i).getId());
}
return sb.toString();
}
@@ -258,6 +259,7 @@
setTitle("SVG Player - Salamander Project");
addWindowListener(new java.awt.event.WindowAdapter()
{
+ @Override
public void windowClosing(java.awt.event.WindowEvent evt)
{
exitForm(evt);
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/SVGViewer.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/SVGViewer.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/SVGViewer.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/SVGViewer.java 2022-02-26 23:40:50.000000000 +0000
@@ -53,7 +53,6 @@
import java.net.URLEncoder;
import java.security.AccessControlException;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -85,6 +84,7 @@
new javax.swing.filechooser.FileFilter() {
final Matcher matchLevelFile = Pattern.compile(".*\\.svg[z]?").matcher("");
+ @Override
public boolean accept(File file)
{
if (file.isDirectory()) return true;
@@ -93,6 +93,7 @@
return matchLevelFile.matches();
}
+ @Override
public String getDescription() { return "SVG file (*.svg, *.svgz)"; }
}
);
@@ -208,6 +209,7 @@
setTitle("SVG Viewer - Salamander Project");
addWindowListener(new java.awt.event.WindowAdapter()
{
+ @Override
public void windowClosing(java.awt.event.WindowEvent evt)
{
exitForm(evt);
@@ -218,10 +220,12 @@
panel_svgArea.addMouseListener(new java.awt.event.MouseAdapter()
{
+ @Override
public void mousePressed(java.awt.event.MouseEvent evt)
{
panel_svgAreaMousePressed(evt);
}
+ @Override
public void mouseReleased(java.awt.event.MouseEvent evt)
{
panel_svgAreaMouseReleased(evt);
@@ -326,7 +330,7 @@
private void panel_svgAreaMouseReleased(java.awt.event.MouseEvent evt)//GEN-FIRST:event_panel_svgAreaMouseReleased
{//GEN-HEADEREND:event_panel_svgAreaMouseReleased
SVGDiagram diagram = svgDisplayPanel.getDiagram();
- List pickedElements;
+ List> pickedElements;
try
{
pickedElements = diagram.pick(new Point(evt.getX(), evt.getY()), null);
@@ -338,16 +342,10 @@
}
System.out.println("Pick results:");
- for (Iterator it = pickedElements.iterator(); it.hasNext();)
- {
- ArrayList path = (ArrayList)it.next();
-
+ for (List path : pickedElements) {
System.out.print(" Path: ");
- for (Iterator it2 = path.iterator(); it2.hasNext();)
- {
- SVGElement ele = (SVGElement)it2.next();
-
+ for (SVGElement ele : path) {
System.out.print("" + ele.getId() + "(" + ele.getClass().getName() + ") ");
}
System.out.println();
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/VersionDialog.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/VersionDialog.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/app/VersionDialog.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/app/VersionDialog.java 2022-02-26 23:40:50.000000000 +0000
@@ -39,13 +39,8 @@
import com.kitfox.svg.SVGConst;
import java.net.*;
import java.io.*;
-import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
-import javax.swing.event.*;
-import javax.swing.*;
-import javax.swing.text.html.*;
-
/**
*
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/BufferPainter.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/BufferPainter.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/BufferPainter.java 1970-01-01 00:00:00.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/BufferPainter.java 2022-02-26 23:40:50.000000000 +0000
@@ -0,0 +1,215 @@
+package com.kitfox.svg;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.Rectangle;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Point2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.ImageObserver;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+public class BufferPainter
+{
+ public static final boolean DEBUG_PAINT = false;
+
+ public static class Cache
+ {
+ private final BufferedImage img;
+ private final Rectangle bounds;
+ private final AffineTransform transform;
+
+ public Cache(BufferedImage img, Rectangle bounds, AffineTransform transform)
+ {
+ this.img = img;
+ this.bounds = bounds;
+ this.transform = transform;
+ }
+
+ boolean isCompatible(AffineTransform tx)
+ {
+ return tx.getScaleX() == transform.getScaleX()
+ && tx.getScaleY() == transform.getScaleY()
+ && tx.getShearX() == transform.getShearX()
+ && tx.getShearY() == transform.getShearY();
+ }
+
+ Rectangle getBoundsForTransform(AffineTransform tx)
+ {
+ double dx = tx.getTranslateX() - transform.getTranslateX();
+ double dy = tx.getTranslateY() - transform.getTranslateY();
+ return new Rectangle((int) (bounds.x + dx), (int) (bounds.y + dy),
+ bounds.width, bounds.height);
+ }
+ }
+
+ public static void paintElement(Graphics2D g, RenderableElement element) throws SVGException
+ {
+ if (element.cachedMask != null
+ || (element.filter != null && !element.filter.filterEffects.isEmpty()))
+ {
+ renderElement(g, element);
+ } else
+ {
+ element.doRender(g);
+ }
+ }
+
+ private static float getTransformScale(Point2D.Float origin, Point2D.Float testPoint,
+ AffineTransform transform)
+ {
+ transform.transform(testPoint, testPoint);
+ float dx = testPoint.x - origin.x;
+ float dy = testPoint.y - origin.y;
+ return (float) Math.sqrt(dx * dx + dy * dy);
+ }
+
+ private static void renderElement(Graphics2D g, RenderableElement element) throws SVGException
+ {
+ AffineTransform transform = g.getTransform();
+
+ Graphics2D gg = (Graphics2D) g.create();
+ Rectangle elementBounds = element.getBoundingBox().getBounds();
+ Rectangle transformedBounds = transform.createTransformedShape(elementBounds).getBounds();
+ Rectangle dstBounds = new Rectangle(transformedBounds);
+
+ ImageObserver observer = element.diagram.getCurrentRenderTarget();
+
+ Cache cache = element.getBufferCache();
+ BufferedImage elementImage;
+
+ if (cache == null || observer == null || !cache.isCompatible(transform))
+ {
+ elementImage = renderToBuffer(gg, element, transform, transformedBounds, dstBounds);
+ if (observer != null)
+ {
+ // Only do caching if we are painting to a component.
+ Cache cacheEntry = new Cache(elementImage, new Rectangle(dstBounds), transform);
+ element.setBufferImage(cacheEntry);
+ }
+ } else
+ {
+ elementImage = cache.img;
+ dstBounds.setBounds(cache.getBoundsForTransform(transform));
+ }
+
+ // Reset the transform. We already accounted for it in the buffer image.
+ gg.setTransform(new AffineTransform());
+ gg.drawImage(elementImage, dstBounds.x, dstBounds.y, observer);
+ if (DEBUG_PAINT)
+ {
+ gg.setColor(Color.GREEN);
+ gg.drawRect(dstBounds.x, dstBounds.y, dstBounds.width, dstBounds.height);
+ if (!dstBounds.equals(transformedBounds))
+ {
+ gg.setColor(Color.PINK);
+ gg.drawRect(transformedBounds.x, transformedBounds.y, transformedBounds.width, transformedBounds.height);
+ }
+ }
+ gg.dispose();
+ }
+
+ private static BufferedImage renderToBuffer(Graphics2D gg, RenderableElement element,
+ AffineTransform transform, Rectangle transformedBounds,
+ Rectangle dstBounds) throws SVGException
+ {
+ Point2D.Float origin = new Point2D.Float(0, 0);
+ transform.transform(origin, origin);
+
+ // As filter operations are commonly implemented using convolutions they need to be
+ // aware of any possible scaling to compensate for it in their kernel size.
+ Point2D.Float testPoint = new Point2D.Float(1, 0);
+ float xScale = getTransformScale(origin, testPoint, transform);
+ testPoint.setLocation(0, 1);
+ float yScale = getTransformScale(origin, testPoint, transform);
+
+ List filterOps = element.filter == null
+ ? Collections.emptyList()
+ : element.filter.filterEffects.stream()
+ .flatMap(f -> f.getOperations(dstBounds, xScale, yScale).stream())
+ .filter(Objects::nonNull)
+ .collect(Collectors.toList());
+
+ for (FilterEffects.FilterOp filterOp : filterOps)
+ {
+ int right = Math.max(dstBounds.x + dstBounds.width,
+ filterOp.requiredImageBounds.x + filterOp.requiredImageBounds.width);
+ int bottom = Math.max(dstBounds.y + dstBounds.height,
+ filterOp.requiredImageBounds.y + filterOp.requiredImageBounds.height);
+ dstBounds.x = Math.min(dstBounds.x, filterOp.requiredImageBounds.x);
+ dstBounds.y = Math.min(dstBounds.y, filterOp.requiredImageBounds.y);
+ dstBounds.width = right - dstBounds.x;
+ dstBounds.height = bottom - dstBounds.y;
+ }
+
+
+ BufferedImage elementImage = BufferPainter.paintToBuffer(gg, transform, dstBounds, transformedBounds,
+ element, null, true);
+
+ for (FilterEffects.FilterOp filterOp : filterOps)
+ {
+ elementImage = filterOp.op.filter(elementImage, null);
+ }
+
+ if (element.cachedMask != null)
+ {
+ // Draw the mask image. Implicitly the mask is empty i.e. has a completely black background.
+ // We can't draw the mask directly to the elementImage using the mask composite as
+ // masks may change the mask value a location at any time during mask realization.
+ BufferedImage maskImage = BufferPainter.paintToBuffer(gg, transform, dstBounds, transformedBounds,
+ element.cachedMask, Color.BLACK, false);
+
+ Graphics2D elementGraphics = (Graphics2D) elementImage.getGraphics();
+ elementGraphics.setRenderingHints(gg.getRenderingHints());
+ elementGraphics.setComposite(element.cachedMask.createMaskComposite());
+ elementGraphics.drawImage(maskImage, 0, 0, element.diagram.getCurrentRenderTarget());
+ elementGraphics.dispose();
+ }
+ return elementImage;
+ }
+
+ public static BufferedImage paintToBuffer(Graphics2D g, AffineTransform transform,
+ Rectangle srcBounds, RenderableElement element,
+ Color bgColor) throws SVGException
+ {
+ return paintToBuffer(g, transform, srcBounds, srcBounds, element, bgColor, false);
+ }
+
+ /*
+ * The srcBounds parameter is expected to be pre-transformed by the given transform.
+ */
+ public static BufferedImage paintToBuffer(Graphics2D g, AffineTransform transform,
+ Rectangle dstBounds, Rectangle srcBounds,
+ RenderableElement element,
+ Color bgColor, boolean preMultiplied) throws SVGException
+ {
+ int type = preMultiplied
+ ? BufferedImage.TYPE_INT_ARGB_PRE
+ : BufferedImage.TYPE_INT_ARGB;
+ BufferedImage img = new BufferedImage(dstBounds.width, dstBounds.height, type);
+ Graphics2D imgGraphics = (Graphics2D) img.getGraphics();
+ if (g != null)
+ {
+ imgGraphics.setRenderingHints(g.getRenderingHints());
+ } else if (bgColor != null)
+ {
+ imgGraphics.setColor(bgColor);
+ imgGraphics.fillRect(0, 0, img.getWidth(), img.getHeight());
+ }
+ int xRelative = srcBounds.x - dstBounds.x;
+ int yRelative = srcBounds.y - dstBounds.y;
+ imgGraphics.translate(xRelative, yRelative);
+ imgGraphics.clipRect(0, 0, srcBounds.width, srcBounds.height);
+
+ // Because we blit the image at the transformed location we have to compensate for the
+ // element location.
+ imgGraphics.translate(-srcBounds.x, -srcBounds.y);
+ imgGraphics.transform(transform);
+ element.doRender(imgGraphics);
+ imgGraphics.dispose();
+ return img;
+ }
+}
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Circle.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Circle.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Circle.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Circle.java 2022-02-26 23:40:50.000000000 +0000
@@ -61,11 +61,13 @@
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
}
+ @Override
protected void build() throws SVGException
{
super.build();
@@ -90,18 +92,21 @@
circle.setFrame(cx - r, cy - r, r * 2f, r * 2f);
}
- public void render(Graphics2D g) throws SVGException
+ @Override
+ protected void doRender(Graphics2D g) throws SVGException
{
beginLayer(g);
renderShape(g, circle);
finishLayer(g);
}
+ @Override
public Shape getShape()
{
return shapeToParent(circle);
}
+ @Override
public Rectangle2D getBoundingBox() throws SVGException
{
return boundsToParent(includeStrokeInBounds(circle.getBounds2D()));
@@ -114,6 +119,7 @@
* @return - true if this node has changed state as a result of the time
* update
*/
+ @Override
public boolean updateTime(double curTime) throws SVGException
{
// if (trackManager.getNumTracks() == 0) return false;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/ClipPath.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/ClipPath.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/ClipPath.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/ClipPath.java 2022-02-26 23:40:50.000000000 +0000
@@ -38,7 +38,6 @@
import com.kitfox.svg.xml.StyleAttribute;
import java.awt.Shape;
import java.awt.geom.Area;
-import java.util.Iterator;
/**
* @author Mark McKay
@@ -59,6 +58,7 @@
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
@@ -68,11 +68,13 @@
* Called after the start element but before the end element to indicate
* each child tag that has been processed
*/
+ @Override
public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException
{
super.loaderAddChild(helper, child);
}
+ @Override
protected void build() throws SVGException
{
super.build();
@@ -102,9 +104,8 @@
}
Area clipArea = null;
- for (Iterator it = children.iterator(); it.hasNext();)
- {
- ShapeElement se = (ShapeElement) it.next();
+ for (SVGElement svgElement : children) {
+ ShapeElement se = (ShapeElement) svgElement;
if (clipArea == null)
{
@@ -130,11 +131,12 @@
* Updates all attributes in this diagram associated with a time event. Ie,
* all attributes with track information.
*
- * @param curTime
+ * @param curTime Time at which to evaluate node
* @return - true if this node has changed state as a result of the time
* update
* @throws com.kitfox.svg.SVGException
*/
+ @Override
public boolean updateTime(double curTime) throws SVGException
{
//Get current values for parameters
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/composite/AdobeCompositeContext.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/composite/AdobeCompositeContext.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/composite/AdobeCompositeContext.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/composite/AdobeCompositeContext.java 2022-02-26 23:40:50.000000000 +0000
@@ -52,7 +52,10 @@
float[] rgba_dstIn = new float[4];
float[] rgba_dstOut = new float[4];
- /** Creates a new instance of AdobeCompositeContext */
+ /** Creates a new instance of AdobeCompositeContext
+ * @param compositeType
+ * @param extraAlpha
+ */
public AdobeCompositeContext(int compositeType, float extraAlpha)
{
this.compositeType = compositeType;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/composite/AdobeComposite.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/composite/AdobeComposite.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/composite/AdobeComposite.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/composite/AdobeComposite.java 2022-02-26 23:40:50.000000000 +0000
@@ -55,7 +55,11 @@
final int compositeType;
final float extraAlpha;
- /** Creates a new instance of AdobeComposite */
+ /**
+ * Creates a new instance of AdobeComposite
+ * @param compositeType
+ * @param extraAlpha
+ */
public AdobeComposite(int compositeType, float extraAlpha)
{
this.compositeType = compositeType;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Defs.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Defs.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Defs.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Defs.java 2022-02-26 23:40:50.000000000 +0000
@@ -35,7 +35,7 @@
*/
package com.kitfox.svg;
-import java.util.Iterator;
+import com.kitfox.svg.xml.StyleSheet;
/**
* @author Mark McKay
@@ -53,6 +53,7 @@
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
@@ -62,6 +63,7 @@
* Called after the start element but before the end element to indicate
* each child tag that has been processed
*/
+ @Override
public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException
{
super.loaderAddChild(helper, child);
@@ -69,15 +71,27 @@
// members.add(child);
}
+ @Override
public boolean updateTime(double curTime) throws SVGException
{
boolean stateChange = false;
- for (Iterator it = children.iterator(); it.hasNext();)
- {
- SVGElement ele = (SVGElement) it.next();
+ for (SVGElement ele : children) {
stateChange = stateChange || ele.updateTime(curTime);
}
return super.updateTime(curTime) || stateChange;
}
+
+ public StyleSheet getStyleSheet()
+ {
+ for (int i = 0; i < getNumChildren(); ++i)
+ {
+ SVGElement ele = getChild(i);
+ if (ele instanceof Style)
+ {
+ return ((Style)ele).getStyleSheet();
+ }
+ }
+ return null;
+ }
}
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Desc.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Desc.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Desc.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Desc.java 2022-02-26 23:40:50.000000000 +0000
@@ -54,6 +54,7 @@
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
@@ -62,6 +63,7 @@
/**
* Called during load process to add text scanned within a tag
*/
+ @Override
public void loaderAddText(SVGLoaderHelper helper, String text)
{
this.text.append(text);
@@ -72,6 +74,7 @@
return text.toString();
}
+ @Override
public boolean updateTime(double curTime)
{
return false;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Ellipse.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Ellipse.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Ellipse.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Ellipse.java 2022-02-26 23:40:50.000000000 +0000
@@ -62,11 +62,13 @@
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
}
+ @Override
protected void build() throws SVGException
{
super.build();
@@ -96,18 +98,21 @@
ellipse.setFrame(cx - rx, cy - ry, rx * 2f, ry * 2f);
}
- public void render(Graphics2D g) throws SVGException
+ @Override
+ protected void doRender(Graphics2D g) throws SVGException
{
beginLayer(g);
renderShape(g, ellipse);
finishLayer(g);
}
+ @Override
public Shape getShape()
{
return shapeToParent(ellipse);
}
+ @Override
public Rectangle2D getBoundingBox() throws SVGException
{
return boundsToParent(includeStrokeInBounds(ellipse.getBounds2D()));
@@ -120,6 +125,7 @@
* @return - true if this node has changed state as a result of the time
* update
*/
+ @Override
public boolean updateTime(double curTime) throws SVGException
{
// if (trackManager.getNumTracks() == 0) return false;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/FeDistantLight.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/FeDistantLight.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/FeDistantLight.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/FeDistantLight.java 2022-02-26 23:40:50.000000000 +0000
@@ -55,17 +55,18 @@
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
}
+ @Override
protected void build() throws SVGException
{
super.build();
StyleAttribute sty = new StyleAttribute();
- String strn;
if (getPres(sty.setName("azimuth")))
{
@@ -88,6 +89,7 @@
return elevation;
}
+ @Override
public boolean updateTime(double curTime) throws SVGException
{
// if (trackManager.getNumTracks() == 0) return false;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/FeGaussianBlur.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/FeGaussianBlur.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/FeGaussianBlur.java 1970-01-01 00:00:00.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/FeGaussianBlur.java 2022-02-26 23:40:50.000000000 +0000
@@ -0,0 +1,117 @@
+package com.kitfox.svg;
+
+import com.kitfox.svg.xml.StyleAttribute;
+
+import java.awt.Rectangle;
+import java.awt.image.ConvolveOp;
+import java.awt.image.Kernel;
+import java.util.Arrays;
+import java.util.List;
+
+public class FeGaussianBlur extends FilterEffects
+{
+ public static final String TAG_NAME = "fegaussianblur";
+
+ private float[] stdDeviation;
+ private float xCurrent;
+ private float yCurrent;
+ private ConvolveOp xBlur;
+ private ConvolveOp yBlur;
+
+ @Override
+ public String getTagName()
+ {
+ return TAG_NAME;
+ }
+
+ @Override
+ protected void build() throws SVGException
+ {
+ super.build();
+ StyleAttribute sty = new StyleAttribute();
+
+ stdDeviation = new float[]{0f};
+ if (getPres(sty.setName("stdDeviation")))
+ {
+ stdDeviation = sty.getFloatList();
+ }
+ xBlur = null;
+ yBlur = null;
+ }
+
+ @Override
+ public List getOperations(Rectangle inputBounds, float xScale, float yScale)
+ {
+ float xSigma = xScale * stdDeviation[0];
+ float ySigma = yScale * stdDeviation[Math.min(stdDeviation.length - 1, 1)];
+
+ return Arrays.asList(
+ xSigma > 0
+ ? getGaussianBlurFilter(inputBounds, xSigma, true)
+ : null,
+ ySigma > 0
+ ? getGaussianBlurFilter(inputBounds, ySigma, false)
+ : null
+ );
+ }
+
+ public FilterOp getGaussianBlurFilter(Rectangle inputBounds, float sigma, boolean horizontal)
+ {
+ int multiplier = 2;
+ float radius = 2f * sigma + 1;
+ int size = (int) Math.ceil(radius * multiplier) + 1;
+ if (horizontal && (xBlur == null || xCurrent != sigma)
+ || !horizontal && (yBlur == null || yCurrent != sigma))
+ {
+ if (horizontal)
+ {
+ xCurrent = sigma;
+ } else
+ {
+ yCurrent = sigma;
+ }
+ float[] data = new float[size];
+
+ float radius2 = radius * radius;
+ float twoSigmaSquare = 2.0f * sigma * sigma;
+ float sigmaRoot = (float) Math.sqrt(twoSigmaSquare * Math.PI);
+ float total = 0.0f;
+
+ float middle = size / 2f;
+ for (int i = 0; i < size; i++)
+ {
+ float distance = middle - i;
+ distance *= distance;
+
+ data[i] = distance > radius2
+ ? 0
+ : (float) Math.exp(-distance / twoSigmaSquare) / sigmaRoot;
+ total += data[i];
+ }
+
+ for (int i = 0; i < data.length; i++)
+ {
+ data[i] /= total;
+ }
+
+ if (horizontal)
+ {
+ xBlur = new ConvolveOp(new Kernel(size, 1, data), ConvolveOp.EDGE_NO_OP, null);
+ } else
+ {
+ yBlur = new ConvolveOp(new Kernel(1, size, data), ConvolveOp.EDGE_NO_OP, null);
+ }
+ }
+
+ Rectangle dstBounds = new Rectangle(inputBounds);
+ if (horizontal)
+ {
+ dstBounds.grow(size, 0);
+ } else
+ {
+ dstBounds.grow(0, size);
+ }
+
+ return new FilterOp(horizontal ? xBlur : yBlur, dstBounds);
+ }
+}
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/FeLight.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/FeLight.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/FeLight.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/FeLight.java 2022-02-26 23:40:50.000000000 +0000
@@ -51,6 +51,7 @@
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/FePointLight.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/FePointLight.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/FePointLight.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/FePointLight.java 2022-02-26 23:40:50.000000000 +0000
@@ -56,17 +56,18 @@
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
}
+ @Override
protected void build() throws SVGException
{
super.build();
StyleAttribute sty = new StyleAttribute();
- String strn;
if (getPres(sty.setName("x")))
{
@@ -84,11 +85,13 @@
}
}
+ @Override
public float getX()
{
return x;
}
+ @Override
public float getY()
{
return y;
@@ -99,6 +102,7 @@
return z;
}
+ @Override
public boolean updateTime(double curTime) throws SVGException
{
// if (trackManager.getNumTracks() == 0) return false;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/FeSpotLight.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/FeSpotLight.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/FeSpotLight.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/FeSpotLight.java 2022-02-26 23:40:50.000000000 +0000
@@ -61,17 +61,18 @@
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
}
+ @Override
protected void build() throws SVGException
{
super.build();
StyleAttribute sty = new StyleAttribute();
- String strn;
if (getPres(sty.setName("x")))
{
@@ -107,11 +108,13 @@
}
}
+ @Override
public float getX()
{
return x;
}
+ @Override
public float getY()
{
return y;
@@ -147,6 +150,7 @@
return limitingConeAngle;
}
+ @Override
public boolean updateTime(double curTime) throws SVGException
{
// if (trackManager.getNumTracks() == 0) return false;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/FillElement.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/FillElement.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/FillElement.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/FillElement.java 2022-02-26 23:40:50.000000000 +0000
@@ -58,6 +58,7 @@
* @param bounds - bounding box of shape being rendered
* @param xform - The current transformation that the shape is being
* rendered under.
+ * @return paint object
*/
abstract public Paint getPaint(Rectangle2D bounds, AffineTransform xform);
}
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/FilterEffects.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/FilterEffects.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/FilterEffects.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/FilterEffects.java 2022-02-26 23:40:50.000000000 +0000
@@ -36,14 +36,18 @@
package com.kitfox.svg;
import com.kitfox.svg.xml.StyleAttribute;
+
+import java.awt.Rectangle;
+import java.awt.image.BufferedImageOp;
import java.net.URI;
import java.net.URL;
+import java.util.List;
/**
* @author Mark McKay
* @author Mark McKay
*/
-public class FilterEffects extends SVGElement
+public abstract class FilterEffects extends SVGElement
{
public static final String TAG_NAME = "filtereffects";
@@ -60,7 +64,6 @@
float y = 0f;
float width = 1f;
float height = 1f;
- String result = "defaultFilterName";
URL href = null;
/**
@@ -70,6 +73,7 @@
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
@@ -79,6 +83,7 @@
* Called after the start element but before the end element to indicate
* each child tag that has been processed
*/
+ @Override
public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException
{
super.loaderAddChild(helper, child);
@@ -89,13 +94,14 @@
}
}
+ @Override
protected void build() throws SVGException
{
super.build();
- StyleAttribute sty = new StyleAttribute();
- String strn;
- /*
+ /*StyleAttribute sty = new StyleAttribute();
+ String strn;
+
if (getPres(sty.setName("filterUnits")))
{
strn = sty.getStringValue().toLowerCase();
@@ -132,6 +138,10 @@
*/
}
+ public List getOperations(Rectangle bounds, float xScale, float yScale) {
+ return null;
+ }
+
public float getX()
{
return x;
@@ -152,6 +162,7 @@
return height;
}
+ @Override
public boolean updateTime(double curTime) throws SVGException
{
// if (trackManager.getNumTracks() == 0) return false;
@@ -249,4 +260,14 @@
return stateChange;
}
+
+ public static class FilterOp {
+ public final BufferedImageOp op;
+ public final Rectangle requiredImageBounds;
+
+ public FilterOp(BufferedImageOp op, Rectangle requiredImageBounds) {
+ this.op = op;
+ this.requiredImageBounds = requiredImageBounds;
+ }
+ }
}
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Filter.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Filter.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Filter.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Filter.java 2022-02-26 23:40:50.000000000 +0000
@@ -61,7 +61,7 @@
float height = 1f;
Point2D filterRes = new Point2D.Double();
URL href = null;
- final ArrayList filterEffects = new ArrayList();
+ final ArrayList filterEffects = new ArrayList<>();
/**
* Creates a new instance of FillElement
@@ -70,6 +70,7 @@
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
@@ -79,16 +80,18 @@
* Called after the start element but before the end element to indicate
* each child tag that has been processed
*/
+ @Override
public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException
{
super.loaderAddChild(helper, child);
if (child instanceof FilterEffects)
{
- filterEffects.add(child);
+ filterEffects.add((FilterEffects) child);
}
}
+ @Override
protected void build() throws SVGException
{
super.build();
@@ -174,6 +177,7 @@
return height;
}
+ @Override
public boolean updateTime(double curTime) throws SVGException
{
// if (trackManager.getNumTracks() == 0) return false;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/FontFace.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/FontFace.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/FontFace.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/FontFace.java 2022-02-26 23:40:50.000000000 +0000
@@ -71,11 +71,13 @@
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
}
+ @Override
protected void build() throws SVGException
{
super.build();
@@ -228,6 +230,7 @@
* @return - true if this node has changed state as a result of the time
* update
*/
+ @Override
public boolean updateTime(double curTime)
{
//Fonts can't change
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Font.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Font.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Font.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Font.java 2022-02-26 23:40:50.000000000 +0000
@@ -58,7 +58,7 @@
int vertAdvY = -1; //Defaults to one 'em'. See font-face
FontFace fontFace = null;
MissingGlyph missingGlyph = null;
- final HashMap glyphs = new HashMap();
+ final HashMap glyphs = new HashMap();
/**
* Creates a new instance of Font
@@ -67,6 +67,7 @@
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
@@ -76,6 +77,7 @@
* Called after the start element but before the end element to indicate
* each child tag that has been processed
*/
+ @Override
public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException
{
super.loaderAddChild(helper, child);
@@ -92,6 +94,7 @@
}
}
+ @Override
public void loaderEndElement(SVGLoaderHelper helper) throws SVGParseException
{
super.loaderEndElement(helper);
@@ -101,6 +104,7 @@
helper.universe.registerFont(this);
}
+ @Override
protected void build() throws SVGException
{
super.build();
@@ -210,6 +214,7 @@
* @return - true if this node has changed state as a result of the time
* update
*/
+ @Override
public boolean updateTime(double curTime) throws SVGException
{
//Fonts can't change
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Glyph.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Glyph.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Glyph.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Glyph.java 2022-02-26 23:40:50.000000000 +0000
@@ -62,11 +62,13 @@
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
}
+ @Override
protected void build() throws SVGException
{
super.build();
@@ -91,6 +93,7 @@
* @return - true if this node has changed state as a result of the time
* update
*/
+ @Override
public boolean updateTime(double curTime) throws SVGException
{
//Fonts can't change
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Gradient.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Gradient.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Gradient.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Gradient.java 2022-02-26 23:40:50.000000000 +0000
@@ -40,6 +40,7 @@
import java.awt.geom.AffineTransform;
import java.net.URI;
import java.util.ArrayList;
+import java.util.Comparator;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -61,7 +62,7 @@
protected int gradientUnits = GU_OBJECT_BOUNDING_BOX;
//Either this gradient contains a list of stops, or it will take it's
// stops from the referenced gradient
- ArrayList stops = new ArrayList();
+ ArrayList stops = new ArrayList();
URI stopRef = null;
protected AffineTransform gradientTransform = null;
@@ -76,6 +77,7 @@
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
@@ -85,6 +87,7 @@
* Called after the start element but before the end element to indicate
* each child tag that has been processed
*/
+ @Override
public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException
{
super.loaderAddChild(helper, child);
@@ -96,6 +99,7 @@
appendStop((Stop) child);
}
+ @Override
protected void build() throws SVGException
{
super.build();
@@ -157,6 +161,41 @@
}
}
+ private void buildStops()
+ {
+ ArrayList stopList = new ArrayList(stops);
+ stopList.sort(new Comparator(){
+ public int compare(Stop o1, Stop o2)
+ {
+ return Float.compare(o1.offset, o2.offset);
+ }
+ });
+
+ //Remove doubles
+ for (int i = stopList.size() - 2; i >= 0; --i)
+ {
+ if (stopList.get(i + 1).offset == stopList.get(i).offset)
+ {
+ stopList.remove(i + 1);
+ }
+ }
+
+
+ stopFractions = new float[stopList.size()];
+ stopColors = new Color[stopList.size()];
+ int idx = 0;
+ for (Stop stop : stopList)
+ {
+ int stopColorVal = stop.color.getRGB();
+ Color stopColor = new Color((stopColorVal >> 16) & 0xff, (stopColorVal >> 8) & 0xff, stopColorVal & 0xff, clamp((int) (stop.opacity * 255), 0, 255));
+
+ stopColors[idx] = stopColor;
+ stopFractions[idx] = stop.offset;
+ idx++;
+ }
+
+ }
+
public float[] getStopFractions()
{
if (stopRef != null)
@@ -170,18 +209,7 @@
return stopFractions;
}
- stopFractions = new float[stops.size()];
- int idx = 0;
- for (Iterator it = stops.iterator(); it.hasNext();)
- {
- Stop stop = (Stop) it.next();
- float val = stop.offset;
- if (idx != 0 && val < stopFractions[idx - 1])
- {
- val = stopFractions[idx - 1];
- }
- stopFractions[idx++] = val;
- }
+ buildStops();
return stopFractions;
}
@@ -199,30 +227,22 @@
return stopColors;
}
- stopColors = new Color[stops.size()];
- int idx = 0;
- for (Iterator it = stops.iterator(); it.hasNext();)
- {
- Stop stop = (Stop) it.next();
- int stopColorVal = stop.color.getRGB();
- Color stopColor = new Color((stopColorVal >> 16) & 0xff, (stopColorVal >> 8) & 0xff, stopColorVal & 0xff, clamp((int) (stop.opacity * 255), 0, 255));
- stopColors[idx++] = stopColor;
- }
+ buildStops();
return stopColors;
}
- public void setStops(Color[] colors, float[] fractions)
- {
- if (colors.length != fractions.length)
- {
- throw new IllegalArgumentException();
- }
-
- this.stopColors = colors;
- this.stopFractions = fractions;
- stopRef = null;
- }
+// public void setStops(Color[] colors, float[] fractions)
+// {
+// if (colors.length != fractions.length)
+// {
+// throw new IllegalArgumentException();
+// }
+//
+// this.stopColors = colors;
+// this.stopFractions = fractions;
+// stopRef = null;
+// }
private int clamp(int val, int min, int max)
{
@@ -254,6 +274,7 @@
* @return - true if this node has changed state as a result of the time
* update
*/
+ @Override
public boolean updateTime(double curTime) throws SVGException
{
// if (trackManager.getNumTracks() == 0) return false;
@@ -261,7 +282,6 @@
//Get current values for parameters
StyleAttribute sty = new StyleAttribute();
- boolean shapeChange = false;
String strn;
@@ -334,9 +354,7 @@
}
//Check stops, if any
- for (Iterator it = stops.iterator(); it.hasNext();)
- {
- Stop stop = (Stop) it.next();
+ for (Stop stop : stops) {
if (stop.updateTime(curTime))
{
stateChange = true;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Group.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Group.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Group.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Group.java 2022-02-26 23:40:50.000000000 +0000
@@ -65,6 +65,7 @@
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
@@ -74,6 +75,7 @@
* Called after the start element but before the end element to indicate
* each child tag that has been processed
*/
+ @Override
public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException
{
super.loaderAddChild(helper, child);
@@ -97,7 +99,8 @@
return true;
}
- void pick(Point2D point, boolean boundingBox, List retVec) throws SVGException
+ @Override
+ protected void doPick(Point2D point, boolean boundingBox, List> retVec) throws SVGException
{
Point2D xPoint = new Point2D.Double(point.getX(), point.getY());
if (xform != null)
@@ -112,9 +115,7 @@
}
- for (Iterator it = children.iterator(); it.hasNext();)
- {
- SVGElement ele = (SVGElement) it.next();
+ for (SVGElement ele : children) {
if (ele instanceof RenderableElement)
{
RenderableElement rendEle = (RenderableElement) ele;
@@ -124,7 +125,8 @@
}
}
- void pick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List retVec) throws SVGException
+ @Override
+ protected void doPick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List> retVec) throws SVGException
{
if (xform != null)
{
@@ -133,9 +135,7 @@
}
- for (Iterator it = children.iterator(); it.hasNext();)
- {
- SVGElement ele = (SVGElement) it.next();
+ for (SVGElement ele : children) {
if (ele instanceof RenderableElement)
{
RenderableElement rendEle = (RenderableElement) ele;
@@ -145,7 +145,8 @@
}
}
- public void render(Graphics2D g) throws SVGException
+ @Override
+ protected void doRender(Graphics2D g) throws SVGException
{
//Don't process if not visible
StyleAttribute styleAttrib = new StyleAttribute();
@@ -168,7 +169,7 @@
beginLayer(g);
- Iterator it = children.iterator();
+ Iterator it = children.iterator();
// try
// {
@@ -184,7 +185,7 @@
Shape clip = g.getClip();
while (it.hasNext())
{
- SVGElement ele = (SVGElement) it.next();
+ SVGElement ele = it.next();
if (ele instanceof RenderableElement)
{
RenderableElement rendEle = (RenderableElement) ele;
@@ -211,6 +212,7 @@
/**
* Retrieves the cached bounding box of this group
*/
+ @Override
public Shape getShape()
{
if (cachedShape == null)
@@ -224,10 +226,7 @@
{
Area retShape = new Area();
- for (Iterator it = children.iterator(); it.hasNext();)
- {
- SVGElement ele = (SVGElement) it.next();
-
+ for (SVGElement ele : children) {
if (ele instanceof ShapeElement)
{
ShapeElement shpEle = (ShapeElement) ele;
@@ -245,6 +244,7 @@
/**
* Retrieves the cached bounding box of this group
*/
+ @Override
public Rectangle2D getBoundingBox() throws SVGException
{
if (boundingBox == null)
@@ -258,16 +258,13 @@
/**
* Recalculates the bounding box by taking the union of the bounding boxes
* of all children. Caches the result.
+ * @throws com.kitfox.svg.SVGException
*/
public void calcBoundingBox() throws SVGException
{
-// Rectangle2D retRect = new Rectangle2D.Float();
Rectangle2D retRect = null;
- for (Iterator it = children.iterator(); it.hasNext();)
- {
- SVGElement ele = (SVGElement) it.next();
-
+ for (SVGElement ele : children) {
if (ele instanceof RenderableElement)
{
RenderableElement rendEle = (RenderableElement) ele;
@@ -303,17 +300,23 @@
boundingBox = boundsToParent(retRect);
}
+ @Override
public boolean updateTime(double curTime) throws SVGException
{
boolean changeState = super.updateTime(curTime);
- Iterator it = children.iterator();
+ Iterator it = children.iterator();
//Distribute message to all members of this group
while (it.hasNext())
{
- SVGElement ele = (SVGElement) it.next();
+ SVGElement ele = it.next();
boolean updateVal = ele.updateTime(curTime);
+ if (updateVal && ele instanceof RenderableElement)
+ {
+ ((RenderableElement) ele).setBufferImage(null);
+ }
+
changeState = changeState || updateVal;
//Update our shape if shape aware children change
@@ -327,6 +330,11 @@
}
}
+ if (changeState)
+ {
+ setBufferImage(null);
+ }
+
return changeState;
}
}
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Hkern.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Hkern.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Hkern.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Hkern.java 2022-02-26 23:40:50.000000000 +0000
@@ -49,11 +49,13 @@
String u2;
int k;
+ @Override
public String getTagName()
{
return TAG_NAME;
}
+ @Override
protected void build() throws SVGException
{
super.build();
@@ -78,6 +80,7 @@
}
}
+ @Override
public boolean updateTime(double curTime) throws SVGException
{
//Fonts can't change
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/ImageSVG.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/ImageSVG.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/ImageSVG.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/ImageSVG.java 2022-02-26 23:40:50.000000000 +0000
@@ -76,11 +76,13 @@
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
}
+ @Override
protected void build() throws SVGException
{
super.build();
@@ -115,7 +117,8 @@
if ("data".equals(src.getScheme()))
{
imageSrc = new URL(null, src.toASCIIString(), new Handler());
- } else
+ }
+ else if (!diagram.getUniverse().isImageDataInlineOnly())
{
try
{
@@ -124,7 +127,6 @@
{
Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
"Could not parse xlink:href " + src, e);
-// e.printStackTrace();
imageSrc = null;
}
}
@@ -134,32 +136,33 @@
throw new SVGException(e);
}
- diagram.getUniverse().registerImage(imageSrc);
-
- //Set widths if not set
- BufferedImage img = diagram.getUniverse().getImage(imageSrc);
- if (img == null)
+ if (imageSrc != null)
{
- xform = new AffineTransform();
- bounds = new Rectangle2D.Float();
- return;
- }
+ diagram.getUniverse().registerImage(imageSrc);
- if (width == 0)
- {
- width = img.getWidth();
- }
- if (height == 0)
- {
- height = img.getHeight();
- }
+ //Set widths if not set
+ BufferedImage img = diagram.getUniverse().getImage(imageSrc);
+ if (img == null)
+ {
+ xform = new AffineTransform();
+ bounds = new Rectangle2D.Float();
+ return;
+ }
+
+ if (width == 0)
+ {
+ width = img.getWidth();
+ }
+ if (height == 0)
+ {
+ height = img.getHeight();
+ }
- //Determine image xform
- xform = new AffineTransform();
-// xform.setToScale(this.width / img.getWidth(), this.height / img.getHeight());
-// xform.translate(this.x, this.y);
- xform.translate(this.x, this.y);
- xform.scale(this.width / img.getWidth(), this.height / img.getHeight());
+ //Determine image xform
+ xform = new AffineTransform();
+ xform.translate(this.x, this.y);
+ xform.scale(this.width / img.getWidth(), this.height / img.getHeight());
+ }
bounds = new Rectangle2D.Float(this.x, this.y, this.width, this.height);
}
@@ -184,7 +187,8 @@
return height;
}
- void pick(Point2D point, boolean boundingBox, List retVec) throws SVGException
+ @Override
+ protected void doPick(Point2D point, boolean boundingBox, List> retVec) throws SVGException
{
if (getBoundingBox().contains(point))
{
@@ -192,7 +196,8 @@
}
}
- void pick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List retVec) throws SVGException
+ @Override
+ protected void doPick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List> retVec) throws SVGException
{
if (ltw.createTransformedShape(getBoundingBox()).intersects(pickArea))
{
@@ -200,7 +205,8 @@
}
}
- public void render(Graphics2D g) throws SVGException
+ @Override
+ protected void doRender(Graphics2D g) throws SVGException
{
StyleAttribute styleAttrib = new StyleAttribute();
if (getStyle(styleAttrib.setName("visibility")))
@@ -250,7 +256,7 @@
AffineTransform curXform = g.getTransform();
g.transform(xform);
- g.drawImage(img, 0, 0, null);
+ g.drawImage(img, 0, 0, diagram.getCurrentRenderTarget());
g.setTransform(curXform);
if (oldComp != null)
@@ -261,6 +267,7 @@
finishLayer(g);
}
+ @Override
public Rectangle2D getBoundingBox()
{
return boundsToParent(bounds);
@@ -273,6 +280,7 @@
* @return - true if this node has changed state as a result of the time
* update
*/
+ @Override
public boolean updateTime(double curTime) throws SVGException
{
// if (trackManager.getNumTracks() == 0) return false;
@@ -328,16 +336,16 @@
{
URI src = sty.getURIValue(getXMLBase());
- URL newVal;
+ URL newVal = null;
if ("data".equals(src.getScheme()))
{
newVal = new URL(null, src.toASCIIString(), new Handler());
- } else
+ } else if (!diagram.getUniverse().isImageDataInlineOnly())
{
newVal = src.toURL();
}
- if (!newVal.equals(imageSrc))
+ if (newVal != null && !newVal.equals(imageSrc))
{
imageSrc = newVal;
shapeChange = true;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/LinearGradient.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/LinearGradient.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/LinearGradient.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/LinearGradient.java 2022-02-26 23:40:50.000000000 +0000
@@ -64,11 +64,13 @@
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
}
+ @Override
protected void build() throws SVGException
{
super.build();
@@ -96,6 +98,7 @@
}
}
+ @Override
public Paint getPaint(Rectangle2D bounds, AffineTransform xform)
{
MultipleGradientPaint.CycleMethod method;
@@ -167,6 +170,7 @@
* @return - true if this node has changed state as a result of the time
* update
*/
+ @Override
public boolean updateTime(double curTime) throws SVGException
{
// if (trackManager.getNumTracks() == 0) return stopChange;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Line.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Line.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Line.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Line.java 2022-02-26 23:40:50.000000000 +0000
@@ -62,11 +62,13 @@
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
}
+ @Override
protected void build() throws SVGException
{
super.build();
@@ -96,18 +98,21 @@
line = new Line2D.Float(x1, y1, x2, y2);
}
- public void render(Graphics2D g) throws SVGException
+ @Override
+ protected void doRender(Graphics2D g) throws SVGException
{
beginLayer(g);
renderShape(g, line);
finishLayer(g);
}
+ @Override
public Shape getShape()
{
return shapeToParent(line);
}
+ @Override
public Rectangle2D getBoundingBox() throws SVGException
{
return boundsToParent(includeStrokeInBounds(line.getBounds2D()));
@@ -120,6 +125,7 @@
* @return - true if this node has changed state as a result of the time
* update
*/
+ @Override
public boolean updateTime(double curTime) throws SVGException
{
// if (trackManager.getNumTracks() == 0) return false;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Marker.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Marker.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Marker.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Marker.java 2022-02-26 23:40:50.000000000 +0000
@@ -60,11 +60,13 @@
float orient = Float.NaN;
boolean markerUnitsStrokeWidth = true; //if set to false 'userSpaceOnUse' is assumed
+ @Override
public String getTagName()
{
return TAG_NAME;
}
+ @Override
protected void build() throws SVGException
{
super.build();
@@ -130,6 +132,7 @@
markerXform.translate(-refX, -refY);
}
+ @Override
protected boolean outsideClip(Graphics2D g) throws SVGException
{
Shape clip = g.getClip();
@@ -143,12 +146,13 @@
}
- public void render(Graphics2D g) throws SVGException
+ @Override
+ protected void doRender(Graphics2D g) throws SVGException
{
AffineTransform oldXform = g.getTransform();
g.transform(markerXform);
- super.render(g);
+ super.doRender(g);
g.setTransform(oldXform);
}
@@ -167,17 +171,19 @@
g.transform(markerXform);
- super.render(g);
+ super.doRender(g);
g.setTransform(cacheXform);
}
+ @Override
public Shape getShape()
{
Shape shape = super.getShape();
return markerXform.createTransformedShape(shape);
}
+ @Override
public Rectangle2D getBoundingBox() throws SVGException
{
Rectangle2D rect = super.getBoundingBox();
@@ -191,6 +197,7 @@
* @return - true if this node has changed state as a result of the time
* update
*/
+ @Override
public boolean updateTime(double curTime) throws SVGException
{
boolean changeState = super.updateTime(curTime);
@@ -228,7 +235,7 @@
public static class MarkerLayout
{
- private ArrayList markerList = new ArrayList();
+ private ArrayList markerList = new ArrayList();
boolean started = false;
public void layout(Shape shape)
@@ -361,7 +368,7 @@
/**
* @return the markerList
*/
- public ArrayList getMarkerList()
+ public ArrayList getMarkerList()
{
return markerList;
}
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Mask.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Mask.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Mask.java 1970-01-01 00:00:00.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Mask.java 2022-02-26 23:40:50.000000000 +0000
@@ -0,0 +1,212 @@
+/*
+ * SVG Salamander
+ * Copyright (c) 2004, Mark McKay
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Mark McKay can be contacted at mark@kitfox.com. Salamander and other
+ * projects can be found at http://www.kitfox.com
+ */
+package com.kitfox.svg;
+
+import java.awt.Color;
+import java.awt.Composite;
+import java.awt.CompositeContext;
+import java.awt.Graphics2D;
+import java.awt.Rectangle;
+import java.awt.RenderingHints;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Area;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorModel;
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+import java.util.List;
+
+/**
+ * Implements the mask element.
+ *
+ * @author Jannis Weis
+ */
+public class Mask extends Group
+{
+ public static final String TAG_NAME = "mask";
+
+ @Override
+ public String getTagName() {
+ return TAG_NAME;
+ }
+
+ @Override
+ public void render(Graphics2D g)
+ {
+ }
+
+ public Composite createMaskComposite()
+ {
+ return new MaskComposite();
+ }
+
+ @Override
+ void pick(Point2D point, boolean boundingBox, List> retVec)
+ {
+ }
+
+ @Override
+ void pick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List> retVec)
+ {
+ }
+
+ public void pickElement(Point2D point, boolean boundingBox,
+ List> retVec, RenderableElement element) throws SVGException
+ {
+ if (boundingBox)
+ {
+ element.doPick(point, true, retVec);
+ } else
+ {
+ Rectangle pickPoint = new Rectangle((int) point.getX(), (int) point.getY(), 1, 1);
+ BufferedImage img = BufferPainter.paintToBuffer(null, new AffineTransform(), pickPoint, this, Color.BLACK);
+ // Only try picking the element if the picked point is visible.
+ if (luminanceToAlpha(img.getRGB(0, 0)) > 0)
+ {
+ element.doPick(point, false, retVec);
+ }
+ }
+ }
+
+ public void pickElement(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox,
+ List> retVec, RenderableElement element) throws SVGException
+ {
+ // If at any point the considered picking area becomes empty we break out early.
+ if (pickArea.isEmpty()) return;
+ if (boundingBox)
+ {
+ element.doPick(pickArea, ltw,true, retVec);
+ } else
+ {
+ // Clip with the element bounds to avoid creating a larger buffer than needed.
+ Area transformedBounds = new Area(ltw.createTransformedShape(element.getBoundingBox()));
+ transformedBounds.intersect(new Area(pickArea));
+ if (transformedBounds.isEmpty()) return;
+
+ Rectangle pickRect = transformedBounds.getBounds();
+ if (pickRect.isEmpty()) return;
+
+ BufferedImage maskArea = BufferPainter.paintToBuffer(null, ltw, pickRect,this, Color.BLACK);
+
+ // Pick if any pixel in the pick area is visible.
+ if (hasVisiblePixel(maskArea))
+ {
+ element.doPick(pickArea, ltw, false, retVec);
+ }
+ }
+ }
+
+ private boolean hasVisiblePixel(BufferedImage img)
+ {
+ Raster raster = img.getRaster();
+ int x = raster.getMinX();
+ int w = raster.getWidth();
+ int y = raster.getMinY();
+ int h = raster.getHeight();
+ int[] srcPix = raster.getPixels(x, y, w, h, (int[]) null);
+ boolean hasVisiblePixel = false;
+ for (int i = 0; i < srcPix.length; i += 4)
+ {
+ int sr = srcPix[i];
+ int sg = srcPix[i + 1];
+ int sb = srcPix[i + 2];
+ if (luminanceToAlpha(sr, sg, sb) > 0)
+ {
+ hasVisiblePixel = true;
+ break;
+ }
+ }
+ return hasVisiblePixel;
+ }
+
+ private static double luminanceToAlpha(int rgb)
+ {
+ return luminanceToAlpha((rgb >> 16) & 0xFF, (rgb >> 8) & 0xFF, rgb & 0xFF);
+ }
+
+ private static double luminanceToAlpha(int r, int g, int b)
+ {
+ // Assuming 'linearRGB' as the 'color-interpolation' value of the mask.
+ return 0.2125 * r + 0.7154 * g + 0.0721 * b;
+ }
+
+ private static class MaskComposite implements Composite, CompositeContext
+ {
+
+ @Override
+ public CompositeContext createContext(ColorModel srcColorModel,
+ ColorModel dstColorModel, RenderingHints hints)
+ {
+ return this;
+ }
+
+ @Override
+ public void dispose()
+ {
+ }
+
+ public void composeRGB(int[] src, int[] dst)
+ {
+ int w = src.length;
+
+ for (int i = 0; i < w; i += 4)
+ {
+ int sr = src[i];
+ int sg = src[i + 1];
+ int sb = src[i + 2];
+ int da = dst[i + 3];
+ double luminance = luminanceToAlpha(sr, sg, sb) / 255d;
+ da *= luminance;
+ dst[i + 3] = Math.min(255, Math.max(0, da));
+ }
+ }
+
+ @Override
+ public void compose(Raster src, Raster dstIn, WritableRaster dstOut) {
+ assert dstIn == dstOut;
+ assert src.getNumBands() == dstIn.getNumBands();
+
+ int x = dstOut.getMinX();
+ int w = dstOut.getWidth();
+ int y = dstOut.getMinY();
+ int h = dstOut.getHeight();
+ int[] srcPix = src.getPixels(x, y, w, h, (int[]) null);
+ int[] dstPix = dstIn.getPixels(x, y, w, h, (int[]) null);
+ composeRGB(srcPix, dstPix);
+ dstOut.setPixels(x, y, w, h, dstPix);
+ }
+ }
+}
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Metadata.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Metadata.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Metadata.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Metadata.java 2022-02-26 23:40:50.000000000 +0000
@@ -52,11 +52,13 @@
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
}
+ @Override
public boolean updateTime(double curTime)
{
return false;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/MissingGlyph.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/MissingGlyph.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/MissingGlyph.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/MissingGlyph.java 2022-02-26 23:40:50.000000000 +0000
@@ -60,10 +60,10 @@
//We may define a path
private Shape path = null;
//Alternately, we may have child graphical elements
- private int horizAdvX = -1; //Inherits font's value if not set
- private int vertOriginX = -1; //Inherits font's value if not set
- private int vertOriginY = -1; //Inherits font's value if not set
- private int vertAdvY = -1; //Inherits font's value if not set
+ private float horizAdvX = -1; //Inherits font's value if not set
+ private float vertOriginX = -1; //Inherits font's value if not set
+ private float vertOriginY = -1; //Inherits font's value if not set
+ private float vertAdvY = -1; //Inherits font's value if not set
/**
* Creates a new instance of Font
@@ -72,6 +72,7 @@
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
@@ -81,11 +82,13 @@
* Called after the start element but before the end element to indicate
* each child tag that has been processed
*/
+ @Override
public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException
{
super.loaderAddChild(helper, child);
}
+ @Override
protected void build() throws SVGException
{
super.build();
@@ -128,22 +131,22 @@
//Read glyph spacing info
if (getPres(sty.setName("horiz-adv-x")))
{
- horizAdvX = sty.getIntValue();
+ horizAdvX = sty.getFloatValue();
}
if (getPres(sty.setName("vert-origin-x")))
{
- vertOriginX = sty.getIntValue();
+ vertOriginX = sty.getFloatValue();
}
if (getPres(sty.setName("vert-origin-y")))
{
- vertOriginY = sty.getIntValue();
+ vertOriginY = sty.getFloatValue();
}
if (getPres(sty.setName("vert-adv-y")))
{
- vertAdvY = sty.getIntValue();
+ vertAdvY = sty.getFloatValue();
}
}
@@ -152,7 +155,8 @@
return path;
}
- public void render(Graphics2D g) throws SVGException
+ @Override
+ protected void doRender(Graphics2D g) throws SVGException
{
//Do not push or pop stack
@@ -161,10 +165,10 @@
renderShape(g, path);
}
- Iterator it = children.iterator();
+ Iterator it = children.iterator();
while (it.hasNext())
{
- SVGElement ele = (SVGElement) it.next();
+ SVGElement ele = it.next();
if (ele instanceof RenderableElement)
{
((RenderableElement) ele).render(g);
@@ -174,7 +178,7 @@
//Do not push or pop stack
}
- public int getHorizAdvX()
+ public float getHorizAdvX()
{
if (horizAdvX == -1)
{
@@ -183,7 +187,7 @@
return horizAdvX;
}
- public int getVertOriginX()
+ public float getVertOriginX()
{
if (vertOriginX == -1)
{
@@ -192,7 +196,7 @@
return vertOriginX;
}
- public int getVertOriginY()
+ public float getVertOriginY()
{
if (vertOriginY == -1)
{
@@ -201,7 +205,7 @@
return vertOriginY;
}
- public int getVertAdvY()
+ public float getVertAdvY()
{
if (vertAdvY == -1)
{
@@ -211,6 +215,7 @@
}
+ @Override
public Shape getShape()
{
if (path != null)
@@ -220,6 +225,7 @@
return null;
}
+ @Override
public Rectangle2D getBoundingBox() throws SVGException
{
if (path != null)
@@ -236,6 +242,7 @@
* @return - true if this node has changed state as a result of the time
* update
*/
+ @Override
public boolean updateTime(double curTime) throws SVGException
{
//Fonts can't change
@@ -253,7 +260,7 @@
/**
* @param horizAdvX the horizAdvX to set
*/
- public void setHorizAdvX(int horizAdvX)
+ public void setHorizAdvX(float horizAdvX)
{
this.horizAdvX = horizAdvX;
}
@@ -261,7 +268,7 @@
/**
* @param vertOriginX the vertOriginX to set
*/
- public void setVertOriginX(int vertOriginX)
+ public void setVertOriginX(float vertOriginX)
{
this.vertOriginX = vertOriginX;
}
@@ -269,7 +276,7 @@
/**
* @param vertOriginY the vertOriginY to set
*/
- public void setVertOriginY(int vertOriginY)
+ public void setVertOriginY(float vertOriginY)
{
this.vertOriginY = vertOriginY;
}
@@ -277,7 +284,7 @@
/**
* @param vertAdvY the vertAdvY to set
*/
- public void setVertAdvY(int vertAdvY)
+ public void setVertAdvY(float vertAdvY)
{
this.vertAdvY = vertAdvY;
}
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/Arc.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/Arc.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/Arc.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/Arc.java 2022-02-26 23:40:50.000000000 +0000
@@ -76,6 +76,7 @@
}
// public void appendPath(ExtendedGeneralPath path, BuildHistory hist)
+ @Override
public void appendPath(GeneralPath path, BuildHistory hist)
{
float offx = isRelative ? hist.lastPoint.x : 0f;
@@ -90,6 +91,7 @@
hist.setLastKnot(x + offx, y + offy);
}
+ @Override
public int getNumKnotsAdded()
{
return 6;
@@ -101,6 +103,8 @@
* indicate if we increase or decrease the angles and the final
* point of the arc.
*
+ * @param path The path that the arc will be appended to.
+ *
* @param rx the x radius of the ellipse
* @param ry the y radius of the ellipse
*
@@ -157,6 +161,18 @@
*
* AffineTransform.getRotateInstance
* (angle, arc.getX()+arc.getWidth()/2, arc.getY()+arc.getHeight()/2);
+ *
+ * @param x0 origin of arc in x
+ * @param y0 origin of arc in y
+ * @param rx radius of arc in x
+ * @param ry radius of arc in y
+ * @param angle number of radians in arc
+ * @param largeArcFlag
+ * @param sweepFlag
+ * @param x ending coordinate of arc in x
+ * @param y ending coordinate of arc in y
+ * @return arc shape
+ *
*/
public static Arc2D computeArc(double x0, double y0,
double rx, double ry,
@@ -256,6 +272,7 @@
return arc;
}
+ @Override
public String toString()
{
return "A " + rx + " " + ry
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/Cubic.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/Cubic.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/Cubic.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/Cubic.java 2022-02-26 23:40:50.000000000 +0000
@@ -56,6 +56,7 @@
public Cubic() {
}
+ @Override
public String toString()
{
return "C " + k1x + " " + k1y
@@ -74,6 +75,7 @@
}
// public void appendPath(ExtendedGeneralPath path, BuildHistory hist)
+ @Override
public void appendPath(GeneralPath path, BuildHistory hist)
{
float offx = isRelative ? hist.lastPoint.x : 0f;
@@ -87,6 +89,7 @@
hist.setLastKnot(k2x + offx, k2y + offy);
}
+ @Override
public int getNumKnotsAdded()
{
return 6;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/CubicSmooth.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/CubicSmooth.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/CubicSmooth.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/CubicSmooth.java 2022-02-26 23:40:50.000000000 +0000
@@ -63,6 +63,7 @@
}
// public void appendPath(ExtendedGeneralPath path, BuildHistory hist)
+ @Override
public void appendPath(GeneralPath path, BuildHistory hist)
{
float offx = isRelative ? hist.lastPoint.x : 0f;
@@ -81,11 +82,13 @@
hist.setLastKnot(k2x + offx, k2y + offy);
}
+ @Override
public int getNumKnotsAdded()
{
return 6;
}
+ @Override
public String toString()
{
return "S " + k2x + " " + k2y
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/Horizontal.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/Horizontal.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/Horizontal.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/Horizontal.java 2022-02-26 23:40:50.000000000 +0000
@@ -51,6 +51,7 @@
public Horizontal() {
}
+ @Override
public String toString()
{
return "H " + x;
@@ -63,6 +64,7 @@
// public void appendPath(ExtendedGeneralPath path, BuildHistory hist)
+ @Override
public void appendPath(GeneralPath path, BuildHistory hist)
{
float offx = isRelative ? hist.lastPoint.x : 0f;
@@ -73,6 +75,7 @@
hist.setLastKnot(x + offx, offy);
}
+ @Override
public int getNumKnotsAdded()
{
return 2;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/LineTo.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/LineTo.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/LineTo.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/LineTo.java 2022-02-26 23:40:50.000000000 +0000
@@ -60,6 +60,7 @@
// public void appendPath(ExtendedGeneralPath path, BuildHistory hist)
+ @Override
public void appendPath(GeneralPath path, BuildHistory hist)
{
float offx = isRelative ? hist.lastPoint.x : 0f;
@@ -70,11 +71,13 @@
hist.setLastKnot(x + offx, y + offy);
}
+ @Override
public int getNumKnotsAdded()
{
return 2;
}
+ @Override
public String toString()
{
return "L " + x + " " + y;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/MoveTo.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/MoveTo.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/MoveTo.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/MoveTo.java 2022-02-26 23:40:50.000000000 +0000
@@ -59,6 +59,7 @@
}
// public void appendPath(ExtendedGeneralPath path, BuildHistory hist)
+ @Override
public void appendPath(GeneralPath path, BuildHistory hist)
{
float offx = isRelative ? hist.lastPoint.x : 0f;
@@ -70,11 +71,13 @@
hist.setLastKnot(x + offx, y + offy);
}
+ @Override
public int getNumKnotsAdded()
{
return 2;
}
+ @Override
public String toString()
{
return "M " + x + " " + y;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/PathParser.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/PathParser.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/PathParser.java 1970-01-01 00:00:00.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/PathParser.java 2022-02-26 23:40:50.000000000 +0000
@@ -0,0 +1,251 @@
+/*
+ * SVG Salamander
+ * Copyright (c) 2004, Mark McKay
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Mark McKay can be contacted at mark@kitfox.com. Salamander and other
+ * projects can be found at http://www.kitfox.com
+ *
+ */
+package com.kitfox.svg.pathcmd;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * A helper for parsing {@link PathCommand}s.
+ *
+ * @author Jannis Weis
+ */
+public class PathParser
+{
+ private final String input;
+ private final int inputLength;
+ private int index;
+ private char currentCommand;
+
+ public PathParser(String input) {
+ this.input = input.trim();
+ this.inputLength = this.input.length();
+ }
+
+ private boolean isCommandChar(char c)
+ {
+ return c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z';
+ }
+
+ private boolean isWhiteSpaceOrSeparator(char c)
+ {
+ return c <= ' ' || c == ',';
+ }
+
+ private char peek()
+ {
+ return input.charAt(index);
+ }
+
+ private void consume()
+ {
+ index++;
+ }
+
+ private boolean hasNext()
+ {
+ return index < inputLength;
+ }
+
+ // This only checks for the rough structure of a number as we need to know
+ // when to separate the next token.
+ // Explicit parsing is done by Float#parseFloat.
+ private boolean isValidNumberChar(char c, NumberCharState state)
+ {
+ boolean valid = '0' <= c && c <= '9';
+ if (valid && state.iteration == 1 && input.charAt(index - 1) == '0')
+ {
+ // Break up combined zeros into multiple numbers.
+ return false;
+ }
+ state.signAllowed = state.signAllowed && !valid;
+ if (state.dotAllowed && !valid)
+ {
+ valid = c == '.';
+ state.dotAllowed = !valid;
+ }
+ if (state.signAllowed && !valid)
+ {
+ valid = c == '+' || c == '-';
+ state.signAllowed = valid;
+ }
+ if (state.exponentAllowed && !valid)
+ {
+ // Possible exponent notation. Needs at least one preceding number
+ valid = c == 'e' || c == 'E';
+ state.exponentAllowed = !valid;
+ state.signAllowed = valid;
+ }
+ state.iteration++;
+ return valid;
+ }
+
+ private void consumeWhiteSpaceOrSeparator() {
+ while (hasNext() && isWhiteSpaceOrSeparator(peek())) {
+ consume();
+ }
+ }
+
+ private float nextFloat()
+ {
+ int start = index;
+ NumberCharState state = new NumberCharState();
+ while (hasNext() && isValidNumberChar(peek(), state)) {
+ consume();
+ }
+ int end = index;
+ consumeWhiteSpaceOrSeparator();
+ String token = input.substring(start, end);
+ try
+ {
+ return Float.parseFloat(token);
+ } catch (NumberFormatException e)
+ {
+ String msg = "Unexpected element while parsing cmd '" + currentCommand
+ + "' encountered token '" + token + "' rest=" + input.substring(start, Math.min(input.length(), start + 10))
+ + " (index=" + index + " in input=" + input + ")";
+ throw new IllegalStateException(msg, e);
+ }
+ }
+
+ public PathCommand[] parsePathCommand()
+ {
+ List commands = new ArrayList<>();
+
+ currentCommand = 'Z';
+ while (hasNext())
+ {
+ char peekChar = peek();
+ if (isCommandChar(peekChar))
+ {
+ consume();
+ currentCommand = peekChar;
+ }
+ consumeWhiteSpaceOrSeparator();
+
+ PathCommand cmd;
+ switch (currentCommand)
+ {
+ case 'M':
+ cmd = new MoveTo(false, nextFloat(), nextFloat());
+ currentCommand = 'L';
+ break;
+ case 'm':
+ cmd = new MoveTo(true, nextFloat(), nextFloat());
+ currentCommand = 'l';
+ break;
+ case 'L':
+ cmd = new LineTo(false, nextFloat(), nextFloat());
+ break;
+ case 'l':
+ cmd = new LineTo(true, nextFloat(), nextFloat());
+ break;
+ case 'H':
+ cmd = new Horizontal(false, nextFloat());
+ break;
+ case 'h':
+ cmd = new Horizontal(true, nextFloat());
+ break;
+ case 'V':
+ cmd = new Vertical(false, nextFloat());
+ break;
+ case 'v':
+ cmd = new Vertical(true, nextFloat());
+ break;
+ case 'A':
+ cmd = new Arc(false, nextFloat(), nextFloat(),
+ nextFloat(),
+ nextFloat() == 1f, nextFloat() == 1f,
+ nextFloat(), nextFloat());
+ break;
+ case 'a':
+ cmd = new Arc(true, nextFloat(), nextFloat(),
+ nextFloat(),
+ nextFloat() == 1f, nextFloat() == 1f,
+ nextFloat(), nextFloat());
+ break;
+ case 'Q':
+ cmd = new Quadratic(false, nextFloat(), nextFloat(),
+ nextFloat(), nextFloat());
+ break;
+ case 'q':
+ cmd = new Quadratic(true, nextFloat(), nextFloat(),
+ nextFloat(), nextFloat());
+ break;
+ case 'T':
+ cmd = new QuadraticSmooth(false, nextFloat(), nextFloat());
+ break;
+ case 't':
+ cmd = new QuadraticSmooth(true, nextFloat(), nextFloat());
+ break;
+ case 'C':
+ cmd = new Cubic(false, nextFloat(), nextFloat(),
+ nextFloat(), nextFloat(),
+ nextFloat(), nextFloat());
+ break;
+ case 'c':
+ cmd = new Cubic(true, nextFloat(), nextFloat(),
+ nextFloat(), nextFloat(),
+ nextFloat(), nextFloat());
+ break;
+ case 'S':
+ cmd = new CubicSmooth(false, nextFloat(), nextFloat(),
+ nextFloat(), nextFloat());
+ break;
+ case 's':
+ cmd = new CubicSmooth(true, nextFloat(), nextFloat(),
+ nextFloat(), nextFloat());
+ break;
+ case 'Z':
+ case 'z':
+ cmd = new Terminal();
+ break;
+ default:
+ throw new RuntimeException("Invalid path element "
+ + currentCommand + "(at index=" + index + " in input=" + input + ")");
+ }
+ commands.add(cmd);
+ }
+ return commands.toArray(new PathCommand[0]);
+ }
+
+ private static class NumberCharState
+ {
+ int iteration = 0;
+ boolean dotAllowed = true;
+ boolean signAllowed = true;
+ boolean exponentAllowed = true;
+ }
+}
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/PathUtil.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/PathUtil.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/PathUtil.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/PathUtil.java 2022-02-26 23:40:50.000000000 +0000
@@ -52,6 +52,9 @@
/**
* Converts a GeneralPath into an SVG representation
+ *
+ * @param path The shape to be encoded
+ * @return A string encoding the path using the SVG path notation
*/
public static String buildPathString(GeneralPath path)
{
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/Quadratic.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/Quadratic.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/Quadratic.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/Quadratic.java 2022-02-26 23:40:50.000000000 +0000
@@ -54,6 +54,7 @@
public Quadratic() {
}
+ @Override
public String toString()
{
return "Q " + kx + " " + ky
@@ -69,6 +70,7 @@
}
// public void appendPath(ExtendedGeneralPath path, BuildHistory hist)
+ @Override
public void appendPath(GeneralPath path, BuildHistory hist)
{
float offx = isRelative ? hist.lastPoint.x : 0f;
@@ -79,6 +81,7 @@
hist.setLastKnot(kx + offx, ky + offy);
}
+ @Override
public int getNumKnotsAdded()
{
return 4;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/QuadraticSmooth.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/QuadraticSmooth.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/QuadraticSmooth.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/QuadraticSmooth.java 2022-02-26 23:40:50.000000000 +0000
@@ -52,6 +52,7 @@
public QuadraticSmooth() {
}
+ @Override
public String toString()
{
return "T " + x + " " + y;
@@ -64,6 +65,7 @@
}
// public void appendPath(ExtendedGeneralPath path, BuildHistory hist)
+ @Override
public void appendPath(GeneralPath path, BuildHistory hist)
{
float offx = isRelative ? hist.lastPoint.x : 0f;
@@ -82,6 +84,7 @@
hist.setLastKnot(kx, ky);
}
+ @Override
public int getNumKnotsAdded()
{
return 4;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/Terminal.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/Terminal.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/Terminal.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/Terminal.java 2022-02-26 23:40:50.000000000 +0000
@@ -51,6 +51,7 @@
public Terminal() {
}
+ @Override
public String toString()
{
return "Z";
@@ -58,6 +59,7 @@
// public void appendPath(ExtendedGeneralPath path, BuildHistory hist)
+ @Override
public void appendPath(GeneralPath path, BuildHistory hist)
{
path.closePath();
@@ -65,6 +67,7 @@
hist.setLastKnot(hist.startPoint.x, hist.startPoint.y);
}
+ @Override
public int getNumKnotsAdded()
{
return 0;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/Vertical.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/Vertical.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/pathcmd/Vertical.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/pathcmd/Vertical.java 2022-02-26 23:40:50.000000000 +0000
@@ -51,6 +51,7 @@
public Vertical() {
}
+ @Override
public String toString()
{
return "V " + y;
@@ -62,6 +63,7 @@
}
// public void appendPath(ExtendedGeneralPath path, BuildHistory hist)
+ @Override
public void appendPath(GeneralPath path, BuildHistory hist)
{
float offx = hist.lastPoint.x;
@@ -72,6 +74,7 @@
hist.setLastKnot(offx, y + offy);
}
+ @Override
public int getNumKnotsAdded()
{
return 2;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Path.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Path.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Path.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Path.java 2022-02-26 23:40:50.000000000 +0000
@@ -62,11 +62,13 @@
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
}
+ @Override
protected void build() throws SVGException
{
super.build();
@@ -85,18 +87,21 @@
path = buildPath(d, fillRule);
}
- public void render(Graphics2D g) throws SVGException
+ @Override
+ protected void doRender(Graphics2D g) throws SVGException
{
beginLayer(g);
renderShape(g, path);
finishLayer(g);
}
+ @Override
public Shape getShape()
{
return shapeToParent(path);
}
+ @Override
public Rectangle2D getBoundingBox() throws SVGException
{
return boundsToParent(includeStrokeInBounds(path.getBounds2D()));
@@ -109,6 +114,7 @@
* @return - true if this node has changed state as a result of the time
* update
*/
+ @Override
public boolean updateTime(double curTime) throws SVGException
{
// if (trackManager.getNumTracks() == 0) return false;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/PatternSVG.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/PatternSVG.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/PatternSVG.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/PatternSVG.java 2022-02-26 23:40:50.000000000 +0000
@@ -46,7 +46,6 @@
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.net.URI;
-import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -76,6 +75,7 @@
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
@@ -85,11 +85,13 @@
* Called after the start element but before the end element to indicate
* each child tag that has been processed
*/
+ @Override
public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException
{
super.loaderAddChild(helper, child);
}
+ @Override
protected void build() throws SVGException
{
super.build();
@@ -226,9 +228,7 @@
g.setClip(0, 0, tileWidth, tileHeight);
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- for (Iterator it = children.iterator(); it.hasNext();)
- {
- SVGElement ele = (SVGElement) it.next();
+ for (SVGElement ele : children) {
if (ele instanceof RenderableElement)
{
AffineTransform xform = new AffineTransform();
@@ -263,6 +263,7 @@
}
}
+ @Override
public Paint getPaint(Rectangle2D bounds, AffineTransform xform)
{
return texPaint;
@@ -275,6 +276,7 @@
* @return - true if this node has changed state as a result of the time
* update
*/
+ @Override
public boolean updateTime(double curTime) throws SVGException
{
//Patterns don't change state
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Polygon.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Polygon.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Polygon.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Polygon.java 2022-02-26 23:40:50.000000000 +0000
@@ -61,11 +61,13 @@
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
}
+ @Override
protected void build() throws SVGException
{
super.build();
@@ -96,18 +98,21 @@
path.closePath();
}
- public void render(Graphics2D g) throws SVGException
+ @Override
+ protected void doRender(Graphics2D g) throws SVGException
{
beginLayer(g);
renderShape(g, path);
finishLayer(g);
}
+ @Override
public Shape getShape()
{
return shapeToParent(path);
}
+ @Override
public Rectangle2D getBoundingBox() throws SVGException
{
return boundsToParent(includeStrokeInBounds(path.getBounds2D()));
@@ -120,6 +125,7 @@
* @return - true if this node has changed state as a result of the time
* update
*/
+ @Override
public boolean updateTime(double curTime) throws SVGException
{
// if (trackManager.getNumTracks() == 0) return false;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Polyline.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Polyline.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Polyline.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Polyline.java 2022-02-26 23:40:50.000000000 +0000
@@ -61,11 +61,13 @@
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
}
+ @Override
public void build() throws SVGException
{
super.build();
@@ -95,18 +97,21 @@
}
}
- public void render(Graphics2D g) throws SVGException
+ @Override
+ protected void doRender(Graphics2D g) throws SVGException
{
beginLayer(g);
renderShape(g, path);
finishLayer(g);
}
+ @Override
public Shape getShape()
{
return shapeToParent(path);
}
+ @Override
public Rectangle2D getBoundingBox() throws SVGException
{
return boundsToParent(includeStrokeInBounds(path.getBounds2D()));
@@ -119,6 +124,7 @@
* @return - true if this node has changed state as a result of the time
* update
*/
+ @Override
public boolean updateTime(double curTime) throws SVGException
{
// if (trackManager.getNumTracks() == 0) return false;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/RadialGradient.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/RadialGradient.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/RadialGradient.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/RadialGradient.java 2022-02-26 23:40:50.000000000 +0000
@@ -36,6 +36,7 @@
package com.kitfox.svg;
import com.kitfox.svg.xml.StyleAttribute;
+import java.awt.Color;
import java.awt.MultipleGradientPaint;
import java.awt.Paint;
import java.awt.RadialGradientPaint;
@@ -65,11 +66,13 @@
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
}
+ @Override
protected void build() throws SVGException
{
super.build();
@@ -105,6 +108,7 @@
}
}
+ @Override
public Paint getPaint(Rectangle2D bounds, AffineTransform xform)
{
MultipleGradientPaint.CycleMethod method;
@@ -125,14 +129,22 @@
Paint paint;
Point2D.Float pt1 = new Point2D.Float(cx, cy);
Point2D.Float pt2 = hasFocus ? new Point2D.Float(fx, fy) : pt1;
+ float[] stopFractions = getStopFractions();
+ Color[] stopColors = getStopColors();
+
+ //Verify that the stop fractions are valid
+ {
+ //for (int i = 0; i <
+ }
+
if (gradientUnits == GU_USER_SPACE_ON_USE)
{
paint = new RadialGradientPaint(
pt1,
r,
pt2,
- getStopFractions(),
- getStopColors(),
+ stopFractions,
+ stopColors,
method,
MultipleGradientPaint.ColorSpaceType.SRGB,
gradientTransform);
@@ -148,8 +160,8 @@
pt1,
r,
pt2,
- getStopFractions(),
- getStopColors(),
+ stopFractions,
+ stopColors,
method,
MultipleGradientPaint.ColorSpaceType.SRGB,
viewXform);
@@ -165,6 +177,7 @@
* @return - true if this node has changed state as a result of the time
* update
*/
+ @Override
public boolean updateTime(double curTime) throws SVGException
{
// if (trackManager.getNumTracks() == 0) return false;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Rect.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Rect.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Rect.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Rect.java 2022-02-26 23:40:50.000000000 +0000
@@ -68,6 +68,7 @@
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
@@ -131,6 +132,7 @@
// setBounds(this.x, this.y, this.width, this.height);
}
*/
+ @Override
protected void build() throws SVGException
{
super.build();
@@ -199,18 +201,21 @@
}
}
- public void render(Graphics2D g) throws SVGException
+ @Override
+ protected void doRender(Graphics2D g) throws SVGException
{
beginLayer(g);
renderShape(g, rect);
finishLayer(g);
}
+ @Override
public Shape getShape()
{
return shapeToParent(rect);
}
+ @Override
public Rectangle2D getBoundingBox() throws SVGException
{
return boundsToParent(includeStrokeInBounds(rect.getBounds2D()));
@@ -223,6 +228,7 @@
* @return - true if this node has changed state as a result of the time
* update
*/
+ @Override
public boolean updateTime(double curTime) throws SVGException
{
// if (trackManager.getNumTracks() == 0) return false;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/RenderableElement.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/RenderableElement.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/RenderableElement.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/RenderableElement.java 2022-02-26 23:40:50.000000000 +0000
@@ -3,16 +3,16 @@
* Copyright (c) 2004, Mark McKay
* All rights reserved.
*
- * Redistribution and use in source and binary forms, with or
+ * Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
- * - Redistributions of source code must retain the above
+ * - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
+ * disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
@@ -26,8 +26,8 @@
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
* Mark McKay can be contacted at mark@kitfox.com. Salamander and other
* projects can be found at http://www.kitfox.com
*
@@ -54,12 +54,16 @@
abstract public class RenderableElement extends TransformableElement
{
AffineTransform cachedXform = null;
-
+
+ Mask cachedMask;
+ Filter filter;
Shape cachedClip = null;
public static final int VECTOR_EFFECT_NONE = 0;
public static final int VECTOR_EFFECT_NON_SCALING_STROKE = 1;
int vectorEffect;
+ private BufferPainter.Cache bufferCache;
+
/**
* Creates a new instance of BoundedElement
*/
@@ -72,6 +76,17 @@
super(id, parent);
}
+ BufferPainter.Cache getBufferCache()
+ {
+ return bufferCache;
+ }
+
+ void setBufferImage(BufferPainter.Cache bufferCache)
+ {
+ this.bufferCache = bufferCache;
+ }
+
+ @Override
protected void build() throws SVGException
{
super.build();
@@ -91,13 +106,69 @@
{
vectorEffect = VECTOR_EFFECT_NONE;
}
+
+ cachedMask = getMask(sty);
+ filter = getFilter(sty);
}
- abstract public void render(Graphics2D g) throws SVGException;
+ public void render(Graphics2D g) throws SVGException
+ {
+ BufferPainter.paintElement(g, this);
+ }
+
+ private Mask getMask(StyleAttribute styleAttrib) throws SVGException
+ {
+ if (getStyle(styleAttrib.setName("mask"), false)
+ && !"none".equals(styleAttrib.getStringValue())) {
+ URI uri = styleAttrib.getURIValue(getXMLBase());
+ if (uri == null) {
+ return null;
+ }
+ return (Mask) diagram.getUniverse().getElement(uri);
+ }
+ return null;
+ }
- abstract void pick(Point2D point, boolean boundingBox, List retVec) throws SVGException;
+ private Filter getFilter(StyleAttribute styleAttrib) throws SVGException
+ {
+ if (getStyle(styleAttrib.setName("filter"), false)
+ && !"none".equals(styleAttrib.getStringValue())) {
+ URI uri = styleAttrib.getURIValue(getXMLBase());
+ if (uri == null) {
+ return null;
+ }
+ return (Filter) diagram.getUniverse().getElement(uri);
+ }
+ return null;
+ }
+
+ abstract protected void doRender(Graphics2D g) throws SVGException;
+
+ void pick(Point2D point, boolean boundingBox, List> retVec) throws SVGException
+ {
+ if (cachedMask != null)
+ {
+ cachedMask.pickElement(point, boundingBox, retVec, this);
+ } else
+ {
+ doPick(point, boundingBox, retVec);
+ }
+ }
+
+ protected abstract void doPick(Point2D point, boolean boundingBox, List> retVec) throws SVGException;
+
+ void pick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List> retVec) throws SVGException
+ {
+ if (cachedMask != null)
+ {
+ cachedMask.pickElement(pickArea, ltw, boundingBox, retVec, this);
+ } else
+ {
+ doPick(pickArea, ltw, boundingBox, retVec);
+ }
+ }
- abstract void pick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List retVec) throws SVGException;
+ protected abstract void doPick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List> retVec) throws SVGException;
abstract public Rectangle2D getBoundingBox() throws SVGException;
/*
@@ -110,6 +181,9 @@
/**
* Pushes transform stack, transforms to local coordinates and sets up
* clipping mask.
+ *
+ * @param g Graphics context
+ * @throws com.kitfox.svg.SVGException
*/
protected void beginLayer(Graphics2D g) throws SVGException
{
@@ -164,6 +238,7 @@
/**
* Restores transform and clipping values to the way they were before this
* layer was drawn.
+ * @param g
*/
protected void finishLayer(Graphics2D g)
{
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/ShapeElement.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/ShapeElement.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/ShapeElement.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/ShapeElement.java 2022-02-26 23:40:50.000000000 +0000
@@ -75,7 +75,8 @@
public ShapeElement() {
}
- abstract public void render(java.awt.Graphics2D g) throws SVGException;
+ @Override
+ abstract protected void doRender(java.awt.Graphics2D g) throws SVGException;
/*
protected void setStrokeWidthScalar(float strokeWidthScalar)
@@ -84,7 +85,8 @@
}
*/
- void pick(Point2D point, boolean boundingBox, List retVec) throws SVGException
+ @Override
+ protected void doPick(Point2D point, boolean boundingBox, List> retVec) throws SVGException
{
// StyleAttribute styleAttrib = new StyleAttribute();
// if (getStyle(styleAttrib.setName("fill")) && getShape().contains(point))
@@ -94,9 +96,10 @@
}
}
- void pick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List retVec) throws SVGException
+ @Override
+ protected void doPick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List> retVec) throws SVGException
{
- StyleAttribute styleAttrib = new StyleAttribute();
+// StyleAttribute styleAttrib = new StyleAttribute();
// if (getStyle(styleAttrib.setName("fill")) && getShape().contains(point))
if (ltw.createTransformedShape((boundingBox ? getBoundingBox() : getShape())).intersects(pickArea))
{
@@ -393,10 +396,10 @@
MarkerLayout layout = new MarkerLayout();
layout.layout(shape);
- ArrayList list = layout.getMarkerList();
+ ArrayList list = layout.getMarkerList();
for (int i = 0; i < list.size(); ++i)
{
- MarkerPos pos = (MarkerPos)list.get(i);
+ MarkerPos pos = list.get(i);
switch (pos.type)
{
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Stop.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Stop.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Stop.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Stop.java 2022-02-26 23:40:50.000000000 +0000
@@ -57,11 +57,13 @@
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
}
+ @Override
protected void build() throws SVGException
{
super.build();
@@ -104,6 +106,7 @@
* @return - true if this node has changed state as a result of the time
* update
*/
+ @Override
public boolean updateTime(double curTime) throws SVGException
{
// if (trackManager.getNumTracks() == 0) return false;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Style.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Style.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Style.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Style.java 2022-02-26 23:40:50.000000000 +0000
@@ -61,6 +61,7 @@
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
@@ -69,6 +70,7 @@
/**
* Called during load process to add text scanned within a tag
*/
+ @Override
public void loaderAddText(SVGLoaderHelper helper, String text)
{
this.text.append(text);
@@ -77,6 +79,7 @@
styleSheet = null;
}
+ @Override
protected void build() throws SVGException
{
super.build();
@@ -89,6 +92,7 @@
}
}
+ @Override
public boolean updateTime(double curTime) throws SVGException
{
//Style sheet doesn't change
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/SVGDiagram.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/SVGDiagram.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/SVGDiagram.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/SVGDiagram.java 2022-02-26 23:40:50.000000000 +0000
@@ -3,16 +3,16 @@
* Copyright (c) 2004, Mark McKay
* All rights reserved.
*
- * Redistribution and use in source and binary forms, with or
+ * Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
- * - Redistributions of source code must retain the above
+ * - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
+ * disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
@@ -26,8 +26,8 @@
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
* Mark McKay can be contacted at mark@kitfox.com. Salamander and other
* projects can be found at http://www.kitfox.com
*
@@ -36,6 +36,7 @@
package com.kitfox.svg;
+import javax.swing.JComponent;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.geom.AffineTransform;
@@ -59,15 +60,16 @@
public class SVGDiagram implements Serializable
{
public static final long serialVersionUID = 0;
-
+
//Indexes elements within this SVG diagram
- final HashMap idMap = new HashMap();
+ final HashMap idMap = new HashMap();
SVGRoot root;
final SVGUniverse universe;
+ private JComponent renderTarget;
/**
- * This is used by the SVGRoot to determine the width of the
+ * This is used by the SVGRoot to determine the width of the
*/
private Rectangle deviceViewport = new Rectangle(100, 100);
@@ -89,7 +91,11 @@
*/
final URI xmlBase;
- /** Creates a new instance of SVGDiagram */
+ /**
+ * Creates a new instance of SVGDiagram
+ * @param xmlBase
+ * @param universe
+ */
public SVGDiagram(URI xmlBase, SVGUniverse universe)
{
this.universe = universe;
@@ -97,55 +103,72 @@
this.xmlBase = xmlBase;
}
+ JComponent getCurrentRenderTarget()
+ {
+ return renderTarget;
+ }
+
+ public void render(JComponent c, Graphics2D g) throws SVGException
+ {
+ renderTarget = c;
+ root.renderToViewport(g);
+ renderTarget = null;
+ }
+
/**
* Draws this diagram to the passed graphics context
+ * @param g
+ * @throws com.kitfox.svg.SVGException
*/
public void render(Graphics2D g) throws SVGException
{
- root.renderToViewport(g);
+ render(null, g);
}
-
+
/**
* Searches thorough the scene graph for all RenderableElements that have
* shapes that contain the passed point.
- *
+ *
* For every shape which contains the pick point, a List containing the
* path to the node is added to the return list. That is, the result of
* SVGElement.getPath() is added for each entry.
*
+ * @param point
+ * @param retVec
* @return the passed in list
+ * @throws com.kitfox.svg.SVGException
*/
- public List pick(Point2D point, List retVec) throws SVGException
+ public List> pick(Point2D point, List> retVec) throws SVGException
{
return pick(point, false, retVec);
}
-
- public List pick(Point2D point, boolean boundingBox, List retVec) throws SVGException
+
+ public List> pick(Point2D point, boolean boundingBox, List> retVec) throws SVGException
{
if (retVec == null)
{
- retVec = new ArrayList();
+ retVec = new ArrayList>();
}
-
+
root.pick(point, boundingBox, retVec);
-
+
return retVec;
}
- public List pick(Rectangle2D pickArea, List retVec) throws SVGException
+ public List> pick(Rectangle2D pickArea, List> retVec) throws SVGException
{
return pick(pickArea, false, retVec);
}
-
- public List pick(Rectangle2D pickArea, boolean boundingBox, List retVec) throws SVGException
+
+ public List> pick(Rectangle2D pickArea, boolean boundingBox, List> retVec) throws SVGException
{
if (retVec == null)
{
- retVec = new ArrayList();
+ retVec = new ArrayList>();
}
-
+
root.pick(pickArea, new AffineTransform(), boundingBox, retVec);
-
+
return retVec;
}
@@ -169,15 +192,17 @@
if (root == null) return 0;
return root.getDeviceWidth();
}
-
+
public float getHeight()
{
if (root == null) return 0;
return root.getDeviceHeight();
}
-
+
/**
* Returns the viewing rectangle of this diagram in device coordinates.
+ * @param rect
+ * @return
*/
public Rectangle2D getViewRect(Rectangle2D rect)
{
@@ -223,6 +248,8 @@
/**
* Updates all attributes in this diagram associated with a time event.
* Ie, all attributes with track information.
+ * @param curTime
+ * @throws com.kitfox.svg.SVGException
*/
public void updateTime(double curTime) throws SVGException
{
@@ -239,6 +266,7 @@
* Sets the dimensions of the device being rendered into. This is used by
* SVGRoot when its x, y, width or height parameters are specified as
* percentages.
+ * @param deviceViewport
*/
public void setDeviceViewport(Rectangle deviceViewport)
{
@@ -250,7 +278,7 @@
root.build();
} catch (SVGException ex)
{
- Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
"Could not build document", ex);
}
}
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/SVGDisplayPanel.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/SVGDisplayPanel.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/SVGDisplayPanel.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/SVGDisplayPanel.java 2022-02-26 23:40:50.000000000 +0000
@@ -105,6 +105,8 @@
/**
* Update this image to reflect the passed time
+ * @param curTime
+ * @throws com.kitfox.svg.SVGException
*/
public void updateTime(double curTime) throws SVGException
{
@@ -113,6 +115,7 @@
diagram.updateTime(curTime);
}
+ @Override
public void paintComponent(Graphics gg)
{
Graphics2D g = (Graphics2D)gg;
@@ -153,6 +156,7 @@
addComponentListener(new java.awt.event.ComponentAdapter()
{
+ @Override
public void componentResized(java.awt.event.ComponentEvent evt)
{
formComponentResized(evt);
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/SVGElementException.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/SVGElementException.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/SVGElementException.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/SVGElementException.java 2022-02-26 23:40:50.000000000 +0000
@@ -48,6 +48,7 @@
/**
* Creates a new instance of SVGException without detail message.
+ * @param element
*/
public SVGElementException(SVGElement element)
{
@@ -57,6 +58,7 @@
/**
* Constructs an instance of SVGException with the specified detail message.
+ * @param element
* @param msg the detail message.
*/
public SVGElementException(SVGElement element, String msg)
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/SVGElement.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/SVGElement.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/SVGElement.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/SVGElement.java 2022-02-26 23:40:50.000000000 +0000
@@ -38,37 +38,27 @@
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.pathcmd.PathParser;
import com.kitfox.svg.xml.StyleAttribute;
import com.kitfox.svg.xml.StyleSheet;
import com.kitfox.svg.xml.XMLParseUtil;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
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;
/**
@@ -81,7 +71,7 @@
public static final long serialVersionUID = 0;
public static final String SVG_NS = "http://www.w3.org/2000/svg";
protected SVGElement parent = null;
- protected final ArrayList children = new ArrayList();
+ protected final ArrayList children = new ArrayList();
protected String id = null;
/**
* CSS class. Used for applying style sheet information.
@@ -90,28 +80,12 @@
/**
* Styles defined for this elemnt via the style attribute.
*/
- protected final HashMap inlineStyles = new HashMap();
+ protected final HashMap inlineStyles = new HashMap();
/**
* Presentation attributes set for this element. Ie, any attribute other
* than the style attribute.
*/
- protected final HashMap presAttribs = new HashMap();
- /**
- * A list of presentation attributes to not include in the presentation
- * attribute set.
- */
- protected static final Set ignorePresAttrib;
-
- static
- {
- HashSet set = new HashSet();
-// set.add("id");
-// set.add("class");
-// set.add("style");
-// set.add("xml:base");
-
- ignorePresAttrib = Collections.unmodifiableSet(set);
- }
+ protected final HashMap presAttribs = new HashMap();
/**
* This element may override the URI we resolve against with an xml:base
* attribute. If so, a copy is placed here. Otherwise, we defer to our
@@ -159,15 +133,16 @@
{
this.parent = parent;
}
-
+
/**
+ * @param retVec
* @return an ordered list of nodes from the root of the tree to this node
*/
- public List getPath(List retVec)
+ public List getPath(List retVec)
{
if (retVec == null)
{
- retVec = new ArrayList();
+ retVec = new ArrayList();
}
if (parent != null)
@@ -185,11 +160,11 @@
*
* @return The list containing the children of this group
*/
- public List getChildren(List retVec)
+ public List getChildren(List retVec)
{
if (retVec == null)
{
- retVec = new ArrayList();
+ retVec = new ArrayList();
}
retVec.addAll(children);
@@ -203,9 +178,7 @@
*/
public SVGElement getChild(String id)
{
- for (Iterator it = children.iterator(); it.hasNext();)
- {
- SVGElement ele = (SVGElement) it.next();
+ for (SVGElement ele : children) {
String eleId = ele.getId();
if (eleId != null && eleId.equals(id))
{
@@ -219,6 +192,8 @@
/**
* Searches children for given element. If found, returns index of child.
* Otherwise returns -1.
+ * @param child
+ * @return index of child
*/
public int indexOfChild(SVGElement child)
{
@@ -228,10 +203,9 @@
/**
* Swaps 2 elements in children.
*
- * @i index of first
- * @j index of second
- *
- * @return true if successful, false otherwise
+ * @param i index of first child
+ * @param j index of second child
+ * @throws com.kitfox.svg.SVGException
*/
public void swapChildren(int i, int j) throws SVGException
{
@@ -240,7 +214,7 @@
return;
}
- Object temp = children.get(i);
+ SVGElement temp = children.get(i);
children.set(i, children.get(j));
children.set(j, temp);
build();
@@ -253,6 +227,8 @@
* @param attrs - Attributes of this tag
* @param helper - An object passed to all SVG elements involved in this
* build process to aid in sharing information.
+ * @param parent
+ * @throws org.xml.sax.SAXException
*/
public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent) throws SAXException
{
@@ -263,11 +239,12 @@
this.id = attrs.getValue("id");
if (this.id != null && !this.id.equals(""))
{
+ this.id = this.id.intern();
diagram.setElement(this.id, this);
}
String className = attrs.getValue("class");
- this.cssClass = (className == null || className.equals("")) ? null : className;
+ this.cssClass = (className == null || className.equals("")) ? null : className.intern();
//docRoot = helper.docRoot;
//universe = helper.universe;
@@ -275,7 +252,7 @@
String style = attrs.getValue("style");
if (style != null)
{
- HashMap map = XMLParseUtil.parseStyle(style, inlineStyles);
+ HashMap, ?> map = XMLParseUtil.parseStyle(style, inlineStyles);
}
String base = attrs.getValue("xml:base");
@@ -294,14 +271,10 @@
int numAttrs = attrs.getLength();
for (int i = 0; i < numAttrs; i++)
{
- String name = attrs.getQName(i);
- if (ignorePresAttrib.contains(name))
- {
- continue;
- }
+ String name = attrs.getQName(i).intern();
String value = attrs.getValue(i);
- presAttribs.put(name, new StyleAttribute(name, value));
+ presAttribs.put(name, new StyleAttribute(name, value == null ? null : value.intern()));
}
}
@@ -365,17 +338,17 @@
}
/**
- * @return a set of Strings that corespond to CSS attributes on this element
+ * @return a set of Strings that correspond to CSS attributes on this element
*/
- public Set getInlineAttributes()
+ public Set getInlineAttributes()
{
return inlineStyles.keySet();
}
/**
- * @return a set of Strings that corespond to XML attributes on this element
+ * @return a set of Strings that correspond to XML attributes on this element
*/
- public Set getPresentationAttributes()
+ public Set getPresentationAttributes()
{
return presAttribs.keySet();
}
@@ -383,6 +356,9 @@
/**
* Called after the start element but before the end element to indicate
* each child tag that has been processed
+ * @param helper
+ * @param child
+ * @throws com.kitfox.svg.SVGElementException
*/
public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException
{
@@ -401,9 +377,7 @@
{
this.diagram = diagram;
diagram.setElement(id, this);
- for (Iterator it = children.iterator(); it.hasNext();)
- {
- SVGElement ele = (SVGElement) it.next();
+ for (SVGElement ele : children) {
ele.setDiagram(diagram);
}
}
@@ -420,6 +394,8 @@
/**
* Called during load process to add text scanned within a tag
+ * @param helper
+ * @param text
*/
public void loaderAddText(SVGLoaderHelper helper, String text)
{
@@ -428,6 +404,8 @@
/**
* Called to indicate that this tag and the tags it contains have been
* completely processed, and that it should finish any load processes.
+ * @param helper
+ * @throws com.kitfox.svg.SVGParseException
*/
public void loaderEndElement(SVGLoaderHelper helper) throws SVGParseException
{
@@ -444,6 +422,7 @@
/**
* Called by internal processes to rebuild the geometry of this node from
* it's presentation attributes, style attributes and animated tracks.
+ * @throws com.kitfox.svg.SVGException
*/
protected void build() throws SVGException
{
@@ -489,11 +468,12 @@
{
return id;
}
- LinkedList contexts = new LinkedList();
+ LinkedList contexts = new LinkedList();
/**
* Hack to allow nodes to temporarily change their parents. The Use tag will
* need this so it can alter the attributes that a particular node uses.
+ * @param context
*/
protected void pushParentContext(SVGElement context)
{
@@ -594,6 +574,8 @@
* @param recursive - If true and this object does not contain the named
* style attribute, checks attributes of parents back to root until one
* found.
+ * @param evalAnimation
+ * @return
*/
public boolean getStyle(StyleAttribute attrib, boolean recursive, boolean evalAnimation)
throws SVGException
@@ -605,7 +587,7 @@
attrib.setStringValue(styAttr == null ? "" : styAttr.getStringValue());
- //Evalutate coresponding track, if one exists
+ //Evalutate corresponding track, if one exists
if (evalAnimation)
{
TrackBase track = trackManager.getTrack(styName, AnimationElement.AT_CSS);
@@ -628,7 +610,7 @@
attrib.setStringValue(presAttr == null ? "" : presAttr.getStringValue());
- //Evalutate coresponding track, if one exists
+ //Evalutate corresponding track, if one exists
if (evalAnimation)
{
TrackBase track = trackManager.getTrack(styName, AnimationElement.AT_XML);
@@ -675,6 +657,7 @@
}
/**
+ * @param styName
* @return the raw style value of this attribute. Does not take the
* presentation value or animation into consideration. Used by animations to
* determine the base to animate from.
@@ -688,19 +671,21 @@
/**
* Copies the presentation attribute into the passed one.
*
+ * @param attrib
* @return - True if attribute was read successfully
+ * @throws com.kitfox.svg.SVGException
*/
public boolean getPres(StyleAttribute attrib) throws SVGException
{
String presName = attrib.getName();
- //Make sure we have a coresponding presentation attribute
+ //Make sure we have a corresponding presentation attribute
StyleAttribute presAttr = (StyleAttribute) presAttribs.get(presName);
//Copy presentation value directly
attrib.setStringValue(presAttr == null ? "" : presAttr.getStringValue());
- //Evalutate coresponding track, if one exists
+ //Evalutate corresponding track, if one exists
TrackBase track = trackManager.getTrack(presName, AnimationElement.AT_XML);
if (track != null)
{
@@ -718,6 +703,7 @@
}
/**
+ * @param styName
* @return the raw presentation value of this attribute. Ignores any
* modifications applied by style attributes or animation. Used by
* animations to determine the starting point to animate from
@@ -728,9 +714,10 @@
return (StyleAttribute) presAttribs.get(styName);
}
+ private static final Pattern TRANSFORM_PATTERN = Pattern.compile("\\w+\\([^)]*\\)");
static protected AffineTransform parseTransform(String val) throws SVGException
{
- final Matcher matchExpression = Pattern.compile("\\w+\\([^)]*\\)").matcher("");
+ final Matcher matchExpression = TRANSFORM_PATTERN.matcher("");
AffineTransform retXform = new AffineTransform();
@@ -743,9 +730,10 @@
return retXform;
}
+ private static final Pattern WORD_PATTERN = Pattern.compile("([a-zA-Z]+|-?\\d+(\\.\\d+)?([eE]-?\\d+)?|-?\\.\\d+([eE]-?\\d+)?)");
static public AffineTransform parseSingleTransform(String val) throws SVGException
{
- final Matcher matchWord = Pattern.compile("([a-zA-Z]+|-?\\d+(\\.\\d+)?(e-?\\d+)?|-?\\.\\d+(e-?\\d+)?)").matcher("");
+ final Matcher matchWord = WORD_PATTERN.matcher("");
AffineTransform retXform = new AffineTransform();
@@ -758,7 +746,7 @@
String function = matchWord.group().toLowerCase();
- LinkedList termList = new LinkedList();
+ LinkedList termList = new LinkedList();
while (matchWord.find())
{
termList.add(matchWord.group());
@@ -766,11 +754,11 @@
double[] terms = new double[termList.size()];
- Iterator it = termList.iterator();
+ Iterator it = termList.iterator();
int count = 0;
while (it.hasNext())
{
- terms[count++] = XMLParseUtil.parseDouble((String) it.next());
+ terms[count++] = XMLParseUtil.parseDouble(it.next());
}
//Calculate transformation
@@ -818,128 +806,9 @@
return retXform;
}
- static protected float nextFloat(LinkedList l)
- {
- String s = (String) l.removeFirst();
- return Float.parseFloat(s);
- }
-
static protected PathCommand[] parsePathList(String list)
{
- final Matcher matchPathCmd = Pattern.compile("([MmLlHhVvAaQqTtCcSsZz])|([-+]?((\\d*\\.\\d+)|(\\d+))([eE][-+]?\\d+)?)").matcher(list);
-
- //Tokenize
- LinkedList tokens = new LinkedList();
- while (matchPathCmd.find())
- {
- tokens.addLast(matchPathCmd.group());
- }
-
-
- boolean defaultRelative = false;
- LinkedList cmdList = new LinkedList();
- char curCmd = 'Z';
- while (tokens.size() != 0)
- {
- String curToken = (String) tokens.removeFirst();
- char initChar = curToken.charAt(0);
- if ((initChar >= 'A' && initChar <= 'Z') || (initChar >= 'a' && initChar <= 'z'))
- {
- curCmd = initChar;
- } else
- {
- tokens.addFirst(curToken);
- }
-
- PathCommand cmd = null;
-
- switch (curCmd)
- {
- case 'M':
- cmd = new MoveTo(false, nextFloat(tokens), nextFloat(tokens));
- curCmd = 'L';
- break;
- case 'm':
- cmd = new MoveTo(true, nextFloat(tokens), nextFloat(tokens));
- curCmd = 'l';
- break;
- case 'L':
- cmd = new LineTo(false, nextFloat(tokens), nextFloat(tokens));
- break;
- case 'l':
- cmd = new LineTo(true, nextFloat(tokens), nextFloat(tokens));
- break;
- case 'H':
- cmd = new Horizontal(false, nextFloat(tokens));
- break;
- case 'h':
- cmd = new Horizontal(true, nextFloat(tokens));
- break;
- case 'V':
- cmd = new Vertical(false, nextFloat(tokens));
- break;
- case 'v':
- cmd = new Vertical(true, nextFloat(tokens));
- break;
- case 'A':
- cmd = new Arc(false, nextFloat(tokens), nextFloat(tokens),
- nextFloat(tokens),
- nextFloat(tokens) == 1f, nextFloat(tokens) == 1f,
- nextFloat(tokens), nextFloat(tokens));
- break;
- case 'a':
- cmd = new Arc(true, nextFloat(tokens), nextFloat(tokens),
- nextFloat(tokens),
- nextFloat(tokens) == 1f, nextFloat(tokens) == 1f,
- nextFloat(tokens), nextFloat(tokens));
- break;
- case 'Q':
- cmd = new Quadratic(false, nextFloat(tokens), nextFloat(tokens),
- nextFloat(tokens), nextFloat(tokens));
- break;
- case 'q':
- cmd = new Quadratic(true, nextFloat(tokens), nextFloat(tokens),
- nextFloat(tokens), nextFloat(tokens));
- break;
- case 'T':
- cmd = new QuadraticSmooth(false, nextFloat(tokens), nextFloat(tokens));
- break;
- case 't':
- cmd = new QuadraticSmooth(true, nextFloat(tokens), nextFloat(tokens));
- break;
- case 'C':
- cmd = new Cubic(false, nextFloat(tokens), nextFloat(tokens),
- nextFloat(tokens), nextFloat(tokens),
- nextFloat(tokens), nextFloat(tokens));
- break;
- case 'c':
- cmd = new Cubic(true, nextFloat(tokens), nextFloat(tokens),
- nextFloat(tokens), nextFloat(tokens),
- nextFloat(tokens), nextFloat(tokens));
- break;
- case 'S':
- cmd = new CubicSmooth(false, nextFloat(tokens), nextFloat(tokens),
- nextFloat(tokens), nextFloat(tokens));
- break;
- case 's':
- cmd = new CubicSmooth(true, nextFloat(tokens), nextFloat(tokens),
- nextFloat(tokens), nextFloat(tokens));
- break;
- case 'Z':
- case 'z':
- cmd = new Terminal();
- break;
- default:
- throw new RuntimeException("Invalid path element");
- }
-
- cmdList.add(cmd);
- defaultRelative = cmd.isRelative;
- }
-
- PathCommand[] retArr = new PathCommand[cmdList.size()];
- cmdList.toArray(retArr);
- return retArr;
+ return new PathParser(list).parsePathCommand();
}
static protected GeneralPath buildPath(String text, int windingRule)
@@ -970,8 +839,10 @@
* Updates all attributes in this diagram associated with a time event. Ie,
* all attributes with track information.
*
+ * @param curTime
* @return - true if this node has changed state as a result of the time
* update
+ * @throws com.kitfox.svg.SVGException
*/
abstract public boolean updateTime(double curTime) throws SVGException;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/SVGLoaderHelper.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/SVGLoaderHelper.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/SVGLoaderHelper.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/SVGLoaderHelper.java 2022-02-26 23:40:50.000000000 +0000
@@ -64,7 +64,12 @@
*/
public final AnimTimeParser animTimeParser = new AnimTimeParser(new StringReader(""));
- /** Creates a new instance of SVGLoaderHelper */
+ /**
+ * Creates a new instance of SVGLoaderHelper
+ * @param xmlBase
+ * @param universe
+ * @param diagram
+ */
public SVGLoaderHelper(URI xmlBase, SVGUniverse universe, SVGDiagram diagram)
{
this.xmlBase = xmlBase;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/SVGLoader.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/SVGLoader.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/SVGLoader.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/SVGLoader.java 2022-02-26 23:40:50.000000000 +0000
@@ -52,11 +52,11 @@
*/
public class SVGLoader extends DefaultHandler
{
- final HashMap nodeClasses = new HashMap();
+ final HashMap> nodeClasses = new HashMap>();
//final HashMap attribClasses = new HashMap();
- final LinkedList buildStack = new LinkedList();
+ final LinkedList buildStack = new LinkedList();
- final HashSet ignoreClasses = new HashSet();
+ final HashSet ignoreClasses = new HashSet();
final SVGLoaderHelper helper;
@@ -74,7 +74,11 @@
final boolean verbose;
- /** Creates a new instance of SVGLoader */
+ /**
+ * Creates a new instance of SVGLoader
+ * @param xmlBase
+ * @param universe
+ */
public SVGLoader(URI xmlBase, SVGUniverse universe)
{
this(xmlBase, universe, false);
@@ -98,6 +102,7 @@
nodeClasses.put("desc", Desc.class);
nodeClasses.put("ellipse", Ellipse.class);
nodeClasses.put("filter", Filter.class);
+ nodeClasses.put(FeGaussianBlur.TAG_NAME, FeGaussianBlur.class);
nodeClasses.put("font", Font.class);
nodeClasses.put("font-face", FontFace.class);
nodeClasses.put("g", Group.class);
@@ -107,6 +112,7 @@
nodeClasses.put("line", Line.class);
nodeClasses.put("lineargradient", LinearGradient.class);
nodeClasses.put("marker", Marker.class);
+ nodeClasses.put("mask", Mask.class);
nodeClasses.put("metadata", Metadata.class);
nodeClasses.put("missing-glyph", MissingGlyph.class);
nodeClasses.put("path", Path.class);
@@ -144,6 +150,7 @@
return sb.toString();
}
+ @Override
public void startDocument() throws SAXException
{
// System.err.println("Start doc");
@@ -151,11 +158,13 @@
// buildStack.clear();
}
+ @Override
public void endDocument() throws SAXException
{
// System.err.println("End doc");
}
+ @Override
public void startElement(String namespaceURI, String sName, String qName, Attributes attrs) throws SAXException
{
if (verbose)
@@ -192,7 +201,7 @@
//System.err.println("+" + sName);
try {
- Class cls = (Class)obj;
+ Class> cls = (Class>)obj;
SVGElement svgEle = (SVGElement)cls.newInstance();
SVGElement parent = null;
@@ -210,6 +219,7 @@
}
+ @Override
public void endElement(String namespaceURI, String sName, String qName)
throws SAXException
{
@@ -264,6 +274,7 @@
}
}
+ @Override
public void characters(char buf[], int offset, int len)
throws SAXException
{
@@ -280,6 +291,7 @@
}
}
+ @Override
public void processingInstruction(String target, String data)
throws SAXException
{
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/SVGRoot.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/SVGRoot.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/SVGRoot.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/SVGRoot.java 2022-02-26 23:40:50.000000000 +0000
@@ -39,11 +39,9 @@
import com.kitfox.svg.xml.NumberWithUnits;
import com.kitfox.svg.xml.StyleAttribute;
import com.kitfox.svg.xml.StyleSheet;
-import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.Shape;
-import java.awt.Toolkit;
import java.awt.geom.AffineTransform;
import java.awt.geom.NoninvertibleTransformException;
import java.awt.geom.Point2D;
@@ -94,11 +92,13 @@
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
}
+ @Override
public void build() throws SVGException
{
super.build();
@@ -164,6 +164,7 @@
return (text.indexOf(find) != -1);
}
+ @Override
public SVGRoot getRoot()
{
return this;
@@ -199,8 +200,8 @@
}
else if (viewBox != null)
{
- xx = (float)viewBox.x;
- ww = (float)viewBox.width;
+ xx = viewBox.x;
+ ww = viewBox.width;
width = new NumberWithUnits(ww, NumberWithUnits.UT_PX);
x = new NumberWithUnits(xx, NumberWithUnits.UT_PX);
}
@@ -227,8 +228,8 @@
}
else if (viewBox != null)
{
- yy = (float)viewBox.y;
- hh = (float)viewBox.height;
+ yy = viewBox.y;
+ hh = viewBox.height;
height = new NumberWithUnits(hh, NumberWithUnits.UT_PX);
y = new NumberWithUnits(yy, NumberWithUnits.UT_PX);
}
@@ -242,26 +243,16 @@
}
clipRect.setRect(xx, yy, ww, hh);
-
-// if (viewBox == null)
-// {
-// viewXform.setToIdentity();
-// }
-// else
-// {
-// //If viewport window is set, we are drawing to entire viewport
-// clipRect.setRect(deviceViewport);
-//
-// viewXform.setToIdentity();
-// viewXform.setToTranslation(deviceViewport.x, deviceViewport.y);
-// viewXform.scale(deviceViewport.width, deviceViewport.height);
-// viewXform.scale(1 / viewBox.width, 1 / viewBox.height);
-// viewXform.translate(-viewBox.x, -viewBox.y);
-// }
}
public void renderToViewport(Graphics2D g) throws SVGException
{
+ render(g);
+ }
+
+ @Override
+ protected void doRender(Graphics2D g) throws SVGException
+ {
prepareViewport();
Rectangle targetViewport = g.getClipBounds();
@@ -303,34 +294,42 @@
}
else
{
-// Dimension size = Toolkit.getDefaultToolkit().getScreenSize();
-// targetViewport = new Rectangle(0, 0, size.width, size.height);
targetViewport = new Rectangle(deviceViewport);
}
clipRect.setRect(targetViewport);
- if (viewBox == null)
- {
- viewXform.setToIdentity();
- }
- else
- {
- viewXform.setToIdentity();
- viewXform.setToTranslation(targetViewport.x, targetViewport.y);
- viewXform.scale(targetViewport.width, targetViewport.height);
- viewXform.scale(1 / viewBox.width, 1 / viewBox.height);
- viewXform.translate(-viewBox.x, -viewBox.y);
- }
+ viewXform.setTransform(calcViewportTransform(targetViewport));
AffineTransform cachedXform = g.getTransform();
g.transform(viewXform);
- super.render(g);
+ super.doRender(g);
g.setTransform(cachedXform);
}
- public void pick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List retVec) throws SVGException
+ public AffineTransform calcViewportTransform(Rectangle targetViewport)
+ {
+ AffineTransform xform = new AffineTransform();
+
+ if (viewBox == null)
+ {
+ xform.setToIdentity();
+ }
+ else
+ {
+ xform.setToIdentity();
+ xform.setToTranslation(targetViewport.x, targetViewport.y);
+ xform.scale(targetViewport.width, targetViewport.height);
+ xform.scale(1 / viewBox.width, 1 / viewBox.height);
+ xform.translate(-viewBox.x, -viewBox.y);
+ }
+
+ return xform;
+ }
+
+ @Override
+ public void doPick(Rectangle2D pickArea, AffineTransform ltw, boolean boundingBox, List> retVec) throws SVGException
{
if (viewXform != null)
{
@@ -338,10 +337,11 @@
ltw.concatenate(viewXform);
}
- super.pick(pickArea, ltw, boundingBox, retVec);
+ super.doPick(pickArea, ltw, boundingBox, retVec);
}
- public void pick(Point2D point, boolean boundingBox, List retVec) throws SVGException
+ @Override
+ public void doPick(Point2D point, boolean boundingBox, List> retVec) throws SVGException
{
Point2D xPoint = new Point2D.Double(point.getX(), point.getY());
if (viewXform != null)
@@ -355,15 +355,17 @@
}
}
- super.pick(xPoint, boundingBox, retVec);
+ super.doPick(xPoint, boundingBox, retVec);
}
+ @Override
public Shape getShape()
{
Shape shape = super.getShape();
return viewXform.createTransformedShape(shape);
}
+ @Override
public Rectangle2D getBoundingBox() throws SVGException
{
Rectangle2D bbox = super.getBoundingBox();
@@ -392,6 +394,7 @@
* @return - true if this node has changed state as a result of the time
* update
*/
+ @Override
public boolean updateTime(double curTime) throws SVGException
{
boolean changeState = super.updateTime(curTime);
@@ -472,6 +475,10 @@
{
return ((Style)ele).getStyleSheet();
}
+ else if (ele instanceof Defs)
+ {
+ return ((Defs)ele).getStyleSheet();
+ }
}
}
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/SVGUniverse.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/SVGUniverse.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/SVGUniverse.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/SVGUniverse.java 2022-02-26 23:40:50.000000000 +0000
@@ -57,12 +57,12 @@
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.zip.GZIPInputStream;
import javax.imageio.ImageIO;
import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
@@ -88,20 +88,21 @@
* 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();
+ 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.
+ * corresponds to the time of 0 in each member diagram.
*/
protected double curTime = 0.0;
private boolean verbose = false;
- //Cache reader for efficiency
- XMLReader cachedReader;
+ //If true, elements will only load image data that is included using inline data: uris
+ private boolean imageDataInlineOnly = false;
+
/**
* Creates a new instance of SVGUniverse
*/
@@ -150,9 +151,7 @@
*/
public void updateTime() throws SVGException
{
- for (Iterator it = loadedDocs.values().iterator(); it.hasNext();)
- {
- SVGDiagram dia = (SVGDiagram) it.next();
+ for (SVGDiagram dia : loadedDocs.values()) {
dia.updateTime(curTime);
}
}
@@ -168,9 +167,8 @@
public Font getDefaultFont()
{
- for (Iterator it = loadedFonts.values().iterator(); it.hasNext();)
- {
- return (Font) it.next();
+ for (Font font : loadedFonts.values()) {
+ return font;
}
return null;
}
@@ -214,7 +212,7 @@
urlIdx++;
}
- SoftReference ref = new SoftReference(img);
+ SoftReference ref = new SoftReference(img);
loadedImages.put(url, ref);
return url;
@@ -248,7 +246,7 @@
return;
}
- SoftReference ref;
+ SoftReference ref;
try
{
String fileName = imageURL.getFile();
@@ -261,11 +259,11 @@
Graphics2D g = img.createGraphics();
icon.paintIcon(null, g, 0, 0);
g.dispose();
- ref = new SoftReference(img);
+ ref = new SoftReference(img);
} else
{
BufferedImage img = ImageIO.read(imageURL);
- ref = new SoftReference(img);
+ ref = new SoftReference(img);
}
loadedImages.put(imageURL, ref);
} catch (Exception e)
@@ -277,7 +275,7 @@
BufferedImage getImage(URL imageURL)
{
- SoftReference ref = (SoftReference) loadedImages.get(imageURL);
+ SoftReference ref = (SoftReference) loadedImages.get(imageURL);
if (ref == null)
{
return null;
@@ -295,7 +293,7 @@
Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
"Could not load image", e);
}
- ref = new SoftReference(img);
+ ref = new SoftReference(img);
loadedImages.put(imageURL, ref);
}
@@ -325,16 +323,45 @@
return null;
}
+ public URI cleanUri(URI uri)
+ {
+ String scheme = uri.getScheme();
+ String schemeSpecific = uri.getSchemeSpecificPart();
+ String frag = uri.getFragment();
+
+ if (schemeSpecific.startsWith("file:///"))
+ {
+ //Work around for URIs of resources obtained by Class.getResource()
+ schemeSpecific = "file:/" + schemeSpecific.substring(8);
+ }
+ else
+ {
+ return uri;
+ }
+
+ try
+ {
+ return new URI(scheme, schemeSpecific, frag);
+ }
+ catch (URISyntaxException ex)
+ {
+ Logger.getLogger(SVGUniverse.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ 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.
+ * checked against the SVG diagram's index and the corresponding element
+ * returned. If there is no corresponding index, null is returned.
*/
public SVGElement getElement(URI path, boolean loadIfAbsent)
{
try
{
+ path = cleanUri(path);
+
//Strip fragment from URI
URI xmlBase = new URI(path.getScheme(), path.getSchemeSpecificPart(), null);
@@ -393,7 +420,7 @@
{
//Workaround for resources stored in jars loaded by Webstart.
//http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6753651
- url = SVGUniverse.class.getResource("xmlBase.getPath()");
+ url = SVGUniverse.class.getResource(xmlBase.getPath());
}
else
{
@@ -466,7 +493,9 @@
}
InputStream is = docRoot.openStream();
- return loadSVG(uri, new InputSource(createDocumentInputStream(is)));
+ URI result = loadSVG(uri, new InputSource(createDocumentInputStream(is)));
+ is.close();
+ return result;
} catch (URISyntaxException ex)
{
Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
@@ -577,19 +606,26 @@
}
}
- private XMLReader getXMLReaderCached() throws SAXException, ParserConfigurationException
+ static ThreadLocal threadSAXParser = new ThreadLocal();
+
+ private XMLReader getXMLReader() throws SAXException, ParserConfigurationException
{
- if (cachedReader == null)
+ SAXParser saxParser = threadSAXParser.get();
+ if (saxParser == null)
{
- SAXParserFactory factory = SAXParserFactory.newInstance();
- factory.setNamespaceAware(true);
- cachedReader = factory.newSAXParser().getXMLReader();
+ SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
+ saxParserFactory.setNamespaceAware(true);
+ saxParser = saxParserFactory.newSAXParser();
+ threadSAXParser.set(saxParser);
}
- return cachedReader;
+ return saxParser.getXMLReader();
}
protected URI loadSVG(URI xmlBase, InputSource is)
{
+ xmlBase = cleanUri(xmlBase);
+
+
// Use an instance of ourselves as the SAX event handler
SVGLoader handler = new SVGLoader(xmlBase, this, verbose);
@@ -601,7 +637,7 @@
try
{
// Parse the input
- XMLReader reader = getXMLReaderCached();
+ XMLReader reader = getXMLReader();
reader.setEntityResolver(
new EntityResolver()
{
@@ -618,8 +654,8 @@
return xmlBase;
} catch (SAXParseException sex)
{
- System.err.println("Error processing " + xmlBase);
- System.err.println(sex.getMessage());
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
+ "Error processing " + xmlBase, sex);
loadedDocs.remove(xmlBase);
return null;
@@ -636,9 +672,9 @@
* Get list of uris of all loaded documents and subdocuments.
* @return
*/
- public ArrayList getLoadedDocumentURIs()
+ public ArrayList getLoadedDocumentURIs()
{
- return new ArrayList(loadedDocs.keySet());
+ return new ArrayList(loadedDocs.keySet());
}
/**
@@ -647,6 +683,7 @@
*/
public void removeDocument(URI uri)
{
+ uri = cleanUri(uri);
loadedDocs.remove(uri);
}
@@ -677,4 +714,20 @@
return universe;
}
+
+ /**
+ * @return the imageDataInlineOnly
+ */
+ public boolean isImageDataInlineOnly()
+ {
+ return imageDataInlineOnly;
+ }
+
+ /**
+ * @param imageDataInlineOnly the imageDataInlineOnly to set
+ */
+ public void setImageDataInlineOnly(boolean imageDataInlineOnly)
+ {
+ this.imageDataInlineOnly = imageDataInlineOnly;
+ }
}
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Symbol.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Symbol.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Symbol.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Symbol.java 2022-02-26 23:40:50.000000000 +0000
@@ -60,11 +60,13 @@
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
}
+ @Override
protected void build() throws SVGException
{
super.build();
@@ -93,6 +95,7 @@
viewXform.translate(-viewBox.getX(), -viewBox.getY());
}
+ @Override
protected boolean outsideClip(Graphics2D g) throws SVGException
{
Shape clip = g.getClip();
@@ -107,22 +110,25 @@
}
- public void render(Graphics2D g) throws SVGException
+ @Override
+ protected void doRender(Graphics2D g) throws SVGException
{
AffineTransform oldXform = g.getTransform();
g.transform(viewXform);
- super.render(g);
+ super.doRender(g);
g.setTransform(oldXform);
}
+ @Override
public Shape getShape()
{
Shape shape = super.getShape();
return viewXform.createTransformedShape(shape);
}
+ @Override
public Rectangle2D getBoundingBox() throws SVGException
{
Rectangle2D rect = super.getBoundingBox();
@@ -136,6 +142,7 @@
* @return - true if this node has changed state as a result of the time
* update
*/
+ @Override
public boolean updateTime(double curTime) throws SVGException
{
// if (trackManager.getNumTracks() == 0) return false;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Text.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Text.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Text.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Text.java 2022-02-26 23:40:50.000000000 +0000
@@ -3,16 +3,16 @@
* Copyright (c) 2004, Mark McKay
* All rights reserved.
*
- * Redistribution and use in source and binary forms, with or
+ * Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
- * - Redistributions of source code must retain the above
+ * - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
+ * disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
@@ -26,8 +26,8 @@
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
* Mark McKay can be contacted at mark@kitfox.com. Salamander and other
* projects can be found at http://www.kitfox.com
*
@@ -35,43 +35,29 @@
*/
package com.kitfox.svg;
-import com.kitfox.svg.util.FontSystem;
+import com.kitfox.svg.util.FontUtil;
import com.kitfox.svg.xml.StyleAttribute;
-import java.awt.Graphics2D;
-import java.awt.Shape;
+
import java.awt.geom.AffineTransform;
-import java.awt.geom.GeneralPath;
-import java.awt.geom.Point2D;
+import java.awt.geom.Path2D;
import java.awt.geom.Rectangle2D;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+import java.util.Arrays;
+import java.util.List;
/**
* @author Mark McKay
* @author Mark McKay
*/
-public class Text extends ShapeElement
+public class Text extends Tspan
{
public static final String TAG_NAME = "text";
-
- float x = 0;
- float y = 0;
- AffineTransform transform = null;
- String fontFamily;
- float fontSize;
- //List of strings and tspans containing the content of this node
- LinkedList content = new LinkedList();
- Shape textShape;
+
public static final int TXAN_START = 0;
public static final int TXAN_MIDDLE = 1;
public static final int TXAN_END = 2;
- int textAnchor = TXAN_START;
public static final int TXST_NORMAL = 0;
public static final int TXST_ITALIC = 1;
public static final int TXST_OBLIQUE = 2;
- int fontStyle;
public static final int TXWE_NORMAL = 0;
public static final int TXWE_BOLD = 1;
public static final int TXWE_BOLDER = 2;
@@ -85,11 +71,9 @@
public static final int TXWE_700 = 10;
public static final int TXWE_800 = 11;
public static final int TXWE_900 = 12;
- int fontWeight;
- float textLength = -1;
- String lengthAdjust = "spacing";
-
+ int textAnchor = TXAN_START;
+
/**
* Creates a new instance of Stop
*/
@@ -97,22 +81,12 @@
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
}
- public void appendText(String text)
- {
- content.addLast(text);
- }
-
- public void appendTspan(Tspan tspan) throws SVGElementException
- {
- super.loaderAddChild(null, tspan);
- content.addLast(tspan);
- }
-
/**
* Discard cached information
*/
@@ -121,119 +95,16 @@
build();
}
- public java.util.List getContent()
- {
- return content;
- }
-
- /**
- * Called after the start element but before the end element to indicate
- * each child tag that has been processed
- */
- public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException
+ @Override
+ protected void build() throws SVGException
{
- super.loaderAddChild(helper, child);
-
- content.addLast(child);
- }
-
- /**
- * Called during load process to add text scanned within a tag
- */
- public void loaderAddText(SVGLoaderHelper helper, String text)
- {
- Matcher matchWs = Pattern.compile("\\s*").matcher(text);
- if (!matchWs.matches())
- {
- content.addLast(text);
- }
+ super.build();
+ buildText();
}
- public void build() throws SVGException
+ protected void buildAttributes(StyleAttribute sty) throws SVGException
{
- super.build();
-
- StyleAttribute sty = new StyleAttribute();
-
- if (getPres(sty.setName("x")))
- {
- x = sty.getFloatValueWithUnits();
- }
-
- if (getPres(sty.setName("y")))
- {
- y = sty.getFloatValueWithUnits();
- }
-
- if (getStyle(sty.setName("font-family")))
- {
- fontFamily = sty.getStringValue();
- }
- else
- {
- fontFamily = "Sans Serif";
- }
-
- if (getStyle(sty.setName("font-size")))
- {
- fontSize = sty.getFloatValueWithUnits();
- }
- else
- {
- fontSize = 12f;
- }
-
- if (getStyle(sty.setName("textLength")))
- {
- textLength = sty.getFloatValueWithUnits();
- }
- else
- {
- textLength = -1;
- }
-
- if (getStyle(sty.setName("lengthAdjust")))
- {
- lengthAdjust = sty.getStringValue();
- }
- else
- {
- lengthAdjust = "spacing";
- }
-
- if (getStyle(sty.setName("font-style")))
- {
- String s = sty.getStringValue();
- if ("normal".equals(s))
- {
- fontStyle = TXST_NORMAL;
- } else if ("italic".equals(s))
- {
- fontStyle = TXST_ITALIC;
- } else if ("oblique".equals(s))
- {
- fontStyle = TXST_OBLIQUE;
- }
- } else
- {
- fontStyle = TXST_NORMAL;
- }
-
- if (getStyle(sty.setName("font-weight")))
- {
- String s = sty.getStringValue();
- if ("normal".equals(s))
- {
- fontWeight = TXWE_NORMAL;
- } else if ("bold".equals(s))
- {
- fontWeight = TXWE_BOLD;
- }
- } else
- {
- fontWeight = TXWE_NORMAL;
- }
-
+ super.buildAttributes(sty);
if (getStyle(sty.setName("text-anchor")))
{
String s = sty.getStringValue();
@@ -251,282 +122,64 @@
{
textAnchor = TXAN_START;
}
+ }
- //text anchor
- //text-decoration
- //text-rendering
- buildText();
+ private void buildText() throws SVGException
+ {
+ buildShapeInformation();
+ Cursor cursor = createInitialCursor();
+ float xInitial = cursor.x;
+ super.buildTextShape(cursor);
+ alignSegmentsAtAnchor(fullPath, xInitial);
}
- protected void buildText() throws SVGException
+ private void alignSegmentsAtAnchor(Path2D textPath, float xInitial)
{
- //Get font
- String[] families = fontFamily.split(",");
- Font font = null;
- for (int i = 0; i < families.length; ++i)
+ AffineTransform tx;
+ Rectangle2D bounds;
+ switch (textAnchor)
{
- font = diagram.getUniverse().getFont(fontFamily);
- if (font != null)
- {
+ case TXAN_MIDDLE:
+ bounds = textPath.getBounds2D();
+ tx = AffineTransform.getTranslateInstance(
+ -(bounds.getX() + bounds.getWidth() / 2.0 - xInitial), 0
+ );
+ break;
+ case TXAN_END:
+ bounds = textPath.getBounds2D();
+ tx = AffineTransform.getTranslateInstance(
+ -(bounds.getX() + bounds.getWidth() - xInitial), 0
+ );
+ break;
+ default:
+ tx = null;
break;
- }
- }
-
- if (font == null)
- {
-// System.err.println("Could not load font");
-
- font = new FontSystem(fontFamily, fontStyle, fontWeight, (int)fontSize);
-// java.awt.Font sysFont = new java.awt.Font(fontFamily, style | weight, (int)fontSize);
-// buildSysFont(sysFont);
-// return;
}
-
-// font = new java.awt.Font(font.getFamily(), style | weight, font.getSize());
-
-// Area textArea = new Area();
- GeneralPath textPath = new GeneralPath();
- textShape = textPath;
-
- float cursorX = x, cursorY = y;
-
- FontFace fontFace = font.getFontFace();
- //int unitsPerEm = fontFace.getUnitsPerEm();
-// int ascent = fontFace.getAscent();
-// float fontScale = fontSize / (float) ascent;
-
-// AffineTransform oldXform = g.getTransform();
-// TextBuilder builder = new TextBuilder();
-//
-// for (Iterator it = content.iterator(); it.hasNext();)
-// {
-// Object obj = it.next();
-//
-// if (obj instanceof String)
-// {
-// String text = (String) obj;
-// if (text != null)
-// {
-// text = text.trim();
-// }
-//
-// for (int i = 0; i < text.length(); i++)
-// {
-// String unicode = text.substring(i, i + 1);
-// MissingGlyph glyph = font.getGlyph(unicode);
-//
-// builder.appendGlyph(glyph);
-// }
-// }
-// else if (obj instanceof Tspan)
-// {
-// Tspan tspan = (Tspan)obj;
-// tspan.buildGlyphs(builder);
-// }
-// }
-//
-// builder.formatGlyphs();
-
-
-
-
-
-
-
-
- AffineTransform xform = new AffineTransform();
-
- for (Iterator it = content.iterator(); it.hasNext();)
+ if (tx != null)
{
- Object obj = it.next();
-
- if (obj instanceof String)
- {
- String text = (String) obj;
- if (text != null)
- {
- text = text.trim();
- }
-
-// strokeWidthScalar = 1f / fontScale;
-
- for (int i = 0; i < text.length(); i++)
- {
- xform.setToIdentity();
- xform.setToTranslation(cursorX, cursorY);
-// xform.scale(fontScale, fontScale);
-// g.transform(xform);
-
- String unicode = text.substring(i, i + 1);
- MissingGlyph glyph = font.getGlyph(unicode);
-
- Shape path = glyph.getPath();
- if (path != null)
- {
- path = xform.createTransformedShape(path);
- textPath.append(path, false);
- }
-// else glyph.render(g);
-
-// cursorX += fontScale * glyph.getHorizAdvX();
- cursorX += glyph.getHorizAdvX();
-
-// g.setTransform(oldXform);
- }
-
- strokeWidthScalar = 1f;
- }
- else if (obj instanceof Tspan)
- {
-// Tspan tspan = (Tspan) obj;
-//
-// xform.setToIdentity();
-// xform.setToTranslation(cursorX, cursorY);
-// xform.scale(fontScale, fontScale);
-//// tspan.setCursorX(cursorX);
-//// tspan.setCursorY(cursorY);
-//
-// Shape tspanShape = tspan.getShape();
-// tspanShape = xform.createTransformedShape(tspanShape);
-// textPath.append(tspanShape, false);
-//// tspan.render(g);
-//// cursorX = tspan.getCursorX();
-//// cursorY = tspan.getCursorY();
-
-
- Tspan tspan = (Tspan)obj;
- Point2D cursor = new Point2D.Float(cursorX, cursorY);
-// tspan.setCursorX(cursorX);
-// tspan.setCursorY(cursorY);
- tspan.appendToShape(textPath, cursor);
-// cursorX = tspan.getCursorX();
-// cursorY = tspan.getCursorY();
- cursorX = (float)cursor.getX();
- cursorY = (float)cursor.getY();
-
- }
-
+ fullPath.transform(tx);
+ textBounds = fullPath.getBounds2D();
+ transformSegments(segments, tx);
}
+ }
- switch (textAnchor)
+ private void transformSegments(List segments, AffineTransform transform)
+ {
+ for (TextSegment segment : segments)
{
- case TXAN_MIDDLE:
+ if (segment.textPath != null)
{
- AffineTransform at = new AffineTransform();
- at.translate(-textPath.getBounds().getWidth() / 2, 0);
- textPath.transform(at);
- break;
- }
- case TXAN_END:
+ segment.textPath.transform(transform);
+ } else
{
- AffineTransform at = new AffineTransform();
- at.translate(-textPath.getBounds().getWidth(), 0);
- textPath.transform(at);
- break;
+ segment.element.fullPath.transform(transform);
+ segment.element.textBounds = segment.element.fullPath.getBounds2D();
+ transformSegments(segment.element.segments, transform);
}
}
}
-// private void buildSysFont(java.awt.Font font) throws SVGException
-// {
-// GeneralPath textPath = new GeneralPath();
-// textShape = textPath;
-//
-// float cursorX = x, cursorY = y;
-//
-//// FontMetrics fm = g.getFontMetrics(font);
-// FontRenderContext frc = new FontRenderContext(null, true, true);
-//
-//// FontFace fontFace = font.getFontFace();
-// //int unitsPerEm = fontFace.getUnitsPerEm();
-//// int ascent = fm.getAscent();
-//// float fontScale = fontSize / (float)ascent;
-//
-//// AffineTransform oldXform = g.getTransform();
-// AffineTransform xform = new AffineTransform();
-//
-// for (Iterator it = content.iterator(); it.hasNext();)
-// {
-// Object obj = it.next();
-//
-// if (obj instanceof String)
-// {
-// String text = (String)obj;
-// text = text.trim();
-//
-// Shape textShape = font.createGlyphVector(frc, text).getOutline(cursorX, cursorY);
-// textPath.append(textShape, false);
-//// renderShape(g, textShape);
-//// g.drawString(text, cursorX, cursorY);
-//
-// Rectangle2D rect = font.getStringBounds(text, frc);
-// cursorX += (float) rect.getWidth();
-// } else if (obj instanceof Tspan)
-// {
-// /*
-// Tspan tspan = (Tspan)obj;
-//
-// xform.setToIdentity();
-// xform.setToTranslation(cursorX, cursorY);
-//
-// Shape tspanShape = tspan.getShape();
-// tspanShape = xform.createTransformedShape(tspanShape);
-// textArea.add(new Area(tspanShape));
-//
-// cursorX += tspanShape.getBounds2D().getWidth();
-// */
-//
-//
-// Tspan tspan = (Tspan)obj;
-// Point2D cursor = new Point2D.Float(cursorX, cursorY);
-//// tspan.setCursorX(cursorX);
-//// tspan.setCursorY(cursorY);
-// tspan.appendToShape(textPath, cursor);
-//// cursorX = tspan.getCursorX();
-//// cursorY = tspan.getCursorY();
-// cursorX = (float)cursor.getX();
-// cursorY = (float)cursor.getY();
-//
-// }
-// }
-//
-// switch (textAnchor)
-// {
-// case TXAN_MIDDLE:
-// {
-// AffineTransform at = new AffineTransform();
-// at.translate(-textPath.getBounds().getWidth() / 2, 0);
-// textPath.transform(at);
-// break;
-// }
-// case TXAN_END:
-// {
-// AffineTransform at = new AffineTransform();
-// at.translate(-Math.ceil(textPath.getBounds().getWidth()), 0);
-// textPath.transform(at);
-// break;
-// }
-// }
-// }
-
- public void render(Graphics2D g) throws SVGException
- {
- beginLayer(g);
- renderShape(g, textShape);
- finishLayer(g);
- }
-
- public Shape getShape()
- {
- return shapeToParent(textShape);
- }
-
- public Rectangle2D getBoundingBox() throws SVGException
- {
- return boundsToParent(includeStrokeInBounds(textShape.getBounds2D()));
- }
-
/**
* Updates all attributes in this diagram associated with a time event. Ie,
* all attributes with track information.
@@ -534,118 +187,28 @@
* @return - true if this node has changed state as a result of the time
* update
*/
+ @Override
public boolean updateTime(double curTime) throws SVGException
{
-// if (trackManager.getNumTracks() == 0) return false;
boolean changeState = super.updateTime(curTime);
//Get current values for parameters
- StyleAttribute sty = new StyleAttribute();
- boolean shapeChange = false;
-
- if (getPres(sty.setName("x")))
- {
- float newVal = sty.getFloatValueWithUnits();
- if (newVal != x)
- {
- x = newVal;
- shapeChange = true;
- }
- }
-
- if (getPres(sty.setName("y")))
- {
- float newVal = sty.getFloatValueWithUnits();
- if (newVal != y)
- {
- y = newVal;
- shapeChange = true;
- }
- }
-
- if (getStyle(sty.setName("textLength")))
- {
- textLength = sty.getFloatValueWithUnits();
- }
- else
- {
- textLength = -1;
- }
-
- if (getStyle(sty.setName("lengthAdjust")))
- {
- lengthAdjust = sty.getStringValue();
- }
- else
- {
- lengthAdjust = "spacing";
- }
-
- if (getPres(sty.setName("font-family")))
- {
- String newVal = sty.getStringValue();
- if (!newVal.equals(fontFamily))
- {
- fontFamily = newVal;
- shapeChange = true;
- }
- }
-
- if (getPres(sty.setName("font-size")))
- {
- float newVal = sty.getFloatValueWithUnits();
- if (newVal != fontSize)
- {
- fontSize = newVal;
- shapeChange = true;
- }
- }
-
-
- if (getStyle(sty.setName("font-style")))
- {
- String s = sty.getStringValue();
- int newVal = fontStyle;
- if ("normal".equals(s))
- {
- newVal = TXST_NORMAL;
- } else if ("italic".equals(s))
- {
- newVal = TXST_ITALIC;
- } else if ("oblique".equals(s))
- {
- newVal = TXST_OBLIQUE;
- }
- if (newVal != fontStyle)
- {
- fontStyle = newVal;
- shapeChange = true;
- }
- }
-
- if (getStyle(sty.setName("font-weight")))
- {
- String s = sty.getStringValue();
- int newVal = fontWeight;
- if ("normal".equals(s))
- {
- newVal = TXWE_NORMAL;
- } else if ("bold".equals(s))
- {
- newVal = TXWE_BOLD;
- }
- if (newVal != fontWeight)
- {
- fontWeight = newVal;
- shapeChange = true;
- }
- }
+ FontUtil.FontInfo fontInfoOld = fontInfo;
+ float[] xOld = x;
+ float[] yOld = y;
+ float[] dxOld = dx;
+ float[] dyOld = dy;
+ buildShapeInformation();
+
+ boolean shapeChange = !fontInfo.equals(fontInfoOld)
+ || !Arrays.equals(xOld, x)
+ || !Arrays.equals(yOld, y)
+ || !Arrays.equals(dxOld, dx)
+ || !Arrays.equals(dyOld, dy);
if (shapeChange)
{
- build();
-// buildFont();
-// return true;
+ buildText();
}
return changeState || shapeChange;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Title.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Title.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Title.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Title.java 2022-02-26 23:40:50.000000000 +0000
@@ -54,6 +54,7 @@
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
@@ -62,6 +63,7 @@
/**
* Called during load process to add text scanned within a tag
*/
+ @Override
public void loaderAddText(SVGLoaderHelper helper, String text)
{
this.text.append(text);
@@ -79,6 +81,7 @@
* @return - true if this node has changed state as a result of the time
* update
*/
+ @Override
public boolean updateTime(double curTime) throws SVGException
{
//Title does not change
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/TransformableElement.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/TransformableElement.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/TransformableElement.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/TransformableElement.java 2022-02-26 23:40:50.000000000 +0000
@@ -86,6 +86,7 @@
}
*/
+ @Override
protected void build() throws SVGException
{
super.build();
@@ -109,7 +110,7 @@
protected Rectangle2D boundsToParent(Rectangle2D rect)
{
- if (xform == null)
+ if (xform == null || rect == null)
{
return rect;
}
@@ -123,6 +124,7 @@
* @return - true if this node has changed state as a result of the time
* update
*/
+ @Override
public boolean updateTime(double curTime) throws SVGException
{
StyleAttribute sty = new StyleAttribute();
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Tspan.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Tspan.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Tspan.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Tspan.java 2022-02-26 23:40:50.000000000 +0000
@@ -35,17 +35,19 @@
*/
package com.kitfox.svg;
-import com.kitfox.svg.util.FontSystem;
+import com.kitfox.svg.util.FontUtil;
import com.kitfox.svg.xml.StyleAttribute;
import java.awt.Graphics2D;
import java.awt.Shape;
-import java.awt.font.FontRenderContext;
-import java.awt.font.GlyphMetrics;
-import java.awt.font.GlyphVector;
import java.awt.geom.AffineTransform;
import java.awt.geom.GeneralPath;
-import java.awt.geom.Point2D;
+import java.awt.geom.Path2D;
import java.awt.geom.Rectangle2D;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
* @author Mark McKay
@@ -60,99 +62,101 @@
float[] dx = null;
float[] dy = null;
float[] rotate = null;
- private String text = "";
-// float cursorX;
-// float cursorY;
-// Shape tspanShape;
+ float textLength = -1;
+ String lengthAdjust = "spacing";
+
+ // List of strings and tspans containing the content of this node
+ private final List content = new ArrayList<>();
+ protected final ArrayList segments = new ArrayList<>();
+ protected Rectangle2D textBounds;
+ protected Path2D fullPath;
+
+ protected FontUtil.FontInfo fontInfo;
+ private Font font;
+
/**
- * Creates a new instance of Stop
+ * Creates a new instance of Tspan
*/
public Tspan()
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
}
-// public float getCursorX()
-// {
-// return cursorX;
-// }
-//
-// public float getCursorY()
-// {
-// return cursorY;
-// }
-//
-// public void setCursorX(float cursorX)
-// {
-// this.cursorX = cursorX;
-// }
-//
-// public void setCursorY(float cursorY)
-// {
-// this.cursorY = cursorY;
-// }
- /*
- public void loaderStartElement(SVGLoaderHelper helper, Attributes attrs, SVGElement parent)
- {
- //Load style string
- super.loaderStartElement(helper, attrs, parent);
-
- String x = attrs.getValue("x");
- String y = attrs.getValue("y");
- String dx = attrs.getValue("dx");
- String dy = attrs.getValue("dy");
- String rotate = attrs.getValue("rotate");
-
- if (x != null) this.x = XMLParseUtil.parseFloatList(x);
- if (y != null) this.y = XMLParseUtil.parseFloatList(y);
- if (dx != null) this.dx = XMLParseUtil.parseFloatList(dx);
- if (dy != null) this.dy = XMLParseUtil.parseFloatList(dy);
- if (rotate != null)
- {
- this.rotate = XMLParseUtil.parseFloatList(rotate);
- for (int i = 0; i < this.rotate.length; i++)
- this.rotate[i] = (float)Math.toRadians(this.rotate[i]);
- }
- }
+ /**
+ * Called after the start element but before the end element to indicate
+ * each child tag that has been processed
*/
+ @Override
+ public void loaderAddChild(SVGLoaderHelper helper, SVGElement child) throws SVGElementException
+ {
+ super.loaderAddChild(helper, child);
+
+ content.add(child);
+ }
/**
* Called during load process to add text scanned within a tag
*/
+ @Override
public void loaderAddText(SVGLoaderHelper helper, String text)
{
- this.text += text;
+ Matcher matchWs = Pattern.compile("\\s*").matcher(text);
+ if (!matchWs.matches())
+ {
+ content.add(text);
+ }
}
- protected void build() throws SVGException
+ public List getContent()
{
- super.build();
+ return content;
+ }
- StyleAttribute sty = new StyleAttribute();
+ /**
+ * Removes all strings and Tspan elements that are children of this element.
+ */
+ public void clearContent()
+ {
+ content.clear();
+ }
+ public void appendText(String text)
+ {
+ content.add(text);
+ }
+
+ public void appendTspan(Tspan tspan) throws SVGElementException
+ {
+ super.loaderAddChild(null, tspan);
+ content.add(tspan);
+ }
+
+ protected void buildAttributes(StyleAttribute sty) throws SVGException
+ {
if (getPres(sty.setName("x")))
{
- x = sty.getFloatList();
+ x = sty.getFloatListWithUnits();
}
if (getPres(sty.setName("y")))
{
- y = sty.getFloatList();
+ y = sty.getFloatListWithUnits();
}
if (getPres(sty.setName("dx")))
{
- dx = sty.getFloatList();
+ dx = sty.getFloatListWithUnits();
}
if (getPres(sty.setName("dy")))
{
- dy = sty.getFloatList();
+ dy = sty.getFloatListWithUnits();
}
if (getPres(sty.setName("rotate")))
@@ -162,308 +166,168 @@
{
rotate[i] = (float) Math.toRadians(this.rotate[i]);
}
-
}
- }
- public void appendToShape(GeneralPath addShape, Point2D cursor) throws SVGException
- {
- StyleAttribute sty = new StyleAttribute();
-
- String fontFamily = null;
- if (getStyle(sty.setName("font-family")))
+ if (getStyle(sty.setName("textLength")))
{
- fontFamily = sty.getStringValue();
+ textLength = sty.getFloatValueWithUnits();
}
-
-
- float fontSize = 12f;
- if (getStyle(sty.setName("font-size")))
+ else
{
- fontSize = sty.getFloatValueWithUnits();
+ textLength = -1;
}
- float letterSpacing = 0;
- if (getStyle(sty.setName("letter-spacing")))
+ if (getStyle(sty.setName("lengthAdjust")))
{
- letterSpacing = sty.getFloatValueWithUnits();
+ lengthAdjust = sty.getStringValue();
}
-
- int fontStyle = 0;
- if (getStyle(sty.setName("font-style")))
- {
- String s = sty.getStringValue();
- if ("normal".equals(s))
- {
- fontStyle = Text.TXST_NORMAL;
- } else if ("italic".equals(s))
- {
- fontStyle = Text.TXST_ITALIC;
- } else if ("oblique".equals(s))
- {
- fontStyle = Text.TXST_OBLIQUE;
- }
- } else
+ else
{
- fontStyle = Text.TXST_NORMAL;
+ lengthAdjust = "spacing";
}
+ }
- int fontWeight = 0;
- if (getStyle(sty.setName("font-weight")))
- {
- String s = sty.getStringValue();
- if ("normal".equals(s))
- {
- fontWeight = Text.TXWE_NORMAL;
- } else if ("bold".equals(s))
- {
- fontWeight = Text.TXWE_BOLD;
- }
- } else
- {
- fontWeight = Text.TXWE_NORMAL;
- }
+ protected void buildShapeInformation() throws SVGException
+ {
+ StyleAttribute sty = new StyleAttribute();
+ buildAttributes(sty);
+ fontInfo = FontUtil.parseFontInfo(this, sty);
+ font = FontUtil.getFont(fontInfo, diagram);
+ }
- //Get font
- Font font = diagram.getUniverse().getFont(fontFamily);
- if (font == null)
- {
- font = new FontSystem(fontFamily, fontStyle, fontWeight, (int)fontSize);
-// addShapeSysFont(addShape, font, fontFamily, fontSize, letterSpacing, cursor);
-// return;
- }
+ protected void buildTextShape(Cursor cursor) throws SVGException
+ {
+ buildShapeInformation();
- FontFace fontFace = font.getFontFace();
-// int ascent = fontFace.getAscent();
-// float fontScale = fontSize / (float) ascent;
+ fullPath = new GeneralPath();
- AffineTransform xform = new AffineTransform();
+ segments.clear();
+ segments.ensureCapacity(content.size());
+ int currentCursorOffset = cursor.offset;
+ cursor.offset = 0;
-// strokeWidthScalar = 1f / fontScale;
+ AffineTransform transform = new AffineTransform();
- float cursorX = (float)cursor.getX();
- float cursorY = (float)cursor.getY();
-
-// int i = 0;
+ float spaceAdvance = font.getGlyph(" ").getHorizAdvX();
- String drawText = this.text;
- drawText = drawText.trim();
- for (int i = 0; i < drawText.length(); i++)
+ for (Serializable obj : content)
{
- if (x != null && i < x.length)
- {
- cursorX = x[i];
- } else if (dx != null && i < dx.length)
+ if (obj instanceof String)
{
- cursorX += dx[i];
- }
-
- if (y != null && i < y.length)
- {
- cursorY = y[i];
- } else if (dy != null && i < dy.length)
+ String text = ((String) obj);
+ String trimmed = text.trim();
+ if (!text.isEmpty() && text.charAt(0) <= ' ')
+ cursor.x += font.getGlyph(" ").getHorizAdvX();
+ Path2D textPath = createStringSegmentPath(trimmed, font, cursor, transform);
+ if (!text.isEmpty() && text.charAt(text.length() - 1) <= ' ')
+ cursor.x += spaceAdvance;
+
+ fullPath.append(textPath, false);
+ segments.add(new TextSegment(textPath, this));
+ } else if (obj instanceof Tspan)
{
- cursorY += dy[i];
+ Tspan tspan = (Tspan) obj;
+ tspan.buildTextShape(cursor);
+ fullPath.append(tspan.fullPath, false);
+ segments.add(new TextSegment(null, (Tspan) obj));
}
- // i++;
-
- xform.setToIdentity();
- xform.setToTranslation(cursorX, cursorY);
-// xform.scale(fontScale, fontScale);
- if (rotate != null)
+ }
+
+ textBounds = fullPath.getBounds2D();
+ cursor.offset += currentCursorOffset;
+ }
+
+ private Path2D createStringSegmentPath(String text, Font font, Cursor cursor, AffineTransform xform)
+ {
+ Path2D textPath = new GeneralPath();
+
+ for (int i = 0; i < text.length(); i++)
+ {
+ // The positions are specified for the whole recursive content of a span.
+ // We need to account for any eventual text which occurred before.
+ cursor.x = getXCursorForIndex(cursor.x, cursor.offset + i);
+ cursor.y = getYCursorForIndex(cursor.y, cursor.offset + i);
+
+ xform.setToTranslation(cursor.x, cursor.y);
+ if (rotate != null && cursor.offset + i < rotate.length)
{
- xform.rotate(rotate[i]);
+ xform.rotate(rotate[cursor.offset + i]);
}
- String unicode = drawText.substring(i, i + 1);
+ String unicode = text.substring(i, i + 1);
MissingGlyph glyph = font.getGlyph(unicode);
Shape path = glyph.getPath();
if (path != null)
{
path = xform.createTransformedShape(path);
- addShape.append(path, false);
+ textPath.append(path, false);
}
-
-// cursorX += fontScale * glyph.getHorizAdvX() + letterSpacing;
- cursorX += glyph.getHorizAdvX() + letterSpacing;
+ cursor.x += glyph.getHorizAdvX() + fontInfo.letterSpacing;
}
+ cursor.offset += text.length();
- //Save final draw point so calling method knows where to begin next
- // text draw
- cursor.setLocation(cursorX, cursorY);
strokeWidthScalar = 1f;
+ return textPath;
}
-// private void addShapeSysFont(GeneralPath addShape, Font font,
-// String fontFamily, float fontSize, float letterSpacing, Point2D cursor)
-// {
-//
-// java.awt.Font sysFont = new java.awt.Font(fontFamily, java.awt.Font.PLAIN, (int) fontSize);
-//
-// FontRenderContext frc = new FontRenderContext(null, true, true);
-// String renderText = this.text.trim();
-//
-// AffineTransform xform = new AffineTransform();
-//
-// float cursorX = (float)cursor.getX();
-// float cursorY = (float)cursor.getY();
-//// int i = 0;
-// for (int i = 0; i < renderText.length(); i++)
-// {
-// if (x != null && i < x.length)
-// {
-// cursorX = x[i];
-// } else if (dx != null && i < dx.length)
-// {
-// cursorX += dx[i];
-// }
-//
-// if (y != null && i < y.length)
-// {
-// cursorY = y[i];
-// } else if (dy != null && i < dy.length)
-// {
-// cursorY += dy[i];
-// }
-//// i++;
-//
-// xform.setToIdentity();
-// xform.setToTranslation(cursorX, cursorY);
-// if (rotate != null)
-// {
-// xform.rotate(rotate[Math.min(i, rotate.length - 1)]);
-// }
-//
-//// String unicode = renderText.substring(i, i + 1);
-// GlyphVector textVector = sysFont.createGlyphVector(frc, renderText.substring(i, i + 1));
-// Shape glyphOutline = textVector.getGlyphOutline(0);
-// GlyphMetrics glyphMetrics = textVector.getGlyphMetrics(0);
-//
-// glyphOutline = xform.createTransformedShape(glyphOutline);
-// addShape.append(glyphOutline, false);
-//
-//
-//// cursorX += fontScale * glyph.getHorizAdvX() + letterSpacing;
-// cursorX += glyphMetrics.getAdvance() + letterSpacing;
-// }
-//
-// cursor.setLocation(cursorX, cursorY);
-// }
-
- public void render(Graphics2D g) throws SVGException
- {
- float cursorX = 0;
- float cursorY = 0;
-
- if (x != null)
- {
- cursorX = x[0];
- cursorY = y[0];
- } else if (dx != null)
- {
- cursorX += dx[0];
- cursorY += dy[0];
- }
-
- StyleAttribute sty = new StyleAttribute();
+ protected Cursor createInitialCursor()
+ {
+ return new Cursor(getXCursorForIndex(0, 0),
+ getYCursorForIndex(0, 0));
+ }
- String fontFamily = null;
- if (getPres(sty.setName("font-family")))
- {
- fontFamily = sty.getStringValue();
- }
+ private float getXCursorForIndex(float current, int index)
+ {
+ return getCursorForIndex(current, index, x, dx);
+ }
+ private float getYCursorForIndex(float current, int index)
+ {
+ return getCursorForIndex(current, index, y, dy);
+ }
- float fontSize = 12f;
- if (getPres(sty.setName("font-size")))
+ private float getCursorForIndex(float current, int index, float[] absolutes, float[] deltas)
+ {
+ if (absolutes != null && index < absolutes.length)
{
- fontSize = sty.getFloatValueWithUnits();
- }
-
- //Get font
- Font font = diagram.getUniverse().getFont(fontFamily);
- if (font == null)
+ current = absolutes[index];
+ } else if (deltas != null && index < deltas.length)
{
- System.err.println("Could not load font");
- java.awt.Font sysFont = new java.awt.Font(fontFamily, java.awt.Font.PLAIN, (int) fontSize);
- renderSysFont(g, sysFont);
- return;
+ current += deltas[index];
}
+ return current;
+ }
-
- FontFace fontFace = font.getFontFace();
- int ascent = fontFace.getAscent();
- float fontScale = fontSize / (float) ascent;
-
- AffineTransform oldXform = g.getTransform();
- AffineTransform xform = new AffineTransform();
-
- strokeWidthScalar = 1f / fontScale;
-
- int posPtr = 1;
-
- for (int i = 0; i < text.length(); i++)
- {
- xform.setToTranslation(cursorX, cursorY);
- xform.scale(fontScale, fontScale);
- g.transform(xform);
-
- String unicode = text.substring(i, i + 1);
- MissingGlyph glyph = font.getGlyph(unicode);
-
- Shape path = glyph.getPath();
- if (path != null)
+ @Override
+ protected void doRender(Graphics2D g) throws SVGException
+ {
+ beginLayer(g);
+ for (TextSegment segment : segments) {
+ if (segment.textPath != null)
{
- renderShape(g, path);
+ // Text portion of this span.
+ segment.element.renderShape(g, segment.textPath);
} else
{
- glyph.render(g);
- }
-
- if (x != null && posPtr < x.length)
- {
- cursorX = x[posPtr];
- cursorY = y[posPtr++];
- } else if (dx != null && posPtr < dx.length)
- {
- cursorX += dx[posPtr];
- cursorY += dy[posPtr++];
+ // Child span.
+ segment.element.doRender(g);
}
-
- cursorX += fontScale * glyph.getHorizAdvX();
-
- g.setTransform(oldXform);
}
-
- strokeWidthScalar = 1f;
- }
-
- protected void renderSysFont(Graphics2D g, java.awt.Font font) throws SVGException
- {
- float cursorX = 0;
- float cursorY = 0;
-
- int posPtr = 1;
- FontRenderContext frc = g.getFontRenderContext();
-
- Shape textShape = font.createGlyphVector(frc, text).getOutline(cursorX, cursorY);
- renderShape(g, textShape);
- Rectangle2D rect = font.getStringBounds(text, frc);
- cursorX += (float) rect.getWidth();
+ finishLayer(g);
}
+ @Override
public Shape getShape()
{
- return null;
- //return shapeToParent(tspanShape);
+ return shapeToParent(fullPath);
}
+ @Override
public Rectangle2D getBoundingBox()
{
- return null;
- //return boundsToParent(tspanShape.getBounds2D());
+ return boundsToParent(textBounds);
}
/**
@@ -473,6 +337,7 @@
* @return - true if this node has changed state as a result of the time
* update
*/
+ @Override
public boolean updateTime(double curTime) throws SVGException
{
//Tspan does not change
@@ -481,11 +346,50 @@
public String getText()
{
- return text;
+ return getText(new StringBuilder());
}
- public void setText(String text)
+ private String getText(StringBuilder builder)
{
- this.text = text;
+ for (Serializable serializable : content)
+ {
+ if (serializable instanceof Tspan)
+ {
+ ((Tspan) serializable).getText(builder);
+ builder.append(' ');
+ } else if (serializable != null)
+ {
+ builder.append(serializable).append(' ');
+ }
+ }
+ if (builder.length() > 0)
+ {
+ // Remove trailing space.
+ return builder.substring(0, builder.length() - 1);
+ } else
+ {
+ return "";
+ }
+ }
+
+ protected static class TextSegment {
+ final Path2D textPath;
+ final Tspan element;
+
+ private TextSegment(Path2D textPath, Tspan element) {
+ this.textPath = textPath;
+ this.element = element;
+ }
+ }
+
+ protected static class Cursor {
+ float x;
+ float y;
+ int offset;
+
+ public Cursor(float x, float y) {
+ this.x = x;
+ this.y = y;
+ }
}
}
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Use.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Use.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/Use.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/Use.java 2022-02-26 23:40:50.000000000 +0000
@@ -65,11 +65,13 @@
{
}
+ @Override
public String getTagName()
{
return TAG_NAME;
}
+ @Override
protected void build() throws SVGException
{
super.build();
@@ -108,7 +110,8 @@
refXform.translate(this.x, this.y);
}
- public void render(Graphics2D g) throws SVGException
+ @Override
+ protected void doRender(Graphics2D g) throws SVGException
{
beginLayer(g);
@@ -133,6 +136,7 @@
finishLayer(g);
}
+ @Override
public Shape getShape()
{
SVGElement ref = diagram.getUniverse().getElement(href);
@@ -147,6 +151,7 @@
return null;
}
+ @Override
public Rectangle2D getBoundingBox() throws SVGException
{
SVGElement ref = diagram.getUniverse().getElement(href);
@@ -173,6 +178,7 @@
* @return - true if this node has changed state as a result of the time
* update
*/
+ @Override
public boolean updateTime(double curTime) throws SVGException
{
// if (trackManager.getNumTracks() == 0) return false;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/util/Base64InputStream.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/util/Base64InputStream.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/util/Base64InputStream.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/util/Base64InputStream.java 2022-02-26 23:40:50.000000000 +0000
@@ -47,7 +47,7 @@
*/
public class Base64InputStream extends FilterInputStream implements Base64Consts
{
- static final HashMap lookup64 = new HashMap();
+ static final HashMap lookup64 = new HashMap();
static {
byte[] ch = BASE64_CHARS.getBytes();
for (int i = 0; i < ch.length; i++)
@@ -65,6 +65,7 @@
super(in);
}
+ @Override
public int read(byte[] b, int off, int len) throws IOException
{
for (int i = 0; i < len; ++i)
@@ -80,6 +81,7 @@
}
+ @Override
public int read() throws IOException
{
if (charsInBuf == 0)
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/util/Base64OutputStream.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/util/Base64OutputStream.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/util/Base64OutputStream.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/util/Base64OutputStream.java 2022-02-26 23:40:50.000000000 +0000
@@ -56,12 +56,14 @@
super(out);
}
+ @Override
public void close() throws IOException
{
writeBits();
super.close();
}
+ @Override
public void write(int b) throws IOException
{
buf = buf << 8 | (b & 0xff);
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/util/FontSystem.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/util/FontSystem.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/util/FontSystem.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/util/FontSystem.java 2022-02-26 23:40:50.000000000 +0000
@@ -39,12 +39,15 @@
import com.kitfox.svg.FontFace;
import com.kitfox.svg.Glyph;
import com.kitfox.svg.MissingGlyph;
-import java.awt.Canvas;
-import java.awt.FontMetrics;
+
+import java.awt.GraphicsEnvironment;
import java.awt.font.FontRenderContext;
import java.awt.font.GlyphMetrics;
import java.awt.font.GlyphVector;
+import java.awt.font.LineMetrics;
import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Locale;
/**
*
@@ -53,11 +56,56 @@
public class FontSystem extends Font
{
java.awt.Font sysFont;
- FontMetrics fm;
- HashMap glyphCache = new HashMap();
+ HashMap glyphCache = new HashMap<>();
+
+ static HashSet sysFontNames = new HashSet<>();
- public FontSystem(String fontFamily, int fontStyle, int fontWeight, int fontSize)
+ public static boolean checkIfSystemFontExists(String fontName)
+ {
+ if (sysFontNames.isEmpty())
+ {
+ for (String name: GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(Locale.ENGLISH))
+ {
+ sysFontNames.add(name);
+ }
+ }
+
+ return sysFontNames.contains(fontName);
+ }
+
+ public static FontSystem createFont(String[] fontFamilies, int fontStyle, int fontWeight, float fontSize)
+ {
+ for (String fontName: fontFamilies)
+ {
+ String javaFontName = mapJavaFontName(fontName);
+ if (checkIfSystemFontExists(javaFontName))
+ {
+ return new FontSystem(javaFontName, fontStyle, fontWeight, fontSize);
+ }
+ }
+
+ return null;
+ }
+
+ private static String mapJavaFontName(String fontName)
+ {
+ if ("serif".equals(fontName))
+ {
+ return java.awt.Font.SERIF;
+ }
+ else if ("sans-serif".equals(fontName))
+ {
+ return java.awt.Font.SANS_SERIF;
+ }
+ else if ("monospace".equals(fontName))
+ {
+ return java.awt.Font.MONOSPACED;
+ }
+ return fontName;
+ }
+
+ private FontSystem(String fontFamily, int fontStyle, int fontWeight, float fontSize)
{
int style;
switch (fontStyle)
@@ -81,18 +129,20 @@
weight = java.awt.Font.PLAIN;
break;
}
- sysFont = new java.awt.Font(fontFamily, style | weight, (int) fontSize);
-
- Canvas c = new Canvas();
- fm = c.getFontMetrics(sysFont);
+
+ sysFont = new java.awt.Font(fontFamily, style | weight, 1).deriveFont(fontSize);
+ FontRenderContext fontRenderContext = new FontRenderContext(null, true, true);
+ LineMetrics lineMetrics = sysFont.getLineMetrics("M", fontRenderContext);
+
FontFace face = new FontFace();
- face.setAscent(fm.getAscent());
- face.setDescent(fm.getDescent());
- face.setUnitsPerEm(fm.charWidth('M'));
+ face.setAscent((int) lineMetrics.getAscent());
+ face.setDescent((int) lineMetrics.getDescent());
+ face.setUnitsPerEm((int) sysFont.getStringBounds("M", fontRenderContext).getWidth());
setFontFace(face);
}
+ @Override
public MissingGlyph getGlyph(String unicode)
{
FontRenderContext frc = new FontRenderContext(null, true, true);
@@ -105,14 +155,14 @@
glyph.setPath(vec.getGlyphOutline(0));
GlyphMetrics gm = vec.getGlyphMetrics(0);
- glyph.setHorizAdvX((int)gm.getAdvanceX());
- glyph.setVertAdvY((int)gm.getAdvanceY());
+ glyph.setHorizAdvX(gm.getAdvanceX());
+ glyph.setVertAdvY(gm.getAdvanceY());
glyph.setVertOriginX(0);
glyph.setVertOriginY(0);
glyphCache.put(unicode, glyph);
}
-
+
return glyph;
}
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/util/FontUtil.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/util/FontUtil.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/util/FontUtil.java 1970-01-01 00:00:00.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/util/FontUtil.java 2022-02-26 23:40:50.000000000 +0000
@@ -0,0 +1,181 @@
+/*
+ * SVG Salamander
+ * Copyright (c) 2004, Mark McKay
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Mark McKay can be contacted at mark@kitfox.com. Salamander and other
+ * projects can be found at http://www.kitfox.com
+ */
+package com.kitfox.svg.util;
+
+import com.kitfox.svg.Font;
+import com.kitfox.svg.SVGDiagram;
+import com.kitfox.svg.SVGElement;
+import com.kitfox.svg.SVGException;
+import com.kitfox.svg.Text;
+import com.kitfox.svg.xml.StyleAttribute;
+
+import java.util.Arrays;
+import java.util.Objects;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Utility class for parsing font information of an {@link SVGElement}.
+ *
+ * @author Jannis Weis
+ */
+public final class FontUtil
+{
+
+ private static final String DEFAULT_FONT_FAMILY = "sans-serif";
+ private static final float DEFAULT_FONT_SIZE = 12f;
+ private static final int DEFAULT_LETTER_SPACING = 0;
+ private static final int DEFAULT_FONT_STYLE = Text.TXST_NORMAL;
+ private static final int DEFAULT_FONT_WEIGHT = Text.TXWE_NORMAL;
+
+ private FontUtil() {}
+
+ public final static class FontInfo {
+ public final String[] families;
+ public final float size;
+ public final int style;
+ public final int weight;
+ public final float letterSpacing;
+
+ public FontInfo(String[] families, float size, int style, int weight, float letterSpacing)
+ {
+ this.families = families;
+ this.size = size;
+ this.style = style;
+ this.weight = weight;
+ this.letterSpacing = letterSpacing;
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o) return true;
+ if (!(o instanceof FontInfo)) return false;
+ FontInfo fontInfo = (FontInfo) o;
+ return Float.compare(fontInfo.size, size) == 0
+ && style == fontInfo.style && weight == fontInfo.weight
+ && Float.compare(fontInfo.letterSpacing, letterSpacing) == 0
+ && Arrays.equals(families, fontInfo.families);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = Objects.hash(size, style, weight, letterSpacing);
+ result = 31 * result + Arrays.hashCode(families);
+ return result;
+ }
+ }
+
+ public static FontInfo parseFontInfo(SVGElement element, StyleAttribute sty) throws SVGException
+ {
+ String fontFamily = DEFAULT_FONT_FAMILY;
+ if (element.getStyle(sty.setName("font-family")))
+ {
+ fontFamily = sty.getStringValue();
+ }
+
+ float fontSize = DEFAULT_FONT_SIZE;
+ if (element.getStyle(sty.setName("font-size")))
+ {
+ fontSize = sty.getFloatValueWithUnits();
+ }
+
+ float letterSpacing = DEFAULT_LETTER_SPACING;
+ if (element.getStyle(sty.setName("letter-spacing")))
+ {
+ letterSpacing = sty.getFloatValueWithUnits();
+ }
+
+ int fontStyle = DEFAULT_FONT_STYLE;
+ if (element.getStyle(sty.setName("font-style")))
+ {
+ String s = sty.getStringValue();
+ if ("normal".equals(s))
+ {
+ fontStyle = Text.TXST_NORMAL;
+ } else if ("italic".equals(s))
+ {
+ fontStyle = Text.TXST_ITALIC;
+ } else if ("oblique".equals(s))
+ {
+ fontStyle = Text.TXST_OBLIQUE;
+ }
+ }
+
+ int fontWeight = DEFAULT_FONT_WEIGHT;
+ if (element.getStyle(sty.setName("font-weight")))
+ {
+ String s = sty.getStringValue();
+ if ("normal".equals(s))
+ {
+ fontWeight = Text.TXWE_NORMAL;
+ } else if ("bold".equals(s))
+ {
+ fontWeight = Text.TXWE_BOLD;
+ }
+ }
+
+ return new FontInfo(fontFamily.split(","), fontSize, fontStyle, fontWeight, letterSpacing);
+ }
+
+ public static Font getFont(FontInfo info, SVGDiagram diagram)
+ {
+ return getFont(info.families, info.style, info.weight, info.size, diagram);
+ }
+
+ private static Font getFont(String[] families, int fontStyle, int fontWeight, float fontSize, SVGDiagram diagram)
+ {
+ Font font = null;
+ for (String family : families)
+ {
+ font = diagram.getUniverse().getFont(family);
+ if (font != null) break;
+ }
+ if (font == null)
+ {
+ //Check system fonts
+ font = FontSystem.createFont(families, fontStyle, fontWeight, fontSize);
+ }
+ if (font == null)
+ {
+ Logger.getLogger(FontSystem.class.getName())
+ .log(Level.WARNING, "Could not create font " + Arrays.toString(families));
+ String[] defaultFont = new String[]{ FontUtil.DEFAULT_FONT_FAMILY };
+ font = FontSystem.createFont(defaultFont, fontStyle, fontWeight, fontSize);
+ }
+ return font;
+ }
+
+}
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/ColorTable.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/ColorTable.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/ColorTable.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/ColorTable.java 2022-02-26 23:40:50.000000000 +0000
@@ -48,9 +48,9 @@
public class ColorTable
{
- static final Map colorTable;
+ static final Map colorTable;
static {
- HashMap table = new HashMap();
+ HashMap table = new HashMap();
//We really should be interpreting the currentColor keyword as
// a reference to the referring node's color, but this quick hack
@@ -214,10 +214,7 @@
static public ColorTable instance() { return singleton; }
public Color lookupColor(String name) {
- Object obj = colorTable.get(name.toLowerCase());
- if (obj == null) return null;
-
- return (Color)obj;
+ return colorTable.get(name.toLowerCase());
}
public static Color parseColor(String val)
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/cpx/CPXInputStream.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/cpx/CPXInputStream.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/cpx/CPXInputStream.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/cpx/CPXInputStream.java 2022-02-26 23:40:50.000000000 +0000
@@ -74,7 +74,11 @@
byte[] inBuffer = new byte[2048];
byte[] decryptBuffer = new byte[2048];
- /** Creates a new instance of CPXInputStream */
+ /**
+ * Creates a new instance of CPXInputStream
+ * @param in
+ * @throws java.io.IOException
+ */
public CPXInputStream(InputStream in) throws IOException {
super(in);
@@ -97,6 +101,7 @@
/**
* We do not allow marking
*/
+ @Override
public boolean markSupported() { return false; }
/**
@@ -108,6 +113,7 @@
* @exception IOException if an I/O error occurs.
* @see java.io.FilterInputStream#in
*/
+ @Override
public void close() throws IOException {
reachedEOF = true;
in.close();
@@ -130,6 +136,7 @@
* @exception IOException if an I/O error occurs.
* @see java.io.FilterInputStream#in
*/
+ @Override
public int read() throws IOException
{
final byte[] b = new byte[1];
@@ -158,6 +165,7 @@
* @exception IOException if an I/O error occurs.
* @see java.io.FilterInputStream#read(byte[], int, int)
*/
+ @Override
public int read(byte[] b) throws IOException
{
return read(b, 0, b.length);
@@ -180,6 +188,7 @@
* @exception IOException if an I/O error occurs.
* @see java.io.FilterInputStream#in
*/
+ @Override
public int read(byte[] b, int off, int len) throws IOException
{
if (reachedEOF) return -1;
@@ -239,6 +248,7 @@
* Call when inflater indicates that it needs more bytes.
* @return - true if we decrypted more bytes to deflate, false if we
* encountered the end of stream
+ * @throws java.io.IOException
*/
protected boolean decryptChunk() throws IOException
{
@@ -259,11 +269,13 @@
* should not rely on this to determine the number of bytes that can be
* read without blocking.
*/
+ @Override
public int available() { return reachedEOF ? 0 : 1; }
/**
* Skips bytes by reading them into a cached buffer
*/
+ @Override
public long skip(long n) throws IOException
{
int skipSize = (int)n;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/cpx/CPXOutputStream.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/cpx/CPXOutputStream.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/cpx/CPXOutputStream.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/cpx/CPXOutputStream.java 2022-02-26 23:40:50.000000000 +0000
@@ -47,7 +47,11 @@
Deflater deflater = new Deflater(Deflater.BEST_COMPRESSION);
- /** Creates a new instance of CPXOutputStream */
+ /**
+ * Creates a new instance of CPXOutputStream
+ * @param os
+ * @throws java.io.IOException
+ */
public CPXOutputStream(OutputStream os) throws IOException {
super(os);
@@ -67,6 +71,7 @@
* @param b the byte.
* @exception IOException if an I/O error occurs.
*/
+ @Override
public void write(int b) throws IOException {
final byte[] buf = new byte[1];
buf[0] = (byte)b;
@@ -89,6 +94,7 @@
* @exception IOException if an I/O error occurs.
* @see java.io.FilterOutputStream#write(byte[], int, int)
*/
+ @Override
public void write(byte b[]) throws IOException {
write(b, 0, b.length);
}
@@ -115,6 +121,7 @@
* @exception IOException if an I/O error occurs.
* @see java.io.FilterOutputStream#write(int)
*/
+ @Override
public void write(byte b[], int off, int len) throws IOException
{
deflater.setInput(b, off, len);
@@ -152,6 +159,7 @@
* @exception IOException if an I/O error occurs.
* @see java.io.FilterOutputStream#out
*/
+ @Override
public void flush() throws IOException {
out.flush();
}
@@ -168,6 +176,7 @@
* @see java.io.FilterOutputStream#flush()
* @see java.io.FilterOutputStream#out
*/
+ @Override
public void close() throws IOException {
deflater.finish();
processAllData();
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/NumberWithUnits.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/NumberWithUnits.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/NumberWithUnits.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/NumberWithUnits.java 2022-02-26 23:40:50.000000000 +0000
@@ -122,11 +122,13 @@
}
}
+ @Override
public String toString()
{
return "" + value + unitsAsString(unitType);
}
+ @Override
public boolean equals(Object obj)
{
if (obj == null) {
@@ -145,6 +147,7 @@
return true;
}
+ @Override
public int hashCode()
{
int hash = 5;
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/ReadableXMLElement.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/ReadableXMLElement.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/ReadableXMLElement.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/ReadableXMLElement.java 2022-02-26 23:40:50.000000000 +0000
@@ -38,8 +38,6 @@
import org.w3c.dom.*;
import java.net.*;
-import java.util.*;
-import java.lang.reflect.*;
/**
* @author Mark McKay
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/StyleAttribute.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/StyleAttribute.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/StyleAttribute.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/StyleAttribute.java 2022-02-26 23:40:50.000000000 +0000
@@ -53,8 +53,7 @@
public static final long serialVersionUID = 0;
static final Pattern patternUrl = Pattern.compile("\\s*url\\((.*)\\)\\s*");
- static final Matcher matchFpNumUnits = Pattern.compile("\\s*([-+]?((\\d*\\.\\d+)|(\\d+))([-+]?[eE]\\d+)?)\\s*(px|cm|mm|in|pc|pt|em|ex)\\s*").matcher("");
-
+ static final Pattern patternFpNumUnits = Pattern.compile("\\s*([-+]?((\\d*\\.\\d+)|(\\d+))([-+]?[eE]\\d+)?)\\s*(px|cm|mm|in|pc|pt|em|ex)\\s*");
String name;
String stringValue;
@@ -140,9 +139,9 @@
}
public String getUnits() {
- matchFpNumUnits.reset(stringValue);
- if (!matchFpNumUnits.matches()) return null;
- return matchFpNumUnits.group(6);
+ Matcher m = patternFpNumUnits.matcher(stringValue);
+ if (!m.matches()) return null;
+ return m.group(6);
}
public NumberWithUnits getNumberWithUnits() {
@@ -154,6 +153,18 @@
NumberWithUnits number = getNumberWithUnits();
return convertUnitsToPixels(number.getUnits(), number.getValue());
}
+
+ public float[] getFloatListWithUnits()
+ {
+ String[] values = getStringList();
+ float[] result = new float[values.length];
+ for (int i = 0; i < result.length; i++)
+ {
+ NumberWithUnits number = XMLParseUtil.parseNumberWithUnits(stringValue);
+ result[i] = convertUnitsToPixels(number.getUnits(), number.getValue());
+ }
+ return result;
+ }
static public float convertUnitsToPixels(int unitType, float value)
{
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/StyleSheet.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/StyleSheet.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/StyleSheet.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/StyleSheet.java 2022-02-26 23:40:50.000000000 +0000
@@ -15,14 +15,14 @@
*/
public class StyleSheet
{
- HashMap ruleMap = new HashMap();
+ 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;
+ return new StyleSheet();
}
public void addStyleRule(StyleSheetRule rule, String value)
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/StyleSheetRule.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/StyleSheetRule.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/StyleSheetRule.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/StyleSheetRule.java 2022-02-26 23:40:50.000000000 +0000
@@ -21,6 +21,7 @@
this.className = className;
}
+ @Override
public int hashCode()
{
int hash = 7;
@@ -30,6 +31,7 @@
return hash;
}
+ @Override
public boolean equals(Object obj)
{
if (obj == null)
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/WritableXMLElement.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/WritableXMLElement.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/WritableXMLElement.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/WritableXMLElement.java 2022-02-26 23:40:50.000000000 +0000
@@ -36,11 +36,6 @@
package com.kitfox.svg.xml;
-import org.w3c.dom.*;
-import java.net.*;
-import java.util.*;
-import java.lang.reflect.*;
-
/**
* @author Mark McKay
* @author Mark McKay
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/XMLParseUtil.java svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/XMLParseUtil.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/com/kitfox/svg/xml/XMLParseUtil.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/com/kitfox/svg/xml/XMLParseUtil.java 2022-02-26 23:40:50.000000000 +0000
@@ -52,8 +52,10 @@
*/
public class XMLParseUtil
{
- static final Matcher fpMatch = Pattern.compile("([-+]?((\\d*\\.\\d+)|(\\d+))([eE][+-]?\\d+)?)(\\%|in|cm|mm|pt|pc|px|em|ex)?").matcher("");
- static final Matcher intMatch = Pattern.compile("[-+]?\\d+").matcher("");
+ static final Pattern fpPat = Pattern.compile("([-+]?((\\d*\\.\\d+)|(\\d+))([eE][+-]?\\d+)?)(\\%|in|cm|mm|pt|pc|px|em|ex)?");
+ static final Pattern intPat = Pattern.compile("[-+]?\\d+");
+ static final Pattern quotePat = Pattern.compile("^'|'$");
+
/** Creates a new instance of XMLParseUtil */
private XMLParseUtil()
@@ -81,7 +83,7 @@
}
/**
- * Returns the first node that is a direct child of root with the coresponding
+ * Returns the first node that is a direct child of root with the corresponding
* name. Does not search children of children.
*/
public static Element getFirstChild(Element root, String name)
@@ -105,7 +107,7 @@
final Matcher matchWs = Pattern.compile("[^\\s]+").matcher("");
matchWs.reset(list);
- LinkedList matchList = new LinkedList();
+ LinkedList matchList = new LinkedList();
while (matchWs.find())
{
matchList.add(matchWs.group());
@@ -117,8 +119,8 @@
public static boolean isDouble(String val)
{
- fpMatch.reset(val);
- return fpMatch.matches();
+ Matcher m = fpPat.matcher(val);
+ return m.matches();
}
public static double parseDouble(String val)
@@ -144,10 +146,10 @@
{
if (val == null) return 0;
- fpMatch.reset(val);
+ Matcher matcher = fpPat.matcher(val);
try
{
- if (!fpMatch.find()) return 0;
+ if (!matcher.find()) return 0;
}
catch (StringIndexOutOfBoundsException e)
{
@@ -155,7 +157,7 @@
"XMLParseUtil: regex parse problem: '" + val + "'", e);
}
- val = fpMatch.group(1);
+ val = matcher.group(1);
//System.err.println("Parsing " + val);
double retVal = 0;
@@ -173,7 +175,7 @@
pixPerInch = 72;
}
final float inchesPerCm = .3936f;
- final String units = fpMatch.group(6);
+ final String units = matcher.group(6);
if ("%".equals(units)) retVal /= 100;
else if ("in".equals(units))
@@ -211,18 +213,17 @@
public synchronized static double[] parseDoubleList(String list)
{
if (list == null) return null;
+ Matcher matcher = fpPat.matcher(list);
- fpMatch.reset(list);
-
- LinkedList doubList = new LinkedList();
- while (fpMatch.find())
+ LinkedList doubList = new LinkedList();
+ while (matcher.find())
{
- String val = fpMatch.group(1);
+ String val = matcher.group(1);
doubList.add(Double.valueOf(val));
}
double[] retArr = new double[doubList.size()];
- Iterator it = doubList.iterator();
+ Iterator it = doubList.iterator();
int idx = 0;
while (it.hasNext())
{
@@ -254,18 +255,17 @@
public synchronized static float findFloat(String val)
{
if (val == null) return 0f;
+ Matcher matcher = fpPat.matcher(val);
+ if (!matcher.find()) return 0f;
- fpMatch.reset(val);
- if (!fpMatch.find()) return 0f;
-
- val = fpMatch.group(1);
+ val = matcher.group(1);
//System.err.println("Parsing " + val);
float retVal = 0f;
try
{
retVal = Float.parseFloat(val);
- String units = fpMatch.group(6);
+ String units = matcher.group(6);
if ("%".equals(units)) retVal /= 100;
}
catch (Exception e)
@@ -276,18 +276,17 @@
public synchronized static float[] parseFloatList(String list)
{
if (list == null) return null;
+ Matcher matcher = fpPat.matcher(list);
- fpMatch.reset(list);
-
- LinkedList floatList = new LinkedList();
- while (fpMatch.find())
+ LinkedList floatList = new LinkedList();
+ while (matcher.find())
{
- String val = fpMatch.group(1);
+ String val = matcher.group(1);
floatList.add(Float.valueOf(val));
}
float[] retArr = new float[floatList.size()];
- Iterator it = floatList.iterator();
+ Iterator it = floatList.iterator();
int idx = 0;
while (it.hasNext())
{
@@ -316,11 +315,10 @@
public static int findInt(String val)
{
if (val == null) return 0;
+ Matcher matcher = intPat.matcher(val);
+ if (!matcher.find()) return 0;
- intMatch.reset(val);
- if (!intMatch.find()) return 0;
-
- val = intMatch.group();
+ val = matcher.group();
//System.err.println("Parsing " + val);
int retVal = 0;
@@ -334,18 +332,17 @@
public static int[] parseIntList(String list)
{
if (list == null) return null;
+ Matcher matcher = intPat.matcher(list);
- intMatch.reset(list);
-
- LinkedList intList = new LinkedList();
- while (intMatch.find())
+ LinkedList intList = new LinkedList();
+ while (matcher.find())
{
- String val = intMatch.group();
+ String val = matcher.group();
intList.add(Integer.valueOf(val));
}
int[] retArr = new int[intList.size()];
- Iterator it = intList.iterator();
+ Iterator it = intList.iterator();
int idx = 0;
while (it.hasNext())
{
@@ -514,7 +511,6 @@
{
String sval = ele.getAttribute(name);
- URL url;
try
{
return new URL(docRoot, sval);
@@ -528,7 +524,7 @@
/**
* Returns the first ReadableXMLElement with the given name
*/
- public static ReadableXMLElement getElement(Class classType, Element root, String name, URL docRoot)
+ public static ReadableXMLElement getElement(Class> classType, Element root, String name, URL docRoot)
{
if (root == null) return null;
@@ -573,7 +569,7 @@
* an attribute of tag 'name' who's string value will be used as the key
* in the HashMap
*/
- public static HashMap getElementHashMap(Class classType, Element root, String name, String key, URL docRoot)
+ public static HashMap getElementHashMap(Class> classType, Element root, String name, String key, URL docRoot)
{
if (root == null) return null;
@@ -583,7 +579,7 @@
return null;
}
- HashMap retMap = new HashMap();
+ HashMap retMap = new HashMap();
NodeList nl = root.getChildNodes();
int size = nl.getLength();
@@ -615,7 +611,7 @@
return retMap;
}
- public static HashSet getElementHashSet(Class classType, Element root, String name, URL docRoot)
+ public static HashSet getElementHashSet(Class> classType, Element root, String name, URL docRoot)
{
if (root == null) return null;
@@ -625,7 +621,7 @@
return null;
}
- HashSet retSet = new HashSet();
+ HashSet retSet = new HashSet();
NodeList nl = root.getChildNodes();
int size = nl.getLength();
@@ -660,7 +656,7 @@
}
- public static LinkedList getElementLinkedList(Class classType, Element root, String name, URL docRoot)
+ public static LinkedList getElementLinkedList(Class> classType, Element root, String name, URL docRoot)
{
if (root == null) return null;
@@ -671,7 +667,7 @@
}
NodeList nl = root.getChildNodes();
- LinkedList elementCache = new LinkedList();
+ LinkedList elementCache = new LinkedList();
int size = nl.getLength();
for (int i = 0; i < size; i++)
{
@@ -698,7 +694,7 @@
return elementCache;
}
- public static Object[] getElementArray(Class classType, Element root, String name, URL docRoot)
+ public static Object[] getElementArray(Class> classType, Element root, String name, URL docRoot)
{
if (root == null) return null;
@@ -708,7 +704,7 @@
return null;
}
- LinkedList elementCache = getElementLinkedList(classType, root, name, docRoot);
+ LinkedList elementCache = getElementLinkedList(classType, root, name, docRoot);
Object[] retArr = (Object[])Array.newInstance(classType, elementCache.size());
return elementCache.toArray(retArr);
@@ -724,7 +720,7 @@
if (root == null) return null;
NodeList nl = root.getChildNodes();
- LinkedList elementCache = new LinkedList();
+ LinkedList elementCache = new LinkedList();
int size = nl.getLength();
for (int i = 0; i < size; i++)
@@ -743,11 +739,11 @@
}
int[] retArr = new int[elementCache.size()];
- Iterator it = elementCache.iterator();
+ Iterator it = elementCache.iterator();
int idx = 0;
while (it.hasNext())
{
- retArr[idx++] = ((Integer)it.next()).intValue();
+ retArr[idx++] = it.next().intValue();
}
return retArr;
@@ -763,7 +759,7 @@
if (root == null) return null;
NodeList nl = root.getChildNodes();
- LinkedList elementCache = new LinkedList();
+ LinkedList elementCache = new LinkedList();
int size = nl.getLength();
for (int i = 0; i < size; i++)
@@ -779,11 +775,11 @@
}
String[] retArr = new String[elementCache.size()];
- Iterator it = elementCache.iterator();
+ Iterator it = elementCache.iterator();
int idx = 0;
while (it.hasNext())
{
- retArr[idx++] = (String)it.next();
+ retArr[idx++] = it.next();
}
return retArr;
@@ -794,8 +790,8 @@
* @param styleString - A CSS formatted string of styles. Eg,
* "font-size:12;fill:#d32c27;fill-rule:evenodd;stroke-width:1pt;"
*/
- public static HashMap parseStyle(String styleString) {
- return parseStyle(styleString, new HashMap());
+ public static HashMap parseStyle(String styleString) {
+ return parseStyle(styleString, new HashMap());
}
/**
@@ -804,7 +800,7 @@
* "font-size:12;fill:#d32c27;fill-rule:evenodd;stroke-width:1pt;"
* @param map - A map to which these styles will be added
*/
- public static HashMap parseStyle(String styleString, HashMap map) {
+ public static HashMap parseStyle(String styleString, HashMap map) {
final Pattern patSemi = Pattern.compile(";");
String[] styles = patSemi.split(styleString);
@@ -821,9 +817,8 @@
{
continue;
}
-
- String key = styles[i].substring(0, colon).trim();
- String value = styles[i].substring(colon + 1).trim();
+ String key = styles[i].substring(0, colon).trim().intern();
+ String value = quotePat.matcher(styles[i].substring(colon + 1).trim()).replaceAll("").intern();
map.put(key, new StyleAttribute(key, value));
}
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/main/java/module-info.java svgsalamander-1.1.4/svg-core/src/main/java/module-info.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/main/java/module-info.java 1970-01-01 00:00:00.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/main/java/module-info.java 2022-02-26 23:40:50.000000000 +0000
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2022, kitfox
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SEeRVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module com.kitfox.svgSalamander {
+ requires static ant;
+ requires static ant.launcher;
+ requires java.desktop;
+ requires java.xml;
+ requires java.logging;
+
+ exports com.kitfox.svg;
+ exports com.kitfox.svg.animation;
+ exports com.kitfox.svg.app;
+ exports com.kitfox.svg.app.ant;
+ exports com.kitfox.svg.app.beans;
+}
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/test/java/com/kitfox/salamander/javascript/JSTest.java svgsalamander-1.1.4/svg-core/src/test/java/com/kitfox/salamander/javascript/JSTest.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/test/java/com/kitfox/salamander/javascript/JSTest.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/test/java/com/kitfox/salamander/javascript/JSTest.java 1970-01-01 00:00:00.000000000 +0000
@@ -1,40 +0,0 @@
-/*
- * JSTest.java
- *
- * Created on April 16, 2007, 12:59 AM
- *
- * To change this template, choose Tools | Template Manager
- * and open the template in the editor.
- */
-
-package com.kitfox.salamander.javascript;
-
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
-import javax.script.ScriptException;
-
-/**
- * http://java.sun.com/developer/technicalArticles/J2SE/Desktop/scripting/
- *
- * @author kitfox
- */
-public class JSTest
-{
-
- /** Creates a new instance of JSTest */
- public JSTest()
- {
- ScriptEngineManager mgr = new ScriptEngineManager();
- ScriptEngine jsEngine = mgr.getEngineByName("JavaScript");
- try {
- jsEngine.eval("print('Hello, world!')");
- } catch (ScriptException ex) {
- ex.printStackTrace();
- }
- }
-
- public static void main(String[] args)
- {
- new JSTest();
- }
-}
diff -Nru svgsalamander-1.1.1+dfsg/svg-core/src/test/java/com/kitfox/svg/zip/ZipTestMain.java svgsalamander-1.1.4/svg-core/src/test/java/com/kitfox/svg/zip/ZipTestMain.java
--- svgsalamander-1.1.1+dfsg/svg-core/src/test/java/com/kitfox/svg/zip/ZipTestMain.java 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-core/src/test/java/com/kitfox/svg/zip/ZipTestMain.java 1970-01-01 00:00:00.000000000 +0000
@@ -1,76 +0,0 @@
-/*
- * ZipTestMain.java
- *
- * Created on July 18, 2007, 12:44 AM
- *
- * To change this template, choose Tools | Template Manager
- * and open the template in the editor.
- */
-
-package com.kitfox.svg.zip;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.util.zip.GZIPInputStream;
-
-/**
- *
- * @author kitfox
- */
-public class ZipTestMain
-{
-
- /** Creates a new instance of ZipTestMain */
- public ZipTestMain() throws IOException
- {
- URL url = ZipTestMain.class.getResource("/missing.svgz");
-// URL url = ZipTestMain.class.getResource("/AdamTagletClasses.svg");
- InputStream is = url.openStream();
- BufferedInputStream bin = new BufferedInputStream(is);
-
- bin.mark(2);
- int b0 = bin.read();
- int b1 = bin.read();
- bin.reset();
-
- InputStreamReader reader;
-
- //Check for gzip magic number
- if ((b1 << 8 | b0) == GZIPInputStream.GZIP_MAGIC)
- {
- GZIPInputStream iis = new GZIPInputStream(bin);
- reader = new InputStreamReader(iis);
- }
- else
- {
- //Plain text
- reader = new InputStreamReader(bin);
- }
-
-
- BufferedReader br = new BufferedReader(reader);
- for (String s = br.readLine(); s != null; s = br.readLine())
- {
- System.err.println(s);
- }
- }
-
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args)
- {
- try
- {
- new ZipTestMain();
- } catch (IOException ex)
- {
- ex.printStackTrace();
- }
- }
-
-}
diff -Nru svgsalamander-1.1.1+dfsg/svg-example/build.xml svgsalamander-1.1.4/svg-example/build.xml
--- svgsalamander-1.1.1+dfsg/svg-example/build.xml 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-example/build.xml 1970-01-01 00:00:00.000000000 +0000
@@ -1,73 +0,0 @@
-
-
-
-
-
-
-
-
-
-
- Builds, tests, and runs the project svg-example.
-
-
-
diff -Nru svgsalamander-1.1.1+dfsg/svg-example/nbproject/build-impl.xml svgsalamander-1.1.4/svg-example/nbproject/build-impl.xml
--- svgsalamander-1.1.1+dfsg/svg-example/nbproject/build-impl.xml 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-example/nbproject/build-impl.xml 1970-01-01 00:00:00.000000000 +0000
@@ -1,1444 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set src.res.dir
- Must set src.dir
- Must set test.src.dir
- Must set build.dir
- Must set dist.dir
- Must set build.classes.dir
- Must set dist.javadoc.dir
- Must set build.test.classes.dir
- Must set build.test.results.dir
- Must set build.classes.excludes
- Must set dist.jar
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- No tests executed.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set JVM to use for profiling in profiler.info.jvm
- Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- To run this application from the command line without Ant, try:
-
- java -jar "${dist.jar.resolved}"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set debug.class
-
-
-
-
- Must select one file in the IDE or set debug.class
-
-
-
-
- Must set fix.includes
-
-
-
-
-
-
-
-
-
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set profile.class
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
-
-
-
-
- This target only works when run from inside the NetBeans IDE.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
-
- Must select some files in the IDE or set test.includes
-
-
-
-
- Must select one file in the IDE or set run.class
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set javac.includes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Some tests failed; see details above.
-
-
-
-
-
-
-
-
- Must select some files in the IDE or set test.includes
-
-
-
- Some tests failed; see details above.
-
-
-
- Must select some files in the IDE or set test.class
- Must select some method in the IDE or set test.method
-
-
-
- Some tests failed; see details above.
-
-
-
-
- Must select one file in the IDE or set test.class
-
-
-
- Must select one file in the IDE or set test.class
- Must select some method in the IDE or set test.method
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
- Must select one file in the IDE or set applet.url
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff -Nru svgsalamander-1.1.1+dfsg/svg-example/nbproject/genfiles.properties svgsalamander-1.1.4/svg-example/nbproject/genfiles.properties
--- svgsalamander-1.1.1+dfsg/svg-example/nbproject/genfiles.properties 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-example/nbproject/genfiles.properties 1970-01-01 00:00:00.000000000 +0000
@@ -1,8 +0,0 @@
-build.xml.data.CRC32=5288c6a7
-build.xml.script.CRC32=0bbcf450
-build.xml.stylesheet.CRC32=8064a381@1.68.1.46
-# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
-# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=5288c6a7
-nbproject/build-impl.xml.script.CRC32=7ea6df96
-nbproject/build-impl.xml.stylesheet.CRC32=05530350@1.79.1.48
diff -Nru svgsalamander-1.1.1+dfsg/svg-example/nbproject/private/private.properties svgsalamander-1.1.4/svg-example/nbproject/private/private.properties
--- svgsalamander-1.1.1+dfsg/svg-example/nbproject/private/private.properties 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-example/nbproject/private/private.properties 1970-01-01 00:00:00.000000000 +0000
@@ -1,6 +0,0 @@
-compile.on.save=false
-do.depend=false
-do.jar=true
-javac.debug=true
-javadoc.preview=true
-user.properties.file=C:\\Users\\kitfox\\AppData\\Roaming\\NetBeans\\8.1\\build.properties
diff -Nru svgsalamander-1.1.1+dfsg/svg-example/nbproject/private/private.xml svgsalamander-1.1.4/svg-example/nbproject/private/private.xml
--- svgsalamander-1.1.1+dfsg/svg-example/nbproject/private/private.xml 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-example/nbproject/private/private.xml 1970-01-01 00:00:00.000000000 +0000
@@ -1,14 +0,0 @@
-
-
-
-
-
-
- file:/C:/dev/java.net/svgsalamander/trunk/svg-example/src/com/kitfox/svg/example/SimpleIconFrame.java
- file:/C:/dev/java.net/svgsalamander/trunk/svg-example/src/svgsalamandererror/icons/btn-settings.svg
- file:/C:/dev/java.net/svgsalamander/trunk/svg-example/src/svgsalamandererror/SvgSalamanderError.java
- file:/C:/dev/java.net/svgsalamander/trunk/svg-example/res/com/kitfox/svg/example/dor-32-gradient.svg
- file:/C:/dev/java.net/svgsalamander/trunk/svg-example/src/com/kitfox/svg/example/MenuIconTestFrame.java
-
-
-
diff -Nru svgsalamander-1.1.1+dfsg/svg-example/nbproject/private/retriever/catalog.xml svgsalamander-1.1.4/svg-example/nbproject/private/retriever/catalog.xml
--- svgsalamander-1.1.1+dfsg/svg-example/nbproject/private/retriever/catalog.xml 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-example/nbproject/private/retriever/catalog.xml 1970-01-01 00:00:00.000000000 +0000
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff -Nru svgsalamander-1.1.1+dfsg/svg-example/nbproject/private/retriever/creativecommons.org/ns.xml svgsalamander-1.1.4/svg-example/nbproject/private/retriever/creativecommons.org/ns.xml
--- svgsalamander-1.1.1+dfsg/svg-example/nbproject/private/retriever/creativecommons.org/ns.xml 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-example/nbproject/private/retriever/creativecommons.org/ns.xml 1970-01-01 00:00:00.000000000 +0000
@@ -1,401 +0,0 @@
-
-
-
-
-
-
- Describing Copyright in RDF - Creative Commons Rights Expression Language
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Describing Copyright in RDF
-
Creative Commons Rights Expression Language
-
-
-
-
The Creative Commons Rights Expression Language (CC
- REL) lets you describe copyright licenses in RDF.
- For more information on describing licenses in RDF
- and attaching those descriptions to digital works,
- see CC
- REL in
- the Creative
- Commons wiki.
-
-
-
Classes
-
-
-
Work
- a potentially
- copyrightable work
-
-
-
-
-
License
- a set of
- requests/permissions to users of a Work, e.g. a
- copyright license, the public domain, information
- for distributors
-
-
-
-
-
-
Jurisdiction
- the legal jurisdiction
- of a license
-
-
-
-
Permission
- an action that may or
- may not be allowed or desired
-
-
-
-
-
Requirement
- an action that may or
- may not be requested of you
-
-
-
-
-
Prohibition
- something you may be
- asked not to do
-
-
-
-
Permissions
-
-
-
Reproduction
- making multiple
- copies
-
-
-
-
-
Distribution
- distribution, public
- display, and publicly performance
-
-
-
-
-
Derivative Works
- distribution of
- derivative works
-
-
-
-
-
Sharing
- permits commercial
- derivatives, but only non-commercial
- distribution
-
-
-
Requirements
-
-
-
Notice
- copyright and license
- notices be kept intact
-
-
-
-
-
Attribution
- credit be given to
- copyright holder and/or author
-
-
-
-
-
Share Alike
- derivative works be
- licensed under the same terms or compatible terms
- as the original work
-
-
-
-
-
Source Code
- source code (the
- preferred form for making modifications) must be
- provided when exercising some rights granted by
- the license.
-
-
-
-
-
Copyleft
- derivative and
- combined works must be licensed under specified
- terms, similar to those on the original
- work
-
-
-
-
Lesser Copyleft
- derivative works must
- be licensed under specified terms, with at least
- the same conditions as the original work;
- combinations with the work may be licensed under
- different terms
-
-
diff -Nru svgsalamander-1.1.1+dfsg/svg-example/nbproject/private/retriever/www.w3.org/1999/02/22-rdf-syntax-ns.xml svgsalamander-1.1.4/svg-example/nbproject/private/retriever/www.w3.org/1999/02/22-rdf-syntax-ns.xml
--- svgsalamander-1.1.1+dfsg/svg-example/nbproject/private/retriever/www.w3.org/1999/02/22-rdf-syntax-ns.xml 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-example/nbproject/private/retriever/www.w3.org/1999/02/22-rdf-syntax-ns.xml 1970-01-01 00:00:00.000000000 +0000
@@ -1,141 +0,0 @@
-
-
-
- The RDF Vocabulary (RDF)
- This is the RDF Schema for the RDF vocabulary defined in the RDF namespace.
-
-
-
-
-
-
- PlainLiteral
- The class of plain (i.e. untyped) literal values.
-
-
-
-
-
-
- type
- The subject is an instance of a class.
-
-
-
-
-
-
- Property
- The class of RDF properties.
-
-
-
-
-
- Statement
-
- The class of RDF statements.
-
-
-
-
- subject
- The subject of the subject RDF statement.
-
-
-
-
-
-
- predicate
- The predicate of the subject RDF statement.
-
-
-
-
-
-
- object
- The object of the subject RDF statement.
-
-
-
-
-
-
- Bag
- The class of unordered containers.
-
-
-
-
-
- Seq
- The class of ordered containers.
-
-
-
-
-
- Alt
- The class of containers of alternatives.
-
-
-
-
-
- value
- Idiomatic property used for structured values.
-
-
-
-
-
-
-
-
- List
- The class of RDF Lists.
-
-
-
-
-
- nil
- The empty list, with no items in it. If the rest of a list is nil then the list has no more items in it.
-
-
-
-
- first
- The first item in the subject RDF list.
-
-
-
-
-
-
- rest
- The rest of the subject RDF list after the first item.
-
-
-
-
-
-
-
- XMLLiteral
- The class of XML literal values.
-
-
-
-
-
-
-
-
diff -Nru svgsalamander-1.1.1+dfsg/svg-example/nbproject/private/retriever/www.w3.org/1999/xlink svgsalamander-1.1.4/svg-example/nbproject/private/retriever/www.w3.org/1999/xlink
--- svgsalamander-1.1.1+dfsg/svg-example/nbproject/private/retriever/www.w3.org/1999/xlink 2016-08-20 09:47:17.000000000 +0000
+++ svgsalamander-1.1.4/svg-example/nbproject/private/retriever/www.w3.org/1999/xlink 1970-01-01 00:00:00.000000000 +0000
@@ -1,32 +0,0 @@
-
-
-
- XLink namespace
-
-
-
-
-
-This is an XML namespace, first defined in the
-Scalable Vector Graphics (SVG) 1.0 Specification and subsequently added to by SVG 1.1 and SVG 1.2. The SVG namespace is mutable; names may be added over time by the W3C SVG Working Group by publication in W3C Technical Reports.