diff --git a/sources/net.sf.j2s.core/dist/swingjs/timestamp b/sources/net.sf.j2s.core/dist/swingjs/timestamp index 738cf75af..991a13b41 100644 --- a/sources/net.sf.j2s.core/dist/swingjs/timestamp +++ b/sources/net.sf.j2s.core/dist/swingjs/timestamp @@ -1 +1 @@ -20200417142842 +20200419115937 diff --git a/sources/net.sf.j2s.core/dist/swingjs/ver/3.2.9/timestamp b/sources/net.sf.j2s.core/dist/swingjs/ver/3.2.9/timestamp index 738cf75af..991a13b41 100644 --- a/sources/net.sf.j2s.core/dist/swingjs/ver/3.2.9/timestamp +++ b/sources/net.sf.j2s.core/dist/swingjs/ver/3.2.9/timestamp @@ -1 +1 @@ -20200417142842 +20200419115937 diff --git a/sources/net.sf.j2s.java.core/src/java/awt/image/BufferedImage.java b/sources/net.sf.j2s.java.core/src/java/awt/image/BufferedImage.java index 0cae97a10..d342a2e35 100644 --- a/sources/net.sf.j2s.java.core/src/java/awt/image/BufferedImage.java +++ b/sources/net.sf.j2s.java.core/src/java/awt/image/BufferedImage.java @@ -50,6 +50,7 @@ import swingjs.JSGraphics2D; import swingjs.JSGraphicsCompositor; import swingjs.JSUtil; +import swingjs.api.JSUtilI; import swingjs.api.js.DOMNode; import swingjs.api.js.HTML5Canvas; @@ -250,7 +251,7 @@ public class BufferedImage extends Image implements RenderedImage, Transparency * in a single byte array in the order B, G, R, A from lower to higher byte * addresses within each pixel. */ - public static final int TYPE_4BYTE_HTML5 = -6; + public static final int TYPE_4BYTE_HTML5 = JSUtilI.TYPE_4BYTE_HTML5; /** * Represents an image with 8-bit RGBA color components with the colors Blue, * Green, and Red stored in 3 bytes and 1 byte of alpha. The image has a @@ -389,6 +390,9 @@ public class BufferedImage extends Image implements RenderedImage, Transparency * @see #TYPE_USHORT_555_RGB */ public BufferedImage(int width, int height, int imageType) { + 秘init(width, height, imageType); + } + protected void 秘init(int width, int height, int imageType) { this.width = width; this.height = height; 秘wxh = width * height; diff --git a/sources/net.sf.j2s.java.core/src/java/io/File.java b/sources/net.sf.j2s.java.core/src/java/io/File.java index d95fb9d07..37a042a08 100644 --- a/sources/net.sf.j2s.java.core/src/java/io/File.java +++ b/sources/net.sf.j2s.java.core/src/java/io/File.java @@ -1753,6 +1753,7 @@ private static File generateFile(String prefix, String suffix, File dir) f.秘isTempFile = true; return f; } + // // private static boolean checkAndCreate(String filename, SecurityManager sm, // boolean restrictive) @@ -1771,29 +1772,19 @@ private static File generateFile(String prefix, String suffix, File dir) // return fs.createFileExclusively(filename, restrictive); // } // - // The resulting temporary file may have more restrictive access permission - // on some platforms, if restrictive is true. - private static File createTempFile0(String prefix, String suffix, - File directory, boolean restrictive) - throws IOException - { - if (prefix == null) throw new NullPointerException(); - if (prefix.length() < 3) - throw new IllegalArgumentException("Prefix string too short"); - String s = (suffix == null) ? ".tmp" : suffix; - directory = new File(temporaryDirectory + (directory == null ? "" : directory)); - // we ensure that there is a clear marker for a temporary directory in SwingJS -// if (directory == null) { -// String tmpDir = temporaryDirectory(); -// directory = new File(tmpDir);//, fs.prefixLength(tmpDir)); -// } -// SecurityManager sm = System.getSecurityManager(); - File f; -// do { - f = generateFile(prefix, s, directory); -// } while (!checkAndCreate(f.getPath(), sm, restrictive)); - return f; - } + // The resulting temporary file may have more restrictive access permission + // on some platforms, if restrictive is true. + private static File createTempFile0(String prefix, String suffix, File directory, boolean restrictive) + throws IOException { + if (prefix == null) + throw new NullPointerException(); + if (prefix.length() < 3) + throw new IllegalArgumentException("Prefix string too short"); + String s = (suffix == null) ? ".tmp" : suffix; + directory = new File(temporaryDirectory + (directory == null ? "" : directory)); + // we ensure that there is a clear marker for a temporary directory in SwingJS + return generateFile(prefix, s, directory); + } /** *
Creates a new empty file in the specified directory, using the
diff --git a/sources/net.sf.j2s.java.core/src/java/net/URL.java b/sources/net.sf.j2s.java.core/src/java/net/URL.java
index f42ffbd8c..e557503c7 100644
--- a/sources/net.sf.j2s.java.core/src/java/net/URL.java
+++ b/sources/net.sf.j2s.java.core/src/java/net/URL.java
@@ -1007,9 +1007,11 @@ public String toExternalForm() {
* @return a URI instance equivalent to this URL.
* @since 1.5
*/
- // public URI toURI() throws URISyntaxException {
- // return new URI (toString());
- // }
+ public URI toURI() throws URISyntaxException {
+ URI uri = new URI (toString());
+ uri.秘bytes = (byte[]) _streamData;
+ return uri;
+ }
/**
* Returns a URLConnection
object that represents a connection to
diff --git a/sources/net.sf.j2s.java.core/src/javax/swing/ImageIcon.java b/sources/net.sf.j2s.java.core/src/javax/swing/ImageIcon.java
index 349b45206..f6c682eb6 100644
--- a/sources/net.sf.j2s.java.core/src/javax/swing/ImageIcon.java
+++ b/sources/net.sf.j2s.java.core/src/javax/swing/ImageIcon.java
@@ -36,6 +36,7 @@
import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;
import swingjs.JSGraphics2D;
+import swingjs.JSToolkit;
/**
* An implementation of the Icon interface that paints Icons
@@ -148,7 +149,11 @@ public class ImageIcon implements Icon {
* @see #ImageIcon(String)
*/
public ImageIcon(String filename, String description) {
- image = Toolkit.getDefaultToolkit().getImage(filename);
+ if (description != null && description.indexOf("jsvideo") >= 0) {
+ image = ((JSToolkit)Toolkit.getDefaultToolkit()).getVideo(filename);
+ } else {
+ image = Toolkit.getDefaultToolkit().getImage(filename);
+ }
if (image == null) {
return;
}
@@ -186,7 +191,11 @@ public ImageIcon (String filename) {
* @see #ImageIcon(String)
*/
public ImageIcon(URL location, String description) {
- image = Toolkit.getDefaultToolkit().getImage(location);
+ if (description != null && description.indexOf("jsvideo") >= 0) {
+ image = ((JSToolkit)Toolkit.getDefaultToolkit()).getVideo(location);
+ } else {
+ image = Toolkit.getDefaultToolkit().getImage(location);
+ }
if (image == null) {
return;
}
@@ -249,7 +258,11 @@ public ImageIcon (Image image) {
* @see java.awt.Toolkit#createImage
*/
public ImageIcon (byte[] imageData, String description) {
- this.image = Toolkit.getDefaultToolkit().createImage(imageData);
+ if (description != null && description.indexOf("jsvideo") >= 0) {
+ image = ((JSToolkit)Toolkit.getDefaultToolkit()).createVideo(imageData);
+ } else {
+ this.image = Toolkit.getDefaultToolkit().createImage(imageData);
+ }
if (image == null) {
return;
}
@@ -315,6 +328,16 @@ protected void loadImage(Image image) {
// }
}
+ /**
+ * SwingJS delayed video size
+ *
+ * @param w
+ * @param h
+ */
+ public void 秘setIconSize(int w, int h) {
+ width = w;
+ height = h;
+ }
// /**
// * Returns an ID to use with the MediaTracker in loading an image.
// */
diff --git a/sources/net.sf.j2s.java.core/src/swingjs/JSImage.java b/sources/net.sf.j2s.java.core/src/swingjs/JSImage.java
index 1231adc6f..31878dfc2 100644
--- a/sources/net.sf.j2s.java.core/src/swingjs/JSImage.java
+++ b/sources/net.sf.j2s.java.core/src/swingjs/JSImage.java
@@ -3,9 +3,18 @@
import java.awt.Component;
import java.awt.Image;
import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Path;
+
+import javax.swing.ImageIcon;
+import javax.swing.JLabel;
+import javax.swing.SwingUtilities;
import javajs.util.Base64;
+import swingjs.JSFileSystem.JSPath;
import swingjs.api.js.DOMNode;
+import swingjs.plaf.JSComponentUI;
/**
* A JavaScript version of BufferedImage.
@@ -61,14 +70,63 @@ public JSImage(byte[] pixelBytes, int width, int height, String src) {
* @param type
*/
@SuppressWarnings("unused")
- public void getDOMImage(byte[] b, String type) {
- String dataurl = "data:image/" + type + ";base64," + Base64.getBase64(b).toString();
+ void setImageNode(JSPath source, byte[] b, String type) {
DOMNode img = null;
- /**
- * @j2sNative img = new Image(this.width, this.height); //if (this.callback)
- * img.onload = this.callback; img.src = dataurl;
- */
+ if (type == "video") {
+ try {
+ String src = (source == null ? null : JSUtil.getWebPathFor(source.toString()));
+ if (b == null && source != null)
+ b = source.秘bytes;
+ System.out.println("JSImage video " + src + " " + (b == null ? 0 : b.length));
+ img = DOMNode.createElement("video", File.createTempFile("video_", "").getName());
+ DOMNode node = img;
+ Runnable r = new Runnable() {
+ // set dimension when available
+ @Override
+ public void run() {
+ int w = 0, h = 0;
+ DOMNode n = node;
+ /**
+ * @j2sNative
+ *
+ * w = n.width = n.videoWidth; h = n.height = n.videoHeight;
+ *
+ */
+ JSComponentUI ui = (JSComponentUI) DOMNode.getAttr(node, "data-ui");
+ System.out.println("JSImage w,h " + w + " " + h);
+ 秘init(w, h, TYPE_INT_ARGB);
+ if (ui != null && ui.jc instanceof JLabel) {
+ JLabel label = (JLabel) ui.jc;
+ w = label.getWidth();
+ h = label.getHeight();
+ n.setAttribute("width", w + "");
+ n.setAttribute("height", h + "");
+ ui.setTainted();
+ ImageIcon icon = (ImageIcon) label.getIcon();
+ if (icon != null) {
+ icon.秘setIconSize(w, h);
+ }
+ }
+ }
+ };
+ /**
+ * @j2sNative
+ *
+ * //document.body.appendChild(img);
+ * img.src = (b == null ? src : URL.createObjectURL(new Blob([b])));
+ * img.onloadedmetadata = function(){ r.run$()};
+ * img.load();
+ */
+
+ } catch (IOException e) {
+ }
+ } else {
+ String dataurl = "data:image/" + type + ";base64," + Base64.getBase64(b).toString();
+ /**
+ * @j2sNative img = new Image(this.width, this.height); img.src = dataurl;
+ */
+ }
秘imgNode = img;
}
diff --git a/sources/net.sf.j2s.java.core/src/swingjs/JSImagekit.java b/sources/net.sf.j2s.java.core/src/swingjs/JSImagekit.java
index cb23488d6..eef7a1073 100644
--- a/sources/net.sf.j2s.java.core/src/swingjs/JSImagekit.java
+++ b/sources/net.sf.j2s.java.core/src/swingjs/JSImagekit.java
@@ -15,7 +15,9 @@
import java.awt.image.ColorModel;
import java.awt.image.ImageConsumer;
import java.awt.image.WritableRaster;
+import java.nio.file.Path;
+import swingjs.JSFileSystem.JSPath;
import swingjs.api.Interface;
import swingjs.api.js.DOMNode;
import swingjs.api.js.HTML5Canvas;
@@ -36,6 +38,7 @@ public class JSImagekit implements ImageConsumer {
private static final int JPG = 1;
private static final int GIF = 2;
private static final int BMP = 3;
+ private static final int VIDEO = 4;
private static final int JPG_SOF0 = 0xC0FF;
private static final int JPG_SOF2 = 0xC2FF;
@@ -52,7 +55,7 @@ public class JSImagekit implements ImageConsumer {
*/
public JSImage createImageFromBytes(byte[] data, int imageoffset,
int imagelength, String name) {
- return createImageFromBytesStatic(data, imageoffset, imagelength, name);
+ return createImageFromBytesStatic(data, imageoffset, imagelength, name, UNK);
}
private int width;
@@ -153,8 +156,8 @@ public void setPixels(int x, int y, int w, int h, ColorModel model,
JSUtil.notImplemented("byte-based image pixels");
}
- private static JSImage createImageFromBytesStatic(byte[] data, int imageoffset,
- int imagelength, String name) {
+ private static JSImage createImageFromBytesStatic(byte[] data, int imageoffset, int imagelength, String name,
+ int imageType) {
int w = 0, h = 0;
int[] argb = null;
byte[] b = null;
@@ -163,20 +166,24 @@ private static JSImage createImageFromBytesStatic(byte[] data, int imageoffset,
// this is from Component.createImage();
w = imageoffset;
h = imagelength;
+ } else if (imageType == VIDEO){
+ b = data;
+ w = imageoffset;
+ h = imagelength;
+ type = "video";
} else {
if (imagelength < 0)
imagelength = data.length;
- // not implemented in JavaScript:
+ // not implemented in JavaScript:
// b = Arrays.copyOfRange(data, imageoffset, imagelength);
int n = imagelength - imageoffset;
- System.arraycopy(data, imageoffset, b = new byte[n], 0, n);
- if (b.length < 10)//was 54??? I have no recollection of why that might be.
+ System.arraycopy(data, imageoffset, b = new byte[n], 0, n);
+ if (b.length < 10)// was 54??? I have no recollection of why that might be.
return null;
- switch (getSourceType(b)) {
+ switch (imageType == UNK ? getSourceType(b) : imageType) {
case BMP:
// just get bytes directly
- BMPDecoder ie = (BMPDecoder) Interface.getInstance(
- "javajs.img.BMPDecoder", true);
+ BMPDecoder ie = (BMPDecoder) Interface.getInstance("javajs.img.BMPDecoder", true);
Object[] o = ie.decodeWindowsBMP(b);
if (o == null || o[0] == null)
return null;
@@ -212,17 +219,16 @@ private static JSImage createImageFromBytesStatic(byte[] data, int imageoffset,
type = "gif";
break;
case UNK:
- System.out.println("JSImagekit: Unknown image type: " + b[0] + " "
- + b[1] + " " + b[2] + " " + b[3]);
+ System.out.println("JSImagekit: Unknown image type: " + b[0] + " " + b[1] + " " + b[2] + " " + b[3]);
data = null;
break;
}
}
if (w == 0 || h == 0)
return null;
- JSImage jsimage = new JSImage(argb, w, h, name);
+ JSImage jsimage = new JSImage(argb, w, h, name);
if (data != null && argb == null)
- jsimage.getDOMImage(b, type);
+ jsimage.setImageNode(null, b, type);
return jsimage;
}
@@ -298,5 +304,15 @@ public static JSGraphics2D createCanvasGraphics(int width, int height, String id
return new JSGraphics2D(canvas);
}
+ public Image createVideo(Path path) {
+ JSImage jsimage = new JSImage((byte[])null, 1, 1, path.toString());
+ jsimage.setImageNode((JSPath) path, null, "video");
+ return jsimage;
+ }
+
+ public Image createVideo(byte[] bytes) {
+ return createImageFromBytesStatic(bytes, 1, 1, null, VIDEO);
+ }
+
}
diff --git a/sources/net.sf.j2s.java.core/src/swingjs/JSToolkit.java b/sources/net.sf.j2s.java.core/src/swingjs/JSToolkit.java
index 865edf370..888ab3b48 100644
--- a/sources/net.sf.j2s.java.core/src/swingjs/JSToolkit.java
+++ b/sources/net.sf.j2s.java.core/src/swingjs/JSToolkit.java
@@ -38,8 +38,14 @@
import java.awt.peer.WindowPeer;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
+import java.io.File;
import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.text.AttributedCharacterIterator.Attribute;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -580,12 +586,12 @@ public Image getImage(String filename) {
return createImage(JSToolkit.class.getResource(filename));
}
+
@Override
public Image getImage(URL url) {
return createImage(url);
}
-
-
+
@Override
public Image createImage(ImageProducer producer) {
JSImagekit kit = new JSImagekit();
@@ -646,11 +652,31 @@ public boolean prepareImage(Image image, int width, int height,
return true;
}
- public static boolean hasFocus(Component c) {
- JSComponentUI ui = getUI(c, false);
- return (ui != null && !ui.isNull && ui.hasFocus());
+ //// video ////
+
+ public Image getVideo(String filename) {
+ return createVideo(new File(filename).toPath());
+ }
+
+ public Image getVideo(URL url) {
+ try {
+ return createVideo(Paths.get(url.toURI()));
+ } catch (URISyntaxException e) {
+ return null;
+ }
+ }
+
+ public Image createVideo(Path path) {
+ return getImagekit().createVideo(path);
}
+ public Image createVideo(byte[] bytes) {
+ return getImagekit().createVideo(bytes);
+ }
+
+
+ ///// audio ////
+
private static JSAudio audioPlayer;
private static JSAudio getAudioPlayer() {
@@ -675,9 +701,6 @@ public static AudioClip getAudioClip(URL url) {
return getAudioPlayer().getAudioClip(url);
}
-
-
-
/**
* Simple way to play any audio file
*
@@ -940,11 +963,16 @@ public PrintJob getPrintJob(Frame frame, String jobtitle,
}
private static KeyboardFocusManagerPeer focusManager;
+
private static KeyboardFocusManagerPeer getFocusPeer() {
return (focusManager == null ? focusManager = new JSFocusPeer() : focusManager);
}
-
+ public static boolean hasFocus(Component c) {
+ JSComponentUI ui = getUI(c, false);
+ return (ui != null && !ui.isNull && ui.hasFocus());
+ }
+
// @Override
public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() {
return getFocusPeer();
diff --git a/sources/net.sf.j2s.java.core/src/swingjs/JSUtil.java b/sources/net.sf.j2s.java.core/src/swingjs/JSUtil.java
index 7762321df..bf80131d2 100644
--- a/sources/net.sf.j2s.java.core/src/swingjs/JSUtil.java
+++ b/sources/net.sf.j2s.java.core/src/swingjs/JSUtil.java
@@ -993,5 +993,9 @@ public byte[] addJSCachedBytes(Object URLorURIorFile) {
return bytes;
}
+ public static String getWebPathFor(String path) {
+ return path.startsWith("http") ? path : J2S.getResourcePath(path, true);
+ }
+
}
diff --git a/sources/net.sf.j2s.java.core/src/swingjs/a2s/Canvas.java b/sources/net.sf.j2s.java.core/src/swingjs/a2s/Canvas.java
index d540f4fb8..ad4361d2e 100644
--- a/sources/net.sf.j2s.java.core/src/swingjs/a2s/Canvas.java
+++ b/sources/net.sf.j2s.java.core/src/swingjs/a2s/Canvas.java
@@ -49,33 +49,4 @@ public void update(Graphics g) {
paint(g);
}
-// @Override
-// public void paint(Graphics g) {
-// ((Graphics2D) g).setBackground(getBackground());
-// g.clearRect(0, 0, width, height);
-//
-
- // on second thought, I think this was a mistaken idea: BH 2019.06
-
-// // see http://www.oracle.com/technetwork/java/painting-140037.html#awt_summary
-//
-// // BH AWT called canvas.update(g), but Swing will call canvas.paint(g) instead.
-// // BH a2s does allow for that, with paint(g) calling update(g) (Opposite of
-// // standard Swing).
-//
-// // BH So in the code, canvas.paint should be renamed something like
-// // canvas.paintMe
-//
-// update(g);
-// }
-//
-//// private boolean notified;
-// @SuppressWarnings("unused")
-// @Override
-// public void update(Graphics g) {
-// if (/** @j2sNative this.paintComponent$java_awt_Graphics || */
-// false)
-// paintComponent(g);
-// }
-
}
diff --git a/sources/net.sf.j2s.java.core/src/swingjs/api/JSUtilI.java b/sources/net.sf.j2s.java.core/src/swingjs/api/JSUtilI.java
index 3f6d2fd89..98a597e8a 100644
--- a/sources/net.sf.j2s.java.core/src/swingjs/api/JSUtilI.java
+++ b/sources/net.sf.j2s.java.core/src/swingjs/api/JSUtilI.java
@@ -11,6 +11,31 @@
public interface JSUtilI {
+ /**
+ * The HTML5 canvas delivers [r g b a r g b a ...] which is not a Java option.
+ * The closest Java option is TYPE_4BYTE_ABGR, but that is not quite what we
+ * need. SwingJS decodes TYPE_4BYTE_HTML5 as TYPE_4BYTE_RGBA"
+ *
+ * ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
+ *
+ * int[] nBits = { 8, 8, 8, 8 };
+ *
+ * int[] bOffs = { 0, 1, 2, 3 };
+ *
+ * colorModel = new ComponentColorModel(cs, nBits, true, false,
+ * Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE);
+ *
+ * raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, width, height,
+ * width * 4, 4, bOffs, null);
+ *
+ * Note, however, that this buffer type should only be used for direct buffer access
+ * using
+ *
+ *
+ *
+ */
+ public static final int TYPE_4BYTE_HTML5 = -6;
+
/**
* Indicate to SwingJS that the given file type is binary.
*
diff --git a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSButtonUI.java b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSButtonUI.java
index dfe68f3f6..c371780fc 100644
--- a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSButtonUI.java
+++ b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSButtonUI.java
@@ -88,6 +88,7 @@ public DOMNode updateDOMNode() {
// this one is only for a simple button
if (domNode == null) {
isSimpleButton = true;
+ imagePersists = true; // at least for now.
allowPaintedBackground = false;
setDoPropagate();
domNode = enableNode = buttonNode = newDOMObject("button", id + "_dom", "type", "button", "style", "padding:0");
@@ -799,7 +800,6 @@ protected Dimension getHTMLSizePreferred(DOMNode obj, boolean addCSS) {
@Override
public void paint(Graphics g, JComponent c) {
- imagePersists = true; // at least for now.
if (jc.秘paintsSelfEntirely())
DOMNode.setStyles(centeringNode, "visibility", "visible");
super.paint(g, c);
diff --git a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSComponentUI.java b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSComponentUI.java
index 38671ba08..2ff1a4ab9 100644
--- a/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSComponentUI.java
+++ b/sources/net.sf.j2s.java.core/src/swingjs/plaf/JSComponentUI.java
@@ -125,7 +125,7 @@
*
* Some UIs (JSSpinnerUI, JSComboBoxUI, JSFrameUI, and JSTextUI) set jqevent.target["data-ui"]
* to point to themselves. This allows the control an option to handle the raw jQuery
- * event directly, bypassing the Java dispatch system entirely, id desired.
+ * event directly, bypassing the Java dispatch system entirely, if desired.
*
* TODO: We should not use this method. It bypasses the normal Java LightWeightDispatcher,
* which has a protected processEvent(AWTEvent) method that
@@ -418,11 +418,6 @@ protected void restoreCellNodes(DOMNode td) {
*/
protected String textAlign;
- /**
- * Labels with icons will have this
- */
- protected int iconHeight;
-
/**
* jSButtonUI buttonListener
*
@@ -1536,6 +1531,11 @@ protected boolean setUIDisabled(boolean b) {
*/
protected boolean isSticky;
+ /**
+ * an icon created using "jsvideo" as its description
+ */
+ protected boolean isVideoIcon;
+
private static DOMNode tempDiv;
/**
@@ -2427,11 +2427,39 @@ protected void setIconAndText(String prop, Icon icon, int gap, String text) {
icon = currentIcon = getIcon(jc, icon);
$(iconNode).empty();
if (currentIcon != null) {
- imageNode = ((BufferedImage)currentIcon.getImage()).秘getImageNode(BufferedImage.GET_IMAGE_FOR_ICON);
+ imageNode = ((BufferedImage) currentIcon.getImage()).秘getImageNode(BufferedImage.GET_IMAGE_FOR_ICON);
+ if (DOMNode.getAttr(imageNode, "tagName") == "VIDEO")
+ isVideoIcon = imagePersists = true;
iconNode.appendChild(imageNode);
- iconHeight = icon.getIconHeight();
- DOMNode.setStyles(imageNode, "visibility", (isLabel ? "hidden" : null));
- DOMNode.setStyles(iconNode, "height", iconHeight + "px", "width", icon.getIconWidth() + "px");
+ int w,h;
+ if (isVideoIcon) {
+ if (jc.isPreferredSizeSet()) {
+ w = jc.getPreferredSize().width;
+ h = jc.getPreferredSize().height;
+ } else {
+ w = DOMNode.getAttrInt(imageNode, "videoWidth");
+ h = DOMNode.getAttrInt(imageNode, "videoHeight");
+ }
+ if (w > 0 && h > 0) {
+ ((ImageIcon) icon).秘setIconSize(w, h);
+ DOMNode.setStyles(imageNode, "height", h + "px", "width", w + "px");
+ DOMNode.setStyles(iconNode, "height", h + "px", "width", w + "px");
+ }
+ // might have to do this if we have problems with onloadmetadata
+// if (isVideoIcon && iconHeight == 1) {
+// iconHeight = icon.getIconHeight();
+// // video is still loading
+// setDataUI(imageNode);
+// setTainted(true);
+// } else {
+// }
+ } else {
+ w = icon.getIconWidth();
+ h = icon.getIconHeight();
+ DOMNode.setStyles(iconNode, "height", h + "px", "width", w + "px");
+ if (!imagePersists)
+ DOMNode.setStyles(imageNode, "visibility", "hidden");
+ }
}
}
if (text == null) {
@@ -2448,8 +2476,7 @@ protected void setIconAndText(String prop, Icon icon, int gap, String text) {
DOMNode.setStyles(textNode, "white-space", "nowrap");
if (icon == null) {
// tool tip does not allow text alignment
- if (iconNode != null && allowTextAlignment
- && isMenuItem && actionNode == null && text != null) {
+ if (iconNode != null && allowTextAlignment && isMenuItem && actionNode == null && text != null) {
DOMNode.addHorizontalGap(iconNode, gap + MENUITEM_OFFSET);
}
} else {
@@ -2481,9 +2508,9 @@ protected void setIconAndText(String prop, Icon icon, int gap, String text) {
prop = "innerHTML";
obj = textNode;
// IT TURNS OUT...
- // that for a