package jalview.gui;
import jalview.analysis.scoremodels.ScoreModels;
-import jalview.analysis.scoremodels.SimilarityParams;
+import jalview.api.AlignViewportI;
import jalview.api.analysis.ScoreModelI;
-import jalview.api.analysis.ViewBasedAnalysisI;
+import jalview.api.analysis.SimilarityParamsI;
import jalview.bin.Cache;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AlignmentView;
-import jalview.datamodel.ColumnSelection;
-import jalview.datamodel.SeqCigar;
+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 jalview.viewmodel.PCAModel;
import java.awt.BorderLayout;
import java.awt.Color;
+import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.print.PrinterJob;
import javax.swing.ButtonGroup;
-import javax.swing.JCheckBoxMenuItem;
import javax.swing.JColorChooser;
import javax.swing.JMenuItem;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.event.InternalFrameEvent;
/**
- * DOCUMENT ME!
- *
- * @author $author$
- * @version $Revision$
+ * The panel holding the Principal Component Analysis 3-D visualisation
*/
-public class PCAPanel extends GPCAPanel implements Runnable,
- IProgressIndicator
+public class PCAPanel extends GPCAPanel
+ implements Runnable, IProgressIndicator
{
+ private static final int MIN_WIDTH = 470;
- private IProgressIndicator progressBar;
+ private static final int MIN_HEIGHT = 250;
- RotatableCanvas rc;
+ private RotatableCanvas rc;
AlignmentPanel ap;
AlignmentViewport av;
- PCAModel pcaModel;
+ private PCAModel pcaModel;
+
+ private int top = 0;
+
+ private IProgressIndicator progressBar;
- int top = 0;
+ private boolean working;
/**
- * Creates a new PCAPanel object.
+ * Constructor given sequence data, a similarity (or distance) score model
+ * name, and score calculation parameters
*
- * @param av
- * DOCUMENT ME!
- * @param s
- * DOCUMENT ME!
+ * @param alignPanel
+ * @param modelName
+ * @param params
*/
- public PCAPanel(AlignmentPanel alignPanel)
+ public PCAPanel(AlignmentPanel alignPanel, String modelName,
+ SimilarityParamsI params)
{
super();
this.av = alignPanel.av;
this.ap = alignPanel;
+ boolean nucleotide = av.getAlignment().isNucleotide();
progressBar = new ProgressBar(statusPanel, statusBar);
boolean selected = av.getSelectionGroup() != null
&& av.getSelectionGroup().getSize() > 0;
AlignmentView seqstrings = av.getAlignmentView(selected);
- boolean nucleotide = av.getAlignment().isNucleotide();
SequenceI[] seqs;
if (!selected)
{
seqs = av.getSelectionGroup().getSequencesInOrder(av.getAlignment());
}
- // TODO can we allow PCA on unaligned data given choice of
- // similarity measure parameters?
- if (!checkAligned(seqstrings))
- {
- JvOptionPane.showMessageDialog(Desktop.desktop,
- MessageManager.getString("label.pca_sequences_not_aligned"),
- MessageManager.getString("label.sequences_not_aligned"),
- JvOptionPane.WARNING_MESSAGE);
-
- return;
- }
-
- pcaModel = new PCAModel(seqstrings, seqs, nucleotide,
- SimilarityParams.SeqSpace);
+ ScoreModelI scoreModel = ScoreModels.getInstance()
+ .getScoreModel(modelName, ap);
+ setPcaModel(new PCAModel(seqstrings, seqs, nucleotide, scoreModel,
+ params));
PaintRefresher.Register(this, av.getSequenceSetId());
- rc = new RotatableCanvas(alignPanel);
- this.getContentPane().add(rc, BorderLayout.CENTER);
- Thread worker = new Thread(this);
- worker.start();
- }
+ setRotatableCanvas(new RotatableCanvas(alignPanel));
+ this.getContentPane().add(getRotatableCanvas(), BorderLayout.CENTER);
- /**
- * Answers true if all sequences have the same aligned length, else false
- *
- * @param seqstrings
- * @return
- */
- protected boolean checkAligned(AlignmentView seqstrings)
- {
- SeqCigar sq[] = seqstrings.getSequences();
- int length = sq[0].getWidth();
- boolean sameLength = true;
- for (int i = 0; i < sq.length; i++)
- {
- if (sq[i].getWidth() != length)
- {
- sameLength = false;
- break;
- }
- }
- return sameLength;
+ addKeyListener(getRotatableCanvas());
+ validate();
+
+ this.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT));
}
/**
*/
protected void close_actionPerformed()
{
- pcaModel = null;
- }
-
- /**
- * Repopulate the options and actions under the score model menu when it is
- * selected. Options will depend on whether 'nucleotide' or 'peptide'
- * modelling is selected (and also possibly on whether any additional score
- * models have been added).
- */
- @Override
- protected void scoreModel_menuSelected()
- {
- scoreModelMenu.removeAll();
- for (final ScoreModelI sm : ScoreModels.getInstance().getModels())
- {
- final String name = sm.getName();
- // create an entry for this score matrix for use in PCA
- JCheckBoxMenuItem jm = new JCheckBoxMenuItem();
- jm.setText(MessageManager.getStringOrReturn("label.score_model_",
- name));
- jm.setSelected(pcaModel.getScoreModelName().equals(name));
- if ((pcaModel.isNucleotide() && sm.isDNA())
- || (!pcaModel.isNucleotide() && sm.isProtein()))
- {
- jm.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- if (!pcaModel.getScoreModelName().equals(name))
- {
- ScoreModelI sm2 = configureScoreModel(sm);
- pcaModel.setScoreModel(sm2);
- Thread worker = new Thread(PCAPanel.this);
- worker.start();
- }
- }
- });
- scoreModelMenu.add(jm);
- }
- }
+ setPcaModel(null);
}
@Override
- public void bgcolour_actionPerformed(ActionEvent e)
+ protected void bgcolour_actionPerformed()
{
Color col = JColorChooser.showDialog(this,
MessageManager.getString("label.select_background_colour"),
- rc.bgColour);
+ getRotatableCanvas().getBgColour());
if (col != null)
{
- rc.bgColour = col;
+ getRotatableCanvas().setBgColour(col);
}
- rc.repaint();
+ getRotatableCanvas().repaint();
}
/**
- * DOCUMENT ME!
+ * Calculates the PCA and displays the results
*/
@Override
public void run()
{
+ working = true;
long progId = System.currentTimeMillis();
IProgressIndicator progress = this;
String message = MessageManager.getString("label.pca_recalculating");
progress.setProgressBar(message, progId);
try
{
- calcSettings.setEnabled(false);
- pcaModel.run();
- // ////////////////
+ getPcaModel().calculate();
+
xCombobox.setSelectedIndex(0);
yCombobox.setSelectedIndex(1);
zCombobox.setSelectedIndex(2);
- pcaModel.updateRc(rc);
+ getPcaModel().updateRc(getRotatableCanvas());
// rc.invalidate();
- nuclSetting.setSelected(pcaModel.isNucleotide());
- protSetting.setSelected(!pcaModel.isNucleotide());
- jvVersionSetting.setSelected(pcaModel.isJvCalcMode());
- top = pcaModel.getTop();
+ setTop(getPcaModel().getTop());
} catch (OutOfMemoryError er)
{
new OOMWarning("calculating PCA", er);
+ working = false;
return;
} finally
{
progress.setProgressBar("", progId);
}
- calcSettings.setEnabled(true);
+
repaint();
if (getParent() == null)
{
- addKeyListener(rc);
- Desktop.addInternalFrame(this, MessageManager
- .getString("label.principal_component_analysis"), 475, 450);
+ Desktop.addInternalFrame(this,
+ MessageManager.formatMessage("label.calc_title", "PCA",
+ getPcaModel().getScoreModelName()),
+ 475, 450);
}
- }
-
- @Override
- protected void nuclSetting_actionPerfomed(ActionEvent arg0)
- {
- if (!pcaModel.isNucleotide())
- {
- pcaModel.setNucleotide(true);
- pcaModel.setScoreModel(ScoreModels.getInstance().getDefaultModel(
- false));
- Thread worker = new Thread(this);
- worker.start();
- }
-
- }
-
- @Override
- protected void protSetting_actionPerfomed(ActionEvent arg0)
- {
-
- if (pcaModel.isNucleotide())
- {
- pcaModel.setNucleotide(false);
- pcaModel.setScoreModel(ScoreModels.getInstance()
- .getDefaultModel(true));
- Thread worker = new Thread(this);
- worker.start();
- }
- }
-
- @Override
- protected void jvVersionSetting_actionPerfomed(ActionEvent arg0)
- {
- pcaModel.setJvCalcMode(jvVersionSetting.isSelected());
- Thread worker = new Thread(this);
- worker.start();
+ working = false;
}
/**
- * DOCUMENT ME!
+ * Updates the PCA display after a change of component to use for x, y or z
+ * axis
*/
- void doDimensionChange()
+ @Override
+ protected void doDimensionChange()
{
- if (top == 0)
+ if (getTop() == 0)
{
return;
}
- int dim1 = top - xCombobox.getSelectedIndex();
- int dim2 = top - yCombobox.getSelectedIndex();
- int dim3 = top - zCombobox.getSelectedIndex();
- pcaModel.updateRcView(dim1, dim2, dim3);
- rc.img = null;
- rc.rotmat.setIdentity();
- rc.initAxes();
- rc.paint(rc.getGraphics());
+ int dim1 = getTop() - xCombobox.getSelectedIndex();
+ int dim2 = getTop() - yCombobox.getSelectedIndex();
+ int dim3 = getTop() - zCombobox.getSelectedIndex();
+ getPcaModel().updateRcView(dim1, dim2, dim3);
+ getRotatableCanvas().resetView();
}
/**
- * DOCUMENT ME!
+ * Sets the selected checkbox item index for PCA dimension (1, 2, 3...) for
+ * the given axis (X/Y/Z)
*
- * @param e
- * DOCUMENT ME!
+ * @param index
+ * @param axis
*/
- @Override
- protected void xCombobox_actionPerformed(ActionEvent e)
- {
- doDimensionChange();
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
- */
- @Override
- protected void yCombobox_actionPerformed(ActionEvent e)
+ public void setSelectedDimensionIndex(int index, Axis axis)
{
- doDimensionChange();
- }
-
- /**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
- */
- @Override
- protected void zCombobox_actionPerformed(ActionEvent e)
- {
- doDimensionChange();
+ switch (axis)
+ {
+ case X:
+ xCombobox.setSelectedIndex(index);
+ break;
+ case Y:
+ yCombobox.setSelectedIndex(index);
+ break;
+ case Z:
+ zCombobox.setSelectedIndex(index);
+ break;
+ default:
+ }
}
@Override
- public void outputValues_actionPerformed(ActionEvent e)
+ protected void outputValues_actionPerformed()
{
CutAndPasteTransfer cap = new CutAndPasteTransfer();
try
{
- cap.setText(pcaModel.getDetails());
+ cap.setText(getPcaModel().getDetails());
Desktop.addInternalFrame(cap,
MessageManager.getString("label.pca_details"), 500, 500);
} catch (OutOfMemoryError oom)
}
@Override
- public void showLabels_actionPerformed(ActionEvent e)
+ protected void showLabels_actionPerformed()
{
- rc.showLabels(showLabels.getState());
+ getRotatableCanvas().showLabels(showLabels.getState());
}
@Override
- public void print_actionPerformed(ActionEvent e)
+ protected void print_actionPerformed()
{
PCAPrinter printer = new PCAPrinter();
printer.start();
}
+ /**
+ * If available, shows the data which formed the inputs for the PCA as a new
+ * alignment
+ */
@Override
- public void originalSeqData_actionPerformed(ActionEvent e)
+ 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 (getPcaModel().getInputData() == null)
{
- jalview.bin.Cache.log
- .info("Unexpected call to originalSeqData_actionPerformed - should have hidden this menu action.");
+ 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[])
} catch (Exception ex)
{
}
- ;
- Object[] alAndColsel = pcaModel.getSeqtrings()
- .getAlignmentAndColumnSelection(gc);
+
+ Object[] alAndColsel = getPcaModel().getInputData()
+ .getAlignmentAndHiddenColumns(gc);
if (alAndColsel != null && alAndColsel[0] != null)
{
// AlignmentOrder origorder = new AlignmentOrder(alAndColsel[0]);
AlignmentI al = new Alignment((SequenceI[]) alAndColsel[0]);
- AlignmentI dataset = (av != null && av.getAlignment() != null) ? av
- .getAlignment().getDataset() : null;
+ AlignmentI dataset = (av != null && av.getAlignment() != null)
+ ? av.getAlignment().getDataset()
+ : null;
if (dataset != null)
{
al.setDataset(dataset);
if (true)
{
// make a new frame!
- AlignFrame af = new AlignFrame(al,
- (ColumnSelection) alAndColsel[1], AlignFrame.DEFAULT_WIDTH,
- AlignFrame.DEFAULT_HEIGHT);
+ AlignFrame af = new AlignFrame(al, (HiddenColumns) alAndColsel[1],
+ AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
// >>>This is a fix for the moment, until a better solution is
// found!!<<<
// msaorder);
Desktop.addInternalFrame(af, MessageManager.formatMessage(
- "label.original_data_for_params",
- new String[] { this.title }), AlignFrame.DEFAULT_WIDTH,
+ "label.original_data_for_params", new String[]
+ { this.title }), AlignFrame.DEFAULT_WIDTH,
AlignFrame.DEFAULT_HEIGHT);
}
}
public void run()
{
PrinterJob printJob = PrinterJob.getPrinterJob();
- PageFormat pf = printJob.pageDialog(printJob.defaultPage());
+ PageFormat defaultPage = printJob.defaultPage();
+ PageFormat pf = printJob.pageDialog(defaultPage);
+
+ if (defaultPage == pf)
+ {
+ /*
+ * user cancelled
+ */
+ return;
+ }
printJob.setPrintable(this, pf);
{
pg.translate((int) pf.getImageableX(), (int) pf.getImageableY());
- rc.drawBackground(pg, rc.bgColour);
- rc.drawScene(pg);
- if (rc.drawAxes == true)
+ getRotatableCanvas().drawBackground(pg);
+ getRotatableCanvas().drawScene(pg);
+ if (getRotatableCanvas().drawAxes)
{
- rc.drawAxes(pg);
+ getRotatableCanvas().drawAxes(pg);
}
if (pi == 0)
}
/**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
+ * Handler for 'Save as EPS' option
*/
@Override
- public void eps_actionPerformed(ActionEvent e)
+ protected void eps_actionPerformed()
{
- makePCAImage(jalview.util.ImageMaker.TYPE.EPS);
+ makePCAImage(ImageMaker.TYPE.EPS);
}
/**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
+ * Handler for 'Save as PNG' option
*/
@Override
- public void png_actionPerformed(ActionEvent e)
+ protected void png_actionPerformed()
{
- makePCAImage(jalview.util.ImageMaker.TYPE.PNG);
+ makePCAImage(ImageMaker.TYPE.PNG);
}
- void makePCAImage(jalview.util.ImageMaker.TYPE type)
+ void makePCAImage(ImageMaker.TYPE type)
{
- int width = rc.getWidth();
- int height = rc.getHeight();
-
- jalview.util.ImageMaker im;
-
- if (type == jalview.util.ImageMaker.TYPE.PNG)
- {
- im = new jalview.util.ImageMaker(this,
- jalview.util.ImageMaker.TYPE.PNG, "Make PNG image from PCA",
- width, height, null, null, null, 0, false);
- }
- else if (type == jalview.util.ImageMaker.TYPE.EPS)
- {
- im = new jalview.util.ImageMaker(this,
- jalview.util.ImageMaker.TYPE.EPS, "Make EPS file from PCA",
- width, height, null, this.getTitle(), null, 0, false);
- }
- else
- {
- im = new jalview.util.ImageMaker(this,
- jalview.util.ImageMaker.TYPE.SVG, "Make SVG file from PCA",
- width, height, null, this.getTitle(), null, 0, false);
-
+ int width = getRotatableCanvas().getWidth();
+ int height = getRotatableCanvas().getHeight();
+
+ ImageMaker im;
+
+ switch (type)
+ {
+ case PNG:
+ im = new ImageMaker(this, ImageMaker.TYPE.PNG,
+ "Make PNG image from PCA", width, height, null, null, null, 0,
+ false);
+ break;
+ case EPS:
+ im = new ImageMaker(this, ImageMaker.TYPE.EPS,
+ "Make EPS file from PCA", width, height, null,
+ this.getTitle(), null, 0, false);
+ 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.drawScene(im.getGraphics());
- if (rc.drawAxes == true)
+ getRotatableCanvas().drawBackground(im.getGraphics());
+ getRotatableCanvas().drawScene(im.getGraphics());
+ if (getRotatableCanvas().drawAxes)
{
- rc.drawAxes(im.getGraphics());
+ getRotatableCanvas().drawAxes(im.getGraphics());
}
im.writeImage();
}
}
@Override
- public void viewMenu_menuSelected()
+ protected void viewMenu_menuSelected()
{
buildAssociatedViewMenu();
}
+ /**
+ * Builds the menu showing the choice of possible views (for the associated
+ * sequence data) to which the PCA may be linked
+ */
void buildAssociatedViewMenu()
{
- AlignmentPanel[] aps = PaintRefresher.getAssociatedPanels(av
- .getSequenceSetId());
- if (aps.length == 1 && rc.av == aps[0].av)
+ AlignmentPanel[] aps = PaintRefresher
+ .getAssociatedPanels(av.getSequenceSetId());
+ if (aps.length == 1 && getRotatableCanvas().av == aps[0].av)
{
associateViewsMenu.setVisible(false);
return;
associateViewsMenu.setVisible(true);
- if ((viewMenu.getItem(viewMenu.getItemCount() - 2) instanceof JMenuItem))
+ if ((viewMenu
+ .getItem(viewMenu.getItemCount() - 2) instanceof JMenuItem))
{
viewMenu.insertSeparator(viewMenu.getItemCount() - 1);
}
JRadioButtonMenuItem item;
ButtonGroup buttonGroup = new ButtonGroup();
- int i, iSize = aps.length;
- final PCAPanel thisPCAPanel = this;
- for (i = 0; i < iSize; i++)
+ int iSize = aps.length;
+
+ for (int i = 0; i < iSize; i++)
{
- final AlignmentPanel ap = aps[i];
- item = new JRadioButtonMenuItem(ap.av.viewName, ap.av == rc.av);
+ final AlignmentPanel panel = aps[i];
+ item = new JRadioButtonMenuItem(panel.av.getViewName(),
+ panel.av == getRotatableCanvas().av);
buttonGroup.add(item);
item.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent evt)
{
- rc.applyToAllViews = false;
- rc.av = ap.av;
- rc.ap = ap;
- PaintRefresher.Register(thisPCAPanel, ap.av.getSequenceSetId());
+ selectAssociatedView(panel);
}
});
associateViewsMenu.add(item);
}
- final JRadioButtonMenuItem itemf = new JRadioButtonMenuItem("All Views");
+ final JRadioButtonMenuItem itemf = new JRadioButtonMenuItem(
+ "All Views");
buttonGroup.add(itemf);
- itemf.setSelected(rc.applyToAllViews);
+ itemf.setSelected(getRotatableCanvas().isApplyToAllViews());
itemf.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent evt)
{
- rc.applyToAllViews = itemf.isSelected();
+ getRotatableCanvas().setApplyToAllViews(itemf.isSelected());
}
});
associateViewsMenu.add(itemf);
* )
*/
@Override
- protected void outputPoints_actionPerformed(ActionEvent e)
+ protected void outputPoints_actionPerformed()
{
CutAndPasteTransfer cap = new CutAndPasteTransfer();
try
{
- cap.setText(pcaModel.getPointsasCsv(false,
+ cap.setText(getPcaModel().getPointsasCsv(false,
xCombobox.getSelectedIndex(), yCombobox.getSelectedIndex(),
zCombobox.getSelectedIndex()));
- Desktop.addInternalFrame(cap, MessageManager.formatMessage(
- "label.points_for_params", new String[] { this.getTitle() }),
- 500, 500);
+ Desktop.addInternalFrame(cap, MessageManager
+ .formatMessage("label.points_for_params", new String[]
+ { this.getTitle() }), 500, 500);
} catch (OutOfMemoryError oom)
{
new OOMWarning("exporting PCA points", oom);
* .ActionEvent)
*/
@Override
- protected void outputProjPoints_actionPerformed(ActionEvent e)
+ protected void outputProjPoints_actionPerformed()
{
CutAndPasteTransfer cap = new CutAndPasteTransfer();
try
{
- cap.setText(pcaModel.getPointsasCsv(true,
+ cap.setText(getPcaModel().getPointsasCsv(true,
xCombobox.getSelectedIndex(), yCombobox.getSelectedIndex(),
zCombobox.getSelectedIndex()));
Desktop.addInternalFrame(cap, MessageManager.formatMessage(
- "label.transformed_points_for_params",
- new String[] { this.getTitle() }), 500, 500);
+ "label.transformed_points_for_params", new String[]
+ { this.getTitle() }), 500, 500);
} catch (OutOfMemoryError oom)
{
new OOMWarning("exporting transformed PCA points", oom);
// }
//
// JPanel progressPanel;
- // Long lId = new Long(id);
+ // Long lId = Long.valueOf(id);
// GridLayout layout = (GridLayout) statusPanel.getLayout();
// if (progressBars.get(lId) != null)
// {
- // progressPanel = (JPanel) progressBars.get(new Long(id));
+ // progressPanel = (JPanel) progressBars.get(Long.valueOf(id));
// statusPanel.remove(progressPanel);
// progressBars.remove(lId);
// progressPanel = null;
final IProgressIndicatorHandler handler)
{
progressBar.registerHandler(id, handler);
- // if (progressBarHandlers == null || !progressBars.contains(new Long(id)))
+ // if (progressBarHandlers == null || !progressBars.contains(Long.valueOf(id)))
// {
// throw new
// Error(MessageManager.getString("error.call_setprogressbar_before_registering_handler"));
// }
- // progressBarHandlers.put(new Long(id), handler);
- // final JPanel progressPanel = (JPanel) progressBars.get(new Long(id));
+ // progressBarHandlers.put(Long.valueOf(id), handler);
+ // final JPanel progressPanel = (JPanel) progressBars.get(Long.valueOf(id));
// if (handler.canCancel())
// {
// JButton cancel = new JButton(
}
@Override
- protected void resetButton_actionPerformed(ActionEvent e)
+ protected void resetButton_actionPerformed()
{
- int t = top;
- top = 0; // ugly - prevents dimensionChanged events from being processed
+ int t = getTop();
+ setTop(0); // ugly - prevents dimensionChanged events from being processed
xCombobox.setSelectedIndex(0);
yCombobox.setSelectedIndex(1);
- top = t;
+ setTop(t);
zCombobox.setSelectedIndex(2);
}
/**
- * If the score model is one that requires to get state data from the current
- * view, allow it to do so
+ * Answers true if PCA calculation is in progress, else false
*
- * @param sm
* @return
*/
- protected ScoreModelI configureScoreModel(ScoreModelI sm)
+ public boolean isWorking()
{
- if (sm instanceof ViewBasedAnalysisI)
- {
- try
- {
- sm = sm.getClass().newInstance();
- ((ViewBasedAnalysisI) sm).configureFromAlignmentView(ap);
- } catch (Exception q)
- {
- Cache.log.error("Couldn't create a scoremodel instance for "
- + sm.getName());
- }
+ 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();
}
- return sm;
+ }
+
+ 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)
+ {
+ getPcaModel().setInputData(data);
+ originalSeqData.setVisible(data != null);
+ }
+
+ public AlignViewportI getAlignViewport()
+ {
+ return av;
+ }
+
+ public PCAModel getPcaModel()
+ {
+ return pcaModel;
+ }
+
+ public void setPcaModel(PCAModel pcaModel)
+ {
+ this.pcaModel = pcaModel;
+ }
+
+ public RotatableCanvas getRotatableCanvas()
+ {
+ return rc;
+ }
+
+ public void setRotatableCanvas(RotatableCanvas rc)
+ {
+ this.rc = rc;
+ }
+
+ public int getTop()
+ {
+ return top;
+ }
+
+ public void setTop(int top)
+ {
+ this.top = top;
+ }
+
+ /**
+ * set the associated view for this PCA.
+ *
+ * @param panel
+ */
+ public void selectAssociatedView(AlignmentPanel panel)
+ {
+ getRotatableCanvas().setApplyToAllViews(false);
+
+ ap = panel;
+ av = panel.av;
+
+ getRotatableCanvas().av = panel.av;
+ getRotatableCanvas().ap = panel;
+ PaintRefresher.Register(PCAPanel.this, panel.av.getSequenceSetId());
}
}