- private void viewerCommandHistory(boolean enable)
- {
- // log("(Not yet implemented) History "
- // + ((debug || enable) ? "on" : "off"));
- }
-
- public long getLoadNotifiesHandled()
- {
- return loadNotifiesHandled;
- }
-
- @Override
- public void setJalviewColourScheme(ColourSchemeI cs)
- {
- colourBySequence = false;
-
- if (cs == null)
- {
- return;
- }
-
- // Chimera expects RBG values in the range 0-1
- final double normalise = 255D;
- viewerCommandHistory(false);
- StringBuilder command = new StringBuilder(128);
-
- List<String> residueSet = ResidueProperties.getResidues(isNucleotide(),
- false);
- for (String resName : residueSet)
- {
- char res = resName.length() == 3
- ? ResidueProperties.getSingleCharacterCode(resName)
- : resName.charAt(0);
- Color col = cs.findColour(res, 0, null, null, 0f);
- command.append("color " + col.getRed() / normalise + ","
- + col.getGreen() / normalise + "," + col.getBlue() / normalise
- + " ::" + resName + ";");
- }
-
- sendAsynchronousCommand(command.toString(), COLOURING_CHIMERA);
- viewerCommandHistory(true);
- }
-
- /**
- * 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 occurred.
- */
- public abstract void refreshGUI();
-
- @Override
- public void setLoadingFromArchive(boolean loadingFromArchive)
- {
- this.loadingFromArchive = loadingFromArchive;
- }
-
- /**
- *
- * @return true if Chimeral is still restoring state or loading is still going
- * on (see setFinsihedLoadingFromArchive)
- */
- @Override
- public boolean isLoadingFromArchive()
- {
- return loadingFromArchive && !loadingFinished;
- }
-
- /**
- * modify flag which controls if sequence colouring events are honoured by the
- * binding. Should be true for normal operation
- *
- * @param finishedLoading
- */
- @Override
- public void setFinishedLoadingFromArchive(boolean finishedLoading)
- {
- loadingFinished = finishedLoading;
- }
-
- /**
- * Send the Chimera 'background solid <color>" command.
- *
- * @see https
- * ://www.cgl.ucsf.edu/chimera/current/docs/UsersGuide/midas/background
- * .html
- * @param col
- */
- @Override
- public void setBackgroundColour(Color col)
- {
- viewerCommandHistory(false);
- double normalise = 255D;
- final String command = "background solid " + col.getRed() / normalise
- + "," + col.getGreen() / normalise + ","
- + col.getBlue() / normalise + ";";
- viewer.sendChimeraCommand(command, false);
- viewerCommandHistory(true);
- }
-
- /**
- * Ask Chimera to save its session to the given file. Returns true if
- * successful, else false.
- *
- * @param filepath
- * @return
- */
- public boolean saveSession(String filepath)
- {
- if (isChimeraRunning())
- {
- List<String> reply = viewer.sendChimeraCommand("save " + filepath,
- true);
- if (reply.contains("Session written"))
- {
- return true;
- }
- else
- {
- Cache.log
- .error("Error saving Chimera session: " + reply.toString());
- }
- }
- return false;
- }
-
- /**
- * Ask Chimera to open a session file. Returns true if successful, else false.
- * The filename must have a .py extension for this command to work.
- *
- * @param filepath
- * @return
- */
- public boolean openSession(String filepath)
- {
- sendChimeraCommand("open " + filepath, true);
- // todo: test for failure - how?
- return true;
- }
-
- /**
- * Returns a list of chains mapped in this viewer. Note this list is not
- * currently scoped per structure.
- *
- * @return
- */
- @Override
- public List<String> getChainNames()
- {
- return chainNames;
- }
-
- /**
- * Send a 'focus' command to Chimera to recentre the visible display
- */
- public void focusView()
- {
- sendChimeraCommand("focus", false);
- }
-
- /**
- * Send a 'show' command for all atoms in the currently selected columns
- *
- * TODO: pull up to abstract structure viewer interface
- *
- * @param vp
- */
- public void highlightSelection(AlignmentViewPanel vp)
- {
- List<Integer> cols = vp.getAlignViewport().getColumnSelection()
- .getSelected();
- AlignmentI alignment = vp.getAlignment();
- StructureSelectionManager sm = getSsm();
- for (SequenceI seq : alignment.getSequences())
- {
- /*
- * convert selected columns into sequence positions
- */
- int[] positions = new int[cols.size()];
- int i = 0;
- for (Integer col : cols)
- {
- positions[i++] = seq.findPosition(col);
- }
- sm.highlightStructure(this, seq, positions);
- }
- }
-