import jalview.javascript.json.JSON;
import java.awt.Color;
+import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
import java.io.BufferedReader;
import java.util.logging.Level;
import java.util.logging.Logger;
+import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import org.json.simple.parser.JSONParser;
if (!isJS() || data == null)
{
return;
- }
- /**
- * @j2sNative
- *
- * swingjs.JSUtil.cacheFileData$S$O(path, data);
- *
- */
+ } /**
+ * @j2sNative
+ *
+ * swingjs.JSUtil.cacheFileData$S$O(path, data);
+ *
+ */
}
public static void cacheFileData(File file)
{
BrowserLauncher.openURL(url);
return false;
- }
- /**
- * @j2sNative
- *
- *
- * window.open(url);
- */
+ } /**
+ * @j2sNative
+ *
+ *
+ * window.open(url);
+ */
return true;
}
public static Object parseJSON(String json) throws ParseException
{
- return (isJS() ? JSON.parse(json)
- : new JSONParser().parse(json));
+ return (isJS() ? JSON.parse(json) : new JSONParser().parse(json));
}
public static Object parseJSON(Reader r)
if (isJS())
{
System.out.println(
- "Platform adding known access-control-allow-origin * for domain "
- + domain);
- /**
- * @j2sNative
- *
- * J2S.addDirectDatabaseCall(domain);
- */
+ "Platform adding known access-control-allow-origin * for domain "
+ + domain);/**
+ * @j2sNative
+ *
+ * J2S.addDirectDatabaseCall(domain);
+ */
}
}
return Regex.perlCode(code);
}
- /**
+ /**
+ * Convert a color name to a Color object. SwingJS can do this natively.
* @param c
*/
public static Color getColorFromName(String name)
default:
return null;
}
-
}
}
*/
}
- public final static String EMBEDDED_DIM = "dim";
+ /**
+ * Retrieve the object's embedded size from a div's style on a page if
+ * embedded in SwingJS.
+ *
+ * @param frame
+ * JFrame or JInternalFrame
+ * @param defaultWidth
+ * use -1 to return null (no default size)
+ * @param defaultHeight
+ * @return the embedded dimensions or null (no default size or not embedded)
+ */
+ public static Dimension getDimIfEmbedded(JComponent frame,
+ int defaultWidth, int defaultHeight)
+ {
+ Dimension d = /** @j2sNative frame.ui.getEmbedded$S("dim") || */
+ null;
+ return (d == null && defaultWidth >= 0
+ ? new Dimension(defaultWidth, defaultHeight)
+ : d);
+ }
/**
*
{
return null;
}
- return (/** swingjs@j2sNative || frame.ui.getEmbedded(type) */
+ return (/** @j2sNative frame.ui.getEmbedded$S(type) || */
null);
}