package jalview.datamodel;
import jalview.api.DBRefEntryI;
-import jalview.io.vamsas.Dbref;
import jalview.util.DBRefUtils;
import jalview.util.MapList;
private String version = "";
- private String ucversion;
+ private String ucversion = "";
private String accessionId = "";
}
quit = false; // signals the Threads that they should exit
- // Starting two seperate threads to read from the PipedInputStreams
+ // Starting two separate threads to read from the PipedInputStreams
//
reader = new Thread(this);
reader.setDaemon(true);
public static MyDesktopPane getDesktopPane()
{
- return Desktop.getInstance().desktopPane;
+ Desktop desktop = Desktop.getInstance();
+ return desktop == null ? null : desktop.desktopPane;
}
- public StructureSelectionManager getStructureSelectionManager()
+ public static StructureSelectionManager getStructureSelectionManager()
{
return StructureSelectionManager
- .getStructureSelectionManager(this);
+ .getStructureSelectionManager(getInstance());
}
static int openFrameCount = 0;
private static int fileLoadingCount = 0;
- public JInternalFrame conservationSlider, PIDSlider;
+ public JInternalFrame conservationSlider;
+
+ public JInternalFrame PIDSlider;
/**
* just an instance (for testng, probably); no actual frames
*/
public static Desktop getInstance()
{
- return (Desktop) ApplicationSingletonProvider
- .getInstance(Desktop.class);
+ return Jalview.isHeadlessMode() ? null
+ : (Desktop) ApplicationSingletonProvider
+ .getInstance(Desktop.class);
}
/**
@SuppressWarnings("unused")
private Desktop()
{
+ try
+ {
/**
* A note to implementors. It is ESSENTIAL that any activities that might
* block are spawned off as threads rather than waited for during this
}
});
desktopPane.addMouseListener(ma);
+ } catch (Throwable t)
+ {
+ t.printStackTrace();
+ }
}
/**
public void doConfigureStructurePrefs()
{
// configure services
- StructureSelectionManager ssm = getStructureSelectionManager();
+ StructureSelectionManager ssm = StructureSelectionManager
+ .getStructureSelectionManager(this);
if (jalview.bin.Cache.getDefault(Preferences.ADD_SS_ANN, true))
{
ssm.setAddTempFacAnnot(jalview.bin.Cache
public static groovy.ui.Console getGroovyConsole()
{
- return Desktop.getInstance().groovyConsole;
+ Desktop desktop = Desktop.getInstance();
+ return desktop == null ? null : desktop.groovyConsole;
}
/**
protected void initDialogFrame(Container content, boolean modal,
boolean block, String title, int width, int height)
{
-
- frame = new JDialog(Desktop.getInstance(), modal);
+ Desktop desktop = Desktop.getInstance();
+ frame = new JDialog(desktop, modal);
frame.setTitle(title);
- if (Desktop.getInstance() != null)
+ if (desktop != null)
{
- Rectangle deskr = Desktop.getInstance().getBounds();
+ Rectangle deskr = desktop.getBounds();
frame.setBounds(new Rectangle((int) (deskr.getCenterX() - width / 2),
(int) (deskr.getCenterY() - height / 2), width, height));
}
*/
{
authlist = new JTextPane();
- Thread t = new Thread(this);
+ Thread t = new Thread(this, "SplashScreen");
t.start();
}
}
@SuppressWarnings("unused")
protected boolean refreshText()
{
- String newtext = Desktop.getInstance().getAboutMessage(true).toString();
+ Desktop desktop = Desktop.getInstance();
+ String newtext = desktop.getAboutMessage(true).toString();
// System.err.println("Text found: \n"+newtext+"\nEnd of newtext.");
if (oldtext != newtext.length())
{
authlist.setSize(new Dimension(750, 375));
add(authlist, BorderLayout.CENTER);
revalidate();
- iframe.setBounds((Desktop.getInstance().getWidth() - 750) / 2,
- (Desktop.getInstance().getHeight() - 375) / 2, 750,
+ iframe.setBounds((desktop.getWidth() - 750) / 2,
+ (desktop.getHeight() - 375) / 2, 750,
authlist.getHeight() + iconimg.getHeight());
iframe.validate();
iframe.setVisible(true);
*/
protected void discoverStructureViews()
{
- if (Desktop.getInstance() != null)
+ Desktop desktop = Desktop.getInstance();
+ if (desktop != null)
{
targetView.removeAllItems();
- Desktop d = Desktop.getInstance();
- if (d.lastTargetedView != null && !d.lastTargetedView.isVisible())
+ if (desktop.lastTargetedView != null
+ && !desktop.lastTargetedView.isVisible())
{
- d.lastTargetedView = null;
+ desktop.lastTargetedView = null;
}
int linkedViewsAt = 0;
- for (StructureViewerBase view : Desktop.getInstance()
+ for (StructureViewerBase view : desktop
.getStructureViewers(null, null))
{
- StructureViewer viewHandler = (d.lastTargetedView != null
- && d.lastTargetedView.sview == view) ? d.lastTargetedView
+ StructureViewer viewHandler = (desktop.lastTargetedView != null
+ && desktop.lastTargetedView.sview == view)
+ ? desktop.lastTargetedView
: StructureViewer.reconfigure(view);
if (view.isLinkedWith(ap))
if (targetView.getItemCount() > 0)
{
targetView.setVisible(true);
- if (d.lastTargetedView != null)
+ if (desktop.lastTargetedView != null)
{
- targetView.setSelectedItem(d.lastTargetedView);
+ targetView.setSelectedItem(desktop.lastTargetedView);
}
else
{
*/
public class HttpServer implements ApplicationSingletonI
{
+ /*
+ * 'context root' - actually just prefixed to the path for each handler for
+ * now - see registerHandler
+ */
+ private static final String JALVIEW_PATH = "jalview";
+
+ /*
+ * The Http server
+ */
+ private Server server;
+
+ /*
+ * Registered handlers for context paths
+ */
+ private HandlerCollection contextHandlers;
+
+ /*
+ * Lookup of ContextHandler by its wrapped handler
+ */
+ Map<Handler, ContextHandler> myHandlers = new HashMap<>();
+
+ /*
+ * The context root for the server
+ */
+ private URI contextRoot;
/**
* Returns the singleton instance of this class.
registerHandler(RestHandler.getInstance());
}
- /*
- * 'context root' - actually just prefixed to the path for each handler for
- * now - see registerHandler
- */
- private static final String JALVIEW_PATH = "jalview";
-
- /*
- * The Http server
- */
- private Server server;
-
- /*
- * Registered handlers for context paths
- */
- private HandlerCollection contextHandlers;
-
- /*
- * Lookup of ContextHandler by its wrapped handler
- */
- Map<Handler, ContextHandler> myHandlers = new HashMap<>();
-
- /*
- * The context root for the server
- */
- private URI contextRoot;
-
/**
* Start the http server
*
}
}
- // /**
- // * Answers true if HTML export is invoke in headless mode or false otherwise
- // *
- // * @return
- // */
- // protected boolean isHeadless()
- // {
- // return System.getProperty("java.awt.headless") != null
- // && System.getProperty("java.awt.headless").equals("true");
- // }
-
/**
* This method provides implementation of consistent behaviour which should
* occur after a HTML file export. It MUST be called at the end of the
public class JalviewFileFilter extends FileFilter
{
- // public static Hashtable suffixHash = new Hashtable();
-
private Map<String, JalviewFileFilter> filters = null;
private String description = "no description";
{
return filename.substring(i + 1).toLowerCase();
}
-
- ;
}
return "";
/**
* A simple handler to process (or delegate) HTTP requests on /jalview/rest.
- * Accessed only by HttpServer.
*/
public class RestHandler extends AbstractRequestHandler
implements ApplicationSingletonI
/**
* Answers an instance of this class scoped to the given context. The instance
* is created on the first request for the context, thereafter the same
- * instance is returned.
+ * instance is returned. Note that the context may be null (this is the case
+ * when running headless without a Desktop).
*
* @param context
* @return
*/
public class IdOrgSettings implements ApplicationSingletonI
{
+ private String url;
- private IdOrgSettings()
- {
- // private singleton
- }
+ private String location;
private static IdOrgSettings getInstance()
{
.getInstance(IdOrgSettings.class);
}
- private String url;
-
- private String location;
-
public static void setUrl(String seturl)
{
getInstance().url = seturl;
{
return getInstance().location;
}
+
+ private IdOrgSettings()
+ {
+ // private singleton
+ }
}
import java.lang.reflect.Method;
/**
- *
- * SwingJS note: Do not use methods in this class directly. Use
- *
- * Platform.openURL(String url) only.
- *
- * JavaScript does not see this class.
- *
* BrowserLauncher is a class that provides two static methods:
*
* openURL(String url), which opens the default web browser for the current user
*
* resetBrowser(), which allows switching browsers in Java.
*
- *
* openURL may support other protocols depending on the system -- mailto, ftp,
* etc. -- but that has not been rigorously tested and is not guaranteed to
* work.
* "mailto:ejalbert@cs.stanford.edu">ejalbert@cs.stanford.edu</a>)
* @version 1.4b1 (Released June 20, 2001)
*/
+/*
+ *
+ * SwingJS note: Do not use methods in this class directly. Use
+ *
+ * Platform.openURL(String url) only.
+ *
+ * JavaScript does not see this class.
+ */
public class BrowserLauncher
{
/**
import java.util.Arrays;
import java.util.List;
-import junit.extensions.PA;
-
import org.testng.annotations.Test;
+import junit.extensions.PA;
+
public class AlignmentSorterTest
{
@Test(groups = "Functional")
/*
* sort with no score features does nothing
*/
- PA.setValue(AlignmentSorter.class, "sortByFeatureCriteria", null);
+ AlignmentSorter sorter = (AlignmentSorter) PA
+ .invokeMethod(AlignmentSorter.class, "getInstance()",
+ new Object[] {});
+ PA.setValue(sorter, "sortByFeatureCriteria", null);
AlignmentSorter.sortByFeature(null, null, 0, al.getWidth(), al,
AlignmentSorter.FEATURE_SCORE);
* sort by ascending score, no filter on feature type or group
* NB sort order for the same feature set (none) gets toggled, so descending
*/
- PA.setValue(AlignmentSorter.class, "sortByFeatureAscending", true);
+ PA.setValue(sorter, "sortByFeatureAscending", true);
AlignmentSorter.sortByFeature(null, null, 0, al.getWidth(), al,
AlignmentSorter.FEATURE_SCORE);
assertSame(al.getSequenceAt(3), seq3); // -0.5
import static org.testng.Assert.assertEquals;
+import jalview.bin.Cache;
import jalview.datamodel.AlignmentI;
import jalview.io.DataSourceType;
import jalview.io.FileLoader;
import java.awt.Font;
import java.awt.FontMetrics;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import junit.extensions.PA;
public class SeqCanvasTest
{
+ @BeforeClass(alwaysRun = true)
+ public void setUp()
+ {
+ Cache.initLogger();
+ }
+
/**
* Test the method that computes wrapped width in residues, height of wrapped
* widths in pixels, and the number of widths visible
public class FeaturesFileTest
{
+ private static final String LINE_SEPARATOR = System.getProperty("line.separator");
private static String simpleGffFile = "examples/testdata/simpleGff3.gff";
@AfterClass(alwaysRun = true)
/*
* remove any sequence mappings created so they don't pollute other tests
*/
- Desktop.getInstance().getStructureSelectionManager().resetAll();
+ Desktop.getStructureSelectionManager().resetAll();
}
@BeforeClass(alwaysRun = true)
+ "desc1\tFER_CAPAN\t-1\t0\t0\tPfam\t1.3\n\n"
+ "desc3\tFER1_SOLLC\t-1\t0\t0\tPfam\n"; // NaN is not output
assertEquals(
- expected.replace("\n", System.getProperty("line.separator")),
+ expected.replace("\n", LINE_SEPARATOR),
exported);
/*
// METAL feature has null group: description used for column 2
expected = gffHeader + "FER_CAPAA\tCath\tMETAL\t39\t39\t1.2\t.\t.\n";
assertEquals(
- expected.replace("\n", System.getProperty("line.separator")),
+ expected.replace("\n", LINE_SEPARATOR),
exported);
/*
expected = gffHeader + "FER_CAPAA\tCath\tMETAL\t39\t39\t1.2\t.\t.\n"
+ "FER_CAPAN\ts3dm\tGAMMA-TURN\t36\t38\t2.1\t.\t.\n";
assertEquals(
- expected.replace("\n", System.getProperty("line.separator")),
+ expected.replace("\n", LINE_SEPARATOR),
exported);
/*
+ "FER_CAPAA\tCath\tMETAL\t39\t39\t1.2\t.\t.\n"
+ "FER_CAPAN\ts3dm\tGAMMA-TURN\t36\t38\t2.1\t.\t.\n"
+ "FER_CAPAN\tUniprot\tPfam\t20\t20\t0.0\t+\t2\tx=y;black=white\n";
- assertEquals(
- expected.replace("\n", System.getProperty("line.separator")),
- exported);
+ assertEquals(fixLineEnd(expected), exported);
}
private String fixLineEnd(String s)
{
- return s.replace("\n", System.getProperty("line.separator"));
+ return s.replace("\n", LINE_SEPARATOR);
}
/**
+ "Cath\tFER_CAPAA\t-1\t39\t39\tMETAL\t1.2\n"
+ "ENDGROUP\tgrp1\n";
assertEquals(
- expected.replace("\n", System.getProperty("line.separator")),
+ expected.replace("\n", LINE_SEPARATOR),
exported);
/*