import jalview.api.AlignViewportI;
import jalview.api.analysis.ScoreModelI;
import jalview.api.analysis.SimilarityParamsI;
-import jalview.bin.Cache;
+import jalview.bin.Console;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AlignmentView;
import jalview.datamodel.HiddenColumns;
import jalview.datamodel.SequenceI;
+import jalview.gui.ImageExporter.ImageWriterI;
+import jalview.gui.JalviewColourChooser.ColourChooserListener;
import jalview.jbgui.GPCAPanel;
import jalview.math.RotatableMatrix.Axis;
import jalview.util.ImageMaker;
import java.awt.print.PrinterJob;
import javax.swing.ButtonGroup;
-import javax.swing.JColorChooser;
import javax.swing.JMenuItem;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.event.InternalFrameAdapter;
ScoreModelI scoreModel = ScoreModels.getInstance()
.getScoreModel(modelName, ap);
- setPcaModel(new PCAModel(seqstrings, seqs, nucleotide, scoreModel,
- params));
+ setPcaModel(
+ new PCAModel(seqstrings, seqs, nucleotide, scoreModel, params));
PaintRefresher.Register(this, av.getSequenceSetId());
setRotatableCanvas(new RotatableCanvas(alignPanel));
addKeyListener(getRotatableCanvas());
validate();
-
- this.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT));
}
/**
protected void close_actionPerformed()
{
setPcaModel(null);
+ if (this.rc != null)
+ {
+ this.rc.sequencePoints = null;
+ this.rc.setAxisEndPoints(null);
+ this.rc = null;
+ }
}
@Override
protected void bgcolour_actionPerformed()
{
- Color col = JColorChooser.showDialog(this,
- MessageManager.getString("label.select_background_colour"),
- getRotatableCanvas().getBgColour());
-
- if (col != null)
+ String ttl = MessageManager.getString("label.select_background_colour");
+ ColourChooserListener listener = new ColourChooserListener()
{
- getRotatableCanvas().setBgColour(col);
- }
- getRotatableCanvas().repaint();
+ @Override
+ public void colourSelected(Color c)
+ {
+ rc.setBgColour(c);
+ rc.repaint();
+ }
+ };
+ JalviewColourChooser.showColourChooser(this, ttl, rc.getBgColour(),
+ listener);
}
/**
MessageManager.formatMessage("label.calc_title", "PCA",
getPcaModel().getScoreModelName()),
475, 450);
+ this.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT));
}
working = false;
}
// JAL-2647 disabled after load from project (until save to project done)
if (getPcaModel().getInputData() == null)
{
- Cache.log.info(
+ Console.info(
"Unexpected call to originalSeqData_actionPerformed - should have hidden this menu action.");
return;
}
}
}
- /**
- * Handler for 'Save as EPS' option
- */
- @Override
- protected void eps_actionPerformed()
- {
- makePCAImage(ImageMaker.TYPE.EPS);
- }
-
- /**
- * Handler for 'Save as PNG' option
- */
- @Override
- protected void png_actionPerformed()
- {
- makePCAImage(ImageMaker.TYPE.PNG);
- }
-
- void makePCAImage(ImageMaker.TYPE type)
+ public void makePCAImage(ImageMaker.TYPE type)
{
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)
+ ImageWriterI writer = new ImageWriterI()
{
- getRotatableCanvas().drawBackground(im.getGraphics());
- getRotatableCanvas().drawScene(im.getGraphics());
- if (getRotatableCanvas().drawAxes)
+ @Override
+ public void exportImage(Graphics g) throws Exception
{
- getRotatableCanvas().drawAxes(im.getGraphics());
+ RotatableCanvas canvas = getRotatableCanvas();
+ canvas.drawBackground(g);
+ canvas.drawScene(g);
+ if (canvas.drawAxes)
+ {
+ canvas.drawAxes(g);
+ }
}
- im.writeImage();
- }
+ };
+ String pca = MessageManager.getString("label.pca");
+ ImageExporter exporter = new ImageExporter(writer, null, type, pca);
+ exporter.doExport(null, this, width, height, pca);
}
@Override
// }
//
// 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(