X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Futil%2FPlatform.java;h=121ac1b55045e381e9702839f39ad56c4bf4c099;hb=f0fd407e5fad67185a9813c57bfc50aacaf1de6e;hp=6d9574743b66ab6e8396ce2cf0c8a89789036e6c;hpb=208c3f5787135dad576950fd4be90bd4b9457f1c;p=jalview.git diff --git a/src/jalview/util/Platform.java b/src/jalview/util/Platform.java index 6d95747..121ac1b 100644 --- a/src/jalview/util/Platform.java +++ b/src/jalview/util/Platform.java @@ -23,6 +23,7 @@ package jalview.util; 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; @@ -40,6 +41,7 @@ import java.util.logging.ConsoleHandler; import java.util.logging.Level; import java.util.logging.Logger; +import javax.swing.JComponent; import javax.swing.SwingUtilities; import org.json.simple.parser.JSONParser; @@ -276,6 +278,8 @@ public class Platform * * Platform.timeCheck("some message", Platform.TIME_MARK); * + * reset...[set/mark]n...get + * * @param msg * @param mode */ @@ -286,6 +290,7 @@ public class Platform { case TIME_RESET: time = mark = t; + duration = 0; if (msg != null) { System.err.println("Platform: timer reset\t\t\t" + msg); @@ -294,6 +299,7 @@ public class Platform case TIME_MARK: if (set > 0) { + // total time between set/mark points duration += (t - set); } else @@ -316,7 +322,7 @@ public class Platform case TIME_GET: if (msg != null) { - System.err.println("Platform: timer dur\t" + ((t - time) / 1000f) + System.err.println("Platform: timer get\t" + ((t - time) / 1000f) + "\t" + ((duration) / 1000f) + "\t" + msg); } set = 0; @@ -714,57 +720,6 @@ public class Platform } /** - * @param c - */ - public static Color getColorFromName(String name) - { - if (name == null) - { - return null; - } - /** - * @j2sNative - * - * return swingjs.JSUtil.getColorFromName$S(name); - */ - { - // or make a static map; or use reflection on the field name - switch (name.toLowerCase()) - { - case "black": - return Color.black; - case "blue": - return Color.blue; - case "cyan": - return Color.cyan; - case "darkgray": - return Color.darkGray; - case "gray": - return Color.gray; - case "green": - return Color.green; - case "lightgray": - return Color.lightGray; - case "magenta": - return Color.magenta; - case "orange": - return Color.orange; - case "pink": - return Color.pink; - case "red": - return Color.red; - case "white": - return Color.white; - case "yellow": - return Color.yellow; - default: - return null; - } - - } - } - - /** * Initialize Java debug logging. A representative sample -- adapt as desired. */ public static void startJavaLogging() @@ -832,7 +787,26 @@ public class Platform */ } - 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); + } /** * @@ -849,7 +823,7 @@ public class Platform { return null; } - return (/** swingjs@j2sNative || frame.ui.getEmbedded(type) */ + return (/** @j2sNative frame.ui.getEmbedded$S(type) || */ null); }