gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] alph/org/nongnu/alph/impl PageImageScroll.java ...


From: Tuomas J. Lukka
Subject: [Gzz-commits] alph/org/nongnu/alph/impl PageImageScroll.java ...
Date: Sat, 12 Apr 2003 02:29:53 -0400

CVSROOT:        /cvsroot/alph
Module name:    alph
Changes by:     Tuomas J. Lukka <address@hidden>        03/04/12 02:29:53

Modified files:
        org/nongnu/alph/impl: PageImageScroll.java 
                              PermanentTextScroll.java 
                              ScrollBlockManager.java 
                              SimpleImageScroll.java 
                              TransientTextScroll.java 

Log message:
        Port to storm

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/alph/alph/org/nongnu/alph/impl/PageImageScroll.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/alph/alph/org/nongnu/alph/impl/PermanentTextScroll.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/alph/alph/org/nongnu/alph/impl/ScrollBlockManager.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/SimpleImageScroll.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/alph/alph/org/nongnu/alph/impl/TransientTextScroll.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text

Patches:
Index: alph/org/nongnu/alph/impl/PageImageScroll.java
diff -u alph/org/nongnu/alph/impl/PageImageScroll.java:1.1 
alph/org/nongnu/alph/impl/PageImageScroll.java:1.2
--- alph/org/nongnu/alph/impl/PageImageScroll.java:1.1  Tue Mar 25 09:36:12 2003
+++ alph/org/nongnu/alph/impl/PageImageScroll.java      Sat Apr 12 02:29:53 2003
@@ -40,7 +40,7 @@
 
 public class PageImageScroll
        implements ScrollBlockManager.MediaserverScrollBlock {
-String rcsid = "$Id: PageImageScroll.java,v 1.1 2003/03/25 14:36:12 tjl Exp $";
+String rcsid = "$Id: PageImageScroll.java,v 1.2 2003/04/12 06:29:53 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,11 +55,11 @@
     String DIR="../mstmpimg/"; // XXX Non-platform-independent!
 
     int pages;
-    Mediaserver ms;
-    Mediaserver.Id id;
+    StormPool ms;
+    BlockId id;
 
-    public String getID() { return id.getString(); }
-    public Mediaserver.Id saveOrGetId(Mediaserver ms) { return 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;
@@ -71,7 +71,7 @@
     }
     //    Mediaserver.Block block;
 
-    public PageImageScroll(Mediaserver ms, Mediaserver.Id id) {
+    public PageImageScroll(StormPool ms, BlockId id) {
        this.ms = ms;
        this.id = id;
 
Index: alph/org/nongnu/alph/impl/PermanentTextScroll.java
diff -u alph/org/nongnu/alph/impl/PermanentTextScroll.java:1.1 
alph/org/nongnu/alph/impl/PermanentTextScroll.java:1.2
--- alph/org/nongnu/alph/impl/PermanentTextScroll.java:1.1      Tue Mar 25 
09:36:12 2003
+++ alph/org/nongnu/alph/impl/PermanentTextScroll.java  Sat Apr 12 02:29:53 2003
@@ -28,6 +28,7 @@
 
 package org.nongnu.alph.impl;
 import org.nongnu.alph.*;
+import org.nongnu.alph.util.*;
 import org.nongnu.storm.*;
 import java.io.*;
 
@@ -36,7 +37,7 @@
 
 public class PermanentTextScroll implements TextScrollBlock,
                   ScrollBlockManager.MediaserverScrollBlock {
-String rcsid = "$Id: PermanentTextScroll.java,v 1.1 2003/03/25 14:36:12 tjl 
Exp $";
+String rcsid = "$Id: PermanentTextScroll.java,v 1.2 2003/04/12 06:29:53 tjl 
Exp $";
 
     char[] chars;
 
@@ -44,17 +45,17 @@
         this.chars = text.toCharArray();
     }
 
-    Mediaserver ms;
-    Mediaserver.Id msid;
+    StormPool ms;
+    BlockId msid;
     boolean loadingFailed;
 
-    public PermanentTextScroll(Mediaserver ms, Mediaserver.Id msid) {
+    public PermanentTextScroll(StormPool ms, BlockId msid) {
        this.ms = ms;
        this.msid = msid;
     }
 
-    public String getID() { return msid.getString(); }
-    public Mediaserver.Id saveOrGetId(Mediaserver ms) { return 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;
@@ -68,11 +69,11 @@
     protected final void load() {
        if(chars != null || loadingFailed) return;
 
-        MediaserverBlock block ;
+        Block block ;
         String ct;
         try {
-            block = ms.getDatum(msid);
-            ct = block.getContentType();
+            block = ms.request(msid, null);
+            ct = msid.getContentType();
         } catch(IOException e) {
            loadingFailed = true;
            e.printStackTrace();
@@ -91,7 +92,7 @@
 
        String string;
        try {
-           string = new String(block.getBytes(), "UTF8");
+           string = new String(SlurpStream.slurp(block.getInputStream()), 
"UTF8");
        } catch(Exception e) {
            loadingFailed = true;
            e.printStackTrace();
Index: alph/org/nongnu/alph/impl/ScrollBlockManager.java
diff -u alph/org/nongnu/alph/impl/ScrollBlockManager.java:1.3 
alph/org/nongnu/alph/impl/ScrollBlockManager.java:1.4
--- alph/org/nongnu/alph/impl/ScrollBlockManager.java:1.3       Sun Apr  6 
06:55:59 2003
+++ alph/org/nongnu/alph/impl/ScrollBlockManager.java   Sat Apr 12 02:29:53 2003
@@ -28,6 +28,7 @@
 
 package org.nongnu.alph.impl;
 import org.nongnu.alph.*;
+import org.nongnu.alph.util.*;
 import org.nongnu.storm.*;
 import java.awt.Dimension;
 import java.awt.Point;
@@ -40,7 +41,7 @@
  */
 
 public class ScrollBlockManager {
-String rcsid = "$Id: ScrollBlockManager.java,v 1.3 2003/04/06 10:55:59 tjl Exp 
$";
+String rcsid = "$Id: ScrollBlockManager.java,v 1.4 2003/04/12 06:29:53 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); }
@@ -49,7 +50,7 @@
      */
     public interface MediaserverScrollBlock extends ScrollBlock {
         /** Get the Mediaserver id of this block; save when not saved yet. */
-        Mediaserver.Id saveOrGetId(Mediaserver ms) throws java.io.IOException;
+        BlockId saveOrGetId(StormPool ms) throws java.io.IOException;
     }
 
     /** A base class for physical spans that belong to one
@@ -374,7 +375,7 @@
        CannotLoadScrollBlockException() { super(); }
     }
 
-    public static Span getSpan(Mediaserver ms, Mediaserver.Id id,
+    public static Span getSpan(StormPool ms, BlockId id,
                               int x, int y, int w, int h) {
        SimpleImageScroll block = null;
        try {
@@ -389,7 +390,7 @@
        return block.getSpan(x, y, w, h);
     }
 
-    public static Span getSpan(Mediaserver ms, Mediaserver.Id id,
+    public static Span getSpan(StormPool ms, BlockId id,
                               int poffs, int plen, int x, int y, int w, int h) 
{
     
         int p0 = poffs, p1 = poffs+plen;
@@ -412,8 +413,8 @@
      *  scroll block. (We do know because we handle text transclusions
      *  in a special way.)
      */
-    static public TextScrollBlock getTextScrollBlock(Mediaserver ms,
-                                                    Mediaserver.Id id)
+    static public TextScrollBlock getTextScrollBlock(StormPool ms,
+                                                    BlockId id)
        throws CannotLoadScrollBlockException {
        if(id == null)
             throw new NullPointerException("cannot get block with id null");
@@ -442,8 +443,8 @@
      * the headers of blocks...
      * @return The scrollblock.
      */
-    static public MediaserverScrollBlock getScrollBlock(Mediaserver ms,
-                                            Mediaserver.Id id,
+    static public MediaserverScrollBlock getScrollBlock(StormPool ms,
+                                            BlockId id,
                                             boolean lazy)
                         throws CannotLoadScrollBlockException {
        if(id == null)
@@ -459,22 +460,23 @@
        return b;
     }
 
-    static public MediaserverScrollBlock getScrollBlock(Mediaserver ms,
-                                            Mediaserver.Id id)
+    static public MediaserverScrollBlock getScrollBlock(StormPool ms,
+                                            BlockId id)
                        throws CannotLoadScrollBlockException {
        return getScrollBlock(ms, id, false);
     }
 
-    static private  MediaserverScrollBlock loadScrollBlock(Mediaserver ms,
-                                               Mediaserver.Id id)
+    static private  MediaserverScrollBlock loadScrollBlock(StormPool ms,
+                                               BlockId id)
                throws CannotLoadScrollBlockException {
        p("Loading scroll block: "+id);
 
-       MediaserverBlock block ;
+       Block block ;
         String ct;
        try {
-           block = ms.getDatum(id);
-            ct = block.getContentType();
+           block = ms.request(id);
+           if(block == null) return null;
+            ct = id.getContentType();
        } catch(IOException e) {
            throw new CannotLoadScrollBlockException("Couldn't load block");
        }
@@ -495,7 +497,8 @@
        } else if(type.equals("image")) {
             Image img = null;
             try {
-                img = 
java.awt.Toolkit.getDefaultToolkit().createImage(block.getBytes());
+                img = java.awt.Toolkit.getDefaultToolkit().createImage(
+                       SlurpStream.slurp(block.getInputStream()));
             } catch (IOException _) {}
            if(img == null)
              throw new CannotLoadScrollBlockException("Unknown image type");
Index: alph/org/nongnu/alph/impl/SimpleImageScroll.java
diff -u alph/org/nongnu/alph/impl/SimpleImageScroll.java:1.1 
alph/org/nongnu/alph/impl/SimpleImageScroll.java:1.2
--- alph/org/nongnu/alph/impl/SimpleImageScroll.java:1.1        Tue Mar 25 
09:36:12 2003
+++ alph/org/nongnu/alph/impl/SimpleImageScroll.java    Sat Apr 12 02:29:53 2003
@@ -28,6 +28,7 @@
 
 package org.nongnu.alph.impl;
 import org.nongnu.alph.*;
+import org.nongnu.alph.util.*;
 import org.nongnu.storm.*;
 
 import java.io.IOException;
@@ -39,17 +40,17 @@
 
 public class SimpleImageScroll
        implements ScrollBlockManager.MediaserverScrollBlock {
-String rcsid = "$Id: SimpleImageScroll.java,v 1.1 2003/03/25 14:36:12 tjl Exp 
$";
+String rcsid = "$Id: SimpleImageScroll.java,v 1.2 2003/04/12 06:29:53 tjl Exp 
$";
 
     final static String DIR="../mstmpimg/"; // XXX Platform dependent!
 
     Image im;
     int width, height;
 
-    Mediaserver ms;
-    Mediaserver.Id id;
+    StormPool ms;
+    BlockId id;
 
-    public SimpleImageScroll(Mediaserver.Id id, Image im, int width, int 
height) {
+    public SimpleImageScroll(BlockId id, Image im, int width, int height) {
        this.id = id;
        this.im = im;
        this.width = width;
@@ -60,13 +61,13 @@
        this( null, im, width, height );
     }
 
-    public SimpleImageScroll(Mediaserver ms,  Mediaserver.Id id) {
+    public SimpleImageScroll(StormPool ms,  BlockId id) {
        this.ms = ms;
        this.id = id;
     }
 
-    public String getID() { return id.getString(); }
-    public Mediaserver.Id saveOrGetId(Mediaserver ms) { return 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;
@@ -86,11 +87,11 @@
        
        Runnable r = (  new Runnable() {
            public void run() {
-               MediaserverBlock block ;
+               Block block ;
                String ct;
                try {
-                   block = ms.getDatum(id);
-                   ct = block.getContentType();
+                   block = ms.request(id, null);
+                   ct = id.getContentType();
                } catch(IOException e) {
                    throw new Error("Couldn't load image block");
                }
@@ -100,7 +101,8 @@
 
                Image img = null;
                try {
-                   img = 
java.awt.Toolkit.getDefaultToolkit().createImage(block.getBytes());
+                   img = java.awt.Toolkit.getDefaultToolkit().createImage(
+                       SlurpStream.slurp(block.getInputStream()));
                } catch (IOException _) {}
                if(img == null)
                    throw new Error("Unknown image type");
Index: alph/org/nongnu/alph/impl/TransientTextScroll.java
diff -u alph/org/nongnu/alph/impl/TransientTextScroll.java:1.1 
alph/org/nongnu/alph/impl/TransientTextScroll.java:1.2
--- alph/org/nongnu/alph/impl/TransientTextScroll.java:1.1      Tue Mar 25 
09:36:12 2003
+++ alph/org/nongnu/alph/impl/TransientTextScroll.java  Sat Apr 12 02:29:53 2003
@@ -35,10 +35,10 @@
 
 public class TransientTextScroll implements TextScrollBlock,
                   ScrollBlockManager.MediaserverScrollBlock {
-String rcsid = "$Id: TransientTextScroll.java,v 1.1 2003/03/25 14:36:12 tjl 
Exp $";
+String rcsid = "$Id: TransientTextScroll.java,v 1.2 2003/04/12 06:29:53 tjl 
Exp $";
 
     boolean finalized = false;
-    Mediaserver.Id mediaserverId = null;
+    BlockId mediaserverId = null;
 
     final StringBuffer current = new StringBuffer();
     char[] curchars;
@@ -90,11 +90,11 @@
     }
 
     public String getID() {
-        if(mediaserverId != null) return mediaserverId.getString();
+        if(mediaserverId != null) return mediaserverId.toString();
        else return "";
     }
 
-    public Mediaserver.Id saveOrGetId(Mediaserver saveTo)
+    public BlockId saveOrGetId(StormPool saveTo)
                                throws java.io.IOException {
         if(finalized)
            return this.mediaserverId; // saved already
@@ -104,9 +104,14 @@
 
        byte[] bytes = current.toString().getBytes("UTF8");
        String content_type = "text/plain; charset=UTF-8";
+
+       BlockOutputStream stream = saveTo.getBlockOutputStream(content_type);
+       stream.write(bytes);
+       stream.close();
+
        finalized = true;
-       mediaserverId = saveTo.addDatum(bytes, content_type); //, assocId);
-       //id = mediaserverId.getString();
+       mediaserverId = stream.getBlockId();
+
        ScrollBlockManager.msCache.put(mediaserverId, this);
        return mediaserverId;
     }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]