[libbluray-devel] havi update

hpi1 git at videolan.org
Wed Nov 14 20:42:15 CET 2012


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Wed Sep 19 14:58:45 2012 +0300| [167946ecb31e2d2cb4f27f0bd07bc060b19743bb] | committer: hpi1

havi update
(merge from dslibbluray)

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=167946ecb31e2d2cb4f27f0bd07bc060b19743bb
---

 .../bdj/java/org/havi/ui/HBackgroundImage.java     |   79 +++++++++++++++++---
 1 file changed, 70 insertions(+), 9 deletions(-)

diff --git a/src/libbluray/bdj/java/org/havi/ui/HBackgroundImage.java b/src/libbluray/bdj/java/org/havi/ui/HBackgroundImage.java
index dacf31f..4b145f9 100644
--- a/src/libbluray/bdj/java/org/havi/ui/HBackgroundImage.java
+++ b/src/libbluray/bdj/java/org/havi/ui/HBackgroundImage.java
@@ -19,34 +19,95 @@
 
 package org.havi.ui;
 
+import java.awt.Image;
+import java.awt.Toolkit;
+import java.awt.image.ImageObserver;
+import java.awt.image.ImageProducer;
+import java.net.URL;
+import java.util.ArrayList;
+
+import org.havi.ui.event.HBackgroundImageEvent;
 import org.havi.ui.event.HBackgroundImageListener;
 
-public class HBackgroundImage {
+import sun.awt.image.ByteArrayImageSource;
+import sun.awt.image.FileImageSource;
+import sun.awt.image.URLImageSource;
+
+public class HBackgroundImage implements ImageObserver {
     public HBackgroundImage(String filename) {
-        throw new Error("Not implemented");
+        producer = new FileImageSource(filename);
+        img = Toolkit.getDefaultToolkit().createImage(producer);
     }
 
     public HBackgroundImage(byte pixels[]) {
-        throw new Error("Not implemented");
+        producer = new ByteArrayImageSource(pixels);
+        img = Toolkit.getDefaultToolkit().createImage(producer);
     }
 
-    public HBackgroundImage(java.net.URL contents) {
-        throw new Error("Not implemented");
+    public HBackgroundImage(URL contents) {
+        producer = new URLImageSource(contents);
+        img = Toolkit.getDefaultToolkit().createImage(producer);
     }
 
    public void load(HBackgroundImageListener listener) {
-        throw new Error("Not implemented");
+        synchronized(listeners) {
+            listeners.add(listener);
+        }
+        Toolkit.getDefaultToolkit().prepareImage(img, -1, -1, this);
     }
 
     public int getHeight() {
-        throw new Error("Not implemented");
+        return img.getHeight(null);
     }
 
     public int getWidth() {
-        throw new Error("Not implemented");
+        return img.getWidth(null);
     }
 
     public void flush() {
-        throw new Error("Not implemented");
+        img.flush();
     }
+
+    public boolean imageUpdate(Image img, int infoflags, int x, int y,
+                               int width, int height) {
+        switch(infoflags) {
+        case ImageObserver.ALLBITS:
+        case ImageObserver.FRAMEBITS:
+            notifyListeners(new HBackgroundImageEvent(this,
+                                                      HBackgroundImageEvent.BACKGROUNDIMAGE_LOADED));
+            return false;
+        case ImageObserver.ERROR:
+            notifyListeners(new HBackgroundImageEvent(this,
+                                                      HBackgroundImageEvent.BACKGROUNDIMAGE_INVALID));
+            return false;
+        case ImageObserver.ABORT:
+            notifyListeners(new HBackgroundImageEvent(this,
+                                                      HBackgroundImageEvent.BACKGROUNDIMAGE_IOERROR));
+            return false;
+        }
+        return true;
+    }
+
+    protected Image getImage() {
+        return img;
+    }
+
+    protected void notifyListeners(HBackgroundImageEvent event) {
+        ArrayList list;
+        synchronized(listeners) {
+            list = (ArrayList)listeners.clone();
+            listeners.clear();
+        }
+        for (int i = 0; i < list.size(); i++) {
+            HBackgroundImageListener listener = (HBackgroundImageListener)list.get(i);
+            if (event.getID()== HBackgroundImageEvent.BACKGROUNDIMAGE_LOADED)
+                listener.imageLoaded(event);
+            else
+                listener.imageLoadFailed(event);
+        }
+    }
+
+    private ImageProducer producer;
+    private Image img;
+    private ArrayList listeners = new ArrayList();
 }



More information about the libbluray-devel mailing list