From dc70d08df6e45850e465c4d39e93c820b4ff8341 Mon Sep 17 00:00:00 2001 From: jprocter Date: Fri, 15 Jun 2012 17:52:58 +0100 Subject: [PATCH] formatting --- src/jalview/analysis/PCA.java | 26 ++++++++------- src/jalview/gui/PCAPanel.java | 73 ++++++++++++++++++++++++----------------- 2 files changed, 57 insertions(+), 42 deletions(-) diff --git a/src/jalview/analysis/PCA.java b/src/jalview/analysis/PCA.java index 4441eeb..f0b7f16 100755 --- a/src/jalview/analysis/PCA.java +++ b/src/jalview/analysis/PCA.java @@ -46,8 +46,9 @@ public class PCA implements Runnable StringBuffer details = new StringBuffer(); /** - * Creates a new PCA object. - * By default, uses blosum62 matrix to generate sequence similarity matrices + * Creates a new PCA object. By default, uses blosum62 matrix to generate + * sequence similarity matrices + * * @param s * Set of amino acid sequences to perform PCA on */ @@ -55,13 +56,16 @@ public class PCA implements Runnable { this(s, false); } - + /** - * Creates a new PCA object. - * By default, uses blosum62 matrix to generate sequence similarity matrices + * Creates a new PCA object. By default, uses blosum62 matrix to generate + * sequence similarity matrices + * * @param s * Set of sequences to perform PCA on - * @param nucleotides if true, uses standard DNA/RNA matrix for sequence similarity calculation. + * @param nucleotides + * if true, uses standard DNA/RNA matrix for sequence similarity + * calculation. */ public PCA(String[] s, boolean nucleotides) { @@ -71,7 +75,7 @@ public class PCA implements Runnable while ((ii < s.length) && (s[ii] != null)) { - bs[ii] = new BinarySequence(s[ii],nucleotides); + bs[ii] = new BinarySequence(s[ii], nucleotides); bs[ii].encode(); ii++; } @@ -79,10 +83,10 @@ public class PCA implements Runnable BinarySequence[] bs2 = new BinarySequence[s.length]; ii = 0; - String sm=nucleotides ? "DNA" : "BLOSUM62"; - ScoreMatrix smtrx=ResidueProperties.getScoreMatrix(sm); - details.append("PCA calculation using "+sm+" sequence similarity matrix\n========\n\n"); - + String sm = nucleotides ? "DNA" : "BLOSUM62"; + ScoreMatrix smtrx = ResidueProperties.getScoreMatrix(sm); + details.append("PCA calculation using " + sm + + " sequence similarity matrix\n========\n\n"); while ((ii < s.length) && (s[ii] != null)) { bs2[ii] = new BinarySequence(s[ii], nucleotides); diff --git a/src/jalview/gui/PCAPanel.java b/src/jalview/gui/PCAPanel.java index f951acf..ad7d1fd 100755 --- a/src/jalview/gui/PCAPanel.java +++ b/src/jalview/gui/PCAPanel.java @@ -35,17 +35,19 @@ import jalview.viewmodel.PCAModel; * @author $author$ * @version $Revision$ */ -public class PCAPanel extends GPCAPanel implements Runnable, IProgressIndicator +public class PCAPanel extends GPCAPanel implements Runnable, + IProgressIndicator { - RotatableCanvas rc; AlignmentPanel ap; AlignViewport av; + PCAModel pcaModel; - int top=0; + + int top = 0; /** * Creates a new PCAPanel object. @@ -62,8 +64,9 @@ public class PCAPanel extends GPCAPanel implements Runnable, IProgressIndicator boolean sameLength = true; - AlignmentView seqstrings = av.getAlignmentView(av.getSelectionGroup() != null); - boolean nucleotide=av.getAlignment().isNucleotide(); + AlignmentView seqstrings = av + .getAlignmentView(av.getSelectionGroup() != null); + boolean nucleotide = av.getAlignment().isNucleotide(); SequenceI[] seqs; if (av.getSelectionGroup() == null) { @@ -99,7 +102,7 @@ public class PCAPanel extends GPCAPanel implements Runnable, IProgressIndicator } pcaModel = new PCAModel(seqstrings, seqs, nucleotide); PaintRefresher.Register(this, av.getSequenceSetId()); - + rc = new RotatableCanvas(ap); this.getContentPane().add(rc, BorderLayout.CENTER); Thread worker = new Thread(this); @@ -123,11 +126,12 @@ public class PCAPanel extends GPCAPanel implements Runnable, IProgressIndicator */ public void run() { - long progId=System.currentTimeMillis(); - IProgressIndicator progress=this; - String message="Recalculating PCA"; - if (getParent()==null) { - progress=ap.alignFrame; + long progId = System.currentTimeMillis(); + IProgressIndicator progress = this; + String message = "Recalculating PCA"; + if (getParent() == null) + { + progress = ap.alignFrame; message = "Calculating PCA"; } progress.setProgressBar(message, progId); @@ -139,45 +143,48 @@ public class PCAPanel extends GPCAPanel implements Runnable, IProgressIndicator xCombobox.setSelectedIndex(0); yCombobox.setSelectedIndex(1); zCombobox.setSelectedIndex(2); - + pcaModel.updateRc(rc); // rc.invalidate(); nuclSetting.setSelected(pcaModel.isNucleotide()); protSetting.setSelected(!pcaModel.isNucleotide()); - top=pcaModel.getTop(); jvVersionSetting.setSelected(pcaModel.isJvCalcMode()); + top = pcaModel.getTop(); } catch (OutOfMemoryError er) { new OOMWarning("calculating PCA", er); return; - } - finally { + } finally + { progress.setProgressBar("", progId); } calcSettings.setEnabled(true); repaint(); - if (getParent()==null) + if (getParent() == null) { addKeyListener(rc); - Desktop.addInternalFrame(this, "Principal component analysis", 475, 450); + Desktop.addInternalFrame(this, "Principal component analysis", 475, + 450); } } + @Override protected void nuclSetting_actionPerfomed(ActionEvent arg0) { if (!pcaModel.isNucleotide()) { pcaModel.setNucleotide(true); - Thread worker = new Thread(this); - worker.start(); + Thread worker = new Thread(this); + worker.start(); } - + } + @Override protected void protSetting_actionPerfomed(ActionEvent arg0) { - + if (pcaModel.isNucleotide()) { pcaModel.setNucleotide(false); @@ -298,7 +305,8 @@ public class PCAPanel extends GPCAPanel implements Runnable, IProgressIndicator { } ; - Object[] alAndColsel = pcaModel.getSeqtrings().getAlignmentAndColumnSelection(gc); + Object[] alAndColsel = pcaModel.getSeqtrings() + .getAlignmentAndColumnSelection(gc); if (alAndColsel != null && alAndColsel[0] != null) { @@ -512,7 +520,9 @@ public class PCAPanel extends GPCAPanel implements Runnable, IProgressIndicator CutAndPasteTransfer cap = new CutAndPasteTransfer(); try { - cap.setText(pcaModel.getPointsasCsv(false, xCombobox.getSelectedIndex(), yCombobox.getSelectedIndex(), zCombobox.getSelectedIndex())); + cap.setText(pcaModel.getPointsasCsv(false, + xCombobox.getSelectedIndex(), yCombobox.getSelectedIndex(), + zCombobox.getSelectedIndex())); Desktop.addInternalFrame(cap, "Points for " + getTitle(), 500, 500); } catch (OutOfMemoryError oom) { @@ -521,8 +531,6 @@ public class PCAPanel extends GPCAPanel implements Runnable, IProgressIndicator } } - - /* * (non-Javadoc) * @@ -535,7 +543,9 @@ public class PCAPanel extends GPCAPanel implements Runnable, IProgressIndicator CutAndPasteTransfer cap = new CutAndPasteTransfer(); try { - cap.setText(pcaModel.getPointsasCsv(true, xCombobox.getSelectedIndex(), yCombobox.getSelectedIndex(), zCombobox.getSelectedIndex())); + cap.setText(pcaModel.getPointsasCsv(true, + xCombobox.getSelectedIndex(), yCombobox.getSelectedIndex(), + zCombobox.getSelectedIndex())); Desktop.addInternalFrame(cap, "Transformed points for " + getTitle(), 500, 500); } catch (OutOfMemoryError oom) @@ -551,7 +561,7 @@ public class PCAPanel extends GPCAPanel implements Runnable, IProgressIndicator /* * (non-Javadoc) - * + * * @see jalview.gui.IProgressIndicator#setProgressBar(java.lang.String, long) */ @Override @@ -635,7 +645,7 @@ public class PCAPanel extends GPCAPanel implements Runnable, IProgressIndicator } /** - * + * * @return true if any progress bars are still active */ @Override @@ -647,14 +657,15 @@ public class PCAPanel extends GPCAPanel implements Runnable, IProgressIndicator } return false; } + @Override protected void resetButton_actionPerformed(ActionEvent e) { - int t=top; - top=0; // ugly - prevents dimensionChanged events from being processed + int t = top; + top = 0; // ugly - prevents dimensionChanged events from being processed xCombobox.setSelectedIndex(0); yCombobox.setSelectedIndex(1); - top=t; + top = t; zCombobox.setSelectedIndex(2); } } -- 1.7.10.2