X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FPCAPanel.java;h=d2d6a985812feb0a847c2fe522424136af5b39cc;hb=70fd4c40d0b2046c6d402e365e4d04f9cfbb68ef;hp=133c0ce022a2c5818c5ec95ddc9768f2ff8f234f;hpb=009f48028c4101e697dab0952ad81fccf26fc915;p=jalview.git diff --git a/src/jalview/gui/PCAPanel.java b/src/jalview/gui/PCAPanel.java index 133c0ce..d2d6a98 100644 --- a/src/jalview/gui/PCAPanel.java +++ b/src/jalview/gui/PCAPanel.java @@ -1,36 +1,58 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.1) + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2) * Copyright (C) 2014 The Jalview Authors * * This file is part of Jalview. * * Jalview is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. * * Jalview is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with Jalview. If not, see . + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . * The Jalview Authors are detailed in the 'AUTHORS' file. */ package jalview.gui; -import java.util.*; -import java.awt.*; -import java.awt.event.*; -import java.awt.print.*; - -import javax.swing.*; - -import jalview.datamodel.*; -import jalview.jbgui.*; +import jalview.datamodel.Alignment; +import jalview.datamodel.AlignmentView; +import jalview.datamodel.ColumnSelection; +import jalview.datamodel.SeqCigar; +import jalview.datamodel.SequenceI; +import jalview.jbgui.GPCAPanel; import jalview.schemes.ResidueProperties; import jalview.util.MessageManager; import jalview.viewmodel.PCAModel; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Graphics; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.print.PageFormat; +import java.awt.print.Printable; +import java.awt.print.PrinterException; +import java.awt.print.PrinterJob; +import java.util.Hashtable; + +import javax.swing.ButtonGroup; +import javax.swing.JButton; +import javax.swing.JCheckBoxMenuItem; +import javax.swing.JColorChooser; +import javax.swing.JLabel; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.JRadioButtonMenuItem; + /** * DOCUMENT ME! * @@ -95,10 +117,8 @@ public class PCAPanel extends GPCAPanel implements Runnable, JOptionPane .showMessageDialog( Desktop.desktop, - "The sequences must be aligned before calculating PCA.\n" - + "Try using the Pad function in the edit menu,\n" - + "or one of the multiple sequence alignment web services.", - "Sequences not aligned", JOptionPane.WARNING_MESSAGE); + MessageManager.getString("label.pca_sequences_not_aligned"), + MessageManager.getString("label.sequences_not_aligned"), JOptionPane.WARNING_MESSAGE); return; } @@ -110,11 +130,12 @@ public class PCAPanel extends GPCAPanel implements Runnable, Thread worker = new Thread(this); worker.start(); } + @Override protected void scoreMatrix_menuSelected() { scoreMatrixMenu.removeAll(); - for (final String sm:ResidueProperties.scoreMatrices.keySet()) + for (final String sm : ResidueProperties.scoreMatrices.keySet()) { if (ResidueProperties.getScoreMatrix(sm) != null) { @@ -134,9 +155,9 @@ public class PCAPanel extends GPCAPanel implements Runnable, @Override public void actionPerformed(ActionEvent e) { - if (!pcaModel.getScore_matrix().equals((String) sm)) + if (!pcaModel.getScore_matrix().equals(sm)) { - pcaModel.setScore_matrix((String) sm); + pcaModel.setScore_matrix(sm); Thread worker = new Thread(us); worker.start(); } @@ -147,9 +168,10 @@ public class PCAPanel extends GPCAPanel implements Runnable, } } } + public void bgcolour_actionPerformed(ActionEvent e) { - Color col = JColorChooser.showDialog(this, "Select Background Colour", + Color col = JColorChooser.showDialog(this, MessageManager.getString("label.select_backgroud_colour"), rc.bgColour); if (col != null) @@ -166,11 +188,11 @@ public class PCAPanel extends GPCAPanel implements Runnable, { long progId = System.currentTimeMillis(); IProgressIndicator progress = this; - String message = "Recalculating PCA"; + String message = MessageManager.getString("label.pca_recalculating"); if (getParent() == null) { progress = ap.alignFrame; - message = "Calculating PCA"; + message = MessageManager.getString("label.pca_calculating"); } progress.setProgressBar(message, progId); try @@ -202,8 +224,8 @@ public class PCAPanel extends GPCAPanel implements Runnable, if (getParent() == null) { addKeyListener(rc); - Desktop.addInternalFrame(this, MessageManager.getString("label.principal_component_analysis"), 475, - 450); + Desktop.addInternalFrame(this, MessageManager + .getString("label.principal_component_analysis"), 475, 450); } } @@ -300,7 +322,8 @@ public class PCAPanel extends GPCAPanel implements Runnable, try { cap.setText(pcaModel.getDetails()); - Desktop.addInternalFrame(cap, MessageManager.getString("label.pca_details"), 500, 500); + Desktop.addInternalFrame(cap, + MessageManager.getString("label.pca_details"), 500, 500); } catch (OutOfMemoryError oom) { new OOMWarning("opening PCA details", oom); @@ -374,8 +397,10 @@ public class PCAPanel extends GPCAPanel implements Runnable, // af.addSortByOrderMenuItem(ServiceName + " Ordering", // msaorder); - Desktop.addInternalFrame(af, MessageManager.formatMessage("label.original_data_for_params", new String[]{this.title}), - AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT); + Desktop.addInternalFrame(af, MessageManager.formatMessage( + "label.original_data_for_params", new String[] + { this.title }), AlignFrame.DEFAULT_WIDTH, + AlignFrame.DEFAULT_HEIGHT); } } /* @@ -440,7 +465,7 @@ public class PCAPanel extends GPCAPanel implements Runnable, */ public void eps_actionPerformed(ActionEvent e) { - makePCAImage(jalview.util.ImageMaker.EPS); + makePCAImage(jalview.util.ImageMaker.TYPE.EPS); } /** @@ -451,27 +476,36 @@ public class PCAPanel extends GPCAPanel implements Runnable, */ public void png_actionPerformed(ActionEvent e) { - makePCAImage(jalview.util.ImageMaker.PNG); + makePCAImage(jalview.util.ImageMaker.TYPE.PNG); } - void makePCAImage(int type) + void makePCAImage(jalview.util.ImageMaker.TYPE type) { int width = rc.getWidth(); int height = rc.getHeight(); jalview.util.ImageMaker im; - if (type == jalview.util.ImageMaker.PNG) + if (type == jalview.util.ImageMaker.TYPE.PNG) { - im = new jalview.util.ImageMaker(this, jalview.util.ImageMaker.PNG, + im = new jalview.util.ImageMaker(this, + jalview.util.ImageMaker.TYPE.PNG, "Make PNG image from PCA", width, height, null, null); } - else + else if (type == jalview.util.ImageMaker.TYPE.EPS) { - im = new jalview.util.ImageMaker(this, jalview.util.ImageMaker.EPS, + im = new jalview.util.ImageMaker(this, + jalview.util.ImageMaker.TYPE.EPS, "Make EPS file from PCA", width, height, null, this.getTitle()); } + else + { + im = new jalview.util.ImageMaker(this, + jalview.util.ImageMaker.TYPE.SVG, "Make SVG file from PCA", + width, height, null, this.getTitle()); + + } if (im.getGraphics() != null) { @@ -485,7 +519,6 @@ public class PCAPanel extends GPCAPanel implements Runnable, } } - public void viewMenu_menuSelected() { buildAssociatedViewMenu(); @@ -564,7 +597,9 @@ public class PCAPanel extends GPCAPanel implements Runnable, cap.setText(pcaModel.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); @@ -587,8 +622,9 @@ public class PCAPanel extends GPCAPanel implements Runnable, cap.setText(pcaModel.getPointsasCsv(true, xCombobox.getSelectedIndex(), yCombobox.getSelectedIndex(), zCombobox.getSelectedIndex())); - Desktop.addInternalFrame(cap, MessageManager.formatMessage("label.transformed_points_for_params", new String[]{this.getTitle()}), - 500, 500); + Desktop.addInternalFrame(cap, MessageManager.formatMessage( + "label.transformed_points_for_params", new String[] + { this.getTitle() }), 500, 500); } catch (OutOfMemoryError oom) { new OOMWarning("exporting transformed PCA points", oom); @@ -659,14 +695,14 @@ public class PCAPanel extends GPCAPanel implements Runnable, { if (progressBarHandlers == null || !progressBars.contains(new Long(id))) { - throw new Error( - "call setProgressBar before registering the progress bar's handler."); + 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)); if (handler.canCancel()) { - JButton cancel = new JButton(MessageManager.getString("action.cancel")); + JButton cancel = new JButton( + MessageManager.getString("action.cancel")); final IProgressIndicator us = this; cancel.addActionListener(new ActionListener() { @@ -675,10 +711,7 @@ public class PCAPanel extends GPCAPanel implements Runnable, public void actionPerformed(ActionEvent e) { handler.cancelActivity(id); - us.setProgressBar( - "Cancelled " - + ((JLabel) progressPanel.getComponent(0)) - .getText(), id); + us.setProgressBar(MessageManager.formatMessage("label.cancelled_params", new String[]{((JLabel) progressPanel.getComponent(0)).getText()}), id); } }); progressPanel.add(cancel, BorderLayout.EAST);