[prev in list] [next in list] [prev in thread] [next in thread]
List: batik-dev
Subject: cvs commit: xml-batik/sources/org/apache/batik/bridge SVGImageElementBridge.java
From: tkormann () apache ! org
Date: 2002-05-25 18:26:34
[Download RAW message or body]
tkormann 02/05/25 11:26:34
Modified: sources/org/apache/batik/bridge SVGImageElementBridge.java
Log:
- clean the code.
- remove the useless part which tries to reload the SVG image each time
an attribute is modified - by keeping a reference to the SVG image.
Revision Changes Path
1.46 +15 -38 xml-batik/sources/org/apache/batik/bridge/SVGImageElementBridge.java
Index: SVGImageElementBridge.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGImageElementBridge.java,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- SVGImageElementBridge.java 25 May 2002 18:08:41 -0000 1.45
+++ SVGImageElementBridge.java 25 May 2002 18:26:34 -0000 1.46
@@ -55,10 +55,12 @@
* Bridge class for the <image> element.
*
* @author <a href="mailto:tkormann@apache.org">Thierry Kormann</a>
- * @version $Id: SVGImageElementBridge.java,v 1.45 2002/05/25 18:08:41 tkormann Exp $
+ * @version $Id: SVGImageElementBridge.java,v 1.46 2002/05/25 18:26:34 tkormann Exp $
*/
public class SVGImageElementBridge extends AbstractGraphicsNodeBridge {
+ protected SVGDocument imgDocument;
+
/**
* Constructs a new bridge for the <image> element.
*/
@@ -112,7 +114,7 @@
try {
Node n = resolver.getNode(uriStr, e);
if (n.getNodeType() == n.DOCUMENT_NODE) {
- SVGDocument imgDocument = (SVGDocument)n;
+ imgDocument = (SVGDocument)n;
node = createSVGImageNode(ctx, e, imgDocument);
}
} catch (BridgeException ex) {
@@ -206,8 +208,7 @@
Rectangle2D bounds = getImageBounds(ctx, e);
GraphicsNode imageNode = ((ImageNode)node).getImage();
float [] vb = null;
-
- if (((ImageNode)node).getImage() instanceof RasterImageNode) {
+ if (imageNode instanceof RasterImageNode) {
//Raster image
Rectangle2D imgBounds =
((RasterImageNode)imageNode).getImageBounds();
@@ -220,43 +221,19 @@
vb[2] = (float)imgBounds.getWidth(); // width
vb[3] = (float)imgBounds.getHeight(); // height
} else {
- // svg image need the viewbox of the embedded
- String uriStr = XLinkSupport.getXLinkHref(e);
- if ( uriStr == null || uriStr.length() == 0 ){
- throw new BridgeException(e, ERR_ATTRIBUTE_MISSING,
- new Object[] {"xlink:href"});
- }
- // try to load the image as an svg document
- SVGDocument svgDoc = (SVGDocument)e.getOwnerDocument();
- // try to load an SVG document
- DocumentLoader loader = ctx.getDocumentLoader();
- URIResolver resolver = new URIResolver(svgDoc, loader);
- SVGDocument imgDocument = null;
- try {
- Node n = resolver.getNode(uriStr, e);
- if (n.getNodeType() == n.DOCUMENT_NODE) {
- imgDocument = (SVGDocument)n;
- }
- } catch (BridgeException ex) {
- throw ex;
- } catch (Exception ex) {
- /* Nothing to do */
- }
if (imgDocument != null) {
Element svgElement = imgDocument.getRootElement();
- String viewBox =
- svgElement.getAttributeNS(null, SVG_VIEW_BOX_ATTRIBUTE);
+ String viewBox = svgElement.getAttributeNS
+ (null, SVG_VIEW_BOX_ATTRIBUTE);
vb = ViewBox.parseViewBoxAttribute(e, viewBox);
- } else {
- imageNode = null;
- }
- }
- if (imageNode != null) {
- // handles the 'preserveAspectRatio', 'overflow' and
- // 'clip' and sets the appropriate AffineTransform to
- // the image node
- initializeViewport(ctx, e, imageNode, vb, bounds);
- }
+ }
+ }
+ if (imageNode != null) {
+ // handles the 'preserveAspectRatio', 'overflow' and
+ // 'clip' and sets the appropriate AffineTransform to
+ // the image node
+ initializeViewport(ctx, e, imageNode, vb, bounds);
+ }
} else {
super.handleDOMAttrModifiedEvent(evt);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic