<classpathentry kind="lib" path="lib/log4j-to-slf4j-2.0-rc2.jar"/>
<classpathentry kind="lib" path="lib/slf4j-log4j12-1.7.7.jar"/>
<classpathentry kind="lib" path="lib/VARNAv3-91.jar"/>
- <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/Plugin.jar"/>
+ <classpathentry kind="lib" path="lib/jfreesvg-2.1.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/plugin.jar"/>
<classpathentry kind="lib" path="lib/xml-apis.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/plugin17"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<mapID target="viewingpdbs.reps" url="html/features/viewingpdbs.html#viewreps"/>
<mapID target="pdbmcviewer" url="html/features/pdbviewer.html"/>
<mapID target="pdbjmol" url="html/features/jmol.html"/>
+ <mapID target="chimera" url="html/features/chimera.html"/>
<mapID target="varna" url="html/features/varna.html"/>
<mapID target="preferences" url="html/features/preferences.html"/>
<mapID target="commandline" url="html/features/commandline.html"/>
</tocitem>
<tocitem text="Viewing PDB Files" target="viewingpdbs" expand="false">
<tocitem text="Jmol Viewer" target="pdbjmol"/>
+ <tocitem text="Chimera Viewer" target="chimera"/>
<tocitem text="Simple PDB Viewer" target="pdbmcviewer"/>
</tocitem>
<tocitem text="Viewing RNA structures" target="varna" expand="false"> </tocitem>
--- /dev/null
+<html>
+<!--
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
+ * Copyright (C) 2014 The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ -->
+<head>
+<title>The Chimera PDB Viewer</title>
+</head>
+<body>
+<p><strong>The Chimera Viewer</strong></p>
+<p>Since Jalview 2.8.2, <a href="https://www.cgl.ucsf.edu/chimera/">Chimera</a>
+has been integrated into Jalview for interactively viewing structures
+opened by entries in the <strong>"Structure"</strong> submenu in the <a href="../menus/popupMenu.html">sequence
+id pop-up menu</a> (if you can't see this, then you need to <a
+ href="viewingpdbs.html">associate a PDB structure</a> with the
+sequence). Chimera is available from the Jalview desktop, provided Chimera has been separately installed.</p>
+<p>You can set a default choice of Jmol or Chimera structure viewer in <a href="preferences.html#structure"> Preferences</a>.
+You can also optionally specify the path to the Chimera program here (if it differs from the standard paths searched by Jalview).
+<p>The following menu entries are provided for viewing structure data<br>
+ <ul>
+ <li>The <strong>"Structure→View
+ Structure→</strong> submenu allows a single PDB structure to be chosen
+ for display from the available structures for a sequence.
+ </li>
+ <li>The <strong>"Structure→View all <em>N</em>
+ structures
+ </strong> option will open a new window containing all structures associated
+ with the current selection.
+ </li>
+ <li>The <strong>"Structure→View all <em>N</em>
+ representative structures
+ </strong> option will open a new window containing exactly one structure per
+ currently selected sequence.<br /></li>
+ </ul>
+ <br>
+</p>
+<p><a name="align"><strong>Superposing structures based
+on their aligned sequences</strong></a><br>
+<p>If several structures are available on the alignment, you may add
+additional structures to an existing Chimera view by selecting their entry
+in the appropriate pop-up menu. Jalview will ask you if you wish to add
+the structure to the existing alignment, and if you do, it will import
+and superimpose the new PDB file using the corresponding positions from
+the alignment. If the alignment is subsequently edited, you can use the
+<a href="#sAlign"><em>Chimera→Align</em></a> menu option from the
+menu bar of the structure view window to superpose the structures using
+the updated alignment.<br>
+</p>
+<p><strong>Chimera Controls</strong><br>
+<p>The structure is by default rendered as a ribbon diagram. Moving the
+mouse over the structure brings up tooltips giving the residue name, PDB
+residue number and chain code
+([RES]Num:Chain). Moving the mouse over an
+associated residue in an alignment window highlights the associated
+atoms in the displayed structures. For comprehensive details of Chimera's commands, refer to the tool's Help menu.</p>
+<p>Basic screen operations (see <a href="https://www.cgl.ucsf.edu/chimera/current/docs/UsersGuide/mouse.html">Chimera help</a> for full details).
+<table border="1">
+ <tr>
+ <td><strong>Action</strong></td>
+ <td><strong>Windows</strong></td>
+ <td><strong>Unix</strong></td>
+ <td><strong>Mac/OSX</strong></td>
+ </tr>
+ <tr>
+ <td>Rotate View</td>
+ <td>Left Click and Drag</td>
+ <td>Left Click and Drag</td>
+ <td>Left Click and Drag</td>
+ </tr>
+ <tr>
+ <td>Zoom</td><td>Right Click<br>
+ drag mouse up or down</td>
+ <td>Right Click<br>drag mouse up or down</td>
+ <td>cmd or Right + Click and drag mouse up or down, <br>or use mouse scroll button</td>
+ </tr>
+ <tr>
+ <td>Move Origin</td>
+ <td>Middle Button + Drag</td>
+ <td>Middle Button and drag</td>
+ <td>alt + Click<br>
+ and drag</td>
+ </tr>
+</table>
+</p>
+<p><strong>Jalview Controls</strong>
+<p>The Jalview Chimera View window has up to five menus:
+<ul>
+ <li><Strong>File<br>
+ </strong>
+ <ul>
+ <li><strong>View Mapping<br>
+ </strong><em> Opens a text window showing the alignment between the
+ residues corresponding to alpha-carbon atoms in the PDB structure and
+ the residues in the associated sequence.</em></li>
+ </ul>
+ </li>
+ <li><strong>View</strong>
+ <ul>
+ <li><strong>Show Chains<br>
+ </strong><em>Select which of the PDB file's chains (if more than one) are to be displayed.</em></li>
+ <li><strong>Colour by ..<br></strong><em>Submenu allowing specific alignment views to be selected for colouring associated chains in the structure display. This menu contains all the alignment views associated with the structure view, with those used to colour the view indicated by ticks. Addditionally, it contains the following menu entries:</em>
+ <ul><li><strong>Select many views<br></strong><em>When this option is enabled, selecting an alignment view adds it to the set used to colour the structures. Use this when colouring structures related to a number of alignments involving different domains or chains which are shown in the same structure view.</em>
+ </li>
+ <li><strong>Select all views<br></strong><em>This is only enabled when </em><strong>Select many views</strong><em> is also enabled, and will add all associated views to the set used to colour the structure display.</em>
+ </li>
+ <li><strong>Invert selection<br></strong><em>This is only enabled when </em><strong>Select many views</strong><em> is also enabled, and will replace the current set of views with any remaining views not currently used to colour the structure display.</em>
+ </li></ul></li></ul>
+ <li><strong>Colours<br>
+ </strong>
+ <ul>
+ <li><strong>By Sequence<br>
+ </strong><em> Colours each residue in the structure with the colour of its
+ corresponding residue in the associated sequence as rendered in the
+ associated alignment views, including any Uniprot sequence features or
+ region colourings.<br/>Pick which of the associated alignment views are used to colour the structures using the <strong>View→Colour by ..</strong> sub menu.</em><br>
+ Residues which only exist in the PDB structure are coloured white if
+ they are insertions (relative to the associated sequence in the
+ alignment) and grey if they are N or C terminal flanks outside the
+ region mapped to the alignment window's sequence.</em></li>
+ <li><strong>Charge & Cysteine<br>
+ </strong><em> Highlights cysteines in yellow, anionic (Aspartic Acid or
+ Glutamic Acid) residues in red, and cationic (Lysine or Arginine)
+ residues in blue.</em></li>
+ <li><strong>Colour with Chimera<br></strong><em>Defers any colouring operations to Chimera. Select this if you want to use the
+ Chimera scripting interface or menu to modify the view directly.</em></li>
+ <li><strong>Standard and User Defined Jalview
+ colourschemes.<br>
+ </strong><em>The remaining entries apply the colourschemes available from
+ the standard and user defined <a href="../colourSchemes/index.html">amino
+ acid colours</a>.</em></li>
+ </ul>
+ </li>
+ <li><strong>Chimera<br>
+ </strong><em>This pulldown menu is only displayed if there are multiple
+ structures shown in the Chimera window, and Jalview can also locate at
+ least two of the structures in the currently associated alignment view.</em>
+ <ul>
+ <li><strong><a name="sAlign">Align</a> <br>
+ </strong><em> When selected, the associated alignment will be used to
+ superimpose all the structures in the view onto the first structure in
+ the alignment. The regions used to calculate the superposition will be
+ highlighted using the 'Cartoon' rendering style, and the remaining
+ data shown as a chain trace.<br></em></li>
+ </ul>
+ </li>
+ <li><strong>Help<br>
+ </strong>
+ <ul>
+ <li><strong>Chimera Help<br>
+ </strong><em>Access the Chimera Help documentation in a new browser window.</em></li>
+ </ul>
+ </li>
+</ul>
+</p>
+</body>
+</html>
and alpha carbon location. Double clicking an atom allows distances to
be measured from it to any other atom in the structure.</p>
<p>
-<table>
+<table border="1">
<tr>
<td><strong>Action</strong></td>
<td><strong>Windows</strong></td>
<li><strong>Select all views<br></strong><em>This is only enabled when </em><strong>Select many views</strong><em> is also enabled, and will add all associated views to the set used to colour the structure display.</em>
</li>
<li><strong>Invert selection<br></strong><em>This is only enabled when </em><strong>Select many views</strong><em> is also enabled, and will replace the current set of views with any remaining views not currently used to colour the structure display.</em>
- </li></ul></li>
+ </li></ul></li></ul>
<li><strong>Colours<br>
</strong>
<ul>
<p><em>Add Temperature Factor annotation to alignment</em> - if selected, PDB Temperature Factor
annotation will be shown on the alignment when available.
<p><em>Default structure viewer</em> - choose JMOL or CHIMERA for viewing 3D structures.
+<p><em>Path to Chimera program</em> - Optional, as Jalview will search standard installation paths for Windows, Linux or MacOS.
+If you have installed Chimera in a non-standard location, you can specify it here. Enter the full path to the Chimera executable program.
<p><a name="connections"><strong>"Connections"
Preferences tab</strong></a></p>
<p>Jalview can view protein structures associated with a sequence
via the <strong>"Structure→"</strong> submenu from a
sequence's <a href="../menus/popupMenu.html">pop-up menu</a>.</p>
+A <a href="jmol.html">Jmol viewer</a> has been included since Jalview 2.3. Jalview 2.8.2 added support for <a href="https://www.cgl.ucsf.edu/chimera/">Chimera</a>,
+provided this has been separately installed. Choice of default viewer is configurable in the Preferences <a href="preferences.html#structure">Structure tab</a>.
+
<p>The following menu entries are provided for viewing structure data<br>
<ul>
<li>The <strong>"Structure→View
with the current selection, superposed according to the currently selected region of the alignment.<br/><em>This
capability was added in Jalview 2.7</em>
</li>
- <li><a name="viewreps"/>The <strong>"Structure→View all <em>N</em>
+ <li>The <strong>"Structure→View all <em>N</em>
representative structures
</strong> option will open a new window containing exactly one structure per
currently selected sequence.<br />
<em>The View representative structures option was introduced in
Jalview 2.8.1</em></li>
</ul>
- <br>
</p>
<p>If a single pdb
<ul>
<li>If no structures are open, then an interactive display of the
- structure will be opened in a new window</li>
+ structure will be opened in a new window.</li>
<li>If another structure is already shown for the current
alignment, then you will be asked if you want to add and <a
href="jmol.html#align">align this structure</a> to the structure in
- the existing view. (<em>new feature in Jalview 2.6</em>)</li>
+ the existing view. (<em>new feature in Jalview 2.6</em>).</li>
<li>If the structure is already shown, then you will be prompted
to associate the sequence with an existing view of the selected
structure. This is useful when working with multi-domain or multi-chain PDB files.</li>
<li style="list-style: none">See the <a href="jmol.html">Jmol
- PDB viewer</a> help page for more information about the display.</li>
+ </a> and <a href="chimera.html">Chimera</a> PDB viewer help pages for more information about the display.</li>
</ul>
<p><strong>Associating PDB files with Sequences</strong></p>
<p>To associate PDB files with a sequence, right click on a sequence
label.autoadd_secstr = Add secondary structure annotation to alignment
label.autoadd_temp = Add Temperature Factor annotation to alignment
label.structure_viewer = Default structure viewer
+label.chimera_path = Path to Chimera program
+label.chimera_path_tip = Jalview will try standard locations, plus any path entered here.
+label.invalid_path = File not found or not executable
label.min_colour = Minimum Colour
label.max_colour = Maximum Colour
label.use_original_colours = Use Original Colours
label.map_sequences_to_visible_window = Map Sequences to Visible Window: {0}
label.add_pdbentry_to_view = Do you want to add {0} to the view called\n{1}\n
label.align_to_existing_structure_view = Align to existing structure view
-label.pdb_entries_couldnt_be_retrieved = The following pdb entries could not be retrieved from the PDB\:\n{0}\nPlease try downloading them manually.
+label.pdb_entries_couldnt_be_retrieved = The following pdb entries could not be retrieved from the PDB\:\n{0}\nPlease retry, or try downloading them manually.
label.couldnt_load_file = Couldn't load file
label.couldnt_find_pdb_id_in_file = Couldn't find a PDB id in the file supplied. Please enter an Id to identify this structure.
label.no_pdb_id_in_file = No PDB Id in File
label.edit_sequences = Edit Sequences
label.sequence_details = Sequence Details
label.jmol_help = Jmol Help
+label.chimera_help = Chimera Help
+label.close_viewer = Close Viewer
+label.confirm_close_chimera = This will close Jalview''s connection to {0}.<br>Do you want to close the Chimera window as well?
+label.chimera_help = Chimera Help
label.all = All
label.sort_by = Sort alignment by
label.sort_by_score = Sort by Score
label.display_features_same_type_different_label_using_different_colour = Display features of the same type with a different label using a different colour. (e.g. domain features)
label.select_colour_minimum_value = Select Colour for Minimum Value
label.select_colour_maximum_value = Select Colour for Maximum Value
-label.open_new_jmol_view_with_all_structures_associated_current_selection_superimpose_using_alignment = Open a new Jmol view with all structures associated with the current selection and superimpose them using the alignment.
+label.open_new_jmol_view_with_all_structures_associated_current_selection_superimpose_using_alignment = Open a new structure viewer with all structures associated with the current selection and superimpose them using the alignment.
label.open_url_param = Open URL {0}
label.open_url_seqs_param = Open URL ({0}..) ({1} seqs)
label.load_pdb_file_associate_with_sequence = Load a PDB file and associate it with sequence {0}
label.web_services = Web Services
label.right_click_to_edit_currently_selected_parameter = Right click to edit currently selected parameter.
label.let_jmol_manage_structure_colours = Let Jmol manage structure colours
+label.let_chimera_manage_structure_colours = Let Chimera manage structure colours
label.marks_leaves_tree_not_associated_with_sequence = Marks leaves of tree not associated with a sequence
label.index_web_services_menu_by_host_site = Index web services in menu by the host site
label.option_want_informed_web_service_URL_cannot_be_accessed_jalview_when_starts_up = Check this option if you want to be informed<br>when a web service URL cannot be accessed by Jalview<br>when it starts up
label.view_structure_for = View structure for {0}
label.view_all_structures = View all {0} structures.
label.view_all_representative_structures = View all {0} representative structures.
-label.open_new_jmol_view_with_all_representative_structures_associated_current_selection_superimpose_using_alignment = Opens a new Jmol view with all representative structures\nassociated with the current selection\nsuperimposed with the current alignment.
+label.open_new_jmol_view_with_all_representative_structures_associated_current_selection_superimpose_using_alignment = Opens a new structure viewer with all representative structures\nassociated with the current selection\nsuperimposed with the current alignment.
label.associate_structure_with_sequence = Associate Structure with Sequence
label.from_file = from file
label.enter_pdb_id = Enter PDB Id
label.link_name = Link Name
label.pdb_file = PDB file
label.colour_with_jmol = Colour with Jmol
+label.colour_with_chimera = Colour with Chimera
label.align_structures = Align structures
label.jmol = Jmol
+label.chimera = Chimera
label.sort_alignment_by_tree = Sort Alignment By Tree
label.mark_unlinked_leaves = Mark Unlinked Leaves
label.associate_leaves_with = Associate Leaves With
label.copied_sequences = Copied sequences
label.cut_sequences = Cut Sequences
label.conservation_colour_increment = Conservation Colour Increment ({0})
-label.percentage_identity_thereshold = Percentage Identity Thereshold ({0})
+label.percentage_identity_thereshold = Percentage Identity Threshold ({0})
label.error_unsupported_owwner_user_colour_scheme = Unsupported owner for User Colour scheme dialog
label.save_alignment_to_file = Save Alignment to file
label.save_features_to_file = Save Features to File
label.add_jabaws_url = Add new JABAWS URL
label.news_from_jalview = News from http://www.jalview.org
label.cut_paste_alignmen_file = Cut & Paste Alignment File
-label.enter_redundancy_thereshold = Enter the redundancy thereshold
+label.enter_redundancy_thereshold = Enter the redundancy threshold
label.select_dark_light_set_thereshold = <html><i>Select a dark and light text colour, then set the threshold to<br>switch between colours, based on background colour</i></html>
label.select_feature_colour = Select Feature Colour
label.delete_all = Delete all sequences
*/
package MCview;
-import java.io.*;
-
-import java.awt.event.*;
-import javax.swing.*;
-
-import jalview.datamodel.*;
-import jalview.gui.*;
-import jalview.io.*;
-import jalview.schemes.*;
+import jalview.datamodel.PDBEntry;
+import jalview.datamodel.SequenceI;
+import jalview.gui.AlignmentPanel;
+import jalview.gui.Desktop;
+import jalview.gui.OOMWarning;
+import jalview.gui.UserDefinedColours;
+import jalview.io.JalviewFileChooser;
+import jalview.io.JalviewFileView;
+import jalview.schemes.BuriedColourScheme;
+import jalview.schemes.HelixColourScheme;
+import jalview.schemes.HydrophobicColourScheme;
+import jalview.schemes.StrandColourScheme;
+import jalview.schemes.TaylorColourScheme;
+import jalview.schemes.TurnColourScheme;
+import jalview.schemes.UserColourScheme;
+import jalview.schemes.ZappoColourScheme;
import jalview.util.MessageManager;
import jalview.ws.ebi.EBIFetchClient;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.PrintWriter;
+
+import javax.swing.ButtonGroup;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JColorChooser;
+import javax.swing.JInternalFrame;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
+import javax.swing.JRadioButtonMenuItem;
+import javax.swing.SwingUtilities;
+
public class PDBViewer extends JInternalFrame implements Runnable
{
.getAbsolutePath());
if (pdbentry.getFile() != null)
+ {
pdbcanvas.init(pdbentry, seq, chains, ap, protocol);
+ }
} catch (Exception ex)
{
pdbcanvas.errorMessage = "Error retrieving file: " + pdbentry.getId();
*/
public void eps_actionPerformed(ActionEvent e)
{
- makePDBImage(jalview.util.ImageMaker.EPS);
+ makePDBImage(jalview.util.ImageMaker.TYPE.EPS);
}
/**
*/
public void png_actionPerformed(ActionEvent e)
{
- makePDBImage(jalview.util.ImageMaker.PNG);
+ makePDBImage(jalview.util.ImageMaker.TYPE.PNG);
}
- void makePDBImage(int type)
+ void makePDBImage(jalview.util.ImageMaker.TYPE type)
{
int width = pdbcanvas.getWidth();
int height = pdbcanvas.getHeight();
jalview.util.ImageMaker im;
- if (type == jalview.util.ImageMaker.PNG)
+ if (type == jalview.util.ImageMaker.TYPE.PNG)
{
- im = new jalview.util.ImageMaker(this, jalview.util.ImageMaker.PNG,
+ im = new jalview.util.ImageMaker(this,
+ jalview.util.ImageMaker.TYPE.PNG,
"Make PNG image from view", width, height, null, null);
}
- else
+ else if (type == jalview.util.ImageMaker.TYPE.EPS)
{
- im = new jalview.util.ImageMaker(this, jalview.util.ImageMaker.EPS,
+ im = new jalview.util.ImageMaker(this,
+ jalview.util.ImageMaker.TYPE.EPS,
"Make EPS file from view", width, height, null,
this.getTitle());
}
+ else
+ {
+
+ im = new jalview.util.ImageMaker(this,
+ jalview.util.ImageMaker.TYPE.SVG, "Make SVG file from PCA",
+ width, height, null, this.getTitle());
+ }
if (im.getGraphics() != null)
{
public List<ChimeraModel> openModel(String modelPath, ModelType type)
{
+ return openModel(modelPath, getFileNameFromPath(modelPath), type);
+ }
+
+ /**
+ * Overloaded method to allow Jalview to pass in a model name.
+ *
+ * @param modelPath
+ * @param modelName
+ * @param type
+ * @return
+ */
+ public List<ChimeraModel> openModel(String modelPath, String modelName,
+ ModelType type)
+ {
logger.info("chimera open " + modelPath);
stopListening();
List<String> response = null;
{
continue;
}
- String modelName = modelPath;
- // TODO: [Optional] Convert path to name in a better way
- if (modelPath.lastIndexOf(File.separator) > 0)
- {
- modelName = modelPath.substring(modelPath
- .lastIndexOf(File.separator) + 1);
- }
- else if (modelPath.lastIndexOf("/") > 0)
- {
- modelName = modelPath
- .substring(modelPath.lastIndexOf("/") + 1);
- }
ChimeraModel newModel = new ChimeraModel(modelName, type,
modelNumbers[0], modelNumbers[1]);
currentModelsMap.put(modelNumber, newModel);
models.add(newModel);
+ // patch for Jalview - set model name in Chimera
+ sendChimeraCommand("setattr M name " + modelName + " #"
+ + modelNumbers[0], false);
+ // end patch for Jalview
modelNumbers = null;
}
}
return models;
}
+ /**
+ * Refactored method to extract the last (or only) element delimited by file
+ * path separator.
+ *
+ * @param modelPath
+ * @return
+ */
+ private String getFileNameFromPath(String modelPath)
+ {
+ String modelName = modelPath;
+ if (modelPath == null)
+ {
+ return null;
+ }
+ // TODO: [Optional] Convert path to name in a better way
+ if (modelPath.lastIndexOf(File.separator) > 0)
+ {
+ modelName = modelPath.substring(modelPath
+ .lastIndexOf(File.separator) + 1);
+ }
+ else if (modelPath.lastIndexOf("/") > 0)
+ {
+ modelName = modelPath
+ .substring(modelPath.lastIndexOf("/") + 1);
+ }
+ return modelName;
+ }
+
public void closeModel(ChimeraModel model)
{
// int model = structure.modelNumber();
public boolean isChimeraLaunched()
{
- // TODO: [Optional] What is the best way to test if chimera is launched?
-
- // sendChimeraCommand("test", true) !=null
+ boolean launched = false;
if (chimera != null)
{
- return true;
+ try
+ {
+ chimera.exitValue();
+ // if we get here, process has ended
+ } catch (IllegalThreadStateException e)
+ {
+ // ok - not yet terminated
+ launched = true;
+ }
}
- return false;
+ return launched;
}
public boolean launchChimera(List<String> chimeraPaths)
{
return null;
}
- return ChimUtils.parseModelColor((String) colorLines.get(0));
+ return ChimUtils.parseModelColor(colorLines.get(0));
}
/**
{
return null;
}
+ // TODO do we need a maximum wait time before aborting?
while (busy)
{
try
;
}
busy = true;
- chimeraListenerThreads.clearResponse(command);
- String text = command.concat("\n");
- // System.out.println("send command to chimera: " + text);
try
{
- // send the command
- chimera.getOutputStream().write(text.getBytes());
- chimera.getOutputStream().flush();
- } catch (IOException e)
- {
- // logger.info("Unable to execute command: " + text);
- // logger.info("Exiting...");
- logger.warn("Unable to execute command: " + text);
- logger.warn("Exiting...");
- clearOnChimeraExit();
- busy = false;
- return null;
- }
- if (!reply)
+ chimeraListenerThreads.clearResponse(command);
+ String text = command.concat("\n");
+ // System.out.println("send command to chimera: " + text);
+ try
+ {
+ // send the command
+ chimera.getOutputStream().write(text.getBytes());
+ chimera.getOutputStream().flush();
+ } catch (IOException e)
+ {
+ // logger.info("Unable to execute command: " + text);
+ // logger.info("Exiting...");
+ logger.warn("Unable to execute command: " + text);
+ logger.warn("Exiting...");
+ clearOnChimeraExit();
+ // busy = false;
+ return null;
+ }
+ if (!reply)
+ {
+ // busy = false;
+ return null;
+ }
+ List<String> rsp = chimeraListenerThreads.getResponse(command);
+ // busy = false;
+ return rsp;
+ } finally
{
busy = false;
- return null;
}
- List<String> rsp = chimeraListenerThreads.getResponse(command);
- busy = false;
- return rsp;
}
public StructureManager getStructureManager()
package ext.edu.ucsf.rbvi.strucviz2;
+import jalview.bin.Cache;
+import jalview.gui.Preferences;
+
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
static final String[] defaultResidueKeys =
{ "FunctionalResidues", "ResidueList", "Residues" };
- private final String chimeraPropertyName = "chimera";
-
- private final String chimeraPathPropertyKey = "LastChimeraPath";
-
public enum ModelType
{
PDB_MODEL, MODBASE_MODEL, SMILES
// we do not care about the model anymore
selSpec = selSpec.concat(nodeInfo.toSpec());
if (i < chimSelectionList.size() - 1)
+ {
selSpec.concat("|");
+ }
}
if (selSpec.length() > 0)
{
for (ChimeraStructuralObject cso : chimSelectionList)
{
if (cso != null)
+ {
cso.setSelected(false);
+ }
}
chimSelectionList.clear();
}
}
}
- // if no network settings, check if the last chimera path is saved in the
- // session
- // String lastPath = CytoUtils.getDefaultChimeraPath(registrar,
- // chimeraPropertyName,
- // chimeraPathPropertyKey);
- // if (lastPath != null && !lastPath.equals("")) {
- // pathList.add(lastPath);
- // return pathList;
- // }
+ /*
+ * Jalview addition: check if path set in user preferences.
+ */
+ String userPath = Cache.getDefault(Preferences.CHIMERA_PATH, null);
+ if (userPath != null)
+ {
+ pathList.add(userPath);
+ }
- // if no user settings and no last path, get default system's settings
+ // Add default installation paths
String os = System.getProperty("os.name");
if (os.startsWith("Linux"))
{
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import ext.edu.ucsf.rbvi.strucviz2.*;
+import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
/***************************************************
* Thread Classes *
public List<String> getResponse(String command) {
List<String> reply;
// System.out.println("getResponse: "+command);
+ // TODO do we need a maximum wait time before aborting?
while (!replyLog.containsKey(command)) {
try {
Thread.currentThread().sleep(100);
} catch (InterruptedException e) {
}
if (replyLog.containsKey(command))
- replyLog.remove(command);
+ {
+ replyLog.remove(command);
+ }
return;
}
*/
private void chimeraRead() throws IOException {
if (chimera == null)
- return;
+ {
+ return;
+ }
String line = null;
while ((line = lineReader.readLine()) != null) {
replyLog.put(command, reply);
}
if (updateModels)
- (new ModelUpdater()).start();
+ {
+ (new ModelUpdater()).start();
+ }
if (updateSelection)
- (new SelectionUpdater()).start();
+ {
+ (new SelectionUpdater()).start();
+ }
if (importNetwork) {
(new NetworkUpdater(line)).start();
}
* display</li>
* <li>STRUCTURE_DISPLAY choose from JMOL (default) or CHIMERA for 3D structure
* display</li>
+ * <li>CHIMERA_PATH specify full path to Chimera program (if non-standard)</li>
*
* </ul>
* Deprecated settings:
}
return sourceRegistry;
}
+
+ /**
+ * Set the specified value, or remove it if null or empty. Does not save the
+ * properties file.
+ *
+ * @param propName
+ * @param value
+ */
+ public static void setOrRemove(String propName, String value)
+ {
+ if (propName == null)
+ {
+ return;
+ }
+ if (value == null || value.trim().length() < 1)
+ {
+ Cache.applicationProperties.remove(propName);
+ }
+ else
+ {
+ Cache.applicationProperties.setProperty(propName, value);
+ }
+ }
}
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
-import java.util.Hashtable;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import java.util.Vector;
import ext.edu.ucsf.rbvi.strucviz2.ChimeraManager;
import ext.edu.ucsf.rbvi.strucviz2.ChimeraModel;
SequenceStructureBinding, StructureSelectionManagerProvider
{
+ private static final String PHOSPHORUS = "P";
+
+ private static final String ALPHACARBON = "CA";
+
private StructureManager csm;
private ChimeraManager viewer;
private boolean loadingFromArchive = false;
/**
- * second flag to indicate if the jmol viewer should ignore sequence colouring
- * events from the structure manager because the GUI is still setting up
+ * second flag to indicate if the Chimera viewer should ignore sequence
+ * colouring events from the structure manager because the GUI is still
+ * setting up
*/
private boolean loadingFinished = true;
/**
- * state flag used to check if the Jmol viewer's paint method can be called
+ * state flag used to check if the Chimera viewer's paint method can be called
*/
private boolean finishedInit = false;
/**
* when true, try to search the associated datamodel for sequences that are
- * associated with any unknown structures in the Jmol view.
+ * associated with any unknown structures in the Chimera view.
*/
private boolean associateNewStructs = false;
- Vector atomsPicked = new Vector();
+ List<String> atomsPicked = new ArrayList<String>();
- public Vector chainNames;
+ public List<String> chainNames;
- Hashtable chainFile;
+ private Map<String, String> chainFile;
/**
- * array of target chains for seuqences - tied to pdbentry and sequence[]
+ * array of target chains for sequences - tied to pdbentry and sequence[]
*/
protected String[][] chains;
public String fileLoadingError;
- private Map<String, List<ChimeraModel>> chimmaps = new HashMap<String, List<ChimeraModel>>();
+ private Map<String, List<ChimeraModel>> chimmaps = new LinkedHashMap<String, List<ChimeraModel>>();
private List<String> mdlToFile = new ArrayList<String>();
try
{
List<ChimeraModel> oldList = viewer.getModelList();
- viewer.openModel(file, ModelType.PDB_MODEL);
+ viewer.openModel(file, pe.getId(), ModelType.PDB_MODEL);
List<ChimeraModel> newList = viewer.getModelList();
if (oldList.size() < newList.size())
{
} catch (Error e)
{
}
- // Explicitly map to the filename used by Jmol ;
+ // Explicitly map to the filename used by Chimera ;
// pdbentry[pe].getFile(), protocol);
if (ssm != null)
}
viewer = new ChimeraManager(
csm = new ext.edu.ucsf.rbvi.strucviz2.StructureManager(true));
- /*
- * viewer = JmolViewer.allocateViewer(renderPanel, new SmarterJmolAdapter(),
- * "jalviewJmol", ap.av.applet .getDocumentBase(),
- * ap.av.applet.getCodeBase(), "", this);
- *
- * jmolpopup = JmolPopup.newJmolPopup(viewer, true, "Jmol", true);
- */
}
public JalviewChimeraBinding(StructureSelectionManager ssm,
}
/**
- * construct a title string for the viewer window based on the data jalview
+ * Construct a title string for the viewer window based on the data Jalview
* knows about
*
+ * @param verbose
* @return
*/
- public String getViewerTitle()
+ public String getViewerTitle(boolean verbose)
{
if (sequence == null || pdbentry == null || sequence.length < 1
|| pdbentry.length < 1 || sequence[0].length < 1)
}
// TODO: give a more informative title when multiple structures are
// displayed.
- StringBuffer title = new StringBuffer("Chimera view for "
- + sequence[0][0].getName() + ":" + pdbentry[0].getId());
+ StringBuilder title = new StringBuilder(64);
+ title.append("Chimera view for " + sequence[0][0].getName() + ":"
+ + pdbentry[0].getId());
- if (pdbentry[0].getProperty() != null)
+ if (verbose)
{
- if (pdbentry[0].getProperty().get("method") != null)
- {
- title.append(" Method: ");
- title.append(pdbentry[0].getProperty().get("method"));
- }
- if (pdbentry[0].getProperty().get("chains") != null)
+ if (pdbentry[0].getProperty() != null)
{
- title.append(" Chain:");
- title.append(pdbentry[0].getProperty().get("chains"));
+ if (pdbentry[0].getProperty().get("method") != null)
+ {
+ title.append(" Method: ");
+ title.append(pdbentry[0].getProperty().get("method"));
+ }
+ if (pdbentry[0].getProperty().get("chains") != null)
+ {
+ title.append(" Chain:");
+ title.append(pdbentry[0].getProperty().get("chains"));
+ }
}
}
return title.toString();
* prepare the view for a given set of models/chains. chainList contains
* strings of the form 'pdbfilename:Chaincode'
*
- * @param chainList
+ * @param toshow
* list of chains to make visible
*/
- public void centerViewer(Vector chainList)
+ public void centerViewer(List<String> toshow)
{
- StringBuffer cmd = new StringBuffer();
- String lbl;
+ StringBuilder cmd = new StringBuilder(64);
int mlength, p;
- for (int i = 0, iSize = chainList.size(); i < iSize; i++)
+ for (String lbl : toshow)
{
mlength = 0;
- lbl = (String) chainList.elementAt(i);
do
{
p = mlength;
mlength = lbl.indexOf(":", p);
} while (p < mlength && mlength < (lbl.length() - 2));
// TODO: lookup each pdb id and recover proper model number for it.
- cmd.append("#" + getModelNum((String) chainFile.get(lbl)) + "."
+ cmd.append("#" + getModelNum(chainFile.get(lbl)) + "."
+ lbl.substring(mlength + 1) + " or ");
}
if (cmd.length() > 0)
+ {
cmd.setLength(cmd.length() - 4);
- evalStateCommand("~display #*; ~ribbon #*; ribbon " + cmd + ";focus "
- + cmd,false);
+ }
+ String cmdstring = cmd.toString();
+ evalStateCommand("~display #*; ~ribbon #*; ribbon " + cmdstring
+ + ";focus " + cmdstring, false);
}
- public void closeViewer()
+ /**
+ * Close down the Jalview viewer, and (optionally) the associate Chimera
+ * window.
+ */
+ public void closeViewer(boolean closeChimera)
{
ssm.removeStructureViewerListener(this, this.getPdbFile());
- // and shut down Chimera
- viewer.exitChimera();
- // viewer.evalStringQuiet("zap");
- // viewer.setJmolStatusListener(null);
+ if (closeChimera)
+ {
+ viewer.exitChimera();
+ }
lastCommand = null;
viewer = null;
releaseUIResources();
}
/**
- * called by JalviewJmolbinding after closeViewer is called - release any
+ * called by JalviewChimerabinding after closeViewer is called - release any
* resources and references so they can be garbage collected.
*/
protected abstract void releaseUIResources();
public void colourByChain()
{
colourBySequence = false;
- // TODO: colour by chain should colour each chain distinctly across all
- // visible models
- // TODO: http://issues.jalview.org/browse/JAL-628
+ // this is not a valid Chimera command; is there one? Menu option hidden
evalStateCommand("select *;color chain",false);
}
public void colourByCharge()
{
colourBySequence = false;
- evalStateCommand("colour *;color white;select ASP,GLU;color red;"
- + "select LYS,ARG;color blue;select CYS;color yellow", false);
+ evalStateCommand(
+ "color white;color red ::ASP;color red ::GLU;color blue ::LYS;color blue ::ARG;color yellow ::CYS",
+ false);
}
/**
int[] _refStructure, ColumnSelection[] _hiddenCols)
{
assert (_alignment.length == _refStructure.length && _alignment.length != _hiddenCols.length);
- StringBuffer allComs = new StringBuffer(); // whole shebang for superposition
+ StringBuilder allComs = new StringBuilder(128); // Chimera superposition cmd
String[] files = getPdbFile();
- // check to see if we are still waiting for Jmol files
+ // check to see if we are still waiting for Chimera files
long starttime = System.currentTimeMillis();
boolean waiting = true;
do
if (waiting)
{
System.err
- .println("RUNTIME PROBLEM: Jmol seems to be taking a long time to process all the structures.");
+ .println("RUNTIME PROBLEM: Chimera seems to be taking a long time to process all the structures.");
return;
}
refreshPdbEntries();
{
refStructure = -1;
}
- StringBuffer command = new StringBuffer();
boolean matched[] = new boolean[alignment.getWidth()];
for (int m = 0; m < matched.length; m++)
int commonrpositions[][] = new int[files.length][alignment.getWidth()];
String isel[] = new String[files.length];
- // reference structure - all others are superposed in it
String[] targetC = new String[files.length];
String[] chainNames = new String[files.length];
- String[] atomS = new String[files.length];
+ String[] atomSpec = new String[files.length];
for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++)
{
StructureMapping[] mapping = ssm.getMapping(files[pdbfnum]);
}
chainNames[pdbfnum] = mapping[m].getPdbId()
+ targetC[pdbfnum];
- atomS[pdbfnum] = asp.getRNA()!=null ? "P" : "CA";
+ atomSpec[pdbfnum] = asp.getRNA() != null ? PHOSPHORUS : ALPHACARBON;
// move on to next pdb file
s = sequence[pdbfnum].length;
break;
}
}
}
+ StringBuilder command = new StringBuilder(256);
for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++)
{
if (pdbfnum == refStructure || selcom[pdbfnum] == null
{
continue;
}
- if (command.length()>0)
+ if (command.length() > 0)
{
command.append(";");
}
- command.append("match");
- // form the matched pair strings
- for (int s = 0; s < 2; s++)
- {
- command.append(" #"+(s == 0 ? pdbfnum : refStructure)+".1");
- // note - need to select on first model, otherwise it all goes wrong!
- command.append(selcom[(s == 0 ? pdbfnum : refStructure)]);
- command.append("@"+atomS[(s == 0 ? pdbfnum : refStructure)]); // match on backbone alpha/polyphosphate
- }
+ /*
+ * Form Chimera match command, from the 'new' structure to the
+ * 'reference' structure e.g. (residues 1-91, chain B/A, alphacarbons):
+ *
+ * match #1:1-91.B@CA #0:1-91.A@CA
+ *
+ * @see
+ * https://www.cgl.ucsf.edu/chimera/docs/UsersGuide/midas/match.html
+ */
+ command.append("match #" + pdbfnum /* +".1" */);
+ // TODO: handle sub-models
+ command.append(selcom[pdbfnum]);
+ command.append("@" + atomSpec[pdbfnum]);
+ command.append(" #" + refStructure /* +".1" */);
+ command.append(selcom[refStructure]);
+ command.append("@" + atomSpec[refStructure]);
}
if (selectioncom.length() > 0)
{
+ // TODO remove debug output
System.out.println("Select regions:\n" + selectioncom.toString());
System.out
.println("Superimpose command(s):\n" + command.toString());
}
System.out.println("Select regions:\n" + selectioncom.toString());
allComs.append("; ~display all; chain @CA|P; ribbon "
- + selectioncom.toString() + "");
+ + selectioncom.toString() + "; focus");
// evalStateCommand("select *; backbone; select "+selcom.toString()+"; cartoons; center "+selcom.toString());
- evalStateCommand(allComs.toString(),false);
+ evalStateCommand(allComs.toString(), true /* false */);
}
}
}
}
- public void evalStateCommand(final String command, boolean resp)
+ /**
+ * Answers true if the Chimera process is still running, false if ended or not
+ * started.
+ *
+ * @return
+ */
+ public boolean isChimeraRunning()
+ {
+ return viewer.isChimeraLaunched();
+ }
+
+ /**
+ * Send a command to Chimera, and optionally log any responses.
+ *
+ * @param command
+ * @param logResponse
+ */
+ public void evalStateCommand(final String command, boolean logResponse)
{
viewerCommandHistory(false);
checkLaunched();
// @Override
// public void run()
// {
- lastReply = viewer.sendChimeraCommand(command, resp);
- if (debug)
+ // trim command or it may never find a match in the replyLog!!
+ lastReply = viewer.sendChimeraCommand(command.trim(), logResponse);
+ if (debug && logResponse)
{
log("Response from command ('" + command + "') was:\n"
+ lastReply);
jalview.api.AlignmentViewPanel alignmentv)
{
if (!colourBySequence || !loadingFinished)
+ {
return;
+ }
if (ssm == null)
{
return;
for (jalview.structure.StructureMappingcommandSet cpdbbyseq : ChimeraCommands
.getColourBySequenceCommand(ssm, files, sequence, sr, fr,
alignment))
+ {
for (String cbyseq : cpdbbyseq.commands)
{
waitForChimera();
evalStateCommand(cbyseq, false);
waitForChimera();
}
+ }
}
private void waitForChimera()
this.colourBySequence = colourBySequence;
}
- public void createImage(String file, String type, int quality)
- {
- System.out.println("JMOL CREATE IMAGE");
- }
-
- public String createImage(String fileName, String type,
- Object textOrBytes, int quality)
- {
- System.out.println("JMOL CREATE IMAGE");
- return null;
- }
-
- public String eval(String strEval)
- {
- // System.out.println(strEval);
- // "# 'eval' is implemented only for the applet.";
- return null;
- }
-
// End StructureListener
// //////////////////////////
String pdbfile)
{
if (getModelNum(pdbfile) < 0)
+ {
return null;
+ }
log("get model / residue colour attribute unimplemented");
return null;
}
for (int i = 0; i < mfn.length; i++)
{
if (mfn[i].equalsIgnoreCase(modelFileName))
+ {
return i;
+ }
}
return -1;
}
String chainId;
if (strInfo.indexOf(":") > -1)
+ {
chainId = strInfo.substring(strInfo.indexOf(":") + 1,
strInfo.indexOf("."));
+ }
else
{
chainId = " ";
;
}
if (lastMessage == null || !lastMessage.equals(strInfo))
+ {
ssm.mouseOverStructure(pdbResNum, chainId, pdbfilename);
+ }
lastMessage = strInfo;
}
int chainSeparator = strInfo.indexOf(":");
int p = 0;
if (chainSeparator == -1)
+ {
chainSeparator = strInfo.indexOf(".");
+ }
String picked = strInfo.substring(strInfo.indexOf("]") + 1,
chainSeparator);
String mdlString = "";
if ((p = strInfo.indexOf(":")) > -1)
+ {
picked += strInfo.substring(p + 1, strInfo.indexOf("."));
+ }
if ((p = strInfo.indexOf("/")) > -1)
{
if (!atomsPicked.contains(picked))
{
viewer.select(picked);
- atomsPicked.addElement(picked);
+ atomsPicked.add(picked);
}
else
{
viewer.select("not " + picked);
- atomsPicked.removeElement(picked);
+ atomsPicked.remove(picked);
}
viewerCommandHistory(true);
// TODO: in application this happens
// incremented every time a load notification is successfully handled -
// lightweight mechanism for other threads to detect when they can start
- // referrring to new structures.
+ // referring to new structures.
private long loadNotifiesHandled = 0;
public long getLoadNotifiesHandled()
fileLoadingError = null;
String[] oldmodels = modelFileNames;
modelFileNames = null;
- chainNames = new Vector();
- chainFile = new Hashtable();
+ chainNames = new ArrayList<String>();
+ chainFile = new HashMap<String, String>();
boolean notifyLoaded = false;
String[] modelfilenames = getPdbFile();
// first check if we've lost any structures
colourBySequence = false;
if (cs == null)
+ {
return;
+ }
String res;
int index;
Color col;
+ // Chimera expects RBG values in the range 0-1
+ final double normalise = 255D;
viewerCommandHistory(false);
// TODO: Switch between nucleotide or aa selection expressions
Enumeration en = ResidueProperties.aa3Hash.keys();
- StringBuffer command = new StringBuffer("select *;color white;");
+ StringBuilder command = new StringBuilder(128);
+ command.append("color white;");
while (en.hasMoreElements())
{
res = en.nextElement().toString();
index = ((Integer) ResidueProperties.aa3Hash.get(res)).intValue();
if (index > 20)
+ {
continue;
+ }
col = cs.findColour(ResidueProperties.aa[index].charAt(0));
- // TODO: need colour string function and res selection here
- command.append("select " + res + ";color[" + col.getRed() + ","
- + col.getGreen() + "," + col.getBlue() + "];");
+ command.append("color " + col.getRed() / normalise + ","
+ + col.getGreen() / normalise + "," + col.getBlue()
+ / normalise + " ::" + res + ";");
}
evalStateCommand(command.toString(),false);
viewerCommandHistory(true);
}
- public void showHelp()
- {
- // chimera help
- showUrl("http://jmol.sourceforge.net/docs/JmolUserGuide/", "jmolHelp");
- }
-
/**
- * open the URL somehow
- *
- * @param target
- */
- public abstract void showUrl(String url, String target);
-
- /**
- * called when the binding thinks the UI needs to be refreshed after a Jmol
+ * called when the binding thinks the UI needs to be refreshed after a Chimera
* state change. this could be because structures were loaded, or because an
- * error has occured.
+ * error has occurred.
*/
public abstract void refreshGUI();
/**
*
- * @return true if Jmol is still restoring state or loading is still going on
- * (see setFinsihedLoadingFromArchive)
+ * @return true if Chimeral is still restoring state or loading is still going
+ * on (see setFinsihedLoadingFromArchive)
*/
public boolean isLoadingFromArchive()
{
loadingFinished = finishedLoading;
}
- public void setBackgroundColour(java.awt.Color col)
+ /**
+ * Send the Chimera 'background solid <color>" command.
+ *
+ * @see https
+ * ://www.cgl.ucsf.edu/chimera/current/docs/UsersGuide/midas/background
+ * .html
+ * @param col
+ */
+ public void setBackgroundColour(Color col)
{
viewerCommandHistory(false);
- // todo set background colour
- viewer.sendChimeraCommand(
- "background [" + col.getRed() + "," + col.getGreen() + ","
- + col.getBlue() + "];", false);
+ double normalise = 255D;
+ final String command = "background solid " + col.getRed() / normalise + ","
+ + col.getGreen() / normalise + "," + col.getBlue()
+ / normalise + ";";
+ viewer.sendChimeraCommand(command, false);
viewerCommandHistory(true);
}
public synchronized PDBEntry[] addSequenceAndChain(PDBEntry[] pdbe,
SequenceI[][] seq, String[][] chns)
{
- int pe = -1;
- Vector v = new Vector();
- Vector rtn = new Vector();
+ List<PDBEntry> v = new ArrayList<PDBEntry>();
+ List<int[]> rtn = new ArrayList<int[]>();
for (int i = 0; i < pdbentry.length; i++)
{
- v.addElement(pdbentry[i]);
+ v.add(pdbentry[i]);
}
for (int i = 0; i < pdbe.length; i++)
{
int r = v.indexOf(pdbe[i]);
if (r == -1 || r >= pdbentry.length)
{
- rtn.addElement(new int[]
+ rtn.add(new int[]
{ v.size(), i });
- v.addElement(pdbe[i]);
+ v.add(pdbe[i]);
}
else
{
addSequenceAndChain(r, seq[i], chns[i]);
}
}
- pdbe = new PDBEntry[v.size()];
- v.copyInto(pdbe);
+ pdbe = v.toArray(new PDBEntry[v.size()]);
pdbentry = pdbe;
if (rtn.size() > 0)
{
- // expand the tied seuqence[] and string[] arrays
+ // expand the tied sequence[] and string[] arrays
SequenceI[][] sqs = new SequenceI[pdbentry.length][];
String[][] sch = new String[pdbentry.length][];
System.arraycopy(sequence, 0, sqs, 0, sequence.length);
pdbe = new PDBEntry[rtn.size()];
for (int r = 0; r < pdbe.length; r++)
{
- int[] stri = ((int[]) rtn.elementAt(r));
+ int[] stri = (rtn.get(r));
// record the pdb file as a new addition
pdbe[r] = pdbentry[stri[0]];
// and add the new sequence/chain entries
return pdbe;
}
+ /**
+ * Adds sequences to the pe'th pdbentry's sequence set.
+ *
+ * @param pe
+ * @param seq
+ */
public void addSequence(int pe, SequenceI[] seq)
{
- // add sequences to the pe'th pdbentry's seuqence set.
addSequenceAndChain(pe, seq, null);
}
{
if (pe < 0 || pe >= pdbentry.length)
{
- throw new Error(MessageManager.formatMessage("error.implementation_error_no_pdbentry_from_index", new String[]{Integer.valueOf(pe).toString()}));
+ throw new Error(MessageManager.formatMessage(
+ "error.implementation_error_no_pdbentry_from_index",
+ new Object[]
+ { Integer.valueOf(pe).toString() }));
}
final String nullChain = "TheNullChain";
- Vector s = new Vector();
- Vector c = new Vector();
+ List<SequenceI> s = new ArrayList<SequenceI>();
+ List<String> c = new ArrayList<String>();
if (chains == null)
{
chains = new String[pdbentry.length][];
{
for (int i = 0; i < sequence[pe].length; i++)
{
- s.addElement(sequence[pe][i]);
+ s.add(sequence[pe][i]);
if (chains[pe] != null)
{
if (i < chains[pe].length)
{
- c.addElement(chains[pe][i]);
+ c.add(chains[pe][i]);
}
else
{
- c.addElement(nullChain);
+ c.add(nullChain);
}
}
else
{
if (tchain != null && tchain.length > 0)
{
- c.addElement(nullChain);
+ c.add(nullChain);
}
}
}
{
if (!s.contains(seq[i]))
{
- s.addElement(seq[i]);
+ s.add(seq[i]);
if (tchain != null && i < tchain.length)
{
- c.addElement(tchain[i] == null ? nullChain : tchain[i]);
+ c.add(tchain[i] == null ? nullChain : tchain[i]);
}
}
}
- SequenceI[] tmp = new SequenceI[s.size()];
- s.copyInto(tmp);
+ SequenceI[] tmp = s.toArray(new SequenceI[s.size()]);
sequence[pe] = tmp;
if (c.size() > 0)
{
- String[] tch = new String[c.size()];
- c.copyInto(tch);
+ String[] tch = c.toArray(new String[c.size()]);
for (int i = 0; i < tch.length; i++)
{
if (tch[i] == nullChain)
alignPanel.makeEPS(f);
}
+ public void createSVG(File f)
+ {
+ alignPanel.makeSVG(f);
+ }
@Override
public void pageSetup_actionPerformed(ActionEvent e)
{
return idwidth.intValue() + 4;
}
- void makeAlignmentImage(int type, File file)
+ void makeAlignmentImage(jalview.util.ImageMaker.TYPE type, File file)
{
long progress = System.currentTimeMillis();
boolean headless = (System.getProperty("java.awt.headless") != null && System
.getProperty("java.awt.headless").equals("true"));
if (alignFrame != null && !headless)
{
- alignFrame.setProgressBar(MessageManager.formatMessage("status.saving_file", new String[]{(type == jalview.util.ImageMaker.PNG ? MessageManager.getString("label.png_image") : MessageManager.getString("label.eps_file"))}), progress);
+ alignFrame.setProgressBar(MessageManager.formatMessage(
+ "status.saving_file",
+ new String[]
+ { type.getLabel() }), progress);
}
try
{
jalview.util.ImageMaker im;
final String imageAction, imageTitle;
- if (type == jalview.util.ImageMaker.PNG)
+ if (type == jalview.util.ImageMaker.TYPE.PNG)
{
imageAction = "Create PNG image from alignment";
imageTitle = null;
}
- else
+ else if (type == jalview.util.ImageMaker.TYPE.EPS)
{
imageAction = "Create EPS file from alignment";
imageTitle = alignFrame.getTitle();
}
+ else
+ {
+ imageAction = "Create SVG file from alignment";
+ imageTitle = alignFrame.getTitle();
+ }
+
im = new jalview.util.ImageMaker(this, type, imageAction, width,
height, file, imageTitle);
if (av.getWrapAlignment())
*/
public void makeEPS(File epsFile)
{
- makeAlignmentImage(jalview.util.ImageMaker.EPS, epsFile);
+ makeAlignmentImage(jalview.util.ImageMaker.TYPE.EPS, epsFile);
}
/**
*/
public void makePNG(File pngFile)
{
- makeAlignmentImage(jalview.util.ImageMaker.PNG, pngFile);
+ makeAlignmentImage(jalview.util.ImageMaker.TYPE.PNG, pngFile);
}
+ public void makeSVG(File svgFile)
+ {
+ makeAlignmentImage(jalview.util.ImageMaker.TYPE.SVG, svgFile);
+ }
public void makePNGImageMap(File imgMapFile, String imageName)
{
// /////ONLY WORKS WITH NONE WRAPPED ALIGNMENTS
*/
package jalview.gui;
-import java.util.*;
-import java.awt.*;
-
-import javax.swing.*;
-import javax.swing.event.*;
-
-import java.awt.event.*;
-import java.io.*;
-
-import jalview.jbgui.GStructureViewer;
-import jalview.api.SequenceStructureBinding;
import jalview.api.structures.JalviewStructureDisplayI;
import jalview.bin.Cache;
-import jalview.datamodel.*;
-import jalview.gui.ViewSelectionMenu.ViewSetProvider;
+import jalview.datamodel.Alignment;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.ColumnSelection;
import jalview.datamodel.PDBEntry;
+import jalview.datamodel.SequenceI;
import jalview.ext.jmol.JalviewJmolBinding;
-import jalview.io.*;
-import jalview.schemes.*;
+import jalview.gui.ViewSelectionMenu.ViewSetProvider;
+import jalview.io.AppletFormatAdapter;
+import jalview.io.JalviewFileChooser;
+import jalview.io.JalviewFileView;
+import jalview.jbgui.GStructureViewer;
+import jalview.schemes.BuriedColourScheme;
+import jalview.schemes.ColourSchemeI;
+import jalview.schemes.HelixColourScheme;
+import jalview.schemes.HydrophobicColourScheme;
+import jalview.schemes.PurinePyrimidineColourScheme;
+import jalview.schemes.StrandColourScheme;
+import jalview.schemes.TaylorColourScheme;
+import jalview.schemes.TurnColourScheme;
+import jalview.schemes.ZappoColourScheme;
import jalview.util.MessageManager;
import jalview.util.Platform;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Vector;
+
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JColorChooser;
+import javax.swing.JInternalFrame;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JSplitPane;
+import javax.swing.event.InternalFrameAdapter;
+import javax.swing.event.InternalFrameEvent;
+import javax.swing.event.MenuEvent;
+import javax.swing.event.MenuListener;
+
public class AppJmol extends GStructureViewer implements Runnable,
ViewSetProvider, JalviewStructureDisplayI
* @param bounds
* @deprecated defaults to AppJmol(String[] files, ... , viewid);
*/
+ @Deprecated
public AppJmol(String file, String id, SequenceI[] seq,
AlignmentPanel ap, String loadStatus, Rectangle bounds)
{
/**
* @deprecated
*/
+ @Deprecated
public AppJmol(String file, String id, SequenceI[] seq,
AlignmentPanel ap, String loadStatus, Rectangle bounds,
String viewid)
{
jmb.setColourBySequence(false);
seqColour.setSelected(false);
- jmolColour.setSelected(true);
+ viewerColour.setSelected(true);
}
if (usetoColour)
{
useAlignmentPanelForColourbyseq(ap);
jmb.setColourBySequence(true);
seqColour.setSelected(true);
- jmolColour.setSelected(false);
+ viewerColour.setSelected(false);
}
this.setBounds(bounds);
initMenus();
private void initMenus()
{
seqColour.setSelected(jmb.isColourBySequence());
- jmolColour.setSelected(!jmb.isColourBySequence());
+ viewerColour.setSelected(!jmb.isColourBySequence());
if (_colourwith == null)
{
_colourwith = new Vector<AlignmentPanel>();
}
});
handler.itemStateChanged(null);
- jmolActionMenu.add(alpanels);
- jmolActionMenu.addMenuListener(new MenuListener()
+ viewerActionMenu.add(alpanels);
+ viewerActionMenu.addMenuListener(new MenuListener()
{
@Override
"label.pdb_entry_is_already_displayed", new String[]
{ pdbentry.getId() }), MessageManager.formatMessage(
"label.map_sequences_to_visible_window", new String[]
- { pdbentry.getId() }), JOptionPane.YES_NO_OPTION);
+ { pdbentry.getId() }),
+ JOptionPane.YES_NO_CANCEL_OPTION);
+ if (option == JOptionPane.CANCEL_OPTION)
+ {
+ return;
+ }
if (option == JOptionPane.YES_OPTION)
{
// TODO : Fix multiple seq to one chain issue here.
{ pdbentry.getId(), topJmol.getTitle() }),
MessageManager
.getString("label.align_to_existing_structure_view"),
- JOptionPane.YES_NO_OPTION);
+ JOptionPane.YES_NO_CANCEL_OPTION);
+ if (option == JOptionPane.CANCEL_OPTION)
+ {
+ return;
+ }
if (option == JOptionPane.YES_OPTION)
{
topJmol.useAlignmentPanelForSuperposition(ap);
useAlignmentPanelForColourbyseq(nap);
jmb.setColourBySequence(enableColourBySeq);
seqColour.setSelected(enableColourBySeq);
- jmolColour.setSelected(!enableColourBySeq);
+ viewerColour.setSelected(!enableColourBySeq);
}
public void useAlignmentPanelForColourbyseq(AlignmentPanel nap)
return;
}
- private Vector getJmolsFor(AlignmentPanel ap2)
+ private Vector getJmolsFor(AlignmentPanel apanel)
{
- Vector otherJmols = new Vector();
- // Now this AppJmol is mapped to new sequences. We must add them to
- // the exisiting array
+ Vector result = new Vector();
JInternalFrame[] frames = Desktop.instance.getAllFrames();
- for (int i = 0; i < frames.length; i++)
+ for (JInternalFrame frame : frames)
{
- if (frames[i] instanceof AppJmol)
+ if (frame instanceof AppJmol)
{
- AppJmol topJmol = ((AppJmol) frames[i]);
- if (topJmol.isLinkedWith(ap2))
+ if (((AppJmol) frame).isLinkedWith(apanel))
{
- otherJmols.addElement(topJmol);
+ result.addElement(frame);
}
}
}
- return otherJmols;
+ return result;
}
void initJmol(String command)
for (int i = 0; i < chainMenu.getItemCount(); i++)
{
if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
+ {
((JCheckBoxMenuItem) chainMenu.getItem(i)).setSelected(true);
+ }
}
centerViewer();
allChainsSelected = false;
public void itemStateChanged(ItemEvent evt)
{
if (!allChainsSelected)
+ {
centerViewer();
+ }
}
});
worker = null;
}
+ @Override
public void pdbFile_actionPerformed(ActionEvent actionEvent)
{
JalviewFileChooser chooser = new JalviewFileChooser(
}
}
+ @Override
public void viewMapping_actionPerformed(ActionEvent actionEvent)
{
jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();
600);
}
- /**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
- */
+ @Override
public void eps_actionPerformed(ActionEvent e)
{
- makePDBImage(jalview.util.ImageMaker.EPS);
+ makePDBImage(jalview.util.ImageMaker.TYPE.EPS);
}
- /**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
- */
+ @Override
public void png_actionPerformed(ActionEvent e)
{
- makePDBImage(jalview.util.ImageMaker.PNG);
+ makePDBImage(jalview.util.ImageMaker.TYPE.PNG);
}
- void makePDBImage(int type)
+ void makePDBImage(jalview.util.ImageMaker.TYPE type)
{
int width = getWidth();
int height = getHeight();
jalview.util.ImageMaker im;
- if (type == jalview.util.ImageMaker.PNG)
+ if (type == jalview.util.ImageMaker.TYPE.PNG)
{
- im = new jalview.util.ImageMaker(this, jalview.util.ImageMaker.PNG,
+ im = new jalview.util.ImageMaker(this,
+ jalview.util.ImageMaker.TYPE.PNG,
"Make PNG image from view", width, height, null, null);
}
- else
+ else if (type == jalview.util.ImageMaker.TYPE.EPS)
{
- im = new jalview.util.ImageMaker(this, jalview.util.ImageMaker.EPS,
+ im = new jalview.util.ImageMaker(this,
+ jalview.util.ImageMaker.TYPE.EPS,
"Make EPS file from view", width, height, null,
this.getTitle());
}
+ else
+ {
+
+ im = new jalview.util.ImageMaker(this,
+ jalview.util.ImageMaker.TYPE.SVG, "Make SVG file from PCA",
+ width, height, null, this.getTitle());
+ }
if (im.getGraphics() != null)
{
}
}
- public void jmolColour_actionPerformed(ActionEvent actionEvent)
+ @Override
+ public void viewerColour_actionPerformed(ActionEvent actionEvent)
{
- if (jmolColour.isSelected())
+ if (viewerColour.isSelected())
{
// disable automatic sequence colouring.
jmb.setColourBySequence(false);
}
}
+ @Override
public void seqColour_actionPerformed(ActionEvent actionEvent)
{
jmb.setColourBySequence(seqColour.isSelected());
}
}
+ @Override
public void chainColour_actionPerformed(ActionEvent actionEvent)
{
chainColour.setSelected(true);
jmb.colourByChain();
}
+ @Override
public void chargeColour_actionPerformed(ActionEvent actionEvent)
{
chargeColour.setSelected(true);
jmb.colourByCharge();
}
+ @Override
public void zappoColour_actionPerformed(ActionEvent actionEvent)
{
zappoColour.setSelected(true);
jmb.setJalviewColourScheme(new ZappoColourScheme());
}
+ @Override
public void taylorColour_actionPerformed(ActionEvent actionEvent)
{
taylorColour.setSelected(true);
jmb.setJalviewColourScheme(new TaylorColourScheme());
}
+ @Override
public void hydroColour_actionPerformed(ActionEvent actionEvent)
{
hydroColour.setSelected(true);
jmb.setJalviewColourScheme(new HydrophobicColourScheme());
}
+ @Override
public void helixColour_actionPerformed(ActionEvent actionEvent)
{
helixColour.setSelected(true);
jmb.setJalviewColourScheme(new HelixColourScheme());
}
+ @Override
public void strandColour_actionPerformed(ActionEvent actionEvent)
{
strandColour.setSelected(true);
jmb.setJalviewColourScheme(new StrandColourScheme());
}
+ @Override
public void turnColour_actionPerformed(ActionEvent actionEvent)
{
turnColour.setSelected(true);
jmb.setJalviewColourScheme(new TurnColourScheme());
}
+ @Override
public void buriedColour_actionPerformed(ActionEvent actionEvent)
{
buriedColour.setSelected(true);
jmb.setJalviewColourScheme(new BuriedColourScheme());
}
+ @Override
public void purinePyrimidineColour_actionPerformed(ActionEvent actionEvent)
{
setJalviewColourScheme(new PurinePyrimidineColourScheme());
}
+ @Override
public void userColour_actionPerformed(ActionEvent actionEvent)
{
userColour.setSelected(true);
new UserDefinedColours(this, null);
}
+ @Override
public void backGround_actionPerformed(ActionEvent actionEvent)
{
java.awt.Color col = JColorChooser.showDialog(this,
}
}
- public void jmolHelp_actionPerformed(ActionEvent actionEvent)
+ @Override
+ public void showHelp_actionPerformed(ActionEvent actionEvent)
{
try
{
this.setTitle(jmb.getViewerTitle());
if (jmb.getPdbFile().length > 1 && jmb.sequence.length > 1)
{
- jmolActionMenu.setVisible(true);
+ viewerActionMenu.setVisible(true);
}
if (!jmb.isLoadingFromArchive())
{
_alignwith.add(ap);
}
;
- for (Component c : jmolActionMenu.getMenuComponents())
+ for (Component c : viewerActionMenu.getMenuComponents())
{
if (c != alignStructs)
{
- jmolActionMenu.remove((JMenuItem) c);
+ viewerActionMenu.remove((JMenuItem) c);
}
}
final ItemListener handler;
import jalview.schemes.ZappoColourScheme;
import jalview.util.MessageManager;
import jalview.util.Platform;
+import jalview.ws.dbsources.Pdb;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
+import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
-import java.util.Enumeration;
import java.util.List;
import java.util.Vector;
ViewSetProvider, JalviewStructureDisplayI
{
- JalviewChimeraBindingModel jmb;
+ private JalviewChimeraBindingModel jmb;
+
+ /*
+ * list of sequenceSet ids associated with the view
+ */
+ private ArrayList<String> _aps = new ArrayList<String>();
+
+ /*
+ * list of alignment panels to use for superposition
+ */
+ private Vector<AlignmentPanel> _alignwith = new Vector<AlignmentPanel>();
+
+ /*
+ * list of alignment panels that are used for colouring structures by aligned
+ * sequences
+ */
+ private Vector<AlignmentPanel> _colourwith = new Vector<AlignmentPanel>();
+
+ private boolean allChainsSelected = false;
+
+ private boolean alignAddedStructures = false;
AlignmentPanel ap;
- Vector atomsPicked = new Vector();
+ /*
+ * state flag for PDB retrieval thread
+ */
+ private boolean _started = false;
private boolean addingStructures = false;
- ViewSelectionMenu seqColourBy;
+ private IProgressIndicator progressBar = null;
+
+ private String viewId = null;
+
+ /*
+ * pdb retrieval thread.
+ */
+ private Thread worker = null;
/**
- *
- * @param files
- * @param ids
- * @param seqs
- * @param ap
- * @param usetoColour
- * - add the alignment panel to the list used for colouring these
- * structures
- * @param useToAlign
- * - add the alignment panel to the list used for aligning these
- * structures
- * @param leaveColouringToJmol
- * - do not update the colours from any other source. Jmol is
- * handling them
- * @param loadStatus
- * @param bounds
- * @param viewid
- *
- * public ChimeraViewFrame(String[] files, String[] ids,
- * SequenceI[][] seqs, AlignmentPanel ap, boolean usetoColour,
- * boolean useToAlign, boolean leaveColouringToJmol, String
- * loadStatus, Rectangle bounds, String viewid) { PDBEntry[]
- * pdbentrys = new PDBEntry[files.length]; for (int i = 0; i <
- * pdbentrys.length; i++) { PDBEntry pdbentry = new PDBEntry();
- * pdbentry.setFile(files[i]); pdbentry.setId(ids[i]); pdbentrys[i] =
- * pdbentry; } // / TODO: check if protocol is needed to be set, and
- * if chains are // autodiscovered. jmb = new
- * JalviewChimeraBindingModel(this,
- * ap.getStructureSelectionManager(), pdbentrys, seqs, null, null);
- *
- * jmb.setLoadingFromArchive(true); addAlignmentPanel(ap); if
- * (useToAlign) { useAlignmentPanelForSuperposition(ap); } if
- * (leaveColouringToJmol || !usetoColour) {
- * jmb.setColourBySequence(false); seqColour.setSelected(false);
- * jmolColour.setSelected(true); } if (usetoColour) {
- * useAlignmentPanelForColourbyseq(ap);
- * jmb.setColourBySequence(true); seqColour.setSelected(true);
- * jmolColour.setSelected(false); } this.setBounds(bounds);
- * initMenus(); viewId = viewid; //
- * jalview.gui.Desktop.addInternalFrame(this, "Loading File", //
- * bounds.width,bounds.height);
- *
- * this.addInternalFrameListener(new InternalFrameAdapter() { public
- * void internalFrameClosing(InternalFrameEvent internalFrameEvent) {
- * closeViewer(); } }); initJmol(loadStatus); // pdbentry, seq,
- * JBPCHECK!
- *
- * }
+ * Initialise menu options.
*/
private void initMenus()
{
+ viewerActionMenu.setText(MessageManager.getString("label.chimera"));
+ viewerColour.setText(MessageManager
+ .getString("label.colour_with_chimera"));
+ viewerColour.setToolTipText(MessageManager
+ .getString("label.let_chimera_manage_structure_colours"));
+ helpItem.setText(MessageManager.getString("label.chimera_help"));
seqColour.setSelected(jmb.isColourBySequence());
- jmolColour.setSelected(!jmb.isColourBySequence());
+ viewerColour.setSelected(!jmb.isColourBySequence());
if (_colourwith == null)
{
_colourwith = new Vector<AlignmentPanel>();
_alignwith = new Vector<AlignmentPanel>();
}
- seqColourBy = new ViewSelectionMenu(MessageManager.getString("label.colour_by"), this, _colourwith,
+ // no colour by chain command in Chimera?
+ chainColour.setVisible(false);
+
+ // save As not yet implemented
+ savemenu.setVisible(false);
+
+ ViewSelectionMenu seqColourBy = new ViewSelectionMenu(
+ MessageManager.getString("label.colour_by"), this, _colourwith,
new ItemListener()
{
-
@Override
public void itemStateChanged(ItemEvent e)
{
}
else
{
- // update the jmol display now.
+ // update the Chimera display now.
seqColour_actionPerformed(null);
}
}
});
viewMenu.add(seqColourBy);
final ItemListener handler;
- JMenu alpanels = new ViewSelectionMenu(MessageManager.getString("label.superpose_with"), this,
+ JMenu alpanels = new ViewSelectionMenu(
+ MessageManager.getString("label.superpose_with"), this,
_alignwith, handler = new ItemListener()
{
-
@Override
public void itemStateChanged(ItemEvent e)
{
alignStructs.setToolTipText(MessageManager
.formatMessage(
"label.align_structures_using_linked_alignment_views",
- new String[]
+ new Object[]
{ new Integer(_alignwith.size()).toString() }));
}
});
handler.itemStateChanged(null);
- jmolActionMenu.add(alpanels);
- jmolActionMenu.addMenuListener(new MenuListener()
+ viewerActionMenu.add(alpanels);
+ viewerActionMenu.addMenuListener(new MenuListener()
{
@Override
public void menuDeselected(MenuEvent e)
{
// TODO Auto-generated method stub
-
}
@Override
public void menuCanceled(MenuEvent e)
{
// TODO Auto-generated method stub
-
}
});
}
- IProgressIndicator progressBar = null;
-
/**
- * add a single PDB structure to a new or existing Jmol view
+ * add a single PDB structure to a new or existing Chimera view
*
* @param pdbentry
* @param seq
public ChimeraViewFrame(PDBEntry pdbentry, SequenceI[] seq,
String[] chains, final AlignmentPanel ap)
{
+ super();
progressBar = ap.alignFrame;
// ////////////////////////////////
// Is the pdb file already loaded?
{
int option = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
MessageManager.formatMessage(
- "label.pdb_entry_is_already_displayed", new String[]
+ "label.pdb_entry_is_already_displayed", new Object[]
{ pdbentry.getId() }), MessageManager.formatMessage(
- "label.map_sequences_to_visible_window", new String[]
- { pdbentry.getId() }), JOptionPane.YES_NO_OPTION);
+ "label.map_sequences_to_visible_window", new Object[]
+ { pdbentry.getId() }),
+ JOptionPane.YES_NO_CANCEL_OPTION);
+ if (option == JOptionPane.CANCEL_OPTION)
+ {
+ return;
+ }
if (option == JOptionPane.YES_OPTION)
{
// TODO : Fix multiple seq to one chain issue here.
ap.paintAlignment(true);
}
- // Now this AppJmol is mapped to new sequences. We must add them to
- // the exisiting array
+ // Now this ChimeraViewFrame is mapped to new sequences. We must add
+ // them to the existing array
JInternalFrame[] frames = Desktop.instance.getAllFrames();
- for (int i = 0; i < frames.length; i++)
+ for (JInternalFrame frame : frames)
{
- if (frames[i] instanceof ChimeraViewFrame)
+ if (frame instanceof ChimeraViewFrame)
{
- final ChimeraViewFrame topJmol = ((ChimeraViewFrame) frames[i]);
+ final ChimeraViewFrame topView = ((ChimeraViewFrame) frame);
// JBPNOTE: this looks like a binding routine, rather than a gui
// routine
- for (int pe = 0; pe < topJmol.jmb.pdbentry.length; pe++)
+ for (int pe = 0; pe < topView.jmb.pdbentry.length; pe++)
{
- if (topJmol.jmb.pdbentry[pe].getFile().equals(alreadyMapped))
+ if (topView.jmb.pdbentry[pe].getFile().equals(alreadyMapped))
{
- topJmol.jmb.addSequence(pe, seq);
- topJmol.addAlignmentPanel(ap);
+ topView.jmb.addSequence(pe, seq);
+ topView.addAlignmentPanel(ap);
// add it to the set used for colouring
- topJmol.useAlignmentPanelForColourbyseq(ap);
- topJmol.buildChimeraActionMenu();
+ topView.useAlignmentPanelForColourbyseq(ap);
+ topView.buildChimeraActionMenu();
ap.getStructureSelectionManager()
.sequenceColoursChanged(ap);
break;
}
}
// /////////////////////////////////
- // Check if there are other Jmol views involving this alignment
+ // Check if there are other Chimera views involving this alignment
// and prompt user about adding this molecule to one of them
- Vector existingViews = getJmolsFor(ap);
- if (existingViews.size() > 0)
+ List<ChimeraViewFrame> existingViews = getChimeraWindowsFor(ap);
+ for (ChimeraViewFrame topView : existingViews)
{
- Enumeration jm = existingViews.elements();
- while (jm.hasMoreElements())
+ // TODO: highlight topView in view somehow
+ int option = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
+ MessageManager.formatMessage("label.add_pdbentry_to_view",
+ new Object[]
+ { pdbentry.getId(), topView.getTitle() }),
+ MessageManager
+ .getString("label.align_to_existing_structure_view"),
+ JOptionPane.YES_NO_CANCEL_OPTION);
+ if (option == JOptionPane.CANCEL_OPTION)
{
- ChimeraViewFrame topJmol = (ChimeraViewFrame) jm.nextElement();
- // TODO: highlight topJmol in view somehow
- int option = JOptionPane
- .showInternalConfirmDialog(
- Desktop.desktop,
- MessageManager.formatMessage(
- "label.add_pdbentry_to_view", new String[]
- { pdbentry.getId(), topJmol.getTitle() }),
- MessageManager
- .getString("label.align_to_existing_structure_view"),
- JOptionPane.YES_NO_OPTION);
- if (option == JOptionPane.YES_OPTION)
- {
- topJmol.useAlignmentPanelForSuperposition(ap);
- topJmol.addStructure(pdbentry, seq, chains, true, ap.alignFrame);
- return;
- }
+ return;
+ }
+ if (option == JOptionPane.YES_OPTION)
+ {
+ topView.useAlignmentPanelForSuperposition(ap);
+ topView.addStructure(pdbentry, seq, chains, true, ap.alignFrame);
+ return;
}
}
// /////////////////////////////////
- openNewJmol(ap, new PDBEntry[]
+ openNewChimera(ap, new PDBEntry[]
{ pdbentry }, new SequenceI[][]
{ seq });
}
- private void openNewJmol(AlignmentPanel ap, PDBEntry[] pdbentrys,
+ private void openNewChimera(AlignmentPanel ap, PDBEntry[] pdbentrys,
SequenceI[][] seqs)
{
progressBar = ap.alignFrame;
}
/**
- * create a new Jmol containing several structures superimposed using the
+ * create a new viewer containing several structures superimposed using the
* given alignPanel.
*
* @param ap
public ChimeraViewFrame(AlignmentPanel ap, PDBEntry[] pe,
SequenceI[][] seqs)
{
- openNewJmol(ap, pe, seqs);
+ super();
+ openNewChimera(ap, pe, seqs);
}
- /**
- * list of sequenceSet ids associated with the view
- */
- ArrayList<String> _aps = new ArrayList();
-
public AlignmentPanel[] getAllAlignmentPanels()
{
AlignmentPanel[] t, list = new AlignmentPanel[0];
}
/**
- * list of alignment panels to use for superposition
- */
- Vector<AlignmentPanel> _alignwith = new Vector<AlignmentPanel>();
-
- /**
- * list of alignment panels that are used for colouring structures by aligned
- * sequences
- */
- Vector<AlignmentPanel> _colourwith = new Vector<AlignmentPanel>();
-
- /**
* set the primary alignmentPanel reference and add another alignPanel to the
* list of ones to use for colouring and aligning
*
useAlignmentPanelForColourbyseq(nap);
jmb.setColourBySequence(enableColourBySeq);
seqColour.setSelected(enableColourBySeq);
- jmolColour.setSelected(!enableColourBySeq);
+ viewerColour.setSelected(!enableColourBySeq);
}
public void useAlignmentPanelForColourbyseq(AlignmentPanel nap)
}
/**
- * pdb retrieval thread.
- */
- private Thread worker = null;
-
- /**
* add a new structure (with associated sequences and chains) to this viewer,
* retrieving it if necessary first.
*
return;
}
- private Vector getJmolsFor(AlignmentPanel ap2)
+ private List<ChimeraViewFrame> getChimeraWindowsFor(AlignmentPanel apanel)
{
- Vector otherJmols = new Vector();
- // Now this AppJmol is mapped to new sequences. We must add them to
- // the exisiting array
+ List<ChimeraViewFrame> result = new ArrayList<ChimeraViewFrame>();
JInternalFrame[] frames = Desktop.instance.getAllFrames();
- for (int i = 0; i < frames.length; i++)
+ for (JInternalFrame frame : frames)
{
- if (frames[i] instanceof ChimeraViewFrame)
+ if (frame instanceof ChimeraViewFrame)
{
- ChimeraViewFrame topJmol = ((ChimeraViewFrame) frames[i]);
- if (topJmol.isLinkedWith(ap2))
+ if (((ChimeraViewFrame) frame).isLinkedWith(apanel))
{
- otherJmols.addElement(topJmol);
+ result.add((ChimeraViewFrame) frame);
}
}
}
- return otherJmols;
+ return result;
}
void initChimera(String command)
jmb.setFinishedInit(false);
// TODO: consider waiting until the structure/view is fully loaded before
// displaying
- jalview.gui.Desktop.addInternalFrame(this, jmb.getViewerTitle(),
+ jalview.gui.Desktop.addInternalFrame(this, jmb.getViewerTitle(true),
getBounds().width, getBounds().height);
if (command == null)
{
jmb.setFinishedInit(true);
}
- void setChainMenuItems(Vector chains)
+ void setChainMenuItems(List<String> chainNames)
{
chainMenu.removeAll();
- if (chains == null)
+ if (chainNames == null)
{
return;
}
for (int i = 0; i < chainMenu.getItemCount(); i++)
{
if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
+ {
((JCheckBoxMenuItem) chainMenu.getItem(i)).setSelected(true);
+ }
}
centerViewer();
allChainsSelected = false;
chainMenu.add(menuItem);
- for (int c = 0; c < chains.size(); c++)
+ for (String chainName : chainNames)
{
- menuItem = new JCheckBoxMenuItem(chains.elementAt(c).toString(), true);
+ menuItem = new JCheckBoxMenuItem(chainName, true);
menuItem.addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent evt)
{
if (!allChainsSelected)
+ {
centerViewer();
+ }
}
});
}
}
- boolean allChainsSelected = false;
-
- private boolean alignAddedStructures = false;
-
void centerViewer()
{
- Vector toshow = new Vector();
- String lbl;
- int mlength, p, mnum;
+ List<String> toshow = new ArrayList<String>();
for (int i = 0; i < chainMenu.getItemCount(); i++)
{
if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
JCheckBoxMenuItem item = (JCheckBoxMenuItem) chainMenu.getItem(i);
if (item.isSelected())
{
- toshow.addElement(item.getText());
+ toshow.add(item.getText());
}
}
}
jmb.centerViewer(toshow);
}
+ /**
+ * Close down this instance of Jalview's Chimera viewer, giving the user the
+ * option to close the associated Chimera window (process). They may wish to
+ * keep it open until they have had an opportunity to save any work.
+ */
public void closeViewer()
{
- jmb.closeViewer();
+ if (jmb.isChimeraRunning())
+ {
+ String prompt = MessageManager
+ .formatMessage("label.confirm_close_chimera", new Object[]
+ { jmb.getViewerTitle(false) });
+ prompt = JvSwingUtils.wrapTooltip(true, prompt);
+ int confirm = JOptionPane.showConfirmDialog(this, prompt,
+ MessageManager.getString("label.close_viewer"),
+ JOptionPane.YES_NO_OPTION);
+ jmb.closeViewer(confirm == JOptionPane.YES_OPTION);
+ }
ap = null;
_aps.clear();
_alignwith.clear();
}
/**
- * state flag for PDB retrieval thread
+ * Open any newly added PDB structures in Chimera, having first fetched data
+ * from PDB (if not already saved).
*/
- private boolean _started = false;
-
public void run()
{
_started = true;
- String pdbid = "";
- // todo - record which pdbids were successfuly imported.
- StringBuffer errormsgs = new StringBuffer(), files = new StringBuffer();
- List<String> fileToLoad=new ArrayList<String>();
+ // todo - record which pdbids were successfully imported.
+ StringBuilder errormsgs = new StringBuilder(128);
+ StringBuilder files = new StringBuilder(128);
List<PDBEntry> filePDB = new ArrayList<PDBEntry>();
- List<Integer> filePDBpos =new ArrayList<Integer>();
+ List<Integer> filePDBpos = new ArrayList<Integer>();
+ PDBEntry thePdbEntry = null;
try
{
String[] curfiles = jmb.getPdbFile(); // files currently in viewer
// TODO: replace with reference fetching/transfer code (validate PDBentry
// as a DBRef?)
- jalview.ws.dbsources.Pdb pdbclient = new jalview.ws.dbsources.Pdb();
for (int pi = 0; pi < jmb.pdbentry.length; pi++)
{
String file = null;
- if (jmb.pdbentry[pi].getFile()==null)
+ thePdbEntry = jmb.pdbentry[pi];
+ if (thePdbEntry.getFile() == null)
{
- // retrieve the pdb and store it locally
- AlignmentI pdbseq = null;
- pdbid = jmb.pdbentry[pi].getId();
- long hdl = pdbid.hashCode() - System.currentTimeMillis();
- if (progressBar != null)
+ /*
+ * Retrieve PDB data, save to file, attach to PDBEntry
+ */
+ file = fetchPdbFile(thePdbEntry);
+ if (file == null)
{
- progressBar.setProgressBar(MessageManager.formatMessage("status.fetching_pdb", new String[]{pdbid}), hdl);
- }
- try
- {
- pdbseq = pdbclient.getSequenceRecords(pdbid = jmb.pdbentry[pi]
- .getId());
- } catch (OutOfMemoryError oomerror)
- {
- new OOMWarning("Retrieving PDB id " + pdbid, oomerror);
- } catch (Exception ex)
- {
- ex.printStackTrace();
- errormsgs.append("'" + pdbid + "'");
- }
- if (progressBar != null)
- {
- progressBar.setProgressBar(MessageManager.getString("label.state_completed"), hdl);
- }
- if (pdbseq != null)
- {
- // just transfer the file name from the first sequence's first
- // PDBEntry
- file = new File(((PDBEntry) pdbseq.getSequenceAt(0).getPDBId()
- .elementAt(0)).getFile()).getAbsolutePath();
- jmb.pdbentry[pi].setFile(file);
-
- files.append(" \"" + Platform.escapeString(file) + "\"");
- }
- else
- {
- errormsgs.append("'" + pdbid + "' ");
+ errormsgs.append("'" + thePdbEntry.getId() + "' ");
}
}
else
{
- file = new File(jmb.pdbentry[pi].getFile())
- .getAbsoluteFile().getPath();
+ /*
+ * Got file already - ignore if already loaded in Chimera.
+ */
+ file = new File(thePdbEntry.getFile()).getAbsoluteFile()
+ .getPath();
if (curfiles != null && curfiles.length > 0)
{
addingStructures = true; // already files loaded.
}
}
}
-
- if (file != null)
- {
- fileToLoad.add(file);
- filePDB.add(jmb.pdbentry[pi]);
- filePDBpos.add(Integer.valueOf(pi));
- files.append(" \"" + Platform.escapeString(file) + "\"");
- }
+ }
+ if (file != null)
+ {
+ filePDB.add(thePdbEntry);
+ filePDBpos.add(Integer.valueOf(pi));
+ files.append(" \"" + Platform.escapeString(file) + "\"");
}
}
} catch (OutOfMemoryError oomerror)
{
- new OOMWarning("Retrieving PDB files: " + pdbid, oomerror);
+ new OOMWarning("Retrieving PDB files: " + thePdbEntry.getId(),
+ oomerror);
} catch (Exception ex)
{
ex.printStackTrace();
- errormsgs.append("When retrieving pdbfiles : current was: '" + pdbid
- + "'");
+ errormsgs.append("When retrieving pdbfiles for '"
+ + thePdbEntry.getId() + "'");
}
if (errormsgs.length() > 0)
{
JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
.formatMessage("label.pdb_entries_couldnt_be_retrieved",
- new String[]
+ new Object[]
{ errormsgs.toString() }), MessageManager
.getString("label.couldnt_load_file"),
JOptionPane.ERROR_MESSAGE);
-
}
- long lastnotify = jmb.getLoadNotifiesHandled();
+
if (files.length() > 0)
{
if (!addingStructures)
{
Cache.log.error("Couldn't open Chimera viewer!", ex);
}
- }
- int num=-1;
+ }
+ int num = -1;
for (PDBEntry pe : filePDB)
{
num++;
{
try
{
- int pos=filePDBpos.get(num).intValue();
+ int pos = filePDBpos.get(num).intValue();
jmb.openFile(pe);
jmb.addSequence(pos, jmb.sequence[pos]);
- File fl=new File(pe.getFile());
+ File fl = new File(pe.getFile());
String protocol = AppletFormatAdapter.URL;
try
{
if (fl.exists())
- {
- protocol = AppletFormatAdapter.FILE;
- }
- } catch (Exception e)
- {
- } catch (Error e)
{
+ protocol = AppletFormatAdapter.FILE;
}
- // Explicitly map to the filename used by Jmol ;
- jmb.ssm.setMapping(jmb.sequence[pos], null, pe.getFile(),
- protocol);
- // pdbentry[pe].getFile(), protocol);
+ } catch (Throwable e)
+ {
+ }
+ // Explicitly map to the filename used by Chimera ;
+ // TODO: use pe.getId() instead of pe.getFile() ?
+ jmb.ssm.setMapping(jmb.sequence[pos], null, pe.getFile(),
+ protocol);
} catch (OutOfMemoryError oomerror)
{
new OOMWarning(
}
}
}
- // jmb.getPdbFile();
jmb.setFinishedInit(true);
jmb.setLoadingFromArchive(false);
-
+
// refresh the sequence colours for the new structure(s)
for (AlignmentPanel ap : _colourwith)
{
worker = null;
}
+ /**
+ * Fetch PDB data and save to a local file. Returns the full path to the file,
+ * or null if fetch fails.
+ *
+ * @param processingEntry
+ * @return
+ * @throws Exception
+ */
+ private String fetchPdbFile(PDBEntry processingEntry) throws Exception
+ {
+ String filePath = null;
+ Pdb pdbclient = new Pdb();
+ AlignmentI pdbseq = null;
+ String pdbid = processingEntry.getId();
+ long hdl = pdbid.hashCode() - System.currentTimeMillis();
+ if (progressBar != null)
+ {
+ progressBar.setProgressBar(MessageManager.formatMessage(
+ "status.fetching_pdb", new Object[]
+ { pdbid }), hdl);
+ }
+ try
+ {
+ pdbseq = pdbclient.getSequenceRecords(pdbid);
+ } catch (OutOfMemoryError oomerror)
+ {
+ new OOMWarning("Retrieving PDB id " + pdbid, oomerror);
+ } finally
+ {
+ if (progressBar != null)
+ {
+ progressBar.setProgressBar(
+ MessageManager.getString("label.state_completed"), hdl);
+ }
+ }
+ /*
+ * If PDB data were saved and are not invalid (empty alignment), return the
+ * file path.
+ */
+ if (pdbseq != null && pdbseq.getHeight() > 0)
+ {
+ // just use the file name from the first sequence's first PDBEntry
+ filePath = new File(((PDBEntry) pdbseq.getSequenceAt(0).getPDBId()
+ .elementAt(0)).getFile()).getAbsolutePath();
+ processingEntry.setFile(filePath);
+ }
+ return filePath;
+ }
+
+ @Override
public void pdbFile_actionPerformed(ActionEvent actionEvent)
{
JalviewFileChooser chooser = new JalviewFileChooser(
if (value == JalviewFileChooser.APPROVE_OPTION)
{
+ BufferedReader in = null;
try
{
// TODO: cope with multiple PDB files in view
- BufferedReader in = new BufferedReader(new FileReader(
- jmb.getPdbFile()[0]));
+ in = new BufferedReader(new FileReader(jmb.getPdbFile()[0]));
File outFile = chooser.getSelectedFile();
PrintWriter out = new PrintWriter(new FileOutputStream(outFile));
} catch (Exception ex)
{
ex.printStackTrace();
+ } finally
+ {
+ if (in != null)
+ {
+ try
+ {
+ in.close();
+ } catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
}
}
}
+ @Override
public void viewMapping_actionPerformed(ActionEvent actionEvent)
{
jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();
600);
}
- /**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
- */
+ @Override
public void eps_actionPerformed(ActionEvent e)
{
- throw new Error(MessageManager.getString("error.eps_generation_not_implemented"));
+ throw new Error(
+ MessageManager
+ .getString("error.eps_generation_not_implemented"));
}
- /**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
- */
+ @Override
public void png_actionPerformed(ActionEvent e)
{
- throw new Error(MessageManager.getString("error.png_generation_not_implemented"));
+ throw new Error(
+ MessageManager
+ .getString("error.png_generation_not_implemented"));
}
- public void jmolColour_actionPerformed(ActionEvent actionEvent)
+ @Override
+ public void viewerColour_actionPerformed(ActionEvent actionEvent)
{
- if (jmolColour.isSelected())
+ if (viewerColour.isSelected())
{
// disable automatic sequence colouring.
jmb.setColourBySequence(false);
}
}
+ @Override
public void seqColour_actionPerformed(ActionEvent actionEvent)
{
jmb.setColourBySequence(seqColour.isSelected());
}
}
+ @Override
public void chainColour_actionPerformed(ActionEvent actionEvent)
{
chainColour.setSelected(true);
jmb.colourByChain();
}
+ @Override
public void chargeColour_actionPerformed(ActionEvent actionEvent)
{
chargeColour.setSelected(true);
jmb.colourByCharge();
}
+ @Override
public void zappoColour_actionPerformed(ActionEvent actionEvent)
{
zappoColour.setSelected(true);
jmb.setJalviewColourScheme(new ZappoColourScheme());
}
+ @Override
public void taylorColour_actionPerformed(ActionEvent actionEvent)
{
taylorColour.setSelected(true);
jmb.setJalviewColourScheme(new TaylorColourScheme());
}
+ @Override
public void hydroColour_actionPerformed(ActionEvent actionEvent)
{
hydroColour.setSelected(true);
jmb.setJalviewColourScheme(new HydrophobicColourScheme());
}
+ @Override
public void helixColour_actionPerformed(ActionEvent actionEvent)
{
helixColour.setSelected(true);
jmb.setJalviewColourScheme(new HelixColourScheme());
}
+ @Override
public void strandColour_actionPerformed(ActionEvent actionEvent)
{
strandColour.setSelected(true);
jmb.setJalviewColourScheme(new StrandColourScheme());
}
+ @Override
public void turnColour_actionPerformed(ActionEvent actionEvent)
{
turnColour.setSelected(true);
jmb.setJalviewColourScheme(new TurnColourScheme());
}
+ @Override
public void buriedColour_actionPerformed(ActionEvent actionEvent)
{
buriedColour.setSelected(true);
jmb.setJalviewColourScheme(new BuriedColourScheme());
}
+ @Override
public void purinePyrimidineColour_actionPerformed(ActionEvent actionEvent)
{
setJalviewColourScheme(new PurinePyrimidineColourScheme());
}
+ @Override
public void userColour_actionPerformed(ActionEvent actionEvent)
{
userColour.setSelected(true);
new UserDefinedColours(this, null);
}
+ @Override
public void backGround_actionPerformed(ActionEvent actionEvent)
{
- java.awt.Color col = JColorChooser.showDialog(this,
- MessageManager.getString("label.select_backgroud_colour"), null);
+ java.awt.Color col = JColorChooser
+ .showDialog(this, MessageManager
+ .getString("label.select_backgroud_colour"), null);
if (col != null)
{
jmb.setBackgroundColour(col);
}
}
- public void jmolHelp_actionPerformed(ActionEvent actionEvent)
+ @Override
+ public void showHelp_actionPerformed(ActionEvent actionEvent)
{
try
{
}
}
- String viewId = null;
-
public String getViewId()
{
if (viewId == null)
}
setChainMenuItems(jmb.chainNames);
- this.setTitle(jmb.getViewerTitle());
+ this.setTitle(jmb.getViewerTitle(true));
if (jmb.getPdbFile().length > 1 && jmb.sequence.length > 1)
{
- jmolActionMenu.setVisible(true);
+ viewerActionMenu.setVisible(true);
}
if (!jmb.isLoadingFromArchive())
{
_alignwith.add(ap);
}
;
- for (Component c : jmolActionMenu.getMenuComponents())
+ for (Component c : viewerActionMenu.getMenuComponents())
{
if (c != alignStructs)
{
- jmolActionMenu.remove((JMenuItem) c);
+ viewerActionMenu.remove((JMenuItem) c);
}
}
- final ItemListener handler;
}
/*
/**
*
* @param ap2
- * @return true if this Jmol instance is linked with the given alignPanel
+ * @return true if this Chimera instance is linked with the given alignPanel
*/
public boolean isLinkedWith(AlignmentPanel ap2)
{
*
* @return TRUE if the view is NOT being coloured by sequence associations.
*/
- public boolean isColouredByJmol()
+ public boolean isColouredByChimera()
{
return !jmb.isColourBySequence();
}
if (showMemoryUsage && g != null && df != null)
{
if (percentUsage < 20)
+ {
g.setColor(Color.red);
+ }
FontMetrics fm = g.getFontMetrics();
if (fm != null)
{
{
invalidate();
File of;
- ImageMaker im = new jalview.util.ImageMaker(this, ImageMaker.EPS, "View of Desktop", getWidth(), getHeight(), of=new File("Jalview_snapshot"+System.currentTimeMillis()+".eps"), "View of desktop");
+ ImageMaker im = new jalview.util.ImageMaker(this, ImageMaker.TYPE.EPS,
+ "View of Desktop", getWidth(), getHeight(), of = new File(
+ "Jalview_snapshot" + System.currentTimeMillis()
+ + ".eps"), "View of desktop");
try {
paintAll(im.getGraphics());
im.writeImage();
AlignmentPanel ap = (AlignmentPanel) source, topap;
// ignore events from panels not used to colour this view
if (!cvf.isUsedforcolourby(ap))
+ {
return;
+ }
if (!isLoadingFromArchive())
{
colourBySequence(ap.av.getShowSequenceFeatures(), ap);
// TODO Auto-generated method stub
}
-
- @Override
- public void showUrl(String url, String target)
- {
- // TODO Auto-generated method stub
-
- }
}
*/
package jalview.gui;
-import java.util.*;
-import java.awt.*;
-import java.awt.event.*;
-import java.awt.print.*;
-
-import javax.swing.*;
-
-import jalview.datamodel.*;
-import jalview.jbgui.*;
+import jalview.datamodel.Alignment;
+import jalview.datamodel.AlignmentView;
+import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.SeqCigar;
+import jalview.datamodel.SequenceI;
+import jalview.jbgui.GPCAPanel;
import jalview.schemes.ResidueProperties;
import jalview.util.MessageManager;
import jalview.viewmodel.PCAModel;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.print.PageFormat;
+import java.awt.print.Printable;
+import java.awt.print.PrinterException;
+import java.awt.print.PrinterJob;
+import java.util.Hashtable;
+
+import javax.swing.ButtonGroup;
+import javax.swing.JButton;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JColorChooser;
+import javax.swing.JLabel;
+import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JProgressBar;
+import javax.swing.JRadioButtonMenuItem;
+
/**
* DOCUMENT ME!
*
@Override
public void actionPerformed(ActionEvent e)
{
- if (!pcaModel.getScore_matrix().equals((String) sm))
+ if (!pcaModel.getScore_matrix().equals(sm))
{
- pcaModel.setScore_matrix((String) sm);
+ pcaModel.setScore_matrix(sm);
Thread worker = new Thread(us);
worker.start();
}
*/
public void eps_actionPerformed(ActionEvent e)
{
- makePCAImage(jalview.util.ImageMaker.EPS);
+ makePCAImage(jalview.util.ImageMaker.TYPE.EPS);
}
/**
*/
public void png_actionPerformed(ActionEvent e)
{
- makePCAImage(jalview.util.ImageMaker.PNG);
+ makePCAImage(jalview.util.ImageMaker.TYPE.PNG);
}
- void makePCAImage(int type)
+ void makePCAImage(jalview.util.ImageMaker.TYPE type)
{
int width = rc.getWidth();
int height = rc.getHeight();
jalview.util.ImageMaker im;
- if (type == jalview.util.ImageMaker.PNG)
+ if (type == jalview.util.ImageMaker.TYPE.PNG)
{
- im = new jalview.util.ImageMaker(this, jalview.util.ImageMaker.PNG,
+ im = new jalview.util.ImageMaker(this,
+ jalview.util.ImageMaker.TYPE.PNG,
"Make PNG image from PCA", width, height, null, null);
}
- else
+ else if (type == jalview.util.ImageMaker.TYPE.EPS)
{
- im = new jalview.util.ImageMaker(this, jalview.util.ImageMaker.EPS,
+ im = new jalview.util.ImageMaker(this,
+ jalview.util.ImageMaker.TYPE.EPS,
"Make EPS file from PCA", width, height, null,
this.getTitle());
}
+ else
+ {
+ im = new jalview.util.ImageMaker(this,
+ jalview.util.ImageMaker.TYPE.SVG, "Make SVG file from PCA",
+ width, height, null, this.getTitle());
+
+ }
if (im.getGraphics() != null)
{
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
+import java.io.File;
import java.util.Collection;
import java.util.StringTokenizer;
import java.util.Vector;
public static final String STRUCTURE_DISPLAY = "STRUCTURE_DISPLAY";
+ public static final String CHIMERA_PATH = "CHIMERA_PATH";
+
public static final String SORT_ANNOTATIONS = "SORT_ANNOTATIONS";
public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE";
addTempFactor.setEnabled(structSelected);
structViewer.setSelectedItem(Cache.getDefault(STRUCTURE_DISPLAY,
Viewer.JMOL.name()));
+ chimeraPath.setText(Cache.getDefault(CHIMERA_PATH, ""));
+ chimeraPath.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ if (chimeraPath.getText().trim().length() > 0)
+ {
+ File f = new File(chimeraPath.getText());
+ if (!f.canExecute())
+ {
+ JOptionPane.showInternalMessageDialog(Desktop.desktop,
+ MessageManager.getString("label.invalid_path"),
+ MessageManager.getString("label.invalid_name"),
+ JOptionPane.ERROR_MESSAGE);
+ }
+ }
+ }
+ });
/*
* Set Connections tab defaults
Boolean.toString(structFromPdb.isSelected()));
Cache.applicationProperties.setProperty(STRUCTURE_DISPLAY, structViewer
.getSelectedItem().toString());
+ Cache.setOrRemove(CHIMERA_PATH, chimeraPath.getText());
/*
* Save Output settings
/*
* Save Connections settings
*/
- if (defaultBrowser.getText().trim().length() < 1)
- {
- Cache.applicationProperties.remove("DEFAULT_BROWSER");
- }
- else
- {
- Cache.applicationProperties.setProperty("DEFAULT_BROWSER",
- defaultBrowser.getText());
- }
+ Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText());
jalview.util.BrowserLauncher.resetBrowser();
Cache.applicationProperties.setProperty("USE_PROXY",
Boolean.toString(useProxy.isSelected()));
- if (proxyServerTB.getText().trim().length() < 1)
- {
- Cache.applicationProperties.remove("PROXY_SERVER");
- }
- else
- {
- Cache.applicationProperties.setProperty("PROXY_SERVER",
- proxyServerTB.getText());
- }
+ Cache.setOrRemove("PROXY_SERVER", proxyServerTB.getText());
- if (proxyPortTB.getText().trim().length() < 1)
- {
- Cache.applicationProperties.remove("PROXY_PORT");
- }
- else
- {
- Cache.applicationProperties.setProperty("PROXY_PORT",
- proxyPortTB.getText());
- }
+ Cache.setOrRemove("PROXY_PORT", proxyPortTB.getText());
if (useProxy.isSelected())
{
return viewStructures(getViewerType(), ap, pdb, sequenceIs);
}
- public JalviewStructureDisplayI createView(Viewer jmol, String[] pdbf,
+ public JalviewStructureDisplayI createView(Viewer viewer, String[] pdbf,
String[] id, SequenceI[][] sq, AlignmentPanel alignPanel,
boolean useinJmolsuperpos, boolean usetoColourbyseq,
boolean jmolColouring, String fileloc, Rectangle rect, String vid)
{
JalviewStructureDisplayI sview = null;
- switch (getViewerType())
+ switch (viewer)
{
case JMOL:
-
sview = new AppJmol(pdbf, id, sq, alignPanel, useinJmolsuperpos,
usetoColourbyseq, jmolColouring, fileloc, rect, vid);
-
break;
case CHIMERA:
+ Cache.log.error("Unsupported structure viewer type "
+ + viewer.toString());
break;
default:
- Cache.log.error("Unknown structure viewer type "
- + getViewerType().toString());
+ Cache.log.error("Unknown structure viewer type " + viewer.toString());
}
return sview;
}
JMenuItem createBioJS = new JMenuItem();
+ JMenuItem createSVG = new JMenuItem();
+
protected JMenuItem font = new JMenuItem();
public JCheckBoxMenuItem seqLimits = new JCheckBoxMenuItem();
createPNG.setActionCommand(MessageManager
.getString("label.save_png_image"));
createPNG.setText("PNG");
+
font.setText(MessageManager.getString("action.font"));
font.addActionListener(new java.awt.event.ActionListener()
{
createEPS(null);
}
});
+
+ createSVG.setText("SVG");
+ createSVG.addActionListener(new java.awt.event.ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ createSVG(null);
+ }
+ });
+
LoadtreeMenuItem.setActionCommand(MessageManager
.getString("label.load_tree_for_sequence_set"));
LoadtreeMenuItem.setText(MessageManager
jMenu2.add(epsFile);
jMenu2.add(createPNG);
jMenu2.add(createBioJS);
+ jMenu2.add(createSVG);
addSequenceMenu.add(addFromFile);
addSequenceMenu.add(addFromText);
addSequenceMenu.add(addFromURL);
{
}
+ public void createSVG(java.io.File f)
+ {
+
+ }
protected void LoadtreeMenuItem_actionPerformed(ActionEvent e)
{
protected JComboBox<String> structViewer = new JComboBox<String>();
+ protected JTextField chimeraPath = new JTextField();
+
/*
* Colours tab components
*/
structureTab.add(viewerLabel);
structViewer.setFont(verdana11);
- structViewer.setBounds(new Rectangle(150, ypos, 120, height));
+ structViewer.setBounds(new Rectangle(160, ypos, 120, height));
structViewer.addItem(Viewer.JMOL.name());
structViewer.addItem(Viewer.CHIMERA.name());
structureTab.add(structViewer);
+ ypos += lineSpacing;
+ JLabel pathLabel = new JLabel();
+ pathLabel.setFont(new java.awt.Font("SansSerif", 0, 11));
+ pathLabel.setHorizontalAlignment(SwingConstants.LEFT);
+ pathLabel.setText(MessageManager.getString("label.chimera_path"));
+ pathLabel.setToolTipText(MessageManager
+ .getString("label.chimera_path_tip"));
+ pathLabel.setBounds(new Rectangle(10, ypos, 140, height));
+ structureTab.add(pathLabel);
+
+ chimeraPath.setFont(verdana11);
+ chimeraPath.setText("");
+ chimeraPath.setBounds(new Rectangle(160, ypos, 300, height));
+ structureTab.add(chimeraPath);
+
return structureTab;
}
import jalview.util.MessageManager;
-import javax.swing.*;
-import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.ButtonGroup;
+import javax.swing.JInternalFrame;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.JRadioButtonMenuItem;
public class GStructureViewer extends JInternalFrame
{
userColour_actionPerformed(actionEvent);
}
});
- jmolColour.setSelected(false);
- jmolColour.setText(MessageManager.getString("label.colour_with_jmol"));
- jmolColour.setToolTipText(MessageManager
+ viewerColour.setSelected(false);
+ viewerColour
+ .setText(MessageManager.getString("label.colour_with_jmol"));
+ viewerColour.setToolTipText(MessageManager
.getString("label.let_jmol_manage_structure_colours"));
- jmolColour.addActionListener(new ActionListener()
+ viewerColour.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent actionEvent)
{
- jmolColour_actionPerformed(actionEvent);
+ viewerColour_actionPerformed(actionEvent);
}
});
helpMenu.setText(MessageManager.getString("action.help"));
- jmolHelp.setText(MessageManager.getString("label.jmol_help"));
- jmolHelp.addActionListener(new ActionListener()
+ helpItem.setText(MessageManager.getString("label.jmol_help"));
+ helpItem.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent actionEvent)
{
- jmolHelp_actionPerformed(actionEvent);
+ showHelp_actionPerformed(actionEvent);
}
});
alignStructs
alignStructs_actionPerformed(actionEvent);
}
});
- jmolActionMenu.setText(MessageManager.getString("label.jmol"));
+ viewerActionMenu.setText(MessageManager.getString("label.jmol"));
menuBar.add(fileMenu);
menuBar.add(viewMenu);
menuBar.add(colourMenu);
- menuBar.add(jmolActionMenu);
- jmolActionMenu.setVisible(false);
+ menuBar.add(viewerActionMenu);
+ viewerActionMenu.setVisible(false);
menuBar.add(helpMenu);
fileMenu.add(savemenu);
fileMenu.add(viewMapping);
colourMenu.add(buriedColour);
colourMenu.add(purinePyrimidineColour);
colourMenu.add(userColour);
- colourMenu.add(jmolColour);
+ colourMenu.add(viewerColour);
colourMenu.add(backGround);
colourButtons.add(seqColour);
colourButtons.add(turnColour);
colourButtons.add(buriedColour);
colourButtons.add(userColour);
- colourButtons.add(jmolColour);
+ colourButtons.add(viewerColour);
- helpMenu.add(jmolHelp);
- jmolActionMenu.add(alignStructs);
+ helpMenu.add(helpItem);
+ viewerActionMenu.add(alignStructs);
}
- protected void jmolColour_actionPerformed(ActionEvent actionEvent)
+ protected void viewerColour_actionPerformed(ActionEvent actionEvent)
{
}
JMenu fileMenu = new JMenu();
- JMenu savemenu = new JMenu();
+ protected JMenu savemenu = new JMenu();
JMenuItem pdbFile = new JMenuItem();
protected JMenu colourMenu = new JMenu();
- protected JMenu jmolActionMenu = new JMenu();
+ protected JMenu viewerActionMenu = new JMenu();
protected JMenuItem alignStructs = new JMenuItem();
protected JRadioButtonMenuItem userColour = new JRadioButtonMenuItem();
- protected JRadioButtonMenuItem jmolColour = new JRadioButtonMenuItem();
+ protected JRadioButtonMenuItem viewerColour = new JRadioButtonMenuItem();
protected ButtonGroup colourButtons = new ButtonGroup();
JMenu helpMenu = new JMenu();
- JMenuItem jmolHelp = new JMenuItem();
+ protected JMenuItem helpItem = new JMenuItem();
public void pdbFile_actionPerformed(ActionEvent actionEvent)
{
}
- public void jmolHelp_actionPerformed(ActionEvent actionEvent)
+ public void showHelp_actionPerformed(ActionEvent actionEvent)
{
}
*/
package jalview.util;
-import java.io.*;
-import javax.imageio.*;
+import jalview.gui.EPSOptions;
+import jalview.io.JalviewFileChooser;
-import java.awt.*;
-import java.awt.image.*;
+import java.awt.Component;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.FileOutputStream;
-import org.jibble.epsgraphics.*;
-import jalview.gui.*;
-import jalview.io.*;
+import javax.imageio.ImageIO;
+
+import org.jfree.graphics2d.svg.SVGGraphics2D;
+import org.jibble.epsgraphics.EpsGraphics2D;
public class ImageMaker
{
- public static final int EPS = 0;
-
- public static final int PNG = 1;
-
- int type = -1;
-
EpsGraphics2D pg;
+ SVGGraphics2D g2;
+
Graphics graphics;
FileOutputStream out;
BufferedImage bi;
- public ImageMaker(Component parent, int type, String title, int width,
- int height, File file, String EPStitle)
+ TYPE type;
+
+ public enum TYPE
+ {
+ EPS("EPS", MessageManager.getString("label.eps_file"), getEPSChooser()), PNG(
+ "PNG", MessageManager.getString("label.png_image"),
+ getPNGChooser()), SVG("SVG", "SVG", getSVGChooser());
+
+ private JalviewFileChooser chooser;
+
+ private String name;
+
+ private String label;
+
+ TYPE(String name, String label, JalviewFileChooser chooser)
+ {
+ this.name = name;
+ this.label = label;
+ this.chooser = chooser;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public JalviewFileChooser getChooser()
+ {
+ return chooser;
+ }
+
+ public String getLabel()
+ {
+ return label;
+ }
+
+ }
+
+
+ public ImageMaker(Component parent, TYPE type, String title, int width,
+ int height, File file, String fileTitle)
{
this.type = type;
if (file == null)
{
JalviewFileChooser chooser;
- chooser = type == EPS ? getEPSChooser() : getPNGChooser();
-
+ chooser = type.getChooser();
chooser.setFileView(new jalview.io.JalviewFileView());
chooser.setDialogTitle(title);
chooser.setToolTipText(MessageManager.getString("action.save"));
-
int value = chooser.showSaveDialog(parent);
if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
{
jalview.bin.Cache.setProperty("LAST_DIRECTORY", chooser
.getSelectedFile().getParent());
-
file = chooser.getSelectedFile();
}
}
try
{
out = new FileOutputStream(file);
-
- if (type == EPS)
+ if (type == TYPE.SVG)
{
- setupEPS(width, height, EPStitle);
+ setupSVG(width, height, fileTitle);
}
- else
+ else if (type == TYPE.EPS)
+ {
+ setupEPS(width, height, fileTitle);
+ }
+ else if (type == TYPE.PNG)
{
setupPNG(width, height);
}
+
} catch (Exception ex)
{
System.out.println("Error creating "
- + (type == EPS ? "EPS" : "PNG") + " file.");
+ + type.getName() + " file.");
}
}
}
return graphics;
}
- void setupPNG(int width, int height)
- {
- bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
- graphics = bi.getGraphics();
- Graphics2D ig2 = (Graphics2D) graphics;
- ig2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON);
- }
+
public void writeImage()
{
pg.flush();
pg.close();
break;
+ case SVG:
+ String svgData = ((SVGGraphics2D) getGraphics()).getSVGDocument();
+ out.write(svgData.getBytes());
+ out.flush();
+ out.close();
+ break;
case PNG:
ImageIO.write(bi, "png", out);
+ out.flush();
out.close();
break;
}
try
{
pg = new EpsGraphics2D(title, out, 0, 0, width, height);
- Graphics2D ig2 = (Graphics2D) pg;
+ Graphics2D ig2 = pg;
ig2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
}
}
- JalviewFileChooser getPNGChooser()
+ void setupPNG(int width, int height)
+ {
+ bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+ graphics = bi.getGraphics();
+ Graphics2D ig2 = (Graphics2D) graphics;
+ ig2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_ON);
+ }
+
+ void setupSVG(int width, int height, String title)
+ {
+ g2 = new SVGGraphics2D(width, height);
+ graphics = g2;
+ }
+
+ static JalviewFileChooser getPNGChooser()
{
return new jalview.io.JalviewFileChooser(
jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[]
{ "Portable network graphics" }, "Portable network graphics");
}
- JalviewFileChooser getEPSChooser()
+ static JalviewFileChooser getEPSChooser()
{
return new jalview.io.JalviewFileChooser(
jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[]
{ "eps" }, new String[]
{ "Encapsulated Postscript" }, "Encapsulated Postscript");
}
+
+ static JalviewFileChooser getSVGChooser()
+ {
+ return new jalview.io.JalviewFileChooser(
+ jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[]
+ { "svg" }, new String[]
+ { "Scalable Vector Graphics" }, "Scalable Vector Graphics");
+ }
}
</property>
</object>
</method>
+ <method name="addElement">
+ <object class="com.zerog.ia.installer.actions.InstallZipfile" objectID="1f46cffffab93">
+ <property name="belongsToUninstallPhase">
+ <boolean>false</boolean>
+ </property>
+ <property name="rollbackEnabledCancel">
+ <boolean>true</boolean>
+ </property>
+ <property name="rollbackEnabledError">
+ <boolean>true</boolean>
+ </property>
+ <property name="ruleExpression">
+ <string><![CDATA[]]></string>
+ </property>
+ <property name="unixPermissions">
+ <string><![CDATA[664]]></string>
+ </property>
+ <property name="sourceName">
+ <string><![CDATA[jfreesvg-2.1.jar]]></string>
+ </property>
+ <property name="overrideUnixPermissions">
+ <boolean>false</boolean>
+ </property>
+ <property name="sourcePath">
+ <string><![CDATA[/home/cruisecontrol/jalview/lib/]]></string>
+ </property>
+ <property name="shouldUninstall">
+ <boolean>true</boolean>
+ </property>
+ <property name="rollbackEnabledCancel">
+ <boolean>true</boolean>
+ </property>
+ <property name="rollbackEnabledError">
+ <boolean>true</boolean>
+ </property>
+ <property name="destinationName">
+ <string><![CDATA[jfreesvg-2.1.jar]]></string>
+ </property>
+ <property name="fileSize">
+ <long>382442</long>
+ </property>
+ <property name="macBinary">
+ <boolean>false</boolean>
+ </property>
+ <property name="targetCheckKind">
+ <int>0</int>
+ </property>
+ <property name="ruleExpression">
+ <string><![CDATA[]]></string>
+ </property>
+ </object>
+ </method>
</object>
</property>
<property name="rulesFailedMessage">
<object refID="f44ca391ab9f"/>
<object refID="f44ca392ab9f"/>
<object refID="f44ca393ab9f"/>
+ <object refID=""1f46cffffab93"/>
<object class="com.zerog.ia.installer.actions.InstallFile" objectID="f44fc5b2aba1">
<property name="belongsToUninstallPhase">
<boolean>false</boolean>
<object refID="f44ca392ab9f"/>
<object refID="f44ca393ab9f"/>
<object refID="f46c2f42ab93"/>
+ <object refID="1f46cffffab93"/>
</visualChildren>
</object>
<object class="com.zerog.ia.installer.actions.InstallDirectory" objectID="f44fc5d5aba1">