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;
private static final int MIN_HEIGHT = 250;
- private RotatableCanvas rc;
+ RotatableCanvas rc;
AlignmentPanel ap;
addKeyListener(getRotatableCanvas());
validate();
-
- this.setMinimumSize(new Dimension(MIN_WIDTH, MIN_HEIGHT));
}
/**
@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;
}
}
}
- /**
- * 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)
+ ImageWriterI writer = new ImageWriterI()
{
- 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)
- {
- 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
}
- /*
- * (non-Javadoc)
- *
- * @see
- * jalview.jbgui.GPCAPanel#outputPoints_actionPerformed(java.awt.event.ActionEvent
- * )
- */
@Override
protected void outputPoints_actionPerformed()
{
}
}
- /*
- * (non-Javadoc)
- *
- * @see
- * jalview.jbgui.GPCAPanel#outputProjPoints_actionPerformed(java.awt.event
- * .ActionEvent)
- */
@Override
protected void outputProjPoints_actionPerformed()
{
}
}
- /*
- * (non-Javadoc)
- *
- * @see jalview.gui.IProgressIndicator#setProgressBar(java.lang.String, long)
- */
@Override
public void setProgressBar(String message, long id)
{
progressBar.setProgressBar(message, id);
- // if (progressBars == null)
- // {
- // progressBars = new Hashtable();
- // progressBarHandlers = new Hashtable();
- // }
- //
- // JPanel progressPanel;
- // Long lId = new Long(id);
- // GridLayout layout = (GridLayout) statusPanel.getLayout();
- // if (progressBars.get(lId) != null)
- // {
- // progressPanel = (JPanel) progressBars.get(new Long(id));
- // statusPanel.remove(progressPanel);
- // progressBars.remove(lId);
- // progressPanel = null;
- // if (message != null)
- // {
- // statusBar.setText(message);
- // }
- // if (progressBarHandlers.contains(lId))
- // {
- // progressBarHandlers.remove(lId);
- // }
- // layout.setRows(layout.getRows() - 1);
- // }
- // else
- // {
- // progressPanel = new JPanel(new BorderLayout(10, 5));
- //
- // JProgressBar progressBar = new JProgressBar();
- // progressBar.setIndeterminate(true);
- //
- // progressPanel.add(new JLabel(message), BorderLayout.WEST);
- // progressPanel.add(progressBar, BorderLayout.CENTER);
- //
- // layout.setRows(layout.getRows() + 1);
- // statusPanel.add(progressPanel);
- //
- // progressBars.put(lId, progressPanel);
- // }
- // // update GUI
- // // setMenusForViewport();
- // validate();
}
@Override
final IProgressIndicatorHandler handler)
{
progressBar.registerHandler(id, handler);
- // if (progressBarHandlers == null || !progressBars.contains(new Long(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));
- // if (handler.canCancel())
- // {
- // JButton cancel = new JButton(
- // MessageManager.getString("action.cancel"));
- // final IProgressIndicator us = this;
- // cancel.addActionListener(new ActionListener()
- // {
- //
- // @Override
- // public void actionPerformed(ActionEvent e)
- // {
- // handler.cancelActivity(id);
- // us.setProgressBar(MessageManager.formatMessage("label.cancelled_params",
- // new String[]{((JLabel) progressPanel.getComponent(0)).getText()}), id);
- // }
- // });
- // progressPanel.add(cancel, BorderLayout.EAST);
- // }
}
/**