001/*
002 * Copyright 2010-2015 Institut Pasteur.
003 * 
004 * This file is part of Icy.
005 * 
006 * Icy is free software: you can redistribute it and/or modify
007 * it under the terms of the GNU General Public License as published by
008 * the Free Software Foundation, either version 3 of the License, or
009 * (at your option) any later version.
010 * 
011 * Icy is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014 * GNU General Public License for more details.
015 * 
016 * You should have received a copy of the GNU General Public License
017 * along with Icy. If not, see <http://www.gnu.org/licenses/>.
018 */
019package icy.gui.frame;
020
021import icy.main.Icy;
022import icy.system.thread.ThreadUtil;
023
024import javax.swing.BoxLayout;
025import javax.swing.JEditorPane;
026import javax.swing.JScrollPane;
027import javax.swing.JTabbedPane;
028
029public class AboutFrame extends IcyFrame
030{
031    final JTabbedPane tabbedPane;
032    final JEditorPane aboutEditorPane;
033    final JEditorPane authorEditorPane;
034    final JEditorPane thanksToEditorPane;
035    final JEditorPane externalEditorPane;
036    final JEditorPane changeLogEditorPane;
037    final JEditorPane licenseEditorPane;
038
039    public AboutFrame(int defaultTab)
040    {
041        super("About ICY", false, true, false, false);
042
043        aboutEditorPane = new JEditorPane("text/html", "");
044        aboutEditorPane.setEditable(false);
045        aboutEditorPane.setCaretPosition(0);
046
047        authorEditorPane = new JEditorPane("text/html", "");
048        authorEditorPane.setEditable(false);
049        authorEditorPane.setCaretPosition(0);
050
051        thanksToEditorPane = new JEditorPane("text/html", "");
052        thanksToEditorPane.setEditable(false);
053        thanksToEditorPane.setCaretPosition(0);
054
055        externalEditorPane = new JEditorPane("text/html", "");
056        externalEditorPane.setEditable(false);
057        externalEditorPane.setCaretPosition(0);
058
059        changeLogEditorPane = new JEditorPane("text/html", "");
060        externalEditorPane.setEditable(false);
061        externalEditorPane.setCaretPosition(0);
062
063        licenseEditorPane = new JEditorPane("text/html", "");
064        licenseEditorPane.setEditable(false);
065        licenseEditorPane.setCaretPosition(0);
066
067        tabbedPane = new JTabbedPane();
068        tabbedPane.add("About", new JScrollPane(aboutEditorPane));
069        // tabbedPane.add("Authors", new JScrollPane(authorEditorPane));
070        // tabbedPane.add("Thanks to", new JScrollPane(thanksToEditorPane));
071        tabbedPane.add("ChangeLog", new JScrollPane(changeLogEditorPane));
072        // tabbedPane.add("External code and library", new JScrollPane(externalEditorPane));
073        tabbedPane.add("License", new JScrollPane(licenseEditorPane));
074
075        // select the default tab
076        tabbedPane.setSelectedIndex(defaultTab);
077
078        setLayout(new BoxLayout(getContentPane(), BoxLayout.PAGE_AXIS));
079        add(tabbedPane);
080        setSize(680, 480);
081        setVisible(true);
082        addToDesktopPane();
083        center();
084        requestFocus();
085
086        loadInfos();
087    }
088
089    private void loadInfos()
090    {
091        ThreadUtil.bgRun(new Runnable()
092        {
093            @Override
094            public void run()
095            {
096                final String about = "<html><center>" + "<br>" + "<br><h2>Icy " + Icy.version + "</h2>"
097                        + "<br>BioImage Analysis unit" + "<br>Institut Pasteur"
098                        + "<br>Unite d'analyse d images quantitative" + "<br>25,28 Rue du Docteur Roux\n"
099                        + "<br>75015 Paris - France" + "<br>"
100                        + "<br><a href=\"http://icy.bioimageanalysis.com\">http://icy.bioimageanalysis.com</a>"
101                        + "</html>";
102
103                final String author = "<html><center><br>" + "<br>" + "<br><font size=3><u>The AIQ Team:</u></font>"
104                        + "<br>" + "<br><b>machin</b> bidule" + "<br><b>machin</b> bidule" + "<br><b>machin</b> bidule"
105                        + "<br><b>machin</b> bidule" + "</html>";
106
107                final String thanks = "<html><center><br>"
108                        + "<br>The authors of <b>bioformat</b> <i>http://www.loci.wisc.edu/ome/formats.html</i> for their fast answer and bugfixes."
109                        + "</html>";
110
111                final String external = "<html><center><br>"
112                        + "<br>"
113                        + "<br><font size=3><u>LIBRARY:</u></font>"
114                        + "<br>"
115                        + "<br><b>BioFormat</b> - http://www.openmicroscopy.org/site/products/bio-formats"
116                        + "<br><b>Substance</b> - https://java.net/projects/substance"
117                        + "</html>";
118
119                final String changelog = "<html><pre>" + Icy.getChangeLog() + "</pre></html>";
120                final String license = "<html><pre>" + Icy.getLicense() + "</pre></html>";
121
122                aboutEditorPane.setText(about);
123                authorEditorPane.setText(author);
124                thanksToEditorPane.setText(thanks);
125                externalEditorPane.setText(external);
126                changeLogEditorPane.setText(changelog);
127                licenseEditorPane.setText(license);
128            }
129        });
130    }
131
132    public AboutFrame()
133    {
134        this(0);
135    }
136
137}