deweese 01/12/13 17:07:50
Modified: sources/org/apache/batik/apps/svgbrowser FindDialog.java
sources/org/apache/batik/ext/awt/image GraphicsUtil.java
sources/org/apache/batik/ext/awt/image/rendered
AbstractTiledRed.java
sources/org/apache/batik/gvt PatternPaintContext.java
Log:
1) Fixed a bug with find and case insensitivity
2) Put in work arounds for several Mac OS X bugs.
Revision Changes Path
1.7 +14 -7
xml-batik/sources/org/apache/batik/apps/svgbrowser/FindDialog.java
Index: FindDialog.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/apps/svgbrowser/FindDialog.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- FindDialog.java 2001/10/05 15:34:26 1.6
+++ FindDialog.java 2001/12/14 01:07:50 1.7
@@ -69,7 +69,7 @@
* an SVG document.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a>
- * @version $Id: FindDialog.java,v 1.6 2001/10/05 15:34:26 tkormann Exp $
+ * @version $Id: FindDialog.java,v 1.7 2001/12/14 01:07:50 deweese Exp $
*/
public class FindDialog extends JDialog implements ActionMap {
@@ -288,6 +288,7 @@
gn = walker.nextGraphicsNode();
while (gn != null &&
((currentIndex = match(gn, text, currentIndex)) < 0)) {
+ currentIndex = 0;
gn = walker.nextGraphicsNode();
}
}
@@ -295,13 +296,12 @@
}
/**
- * Returns the index inside the specified TextNode of the specified text, or
- * -1 if not found.
+ * Returns the index inside the specified TextNode of the
+ * specified text, or -1 if not found.
*
* @param node the graphics node to check
* @param text the text use to match
- * @param index the index from which to start
- */
+ * @param index the index from which to start */
protected int match(GraphicsNode node, String text, int index) {
if (!(node instanceof TextNode)
|| !node.isVisible()
@@ -326,15 +326,22 @@
}
TextNode textNode = (TextNode)gn;
// mark the selection of the substring found
- String text = textNode.getText();
+ String text = textNode.getText();
String pattern = search.getText();
+ if (!caseSensitive.isSelected()) {
+ text = text.toLowerCase();
+ pattern = pattern.toLowerCase();
+ }
+ int end = text.indexOf(pattern, currentIndex);
+
AttributedCharacterIterator aci =
textNode.getAttributedCharacterIterator();
aci.first();
- for (int i=0; i < text.indexOf(pattern, currentIndex); ++i) {
+ for (int i=0; i < end; ++i) {
aci.next();
}
Mark startMark = textNode.getMarkerForChar(aci.getIndex(), true);
+
for (int i = 0; i < pattern.length()-1; ++i) {
aci.next();
}
1.22 +9 -2
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.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- GraphicsUtil.java 2001/12/05 13:46:04 1.21
+++ GraphicsUtil.java 2001/12/14 01:07:50 1.22
@@ -66,10 +66,13 @@
* implementations.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Thomas DeWeese</a>
- * @version $Id: GraphicsUtil.java,v 1.21 2001/12/05 13:46:04 deweese Exp $
+ * @version $Id: GraphicsUtil.java,v 1.22 2001/12/14 01:07:50 deweese Exp $
*/
public class GraphicsUtil {
+ public static boolean useMacOSXHacks =
+ ("Mac OS X".equals(System.getProperty("os.name")));
+
public static AffineTransform IDENTITY = new AffineTransform();
/**
@@ -283,7 +286,11 @@
// System.out.println("Starting Draw: " + cr);
long startTime = System.currentTimeMillis();
- if (false) {
+ if (useMacOSXHacks) {
+ // We use this code path on MacOSX since the tile
+ // drawing code below sometimes dies for no real
+ // reason this seems to behave better.
+
// org.ImageDisplay.showImage("foo: ", cr);
// This can be significantly faster but can also
// require much more memory.
1.12 +89 -28
xml-batik/sources/org/apache/batik/ext/awt/image/rendered/AbstractTiledRed.java
Index: AbstractTiledRed.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/ext/awt/image/rendered/AbstractTiledRed.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- AbstractTiledRed.java 2001/07/26 18:03:07 1.11
+++ AbstractTiledRed.java 2001/12/14 01:07:50 1.12
@@ -13,7 +13,9 @@
import java.util.Map;
import java.util.List;
import java.awt.Rectangle;
+import java.awt.Point;
+import java.awt.image.DataBufferInt;
import java.awt.image.Raster;
import java.awt.image.WritableRaster;
import java.awt.image.SampleModel;
@@ -26,7 +28,7 @@
* the subclass implementation.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Thomas DeWeese</a>
- * @version $Id: AbstractTiledRed.java,v 1.11 2001/07/26 18:03:07 deweese Exp $
+ * @version $Id: AbstractTiledRed.java,v 1.12 2001/12/14 01:07:50 deweese Exp $
*/
public abstract class AbstractTiledRed
extends AbstractRed
@@ -380,33 +382,7 @@
(insideTx0, insideTy0, xtiles, ytiles, occupied,
0, 0, xtiles, ytiles);
// System.out.println("Starting Splits");
- TileBlock [] blocks = block.getBestSplit();
-
- // System.out.println("Starting Computation: " + this);
- if (blocks != null)
- // System.out.println("Ending Splits: " + blocks.length);
-
- for (int i=0; i<blocks.length; i++) {
- TileBlock curr = blocks[i];
-
- // System.out.println("Block " + i + ":\n" + curr);
-
- int xloc = curr.getXLoc()*tileWidth +tileGridXOff;
- int yloc = curr.getYLoc()*tileHeight+tileGridYOff;
- Rectangle tb = new Rectangle(xloc, yloc,
- curr.getWidth()*tileWidth,
- curr.getHeight()*tileHeight);
- tb = tb.intersection(bounds);
-
- WritableRaster child =
- wr.createWritableChild(tb.x, tb.y, tb.width, tb.height,
- tb.x, tb.y, null);
- // System.out.println("Computing : " + child);
- genRect(child);
-
- if (Thread.currentThread().isInterrupted())
- return;
- }
+ drawBlock(block, wr);
// Exception e= new Exception("Foo");
// e.printStackTrace();
}
@@ -508,5 +484,90 @@
}
}
+ protected void drawBlock(TileBlock block, WritableRaster wr) {
+ TileBlock [] blocks = block.getBestSplit();
+ if (blocks == null)
+ return;
+
+ if (GraphicsUtil.useMacOSXHacks)
+ // Mac OS X doesn't properly handle child rasters that
+ // only reference part of the parent. In particular it
+ // appears to draw as if the childs X & Y were located at
+ // the parents upper left corner.
+ drawBlockAndCopy(blocks, wr);
+ else
+ drawBlockInPlace(blocks, wr);
+ }
+
+ protected void drawBlockAndCopy(TileBlock []blocks, WritableRaster wr) {
+ if (blocks.length == 1) {
+ TileBlock curr = blocks[0];
+ int xloc = curr.getXLoc()*tileWidth +tileGridXOff;
+ int yloc = curr.getYLoc()*tileHeight+tileGridYOff;
+ if ((xloc == wr.getMinX()) &&
+ (yloc == wr.getMinY())) {
+ // Safe to draw in place...
+ drawBlockInPlace(blocks, wr);
+ return;
+ }
+ }
+
+ int maxSz=0;
+ for (int i=0; i<blocks.length; i++) {
+ int sz = ((blocks[i].getWidth() *tileWidth)*
+ (blocks[i].getHeight()*tileHeight));
+ if (sz > maxSz) maxSz=sz;
+ }
+ DataBufferInt dbi = new DataBufferInt(maxSz);
+ int [] masks = { 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000 };
+ boolean use_INT_PACK = GraphicsUtil.is_INT_PACK_Data
+ (wr.getSampleModel(), false);
+
+ for (int i=0; i<blocks.length; i++) {
+ TileBlock curr = blocks[i];
+ int xloc = curr.getXLoc()*tileWidth +tileGridXOff;
+ int yloc = curr.getYLoc()*tileHeight+tileGridYOff;
+ Rectangle tb = new Rectangle(xloc, yloc,
+ curr.getWidth()*tileWidth,
+ curr.getHeight()*tileHeight);
+ tb = tb.intersection(bounds);
+ Point loc = new Point(tb.x, tb.y);
+ WritableRaster child = Raster.createPackedRaster
+ (dbi, tb.width, tb.height, tb.width, masks, loc);
+ genRect(child);
+ if (use_INT_PACK) GraphicsUtil.copyData_INT_PACK(child, wr);
+ else GraphicsUtil.copyData_FALLBACK(child, wr);
+
+ if (Thread.currentThread().isInterrupted())
+ return;
+ }
+ }
+
+
+ protected void drawBlockInPlace(TileBlock [] blocks, WritableRaster wr) {
+ // System.out.println("Ending Splits: " + blocks.length);
+
+ for (int i=0; i<blocks.length; i++) {
+ TileBlock curr = blocks[i];
+
+ // System.out.println("Block " + i + ":\n" + curr);
+
+ int xloc = curr.getXLoc()*tileWidth +tileGridXOff;
+ int yloc = curr.getYLoc()*tileHeight+tileGridYOff;
+ Rectangle tb = new Rectangle(xloc, yloc,
+ curr.getWidth()*tileWidth,
+ curr.getHeight()*tileHeight);
+ tb = tb.intersection(bounds);
+
+ WritableRaster child =
+ wr.createWritableChild(tb.x, tb.y, tb.width, tb.height,
+ tb.x, tb.y, null);
+ // System.out.println("Computing : " + child);
+ genRect(child);
+
+ if (Thread.currentThread().isInterrupted())
+ return;
+ }
+ }
}
1.8 +10 -2 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.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- PatternPaintContext.java 2001/09/17 20:45:18 1.7
+++ PatternPaintContext.java 2001/12/14 01:07:50 1.8
@@ -39,7 +39,7 @@
* paint implementation.
*
* @author <a href="[EMAIL PROTECTED]">Vincent Hardy</a>
- * @version $Id: PatternPaintContext.java,v 1.7 2001/09/17 20:45:18 deweese Exp $
+ * @version $Id: PatternPaintContext.java,v 1.8 2001/12/14 01:07:50 deweese Exp $
*/
public class PatternPaintContext implements PaintContext {
@@ -162,6 +162,14 @@
GraphicsUtil.coerceData(wr, tiled.getColorModel(),
rasterCM.isAlphaPremultiplied());
- return wr;
+ // On Mac OS X it always wants the raster at 0,0 if the
+ // requested width and height matches raster we can just
+ // return it. Otherwise we create a translated child that
+ // lives at 0,0.
+ if ((raster.getWidth() == width) &&
+ (raster.getHeight() == height))
+ return raster;
+
+ return wr.createTranslatedChild(0,0);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]