2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import jalview.api.structures.JalviewStructureDisplayI;
24 import jalview.bin.Cache;
25 import jalview.datamodel.PDBEntry;
26 import jalview.datamodel.SequenceI;
27 import jalview.datamodel.StructureViewerModel;
28 import jalview.structure.StructureSelectionManager;
30 import java.awt.Rectangle;
33 * proxy for handling structure viewers.
35 * this allows new views to be created with the currently configured viewer, the
36 * preferred viewer to be set/read and existing views created previously with a
37 * particular viewer to be recovered
41 public class StructureViewer
43 StructureSelectionManager ssm;
45 public enum ViewerType
50 public ViewerType getViewerType()
52 String viewType = Cache.getDefault(Preferences.STRUCTURE_DISPLAY,
53 ViewerType.JMOL.name());
54 return ViewerType.valueOf(viewType);
57 public void setViewerType(ViewerType type)
59 Cache.setProperty(Preferences.STRUCTURE_DISPLAY, type.name());
62 public StructureViewer(StructureSelectionManager structureSelectionManager)
64 ssm = structureSelectionManager;
67 public JalviewStructureDisplayI viewStructures(AlignmentPanel ap,
68 PDBEntry[] pr, SequenceI[][] collateForPDB)
70 return viewStructures(getViewerType(), ap, pr, collateForPDB);
73 public JalviewStructureDisplayI viewStructures(ViewerType viewerType,
74 AlignmentPanel ap, PDBEntry[] pr, SequenceI[][] collateForPDB)
76 JalviewStructureDisplayI sview = null;
77 if (viewerType.equals(ViewerType.JMOL))
79 sview = new AppJmol(ap, pr, ap.av.collateForPDB(pr));
81 else if (viewerType.equals(ViewerType.CHIMERA))
83 sview = new ChimeraViewFrame(ap, pr, ap.av.collateForPDB(pr));
87 Cache.log.error("Unknown structure viewer type "
88 + getViewerType().toString());
93 public JalviewStructureDisplayI viewStructures(ViewerType viewerType,
94 AlignmentPanel ap, PDBEntry pr, SequenceI[] collateForPDB)
96 JalviewStructureDisplayI sview = null;
97 if (viewerType.equals(ViewerType.JMOL))
99 sview = new AppJmol(pr, collateForPDB, null, ap);
101 else if (viewerType.equals(ViewerType.CHIMERA))
103 sview = new ChimeraViewFrame(pr, collateForPDB, null, ap);
107 Cache.log.error("Unknown structure viewer type "
108 + getViewerType().toString());
113 public JalviewStructureDisplayI viewStructures(PDBEntry pdb,
114 SequenceI[] sequenceIs, Object object, AlignmentPanel ap)
116 return viewStructures(getViewerType(), ap, pdb, sequenceIs);
120 * Create a new panel controlling a structure viewer.
133 public JalviewStructureDisplayI createView(ViewerType type,
134 String[] pdbf, String[] id, SequenceI[][] sq,
135 AlignmentPanel alignPanel, StructureViewerModel viewerData, String fileloc,
136 Rectangle rect, String vid)
138 final boolean useinViewerSuperpos = viewerData.isAlignWithPanel();
139 final boolean usetoColourbyseq = viewerData.isColourWithAlignPanel();
140 final boolean viewerColouring = viewerData.isColourByViewer();
142 JalviewStructureDisplayI sview = null;
146 sview = new AppJmol(pdbf, id, sq, alignPanel, usetoColourbyseq,
147 useinViewerSuperpos, viewerColouring, fileloc, rect, vid);
150 Cache.log.error("Unsupported structure viewer type "
154 Cache.log.error("Unknown structure viewer type " + type.toString());