import jalview.util.ColorUtils;
import jalview.util.FileUtils;
import jalview.util.HttpUtils;
+import jalview.util.IdUtils;
+import jalview.util.IdUtils.IdType;
import jalview.util.ImageMaker;
import jalview.util.ImageMaker.TYPE;
import jalview.util.MessageManager;
desktop.setProgressBar(
MessageManager.getString(
"status.processing_commandline_args"),
- progress = System.currentTimeMillis());
+ progress = IdUtils.newId(IdType.PROGRESS));
progressBarSet = true;
}
}
}
}
-
// Show secondary structure annotations?
boolean showSSAnnotations = avm.getFromSubValArgOrPref(
Arg.SHOWSSANNOTATIONS, av.getSubVals(), null,
"STRUCT_FROM_PDB", true);
-
+
// Show sequence annotations?
boolean showAnnotations = avm.getFromSubValArgOrPref(
Arg.SHOWANNOTATIONS, av.getSubVals(), null,
"SHOW_ANNOTATIONS", true);
-
+
boolean hideTFrows = (avm.getBoolean(Arg.NOTEMPFAC));
final AlignFrame _af = af;
- // many of jalview's format/layout methods are only thread safe on the swingworker thread.
- // all these methods should be on the alignViewController so it can coordinate such details
+ // many of jalview's format/layout methods are only thread safe on the
+ // swingworker thread.
+ // all these methods should be on the alignViewController so it can
+ // coordinate such details
try
{
SwingUtilities.invokeAndWait(new Runnable()
}
}
if (progressBarSet && desktop != null)
+ {
desktop.setProgressBar(null, progress);
-
+ }
}
// open the structure (from same PDB file or given PDBfile)
import jalview.schemes.ColourSchemeProperty;
import jalview.util.ChannelProperties;
import jalview.util.HttpUtils;
+import jalview.util.IdUtils;
+import jalview.util.IdUtils.IdType;
import jalview.util.LaunchUtils;
import jalview.util.MessageManager;
import jalview.util.Platform;
public void addFetcher(final AlignFrame af,
final Vector<String> dasSources)
{
- final long id = System.currentTimeMillis();
+ final long id = IdUtils.newId(IdType.PROGRESS);
queued++;
final FeatureFetcher us = this;
new Thread(new Runnable()
desktop.setProgressBar(
MessageManager
.getString("status.processing_commandline_args"),
- progress = System.currentTimeMillis());
+ progress = IdUtils.newId(IdType.PROGRESS));
}
Console.outPrintln("CMD [-open " + file + "] executed successfully!");
import jalview.io.FileFormat;
import jalview.io.FormatAdapter;
import jalview.util.Comparison;
+import jalview.util.IdUtils;
+import jalview.util.IdUtils.IdType;
import jalview.util.MessageManager;
import jalview.util.Platform;
MessageManager.formatMessage(
"action.clustering_matrix_for",
cm.getAnnotDescr(), 5f),
- progBar = System.currentTimeMillis());
+ progBar = IdUtils.newId(IdType.PROGRESS));
cm.setGroupSet(GroupSet.makeGroups(cm, true));
cm.randomlyReColourGroups();
cm.transferGroupColorsTo(alignmentAnnotation);
* @param width
* Width for scaling labels
*/
- public void drawComponent(Graphics g, boolean clip, int givenWidth, boolean forGUI)
+ public void drawComponent(Graphics g, boolean clip, int givenWidth,
+ boolean forGUI)
{
int width = givenWidth;
IdwidthAdjuster iwa = null;
{
Graphics2D g2d = (Graphics2D) g;
Graphics dummy = g2d.create();
- int newAnnotationIdWidth = drawLabels(dummy, clip, width, false, forGUI,
- null, false);
+ int newAnnotationIdWidth = drawLabels(dummy, clip, width, false,
+ forGUI, null, false);
dummy.dispose();
Dimension d = ap.calculateDefaultAlignmentIdWidth();
int alignmentIdWidth = d.width;
}
else
{
- int newAnnotationIdWidth = drawLabels(g, clip, width, false, forGUI, null, false);
- width = newAnnotationIdWidth<givenWidth ? givenWidth: Math.min(newAnnotationIdWidth, givenWidth);
+ int newAnnotationIdWidth = drawLabels(g, clip, width, false, forGUI,
+ null, false);
+ width = newAnnotationIdWidth < givenWidth ? givenWidth
+ : Math.min(newAnnotationIdWidth, givenWidth);
}
drawLabels(g, clip, width, true, forGUI, null, false);
}
* fmetrics must be supplied.
*
* @param g
- * Graphics2D instance (used for rendering and font scaling if no fmetrics supplied)
+ * Graphics2D instance (used for rendering and font scaling if no
+ * fmetrics supplied)
* @param clip
* - true indicates that only current visible area needs to be
* rendered
* @param width
* Width for scaling labels
- * @param actuallyDraw - when false, no graphics are rendered to g0
- * @param forGUI - when false, GUI relevant marks like indicators for dragging annotation panel height are not rendered
+ * @param actuallyDraw
+ * - when false, no graphics are rendered to g0
+ * @param forGUI
+ * - when false, GUI relevant marks like indicators for dragging
+ * annotation panel height are not rendered
* @param fmetrics
* FontMetrics if Graphics object g is null
- * @param includeHidden - when true returned width includes labels in hidden row width calculation
+ * @param includeHidden
+ * - when true returned width includes labels in hidden row width
+ * calculation
* @return the width of the annotation labels.
*/
public int drawLabels(Graphics g0, boolean clip, int width,
- boolean actuallyDraw, boolean forGUI, FontMetrics fmetrics, boolean includeHidden)
+ boolean actuallyDraw, boolean forGUI, FontMetrics fmetrics,
+ boolean includeHidden)
{
if (clip)
{
}
}
- if (!resizePanel && dragEvent != null && aa != null && selectedRow>-1 && selectedRow<aa.length)
+ if (!resizePanel && dragEvent != null && aa != null && selectedRow > -1
+ && selectedRow < aa.length)
{
if (actuallyDraw && g != null)
{
*/
package jalview.gui;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
import jalview.analysis.AlignmentUtils;
import jalview.analysis.CrossRef;
import jalview.api.AlignmentViewPanel;
import jalview.io.gff.SequenceOntologyI;
import jalview.structure.StructureSelectionManager;
import jalview.util.DBRefUtils;
+import jalview.util.IdUtils;
+import jalview.util.IdUtils.IdType;
import jalview.util.MapList;
import jalview.util.MappingUtils;
import jalview.util.MessageManager;
import jalview.viewmodel.seqfeatures.FeatureRendererModel;
import jalview.ws.SequenceFetcher;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
/**
* Factory constructor and runnable for discovering and displaying
* cross-references for a set of aligned sequences
@Override
public void run()
{
- final long sttime = System.currentTimeMillis();
+ final long id = IdUtils.newId(IdType.PROGRESS);
alignFrame.setProgressBar(MessageManager.formatMessage(
"status.searching_for_sequences_from", new Object[]
- { source }), sttime);
+ { source }), id);
try
{
AlignmentI alignment = alignFrame.getViewport().getAlignment();
{
alignFrame.setProgressBar(MessageManager.formatMessage(
"status.finished_searching_for_sequences_from", new Object[]
- { source }), sttime);
+ { source }), id);
}
}
if (copyAlignment.getHeight() <= 0)
{
- jalview.bin.Console.errPrintln("No Sequences generated for xRef type " + source);
+ jalview.bin.Console
+ .errPrintln("No Sequences generated for xRef type " + source);
return null;
}
import jalview.urls.IdOrgSettings;
import jalview.util.BrowserLauncher;
import jalview.util.ChannelProperties;
+import jalview.util.IdUtils;
+import jalview.util.IdUtils.IdType;
import jalview.util.ImageMaker.TYPE;
import jalview.util.LaunchUtils;
import jalview.util.MessageManager;
@Override
public void run()
{
- long now = System.currentTimeMillis();
+ long progressId = IdUtils.newId(IdType.PROGRESS);
Desktop.instance.setProgressBar(
- MessageManager.getString("status.refreshing_news"), now);
+ MessageManager.getString("status.refreshing_news"),
+ progressId);
jvnews.refreshNews();
- Desktop.instance.setProgressBar(null, now);
+ Desktop.instance.setProgressBar(null, progressId);
jvnews.showNews();
}
}).start();
}
/**
- * close everything, stash window geometries, and shut down all associated threads/workers
- * @param dispose - sets the dispose on close flag - JVM may terminate when set
- * @param terminateJvm - quit with prejudice - stops the JVM.
+ * close everything, stash window geometries, and shut down all associated
+ * threads/workers
+ *
+ * @param dispose
+ * - sets the dispose on close flag - JVM may terminate when set
+ * @param terminateJvm
+ * - quit with prejudice - stops the JVM.
*/
- public void quitTheDesktop(boolean dispose, boolean terminateJvm) {
+ public void quitTheDesktop(boolean dispose, boolean terminateJvm)
+ {
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
Cache.setProperty("SCREENGEOMETRY_WIDTH", screen.width + "");
Cache.setProperty("SCREENGEOMETRY_HEIGHT", screen.height + "");
- storeLastKnownDimensions("", new Rectangle(getBounds().x,
- getBounds().y, getWidth(), getHeight()));
+ storeLastKnownDimensions("", new Rectangle(getBounds().x, getBounds().y,
+ getWidth(), getHeight()));
if (jconsole != null)
{
// instance.dispose();
}
}
+
public QuitHandler.QResponse desktopQuit(boolean ui, boolean disposeFlag)
{
final Runnable doDesktopQuit = () -> {
- // FIRST !! check for aborted quit
+ // FIRST !! check for aborted quit
if (QuitHandler.quitCancelled())
{
- jalview.bin.Console.debug("Quit was cancelled - Desktop aborting quit");
+ jalview.bin.Console
+ .debug("Quit was cancelled - Desktop aborting quit");
return;
}
-
+
// Proceed with quitting
- quitTheDesktop(disposeFlag, QuitHandler.gotQuitResponse() == QResponse.FORCE_QUIT);
+ quitTheDesktop(disposeFlag,
+ QuitHandler.gotQuitResponse() == QResponse.FORCE_QUIT);
// and exit the JVM
instance.quit();
};
}
/**
- * Exits the program and the JVM.
+ * Exits the program and the JVM.
*
* Don't call this directly
*
* - use desktopQuit() above to tidy up first.
*
- * - use closeDesktop() to shutdown Jalview without shutting down the JVM
+ * - use closeDesktop() to shutdown Jalview without shutting down the JVM
*
*/
@Override
// TODO: refactor to Jalview desktop session controller action.
setProgressBar(MessageManager.formatMessage(
"label.saving_jalview_project", new Object[]
- { chosenFile.getName() }), chosenFile.hashCode());
+ { chosenFile.getName() }),
+ IdUtils.newId(IdType.PROGRESS, chosenFile));
Cache.setProperty("LAST_DIRECTORY", chosenFile.getParent());
// TODO catch and handle errors for savestate
// TODO prevent user from messing with the Desktop whilst we're saving
MessageManager.getString("label.couldnt_save_project"),
JvOptionPane.WARNING_MESSAGE);
}
- setProgressBar(null, chosenFile.hashCode());
+ setProgressBar(null, IdUtils.newId(IdType.PROGRESS, chosenFile));
}
}).start();
}
*/
public static void showUrl(final String url)
{
- if (url!=null && !url.trim().equals("")) {
- jalview.bin.Console.info("Opening URL: "+url);
+ if (url != null && !url.trim().equals(""))
+ {
+ jalview.bin.Console.info("Opening URL: " + url);
showUrl(url, Desktop.instance);
- } else {
+ }
+ else
+ {
jalview.bin.Console.warn("Ignoring attempt to show an empty URL.");
}
-
+
}
/**
{
progress.setProgressBar(MessageManager
.formatMessage("status.opening_params", new Object[]
- { url }), this.hashCode());
+ { url }), IdUtils.newId(IdType.PROGRESS, this));
}
jalview.util.BrowserLauncher.openURL(url);
} catch (Exception ex)
}
if (progress != null)
{
- progress.setProgressBar(null, this.hashCode());
+ progress.setProgressBar(null,
+ IdUtils.newId(IdType.PROGRESS, this));
}
}
}).start();
}
/**
- * closes the current instance window, but leaves the JVM running.
- * Bypasses any shutdown prompts, but does not set window dispose on close in case JVM terminates.
+ * closes the current instance window, but leaves the JVM running. Bypasses
+ * any shutdown prompts, but does not set window dispose on close in case JVM
+ * terminates.
*/
public static void closeDesktop()
{
import jalview.io.exceptions.ImageOutputException;
import jalview.jbgui.GPCAPanel;
import jalview.math.RotatableMatrix.Axis;
+import jalview.util.IdUtils;
+import jalview.util.IdUtils.IdType;
import jalview.util.ImageMaker;
import jalview.util.MessageManager;
import jalview.viewmodel.AlignmentViewport;
public void run()
{
working = true;
- long progId = System.currentTimeMillis();
+ long progId = IdUtils.newId(IdType.PROGRESS);
IProgressIndicator progress = this;
String message = MessageManager.getString("label.pca_recalculating");
if (getParent() == null)
}
}
+ @Override
public void makePCAImage(ImageMaker.TYPE type)
{
int width = getRotatableCanvas().getWidth();
};
String pca = MessageManager.getString("label.pca");
ImageExporter exporter = new ImageExporter(writer, null, type, pca);
- try {
+ try
+ {
exporter.doExport(null, this, width, height, pca);
- } catch (ImageOutputException ioex) {
- Console.error("Unexpected error whilst writing "+type.toString(),ioex);
+ } catch (ImageOutputException ioex)
+ {
+ Console.error("Unexpected error whilst writing " + type.toString(),
+ ioex);
}
}
import jalview.io.FileFormatI;
import jalview.io.gff.SequenceOntologyI;
import jalview.util.DBRefUtils;
+import jalview.util.IdUtils;
+import jalview.util.IdUtils.IdType;
import jalview.util.MessageManager;
import jalview.util.Platform;
import jalview.ws.seqfetcher.DbSourceProxy;
"status.fetching_sequence_queries_from", new String[]
{ Integer.valueOf(nqueries).toString(),
proxy.getDbName() }),
- Thread.currentThread().hashCode());
+ IdUtils.newId(IdType.PROGRESS, Thread.currentThread()));
if (proxy.getMaximumQueryCount() == 1)
{
/*
}
guiWindow.setProgressBar(
MessageManager.getString("status.finshed_querying"),
- Thread.currentThread().hashCode());
+ IdUtils.newId(IdType.PROGRESS, Thread.currentThread()));
}
guiWindow
.setProgressBar(
? MessageManager
.getString("status.parsing_results")
: MessageManager.getString("status.processing"),
- Thread.currentThread().hashCode());
+ IdUtils.newId(IdType.PROGRESS, Thread.currentThread()));
// process results
while (presult.size() > 0)
{
preferredFeatureColours);
}
// only remove visual delay after we finished parsing.
- guiWindow.setProgressBar(null, Thread.currentThread().hashCode());
+ guiWindow.setProgressBar(null,
+ IdUtils.newId(IdType.PROGRESS, Thread.currentThread()));
if (nextFetch.size() > 0)
{
StringBuffer sb = new StringBuffer();
import jalview.structure.StructureImportSettings.TFType;
import jalview.structure.StructureMapping;
import jalview.structure.StructureSelectionManager;
+import jalview.util.IdUtils;
+import jalview.util.IdUtils.IdType;
import jalview.util.MessageManager;
import jalview.util.Platform;
import jalview.util.StringUtils;
List<SequenceI> seqsWithoutSourceDBRef = null;
private boolean showChooserGUI = true;
+
/**
- * when true, queries to external services are supressed (no SIFTs, no PDBe, no 3D-Beacons, etc)
+ * when true, queries to external services are supressed (no SIFTs, no PDBe,
+ * no 3D-Beacons, etc)
*/
private boolean dontQueryServices = false;
{
this(selectedSeqs, selectedSeq, ap, showGUI, false);
}
-
+
public StructureChooser(SequenceI[] selectedSeqs, SequenceI selectedSeq,
AlignmentPanel ap, boolean showGUI, boolean dontQueryServices)
{
}
}).start();
- } else {
- Console.debug("Structure chooser not querying services to discover metadata.");
+ }
+ else
+ {
+ Console.debug(
+ "Structure chooser not querying services to discover metadata.");
}
}
*/
public void promptForTDBFetch(boolean ignoreGui)
{
- final long progressId = System.currentTimeMillis();
+ final long progressId = IdUtils.newId(IdType.PROGRESS);
// final action after prompting and discovering db refs
final Runnable strucDiscovery = new Runnable()
.getFTSDataFor(getResultTable(), selectedRow,
discoveredStructuresSet);
String pageUrl = row.getModelViewUrl();
-
+
JPopupMenu popup = new JPopupMenu("3D Beacons");
JMenuItem viewUrl = new JMenuItem("View model web page");
- if (pageUrl == null || "".equals(pageUrl.trim())) {
+ if (pageUrl == null || "".equals(pageUrl.trim()))
+ {
viewUrl.setEnabled(false);
viewUrl.setText("No model page available.");
}
final String progress = MessageManager
.getString("label.working_ellipsis");
- setProgressBar(progress, progress.hashCode());
+ setProgressBar(progress, IdUtils.newId(IdType.PROGRESS, progress));
Runnable viewStruc = new Runnable()
{
@Override
@Override
public void run()
{
- setProgressBar("Complete.", progress.hashCode());
+ setProgressBar("Complete.",
+ IdUtils.newId(IdType.PROGRESS, progress));
closeAction(preferredHeight);
mainFrame.dispose();
}
// headless = true;
prompt = false;
// suppress structure viewer's external service queries
- sc = new StructureChooser(new SequenceI[] { seq }, seq, ap, false,true);
+ sc = new StructureChooser(new SequenceI[] { seq }, seq, ap, false,
+ true);
}
if (ssm == null)
{
import jalview.structure.StructureMapping;
import jalview.structures.models.AAStructureBindingModel;
import jalview.util.BrowserLauncher;
+import jalview.util.IdUtils;
+import jalview.util.IdUtils.IdType;
import jalview.util.MessageManager;
import jalview.ws.dbsources.EBIAlfaFold;
import jalview.ws.dbsources.Pdb;
}
/**
- * Singleton list of all (open) instances of structureViewerBase
- * TODO: JAL-3362 - review and adopt the swingJS-safe singleton pattern so each structure viewer base instance is kept to its own JalviewJS parent
+ * Singleton list of all (open) instances of structureViewerBase TODO:
+ * JAL-3362 - review and adopt the swingJS-safe singleton pattern so each
+ * structure viewer base instance is kept to its own JalviewJS parent
*/
private static List<JalviewStructureDisplayI> svbs = new ArrayList<>();
*
* @return TRUE if the view is NOT being coloured by the alignment colours.
*/
+ @Override
public boolean isColouredByViewer()
{
return !getBinding().isColourBySequence();
}
+ @Override
public String getViewId()
{
if (viewId == null)
}
}
+ @Override
public abstract ViewerType getViewerType();
/**
chainMenu.add(menuItem);
}
}
- void setHetatmMenuItems(Map<String,String> hetatmNames)
+
+ void setHetatmMenuItems(Map<String, String> hetatmNames)
{
hetatmMenu.removeAll();
if (hetatmNames == null || hetatmNames.isEmpty())
return;
}
hetatmMenu.setVisible(true);
- allHetatmBeingSelected=false;
+ allHetatmBeingSelected = false;
JMenuItem allMenuItem = new JMenuItem(
MessageManager.getString("label.all"));
JMenuItem noneMenuItem = new JMenuItem(
allMenuItem.addActionListener(new ActionListener()
{
@Override
- public void actionPerformed(ActionEvent e) {
+ public void actionPerformed(ActionEvent e)
{
- allHetatmBeingSelected=true;
- // Toggle state of everything - on
- for (int i = 0; i < hetatmMenu.getItemCount(); i++)
{
- if (hetatmMenu.getItem(i) instanceof JCheckBoxMenuItem)
+ allHetatmBeingSelected = true;
+ // Toggle state of everything - on
+ for (int i = 0; i < hetatmMenu.getItemCount(); i++)
{
- ((JCheckBoxMenuItem) hetatmMenu.getItem(i)).setSelected(true);
+ if (hetatmMenu.getItem(i) instanceof JCheckBoxMenuItem)
+ {
+ ((JCheckBoxMenuItem) hetatmMenu.getItem(i)).setSelected(true);
+ }
}
+ allHetatmBeingSelected = false;
+ showSelectedHetatms();
}
- allHetatmBeingSelected=false;
- showSelectedHetatms();
}
- }});
+ });
noneMenuItem.addActionListener(new ActionListener()
{
@Override
- public void actionPerformed(ActionEvent e) {
+ public void actionPerformed(ActionEvent e)
{
- allHetatmBeingSelected=true;
- // Toggle state of everything off
- for (int i = 0; i < hetatmMenu.getItemCount(); i++)
{
- if (hetatmMenu.getItem(i) instanceof JCheckBoxMenuItem)
+ allHetatmBeingSelected = true;
+ // Toggle state of everything off
+ for (int i = 0; i < hetatmMenu.getItemCount(); i++)
{
- ((JCheckBoxMenuItem) hetatmMenu.getItem(i)).setSelected(false);
+ if (hetatmMenu.getItem(i) instanceof JCheckBoxMenuItem)
+ {
+ ((JCheckBoxMenuItem) hetatmMenu.getItem(i))
+ .setSelected(false);
+ }
}
+ allHetatmBeingSelected = false;
+ showSelectedHetatms();
}
- allHetatmBeingSelected=false;
- showSelectedHetatms();
}
- }});
+ });
hetatmMenu.add(noneMenuItem);
hetatmMenu.add(allMenuItem);
for (Map.Entry<String, String> chain : hetatmNames.entrySet())
{
- JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(chain.getKey(), false);
+ JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(chain.getKey(),
+ false);
menuItem.setToolTipText(chain.getValue());
menuItem.addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent evt)
{
if (!allHetatmBeingSelected)
- {
+ {
// update viewer only when we were clicked, not programmatically
// checked/unchecked
showSelectedHetatms();
{
// TODO would rather have startProgress/stopProgress as the
// IProgressIndicator interface
- long tm = random.nextLong();
+ long tm = IdUtils.newId(IdType.PROGRESS);
if (progressBar != null)
{
progressBar.setProgressBar(msg, tm);
}
getBinding().showChains(toshow);
}
+
/**
* Display selected hetatms in viewer
*/
}
getBinding().showHetatms(toshow);
}
+
/**
* Tries to fetch a PDB file and save to a temporary local file. Returns the
* saved file path if successful, or null if not.
EBIAlfaFold afclient = new EBIAlfaFold();
AlignmentI pdbseq = null;
String pdbid = processingEntry.getId();
- long handle = System.currentTimeMillis()
- + Thread.currentThread().hashCode();
+ long handle = IdUtils.newId(IdType.PROGRESS);
/*
* Write 'fetching PDB' progress on AlignFrame as we are not yet visible
*
* @return
*/
+ @Override
public File saveSession()
{
if (getBinding() == null)
// TODO: check for memory leaks where instance isn't finalised because jmb
// holds a reference to the window
// jmb = null;
-
- try {
+
+ try
+ {
svbs.remove(this);
} catch (Throwable t)
{
- Console.info("Unexpected exception when deregistering structure viewer",t);
+ Console.info(
+ "Unexpected exception when deregistering structure viewer",
+ t);
}
dispose();
}
import jalview.bin.Cache;
import jalview.jbgui.GWsPreferences;
+import jalview.util.IdUtils;
+import jalview.util.IdUtils.IdType;
import jalview.util.MessageManager;
import jalview.ws.jws2.Jws2Discoverer;
import jalview.ws.rest.RestServiceDescription;
@Override
public void run()
{
- long ct = System.currentTimeMillis();
+ long ct = IdUtils.newId(IdType.PROGRESS);
Desktop.instance.setProgressBar(MessageManager
.getString("status.refreshing_web_service_menus"), ct);
if (lastrefresh != update)
import jalview.gui.AlignmentPanel;
import jalview.gui.IProgressIndicator;
import jalview.io.exceptions.ImageOutputException;
+import jalview.util.IdUtils;
+import jalview.util.IdUtils.IdType;
import jalview.util.MessageManager;
public abstract class HTMLOutput implements Runnable
this.ap = ap;
this.pIndicator = ap.alignFrame;
this.description = desc;
- this.pSessionId = System.currentTimeMillis();
+ this.pSessionId = IdUtils.newId(IdType.PROGRESS);
}
/**
exportHTML(outputFile, null);
}
- public void exportHTML(String outputFile, String renderer) throws ImageOutputException
+ public void exportHTML(String outputFile, String renderer)
+ throws ImageOutputException
{
setProgressMessage(MessageManager.formatMessage(
"status.exporting_alignment_as_x_file", getDescription()));
import jalview.io.DataSourceType;
import jalview.io.StructureFile;
import jalview.structure.StructureImportSettings.TFType;
+import jalview.util.IdUtils;
+import jalview.util.IdUtils.IdType;
import jalview.util.MappingUtils;
import jalview.util.MessageManager;
import jalview.util.Platform;
{
if (mappings.isEmpty())
{
- jalview.bin.Console.errPrintln("reportMapping: No PDB/Sequence mappings.");
+ jalview.bin.Console
+ .errPrintln("reportMapping: No PDB/Sequence mappings.");
}
else
{
int i = 0;
for (StructureMapping sm : mappings)
{
- jalview.bin.Console.errPrintln("mapping " + i++ + " : " + sm.pdbfile);
+ jalview.bin.Console
+ .errPrintln("mapping " + i++ + " : " + sm.pdbfile);
}
}
}
pdbFile, sourceType, tft, paeFilename, true);
}
-
/**
* create sequence structure mappings between each sequence and the given
* pdbFile (retrieved via the given protocol). Either constructs a mapping
* - structure data resource
* @param sourceType
* - how to resolve data from resource
- * @param tft - specify how to interpret the temperature factor column in the atom data
- * @param paeFilename - when not null, specifies a filename containing a matrix formatted in JSON using one of the known PAE formats
- * @param doXferSettings - when true, transfer annotation to mapped sequences in sequenceArray
+ * @param tft
+ * - specify how to interpret the temperature factor column in the
+ * atom data
+ * @param paeFilename
+ * - when not null, specifies a filename containing a matrix
+ * formatted in JSON using one of the known PAE formats
+ * @param doXferSettings
+ * - when true, transfer annotation to mapped sequences in
+ * sequenceArray
* @return null or the structure data parsed as a pdb file
*/
synchronized public StructureFile setMapping(boolean forStructureView,
* @param IProgressIndicator
* reference to UI component that maintains a progress bar for the
* mapping operation
- * @param tft - specify how to interpret the temperature factor column in the atom data
- * @param paeFilename - when not null, specifies a filename containing a matrix formatted in JSON using one of the known PAE formats
- * @param doXferSettings - when true, transfer annotation to mapped sequences in sequenceArray
+ * @param tft
+ * - specify how to interpret the temperature factor column in the
+ * atom data
+ * @param paeFilename
+ * - when not null, specifies a filename containing a matrix
+ * formatted in JSON using one of the known PAE formats
+ * @param doXferSettings
+ * - when true, transfer annotation to mapped sequences in
+ * sequenceArray
* @return null or the structure data parsed as a pdb file
*/
synchronized public StructureFile computeMapping(boolean forStructureView,
IProgressIndicator progress, TFType tft, String paeFilename,
boolean doXferSettings)
{
- long progressSessionId = System.currentTimeMillis() * 3;
+ long progressSessionId = IdUtils.newId(IdType.PROGRESS);
/**
* do we extract and transfer annotation from 3D data ?
--- /dev/null
+package jalview.util;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import jalview.bin.Console;
+
+public class IdUtils
+{
+ /**
+ * id generating tools avoiding Random.nextLong() for JalviewJS. Avoids
+ * collisions.
+ */
+
+ public static enum IdType
+ {
+ GENERAL, PROGRESS;
+ }
+
+ private static int count = 0;
+
+ private static Map<IdType, Set<Long>> typeMap = new HashMap<>();
+
+ static
+ {
+ for (IdType t : IdType.values())
+ {
+ typeMap.put(t, new HashSet<>());
+ }
+ }
+
+ public static long newId()
+ {
+ return newId(IdType.GENERAL, null);
+ }
+
+ public static long newId(IdType t)
+ {
+ return newId(t, null);
+ }
+
+ public static long newId(IdType t, Object o)
+ {
+ Set<Long> idSet = typeMap.get(t);
+ long newId = 0;
+ if (o == null)
+ {
+ // get a new hashCode -- not tied to an object.
+ // Adding Integer.MAX_VALUE should avoid collisions with object generated
+ // Ids.
+ newId = Integer.MAX_VALUE + t.hashCode() + System.currentTimeMillis()
+ + count;
+ while (idSet.contains(newId))
+ {
+ newId += count;
+ }
+ }
+ else
+ {
+ // generate the hashcode tied to this object for this type
+ newId = t.hashCode() + o.hashCode();
+ if (idSet.contains(newId))
+ {
+ Console.debug("Using an existing id for Type " + t.name()
+ + " and object " + o.toString() + ": '" + newId + "'");
+ }
+ else
+ {
+ idSet.add(newId);
+ }
+ }
+ count++;
+ return newId;
+ }
+
+ public static void NOTremoveId(IdType t, Object o)
+ {
+ if (o == null)
+ {
+ return;
+ }
+ Set<Long> idSet = typeMap.get(t);
+ long id = t.hashCode() + o.hashCode();
+ idSet.remove(id);
+ }
+
+ public static void NOTremoveId(IdType t, long id)
+ {
+ Set<Long> idSet = typeMap.get(t);
+ idSet.remove(id);
+ }
+
+}
*/
package jalview.ws;
-import java.util.Locale;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
-import java.util.StringTokenizer;
import java.util.Vector;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import jalview.gui.IProgressIndicator;
import jalview.gui.OOMWarning;
import jalview.util.DBRefUtils;
+import jalview.util.IdUtils;
+import jalview.util.IdUtils.IdType;
import jalview.util.MessageManager;
import jalview.ws.seqfetcher.DbSourceProxy;
import uk.ac.ebi.picr.model.UPEntry;
throw new Error(MessageManager
.getString("error.implementation_error_must_init_dbsources"));
}
- long startTime = System.currentTimeMillis();
+ long progressId = IdUtils.newId(IdType.PROGRESS);
if (progressWindow != null)
{
progressWindow.setProgressBar(
MessageManager.getString("status.fetching_db_refs"),
- startTime);
+ progressId);
}
try
{
}
} catch (Exception e)
{
- jalview.bin.Console.errPrintln("Couldn't locate PICR service instance.\n");
+ jalview.bin.Console
+ .errPrintln("Couldn't locate PICR service instance.\n");
e.printStackTrace();
}
while (sdataset.size() > 0 && db < dbSources.length)
{
int maxqlen = 1; // default number of queries made at one time
- jalview.bin.Console.outPrintln("Verifying against " + dbSources[db].getDbName());
+ jalview.bin.Console
+ .outPrintln("Verifying against " + dbSources[db].getDbName());
// iterate through db for each remaining un-verified sequence
SequenceI[] currSeqs = new SequenceI[sdataset.size()];
{
progressWindow.setProgressBar(
MessageManager.getString("label.dbref_search_completed"),
- startTime);
+ progressId);
}
for (FetchFinishedListenerI listener : listeners)
}
}
- jalview.bin.Console.outPrintln("Adding dbrefs to " + sequence.getName()
- + " from " + dbSource + " sequence : "
+ jalview.bin.Console.outPrintln("Adding dbrefs to "
+ + sequence.getName() + " from " + dbSource + " sequence : "
+ retrievedSeq.getName());
sequence.transferAnnotation(retrievedSeq, mp);
*/
package jalview.ws.jws2;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import compbio.data.sequence.FastaSequence;
+import compbio.metadata.Argument;
+import compbio.metadata.ChunkHolder;
+import compbio.metadata.JobStatus;
+import compbio.metadata.JobSubmissionException;
+import compbio.metadata.Option;
+import compbio.metadata.ResultNotAvailableException;
import jalview.analysis.AlignSeq;
import jalview.analysis.SeqsetUtils;
import jalview.api.AlignViewportI;
import jalview.gui.IProgressIndicator;
import jalview.gui.IProgressIndicatorHandler;
import jalview.schemes.ResidueProperties;
+import jalview.util.IdUtils;
+import jalview.util.IdUtils.IdType;
import jalview.workers.AlignCalcWorker;
import jalview.ws.jws2.dm.AAConSettings;
import jalview.ws.jws2.dm.JabaWsParamSet;
import jalview.ws.jws2.jabaws2.Jws2Instance;
import jalview.ws.params.WsParamSetI;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import compbio.data.sequence.FastaSequence;
-import compbio.metadata.Argument;
-import compbio.metadata.ChunkHolder;
-import compbio.metadata.JobStatus;
-import compbio.metadata.JobSubmissionException;
-import compbio.metadata.Option;
-import compbio.metadata.ResultNotAvailableException;
-
public abstract class AbstractJabaCalcWorker extends AlignCalcWorker
{
if (guiProgress != null)
{
guiProgress.setProgressBar("JABA " + getServiceActionText(),
- progressId = System.currentTimeMillis());
+ progressId = IdUtils.newId(IdType.PROGRESS));
}
rslt = submitToService(seqs);
if (guiProgress != null)
{
if (cancelJob(rslt))
{
- jalview.bin.Console.errPrintln("Cancelled AACon job: " + rslt);
+ jalview.bin.Console
+ .errPrintln("Cancelled AACon job: " + rslt);
}
else
{
- jalview.bin.Console.errPrintln("FAILED TO CANCEL AACon job: " + rslt);
+ jalview.bin.Console
+ .errPrintln("FAILED TO CANCEL AACon job: " + rslt);
}
} catch (Exception x)
}
else
{
- jalview.bin.Console.errPrintln("Job " + id + " couldn't be cancelled.");
+ jalview.bin.Console
+ .errPrintln("Job " + id + " couldn't be cancelled.");
}
} catch (Exception q)
{
*/
package jalview.ws.jws2;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+
+import javax.swing.JInternalFrame;
+
+import compbio.data.msa.MsaWS;
+import compbio.metadata.Argument;
+import compbio.metadata.ChunkHolder;
+import compbio.metadata.JobStatus;
+import compbio.metadata.Preset;
import jalview.analysis.AlignSeq;
import jalview.bin.Console;
import jalview.datamodel.Alignment;
import jalview.gui.Desktop;
import jalview.gui.SplitFrame;
import jalview.gui.WebserviceInfo;
+import jalview.util.IdUtils;
+import jalview.util.IdUtils.IdType;
import jalview.util.MessageManager;
import jalview.ws.AWsJob;
import jalview.ws.JobStateSummary;
import jalview.ws.jws2.dm.JabaWsParamSet;
import jalview.ws.params.WsParamSetI;
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-
-import javax.swing.JInternalFrame;
-
-import compbio.data.msa.MsaWS;
-import compbio.metadata.Argument;
-import compbio.metadata.ChunkHolder;
-import compbio.metadata.JobStatus;
-import compbio.metadata.Preset;
-
class MsaWSThread extends AWS2Thread implements WSClientI
{
boolean submitGaps = false; // pass sequences including gaps to alignment
@Override
public void parseResult()
{
- long progbar = System.currentTimeMillis();
+ long progbar = IdUtils.newId(IdType.PROGRESS);
wsInfo.setProgressBar(
MessageManager.getString("status.collecting_job_results"),
progbar);