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 21, 2009
016 * Created by ap3
017 *
018 */
019
020package org.biojava.nbio.structure.align.gui;
021
022import org.biojava.nbio.structure.align.StructureAlignment;
023import org.biojava.nbio.structure.align.StructureAlignmentFactory;
024import org.biojava.nbio.structure.align.util.ResourceManager;
025import org.biojava.nbio.structure.align.webstart.BrowserOpener;
026
027import javax.swing.*;
028import javax.swing.event.HyperlinkEvent;
029import javax.swing.event.HyperlinkListener;
030import java.awt.*;
031import java.awt.event.ActionEvent;
032import java.awt.event.ActionListener;
033
034public class AboutDialog
035{
036        Box vBox;
037        public AboutDialog(){
038
039        }
040
041        public void showDialog(){
042                JDialog dialog = new JDialog();
043
044                dialog.setSize(new Dimension(500,650));
045
046                ResourceManager mgr = ResourceManager.getResourceManager("ce");
047
048                String msg = "";
049
050                msg += mgr.getString("ce.about");
051
052                msg += "<b>Currently suported algorithms and version:</b><br>";
053                // add the Algorithms and  version nrs.
054
055                StructureAlignment[] algorithms = StructureAlignmentFactory.getAllAlgorithms();
056                for (StructureAlignment algorithm: algorithms){
057                        msg+="<i>"+algorithm.getAlgorithmName()+"</i> V." +algorithm.getVersion()+"<br>";
058                }
059                //msg+="<hr>";
060
061                JEditorPane txt = new JEditorPane("text/html", msg);
062                txt.setEditable(false);
063
064                JScrollPane scroll = new JScrollPane(txt);
065                scroll.setSize(new Dimension(300,500));
066                vBox= Box.createVerticalBox();
067                vBox.add(scroll);
068
069                txt.addHyperlinkListener(new HyperlinkListener(){
070
071                        @Override
072                        public void hyperlinkUpdate(HyperlinkEvent e) {
073
074                                if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
075                                        String href = e.getDescription();
076                                        BrowserOpener.showDocument(href);
077                                }
078                                if ( e.getEventType() == HyperlinkEvent.EventType.ENTERED) {
079                                        // change the mouse curor
080                                        vBox.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
081                                }
082                                if (e.getEventType() == HyperlinkEvent.EventType.EXITED) {
083                                        vBox.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
084                                }
085                        }
086                });
087
088
089
090
091                JButton close = new JButton("Close");
092
093                close.addActionListener(new ActionListener(){
094                        @Override
095                        public void actionPerformed(ActionEvent event) {
096                                Object source = event.getSource();
097
098                                JButton but = (JButton)source;
099                                Container parent = but.getParent().getParent().getParent().getParent().getParent().getParent() ;
100
101                                JDialog dia = (JDialog) parent;
102                                dia.dispose();
103                        }
104                });
105
106                Box hBoxb = Box.createHorizontalBox();
107                hBoxb.add(Box.createGlue());
108                hBoxb.add(close,BorderLayout.EAST);
109
110                vBox.add(hBoxb);
111
112                dialog.getContentPane().add(vBox);
113                dialog.setVisible(true);
114
115
116        }
117}