001/* 002 * PDB web development code 003 * 004 * This code may be freely distributed and modified under the 005 * terms of the GNU Lesser General Public Licence. This should 006 * be distributed with the code. If you do not have a copy, 007 * see: 008 * 009 * http://www.gnu.org/copyleft/lesser.html 010 * 011 * Copyright for this code is held jointly by the individual 012 * authors. These should be listed in @author doc comments. 013 * 014 * 015 * Created on Jul 28, 2009 016 * Created by ap3 017 * 018 */ 019 020package org.biojava.nbio.structure.align.gui; 021 022import org.biojava.nbio.structure.align.gui.jmol.AbstractAlignmentJmol; 023import org.biojava.nbio.structure.gui.ScaleableMatrixPanel; 024import org.biojava.nbio.structure.jama.Matrix; 025 026import javax.swing.*; 027 028import java.awt.event.ActionEvent; 029import java.awt.event.ActionListener; 030import java.awt.event.WindowAdapter; 031import java.awt.event.WindowEvent; 032 033/** 034 * Shows the interatomic Distance Matrices of all the Structures aligned in different Frames. 035 */ 036public class MyDistMaxListener implements ActionListener{ 037 038 AbstractAlignmentJmol parent; 039 040 public MyDistMaxListener(AbstractAlignmentJmol parent){ 041 this.parent = parent; 042 } 043 044 @Override 045 public void actionPerformed(ActionEvent a) { 046 047 System.out.println("Show interatomic Distance Matrices"); 048 049 if (parent.getDistanceMatrices() == null) { 050 System.err.println("Not displaying any alignment currently!"); 051 return; 052 } 053 for (int i=0; i<parent.getDistanceMatrices().size(); i++){ 054 if (parent.getDistanceMatrices().get(i)!=null) 055 showMatrix(parent.getDistanceMatrices().get(i), "Internal Distances for Structure "+(i+1)); 056 } 057 } 058 059 private void showMatrix(Matrix m, String title){ 060 ScaleableMatrixPanel smp = new ScaleableMatrixPanel(); 061 JFrame frame = new JFrame(title); 062 frame.addWindowListener(new WindowAdapter(){ 063 @Override 064 public void windowClosing(WindowEvent e){ 065 JFrame f = (JFrame) e.getSource(); 066 f.setVisible(false); 067 f.dispose(); 068 } 069 }); 070 071 smp.setMatrix(m); 072 frame.getContentPane().add(smp); 073 frame.pack(); 074 frame.setVisible(true); 075 } 076}