userColourSchemes = UserDefinedColours
.getUserColourSchemes();
if (userColourSchemes != null)
{
for (String userColour : userColourSchemes.keySet())
{
final JRadioButtonMenuItem radioItem = new JRadioButtonMenuItem(
userColour);
radioItem.setName("USER_DEFINED");
radioItem.addMouseListener(new MouseAdapter()
{
@Override
public void mousePressed(MouseEvent evt)
{
if (evt.isPopupTrigger()) // Mac
{
offerRemoval(radioItem);
}
}
@Override
public void mouseReleased(MouseEvent evt)
{
if (evt.isPopupTrigger()) // Windows
{
offerRemoval(radioItem);
}
}
/**
* @param radioItem
*/
void offerRemoval(final JRadioButtonMenuItem radioItem)
{
radioItem.removeActionListener(radioItem.getActionListeners()[0]);
int option = JvOptionPane.showInternalConfirmDialog(
jalview.gui.Desktop.desktop, MessageManager
.getString("label.remove_from_default_list"),
MessageManager
.getString("label.remove_user_defined_colour"),
JvOptionPane.YES_NO_OPTION);
if (option == JvOptionPane.YES_OPTION)
{
jalview.gui.UserDefinedColours
.removeColourFromDefaults(radioItem.getText());
coloursMenu.remove(radioItem);
}
else
{
radioItem.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent evt)
{
user_actionPerformed(evt);
}
});
}
}
});
radioItem.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent evt)
{
user_actionPerformed(evt);
}
});
coloursMenu.add(radioItem);
bg.add(radioItem);
}
}
viewMenu.add(wire);
viewMenu.add(depth);
viewMenu.add(zbuffer);
viewMenu.add(allchains);
}
JMenuBar jMenuBar1 = new JMenuBar();
JMenu fileMenu = new JMenu();
JMenu coloursMenu = new JMenu();
JMenu saveMenu = new JMenu();
JMenuItem png = new JMenuItem();
JMenuItem eps = new JMenuItem();
JMenuItem mapping = new JMenuItem();
JCheckBoxMenuItem wire = new JCheckBoxMenuItem();
JCheckBoxMenuItem depth = new JCheckBoxMenuItem();
JCheckBoxMenuItem zbuffer = new JCheckBoxMenuItem();
JCheckBoxMenuItem allchains = new JCheckBoxMenuItem();
JRadioButtonMenuItem charge = new JRadioButtonMenuItem();
JRadioButtonMenuItem chain = new JRadioButtonMenuItem();
JRadioButtonMenuItem seqButton = new JRadioButtonMenuItem();
JRadioButtonMenuItem hydro = new JRadioButtonMenuItem();
JRadioButtonMenuItem taylor = new JRadioButtonMenuItem();
JRadioButtonMenuItem zappo = new JRadioButtonMenuItem();
JRadioButtonMenuItem user = new JRadioButtonMenuItem();
JRadioButtonMenuItem buried = new JRadioButtonMenuItem();
JRadioButtonMenuItem turn = new JRadioButtonMenuItem();
JRadioButtonMenuItem strand = new JRadioButtonMenuItem();
JRadioButtonMenuItem helix = new JRadioButtonMenuItem();
JMenu viewMenu = new JMenu();
JMenuItem background = new JMenuItem();
JMenuItem savePDB = new JMenuItem();
/**
* DOCUMENT ME!
*
* @param e
* DOCUMENT ME!
*/
public void eps_actionPerformed(ActionEvent e)
{
makePDBImage(jalview.util.ImageMaker.TYPE.EPS);
}
/**
* DOCUMENT ME!
*
* @param e
* DOCUMENT ME!
*/
public void png_actionPerformed(ActionEvent e)
{
makePDBImage(jalview.util.ImageMaker.TYPE.PNG);
}
void makePDBImage(jalview.util.ImageMaker.TYPE type)
{
int width = pdbcanvas.getWidth();
int height = pdbcanvas.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 view",
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 view",
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);
}
if (im.getGraphics() != null)
{
pdbcanvas.drawAll(im.getGraphics(), width, height);
im.writeImage();
}
}
public void charge_actionPerformed(ActionEvent e)
{
pdbcanvas.bysequence = false;
pdbcanvas.pdb.setChargeColours();
pdbcanvas.redrawneeded = true;
pdbcanvas.repaint();
}
public void hydro_actionPerformed(ActionEvent e)
{
pdbcanvas.bysequence = false;
pdbcanvas.pdb.setColours(new HydrophobicColourScheme());
pdbcanvas.redrawneeded = true;
pdbcanvas.repaint();
}
public void chain_actionPerformed(ActionEvent e)
{
pdbcanvas.bysequence = false;
pdbcanvas.pdb.setChainColours();
pdbcanvas.redrawneeded = true;
pdbcanvas.repaint();
}
public void zbuffer_actionPerformed(ActionEvent e)
{
pdbcanvas.zbuffer = !pdbcanvas.zbuffer;
pdbcanvas.redrawneeded = true;
pdbcanvas.repaint();
}
public void molecule_actionPerformed(ActionEvent e)
{
pdbcanvas.bymolecule = !pdbcanvas.bymolecule;
pdbcanvas.redrawneeded = true;
pdbcanvas.repaint();
}
public void depth_actionPerformed(ActionEvent e)
{
pdbcanvas.depthcue = !pdbcanvas.depthcue;
pdbcanvas.redrawneeded = true;
pdbcanvas.repaint();
}
public void wire_actionPerformed(ActionEvent e)
{
pdbcanvas.wire = !pdbcanvas.wire;
pdbcanvas.redrawneeded = true;
pdbcanvas.repaint();
}
public void seqButton_actionPerformed(ActionEvent e)
{
pdbcanvas.bysequence = true;
pdbcanvas.updateSeqColours();
}
public void mapping_actionPerformed(ActionEvent e)
{
jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();
try
{
cap.setText(pdbcanvas.mappingDetails.toString());
Desktop.addInternalFrame(cap,
MessageManager.getString("label.pdb_sequence_mapping"), 550,
600);
} catch (OutOfMemoryError oom)
{
new OOMWarning("Opening sequence to structure mapping report", oom);
cap.dispose();
}
}
public void allchains_itemStateChanged(ItemEvent e)
{
pdbcanvas.setAllchainsVisible(allchains.getState());
}
public void zappo_actionPerformed(ActionEvent e)
{
pdbcanvas.bysequence = false;
pdbcanvas.pdb.setColours(new ZappoColourScheme());
pdbcanvas.redrawneeded = true;
pdbcanvas.repaint();
}
public void taylor_actionPerformed(ActionEvent e)
{
pdbcanvas.bysequence = false;
pdbcanvas.pdb.setColours(new TaylorColourScheme());
pdbcanvas.redrawneeded = true;
pdbcanvas.repaint();
}
public void helix_actionPerformed(ActionEvent e)
{
pdbcanvas.bysequence = false;
pdbcanvas.pdb.setColours(new HelixColourScheme());
pdbcanvas.redrawneeded = true;
pdbcanvas.repaint();
}
public void strand_actionPerformed(ActionEvent e)
{
pdbcanvas.bysequence = false;
pdbcanvas.pdb.setColours(new StrandColourScheme());
pdbcanvas.redrawneeded = true;
pdbcanvas.repaint();
}
public void turn_actionPerformed(ActionEvent e)
{
pdbcanvas.bysequence = false;
pdbcanvas.pdb.setColours(new TurnColourScheme());
pdbcanvas.redrawneeded = true;
pdbcanvas.repaint();
}
public void buried_actionPerformed(ActionEvent e)
{
pdbcanvas.bysequence = false;
pdbcanvas.pdb.setColours(new BuriedColourScheme());
pdbcanvas.redrawneeded = true;
pdbcanvas.repaint();
}
public void user_actionPerformed(ActionEvent e)
{
if (e.getActionCommand().equals(
MessageManager.getString("action.user_defined")))
{
// new UserDefinedColours(pdbcanvas, null);
}
else
{
UserColourScheme udc = UserDefinedColours
.getUserColourSchemes().get(e.getActionCommand());
pdbcanvas.pdb.setColours(udc);
pdbcanvas.redrawneeded = true;
pdbcanvas.repaint();
}
}
public void background_actionPerformed(ActionEvent e)
{
Color col = JColorChooser.showDialog(this,
MessageManager.getString("label.select_background_colour"),
pdbcanvas.backgroundColour);
if (col != null)
{
pdbcanvas.backgroundColour = col;
pdbcanvas.redrawneeded = true;
pdbcanvas.repaint();
}
}
public void savePDB_actionPerformed(ActionEvent e)
{
JalviewFileChooser chooser = new JalviewFileChooser(
jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle(MessageManager.getString("label.save_pdb_file"));
chooser.setToolTipText(MessageManager.getString("action.save"));
int value = chooser.showSaveDialog(this);
if (value == JalviewFileChooser.APPROVE_OPTION)
{
try
{
BufferedReader in = new BufferedReader(new FileReader(tmpPDBFile));
File outFile = chooser.getSelectedFile();
PrintWriter out = new PrintWriter(new FileOutputStream(outFile));
String data;
while ((data = in.readLine()) != null)
{
if (!(data.indexOf("") > -1 || data.indexOf("
") > -1))
{
out.println(data);
}
}
out.close();
in.close();
} catch (Exception ex)
{
ex.printStackTrace();
}
}
}
}