/** Default file is ~/.jalview_properties */
static String propertiesFile;
- private static boolean propsAreReadOnly = /** @j2sNative true || */
- false;
+ private static boolean propsAreReadOnly = Platform.isJS();/// ** @j2sNative
+ /// true || */false;
public static void initLogger()
{
// LOAD THE AUTHORS FROM THE authors.props file
boolean ignore = Platform.isJS();
if (!ignore)
- try
+ /**
+ * @j2sNative
+ */
{
- String authorDetails = "jar:"
- .concat(Cache.class.getProtectionDomain().getCodeSource()
- .getLocation().toString().concat("!/authors.props"));
+ try
+ {
+ String authorDetails = "jar:"
+ .concat(Cache.class.getProtectionDomain().getCodeSource()
+ .getLocation().toString().concat("!/authors.props"));
- java.net.URL localJarFileURL = new java.net.URL(authorDetails);
+ java.net.URL localJarFileURL = new java.net.URL(authorDetails);
- InputStream in = localJarFileURL.openStream();
- applicationProperties.load(in);
- in.close();
-
- } catch (Exception ex)
- {
- System.out.println("Error reading author details: " + ex);
- ignore = true;
+ InputStream in = localJarFileURL.openStream();
+ applicationProperties.load(in);
+ in.close();
+
+ } catch (Exception ex)
+ {
+ System.out.println("Error reading author details: " + ex);
+ ignore = true;
+ }
}
if (ignore) {
// BH 2019.01.25 switching to Platform.isJS()
ignore = Platform.isJS();
if (!ignore)
- try
+ /**
+ * @j2sNative
+ */
{
- String buildDetails = "jar:".concat(Cache.class.getProtectionDomain()
- .getCodeSource().getLocation().toString()
- .concat("!/.build_properties"));
+ try
+ {
+ String buildDetails = "jar:".concat(Cache.class.getProtectionDomain()
+ .getCodeSource().getLocation().toString()
+ .concat("!/.build_properties"));
- java.net.URL localJarFileURL = new java.net.URL(buildDetails);
+ java.net.URL localJarFileURL = new java.net.URL(buildDetails);
- InputStream in = localJarFileURL.openStream();
- applicationProperties.load(in);
- in.close();
- } catch (Exception ex)
- {
- System.out.println("Error reading build details: " + ex);
- ignore = true;
+ InputStream in = localJarFileURL.openStream();
+ applicationProperties.load(in);
+ in.close();
+ } catch (Exception ex)
+ {
+ System.out.println("Error reading build details: " + ex);
+ ignore = true;
+ }
}
if (ignore) {
import jalview.util.Platform;
import jalview.ws.jws2.Jws2Discoverer;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.util.logging.Logger;
import javax.swing.LookAndFeel;
-import javax.swing.Timer;
import javax.swing.UIManager;
import groovy.lang.Binding;
public class Jalview
{
/**
- * @j2sNative
- *
- * // find first query parameter (if any) that doesn't start with j2s
- * // and set as space-delimited arguments to Jalview main
- * hr = decodeURI(document.location.href);
- * pos = hr.indexOf("?");
- * if (pos > 0)
- * {
- * q = hr.substring(pos+1);
- * args = q.split("&");
- * for (i = 0 ; i < args.length; i++)
- * {
- * arg1 = args[i];
- * if (!arg1.startsWith("j2s"))
- * {
- * thisApplet.__Info.args = arg1.split(" ");
- * break;
- * }
- * }
- * }
- */
+ * // find first query parameter (if any) that doesn't start with j2s // and
+ * set as space-delimited arguments to Jalview main
+ *
+ * @j2sNative
+ *
+ * var hr = decodeURI(document.location.href); var pos =
+ * hr.indexOf("?"); if (pos > 0) { q = hr.substring(pos+1); args =
+ * q.split("&"); for (i = 0 ; i < args.length; i++) { arg1 =
+ * args[i]; if (!arg1.startsWith("j2s")) { thisApplet.__Info.args =
+ * arg1.split(" "); break; } } }
+ */
/*
* singleton instance of this class
static
{
if (!Platform.isJS())
- { // BH 2018
- // grab all the rights we can for the JVM
+ /**
+ * Java only
+ *
+ * @j2sNative
+ */
+ {
+ // grab all the rights we can for the JVM
Policy.setPolicy(new Policy()
{
@Override
private static void setLogging()
{
// BH - for event debugging in JavaScript (Java mode only)
- if (!(/** @j2sNative true ||*/false))
+ if (!Platform.isJS())// !(/** @j2sNative true ||*/false))
+ /**
+ * Java only
+ *
+ * @j2sNative
+ */
{
Logger.getLogger("").setLevel(Level.ALL);
logClass("java.awt.EventDispatchThread");
"CMD [-props " + usrPropsFile + "] executed successfully!");
}
+ if (!Platform.isJS())
/**
- * BH 2018 ignoring this section for JS
+ * ignore in JavaScript
*
* @j2sNative
*/
desktop.setInBatchMode(true); // indicate we are starting up
desktop.setVisible(true);
+ if (!Platform.isJS())
/**
- * BH 2018 JS bypass this section
+ * Java only
*
* @j2sNative
- *
*/
{
desktop.startServiceDiscovery();
}
System.out.println("CMD [-open " + file + "] executed successfully!");
- if (!Platform.isJS() && !file.startsWith("http://"))
+ if (!Platform.isJS())
+ /**
+ * ignore in JavaScript -- can't just file existence - could load it?
+ *
+ * @j2sNative
+ */
{
- if (!(new File(file)).exists())
+ if (!file.startsWith("http://") && !file.startsWith("https://"))
+ // BH 2019 added https check for Java
{
- System.out.println("Can't find " + file);
- if (headless)
+ if (!(new File(file)).exists())
{
- System.exit(1);
+ System.out.println("Can't find " + file);
+ if (headless)
+ {
+ System.exit(1);
+ }
}
}
}
// And the user
// ////////////////////
- if (/** @j2sNative false && */ // BH 2018
+ if (!Platform.isJS() && // /** @j2sNative false && */ // BH 2018
!headless && file == null && vamsasImport == null
&& jalview.bin.Cache.getDefault("SHOW_STARTUP_FILE", true))
+ /**
+ * Java only
+ *
+ * @j2sNative
+ */
{
file = jalview.bin.Cache.getDefault("STARTUP_FILE",
jalview.bin.Cache.getDefault("www.jalview.org",
/**
* @j2sNative
*
- * hr = decodeURI(document.location.href);
- * pos = hr.indexOf("?");
- * // set space-delimited query parameters as arguments to Jalview main
- * if (pos > 0)
- * {
- * thisApplet.__Info.args = hr.substring(pos+1).split(" ");
- * }
+ * var hr = decodeURI(document.location.href); var pos =
+ * hr.indexOf("?"); // set space-delimited query parameters as
+ * arguments to Jalview main if (pos > 0) {
+ * thisApplet.__Info.args = hr.substring(pos+1).split(" "); }
*/
}
t.setRepeats(true);
if (/** @j2sNative true || */
false)
- t.start();
+ {
+ t.start();
+ }
}
btn_autosearch.setText(MessageManager.getString("option.autosearch"));
btn_autosearch.setToolTipText(
MessageManager.getString("option.enable_disable_autosearch"));
- btn_autosearch.setSelected(Platform.isJS() ? false :
- Cache.getDefault(getAutosearchPreference(), true));
+ btn_autosearch.setSelected(!Platform.isJS()
+ && Cache.getDefault(getAutosearchPreference(), true));
btn_autosearch.addActionListener(new java.awt.event.ActionListener()
{
@Override
clientResponseClass = (Class<ClientResponse>) (Object) jalview.javascript.web.ClientResponse.class;
}
else
+ /**
+ * Java only
+ *
+ * @j2sNative
+ */
{
- // Java only
client = Client.create(new DefaultClientConfig());
clientResponseClass = ClientResponse.class;
}
.valueOf(pdbResponse.get("numFound").toString());
if (numFound > 0)
{
- result = new ArrayList<FTSData>();
+ result = new ArrayList<>();
List<Object> docs = (List<Object>) pdbResponse.get("docs");
for (Iterator<Object> docIter = docs.iterator(); docIter
.hasNext();)
if (allDefaultDisplayedStructureDataColumns == null
|| allDefaultDisplayedStructureDataColumns.isEmpty())
{
- allDefaultDisplayedStructureDataColumns = new ArrayList<FTSDataColumnI>();
+ allDefaultDisplayedStructureDataColumns = new ArrayList<>();
allDefaultDisplayedStructureDataColumns
.addAll(super.getAllDefaultDisplayedFTSDataColumns());
}
clientResponseClass = (Class<ClientResponse>) (Object) jalview.javascript.web.ClientResponse.class;
}
else
+ /**
+ * Java only
+ *
+ * @j2sNative
+ */
{
// Java only
client = Client.create(new DefaultClientConfig());
if (Desktop.desktop != null)
{
this.setDropTarget(new java.awt.dnd.DropTarget(this, this));
- /**
- * BH 2018 ignore service listeners
- *
- * @j2sNative
- *
- */
+ if (!Platform.isJS())
{
addServiceListeners();
}
((JPanel) pane).add(textLabel, BorderLayout.NORTH);
}
else
+ /**
+ * Java only
+ *
+ * @j2sNative
+ */
{
JEditorPane editPane = new JEditorPane("text/html", "");
editPane.setEditable(false);
*/
public Desktop()
{
- super();
+ super();
/**
- * A note to implementors. It is ESSENTIAL that any activities that might block
- * are spawned off as threads rather than waited for during this constructor.
+ * A note to implementors. It is ESSENTIAL that any activities that might
+ * block are spawned off as threads rather than waited for during this
+ * constructor.
*/
instance = this;
if (!Platform.isJS())
boolean showjconsole = jalview.bin.Cache.getDefault("SHOW_JAVA_CONSOLE",
false);
desktop = new MyDesktopPane(selmemusage);
-
-
+
showMemusage.setSelected(selmemusage);
desktop.setBackground(Color.white);
getContentPane().setLayout(new BorderLayout());
// JScrollPane sp = new JScrollPane();
// sp.getViewport().setView(desktop);
// getContentPane().add(sp, BorderLayout.CENTER);
-
- // BH 2018 - just an experiment to try unclipped JInternalFrames.
- if (Platform.isJS())
- {
- getRootPane().putClientProperty("swingjs.overflow.hidden", "false");
- }
-
+
+ // BH 2018 - just an experiment to try unclipped JInternalFrames.
+ if (Platform.isJS())
+ {
+ getRootPane().putClientProperty("swingjs.overflow.hidden", "false");
+ }
+
getContentPane().add(desktop, BorderLayout.CENTER);
desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
-
+
// This line prevents Windows Look&Feel resizing all new windows to maximum
// if previous window was maximised
desktop.setDesktopManager(new MyDesktopManager(
int yPos = Math.max(5, (screenSize.height - 650) / 2);
setBounds(xPos, yPos, 900, 650);
}
-
- boolean doFullLoad = /** @j2sNative ! */true;
-
- if (doFullLoad) {
-
+
+ // boolean doFullLoad = /** @j2sNative ! */true;
+ if (!Platform.isJS())
+ /**
+ * Java only
+ *
+ * @j2sNative
+ */
+ {
+
jconsole = new Console(this, showjconsole);
// add essential build information
jconsole.setHeader("Jalview Version: "
}
});
- // Thread off a new instance of the file chooser - this reduces the time it
+ // Thread off a new instance of the file chooser - this reduces the time
+ // it
// takes to open it later on.
new Thread(new Runnable()
{
});
- }
+ }
this.setDropTarget(new java.awt.dnd.DropTarget(desktop, this));
frame.setResizable(resizable);
frame.setMaximizable(resizable);
frame.setIconifiable(resizable);
- frame.setOpaque(/** @j2sNative true || */
- false);
+ frame.setOpaque(Platform.isJS());/// ** @j2sNative true || */false);
if (frame.getX() < 1 && frame.getY() < 1)
{
JPanel panel = new JPanel(new GridLayout(2, 1));
panel.add(label);
-
+
/*
* the URL to fetch is
* Java: an editable combobox with history
history = new JTextField(urlBase, 35);
}
else
+ /**
+ * Java only
+ *
+ * @j2sNative
+ */
{
JComboBox<String> asCombo = new JComboBox<>();
asCombo.setPreferredSize(new Dimension(400, 20));
Object[] options = new Object[] { MessageManager.getString("action.ok"),
MessageManager.getString("action.cancel") };
- Runnable action = new Runnable() {
+ Runnable action = new Runnable()
+ {
@Override
public void run()
{
- String url = Platform.isJS() ? ((JTextField) history).getText()
+ @SuppressWarnings("unchecked")
+ String url = (history instanceof JTextField
+ ? ((JTextField) history).getText()
: ((JComboBox<String>) history).getSelectedItem()
- .toString();
+ .toString());
if (url.toLowerCase().endsWith(".jar"))
{
if (format == null)
{
- String msg = MessageManager.formatMessage("label.couldnt_locate", url);
+ String msg = MessageManager
+ .formatMessage("label.couldnt_locate", url);
JvOptionPane.showInternalMessageDialog(Desktop.desktop, msg,
MessageManager.getString("label.url_not_found"),
JvOptionPane.WARNING_MESSAGE);
new FileLoader().LoadFile(url, DataSourceType.URL, format);
}
}
- }};
+ }
+ };
String dialogOption = MessageManager
.getString("label.input_alignment_from_url");
JvOptionPane.newOptionDialog(desktop).setResponseHandler(0, action)
BrowserLauncher.openURL("http://www.jalview.org/help.html");
}
else
+ /**
+ * Java only
+ *
+ * @j2sNative
+ */
{
Help.showHelpWindow();
}
*/
chooser = new FeatureTypeSettings(fr, type);
if (!Platform.isJS())
+ /**
+ * Java only
+ *
+ * @j2sNative
+ */
{
chooser.setRequestFocusEnabled(true);
chooser.requestFocus();
*/
public static void showHelpWindow(HelpId id) throws HelpSetException
{
- if (Platform.isJS())
- {
- try
- {
- BrowserLauncher.openURL(HELP_PAGE_ROOT + id.getPath());
- } catch (IOException e) {}
- return;
- }
-
- ClassLoader cl = Desktop.class.getClassLoader();
- URL url = HelpSet.findHelpSet(cl, "help/help"); // $NON-NLS-$
- HelpSet hs = new HelpSet(cl, url);
-
- if (hb == null)
+ if (Platform.isJS())
{
- /*
- * create help broker first time (only)
- */
- hb = hs.createHelpBroker();
+ try
+ {
+ BrowserLauncher.openURL(HELP_PAGE_ROOT + id.getPath());
+ } catch (IOException e)
+ {
+ }
}
-
- try
- {
- hb.setCurrentID(id.getId());
- } catch (BadIDException bad)
+ else
+ /**
+ * Java only
+ *
+ * @j2sNative
+ */
{
- System.out.println("Bad help link: " + id.getId()
- + ": must match a target in help.jhm");
- throw bad;
- }
- /*
- * set Help visible - at its current location if it is already shown,
- * else at a location as determined by the window manager
- */
- Point p = hb.getLocation();
- hb.setLocation(p);
- hb.setDisplayed(true);
+ ClassLoader cl = Desktop.class.getClassLoader();
+ URL url = HelpSet.findHelpSet(cl, "help/help"); // $NON-NLS-$
+ HelpSet hs = new HelpSet(cl, url);
+
+ if (hb == null)
+ {
+ /*
+ * create help broker first time (only)
+ */
+ hb = hs.createHelpBroker();
+ }
+
+ try
+ {
+ hb.setCurrentID(id.getId());
+ } catch (BadIDException bad)
+ {
+ System.out.println("Bad help link: " + id.getId()
+ + ": must match a target in help.jhm");
+ throw bad;
+ }
+
+ /*
+ * set Help visible - at its current location if it is already shown,
+ * else at a location as determined by the window manager
+ */
+ Point p = hb.getLocation();
+ hb.setLocation(p);
+ hb.setDisplayed(true);
+ }
}
/**
void startScrolling(boolean up)
{
scrollThread = new ScrollThread(up);
- if (!Platform.isJS())
- {
- /*
- * Java - run in a new thread
- */
- scrollThread.start();
- }
- else
+ if (Platform.isJS())
{
/*
* for JalviewJS using Swing Timer
});
t.start();
}
+ else
+ /**
+ * Java only
+ *
+ * @j2sNative
+ */
+ {
+ scrollThread.start();
+ }
}
/**
* (for Javascript, see propertyChange)
*/
if (!Platform.isJS())
+ /**
+ * Java only
+ *
+ * @j2sNative
+ */
{
handleResponse(response);
}
initresponse);
}
if (!Platform.isJS())
+ /**
+ * Java only
+ *
+ * @j2sNative
+ */
{
handleResponse(response);
}
* Javascript does not call componentResized on initial display,
* so do the update here
*/
- boolean doUpdate = /** @j2sNative true || */ false;
- if (doUpdate)
+ // boolean doUpdate = /** @j2sNative true || */ false;
+ if (Platform.isJS())
+ {
updateOverviewImage();
+ }
}
/*
protected void showFeatureDetails(SequenceFeature sf)
{
JInternalFrame details;
- if (/** @j2sNative true || */ false)
+ if (Platform.isJS())// ** @j2sNative true || */ false)
{
details = new JInternalFrame();
JPanel panel = new JPanel(new BorderLayout());
panel.setOpaque(true);
panel.setBackground(Color.white);
// TODO JAL-3026 set style of table correctly for feature details
- JLabel reprt = new JLabel(MessageManager.formatMessage("label.html_content",
- new Object[]
- { sf.getDetailsReport()}));
+ JLabel reprt = new JLabel(MessageManager
+ .formatMessage("label.html_content", new Object[]
+ { sf.getDetailsReport() }));
reprt.setBackground(Color.WHITE);
reprt.setOpaque(true);
- panel.add(reprt,BorderLayout.CENTER);
+ panel.add(reprt, BorderLayout.CENTER);
details.setContentPane(panel);
details.pack();
}
else
+ /**
+ * Java only
+ *
+ * @j2sNative
+ */
{
CutAndPasteHtmlTransfer cap = new CutAndPasteHtmlTransfer();
// it appears Java's CSS does not support border-collaps :-(
}
contents.append("</body></html>");
String report = contents.toString();
-
+
JInternalFrame frame;
if (Platform.isJS())
{
textLabel.setText(report);
textLabel.setBackground(Color.WHITE);
JPanel pane = new JPanel(new BorderLayout());
- ((JPanel) pane).setOpaque(true);
+ pane.setOpaque(true);
pane.setBackground(Color.WHITE);
- ((JPanel) pane).add(textLabel, BorderLayout.NORTH);
+ pane.add(textLabel, BorderLayout.NORTH);
frame = new JInternalFrame();
frame.getContentPane().add(new JScrollPane(pane));
}
else
+ /**
+ * Java only
+ *
+ * @j2sNative
+ */
{
CutAndPasteHtmlTransfer cap = new CutAndPasteHtmlTransfer();
cap.setText(report);
frame = new JInternalFrame();
frame.setContentPane(this);
if (!Platform.isJS())
+ /**
+ * Java only
+ *
+ * @j2sNative
+ */
{
wsPrefs = new WsPreferences();
wsTab.add(wsPrefs, BorderLayout.CENTER);
public void defaultBrowser_mouseClicked(MouseEvent e)
{
// TODO: JAL-3048 not needed for j2s
- /*
+ if (!Platform.isJS()) // BH 2019
+ /**
+ * Java only
+ *
* @j2sNative
*/
{
{
scrollThread = new ScrollThread();
scrollThread.setMousePosition(mousePos);
- if (!Platform.isJS())
- {
- /*
- * Java - run in a new thread
- */
- scrollThread.start();
- }
- else
+ if (Platform.isJS())
{
/*
* Javascript - run every 20ms until scrolling stopped
t.start();
}
}
+ else
+ {
+ /*
+ * Java - run in a new thread
+ */
+ scrollThread.start();
+ }
}
/**
*/
package jalview.gui;
+import jalview.util.Platform;
+
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JPanel;
-import javax.swing.JTextField;
import javax.swing.JTextPane;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
JPanel iconimg = new JPanel(new BorderLayout());
/**
- * either text area in javascript or in java text pane
+ * either text area in javascript or in java text pane
*/
Component authlist;
{
this.interactiveDialog = interactive;
// show a splashscreen that will disapper
- if (/** @j2sNative true || */ false)
+ if (Platform.isJS()) // BH 2019
+ // if (/** @j2sNative true || */ false)
{
authlist = new JLabel("");
run();
else
{
/**
+ * Java only
+ *
* @j2sNative
*/
{
MouseAdapter closer = new MouseAdapter()
{
+ @Override
public void mousePressed(MouseEvent evt)
{
try
java.net.URL urllogo = getClass()
.getResource("/images/Jalview_Logo_small.png");
- if (/** @j2sNative false || */ url != null)
+ if (/** @j2sNative false || */
+ url != null)
{
image = java.awt.Toolkit.getDefaultToolkit().createImage(url);
Image logo = java.awt.Toolkit.getDefaultToolkit()
iframe.setLayer(JLayeredPane.PALETTE_LAYER);
/**
* we add image directly in html for javascript ?
+ *
* @j2sNative
*/
{
{
iframe.setVisible(false);
oldtext = newtext.length();
- if (/** @j2sNative true || */ false)
+ if (Platform.isJS()) // BH 2019
+ // if (/** @j2sNative true || */ false)
{
- authlist = new JLabel("<html><br/><br/><img src=\"swingjs/j2s/images/Jalview_Logo.png\"/><br/>"+newtext);
+ authlist = new JLabel(
+ "<html><br/><br/><img src=\"swingjs/j2s/images/Jalview_Logo.png\"/><br/>"
+ + newtext);
((JLabel) authlist).setOpaque(true);
((JLabel) authlist).setBackground(Color.white);
- } else {
+ }
+ else
+ {
/**
- * @j2sNative
+ * Java only
+ *
+ * @j2sNative
*/
{
authlist = new JTextPane();
}
}
authlist.addMouseListener(closer);
-
+
authlist.setVisible(true);
authlist.setSize(new Dimension(750, 375));
add(authlist, BorderLayout.CENTER);
/**
* Create splash screen, display it and clear it off again.
*/
+ @Override
public void run()
{
initSplashScreenWindow();
public SplashImage(Image todisplay)
{
image = todisplay;
- if (image!=null)
- { setPreferredSize(new Dimension(image.getWidth(this) + 8,
- image.getHeight(this)));
+ if (image != null)
+ {
+ setPreferredSize(new Dimension(image.getWidth(this) + 8,
+ image.getHeight(this)));
}
}
return new Dimension(image.getWidth(this) + 8, image.getHeight(this));
}
+ @Override
public void paintComponent(Graphics g)
{
g.setColor(Color.white);
import jalview.util.ColorUtils;
import jalview.util.Format;
import jalview.util.MessageManager;
+import jalview.util.Platform;
import jalview.xml.binding.jalview.JalviewUserColours;
import jalview.xml.binding.jalview.JalviewUserColours.Colour;
import jalview.xml.binding.jalview.ObjectFactory;
protected void warnIfUnsavedChanges()
{
// BH 2018 no warning in JavaScript TODO
-
- if (/** @j2sNative true || */ !changedButNotSaved)
- {
- return;
- }
- String name = schemeName.getText().trim();
- if (oldColourScheme != null && !"".equals(name)
- && name.equals(oldColourScheme.getSchemeName()))
- {
- String message = MessageManager.formatMessage("label.scheme_changed",
- name);
- String title = MessageManager.getString("label.save_changes");
- String[] options = new String[] { title,
- MessageManager.getString("label.dont_save_changes"), };
- final String question = JvSwingUtils.wrapTooltip(true, message);
- int response = JvOptionPane.showOptionDialog(Desktop.desktop,
- question, title, JvOptionPane.DEFAULT_OPTION,
- JvOptionPane.PLAIN_MESSAGE, null, options, options[0]);
-
- if (response == 0)
+ if (!Platform.isJS() && changedButNotSaved)
+ /**
+ * Java only
+ *
+ * @j2sNative
+ */
+ {
+ String name = schemeName.getText().trim();
+ if (oldColourScheme != null && !"".equals(name)
+ && name.equals(oldColourScheme.getSchemeName()))
{
- /*
- * prompt to save changes to file; if done,
- * resets 'changed' flag to false
- */
- savebutton_actionPerformed();
- }
+ String message = MessageManager
+ .formatMessage("label.scheme_changed", name);
+ String title = MessageManager.getString("label.save_changes");
+ String[] options = new String[] { title,
+ MessageManager.getString("label.dont_save_changes"), };
+ final String question = JvSwingUtils.wrapTooltip(true, message);
+ int response = JvOptionPane.showOptionDialog(Desktop.desktop,
+ question, title, JvOptionPane.DEFAULT_OPTION,
+ JvOptionPane.PLAIN_MESSAGE, null, options, options[0]);
+
+ if (response == 0)
+ {
+ /*
+ * prompt to save changes to file; if done,
+ * resets 'changed' flag to false
+ */
+ savebutton_actionPerformed();
+ }
- /*
- * if user chooses not to save (either in this dialog or in the
- * save as dialogs), treat this as a new user defined colour scheme
- */
- if (changedButNotSaved)
- {
/*
- * clear scheme name and re-apply as an anonymous scheme
+ * if user chooses not to save (either in this dialog or in the
+ * save as dialogs), treat this as a new user defined colour scheme
*/
- schemeName.setText("");
- applyButton_actionPerformed();
+ if (changedButNotSaved)
+ {
+ /*
+ * clear scheme name and re-apply as an anonymous scheme
+ */
+ schemeName.setText("");
+ applyButton_actionPerformed();
+ }
}
}
}
int value = super.showOpenDialog(this);
if (!Platform.isJS())
+ /**
+ * Java only
+ *
+ * @j2sNative
+ */
{
/*
* code here is not run in JalviewJS, instead
boolean isStructureProfile = profl[0] == AlignmentAnnotation.STRUCTURE_PROFILE;
boolean isCdnaProfile = profl[0] == AlignmentAnnotation.CDNA_PROFILE;
float ht = normaliseProfile ? y - _aa.graphHeight : y1;
- final double normaliseFactor = normaliseProfile ? _aa.graphHeight : (y2 - y1);
+ final double normaliseFactor = normaliseProfile ? _aa.graphHeight
+ : (y2 - y1);
/**
* Render a single base for a sequence profile, a base pair for
s = new String(dc);
}
// next profl[] position is profile % for the character(s)
-
+
int percent = profl[c++];
if (percent == 0)
{
// (int)(scl));
// g.setColor(profcolour.findColour(dc[0]).darker());
- double sx = 1f * charWidth / fm.charsWidth(dc, 0, dc.length);
+ double sx = 1f * charWidth / fm.charsWidth(dc, 0, dc.length);
double sy = newHeight / asc;
- double newAsc = asc * sy;
+ double newAsc = asc * sy;
double newDec = dec * sy;
// it is not necessary to recalculate lm for the new font.
// note: lm.getBaselineOffsets()[lm.getBaselineIndex()]) must be 0
ht2 += newHeight;
}
else
+ /**
+ * Java only
+ *
+ * @j2sNative
+ */
{
- /*
- * Java ('normal') method is to scale the font to fit
- */
+ // Java ('normal') method is to scale the font to fit
+
final int hght = (int) (ht + (newAsc - newDec));
Font font = ofont
.deriveFont(AffineTransform.getScaleInstance(sx, sy));
Graphics2D g2 = (Graphics2D) g;
g2.setStroke(new BasicStroke(1, BasicStroke.CAP_SQUARE,
BasicStroke.JOIN_ROUND, 3f, new float[]
- { 5f, 3f }, 0f));
+ { 5f, 3f }, 0f));
y2 = (int) (y
- ((_aa.threshold.value - min) / range) * _aa.graphHeight);
public class Platform
{
- private static boolean isJS = /** @j2sNative true || */false;
+ private static boolean isJS = /** @j2sNative true || */
+ false;
+
+ private static Boolean isNoJSMac = null, isNoJSWin = null, isMac = null,
+ isWin = null;
- private static Boolean isNoJSMac = null, isNoJSWin = null,
- isMac = null, isWin = null;
-
private static Boolean isHeadless = null;
/**
* added to group mouse events into Windows and nonWindows (mac, unix, linux)
+ *
* @return
*/
public static boolean isMac()
{
- return (isMac == null ? (isMac = (System.getProperty("os.name").indexOf("Mac") >= 0)) : isMac);
+ return (isMac == null
+ ? (isMac = (System.getProperty("os.name").indexOf("Mac") >= 0))
+ : isMac);
}
/**
* added to group mouse events into Windows and nonWindows (mac, unix, linux)
+ *
* @return
*/
- public static boolean isWin()
+ public static boolean isWin()
{
- return (isWin == null ? (isWin = (System.getProperty("os.name").indexOf("Win") >= 0)) : isWin);
+ return (isWin == null
+ ? (isWin = (System.getProperty("os.name").indexOf("Win") >= 0))
+ : isWin);
}
/**
*/
public static boolean isJS()
{
- return isJS;
+ return isJS;
}
/**
*/
public static boolean isAMacAndNotJS()
{
- return (isNoJSMac == null ? (isNoJSMac = !isJS && isMac()) : isNoJSMac);
+ return (isNoJSMac == null ? (isNoJSMac = !isJS && isMac()) : isNoJSMac);
}
-/**
+ /**
* Check if we are on a Microsoft plaform...
*
* @return true if we have to cope with another platform variation
*/
public static boolean isWindowsAndNotJS()
{
- return (isNoJSWin == null ? (isNoJSWin = !isJS && isWin()) : isNoJSWin);
- }
+ return (isNoJSWin == null ? (isNoJSWin = !isJS && isWin()) : isNoJSWin);
+ }
/**
*
/**
* Answers true if the mouse event has Meta-down (Command key on Mac) or
* Ctrl-down (on other o/s). Note this answers _false_ if the Ctrl key is
- * pressed instead of the Meta/Cmd key on Mac. To test for Ctrl-pressed on Mac,
- * you can use e.isPopupTrigger().
+ * pressed instead of the Meta/Cmd key on Mac. To test for Ctrl-pressed on
+ * Mac, you can use e.isPopupTrigger().
*
* @param e
* @return
*/
protected static boolean isControlDown(MouseEvent e, boolean aMac)
{
- if (!aMac) {
- return e.isControlDown();
+ if (!aMac)
+ {
+ return e.isControlDown();
}
- // answer false for right mouse button
- // shortcut key will be META for a Mac
- return !e.isPopupTrigger()
- && (Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() & e.getModifiers()) != 0;
- // could we use e.isMetaDown() here?
+ // answer false for right mouse button
+ // shortcut key will be META for a Mac
+ return !e.isPopupTrigger()
+ && (Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()
+ & e.getModifiers()) != 0;
+ // could we use e.isMetaDown() here?
}
// BH: I don't know about that previous method. Here is what SwingJS uses.
//
/**
- * Windows (not Mac, Linux, or Unix) and right button
- * to test for the right-mouse pressed event in Windows
- * that would have opened a menu or a Mac.
+ * Windows (not Mac, Linux, or Unix) and right button to test for the
+ * right-mouse pressed event in Windows that would have opened a menu or a
+ * Mac.
*
* @param e
* @return
*/
- public static boolean isWinRightButton(MouseEvent e)
+ public static boolean isWinRightButton(MouseEvent e)
{
- // was !isAMac(), but that is true also for Linux and Unix and JS,
+ // was !isAMac(), but that is true also for Linux and Unix and JS,
- return isWin() && SwingUtilities.isRightMouseButton(e);
+ return isWin() && SwingUtilities.isRightMouseButton(e);
}
-
-
+
/**
- * Windows (not Mac, Linux, or Unix) and middle button -- for mouse wheeling
+ * Windows (not Mac, Linux, or Unix) and middle button -- for mouse wheeling
* without pressing the button.
*
* @param e
* @return
*/
- public static boolean isWinMiddleButton(MouseEvent e)
+ public static boolean isWinMiddleButton(MouseEvent e)
{
- // was !isAMac(), but that is true also for Linux and Unix and JS
- return isWin() && SwingUtilities.isMiddleMouseButton(e);
+ // was !isAMac(), but that is true also for Linux and Unix and JS
+ return isWin() && SwingUtilities.isMiddleMouseButton(e);
}
- public static boolean allowMnemonics()
+ public static boolean allowMnemonics()
{
- return !isMac();
+ return !isMac();
}
-
+
public final static int TIME_RESET = 0;
- public final static int TIME_MARK = 1;
- public static final int TIME_SET = 2;
- public static final int TIME_GET = 3;
-
+
+ public final static int TIME_MARK = 1;
+
+ public static final int TIME_SET = 2;
+
+ public static final int TIME_GET = 3;
+
public static long time, mark, set, duration;
-
- public static void timeCheck(String msg, int mode) {
- long t = System.currentTimeMillis();
- switch (mode) {
- case TIME_RESET:
- time = mark = t;
- if (msg != null)
+
+ public static void timeCheck(String msg, int mode)
+ {
+ long t = System.currentTimeMillis();
+ switch (mode)
+ {
+ case TIME_RESET:
+ time = mark = t;
+ if (msg != null)
{
System.err.println("Platform: timer reset\t\t\t" + msg);
}
- break;
- case TIME_MARK:
- if (set > 0) {
- duration += (t - set);
- } else {
- if (time == 0)
+ break;
+ case TIME_MARK:
+ if (set > 0)
{
- time = mark = t;
+ duration += (t - set);
}
- if (msg != null)
+ else
+ {
+ if (time == 0)
+ {
+ time = mark = t;
+ }
+ if (msg != null)
{
- System.err.println("Platform: timer mark\t" + ((t - time)/1000f) + "\t" + ((t - mark)/1000f) + "\t" + msg);
+ System.err.println("Platform: timer mark\t" + ((t - time) / 1000f)
+ + "\t" + ((t - mark) / 1000f) + "\t" + msg);
}
- mark = t;
- }
- break;
- case TIME_SET:
- set = t;
- break;
- case TIME_GET:
- if (msg != null)
+ mark = t;
+ }
+ break;
+ case TIME_SET:
+ set = t;
+ break;
+ case TIME_GET:
+ if (msg != null)
{
- System.err.println("Platform: timer dur\t" + ((t - time)/1000f) + "\t" + ((duration)/1000f) + "\t" + msg);
+ System.err.println("Platform: timer dur\t" + ((t - time) / 1000f)
+ + "\t" + ((duration) / 1000f) + "\t" + msg);
}
- set = 0;
- break;
- }
+ set = 0;
+ break;
+ }
}
- public static void cacheFileData(String path, byte[] data)
- {
- if (!isJS())
+ public static void cacheFileData(String path, byte[] data)
{
- return;
- /**
- * @j2sNative
- *
- * swingjs.JSUtil.cacheFileData$S$O(path, data);
- *
- */
- }
+ if (!isJS())
+ {
+ return;
+ }
+ /**
+ * @j2sNative
+ *
+ * swingjs.JSUtil.cacheFileData$S$O(path, data);
+ *
+ */
}
- public static byte[] getFileBytes(File f)
+ public static byte[] getFileBytes(File f)
{
- return /** @j2sNative f && f._bytes || */null;
+ return /** @j2sNative f && f._bytes || */
+ null;
}
- public static byte[] getFileAsBytes(String fileStr)
+ public static byte[] getFileAsBytes(String fileStr)
{
// BH 2018 hack for no support for access-origin
- return /** @j2sNative swingjs.JSUtil.getFileAsBytes$O(fileStr) || */ null;
+ return /** @j2sNative swingjs.JSUtil.getFileAsBytes$O(fileStr) || */
+ null;
}
- public static String getFileAsString(String data)
+ public static String getFileAsString(String data)
{
- return /** @j2sNative swingjs.JSUtil.getFileAsString$S(data) || */ null;
+ return /** @j2sNative swingjs.JSUtil.getFileAsString$S(data) || */
+ null;
}
- public static boolean setFileBytes(File f, String urlstring)
+ public static boolean setFileBytes(File f, String urlstring)
{
- if (!isJS())
- {
- return false;
- }
- @SuppressWarnings("unused")
- byte[] bytes = getFileAsBytes(urlstring);
- /** @j2sNative
- * f._bytes = bytes;
- */
- return true;
+ if (!isJS())
+ {
+ return false;
+ }
+ @SuppressWarnings("unused")
+ byte[] bytes = getFileAsBytes(urlstring);
+ /**
+ * @j2sNative f._bytes = bytes;
+ */
+ return true;
}
-
public static void addJ2SBinaryType(String ext)
{
- /**
- * @j2sNative
- *
- * J2S._binaryTypes.push("." + ext + "?");
- *
- */
+ /**
+ * @j2sNative
+ *
+ * J2S._binaryTypes.push("." + ext + "?");
+ *
+ */
}
- public static String encodeURI(String value)
+ public static String encodeURI(String value)
{
/**
- * @j2sNative
- * return encodeURIComponent(value);
+ * @j2sNative return encodeURIComponent(value);
*/
- return value;
+ return value;
}
- public static boolean openURL(String url)
- {
- if (!isJS())
+ public static boolean openURL(String url)
{
- return false;
- }
- /**
- * @j2sNative
- *
- *
- * window.open(url);
- */
- return true;
+ if (!isJS())
+ {
+ return false;
+ }
+ /**
+ * @j2sNative
+ *
+ *
+ * window.open(url);
+ */
+ return true;
}
- public static String getUniqueAppletID() {
- @SuppressWarnings("unused")
- ThreadGroup g = Thread.currentThread().getThreadGroup();
- /**
- * @j2sNative return g.html5Applet._uniqueId;
- *
- */
- return null;
+ public static String getUniqueAppletID()
+ {
+ @SuppressWarnings("unused")
+ ThreadGroup g = Thread.currentThread().getThreadGroup();
+ /**
+ * @j2sNative return g.html5Applet._uniqueId;
+ *
+ */
+ return null;
+
+ }
- }
/**
- * Read the Info block for this applet.
+ * Read the Info block for this applet.
*
- * @param prefix "jalview_"
+ * @param prefix
+ * "jalview_"
* @param p
- * @return unique id for this applet
+ * @return unique id for this applet
*/
- public static void readInfoProperties(String prefix, Properties p)
+ public static void readInfoProperties(String prefix, Properties p)
{
- @SuppressWarnings("unused")
- ThreadGroup g = Thread.currentThread().getThreadGroup();
- String id = getUniqueAppletID();
- String key = "", value = "";
- /**
- * @j2sNative
- var info = g.html5Applet.__Info || {};
- for (var key in info) {
- if (key.indexOf(prefix) == 0) {
- value = "" + info[key];
- */
-
- p.put(id + "_" + key, value);
-
- /**
- * @j2sNative
-
-
- }
- }
- */
- }
+ @SuppressWarnings("unused")
+ ThreadGroup g = Thread.currentThread().getThreadGroup();
+ String id = getUniqueAppletID();
+ String key = "", value = "";
+ /**
+ * @j2sNative var info = g.html5Applet.__Info || {}; for (var key in info) {
+ * if (key.indexOf(prefix) == 0) { value = "" + info[key];
+ */
+ p.put(id + "_" + key, value);
+
+ /**
+ * @j2sNative
+ *
+ *
+ * } }
+ */
+ }
}