if (fileObject == null)
{
- DataSourceType protocol = HttpUtils.startsWithHttpOrHttps(fileName)
- ? DataSourceType.URL
- : DataSourceType.FILE;
+ DataSourceType protocol = HttpUtils.startsWithHttpOrHttps(
+ fileName) ? DataSourceType.URL : DataSourceType.FILE;
newframe = loader.LoadFileWaitTillLoaded(fileName, protocol,
currentFileFormat);
}
}
});
- boolean selmemusage = Cache.getDefault("SHOW_MEMUSAGE",
- false);
+ boolean selmemusage = Cache.getDefault("SHOW_MEMUSAGE", false);
- boolean showjconsole = Cache.getDefault("SHOW_JAVA_CONSOLE",
- false);
+ boolean showjconsole = Cache.getDefault("SHOW_JAVA_CONSOLE", false);
desktop = new MyDesktopPane(selmemusage);
showMemusage.setSelected(selmemusage);
.getStructureSelectionManager(this);
if (Cache.getDefault(Preferences.ADD_SS_ANN, true))
{
- ssm.setAddTempFacAnnot(Cache
- .getDefault(Preferences.ADD_TEMPFACT_ANN, true));
- ssm.setProcessSecondaryStructure(Cache
- .getDefault(Preferences.STRUCT_FROM_PDB, true));
+ ssm.setAddTempFacAnnot(
+ Cache.getDefault(Preferences.ADD_TEMPFACT_ANN, true));
+ ssm.setProcessSecondaryStructure(
+ Cache.getDefault(Preferences.STRUCT_FROM_PDB, true));
ssm.setSecStructServices(
Cache.getDefault(Preferences.USE_RNAVIEW, true));
}
}
}
}).start();
-
+
}
@Override
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
String x = Cache.getProperty(windowName + "SCREEN_X");
String y = Cache.getProperty(windowName + "SCREEN_Y");
- String width = Cache
- .getProperty(windowName + "SCREEN_WIDTH");
- String height = Cache
- .getProperty(windowName + "SCREEN_HEIGHT");
+ String width = Cache.getProperty(windowName + "SCREEN_WIDTH");
+ String height = Cache.getProperty(windowName + "SCREEN_HEIGHT");
if ((x != null) && (y != null) && (width != null) && (height != null))
{
int ix = Integer.parseInt(x), iy = Integer.parseInt(y),
// attempt #1 - try to cope with change in screen geometry - this
// version doesn't preserve original jv aspect ratio.
// take ratio of current screen size vs original screen size.
- double sw = ((1f * screenSize.width) / (1f * Integer.parseInt(
- Cache.getProperty("SCREENGEOMETRY_WIDTH"))));
- double sh = ((1f * screenSize.height) / (1f * Integer.parseInt(
- Cache.getProperty("SCREENGEOMETRY_HEIGHT"))));
+ double sw = ((1f * screenSize.width) / (1f * Integer
+ .parseInt(Cache.getProperty("SCREENGEOMETRY_WIDTH"))));
+ double sh = ((1f * screenSize.height) / (1f * Integer
+ .parseInt(Cache.getProperty("SCREENGEOMETRY_HEIGHT"))));
// rescale the bounds depending upon the current screen geometry.
ix = (int) (ix * sw);
iw = (int) (iw * sw);
}
/**
- * Add key bindings to a JInternalFrame so that Ctrl-W and Cmd-W will close the
- * window
+ * Add key bindings to a JInternalFrame so that Ctrl-W and Cmd-W will close
+ * the window
*
* @param frame
*/
public void inputLocalFileMenuItem_actionPerformed(AlignViewport viewport)
{
String fileFormat = Cache.getProperty("DEFAULT_FILE_FORMAT");
- JalviewFileChooser chooser = JalviewFileChooser
- .forRead(Cache.getProperty("LAST_DIRECTORY"), fileFormat, BackupFiles.getEnabled());
+ JalviewFileChooser chooser = JalviewFileChooser.forRead(
+ Cache.getProperty("LAST_DIRECTORY"), fileFormat,
+ BackupFiles.getEnabled());
chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle(
public void quit()
{
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
- Cache.setProperty("SCREENGEOMETRY_WIDTH",
- screen.width + "");
- Cache.setProperty("SCREENGEOMETRY_HEIGHT",
- screen.height + "");
+ Cache.setProperty("SCREENGEOMETRY_WIDTH", screen.width + "");
+ Cache.setProperty("SCREENGEOMETRY_HEIGHT", screen.height + "");
storeLastKnownDimensions("", new Rectangle(getBounds().x, getBounds().y,
getWidth(), getHeight()));
private void storeLastKnownDimensions(String string, Rectangle jc)
{
- Cache.log.debug("Storing last known dimensions for "
- + string + ": x:" + jc.x + " y:" + jc.y + " width:" + jc.width
- + " height:" + jc.height);
+ Cache.log.debug("Storing last known dimensions for " + string + ": x:"
+ + jc.x + " y:" + jc.y + " width:" + jc.width + " height:"
+ + jc.height);
Cache.setProperty(string + "SCREEN_X", jc.x + "");
Cache.setProperty(string + "SCREEN_Y", jc.y + "");
setProgressBar(MessageManager.formatMessage(
"label.saving_jalview_project", new Object[]
{ chosenFile.getName() }), chosenFile.hashCode());
- Cache.setProperty("LAST_DIRECTORY",
- chosenFile.getParent());
+ 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
try
{
- boolean doBackup = BackupFiles.getEnabled();
- BackupFiles backupfiles = doBackup ? new BackupFiles(chosenFile) : null;
+ boolean doBackup = BackupFiles.getEnabled();
+ BackupFiles backupfiles = doBackup ? new BackupFiles(chosenFile)
+ : null;
- new Jalview2XML().saveState(doBackup ? backupfiles.getTempFile() : chosenFile);
+ new Jalview2XML().saveState(
+ doBackup ? backupfiles.getTempFile() : chosenFile);
if (doBackup)
{
setProgressBar(null, chosenFile.hashCode());
}
}).start();
- }
+ }
}
@Override
"Jalview Project (old)" };
JalviewFileChooser chooser = new JalviewFileChooser(
Cache.getProperty("LAST_DIRECTORY"), suffix, desc,
- "Jalview Project", true, BackupFiles.getEnabled()); // last two booleans: allFiles,
- // allowBackupFiles
+ "Jalview Project", true, BackupFiles.getEnabled()); // last two
+ // booleans:
+ // allFiles,
+ // allowBackupFiles
chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle(MessageManager.getString("label.restore_state"));
chooser.setResponseHandler(0, new Runnable()
@Override
public void run()
{
- try
+ try
{
new Jalview2XML().loadJalviewAlign(selectedFile);
} catch (OutOfMemoryError oom)
- {
- new OOMWarning("Whilst loading project from " + choice, oom);
- } catch (Exception ex)
- {
- Cache.log.error(
- "Problems whilst loading project from " + choice, ex);
- JvOptionPane.showMessageDialog(Desktop.desktop,
- MessageManager.formatMessage(
- "label.error_whilst_loading_project_from",
- new Object[]
- { choice }),
- MessageManager.getString("label.couldnt_load_project"),
- JvOptionPane.WARNING_MESSAGE);
- }
+ {
+ new OOMWarning("Whilst loading project from " + choice, oom);
+ } catch (Exception ex)
+ {
+ Cache.log.error(
+ "Problems whilst loading project from " + choice, ex);
+ JvOptionPane.showMessageDialog(Desktop.desktop,
+ MessageManager.formatMessage(
+ "label.error_whilst_loading_project_from",
+ new Object[]
+ { choice }),
+ MessageManager
+ .getString("label.couldnt_load_project"),
+ JvOptionPane.WARNING_MESSAGE);
+ }
}
}, "Project Loader").start();
}
});
-
+
chooser.showOpenDialog(this);
}
// FIXME: ideally should use UI interface API
FeatureSettings viewFeatureSettings = (af.featureSettings != null
- && af.featureSettings.isOpen())
- ? af.featureSettings
- : null;
+ && af.featureSettings.isOpen()) ? af.featureSettings : null;
Rectangle fsBounds = af.getFeatureSettingsGeometry();
for (int i = 0; i < size; i++)
{
addInternalFrame(newaf, af.getTitle(), AlignFrame.DEFAULT_WIDTH,
AlignFrame.DEFAULT_HEIGHT);
- // and materialise a new feature settings dialog instance for the new alignframe
+ // and materialise a new feature settings dialog instance for the new
+ // alignframe
// (closes the old as if 'OK' was pressed)
if (ap == af.alignPanel && newaf.featureSettings != null
&& newaf.featureSettings.isOpen()
/**
* Gather expanded views (separate AlignFrame's) with the same sequence set
- * identifier back in to this frame as additional views, and close the expanded
- * views. Note the expanded frames may themselves have multiple views. We take
- * the lot.
+ * identifier back in to this frame as additional views, and close the
+ * expanded views. Note the expanded frames may themselves have multiple
+ * views. We take the lot.
*
* @param source
*/
}
// refresh the feature setting UI for the source frame if it exists
- if (source.featureSettings != null
- && source.featureSettings.isOpen())
+ if (source.featureSettings != null && source.featureSettings.isOpen())
{
source.showFeatureSettingsUI();
}
/**
* Proxy class for JDesktopPane which optionally displays the current memory
- * usage and highlights the desktop area with a red bar if free memory runs low.
+ * usage and highlights the desktop area with a red bar if free memory runs
+ * low.
*
* @author AMW
*/
- public class MyDesktopPane extends JDesktopPane
- implements Runnable
+ public class MyDesktopPane extends JDesktopPane implements Runnable
{
private static final float ONE_MB = 1048576f;
}
/**
- * Bind Ctrl/Cmd-Q to Quit - for reset as Groovy Console takes over this binding
- * when opened
+ * Bind Ctrl/Cmd-Q to Quit - for reset as Groovy Console takes over this
+ * binding when opened
*/
protected void addQuitHandler()
{
- getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
- .put(KeyStroke.getKeyStroke(KeyEvent.VK_Q,
- jalview.util.ShortcutKeyMaskExWrapper.getMenuShortcutKeyMaskEx()),
+ getRootPane()
+ .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
+ KeyStroke
+ .getKeyStroke(KeyEvent.VK_Q,
+ jalview.util.ShortcutKeyMaskExWrapper
+ .getMenuShortcutKeyMaskEx()),
"Quit");
getRootPane().getActionMap().put("Quit", new AbstractAction()
{
}
/**
- * This will return the first AlignFrame holding the given viewport instance. It
- * will break if there are more than one AlignFrames viewing a particular av.
+ * This will return the first AlignFrame holding the given viewport instance.
+ * It will break if there are more than one AlignFrames viewing a particular
+ * av.
*
* @param viewport
* @return alignFrame for viewport
/**
* Explode the views in the given SplitFrame into separate SplitFrame windows.
- * This respects (remembers) any previous 'exploded geometry' i.e. the size and
- * location last time the view was expanded (if any). However it does not
+ * This respects (remembers) any previous 'exploded geometry' i.e. the size
+ * and location last time the view was expanded (if any). However it does not
* remember the split pane divider location - this is set to match the
* 'exploding' frame.
*
Transferable t) throws Exception
{
- // BH 2018 changed List<String> to List<Object> to allow for File from SwingJS
+ // BH 2018 changed List<String> to List<Object> to allow for File from
+ // SwingJS
// DataFlavor[] flavors = t.getTransferDataFlavors();
// for (int i = 0; i < flavors.length; i++) {
// byte[] data = getDroppedFileBytes(file);
// fileName.setText(file.getName() + " - " + data.length + " " +
// evt.getLocation());
- // JTextArea target = (JTextArea) ((DropTarget) evt.getSource()).getComponent();
+ // JTextArea target = (JTextArea) ((DropTarget)
+ // evt.getSource()).getComponent();
// target.setText(new String(data));
// }
// dtde.dropComplete(true);
}
/**
- * Answers a (possibly empty) list of any structure viewer frames (currently for
- * either Jmol or Chimera) which are currently open. This may optionally be
- * restricted to viewers of a specified class, or viewers linked to a specified
- * alignment panel.
+ * Answers a (possibly empty) list of any structure viewer frames (currently
+ * for either Jmol or Chimera) which are currently open. This may optionally
+ * be restricted to viewers of a specified class, or viewers linked to a
+ * specified alignment panel.
*
* @param apanel
* if not null, only return viewers linked to this panel
/*
* Set overview panel defaults
*/
- gapColour.setBackground(
- Cache.getDefaultColour(GAP_COLOUR,
- jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_GAP));
- hiddenColour.setBackground(
- Cache.getDefaultColour(HIDDEN_COLOUR,
- jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_HIDDEN));
+ gapColour.setBackground(Cache.getDefaultColour(GAP_COLOUR,
+ jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_GAP));
+ hiddenColour.setBackground(Cache.getDefaultColour(HIDDEN_COLOUR,
+ jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_HIDDEN));
useLegacyGap.setSelected(Cache.getDefault(USE_LEGACY_GAP, false));
gapLabel.setEnabled(!useLegacyGap.isSelected());
gapColour.setEnabled(!useLegacyGap.isSelected());
* set choice of structure viewer, and path if saved as a preference;
* default to Jmol (first choice) if an unexpected value is found
*/
- String viewerType = Cache.getDefault(STRUCTURE_DISPLAY, ViewerType.JMOL.name());
+ String viewerType = Cache.getDefault(STRUCTURE_DISPLAY,
+ ViewerType.JMOL.name());
structViewer.setSelectedItem(viewerType);
String viewerPath = "";
ViewerType type = null;
{
if (validateViewerPath())
{
- Cache.setProperty(structViewer.getSelectedItem()
- .equals(ViewerType.CHIMERAX.name())
- ? CHIMERAX_PATH
- : CHIMERA_PATH, structureViewerPath.getText());
+ Cache.setProperty(
+ structViewer.getSelectedItem().equals(
+ ViewerType.CHIMERAX.name()) ? CHIMERAX_PATH
+ : CHIMERA_PATH,
+ structureViewerPath.getText());
}
}
});
annotations_actionPerformed(null); // update the display of the annotation
// settings
-
-
+
/*
* Set Backups tab defaults
*/
comboBox.addItem(promptEachTimeOpt);
comboBox.addItem(lineArtOpt);
comboBox.addItem(textOpt);
-
+
/*
* JalviewJS doesn't support Lineart so force it to Text
*/
Boolean.toString(structFromPdb.isSelected()));
String viewer = structViewer.getSelectedItem().toString();
String viewerPath = structureViewerPath.getText();
- Cache.applicationProperties.setProperty(STRUCTURE_DISPLAY,
- viewer);
+ Cache.applicationProperties.setProperty(STRUCTURE_DISPLAY, viewer);
if (viewer.equals(ViewerType.CHIMERA.name()))
{
Cache.setOrRemove(CHIMERA_PATH, viewerPath);
Cache.applicationProperties.setProperty(BackupFiles.ENABLED,
Boolean.toString(enableBackupFiles.isSelected()));
int preset = getComboIntStringKey(backupfilesPresetsCombo);
- Cache.applicationProperties.setProperty(BackupFiles.NS + "_PRESET", Integer.toString(preset));
+ Cache.applicationProperties.setProperty(BackupFiles.NS + "_PRESET",
+ Integer.toString(preset));
if (preset == BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM)
{
BackupFilesPresetEntry customBFPE = getBackupfilesCurrentEntry();
BackupFilesPresetEntry.backupfilesPresetEntriesValues.put(
BackupFilesPresetEntry.BACKUPFILESSCHEMECUSTOM, customBFPE);
- Cache.applicationProperties
- .setProperty(BackupFilesPresetEntry.CUSTOMCONFIG,
- customBFPE.toString());
+ Cache.applicationProperties.setProperty(
+ BackupFilesPresetEntry.CUSTOMCONFIG, customBFPE.toString());
}
BackupFilesPresetEntry savedBFPE = BackupFilesPresetEntry.backupfilesPresetEntriesValues
if (!useLegacyGap.isSelected())
{
JalviewColourChooser.showColourChooser(this,
- MessageManager.getString("label.select_gap_colour"),
- gap);
+ MessageManager.getString("label.select_gap_colour"), gap);
}
}
public void hiddenColour_actionPerformed(JPanel hidden)
{
JalviewColourChooser.showColourChooser(this,
- MessageManager.getString("label.select_hidden_colour"),
- hidden);
+ MessageManager.getString("label.select_hidden_colour"), hidden);
}
@Override
boolean delete = confirmNewerDeleteFile(fileToBeDeleted,
replacementFile, true);
- Cache.trace("BACKUPFILES "
- + (delete ? "confirmed" : "not") + " deleting file "
+ Cache.trace("BACKUPFILES " + (delete ? "confirmed" : "not")
+ + " deleting file "
+ fileToBeDeleted.getAbsolutePath()
+ " which is newer than "
+ replacementFile.getAbsolutePath());
// noMax == true means keep all backup files
if ((!noMax) && bfTreeMap.size() >= max)
{
- Cache.trace("BACKUPFILES noMax: " + noMax + ", " + "max: "
- + max + ", " + "bfTreeMap.size(): " + bfTreeMap.size());
+ Cache.trace("BACKUPFILES noMax: " + noMax + ", " + "max: " + max
+ + ", " + "bfTreeMap.size(): " + bfTreeMap.size());
// need to delete some files to keep number of backups to designated
// max.
// Note that if the suffix is not numbered then do not delete any
// delete destination file - not usually necessary but Just In Case...
Cache.trace("BACKUPFILES deleting " + newFile.getAbsolutePath());
newFile.delete();
- Cache.trace("BACKUPFILES moving " + oldFile.getAbsolutePath()
- + " to " + newFile.getAbsolutePath());
+ Cache.trace("BACKUPFILES moving " + oldFile.getAbsolutePath() + " to "
+ + newFile.getAbsolutePath());
Files.move(oldPath, newPath, StandardCopyOption.REPLACE_EXISTING);
ret = true;
Cache.trace("BACKUPFILES move seems to have succeeded");
tabbedPane.add(initConnectionsTab(),
MessageManager.getString("label.connections"));
- if (!Platform.isJS())
- {
- tabbedPane.add(initBackupsTab(),
- MessageManager.getString("label.backups"));
- }
+ if (!Platform.isJS())
+ {
+ tabbedPane.add(initBackupsTab(),
+ MessageManager.getString("label.backups"));
+ }
tabbedPane.add(initLinksTab(),
MessageManager.getString("label.urllinks"));
ypos += lineSpacing;
structureViewerPathLabel = new JLabel();
- structureViewerPathLabel.setFont(LABEL_FONT);// new Font("SansSerif", 0, 11));
+ structureViewerPathLabel.setFont(LABEL_FONT);// new Font("SansSerif", 0,
+ // 11));
structureViewerPathLabel.setHorizontalAlignment(SwingConstants.LEFT);
structureViewerPathLabel.setText(MessageManager
.formatMessage("label.viewer_path", "Chimera(X)"));
- structureViewerPathLabel.setBounds(new Rectangle(10, ypos, 170, height));
+ structureViewerPathLabel
+ .setBounds(new Rectangle(10, ypos, 170, height));
structureViewerPathLabel.setEnabled(false);
structureTab.add(structureViewerPathLabel);
/*
* hide Chimera options in JalviewJS
*/
- if (Platform.isJS())
+ if (Platform.isJS())
{
structureViewerPathLabel.setVisible(false);
structureViewerPath.setVisible(false);
viewerLabel.setVisible(false);
structViewer.setVisible(false);
}
-
+
return structureTab;
}
visualTab.add(fontNameCB);
visualTab.add(fontSizeCB);
visualTab.add(fontStyleCB);
-
+
if (Platform.isJS())
{
startupCheckbox.setVisible(false);
startupFileTextfield.setVisible(false);
}
-
+
return visualTab;
}
{
BackupFilesPresetEntry savedPreset = BackupFilesPresetEntry
.getSavedBackupEntry();
- enableBackupFiles
- .setSelected(Cache.getDefault(BackupFiles.ENABLED, !Platform.isJS()));
+ enableBackupFiles.setSelected(
+ Cache.getDefault(BackupFiles.ENABLED, !Platform.isJS()));
BackupFilesPresetEntry backupfilesCustomEntry = BackupFilesPresetEntry
.createBackupFilesPresetEntry(Cache
}
});
-
// enable checkbox 1 col
gbc.gridwidth = 1;
gbc.gridheight = 1;
presetsComboLabel = new JLabel(title + ":");
presetsPanel.add(presetsComboLabel, gbc);
- List<Object> entries = Arrays
- .asList((Object[]) BackupFilesPresetEntry.backupfilesPresetEntries);
+ List<Object> entries = Arrays.asList(
+ (Object[]) BackupFilesPresetEntry.backupfilesPresetEntries);
List<String> tooltips = Arrays.asList(
BackupFilesPresetEntry.backupfilesPresetEntryDescriptions);
backupfilesPresetsCombo = JvSwingUtils.buildComboWithTooltips(entries,
{
if (customiseCheckbox.isSelected())
{
- // got here by clicking on customiseCheckbox so don't change the values
+ // got here by clicking on customiseCheckbox so don't change the
+ // values
backupfilesCustomOptionsSetEnabled();
}
else
private JPanel initBackupsTabFilenameExamplesPanel()
{
- String title = MessageManager
- .getString("label.scheme_examples");
+ String title = MessageManager.getString("label.scheme_examples");
TitledBorder tb = new TitledBorder(title);
exampleFilesPanel.setBorder(tb);
exampleFilesPanel.setLayout(new GridBagLayout());
-
backupfilesExampleLabel.setEditable(false);
backupfilesExampleLabel
.setBackground(exampleFilesPanel.getBackground());
}
protected void setComboIntStringKey(
- JComboBox<Object> backupfilesPresetsCombo2,
- int key)
+ JComboBox<Object> backupfilesPresetsCombo2, int key)
{
for (int i = 0; i < backupfilesPresetsCombo2.getItemCount(); i++)
{
JPanel jp = new JPanel();
jp.setLayout(new FlowLayout());
- oldBackupFilesLabel
- .setText(MessageManager
- .getString("label.autodelete_old_backup_files"));
+ oldBackupFilesLabel.setText(
+ MessageManager.getString("label.autodelete_old_backup_files"));
oldBackupFilesLabel.setFont(LABEL_FONT);
oldBackupFilesLabel.setHorizontalAlignment(SwingConstants.LEFT);
jp.add(oldBackupFilesLabel);
}
- // add some extra empty lines to pad out the example files box. ugh, please tell
+ // add some extra empty lines to pad out the example files box. ugh, please
+ // tell
// me how to do this better
int remainingLines = lowersurround + uppersurround + 1 - lineNumber;
if (remainingLines > 0)
private void backupfilesKeepAllSetEnabled(boolean tryEnabled)
{
boolean enabled = tryEnabled && enableBackupFiles.isSelected()
- && customiseCheckbox.isSelected()
- && suffixTemplate.getText()
+ && customiseCheckbox.isSelected() && suffixTemplate.getText()
.indexOf(BackupFiles.NUM_PLACEHOLDER) > -1;
keepfilesPanel.setEnabled(enabled);
backupfilesKeepAll.setEnabled(enabled);
}
}
-
import java.awt.Rectangle;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import jalview.gui.AlignViewport;
import jalview.gui.AlignmentPanel;
import jalview.gui.AppVarna;
-import jalview.gui.ChimeraViewFrame;
import jalview.gui.Desktop;
import jalview.gui.JvOptionPane;
import jalview.gui.OOMWarning;
// create backupfiles object and get new temp filename destination
boolean doBackup = BackupFiles.getEnabled();
BackupFiles backupfiles = doBackup ? new BackupFiles(jarFile) : null;
- FileOutputStream fos = new FileOutputStream(doBackup ?
- backupfiles.getTempFilePath() : jarFile);
+ FileOutputStream fos = new FileOutputStream(
+ doBackup ? backupfiles.getTempFilePath() : jarFile);
JarOutputStream jout = new JarOutputStream(fos);
List<AlignFrame> frames = new ArrayList<>();
if (frames[f] instanceof StructureViewerBase)
{
StructureViewerBase viewFrame = (StructureViewerBase) frames[f];
- matchedFile = saveStructureViewer(ap, jds, pdb, entry, viewIds,
- matchedFile, viewFrame);
+ matchedFile = saveStructureViewer(ap, jds, pdb, entry,
+ viewIds, matchedFile, viewFrame);
/*
* Only store each structure viewer's state once in the project
* jar. First time through only (storeDS==false)
}
else
{
- Cache.log.error("Failed to save viewer state for "
- +
- viewerType);
+ Cache.log.error(
+ "Failed to save viewer state for " + viewerType);
}
}
}
if (colourScheme instanceof jalview.schemes.UserColourScheme)
{
- jGroup.setColour(
- setUserColourScheme(colourScheme, userColours,
- object));
+ jGroup.setColour(setUserColourScheme(colourScheme,
+ userColours, object));
}
else
{
* save any filter for the feature type
*/
FeatureMatcherSetI filter = fr.getFeatureFilter(featureType);
- if (filter != null) {
- Iterator<FeatureMatcherI> filters = filter.getMatchers().iterator();
+ if (filter != null)
+ {
+ Iterator<FeatureMatcherI> filters = filter.getMatchers()
+ .iterator();
FeatureMatcherI firstFilter = filters.next();
- setting.setMatcherSet(Jalview2XML.marshalFilter(
- firstFilter, filters, filter.isAnded()));
+ setting.setMatcherSet(Jalview2XML.marshalFilter(firstFilter,
+ filters, filter.isAnded()));
}
/*
setting.setDisplay(
av.getFeaturesDisplayed().isVisible(featureType));
- float rorder = fr
- .getOrder(featureType);
+ float rorder = fr.getOrder(featureType);
if (rorder > -1)
{
setting.setOrder(rorder);
Group g = new Group();
g.setName(grp);
g.setDisplay(((Boolean) fr.checkGroupVisibility(grp, false))
- .booleanValue());
+ .booleanValue());
// fs.addGroup(g);
fs.getGroup().add(g);
groupsAdded.addElement(grp);
{
if (calcIdParam.getVersion().equals("1.0"))
{
- final String[] calcIds = calcIdParam.getServiceURL().toArray(new String[0]);
+ final String[] calcIds = calcIdParam.getServiceURL()
+ .toArray(new String[0]);
Jws2Instance service = Jws2Discoverer.getDiscoverer()
.getPreferredServiceFor(calcIds);
if (service != null)
}
if (ref.hasMap())
{
- Mapping mp = createVamsasMapping(ref.getMap(), parentseq,
- jds, recurse);
+ Mapping mp = createVamsasMapping(ref.getMap(), parentseq, jds,
+ recurse);
dbref.setMapping(mp);
}
vamsasSeq.getDBRef().add(dbref);
return id;
}
- jalview.schemes.UserColourScheme getUserColourScheme(
- JalviewModel jm, String id)
+ jalview.schemes.UserColourScheme getUserColourScheme(JalviewModel jm,
+ String id)
{
List<UserColours> uc = jm.getUserColours();
UserColours colours = null;
-/*
+ /*
for (int i = 0; i < uc.length; i++)
{
if (uc[i].getId().equals(id))
break;
}
}
-*/
+ */
for (UserColours c : uc)
{
if (c.getId().equals(id))
newColours = new java.awt.Color[23];
for (int i = 0; i < 23; i++)
{
- newColours[i] = new java.awt.Color(Integer.parseInt(
- colours.getUserColourScheme().getColour().get(i + 24)
- .getRGB(),
- 16));
+ newColours[i] = new java.awt.Color(
+ Integer.parseInt(colours.getUserColourScheme().getColour()
+ .get(i + 24).getRGB(), 16));
}
ucs.setLowerCaseColours(newColours);
}
return af;
}
- @SuppressWarnings("unused")
- private jarInputStreamProvider createjarInputStreamProvider(final Object ofile) throws MalformedURLException {
+ @SuppressWarnings("unused")
+ private jarInputStreamProvider createjarInputStreamProvider(
+ final Object ofile) throws MalformedURLException
+ {
- // BH 2018 allow for bytes already attached to File object
- try {
- String file = (ofile instanceof File ? ((File) ofile).getCanonicalPath() : ofile.toString());
+ // BH 2018 allow for bytes already attached to File object
+ try
+ {
+ String file = (ofile instanceof File
+ ? ((File) ofile).getCanonicalPath()
+ : ofile.toString());
byte[] bytes = Platform.isJS() ? Platform.getFileBytes((File) ofile)
: null;
- URL url = null;
- errorMessage = null;
- uniqueSetSuffix = null;
- seqRefIds = null;
- viewportsAdded.clear();
- frefedSequence = null;
-
- if (HttpUtils.startsWithHttpOrHttps(file))
- {
- url = new URL(file);
- }
- final URL _url = url;
- return new jarInputStreamProvider()
- {
-
- @Override
- public JarInputStream getJarInputStream() throws IOException {
- if (bytes != null) {
-// System.out.println("Jalview2XML: opening byte jarInputStream for bytes.length=" + bytes.length);
- return new JarInputStream(new ByteArrayInputStream(bytes));
- }
- if (_url != null) {
-// System.out.println("Jalview2XML: opening url jarInputStream for " + _url);
- return new JarInputStream(_url.openStream());
- } else {
-// System.out.println("Jalview2XML: opening file jarInputStream for " + file);
- return new JarInputStream(new FileInputStream(file));
- }
- }
-
- @Override
- public String getFilename() {
- return file;
- }
- };
- } catch (IOException e) {
- e.printStackTrace();
- return null;
- }
- }
+ URL url = null;
+ errorMessage = null;
+ uniqueSetSuffix = null;
+ seqRefIds = null;
+ viewportsAdded.clear();
+ frefedSequence = null;
+
+ if (HttpUtils.startsWithHttpOrHttps(file))
+ {
+ url = new URL(file);
+ }
+ final URL _url = url;
+ return new jarInputStreamProvider()
+ {
+
+ @Override
+ public JarInputStream getJarInputStream() throws IOException
+ {
+ if (bytes != null)
+ {
+ // System.out.println("Jalview2XML: opening byte jarInputStream for
+ // bytes.length=" + bytes.length);
+ return new JarInputStream(new ByteArrayInputStream(bytes));
+ }
+ if (_url != null)
+ {
+ // System.out.println("Jalview2XML: opening url jarInputStream for "
+ // + _url);
+ return new JarInputStream(_url.openStream());
+ }
+ else
+ {
+ // System.out.println("Jalview2XML: opening file jarInputStream for
+ // " + file);
+ return new JarInputStream(new FileInputStream(file));
+ }
+ }
+
+ @Override
+ public String getFilename()
+ {
+ return file;
+ }
+ };
+ } catch (IOException e)
+ {
+ e.printStackTrace();
+ return null;
+ }
+ }
/**
* Recover jalview session from a jalview project archive. Caller may
XMLStreamReader streamReader = XMLInputFactory.newInstance()
.createXMLStreamReader(jin);
javax.xml.bind.Unmarshaller um = jc.createUnmarshaller();
- JAXBElement<JalviewModel> jbe = um
- .unmarshal(streamReader, JalviewModel.class);
+ JAXBElement<JalviewModel> jbe = um.unmarshal(streamReader,
+ JalviewModel.class);
JalviewModel object = jbe.getValue();
if (true) // !skipViewport(object))
AlignFrame loadFromObject(JalviewModel jalviewModel, String file,
boolean loadTreesAndStructures, jarInputStreamProvider jprovider)
{
- SequenceSet vamsasSet = jalviewModel.getVamsasModel().getSequenceSet().get(0);
+ SequenceSet vamsasSet = jalviewModel.getVamsasModel().getSequenceSet()
+ .get(0);
List<Sequence> vamsasSeqs = vamsasSet.getSequence();
// JalviewModelSequence jms = object.getJalviewModelSequence();
if (tmpSeq.getStart() != jseq.getStart()
|| tmpSeq.getEnd() != jseq.getEnd())
{
- System.err.println(
- String.format("Warning JAL-2154 regression: updating start/end for sequence %s from %d/%d to %d/%d",
- tmpSeq.getName(), tmpSeq.getStart(),
- tmpSeq.getEnd(), jseq.getStart(),
- jseq.getEnd()));
+ System.err.println(String.format(
+ "Warning JAL-2154 regression: updating start/end for sequence %s from %d/%d to %d/%d",
+ tmpSeq.getName(), tmpSeq.getStart(), tmpSeq.getEnd(),
+ jseq.getStart(), jseq.getEnd()));
}
}
else
else
{
// defer to later
- frefedSequence.add(
- newAlcodMapRef(map.getDnasq(), cf, mapping));
+ frefedSequence
+ .add(newAlcodMapRef(map.getDnasq(), cf, mapping));
}
}
}
jaa.setCalcId(annotation.getCalcId());
if (annotation.getProperty().size() > 0)
{
- for (Annotation.Property prop : annotation
- .getProperty())
+ for (Annotation.Property prop : annotation.getProperty())
{
jaa.setProperty(prop.getName(), prop.getValue());
}
sg.setShowNonconserved(safeBoolean(jGroup.isShowUnconserved()));
sg.thresholdTextColour = safeInt(jGroup.getTextColThreshold());
// attributes with a default in the schema are never null
- sg.setShowConsensusHistogram(jGroup.isShowConsensusHistogram());
- sg.setshowSequenceLogo(jGroup.isShowSequenceLogo());
- sg.setNormaliseSequenceLogo(jGroup.isNormaliseSequenceLogo());
+ sg.setShowConsensusHistogram(jGroup.isShowConsensusHistogram());
+ sg.setshowSequenceLogo(jGroup.isShowSequenceLogo());
+ sg.setNormaliseSequenceLogo(jGroup.isNormaliseSequenceLogo());
sg.setIgnoreGapsConsensus(jGroup.isIgnoreGapsinConsensus());
if (jGroup.getConsThreshold() != null
&& jGroup.getConsThreshold().intValue() != 0)
if (addAnnotSchemeGroup)
{
// reconstruct the annotation colourscheme
- sg.setColourScheme(constructAnnotationColour(
- jGroup.getAnnotationColours(), null, al, jalviewModel, false));
+ sg.setColourScheme(
+ constructAnnotationColour(jGroup.getAnnotationColours(),
+ null, al, jalviewModel, false));
}
}
}
* @param av
* @param ap
*/
- protected void loadTrees(JalviewModel jm, Viewport view,
- AlignFrame af, AlignViewport av, AlignmentPanel ap)
+ protected void loadTrees(JalviewModel jm, Viewport view, AlignFrame af,
+ AlignViewport av, AlignmentPanel ap)
{
// TODO result of automated refactoring - are all these parameters needed?
try
for (int s = 0; s < structureStateCount; s++)
{
// check to see if we haven't already created this structure view
- final StructureState structureState = pdbid
- .getStructureState().get(s);
+ final StructureState structureState = pdbid.getStructureState()
+ .get(s);
String sviewid = (structureState.getViewId() == null) ? null
: structureState.getViewId() + uniqueSetSuffix;
jalview.datamodel.PDBEntry jpdb = new jalview.datamodel.PDBEntry();
colourByViewer &= structureState.isColourByJmol();
jmoldat.setColourByViewer(colourByViewer);
- if (jmoldat.getStateData().length() < structureState
- .getValue()/*Content()*/.length())
+ if (jmoldat.getStateData().length() < structureState.getValue()
+ /*Content()*/.length())
{
jmoldat.setStateData(structureState.getValue());// Content());
}
} catch (IllegalArgumentException | NullPointerException e)
{
// TODO JAL-3619 show error dialog / offer an alternative viewer
- Cache.log.error(
- "Invalid structure viewer type: " + type);
+ Cache.log.error("Invalid structure viewer type: " + type);
}
}
}
AlignFrame loadViewport(String file, List<JSeq> JSEQ,
- List<SequenceI> hiddenSeqs, AlignmentI al,
- JalviewModel jm, Viewport view, String uniqueSeqSetId,
- String viewId, List<JvAnnotRow> autoAlan)
+ List<SequenceI> hiddenSeqs, AlignmentI al, JalviewModel jm,
+ Viewport view, String uniqueSeqSetId, String viewId,
+ List<JvAnnotRow> autoAlan)
{
AlignFrame af = null;
af = new AlignFrame(al, safeInt(view.getWidth()),
- safeInt(view.getHeight()), uniqueSeqSetId, viewId)
-// {
-//
-// @Override
-// protected void processKeyEvent(java.awt.event.KeyEvent e) {
-// System.out.println("Jalview2XML AF " + e);
-// super.processKeyEvent(e);
-//
-// }
-//
-// }
+ safeInt(view.getHeight()), uniqueSeqSetId, viewId)
+ // {
+ //
+ // @Override
+ // protected void processKeyEvent(java.awt.event.KeyEvent e) {
+ // System.out.println("Jalview2XML AF " + e);
+ // super.processKeyEvent(e);
+ //
+ // }
+ //
+ // }
;
af.setFileName(file, FileFormat.Jalview);
viewport.setColourText(safeBoolean(view.isShowColourText()));
- viewport
- .setConservationSelected(
- safeBoolean(view.isConservationSelected()));
+ viewport.setConservationSelected(
+ safeBoolean(view.isConservationSelected()));
viewport.setIncrement(safeInt(view.getConsThreshold()));
viewport.setShowJVSuffix(safeBoolean(view.isShowFullId()));
viewport.setRightAlignIds(safeBoolean(view.isRightAlignIds()));
af.changeColour(cs);
viewport.setColourAppliesToAllGroups(true);
- viewport
- .setShowSequenceFeatures(
- safeBoolean(view.isShowSequenceFeatures()));
+ viewport.setShowSequenceFeatures(
+ safeBoolean(view.isShowSequenceFeatures()));
viewport.setCentreColumnLabels(view.isCentreColumnLabels());
viewport.setIgnoreGapsConsensus(view.isIgnoreGapsinConsensus(), null);
.getFeatureRenderer();
FeaturesDisplayed fdi;
viewport.setFeaturesDisplayed(fdi = new FeaturesDisplayed());
- String[] renderOrder = new String[jm.getFeatureSettings()
- .getSetting().size()];
+ String[] renderOrder = new String[jm.getFeatureSettings().getSetting()
+ .size()];
Map<String, FeatureColourI> featureColours = new Hashtable<>();
Map<String, Float> featureOrder = new Hashtable<>();
- for (int fs = 0; fs < jm.getFeatureSettings()
- .getSetting().size(); fs++)
+ for (int fs = 0; fs < jm.getFeatureSettings().getSetting()
+ .size(); fs++)
{
Setting setting = jm.getFeatureSettings().getSetting().get(fs);
String featureType = setting.getType();
.getMatcherSet();
if (filters != null)
{
- FeatureMatcherSetI filter = Jalview2XML
- .parseFilter(featureType, filters);
+ FeatureMatcherSetI filter = Jalview2XML.parseFilter(featureType,
+ filters);
if (!filter.isEmpty())
{
fr.setFeatureFilter(featureType, filter);
float max = setting.getMax() == null ? 1f
: setting.getMax().floatValue();
FeatureColourI gc = new FeatureColour(maxColour, minColour,
- maxColour,
- noValueColour, min, max);
+ maxColour, noValueColour, min, max);
if (setting.getAttributeName().size() > 0)
{
gc.setAttributeName(setting.getAttributeName().toArray(
}
else
{
- featureColours.put(featureType,
- new FeatureColour(maxColour));
+ featureColours.put(featureType, new FeatureColour(maxColour));
}
renderOrder[fs] = featureType;
if (setting.getOrder() != null)
}
}
}
+
/**
*
* @param vamsasSeq
* @param af
* @param jprovider
*/
- protected void createStructureViewer(
- ViewerType viewerType, final Entry<String, StructureViewerModel> viewerData,
+ protected void createStructureViewer(ViewerType viewerType,
+ final Entry<String, StructureViewerModel> viewerData,
AlignFrame af, jarInputStreamProvider jprovider)
{
final StructureViewerModel viewerModel = viewerData.getValue();
{
String viewerJarEntryName = getViewerJarEntryName(
viewerModel.getViewId());
- sessionFilePath = copyJarEntry(jprovider,
- viewerJarEntryName,
+ sessionFilePath = copyJarEntry(jprovider, viewerJarEntryName,
"viewerSession", ".tmp");
}
final String sessionPath = sessionFilePath;
addNewStructureViewer(sview);
} catch (OutOfMemoryError ex)
{
- new OOMWarning("Restoring structure view for "
- + viewerType,
+ new OOMWarning("Restoring structure view for " + viewerType,
(OutOfMemoryError) ex.getCause());
if (sview != null && sview.isVisible())
{
String reformatedOldFilename = oldfilenam.replaceAll("/", "\\\\");
filedat = oldFiles.get(new File(reformatedOldFilename));
}
- rewritten
- .append(Platform.escapeBackslashes(filedat.getFilePath()));
+ rewritten.append(Platform.escapeBackslashes(filedat.getFilePath()));
rewritten.append("\"");
cp = ecp + 1; // advance beyond last \" and set cursor so we can
// look for next file statement.
* @param fcol
* @return
*/
- public static Colour marshalColour(
- String featureType, FeatureColourI fcol)
+ public static Colour marshalColour(String featureType,
+ FeatureColourI fcol)
{
Colour col = new Colour();
if (fcol.isSimpleColour())
boolean and)
{
jalview.xml.binding.jalview.FeatureMatcherSet result = new jalview.xml.binding.jalview.FeatureMatcherSet();
-
+
if (filters.hasNext())
{
/*
}
result.setMatchCondition(matcherModel);
}
-
+
return result;
}
* @param matcherSetModel
* @return
*/
- public static FeatureMatcherSetI parseFilter(
- String featureType,
+ public static FeatureMatcherSetI parseFilter(String featureType,
jalview.xml.binding.jalview.FeatureMatcherSet matcherSetModel)
{
FeatureMatcherSetI result = new FeatureMatcherSet();
featureType, e.getMessage()));
// return as much as was parsed up to the error
}
-
+
return result;
}
* @throws IllegalStateException
* if AND and OR conditions are mixed
*/
- protected static void parseFilterConditions(
- FeatureMatcherSetI matcherSet,
+ protected static void parseFilterConditions(FeatureMatcherSetI matcherSet,
jalview.xml.binding.jalview.FeatureMatcherSet matcherSetModel,
boolean and)
{
else if (filterBy == FilterBy.BY_SCORE)
{
matchCondition = FeatureMatcher.byScore(cond, pattern);
-
+
}
else if (filterBy == FilterBy.BY_ATTRIBUTE)
{
matchCondition = FeatureMatcher.byAttribute(cond, pattern,
attNames);
}
-
+
/*
* note this throws IllegalStateException if AND-ing to a
* previously OR-ed compound condition, or vice versa
public static FeatureColourI parseColour(Colour colourModel)
{
FeatureColourI colour = null;
-
+
if (colourModel.getMax() != null)
{
Color mincol = null;
Color maxcol = null;
Color noValueColour = null;
-
+
try
{
mincol = new Color(Integer.parseInt(colourModel.getMinRGB(), 16));
{
Cache.log.warn("Couldn't parse out graduated feature color.", e);
}
-
+
NoValueColour noCol = colourModel.getNoValueColour();
if (noCol == NoValueColour.MIN)
{
{
noValueColour = maxcol;
}
-
+
colour = new FeatureColour(maxcol, mincol, maxcol, noValueColour,
safeFloat(colourModel.getMin()),
safeFloat(colourModel.getMax()));
Color color = new Color(Integer.parseInt(colourModel.getRGB(), 16));
colour = new FeatureColour(color);
}
-
+
return colour;
}
}