You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by de...@apache.org on 2001/05/02 16:56:38 UTC
cvs commit: xml-batik/xdocs extendingBatik.xml
deweese 01/05/02 07:56:38
Modified: samples/tests patternRegions.svg
sources/org/apache/batik/ext/awt/image GraphicsUtil.java
sources/org/apache/batik/ext/awt/image/rendered
FloodRed.java TileRed.java
sources/org/apache/batik/gvt PatternPaint.java
PatternPaintContext.java
sources/org/apache/batik/gvt/filter GraphicsNodeRed8Bit.java
xdocs extendingBatik.xml
Added: sources/org/apache/batik/ext/awt/image/rendered
TileCacheRed.java
Log:
1) Several tweaks to the Pattern code. It still isn't as fast as I
would like, but I have convinced myself that there isn't anything
strictly wrong.
2) Updated patternRegions to have a more "normal" value for cx in
pattern #4.
3) Changed the way GraphicsUtil.drawImage works. It should now put
slightly less pressure on the TileCache in general.
Revision Changes Path
1.7 +2 -2 xml-batik/samples/tests/patternRegions.svg
Index: patternRegions.svg
===================================================================
RCS file: /home/cvs/xml-batik/samples/tests/patternRegions.svg,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- patternRegions.svg 2001/03/14 17:25:16 1.6
+++ patternRegions.svg 2001/05/02 14:56:21 1.7
@@ -15,7 +15,7 @@
<!-- work in Batik for patternRegions -->
<!-- -->
<!-- @author vhardy@eng.sun.com -->
-<!-- @version $Id: patternRegions.svg,v 1.6 2001/03/14 17:25:16 vhardy Exp $ -->
+<!-- @version $Id: patternRegions.svg,v 1.7 2001/05/02 14:56:21 deweese Exp $ -->
<!-- ========================================================================= -->
<?xml-stylesheet type="text/css" href="test.css" ?>
@@ -75,7 +75,7 @@
<pattern id="pattern4"
patternContentUnits="objectBoundingBox"
x="0" y="0" width=".75" height=".5" overflow="visible">
- <circle cx="25%" cy=".33333333" r=".25" style="fill:red" />
+ <circle cx="0.0556%" cy=".33333333" r=".25" style="fill:red" />
<rect x=".25" y=".33333333" width="0.375" height=".5" style="fill:green"/>
</pattern>
1.16 +8 -4 xml-batik/sources/org/apache/batik/ext/awt/image/GraphicsUtil.java
Index: GraphicsUtil.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/image/GraphicsUtil.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- GraphicsUtil.java 2001/04/30 22:01:02 1.15
+++ GraphicsUtil.java 2001/05/02 14:56:23 1.16
@@ -70,7 +70,7 @@
* implementations.
*
* @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
- * @version $Id: GraphicsUtil.java,v 1.15 2001/04/30 22:01:02 deweese Exp $
+ * @version $Id: GraphicsUtil.java,v 1.16 2001/05/02 14:56:23 deweese Exp $
*/
public class GraphicsUtil {
@@ -329,11 +329,13 @@
long startTime = System.currentTimeMillis();
yloc = yt0*th+cr.getTileGridYOffset();
+ int minX = xt0*tw+cr.getTileGridXOffset();
+ int xStep = tw;
+ xloc = minX;
for (int y=yt0; y<yt1; y++, yloc += th) {
if (yloc > endY) break;
- xloc = xt0*tw+cr.getTileGridXOffset();
- for (int x=xt0; x<xt1; x++, xloc+=tw) {
- if (xloc > endX) break;
+ for (int x=xt0; x<xt1; x++, xloc+=xStep) {
+ if ((xloc<minX) || (xloc > endX)) break;
tR.x = xloc;
tR.y = yloc;
Rectangle2D.intersect(crR, tR, iR);
@@ -359,6 +361,8 @@
g2d.drawImage(subBI, trans, null);
// big2d.fillRect(0, 0, tw, th);
}
+ xStep = -xStep; // Reverse directions.
+ xloc += xStep; // Get back in bounds.
}
long endTime = System.currentTimeMillis();
1.3 +4 -3 xml-batik/sources/org/apache/batik/ext/awt/image/rendered/FloodRed.java
Index: FloodRed.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/image/rendered/FloodRed.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FloodRed.java 2001/02/23 14:59:59 1.2
+++ FloodRed.java 2001/05/02 14:56:26 1.3
@@ -24,11 +24,12 @@
import java.awt.image.WritableRaster;
/**
- * This implementation of RenderableImage will render its input
- * GraphicsNode on demand for tiles.
+ * This implementation of RenderedImage will generate an infinate
+ * field of a single color. It reports bounds but will in fact render
+ * out to infinity.
*
* @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
- * @version $Id: FloodRed.java,v 1.2 2001/02/23 14:59:59 deweese Exp $
+ * @version $Id: FloodRed.java,v 1.3 2001/05/02 14:56:26 deweese Exp $
*/
public class FloodRed extends AbstractRed {
1.6 +42 -25 xml-batik/sources/org/apache/batik/ext/awt/image/rendered/TileRed.java
Index: TileRed.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/ext/awt/image/rendered/TileRed.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- TileRed.java 2001/04/19 21:30:49 1.5
+++ TileRed.java 2001/05/02 14:56:27 1.6
@@ -37,7 +37,7 @@
* left corner of the tiled region.
*
* @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
- * @version $Id: TileRed.java,v 1.5 2001/04/19 21:30:49 deweese Exp $
+ * @version $Id: TileRed.java,v 1.6 2001/05/02 14:56:27 deweese Exp $
*/
public class TileRed extends AbstractRed implements TileGenerator {
static final AffineTransform IDENTITY = new AffineTransform();
@@ -54,6 +54,8 @@
private RenderingHints hints;
+ final boolean is_INT_PACK;
+
/**
* Tile
*/
@@ -98,15 +100,29 @@
SampleModel sm = fixSampleModel(tile, tiledRegion);
ColorModel cm = tile.getColorModel();
-
- if ((2.0*sm.getWidth()*sm.getHeight()) > (xStep*(double)yStep))
- {
- sm = sm.createCompatibleSampleModel(xStep, yStep);
- raster = Raster.createWritableRaster
- (sm, new Point(tile.getMinX(), tile.getMinY()));
+ double smSz = sm.getWidth()*sm.getHeight();
+ double stepSz = (xStep*(double)yStep);
+ if (2.0*smSz > stepSz) {
+ int xSz = xStep;
+ int ySz = yStep;
+
+ // If the pattern size is small then have multiple copies
+ // in our tile.
+ if (4*stepSz < smSz) {
+ double mult = smSz/stepSz;
+ double sqrt = Math.sqrt(mult);
+ xSz *= (int)sqrt;
+ ySz *= (int)sqrt;
}
+
+ sm = sm.createCompatibleSampleModel(xSz, ySz);
+ raster = Raster.createWritableRaster
+ (sm, new Point(tile.getMinX(), tile.getMinY()));
+ }
+ is_INT_PACK = GraphicsUtil.is_INT_PACK_Data(sm, false);
+
// Initialize our base class We set our bounds be we will
// respond with data for any area we cover. This is needed
// because the userRegion passed into PatterPaintContext
@@ -132,9 +148,6 @@
int tx1 = getXTile(wr.getMinX()+wr.getWidth() -1);
int ty1 = getYTile(wr.getMinY()+wr.getHeight()-1);
- final boolean is_INT_PACK =
- GraphicsUtil.is_INT_PACK_Data(getSampleModel(), false);
-
for (int y=ty0; y<=ty1; y++)
for (int x=tx0; x<=tx1; x++) {
Raster r = getTile(x, y);
@@ -190,9 +203,10 @@
Graphics2D g = GraphicsUtil.createGraphics(bi, hints);
- int minX = wr.getMinX(), minY = wr.getMinY();
- int maxY = wr.getHeight();
+ int minX = wr.getMinX();
+ int minY = wr.getMinY();
int maxX = wr.getWidth();
+ int maxY = wr.getHeight();
g.setComposite(AlphaComposite.Clear);
@@ -205,23 +219,26 @@
// Process initial translate so that tile is
// painted to the left of the raster top-left
// corner on the first drawRenderedImage
- double tileTx, tileTy;
int x1 = src.getMinX()+src.getWidth()-1;
int y1 = src.getMinY()+src.getHeight()-1;
- tileTx = Math.ceil(((minX-x1)/xStep))*xStep;
- tileTy = Math.ceil(((minY-y1)/yStep))*yStep;
+ int tileTx = (int)Math.ceil(((minX-x1)/xStep))*xStep;
+ int tileTy = (int)Math.ceil(((minY-y1)/yStep))*yStep;
g.translate(tileTx, tileTy);
- double curX = tileTx - wr.getMinX() + src.getMinX();
- double curY = tileTy - wr.getMinY() + src.getMinY();
- int col = 0;
+ int curX = tileTx - wr.getMinX() + src.getMinX();
+ int curY = tileTy - wr.getMinY() + src.getMinY();
- // System.out.println("Src : " + src.getWidth()+"x"+src.getHeight());
+ // System.out.println("Wr: " + wr.getBounds());
+ // System.out.println("Src : [" + src.getMinX() + ", " +
+ // src.getMinY() + ", " +
+ // src.getWidth() + ", " +
+ // src.getHeight() + "]");
// System.out.println("tileTx/tileTy : " + tileTx + " / " + tileTy);
- while(curY <= maxY){
- while(curX <= maxX){
+ minX = curX;
+ while(curY <= maxY) {
+ while (curX <= maxX) {
// System.out.println("curX/curY : " + curX + " / " + curY);
// System.out.println("transform : " +
// g.getTransform().getTranslateX() +
@@ -230,12 +247,12 @@
GraphicsUtil.drawImage(g, src);
curX += xStep;
g.translate(xStep, 0);
- col++;
+ if (Thread.currentThread().isInterrupted())
+ return wr;
}
curY += yStep;
- g.translate(-col*xStep, yStep);
- curX -= col*xStep;
- col = 0;
+ g.translate(minX-curX, yStep);
+ curX = minX;
}
/*g.setTransform(new AffineTransform());
1.1 xml-batik/sources/org/apache/batik/ext/awt/image/rendered/TileCacheRed.java
Index: TileCacheRed.java
===================================================================
/*****************************************************************************
* Copyright (C) The Apache Software Foundation. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Apache Software License *
* version 1.1, a copy of which has been included with this distribution in *
* the LICENSE file. *
*****************************************************************************/
package org.apache.batik.ext.awt.image.rendered;
import java.awt.image.WritableRaster;
/**
* This implementation of RenderedImage only serves to put the tiles
* generated by it's input into the TileCache.
*
* @author <a href="mailto:thomas.deweese@kodak.com">Thomas DeWeese</a>
* @version $Id: TileCacheRed.java,v 1.1 2001/05/02 14:56:27 deweese Exp $
*/
public class TileCacheRed extends AbstractTiledRed {
/**
* Place the results of computations of cr into the global tile cache.
* @param cr The operation to cache results from.
*/
public TileCacheRed(CachableRed cr) {
super(cr, null);
}
public void genRect(WritableRaster wr) {
// Get my source.
CachableRed src = (CachableRed)getSources().get(0);
src.copyData(wr);
}
}
1.6 +3 -2 xml-batik/sources/org/apache/batik/gvt/PatternPaint.java
Index: PatternPaint.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/PatternPaint.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- PatternPaint.java 2001/03/26 21:27:36 1.5
+++ PatternPaint.java 2001/05/02 14:56:31 1.6
@@ -30,7 +30,7 @@
* Concrete implementation of the <tt>PatternPaint</tt> interface
*
* @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
- * @version $Id: PatternPaint.java,v 1.5 2001/03/26 21:27:36 deweese Exp $
+ * @version $Id: PatternPaint.java,v 1.6 2001/05/02 14:56:31 deweese Exp $
*/
public class PatternPaint implements Paint {
@@ -112,7 +112,8 @@
//
if(overflow){
Rectangle2D nodeBounds = comp.getBounds(gnrc);
- // System.out.println("Node Bounds : " + nodeBounds);
+ // System.out.println("Comp Bounds : " + nodeBounds);
+ // System.out.println("Node Bounds : " + node.getBounds(gnrc));
padBounds.add(nodeBounds);
}
1.5 +2 -1 xml-batik/sources/org/apache/batik/gvt/PatternPaintContext.java
Index: PatternPaintContext.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/PatternPaintContext.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- PatternPaintContext.java 2001/04/24 21:34:52 1.4
+++ PatternPaintContext.java 2001/05/02 14:56:32 1.5
@@ -30,13 +30,14 @@
import org.apache.batik.ext.awt.image.GraphicsUtil;
import org.apache.batik.ext.awt.image.renderable.Filter;
import org.apache.batik.ext.awt.image.renderable.TileRable8Bit;
+import org.apache.batik.ext.awt.image.rendered.TileCacheRed;
/**
* <tt>PaintContext</tt> for the <tt>ConcretePatterPaint</tt>
* paint implementation.
*
* @author <a href="vincent.hardy@eng.sun.com">Vincent Hardy</a>
- * @version $Id: PatternPaintContext.java,v 1.4 2001/04/24 21:34:52 deweese Exp $
+ * @version $Id: PatternPaintContext.java,v 1.5 2001/05/02 14:56:32 deweese Exp $
*/
public class PatternPaintContext implements PaintContext {
1.7 +2 -1 xml-batik/sources/org/apache/batik/gvt/filter/GraphicsNodeRed8Bit.java
Index: GraphicsNodeRed8Bit.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/filter/GraphicsNodeRed8Bit.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- GraphicsNodeRed8Bit.java 2001/04/19 21:30:49 1.6
+++ GraphicsNodeRed8Bit.java 2001/05/02 14:56:35 1.7
@@ -33,7 +33,7 @@
* GraphicsNode on demand for tiles.
*
* @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
- * @version $Id: GraphicsNodeRed8Bit.java,v 1.6 2001/04/19 21:30:49 deweese Exp $
+ * @version $Id: GraphicsNodeRed8Bit.java,v 1.7 2001/05/02 14:56:35 deweese Exp $
*/
public class GraphicsNodeRed8Bit extends AbstractTiledRed {
@@ -112,6 +112,7 @@
}
public void genRect(WritableRaster wr) {
+ // System.out.println(" Rect: " + wr.getBounds());
BufferedImage offScreen
= new BufferedImage(cm,
wr.createWritableTranslatedChild(0,0),
1.2 +68 -14 xml-batik/xdocs/extendingBatik.xml
Index: extendingBatik.xml
===================================================================
RCS file: /home/cvs/xml-batik/xdocs/extendingBatik.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- extendingBatik.xml 2001/04/30 05:03:35 1.1
+++ extendingBatik.xml 2001/05/02 14:56:37 1.2
@@ -1,31 +1,85 @@
<?xml version="1.0"?>
<!DOCTYPE document SYSTEM "./dtd/document-v10.dtd">
-<!-- ========================================================================= -->
-<!-- Copyright (C) The Apache Software Foundation. All rights reserved. -->
-<!-- -->
-<!-- This software is published under the terms of the Apache Software License -->
-<!-- version 1.1, a copy of which has been included with this distribution in -->
-<!-- the LICENSE file. -->
-<!-- ========================================================================= -->
-
-<!-- ========================================================================= -->
-<!-- author vincent.hardy@eng.sun.com -->
-<!-- version $Id: extendingBatik.xml,v 1.1 2001/04/30 05:03:35 vhardy Exp $ -->
-<!-- ========================================================================= -->
+<!-- ====================================================================== -->
+<!-- Copyright (C) The Apache Software Foundation. All rights reserved. -->
+<!-- -->
+<!-- This software is published under the terms of the Apache Software -->
+<!-- License version 1.1, a copy of which has been included with this -->
+<!-- distribution in the LICENSE file. -->
+<!-- ====================================================================== -->
+<!-- ====================================================================== -->
+<!-- author vincent.hardy@eng.sun.com -->
+<!-- version $Id: extendingBatik.xml,v 1.2 2001/05/02 14:56:37 deweese Exp $ -->
+<!-- ====================================================================== -->
+
<document>
<header>
<title>Extending Batik</title>
<subtitle>Possible extensions</subtitle>
<authors>
- <person name="Vincent Hardy" email="vincent.hardy@eng.sun.com"/>
+ <person name="Thomas DeWeese" email="thomas.deweese@kodak.com"/>
</authors>
</header>
<body>
<s1 title="Introduction">
- <p>TO BE WRITTEN (VH)</p>
+ <p>The goal of this section is to provide an overview of
+ the built in extension mechanisms in Batik. As an open
+ source project, people can of course make any extension
+ they feel is interesting, however Batik has been
+ designed with several forms of extension in mind.</p>
+
+ <p>The main areas extension are anticipated are:</p>
+ <ul>
+ <li><link href="#customXMLTags">
+ Support for custom XML Tags
+ </link></li>
+ <li><link href="#imageTagFormats">
+ Support for new file formats in the 'image' tag.
+ </link></li>
+ <li><link href="#urlProtocols">
+ Support for new protocols in URL references.
+ </link></li>
+ <li><link href="#transcoders">
+ Support for new Transcoders.
+ </link></li>
+ </ul>
+
+ <note>
+ If you feel that we have overlooked an important area for
+ extension please let your feelings be known on the mailing-lists.
+ </note>
+ </s1>
+
+ <s1 title="Custom XML Tags">
+ <p>
+ First one must ask "What does it mean to support custom
+ XML tags?"
+ </p>
+ <p>
+ If your only interest if for the custom tags to appear in
+ the SVG DOM tree, you need do nothing more than provide
+ appropriate namespacing and DTD(s) (ie. simply make your
+ new content well formed XML). Batik will ignore the parts
+ that aren't part of SVG.
+ </p>
+
+ <p>
+ If your interest is in having the new tag participate in
+ the generation of graphics then you must inform the Bridge
+ about your new tags.
+ </p>
+ </s1>
+
+ <s1 title="New File Formats">
+ </s1>
+
+ <s1 title="New Protocols">
+ </s1>
+
+ <s1 title="New Transcoders">
</s1>
</body>
</document>
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org