| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
package dr.app.bss; |
| 27 |
|
| 28 |
import jam.framework.DocumentFrame; |
| 29 |
import jam.framework.Exportable; |
| 30 |
|
| 31 |
import java.awt.BorderLayout; |
| 32 |
import java.awt.Component; |
| 33 |
import java.awt.Dimension; |
| 34 |
import java.awt.Insets; |
| 35 |
import java.awt.event.ActionEvent; |
| 36 |
import java.io.File; |
| 37 |
import java.io.FileInputStream; |
| 38 |
import java.io.FileNotFoundException; |
| 39 |
import java.io.FileOutputStream; |
| 40 |
import java.io.FileWriter; |
| 41 |
import java.io.IOException; |
| 42 |
import java.io.ObjectInputStream; |
| 43 |
import java.io.ObjectOutputStream; |
| 44 |
import java.io.OutputStream; |
| 45 |
import java.io.PrintWriter; |
| 46 |
import java.util.ArrayList; |
| 47 |
|
| 48 |
import javax.swing.AbstractAction; |
| 49 |
import javax.swing.Action; |
| 50 |
import javax.swing.JComponent; |
| 51 |
import javax.swing.JFileChooser; |
| 52 |
import javax.swing.JLabel; |
| 53 |
import javax.swing.JPanel; |
| 54 |
import javax.swing.JProgressBar; |
| 55 |
import javax.swing.JTabbedPane; |
| 56 |
import javax.swing.SwingUtilities; |
| 57 |
import javax.swing.SwingWorker; |
| 58 |
import javax.swing.plaf.BorderUIResource; |
| 59 |
|
| 60 |
import dr.app.beagle.tools.BeagleSequenceSimulator; |
| 61 |
import dr.app.beagle.tools.Partition; |
| 62 |
import dr.evolution.alignment.SimpleAlignment; |
| 63 |
import dr.evomodel.tree.TreeModel; |
| 64 |
import dr.math.MathUtils; |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
@SuppressWarnings("serial") |
| 71 |
public class MainFrame extends DocumentFrame implements FileMenuHandler { |
| 72 |
|
| 73 |
private PartitionDataList dataList; |
| 74 |
private BeagleSequenceSimulator beagleSequenceSimulator; |
| 75 |
|
| 76 |
private final String TAXA_TAB_NAME = "Taxa"; |
| 77 |
private final String TREES_TAB_NAME = "Data"; |
| 78 |
private final String PARTITIONS_TAB_NAME = "Partitions"; |
| 79 |
private final String SIMULATION_TAB_NAME = "Simulation"; |
| 80 |
private final String TERMINAL_TAB_NAME = "Terminal"; |
| 81 |
|
| 82 |
private JTabbedPane tabbedPane = new JTabbedPane(); |
| 83 |
private TaxaPanel taxaPanel; |
| 84 |
private TreesPanel treesPanel; |
| 85 |
private PartitionsPanel partitionsPanel; |
| 86 |
private SimulationPanel simulationPanel; |
| 87 |
private TerminalPanel terminalPanel; |
| 88 |
|
| 89 |
private JLabel statusLabel; |
| 90 |
private JProgressBar progressBar; |
| 91 |
private File workingDirectory = null; |
| 92 |
|
| 93 |
public MainFrame(String title) { |
| 94 |
|
| 95 |
super(); |
| 96 |
|
| 97 |
setTitle(title); |
| 98 |
dataList = new PartitionDataList(); |
| 99 |
dataList.add(new PartitionData()); |
| 100 |
|
| 101 |
} |
| 102 |
|
| 103 |
@Override |
| 104 |
protected void initializeComponents() { |
| 105 |
|
| 106 |
setSize(new Dimension(1300, 600)); |
| 107 |
setMinimumSize(new Dimension(260, 100)); |
| 108 |
|
| 109 |
taxaPanel = new TaxaPanel(dataList); |
| 110 |
treesPanel = new TreesPanel(this, dataList); |
| 111 |
partitionsPanel = new PartitionsPanel(dataList); |
| 112 |
simulationPanel = new SimulationPanel(this, dataList); |
| 113 |
terminalPanel = new TerminalPanel(); |
| 114 |
|
| 115 |
tabbedPane.addTab(TAXA_TAB_NAME, null, taxaPanel); |
| 116 |
tabbedPane.addTab(TREES_TAB_NAME, null, treesPanel); |
| 117 |
tabbedPane.addTab(PARTITIONS_TAB_NAME, null, partitionsPanel); |
| 118 |
tabbedPane.addTab(SIMULATION_TAB_NAME, null, simulationPanel); |
| 119 |
tabbedPane.addTab(TERMINAL_TAB_NAME, null, terminalPanel); |
| 120 |
|
| 121 |
statusLabel = new JLabel("No taxa loaded"); |
| 122 |
|
| 123 |
JPanel progressPanel = new JPanel(new BorderLayout(0, 0)); |
| 124 |
progressBar = new JProgressBar(); |
| 125 |
progressPanel.add(progressBar, BorderLayout.CENTER); |
| 126 |
|
| 127 |
JPanel statusPanel = new JPanel(new BorderLayout(0, 0)); |
| 128 |
statusPanel.add(statusLabel, BorderLayout.CENTER); |
| 129 |
statusPanel.add(progressPanel, BorderLayout.EAST); |
| 130 |
statusPanel.setBorder(new BorderUIResource.EmptyBorderUIResource( |
| 131 |
new Insets(0, 6, 0, 6))); |
| 132 |
|
| 133 |
JPanel tabbedPanePanel = new JPanel(new BorderLayout(0, 0)); |
| 134 |
tabbedPanePanel.add(tabbedPane, BorderLayout.CENTER); |
| 135 |
tabbedPanePanel.add(statusPanel, BorderLayout.SOUTH); |
| 136 |
tabbedPanePanel.setBorder(new BorderUIResource.EmptyBorderUIResource( |
| 137 |
new Insets(12, 12, 12, 12))); |
| 138 |
|
| 139 |
getContentPane().setLayout(new java.awt.BorderLayout(0, 0)); |
| 140 |
getContentPane().add(tabbedPanePanel, BorderLayout.CENTER); |
| 141 |
|
| 142 |
tabbedPane.setSelectedComponent(treesPanel); |
| 143 |
|
| 144 |
} |
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
public void doExport() { |
| 152 |
|
| 153 |
if (getTreesCount() == 0) { |
| 154 |
|
| 155 |
tabbedPane.setSelectedComponent(treesPanel); |
| 156 |
Utils.showDialog("Please load at least one tree file before generating alignment."); |
| 157 |
|
| 158 |
} else { |
| 159 |
|
| 160 |
JFileChooser chooser = new JFileChooser(); |
| 161 |
chooser.setDialogTitle("Simulate..."); |
| 162 |
chooser.setMultiSelectionEnabled(false); |
| 163 |
chooser.setCurrentDirectory(workingDirectory); |
| 164 |
|
| 165 |
int returnVal = chooser.showSaveDialog(Utils.getActiveFrame()); |
| 166 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
| 167 |
|
| 168 |
File file = chooser.getSelectedFile(); |
| 169 |
|
| 170 |
collectAllSettings(); |
| 171 |
generateNumberOfSimulations(file); |
| 172 |
|
| 173 |
File tmpDir = chooser.getCurrentDirectory(); |
| 174 |
if (tmpDir != null) { |
| 175 |
workingDirectory = tmpDir; |
| 176 |
} |
| 177 |
|
| 178 |
} |
| 179 |
|
| 180 |
} |
| 181 |
|
| 182 |
} |
| 183 |
|
| 184 |
|
| 185 |
private void generateNumberOfSimulations(final File outFile) { |
| 186 |
|
| 187 |
setBusy(); |
| 188 |
|
| 189 |
SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() { |
| 190 |
|
| 191 |
ArrayList<TreeModel> simulatedTreeModelList = new ArrayList<TreeModel>(); |
| 192 |
|
| 193 |
|
| 194 |
public Void doInBackground() { |
| 195 |
|
| 196 |
try { |
| 197 |
|
| 198 |
if (BeagleSequenceSimulatorApp.VERBOSE) { |
| 199 |
Utils.printPartitionDataList(dataList); |
| 200 |
System.out.println(); |
| 201 |
} |
| 202 |
|
| 203 |
long startingSeed = dataList.startingSeed; |
| 204 |
for (int i = 0; i < dataList.simulationsCount; i++) { |
| 205 |
|
| 206 |
String fullPath = Utils.getMultipleWritePath(outFile, |
| 207 |
dataList.outputFormat.toString().toLowerCase(), i); |
| 208 |
PrintWriter writer = new PrintWriter(new FileWriter( |
| 209 |
fullPath)); |
| 210 |
|
| 211 |
ArrayList<Partition> partitionsList = new ArrayList<Partition>(); |
| 212 |
|
| 213 |
for (PartitionData data : dataList) { |
| 214 |
|
| 215 |
if (data.record == null) { |
| 216 |
|
| 217 |
writer.close(); |
| 218 |
throw new RuntimeException( |
| 219 |
"Set data in Partitions tab for " |
| 220 |
+ (partitionsList.size() + 1) |
| 221 |
+ " partition."); |
| 222 |
|
| 223 |
} else { |
| 224 |
|
| 225 |
TreeModel treeModel = data.createTreeModel(); |
| 226 |
simulatedTreeModelList.add(treeModel); |
| 227 |
|
| 228 |
|
| 229 |
Partition partition = new Partition( |
| 230 |
treeModel, |
| 231 |
data.createBranchModel(), |
| 232 |
data.createSiteRateModel(), |
| 233 |
data.createClockRateModel(), |
| 234 |
data.createFrequencyModel(), |
| 235 |
data.from - 1, |
| 236 |
data.to - 1, |
| 237 |
data.every |
| 238 |
); |
| 239 |
|
| 240 |
if (data.ancestralSequenceString != null) { |
| 241 |
partition.setRootSequence(data.createAncestralSequence()); |
| 242 |
} |
| 243 |
|
| 244 |
partitionsList.add(partition); |
| 245 |
|
| 246 |
} |
| 247 |
|
| 248 |
} |
| 249 |
|
| 250 |
if (dataList.setSeed) { |
| 251 |
MathUtils.setSeed(startingSeed); |
| 252 |
startingSeed += 1; |
| 253 |
} |
| 254 |
|
| 255 |
beagleSequenceSimulator = new BeagleSequenceSimulator( |
| 256 |
partitionsList |
| 257 |
); |
| 258 |
|
| 259 |
SimpleAlignment alignment = beagleSequenceSimulator.simulate(dataList.useParallel, dataList.outputAncestralSequences); |
| 260 |
alignment.setOutputType(dataList.outputFormat); |
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
writer.println(alignment.toString()); |
| 271 |
writer.close(); |
| 272 |
|
| 273 |
} |
| 274 |
|
| 275 |
} catch (Exception e) { |
| 276 |
Utils.handleException(e); |
| 277 |
setStatus("Exception occured."); |
| 278 |
setIdle(); |
| 279 |
} |
| 280 |
|
| 281 |
return null; |
| 282 |
} |
| 283 |
|
| 284 |
|
| 285 |
public void done() { |
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
terminalPanel.setText(Utils.partitionDataListToString(dataList, simulatedTreeModelList |
| 290 |
|
| 291 |
)); |
| 292 |
setStatus("Generated " + Utils.getSiteCount(dataList) + " sites."); |
| 293 |
setIdle(); |
| 294 |
|
| 295 |
} |
| 296 |
}; |
| 297 |
|
| 298 |
worker.execute(); |
| 299 |
|
| 300 |
} |
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
public final void doGenerateXML() { |
| 307 |
|
| 308 |
if (getTreesCount() == 0) { |
| 309 |
|
| 310 |
tabbedPane.setSelectedComponent(treesPanel); |
| 311 |
Utils.showDialog("Please load at least one tree file before generating XML."); |
| 312 |
|
| 313 |
|
| 314 |
} else { |
| 315 |
|
| 316 |
JFileChooser chooser = new JFileChooser(); |
| 317 |
chooser.setDialogTitle("Generate XML..."); |
| 318 |
chooser.setMultiSelectionEnabled(false); |
| 319 |
chooser.setCurrentDirectory(workingDirectory); |
| 320 |
|
| 321 |
int returnVal = chooser.showSaveDialog(Utils.getActiveFrame()); |
| 322 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
| 323 |
|
| 324 |
File file = chooser.getSelectedFile(); |
| 325 |
|
| 326 |
generateXML(file); |
| 327 |
|
| 328 |
File tmpDir = chooser.getCurrentDirectory(); |
| 329 |
if (tmpDir != null) { |
| 330 |
workingDirectory = tmpDir; |
| 331 |
} |
| 332 |
|
| 333 |
} |
| 334 |
|
| 335 |
} |
| 336 |
|
| 337 |
} |
| 338 |
|
| 339 |
private void generateXML(final File outFile) { |
| 340 |
|
| 341 |
setBusy(); |
| 342 |
|
| 343 |
SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() { |
| 344 |
|
| 345 |
|
| 346 |
public Void doInBackground() { |
| 347 |
|
| 348 |
try { |
| 349 |
|
| 350 |
collectAllSettings(); |
| 351 |
XMLGenerator xmlGenerator = new XMLGenerator(dataList); |
| 352 |
xmlGenerator.generateXML(outFile); |
| 353 |
|
| 354 |
} catch (Exception e) { |
| 355 |
Utils.handleException(e); |
| 356 |
setStatus("Exception occured."); |
| 357 |
setIdle(); |
| 358 |
} |
| 359 |
|
| 360 |
return null; |
| 361 |
} |
| 362 |
|
| 363 |
|
| 364 |
public void done() { |
| 365 |
|
| 366 |
setStatus("Generated " + outFile); |
| 367 |
setIdle(); |
| 368 |
|
| 369 |
} |
| 370 |
}; |
| 371 |
|
| 372 |
worker.execute(); |
| 373 |
|
| 374 |
} |
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
public Action getSaveSettingsAction() { |
| 382 |
return new AbstractAction("Save settings...") { |
| 383 |
public void actionPerformed(ActionEvent ae) { |
| 384 |
doSaveSettings(); |
| 385 |
} |
| 386 |
}; |
| 387 |
} |
| 388 |
|
| 389 |
private void doSaveSettings() { |
| 390 |
|
| 391 |
JFileChooser chooser = new JFileChooser(); |
| 392 |
chooser.setDialogTitle("Save as..."); |
| 393 |
chooser.setMultiSelectionEnabled(false); |
| 394 |
chooser.setCurrentDirectory(workingDirectory); |
| 395 |
|
| 396 |
int returnVal = chooser.showSaveDialog(Utils.getActiveFrame()); |
| 397 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
| 398 |
|
| 399 |
File file = chooser.getSelectedFile(); |
| 400 |
|
| 401 |
saveSettings(file); |
| 402 |
|
| 403 |
File tmpDir = chooser.getCurrentDirectory(); |
| 404 |
if (tmpDir != null) { |
| 405 |
workingDirectory = tmpDir; |
| 406 |
} |
| 407 |
|
| 408 |
setStatus("Saved as " + file.getAbsolutePath()); |
| 409 |
|
| 410 |
} |
| 411 |
|
| 412 |
} |
| 413 |
|
| 414 |
private void saveSettings(File file) { |
| 415 |
|
| 416 |
try { |
| 417 |
|
| 418 |
String fullPath = Utils.getWritePath(file, "bss"); |
| 419 |
OutputStream fileOut = new FileOutputStream(new File(fullPath)); |
| 420 |
ObjectOutputStream out = new ObjectOutputStream(fileOut); |
| 421 |
|
| 422 |
out.writeObject(dataList); |
| 423 |
out.close(); |
| 424 |
fileOut.close(); |
| 425 |
|
| 426 |
} catch (FileNotFoundException e) { |
| 427 |
Utils.handleException(e); |
| 428 |
} catch (IOException e) { |
| 429 |
Utils.handleException(e); |
| 430 |
} |
| 431 |
|
| 432 |
} |
| 433 |
|
| 434 |
|
| 435 |
public Action getLoadSettingsAction() { |
| 436 |
return new AbstractAction("Load settings...") { |
| 437 |
public void actionPerformed(ActionEvent ae) { |
| 438 |
doLoadSettings(); |
| 439 |
} |
| 440 |
}; |
| 441 |
} |
| 442 |
|
| 443 |
private void doLoadSettings() { |
| 444 |
|
| 445 |
JFileChooser chooser = new JFileChooser(); |
| 446 |
chooser.setDialogTitle("Load..."); |
| 447 |
chooser.setMultiSelectionEnabled(false); |
| 448 |
chooser.setCurrentDirectory(workingDirectory); |
| 449 |
|
| 450 |
int returnVal = chooser.showOpenDialog(Utils.getActiveFrame()); |
| 451 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
| 452 |
|
| 453 |
File file = chooser.getSelectedFile(); |
| 454 |
|
| 455 |
loadSettings(file); |
| 456 |
|
| 457 |
File tmpDir = chooser.getCurrentDirectory(); |
| 458 |
if (tmpDir != null) { |
| 459 |
workingDirectory = tmpDir; |
| 460 |
} |
| 461 |
|
| 462 |
setStatus("Loaded " + file.getAbsolutePath()); |
| 463 |
|
| 464 |
} |
| 465 |
|
| 466 |
} |
| 467 |
|
| 468 |
private void loadSettings(File file) { |
| 469 |
|
| 470 |
try { |
| 471 |
|
| 472 |
FileInputStream fileIn = new FileInputStream(file); |
| 473 |
ObjectInputStream in = new ObjectInputStream(fileIn); |
| 474 |
|
| 475 |
dataList = (PartitionDataList) in.readObject(); |
| 476 |
|
| 477 |
in.close(); |
| 478 |
fileIn.close(); |
| 479 |
|
| 480 |
if (BeagleSequenceSimulatorApp.VERBOSE) { |
| 481 |
Utils.printPartitionDataList(dataList); |
| 482 |
System.out.println(); |
| 483 |
} |
| 484 |
|
| 485 |
partitionsPanel.updatePartitionTable(dataList); |
| 486 |
taxaPanel.updateTaxaTable(dataList); |
| 487 |
treesPanel.updateTreesTable(dataList); |
| 488 |
simulationPanel.updateSimulationPanel(dataList); |
| 489 |
|
| 490 |
} catch (IOException ioe) { |
| 491 |
|
| 492 |
Utils.handleException( |
| 493 |
ioe, |
| 494 |
"Unable to read BSS file. " |
| 495 |
+ "BSS can only read files created by 'Saving' within BSS. " |
| 496 |
+ "It cannot read XML files."); |
| 497 |
|
| 498 |
} catch (ClassNotFoundException cnfe) { |
| 499 |
|
| 500 |
Utils.handleException(cnfe); |
| 501 |
|
| 502 |
} |
| 503 |
|
| 504 |
} |
| 505 |
|
| 506 |
@Override |
| 507 |
protected boolean readFromFile(File arg0) throws IOException { |
| 508 |
return false; |
| 509 |
} |
| 510 |
|
| 511 |
@Override |
| 512 |
protected boolean writeToFile(File arg0) throws IOException { |
| 513 |
return false; |
| 514 |
} |
| 515 |
|
| 516 |
|
| 517 |
|
| 518 |
|
| 519 |
|
| 520 |
public File getWorkingDirectory() { |
| 521 |
return workingDirectory; |
| 522 |
} |
| 523 |
|
| 524 |
public void setWorkingDirectory(File workingDirectory) { |
| 525 |
this.workingDirectory = workingDirectory; |
| 526 |
} |
| 527 |
|
| 528 |
public void collectAllSettings() { |
| 529 |
|
| 530 |
|
| 531 |
|
| 532 |
|
| 533 |
|
| 534 |
simulationPanel.collectSettings(); |
| 535 |
|
| 536 |
} |
| 537 |
|
| 538 |
public void fireTaxaChanged() { |
| 539 |
|
| 540 |
if (SwingUtilities.isEventDispatchThread()) { |
| 541 |
|
| 542 |
doTaxaChanged(); |
| 543 |
|
| 544 |
} else { |
| 545 |
|
| 546 |
SwingUtilities.invokeLater(new Runnable() { |
| 547 |
public void run() { |
| 548 |
|
| 549 |
doTaxaChanged(); |
| 550 |
|
| 551 |
} |
| 552 |
}); |
| 553 |
} |
| 554 |
|
| 555 |
} |
| 556 |
|
| 557 |
private void doTaxaChanged() { |
| 558 |
|
| 559 |
treesPanel.fireTableDataChanged(); |
| 560 |
taxaPanel.fireTaxaChanged(); |
| 561 |
setStatus(Integer.toString(dataList.allTaxa |
| 562 |
.getTaxonCount()) + " taxa loaded."); |
| 563 |
|
| 564 |
} |
| 565 |
|
| 566 |
public void setBusy() { |
| 567 |
|
| 568 |
if (SwingUtilities.isEventDispatchThread()) { |
| 569 |
|
| 570 |
simulationPanel.setBusy(); |
| 571 |
progressBar.setIndeterminate(true); |
| 572 |
|
| 573 |
} else { |
| 574 |
|
| 575 |
SwingUtilities.invokeLater(new Runnable() { |
| 576 |
public void run() { |
| 577 |
|
| 578 |
simulationPanel.setBusy(); |
| 579 |
progressBar.setIndeterminate(true); |
| 580 |
|
| 581 |
} |
| 582 |
}); |
| 583 |
} |
| 584 |
|
| 585 |
} |
| 586 |
|
| 587 |
public void setIdle() { |
| 588 |
|
| 589 |
if (SwingUtilities.isEventDispatchThread()) { |
| 590 |
|
| 591 |
simulationPanel.setIdle(); |
| 592 |
progressBar.setIndeterminate(false); |
| 593 |
|
| 594 |
} else { |
| 595 |
|
| 596 |
SwingUtilities.invokeLater(new Runnable() { |
| 597 |
public void run() { |
| 598 |
|
| 599 |
simulationPanel.setIdle(); |
| 600 |
progressBar.setIndeterminate(false); |
| 601 |
|
| 602 |
} |
| 603 |
}); |
| 604 |
} |
| 605 |
|
| 606 |
} |
| 607 |
|
| 608 |
public void setStatus(final String status) { |
| 609 |
|
| 610 |
if (SwingUtilities.isEventDispatchThread()) { |
| 611 |
|
| 612 |
statusLabel.setText(status); |
| 613 |
|
| 614 |
} else { |
| 615 |
|
| 616 |
SwingUtilities.invokeLater(new Runnable() { |
| 617 |
public void run() { |
| 618 |
|
| 619 |
statusLabel.setText(status); |
| 620 |
|
| 621 |
} |
| 622 |
}); |
| 623 |
} |
| 624 |
|
| 625 |
} |
| 626 |
|
| 627 |
public void hideTreeColumn() { |
| 628 |
|
| 629 |
if (SwingUtilities.isEventDispatchThread()) { |
| 630 |
|
| 631 |
partitionsPanel.hideTreeColumn(); |
| 632 |
|
| 633 |
} else { |
| 634 |
|
| 635 |
SwingUtilities.invokeLater(new Runnable() { |
| 636 |
public void run() { |
| 637 |
|
| 638 |
partitionsPanel.hideTreeColumn(); |
| 639 |
|
| 640 |
} |
| 641 |
}); |
| 642 |
} |
| 643 |
|
| 644 |
} |
| 645 |
|
| 646 |
public void showTreeColumn() { |
| 647 |
|
| 648 |
if (SwingUtilities.isEventDispatchThread()) { |
| 649 |
|
| 650 |
partitionsPanel.showTreeColumn(); |
| 651 |
|
| 652 |
} else { |
| 653 |
|
| 654 |
SwingUtilities.invokeLater(new Runnable() { |
| 655 |
public void run() { |
| 656 |
|
| 657 |
partitionsPanel.showTreeColumn(); |
| 658 |
|
| 659 |
} |
| 660 |
}); |
| 661 |
} |
| 662 |
|
| 663 |
} |
| 664 |
|
| 665 |
public void disableTaxaPanel() { |
| 666 |
|
| 667 |
final int index = Utils.getTabbedPaneComponentIndex(tabbedPane, TAXA_TAB_NAME); |
| 668 |
|
| 669 |
if (SwingUtilities.isEventDispatchThread()) { |
| 670 |
|
| 671 |
tabbedPane.setEnabledAt(index, false); |
| 672 |
|
| 673 |
} else { |
| 674 |
|
| 675 |
SwingUtilities.invokeLater(new Runnable() { |
| 676 |
public void run() { |
| 677 |
|
| 678 |
tabbedPane.setEnabledAt(index, false); |
| 679 |
|
| 680 |
} |
| 681 |
}); |
| 682 |
} |
| 683 |
|
| 684 |
} |
| 685 |
|
| 686 |
public void enableTaxaPanel() { |
| 687 |
|
| 688 |
final int index = Utils.getTabbedPaneComponentIndex(tabbedPane, TAXA_TAB_NAME); |
| 689 |
|
| 690 |
if (SwingUtilities.isEventDispatchThread()) { |
| 691 |
|
| 692 |
tabbedPane.setEnabledAt(index, true); |
| 693 |
|
| 694 |
} else { |
| 695 |
|
| 696 |
SwingUtilities.invokeLater(new Runnable() { |
| 697 |
public void run() { |
| 698 |
|
| 699 |
tabbedPane.setEnabledAt(index, true); |
| 700 |
|
| 701 |
} |
| 702 |
}); |
| 703 |
} |
| 704 |
|
| 705 |
} |
| 706 |
|
| 707 |
private int getTreesCount() { |
| 708 |
return dataList.recordsList.size(); |
| 709 |
} |
| 710 |
|
| 711 |
|
| 712 |
public JComponent getExportableComponent() { |
| 713 |
JComponent exportable = null; |
| 714 |
Component component = tabbedPane.getSelectedComponent(); |
| 715 |
|
| 716 |
if (component instanceof Exportable) { |
| 717 |
exportable = ((Exportable) component).getExportableComponent(); |
| 718 |
} else if (component instanceof JComponent) { |
| 719 |
exportable = (JComponent) component; |
| 720 |
} |
| 721 |
|
| 722 |
return exportable; |
| 723 |
} |
| 724 |
|
| 725 |
} |