[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] alph ./Makefile org/nongnu/alph/ImageSpan.java ...
From: |
Tuomas J. Lukka |
Subject: |
[Gzz-commits] alph ./Makefile org/nongnu/alph/ImageSpan.java ... |
Date: |
Sun, 20 Apr 2003 04:50:03 -0400 |
CVSROOT: /cvsroot/alph
Module name: alph
Changes by: Tuomas J. Lukka <address@hidden> 03/04/20 04:50:02
Modified files:
. : Makefile
org/nongnu/alph: ImageSpan.java ScrollBlock.java
org/nongnu/alph/impl: FakeTextSpan.java PageImageScroll.java
PermanentTextScroll.java
ScrollBlockManager.java
SimpleImageScroll.java
TransientTextScroll.java
Added files:
org/nongnu/alph: BlockFile.java
org/nongnu/alph/impl: AbstractScrollBlock.java StdBlockFile.java
Log message:
Changes for actualy accessing the scrollblock data. This is working up
the way to allow image generation.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/alph/alph/Makefile.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/alph/alph/org/nongnu/alph/BlockFile.java?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/alph/alph/org/nongnu/alph/ImageSpan.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/alph/alph/org/nongnu/alph/ScrollBlock.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/alph/alph/org/nongnu/alph/impl/AbstractScrollBlock.java?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/alph/alph/org/nongnu/alph/impl/StdBlockFile.java?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/alph/alph/org/nongnu/alph/impl/FakeTextSpan.java.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/alph/alph/org/nongnu/alph/impl/PageImageScroll.java.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/alph/alph/org/nongnu/alph/impl/PermanentTextScroll.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/alph/alph/org/nongnu/alph/impl/ScrollBlockManager.java.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/alph/alph/org/nongnu/alph/impl/SimpleImageScroll.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/alph/alph/org/nongnu/alph/impl/TransientTextScroll.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
Patches:
Index: alph/Makefile
diff -u alph/Makefile:1.7 alph/Makefile:1.8
--- alph/Makefile:1.7 Mon Apr 7 12:00:13 2003
+++ alph/Makefile Sun Apr 20 04:50:02 2003
@@ -1,10 +1,11 @@
all: java test
+NAVIDOCCLASSDIR=../navidoc/CLASSES
STORMCLASSDIR=../storm/CLASSES
ALPH_DEPENDS=../alph-depends
-CLASSPATH=$(CLASSDIR):$(STORMCLASSDIR):$(ALPH_DEPENDS)/jython.jar:$(ALPH_DEPENDS)/collections-kaffe.jar:$(ALPH_DEPENDS)/xerces.jar:$(shell
echo $$CLASSPATH)
+CLASSPATH=$(CLASSDIR):$(NAVIDOCCLASSDIR):$(STORMCLASSDIR):$(ALPH_DEPENDS)/jython.jar:$(ALPH_DEPENDS)/collections-kaffe.jar:$(ALPH_DEPENDS)/xerces.jar:$(shell
echo $$CLASSPATH)
export CLASSPATH
RAWSRC = `find org/ -name "*.java"`
Index: alph/org/nongnu/alph/ImageSpan.java
diff -u alph/org/nongnu/alph/ImageSpan.java:1.2
alph/org/nongnu/alph/ImageSpan.java:1.3
--- alph/org/nongnu/alph/ImageSpan.java:1.2 Tue Mar 25 07:25:29 2003
+++ alph/org/nongnu/alph/ImageSpan.java Sun Apr 20 04:50:02 2003
@@ -36,16 +36,6 @@
public interface ImageSpan extends Span {
- /** Get a drawable image for this span.
- * This method may return null if image not yet loaded / created.
- * This is because we can't easily put ourselves into the
- * Java Image class.
- * <p>
- * The class which loads the images should naturally call
- * UpdateManager.chg() to
- */
-// Image getImage();
-
/** Get the location of this span in the mediaserver block.
*/
Point getLocation();
Index: alph/org/nongnu/alph/ScrollBlock.java
diff -u alph/org/nongnu/alph/ScrollBlock.java:1.2
alph/org/nongnu/alph/ScrollBlock.java:1.3
--- alph/org/nongnu/alph/ScrollBlock.java:1.2 Tue Mar 25 07:25:29 2003
+++ alph/org/nongnu/alph/ScrollBlock.java Sun Apr 20 04:50:02 2003
@@ -37,7 +37,12 @@
*/
public interface ScrollBlock {
-String rcsid = "$Id: ScrollBlock.java,v 1.2 2003/03/25 12:25:29 tjl Exp $";
+String rcsid = "$Id: ScrollBlock.java,v 1.3 2003/04/20 08:50:02 tjl Exp $";
+
+ /** Get the data of the scrollblock in a tmp file.
+ * May return null, if data not yet finalized.
+ */
+ BlockFile getBlockFile() throws java.io.FileNotFoundException;
/** Get the current contents of this block as a single span
* of the appropriate type.
@@ -47,7 +52,7 @@
/** Whether this block has been finalized or whether more
* can be appended.
*/
- boolean isFinalized();
+ boolean isPermanent();
/** Get the globally unique identifier of this block.
* XXX Exact semantics, tmp ids
Index: alph/org/nongnu/alph/impl/FakeTextSpan.java
diff -u alph/org/nongnu/alph/impl/FakeTextSpan.java:1.3
alph/org/nongnu/alph/impl/FakeTextSpan.java:1.4
--- alph/org/nongnu/alph/impl/FakeTextSpan.java:1.3 Tue Apr 15 23:44:23 2003
+++ alph/org/nongnu/alph/impl/FakeTextSpan.java Sun Apr 20 04:50:02 2003
@@ -38,7 +38,7 @@
*/
public class FakeTextSpan implements TextSpan, java.io.Serializable {
-public static final String rcsid = "$Id: FakeTextSpan.java,v 1.3 2003/04/16
03:44:23 tjl Exp $";
+public static final String rcsid = "$Id: FakeTextSpan.java,v 1.4 2003/04/20
08:50:02 tjl Exp $";
String text;
transient FakeTextScrollBlock sb;
@@ -104,7 +104,7 @@
public String getID() { return "" /*id*/; }
public Span getCurrent() { return FakeTextSpan.this; }
- public boolean isFinalized() { return true; }
+ public boolean isPermanent() { return true; }
public TextSpan append(char ch) throws ImmutableException {
throw new ImmutableException();
@@ -119,6 +119,9 @@
}
public Span getSpan(int offs, int len) {
return FakeTextSpan.this.subSpan(offs, offs+len);
+ }
+ public BlockFile getBlockFile() {
+ return null;
}
}
Index: alph/org/nongnu/alph/impl/PageImageScroll.java
diff -u alph/org/nongnu/alph/impl/PageImageScroll.java:1.3
alph/org/nongnu/alph/impl/PageImageScroll.java:1.4
--- alph/org/nongnu/alph/impl/PageImageScroll.java:1.3 Tue Apr 15 23:44:23 2003
+++ alph/org/nongnu/alph/impl/PageImageScroll.java Sun Apr 20 04:50:02 2003
@@ -38,9 +38,8 @@
/** An scrollblock containing paged media (PS/PDF).
*/
-public class PageImageScroll
- implements ScrollBlockManager.MediaserverScrollBlock {
-String rcsid = "$Id: PageImageScroll.java,v 1.3 2003/04/16 03:44:23 tjl Exp $";
+public class PageImageScroll extends AbstractScrollBlock {
+String rcsid = "$Id: PageImageScroll.java,v 1.4 2003/04/20 08:50:02 tjl Exp $";
public static boolean dbg = true;
final static void p(String s) { if(dbg) System.out.println(s); }
final static void pa(String s) { System.out.println(s); }
@@ -55,25 +54,17 @@
String DIR="../tmpimg/"; // XXX Non-platform-independent!
int pages;
- StormPool ms;
- BlockId id;
- public String getID() { return id.toString(); }
- public BlockId saveOrGetId(StormPool ms) { return id; }
public boolean equals(Object o) {
if(!(o instanceof ScrollBlock)) return false;
ScrollBlock sb = (ScrollBlock)o;
return sb.getID().equals(getID());
}
- public int hashCode() {
- return getID().hashCode();
- }
// Mediaserver.Block block;
public PageImageScroll(StormPool ms, BlockId id) {
- this.ms = ms;
- this.id = id;
+ super(ms, id);
checkLen();
}
@@ -121,8 +112,6 @@
return new SimplePageSpan(p0, p1, x, y, w, h);
}
-
- public boolean isFinalized() { return true; }
// ----- Spans ---
Index: alph/org/nongnu/alph/impl/PermanentTextScroll.java
diff -u alph/org/nongnu/alph/impl/PermanentTextScroll.java:1.2
alph/org/nongnu/alph/impl/PermanentTextScroll.java:1.3
--- alph/org/nongnu/alph/impl/PermanentTextScroll.java:1.2 Sat Apr 12
02:29:53 2003
+++ alph/org/nongnu/alph/impl/PermanentTextScroll.java Sun Apr 20 04:50:02 2003
@@ -35,36 +35,25 @@
/** A text scroll block loaded from somewhere.
*/
-public class PermanentTextScroll implements TextScrollBlock,
- ScrollBlockManager.MediaserverScrollBlock {
-String rcsid = "$Id: PermanentTextScroll.java,v 1.2 2003/04/12 06:29:53 tjl
Exp $";
+public class PermanentTextScroll extends AbstractScrollBlock
+ implements TextScrollBlock
+ {
+String rcsid = "$Id: PermanentTextScroll.java,v 1.3 2003/04/20 08:50:02 tjl
Exp $";
char[] chars;
-
- public PermanentTextScroll(String text) {
- this.chars = text.toCharArray();
- }
-
- StormPool ms;
- BlockId msid;
boolean loadingFailed;
public PermanentTextScroll(StormPool ms, BlockId msid) {
+ super(ms, msid);
this.ms = ms;
this.msid = msid;
}
- public String getID() { return msid.toString(); }
- public BlockId saveOrGetId(StormPool ms) { return msid; }
-
public boolean equals(Object o) {
if(!(o instanceof PermanentTextScroll)) return false;
ScrollBlock sb = (ScrollBlock)o;
return sb.getID().equals(getID());
}
- public int hashCode() {
- return getID().hashCode();
- }
protected final void load() {
if(chars != null || loadingFailed) return;
@@ -118,9 +107,6 @@
return new ScrollBlockManager.SimpleTextSpan(this, offs1, offs2);
}
- public boolean isFinalized() {
- return true;
- }
public char[] getCharArray() {
load();
Index: alph/org/nongnu/alph/impl/ScrollBlockManager.java
diff -u alph/org/nongnu/alph/impl/ScrollBlockManager.java:1.4
alph/org/nongnu/alph/impl/ScrollBlockManager.java:1.5
--- alph/org/nongnu/alph/impl/ScrollBlockManager.java:1.4 Sat Apr 12
02:29:53 2003
+++ alph/org/nongnu/alph/impl/ScrollBlockManager.java Sun Apr 20 04:50:02 2003
@@ -41,14 +41,14 @@
*/
public class ScrollBlockManager {
-String rcsid = "$Id: ScrollBlockManager.java,v 1.4 2003/04/12 06:29:53 tjl Exp
$";
+String rcsid = "$Id: ScrollBlockManager.java,v 1.5 2003/04/20 08:50:02 tjl Exp
$";
public static boolean dbg = false;
final static void p(String s) { if(dbg) System.out.println(s); }
final static void pa(String s) { System.out.println(s); }
/** A scrollblock that is associated with a Mediaserver block.
*/
- public interface MediaserverScrollBlock extends ScrollBlock {
+ public interface StormSaveableScrollBlock extends ScrollBlock {
/** Get the Mediaserver id of this block; save when not saved yet. */
BlockId saveOrGetId(StormPool ms) throws java.io.IOException;
}
@@ -58,8 +58,8 @@
*/
static abstract public class SpanBase implements Span,
java.io.Serializable {
- transient MediaserverScrollBlock sb;
- SpanBase(MediaserverScrollBlock sb) { this.sb = sb; }
+ transient ScrollBlock sb;
+ SpanBase(ScrollBlock sb) { this.sb = sb; }
public ScrollBlock getScrollBlock() { return sb; }
public String getScrollId() { return sb.getID(); }
@@ -102,7 +102,7 @@
/** Create a new 1-D span, which starts at offs0 and
* ends just before offs1 - analogous to String.substring.
*/
- protected Span1DBase(MediaserverScrollBlock sb, int offs0, int offs1) {
+ protected Span1DBase(ScrollBlock sb, int offs0, int offs1) {
super(sb);
this.offs0 = offs0;
this.offs1 = offs1;
@@ -195,7 +195,7 @@
static public class SimpleTextSpan extends Span1DBase
implements TextSpan, java.io.Serializable {
SimpleTextSpan(TextScrollBlock sb, int offs0, int offs1) {
- super((MediaserverScrollBlock)sb, offs0, offs1);
+ super(sb, offs0, offs1);
}
protected ScrollBlockManager.Span1DBase
@@ -214,7 +214,7 @@
static abstract public class ImageSpanBase extends SpanBase
implements ImageSpan {
protected final int x, y, w, h;
- ImageSpanBase(MediaserverScrollBlock sb, int x, int y, int w, int h) {
+ ImageSpanBase(ScrollBlock sb, int x, int y, int w, int h) {
super(sb);
this.x = x;
this.y = y;
@@ -269,7 +269,7 @@
static abstract public class PageSpanBase extends Span1DBase
implements PageSpan {
protected final int x, y, w, h;
- PageSpanBase(MediaserverScrollBlock sb, int page0, int page1,
+ PageSpanBase(ScrollBlock sb, int page0, int page1,
int x, int y, int w, int h) {
super(sb, page0, page1);
this.x = x;
@@ -443,13 +443,13 @@
* the headers of blocks...
* @return The scrollblock.
*/
- static public MediaserverScrollBlock getScrollBlock(StormPool ms,
+ static public ScrollBlock getScrollBlock(StormPool ms,
BlockId id,
boolean lazy)
throws CannotLoadScrollBlockException {
if(id == null)
throw new NullPointerException("cannot get block with id null");
- MediaserverScrollBlock b = (MediaserverScrollBlock)msCache.get(id);
+ ScrollBlock b = (ScrollBlock)msCache.get(id);
if(b == null) {
if(lazy)
return null;
@@ -460,13 +460,13 @@
return b;
}
- static public MediaserverScrollBlock getScrollBlock(StormPool ms,
+ static public ScrollBlock getScrollBlock(StormPool ms,
BlockId id)
throws CannotLoadScrollBlockException {
return getScrollBlock(ms, id, false);
}
- static private MediaserverScrollBlock loadScrollBlock(StormPool ms,
+ static private ScrollBlock loadScrollBlock(StormPool ms,
BlockId id)
throws CannotLoadScrollBlockException {
p("Loading scroll block: "+id);
@@ -495,27 +495,7 @@
+"'");
return new PermanentTextScroll(ms, id);
} else if(type.equals("image")) {
- Image img = null;
- try {
- img = java.awt.Toolkit.getDefaultToolkit().createImage(
- SlurpStream.slurp(block.getInputStream()));
- } catch (IOException _) {}
- if(img == null)
- throw new CannotLoadScrollBlockException("Unknown image type");
- int count = 0;
- while(img.getWidth(null) < 0 || img.getHeight(null) < 0) {
- try {
- count++;
- if(count > 50)
- throw new CannotLoadScrollBlockException("Timeout");
- Thread.sleep(200);
- } catch(InterruptedException e) {
- throw new Error("Interrupted");
- }
- }
- p("Loaded image scroll block.");
- return new SimpleImageScroll(id, img,
- img.getWidth(null), img.getHeight(null));
+ return new SimpleImageScroll(ms, id);
} else if(ct.equals("application/postscript") ||
ct.equals("application/pdf")) {
p("Loaded page image scroll block.");
Index: alph/org/nongnu/alph/impl/SimpleImageScroll.java
diff -u alph/org/nongnu/alph/impl/SimpleImageScroll.java:1.2
alph/org/nongnu/alph/impl/SimpleImageScroll.java:1.3
--- alph/org/nongnu/alph/impl/SimpleImageScroll.java:1.2 Sat Apr 12
02:29:53 2003
+++ alph/org/nongnu/alph/impl/SimpleImageScroll.java Sun Apr 20 04:50:02 2003
@@ -38,37 +38,20 @@
/** An image scrollblock
*/
-public class SimpleImageScroll
- implements ScrollBlockManager.MediaserverScrollBlock {
-String rcsid = "$Id: SimpleImageScroll.java,v 1.2 2003/04/12 06:29:53 tjl Exp
$";
+public class SimpleImageScroll extends AbstractScrollBlock {
+String rcsid = "$Id: SimpleImageScroll.java,v 1.3 2003/04/20 08:50:02 tjl Exp
$";
- final static String DIR="../mstmpimg/"; // XXX Platform dependent!
-
- Image im;
- int width, height;
-
- StormPool ms;
- BlockId id;
-
- public SimpleImageScroll(BlockId id, Image im, int width, int height) {
- this.id = id;
- this.im = im;
- this.width = width;
- this.height = height;
- }
-
- public SimpleImageScroll(Image im, int width, int height) {
- this( null, im, width, height );
- }
+ int width=-1, height=-1;
public SimpleImageScroll(StormPool ms, BlockId id) {
- this.ms = ms;
- this.id = id;
+ super(ms, id);
+ try {
+ ms.request(id, null);
+ } catch(IOException e) {
+ throw new Error("Couldn't load image block");
+ }
}
- public String getID() { return id.toString(); }
- public BlockId saveOrGetId(StormPool ms) { return id; }
-
public boolean equals(Object o) {
if(!(o instanceof ScrollBlock)) return false;
ScrollBlock sb = (ScrollBlock)o;
@@ -78,53 +61,32 @@
return getID().hashCode();
}
- public String imageFilename() {
- return new String(DIR+getID());
- }
-
- private void loadImage() {
- // Background.getDefaultInstance().addTask(
+ private void loadImageSize() {
- Runnable r = ( new Runnable() {
- public void run() {
- Block block ;
- String ct;
- try {
- block = ms.request(id, null);
- ct = id.getContentType();
- } catch(IOException e) {
- throw new Error("Couldn't load image block");
- }
-
- if(!ct.substring(0,ct.indexOf('/')).equals("image"))
- throw new Error("Block isn't an image");
-
- Image img = null;
- try {
- img = java.awt.Toolkit.getDefaultToolkit().createImage(
- SlurpStream.slurp(block.getInputStream()));
- } catch (IOException _) {}
- if(img == null)
- throw new Error("Unknown image type");
- int count = 0;
- while(img.getWidth(null) < 0 || img.getHeight(null) < 0) {
- try {
- count++;
- if(count > 100)
- throw new Error("Timeout");
- Thread.sleep(200);
- } catch(InterruptedException e) {
- throw new Error("Interrupted");
- }
- }
- SimpleImageScroll.this.im = img;
- SimpleImageScroll.this.width = img.getWidth(null);
- SimpleImageScroll.this.height = img.getHeight(null);
- }
- });
+ String ct = msid.getContentType();
+
+ if(!ct.substring(0,ct.indexOf('/')).equals("image"))
+ throw new Error("Block isn't an image");
+
+ Block block ;
+ Dimension d;
+ try {
+ block = ms.get(msid);
+ java.io.InputStream is = block.getInputStream();
+ d = org.nongnu.navidoc.util.ImageSize.readSize(is);
+ if(d == null)
+ throw new Error("Couldn't get size of image block");
+ is.close();
+
+ } catch(Exception e) {
+ throw new Error("Couldn't load image block");
+ }
+
+ this.width = d.width;
+ this.height = d.height;
}
- class SimpleImageSpan extends ScrollBlockManager.ImageSpanBase implements
Runnable{
+ class SimpleImageSpan extends ScrollBlockManager.ImageSpanBase {
SimpleImageSpan(int x, int y, int w, int h) {
super(SimpleImageScroll.this, x, y, w, h);
}
@@ -134,32 +96,10 @@
return new SimpleImageSpan(x, y, w, h);
}
- Image cached;
-
- public Image getImage() {
- if(cached != null) return cached;
- if(im == null) {
- loadImage();
- return null;
- }
- if(x==0 && y==0 && w==width && h==height)
- return im;
-
- // Background.getDefaultInstance().addTask(this);
- return null;
- }
-
- public void run() {
- if(cached != null) return;
-
- ImageFilter filter = new CropImageFilter(x,y,w,h);
- cached = java.awt.Toolkit.getDefaultToolkit().createImage
- (new FilteredImageSource(im.getSource(), filter));
- }
}
public Span getCurrent() {
- if(im == null) loadImage();
+ if(width < 0) loadImageSize();
return new SimpleImageSpan(0, 0, width, height);
}
@@ -168,7 +108,6 @@
}
- public boolean isFinalized() { return true; }
}
Index: alph/org/nongnu/alph/impl/TransientTextScroll.java
diff -u alph/org/nongnu/alph/impl/TransientTextScroll.java:1.2
alph/org/nongnu/alph/impl/TransientTextScroll.java:1.3
--- alph/org/nongnu/alph/impl/TransientTextScroll.java:1.2 Sat Apr 12
02:29:53 2003
+++ alph/org/nongnu/alph/impl/TransientTextScroll.java Sun Apr 20 04:50:02 2003
@@ -33,9 +33,13 @@
/** A text scroll block.
*/
-public class TransientTextScroll implements TextScrollBlock,
- ScrollBlockManager.MediaserverScrollBlock {
-String rcsid = "$Id: TransientTextScroll.java,v 1.2 2003/04/12 06:29:53 tjl
Exp $";
+public class TransientTextScroll extends AbstractScrollBlock
+ implements TextScrollBlock, ScrollBlockManager.StormSaveableScrollBlock
{
+String rcsid = "$Id: TransientTextScroll.java,v 1.3 2003/04/20 08:50:02 tjl
Exp $";
+
+ public TransientTextScroll() {
+ super(null, null);
+ }
boolean finalized = false;
BlockId mediaserverId = null;
@@ -85,14 +89,6 @@
this, offs1, offs2);
}
- public boolean isFinalized() {
- return finalized;
- }
-
- public String getID() {
- if(mediaserverId != null) return mediaserverId.toString();
- else return "";
- }
public BlockId saveOrGetId(StormPool saveTo)
throws java.io.IOException {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] alph ./Makefile org/nongnu/alph/ImageSpan.java ...,
Tuomas J. Lukka <=