| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.appletgui; |
| 22 |
|
|
| 23 |
|
import jalview.api.AlignmentViewPanel; |
| 24 |
|
import jalview.api.ViewStyleI; |
| 25 |
|
import jalview.bin.JalviewLite; |
| 26 |
|
import jalview.datamodel.AlignmentI; |
| 27 |
|
import jalview.structure.StructureSelectionManager; |
| 28 |
|
import jalview.viewmodel.AlignmentViewport; |
| 29 |
|
|
| 30 |
|
import java.awt.BorderLayout; |
| 31 |
|
import java.awt.Dimension; |
| 32 |
|
import java.awt.GridLayout; |
| 33 |
|
import java.awt.Panel; |
| 34 |
|
|
| |
|
| 0% |
Uncovered Elements: 108 (108) |
Complexity: 25 |
Complexity Density: 0.37 |
|
| 35 |
|
public class SplitFrame extends EmbmenuFrame |
| 36 |
|
{ |
| 37 |
|
private static final long serialVersionUID = 1L; |
| 38 |
|
|
| 39 |
|
private AlignFrame topFrame; |
| 40 |
|
|
| 41 |
|
private AlignFrame bottomFrame; |
| 42 |
|
|
| 43 |
|
private Panel outermost; |
| 44 |
|
|
| 45 |
|
|
| 46 |
|
|
| 47 |
|
|
| 48 |
|
|
| |
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.75 |
|
| 49 |
0 |
public SplitFrame(AlignFrame af1, AlignFrame af2)... |
| 50 |
|
{ |
| 51 |
0 |
boolean af1IsNucleotide = af1.viewport.getAlignment().isNucleotide(); |
| 52 |
0 |
topFrame = af1IsNucleotide ? af1 : af2; |
| 53 |
0 |
bottomFrame = topFrame == af1 ? af2 : af1; |
| 54 |
0 |
init(); |
| 55 |
|
} |
| 56 |
|
|
| 57 |
|
|
| 58 |
|
|
| 59 |
|
|
| 60 |
|
|
| 61 |
|
|
| 62 |
|
|
| |
|
| 0% |
Uncovered Elements: 26 (26) |
Complexity: 6 |
Complexity Density: 0.38 |
|
| 63 |
0 |
public void init()... |
| 64 |
|
{ |
| 65 |
0 |
constructSplit(); |
| 66 |
|
|
| 67 |
|
|
| 68 |
|
|
| 69 |
|
|
| 70 |
0 |
final AlignViewport topViewport = topFrame.viewport; |
| 71 |
0 |
final AlignViewport bottomViewport = bottomFrame.viewport; |
| 72 |
0 |
final AlignmentI topAlignment = topViewport.getAlignment(); |
| 73 |
0 |
final AlignmentI bottomAlignment = bottomViewport.getAlignment(); |
| 74 |
0 |
AlignmentViewport cdna = topAlignment.isNucleotide() ? topViewport |
| 75 |
0 |
: (bottomAlignment.isNucleotide() ? bottomViewport : null); |
| 76 |
0 |
AlignmentViewport protein = !topAlignment.isNucleotide() ? topViewport |
| 77 |
0 |
: (!bottomAlignment.isNucleotide() ? bottomViewport : null); |
| 78 |
|
|
| 79 |
0 |
final StructureSelectionManager ssm = StructureSelectionManager |
| 80 |
|
.getStructureSelectionManager(topViewport.applet); |
| 81 |
0 |
ssm.registerMappings(protein.getAlignment().getCodonFrames()); |
| 82 |
0 |
topViewport.setCodingComplement(bottomViewport); |
| 83 |
0 |
ssm.addCommandListener(cdna); |
| 84 |
0 |
ssm.addCommandListener(protein); |
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| 88 |
|
|
| 89 |
0 |
protein.initComplementConsensus(); |
| 90 |
0 |
AlignmentViewPanel ap = topAlignment.isNucleotide() |
| 91 |
|
? bottomFrame.alignPanel |
| 92 |
|
: topFrame.alignPanel; |
| 93 |
0 |
protein.updateConsensus(ap); |
| 94 |
|
|
| 95 |
0 |
adjustLayout(); |
| 96 |
|
} |
| 97 |
|
|
| 98 |
|
|
| 99 |
|
|
| 100 |
|
|
| |
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
| 101 |
0 |
protected void constructSplit()... |
| 102 |
|
{ |
| 103 |
0 |
setMenuBar(null); |
| 104 |
0 |
outermost = new Panel(new GridLayout(2, 1)); |
| 105 |
|
|
| 106 |
0 |
Panel topPanel = new Panel(); |
| 107 |
0 |
Panel bottomPanel = new Panel(); |
| 108 |
0 |
outermost.add(topPanel); |
| 109 |
0 |
outermost.add(bottomPanel); |
| 110 |
|
|
| 111 |
0 |
addAlignFrameComponents(topFrame, topPanel); |
| 112 |
0 |
addAlignFrameComponents(bottomFrame, bottomPanel); |
| 113 |
|
} |
| 114 |
|
|
| 115 |
|
|
| 116 |
|
|
| 117 |
|
|
| |
|
| 0% |
Uncovered Elements: 28 (28) |
Complexity: 8 |
Complexity Density: 0.5 |
|
| 118 |
0 |
protected void adjustLayout()... |
| 119 |
|
{ |
| 120 |
0 |
AlignmentViewport cdna = topFrame.getAlignViewport().getAlignment() |
| 121 |
|
.isNucleotide() ? topFrame.viewport : bottomFrame.viewport; |
| 122 |
0 |
AlignmentViewport protein = cdna == topFrame.viewport |
| 123 |
|
? bottomFrame.viewport |
| 124 |
|
: topFrame.viewport; |
| 125 |
|
|
| 126 |
|
|
| 127 |
|
|
| 128 |
|
|
| 129 |
|
|
| 130 |
|
|
| 131 |
0 |
int w1 = topFrame.alignPanel.idPanel.idCanvas.getWidth(); |
| 132 |
0 |
int w2 = bottomFrame.alignPanel.idPanel.idCanvas.getWidth(); |
| 133 |
0 |
int w3 = Math.max(w1, w2); |
| 134 |
0 |
if (w1 != w3) |
| 135 |
|
{ |
| 136 |
0 |
Dimension d = topFrame.alignPanel.idPanel.idCanvas.getSize(); |
| 137 |
0 |
topFrame.alignPanel.idPanel.idCanvas |
| 138 |
|
.setSize(new Dimension(w3, d.height)); |
| 139 |
|
} |
| 140 |
0 |
if (w2 != w3) |
| 141 |
|
{ |
| 142 |
0 |
Dimension d = bottomFrame.alignPanel.idPanel.idCanvas.getSize(); |
| 143 |
0 |
bottomFrame.alignPanel.idPanel.idCanvas |
| 144 |
|
.setSize(new Dimension(w3, d.height)); |
| 145 |
|
} |
| 146 |
|
|
| 147 |
|
|
| 148 |
|
|
| 149 |
|
|
| 150 |
0 |
if (protein != null && cdna != null) |
| 151 |
|
{ |
| 152 |
0 |
ViewStyleI vs = protein.getViewStyle(); |
| 153 |
0 |
int scale = vs.isScaleProteinAsCdna() ? 3 : 1; |
| 154 |
0 |
vs.setCharWidth(scale * cdna.getViewStyle().getCharWidth()); |
| 155 |
0 |
protein.setViewStyle(vs); |
| 156 |
|
} |
| 157 |
|
} |
| 158 |
|
|
| 159 |
|
|
| 160 |
|
|
| 161 |
|
|
| 162 |
|
|
| 163 |
|
|
| 164 |
|
@param |
| 165 |
|
@param |
| 166 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
| 167 |
0 |
private void addAlignFrameComponents(AlignFrame af, Panel panel)... |
| 168 |
|
{ |
| 169 |
0 |
panel.setLayout(new BorderLayout()); |
| 170 |
0 |
Panel menuPanel = af.makeEmbeddedPopupMenu(af.getMenuBar(), true, |
| 171 |
|
false); |
| 172 |
0 |
panel.add(menuPanel, BorderLayout.NORTH); |
| 173 |
0 |
panel.add(af.statusBar, BorderLayout.SOUTH); |
| 174 |
0 |
panel.add(af.alignPanel, BorderLayout.CENTER); |
| 175 |
|
|
| 176 |
0 |
af.setSplitFrame(this); |
| 177 |
|
} |
| 178 |
|
|
| 179 |
|
|
| 180 |
|
|
| 181 |
|
|
| 182 |
|
@param |
| 183 |
|
@param |
| 184 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
| 185 |
0 |
public void addToDisplay(boolean embedded, JalviewLite applet)... |
| 186 |
|
{ |
| 187 |
0 |
createSplitFrameWindow(embedded, applet); |
| 188 |
0 |
validate(); |
| 189 |
0 |
topFrame.alignPanel.adjustAnnotationHeight(); |
| 190 |
0 |
topFrame.alignPanel.paintAlignment(true, true); |
| 191 |
0 |
bottomFrame.alignPanel.adjustAnnotationHeight(); |
| 192 |
0 |
bottomFrame.alignPanel.paintAlignment(true, true); |
| 193 |
|
} |
| 194 |
|
|
| 195 |
|
|
| 196 |
|
|
| 197 |
|
|
| 198 |
|
|
| 199 |
|
@param |
| 200 |
|
@param |
| 201 |
|
|
| |
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
| 202 |
0 |
protected void createSplitFrameWindow(boolean embed, JalviewLite applet)... |
| 203 |
|
{ |
| 204 |
0 |
if (embed) |
| 205 |
|
{ |
| 206 |
0 |
applet.add(outermost); |
| 207 |
0 |
applet.validate(); |
| 208 |
|
} |
| 209 |
|
else |
| 210 |
|
{ |
| 211 |
0 |
this.add(outermost); |
| 212 |
0 |
int width = Math.max(topFrame.frameWidth, bottomFrame.frameWidth); |
| 213 |
0 |
int height = topFrame.frameHeight + bottomFrame.frameHeight; |
| 214 |
0 |
jalview.bin.JalviewLite.addFrame(this, this.getTitle(), width, |
| 215 |
|
height); |
| 216 |
|
} |
| 217 |
|
} |
| 218 |
|
|
| 219 |
|
|
| 220 |
|
|
| 221 |
|
|
| 222 |
|
|
| 223 |
|
@param |
| 224 |
|
@return |
| 225 |
|
|
| |
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
| 226 |
0 |
public AlignFrame getComplement(AlignFrame af)... |
| 227 |
|
{ |
| 228 |
0 |
if (topFrame == af) |
| 229 |
|
{ |
| 230 |
0 |
return bottomFrame; |
| 231 |
|
} |
| 232 |
0 |
else if (bottomFrame == af) |
| 233 |
|
{ |
| 234 |
0 |
return topFrame; |
| 235 |
|
} |
| 236 |
0 |
return null; |
| 237 |
|
} |
| 238 |
|
} |