import jalview.analysis.scoremodels.ScoreModels;
import jalview.api.analysis.ScoreModelI;
import jalview.api.analysis.SimilarityParamsI;
+import jalview.bin.Cache;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AlignmentView;
import jalview.datamodel.HiddenColumns;
import jalview.datamodel.SequenceI;
import jalview.jbgui.GPCAPanel;
+import jalview.math.RotatableMatrix.Axis;
import jalview.util.ImageMaker;
import jalview.util.MessageManager;
import jalview.viewmodel.AlignmentViewport;
import javax.swing.event.InternalFrameEvent;
/**
- * The panel holding the Principal Component Analysis 3-d visualisation
+ * The panel holding the Principal Component Analysis 3-D visualisation
*/
public class PCAPanel extends GPCAPanel
implements Runnable, IProgressIndicator
{
+ private static final int MIN_WIDTH = 470;
+
+ private static final int MIN_HEIGHT = 250;
+
RotatableCanvas rc;
AlignmentPanel ap;
int top = 0;
- private static final int MIN_WIDTH = 470;
-
- private static final int MIN_HEIGHT = 250;
-
private IProgressIndicator progressBar;
private boolean working;
rc = new RotatableCanvas(alignPanel);
this.getContentPane().add(rc, BorderLayout.CENTER);
- /*
- * perform calculation in a new Thread
- */
- Thread worker = new Thread(this);
- worker.start();
+ addKeyListener(rc);
+ validate();
+
+ this.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT));
}
/**
@Override
public void run()
{
+ working = true;
long progId = System.currentTimeMillis();
IProgressIndicator progress = this;
String message = MessageManager.getString("label.pca_recalculating");
message = MessageManager.getString("label.pca_calculating");
}
progress.setProgressBar(message, progId);
- working = true;
try
{
pcaModel.calculate();
- // ////////////////
+
xCombobox.setSelectedIndex(0);
yCombobox.setSelectedIndex(1);
zCombobox.setSelectedIndex(2);
repaint();
if (getParent() == null)
{
- addKeyListener(rc);
Desktop.addInternalFrame(this,
MessageManager.formatMessage("label.calc_title", "PCA",
pcaModel.getScoreModelName()),
475, 450);
- this.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT));
}
working = false;
}
int dim3 = top - zCombobox.getSelectedIndex();
pcaModel.updateRcView(dim1, dim2, dim3);
rc.resetView();
- rc.paint(rc.getGraphics());
+ }
+
+ /**
+ * Sets the selected checkbox item index for PCA dimension (1, 2, 3...) for
+ * the given axis (X/Y/Z)
+ *
+ * @param index
+ * @param axis
+ */
+ public void setSelectedDimensionIndex(int index, Axis axis)
+ {
+ switch (axis)
+ {
+ case X:
+ xCombobox.setSelectedIndex(index);
+ break;
+ case Y:
+ yCombobox.setSelectedIndex(index);
+ break;
+ case Z:
+ zCombobox.setSelectedIndex(index);
+ break;
+ default:
+ }
}
@Override
printer.start();
}
+ /**
+ * If available, shows the data which formed the inputs for the PCA as a new
+ * alignment
+ */
@Override
public void originalSeqData_actionPerformed()
{
- // this was cut'n'pasted from the equivalent TreePanel method - we should
- // make this an abstract function of all jalview analysis windows
- if (pcaModel.getSeqtrings() == null)
+ // JAL-2647 disabled after load from project (until save to project done)
+ if (pcaModel.getInputData() == null)
{
- jalview.bin.Cache.log.info(
+ Cache.log.info(
"Unexpected call to originalSeqData_actionPerformed - should have hidden this menu action.");
return;
}
// decide if av alignment is sufficiently different to original data to
// warrant a new window to be created
- // create new alignmnt window with hidden regions (unhiding hidden regions
+ // create new alignment window with hidden regions (unhiding hidden regions
// yields unaligned seqs)
// or create a selection box around columns in alignment view
// test Alignment(SeqCigar[])
{
}
- Object[] alAndColsel = pcaModel.getSeqtrings()
+ Object[] alAndColsel = pcaModel.getInputData()
.getAlignmentAndHiddenColumns(gc);
if (alAndColsel != null && alAndColsel[0] != null)
{
pg.translate((int) pf.getImageableX(), (int) pf.getImageableY());
- rc.drawBackground(pg, rc.bgColour);
+ rc.drawBackground(pg);
rc.drawScene(pg);
if (rc.drawAxes)
{
ImageMaker im;
- if (type == ImageMaker.TYPE.PNG)
+ switch (type)
{
+ case PNG:
im = new ImageMaker(this, ImageMaker.TYPE.PNG,
"Make PNG image from PCA", width, height, null, null, null, 0,
false);
- }
- else if (type == jalview.util.ImageMaker.TYPE.EPS)
- {
+ break;
+ case EPS:
im = new ImageMaker(this, ImageMaker.TYPE.EPS,
"Make EPS file from PCA", width, height, null,
this.getTitle(), null, 0, false);
- }
- else
- {
+ break;
+ default:
im = new ImageMaker(this, ImageMaker.TYPE.SVG,
"Make SVG file from PCA", width, height, null,
this.getTitle(), null, 0, false);
if (im.getGraphics() != null)
{
- rc.drawBackground(im.getGraphics(), Color.black);
+ rc.drawBackground(im.getGraphics());
rc.drawScene(im.getGraphics());
if (rc.drawAxes)
{
{
return working;
}
+
+ /**
+ * Answers the selected checkbox item index for PCA dimension for the X, Y or
+ * Z axis of the display
+ *
+ * @param axis
+ * @return
+ */
+ public int getSelectedDimensionIndex(Axis axis)
+ {
+ switch (axis)
+ {
+ case X:
+ return xCombobox.getSelectedIndex();
+ case Y:
+ return yCombobox.getSelectedIndex();
+ default:
+ return zCombobox.getSelectedIndex();
+ }
+ }
+
+ public void setShowLabels(boolean show)
+ {
+ showLabels.setSelected(show);
+ }
+
+ /**
+ * Sets the input data used to calculate the PCA. This is provided for
+ * 'restore from project', which does not currently support this (AL-2647), so
+ * sets the value to null, and hides the menu option for "Input Data...". J
+ *
+ * @param data
+ */
+ public void setInputData(AlignmentView data)
+ {
+ pcaModel.setInputData(data);
+ originalSeqData.setVisible(data != null);
+ }
}