/[alph]/alph/org/nongnu/alph/impl/ScrollBlockManager.java
ViewVC logotype

Diff of /alph/org/nongnu/alph/impl/ScrollBlockManager.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by tjl, Sat Apr 12 06:29:53 2003 UTC revision 1.5 by tjl, Sun Apr 20 08:50:02 2003 UTC
# Line 48  String rcsid = "$Id$"; Line 48  String rcsid = "$Id$";
48    
49      /** A scrollblock that is associated with a Mediaserver block.      /** A scrollblock that is associated with a Mediaserver block.
50       */       */
51      public interface MediaserverScrollBlock extends ScrollBlock {      public interface StormSaveableScrollBlock extends ScrollBlock {
52          /** Get the Mediaserver id of this block; save when not saved yet. */          /** Get the Mediaserver id of this block; save when not saved yet. */
53          BlockId saveOrGetId(StormPool ms) throws java.io.IOException;          BlockId saveOrGetId(StormPool ms) throws java.io.IOException;
54      }      }
# Line 58  String rcsid = "$Id$"; Line 58  String rcsid = "$Id$";
58       */       */
59      static abstract public class SpanBase implements Span,      static abstract public class SpanBase implements Span,
60                                               java.io.Serializable {                                               java.io.Serializable {
61          transient MediaserverScrollBlock sb;          transient ScrollBlock sb;
62          SpanBase(MediaserverScrollBlock sb) { this.sb = sb; }          SpanBase(ScrollBlock sb) { this.sb = sb; }
63          public ScrollBlock getScrollBlock() { return sb; }          public ScrollBlock getScrollBlock() { return sb; }
64          public String getScrollId() { return sb.getID(); }          public String getScrollId() { return sb.getID(); }
65    
# Line 102  String rcsid = "$Id$"; Line 102  String rcsid = "$Id$";
102          /** Create a new 1-D span, which starts at offs0 and          /** Create a new 1-D span, which starts at offs0 and
103           * ends just before offs1 - analogous to String.substring.           * ends just before offs1 - analogous to String.substring.
104           */           */
105          protected Span1DBase(MediaserverScrollBlock sb, int offs0, int offs1) {          protected Span1DBase(ScrollBlock sb, int offs0, int offs1) {
106              super(sb);              super(sb);
107              this.offs0 = offs0;              this.offs0 = offs0;
108              this.offs1 = offs1;              this.offs1 = offs1;
# Line 195  String rcsid = "$Id$"; Line 195  String rcsid = "$Id$";
195      static public class SimpleTextSpan extends Span1DBase      static public class SimpleTextSpan extends Span1DBase
196                                  implements TextSpan, java.io.Serializable {                                  implements TextSpan, java.io.Serializable {
197          SimpleTextSpan(TextScrollBlock sb, int offs0, int offs1) {          SimpleTextSpan(TextScrollBlock sb, int offs0, int offs1) {
198              super((MediaserverScrollBlock)sb, offs0, offs1);              super(sb, offs0, offs1);
199          }          }
200    
201          protected ScrollBlockManager.Span1DBase          protected ScrollBlockManager.Span1DBase
# Line 214  String rcsid = "$Id$"; Line 214  String rcsid = "$Id$";
214      static abstract public class ImageSpanBase extends SpanBase      static abstract public class ImageSpanBase extends SpanBase
215          implements ImageSpan {          implements ImageSpan {
216          protected final int x, y, w, h;          protected final int x, y, w, h;
217          ImageSpanBase(MediaserverScrollBlock sb, int x, int y, int w, int h) {          ImageSpanBase(ScrollBlock sb, int x, int y, int w, int h) {
218              super(sb);              super(sb);
219              this.x = x;              this.x = x;
220              this.y = y;              this.y = y;
# Line 269  String rcsid = "$Id$"; Line 269  String rcsid = "$Id$";
269      static abstract public class PageSpanBase extends Span1DBase      static abstract public class PageSpanBase extends Span1DBase
270                                  implements PageSpan {                                  implements PageSpan {
271          protected final int x, y, w, h;          protected final int x, y, w, h;
272          PageSpanBase(MediaserverScrollBlock sb, int page0, int page1,          PageSpanBase(ScrollBlock sb, int page0, int page1,
273                      int x, int y, int w, int h) {                      int x, int y, int w, int h) {
274              super(sb, page0, page1);              super(sb, page0, page1);
275              this.x = x;              this.x = x;
# Line 443  String rcsid = "$Id$"; Line 443  String rcsid = "$Id$";
443       * the headers of blocks...       * the headers of blocks...
444       * @return The scrollblock.       * @return The scrollblock.
445       */       */
446      static public MediaserverScrollBlock getScrollBlock(StormPool ms,      static public ScrollBlock getScrollBlock(StormPool ms,
447                                               BlockId id,                                               BlockId id,
448                                               boolean lazy)                                               boolean lazy)
449                          throws CannotLoadScrollBlockException {                          throws CannotLoadScrollBlockException {
450          if(id == null)          if(id == null)
451              throw new NullPointerException("cannot get block with id null");              throw new NullPointerException("cannot get block with id null");
452          MediaserverScrollBlock b = (MediaserverScrollBlock)msCache.get(id);          ScrollBlock b = (ScrollBlock)msCache.get(id);
453          if(b == null) {          if(b == null) {
454              if(lazy)              if(lazy)
455                  return null;                  return null;
# Line 460  String rcsid = "$Id$"; Line 460  String rcsid = "$Id$";
460          return b;          return b;
461      }      }
462    
463      static public MediaserverScrollBlock getScrollBlock(StormPool ms,      static public ScrollBlock getScrollBlock(StormPool ms,
464                                               BlockId id)                                               BlockId id)
465                          throws CannotLoadScrollBlockException {                          throws CannotLoadScrollBlockException {
466          return getScrollBlock(ms, id, false);          return getScrollBlock(ms, id, false);
467      }      }
468    
469      static private  MediaserverScrollBlock loadScrollBlock(StormPool ms,      static private  ScrollBlock loadScrollBlock(StormPool ms,
470                                                  BlockId id)                                                  BlockId id)
471                  throws CannotLoadScrollBlockException {                  throws CannotLoadScrollBlockException {
472          p("Loading scroll block: "+id);          p("Loading scroll block: "+id);
# Line 495  String rcsid = "$Id$"; Line 495  String rcsid = "$Id$";
495                              +"'");                              +"'");
496              return new PermanentTextScroll(ms, id);              return new PermanentTextScroll(ms, id);
497          } else if(type.equals("image")) {          } else if(type.equals("image")) {
498              Image img = null;              return new SimpleImageScroll(ms, id);
             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));  
499          } else if(ct.equals("application/postscript") ||          } else if(ct.equals("application/postscript") ||
500                    ct.equals("application/pdf")) {                    ct.equals("application/pdf")) {
501              p("Loaded page image scroll block.");              p("Loaded page image scroll block.");

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26