$darkmode
DENOPTIM
HomePanel.java
Go to the documentation of this file.
1/*
2 * DENOPTIM
3 * Copyright (C) 2020 Marco Foscato <marco.foscato@uib.no>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as published
7 * by the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19package denoptim.gui;
20
21import java.awt.BorderLayout;
22import java.awt.Color;
23import java.awt.Cursor;
24import java.awt.Desktop;
25import java.awt.FlowLayout;
26import java.awt.Font;
27import java.awt.GridLayout;
28import java.awt.event.ActionEvent;
29import java.awt.event.ActionListener;
30import java.awt.event.MouseAdapter;
31import java.awt.event.MouseEvent;
32import java.io.File;
33import java.io.IOException;
34import java.net.URI;
35import java.net.URISyntaxException;
36import java.net.URL;
37
38import javax.swing.GroupLayout;
39import javax.swing.ImageIcon;
40import javax.swing.JButton;
41import javax.swing.JLabel;
42import javax.swing.JPanel;
43import javax.swing.JTextPane;
44import javax.swing.UIManager;
45import javax.swing.text.SimpleAttributeSet;
46import javax.swing.text.StyleConstants;
47
52public class HomePanel extends GUICardPanel
53{
54
58 private static final long serialVersionUID = 5512821342651489833L;
59
60//-----------------------------------------------------------------------------
61
66 super(mainPanel, "Home");
67 initialize();
68 }
69
70//-----------------------------------------------------------------------------
71
75 private void initialize() {
76 this.setLayout(new BorderLayout(0, 0));
77
78 //Central panel (figure and shortcuts)
79 JPanel centralPanel = new JPanel();
80 this.add(centralPanel, BorderLayout.CENTER);
81
82 //Figure panel
83 JPanel figurePanel = new JPanel();
84 centralPanel.add(figurePanel);
85
86 JLabel show_image = new JLabel("");
87
88 try
89 {
90 URL url = ClassLoader.getSystemResource(
91 "images/DENOPTIM_extended_logo.png");
92 show_image.setIcon(new ImageIcon(new ImageIcon(url).getImage()));
93 } catch (Throwable t)
94 {
95 // Problems loading resources
96 }
97 figurePanel.add(show_image);
98
99 //Shortcuts panel
100 JPanel buttonsPanel = new JPanel();
101 buttonsPanel.setLayout(new FlowLayout());
102 centralPanel.add(buttonsPanel);
103
104 JButton btnNewGA = new JButton("New Evolutionary De Novo Design");
105 btnNewGA.addActionListener(new ActionListener() {
106 public void actionPerformed(ActionEvent e) {
108 }
109 });
110
111 JButton btnNewVirtualScreening = new JButton("New Virtual Screening");
112 btnNewVirtualScreening.addActionListener(new ActionListener() {
113 public void actionPerformed(ActionEvent e) {
115 }
116 });
117
118 //TODO: new fragmentation job with GM3DFragmenter "New Fragmentation"
119
120 JButton btnNewFragments = new JButton("Make Fragments");
121 btnNewFragments.addActionListener(new ActionListener() {
122 public void actionPerformed(ActionEvent e) {
124 }
125 });
126
127 JButton btnNewGraph = new JButton("Make Graphs");
128 btnNewGraph.addActionListener(new ActionListener() {
129 public void actionPerformed(ActionEvent e) {
131 }
132 });
133
134 JButton btnReadGAOutput = new JButton("Inspect Evolutionary Run");
135 btnReadGAOutput.setToolTipText("Analyzes the output folder of an "
136 + "evolutionary experiment (i.e., folder named RUN...)");
137 btnReadGAOutput.addActionListener(new ActionListener() {
138 public void actionPerformed(ActionEvent e) {
139 File file = GUIFileOpener.pickFolder(btnReadGAOutput);
140 if (file == null)
141 {
142 return;
143 }
144 mainPanel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
146 mainPanel.add(inspector);
147 inspector.importGARunData(file,btnReadGAOutput);
148 }
149 });
150 JButton btnReadFSEOutput = new JButton("Inspect Combinatorial Run");
151 btnReadFSEOutput.setToolTipText("Analyzes the output folder of an "
152 + "combinatorial experiment (i.e., folder named FSE...)");
153 btnReadFSEOutput.addActionListener(new ActionListener() {
154 public void actionPerformed(ActionEvent e) {
155 File file = GUIFileOpener.pickFolder(btnReadFSEOutput);
156 if (file == null)
157 {
158 return;
159 }
160 mainPanel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
162 mainPanel.add(inspector);
163 inspector.importFSERunData(file);
164 }
165 });
166
167 JButton btnTestFitness = new JButton("Test Fitness Provider");
168 btnTestFitness.addActionListener(new ActionListener() {
169 public void actionPerformed(ActionEvent e) {
171 }
172 });
173
174
175 //Credits panel
176 JPanel creditsPanel = new JPanel();
177 this.add(creditsPanel, BorderLayout.SOUTH);
178 creditsPanel.setLayout(new GridLayout(0, 1, 0, 0));
179
180 JTextPane txtpnCredits = new JTextPane();
181 txtpnCredits.setFont(new Font("Lucida Grande", Font.PLAIN, 10));
182 txtpnCredits.setBackground(UIManager.getColor("Button.background"));
183 SimpleAttributeSet attribs = new SimpleAttributeSet();
184 StyleConstants.setAlignment(attribs , StyleConstants.ALIGN_CENTER);
185 txtpnCredits.setParagraphAttributes(attribs,false);
186 txtpnCredits.setText("The DENOPTIM project"+System.getProperty("line.separator")+"University of Bergen and Norwegian University of Science and Technology");
187 creditsPanel.add(txtpnCredits);
188
189
190 JTextPane email = new JTextPane();
191 email.setForeground(Color.BLUE.darker());
192 email.setFont(new Font("Lucida Grande", Font.PLAIN, 10));
193 email.setBackground(UIManager.getColor("Button.background"));
194 email.setText("denoptim.project@gmail.com");
195 email.setParagraphAttributes(attribs,false);
196 email.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
197 email.addMouseListener(new MouseAdapter() {
198 @Override
199 public void mouseClicked(MouseEvent e) {
200 try {
201 Desktop.getDesktop().mail(new URI("mailto:denoptim.project@gmail.com"));
202 } catch (IOException | URISyntaxException e1) {
203 e1.printStackTrace();
204 }
205 }
206 });
207 creditsPanel.add(email);
208
209 JLabel labShortcuts = new JLabel("Shortcuts:");
210
211 JLabel labEmpty = new JLabel("<html><br><br><br><br><br><br></html>");
212
213 // Here we define the position of all the components of the central panel
214 GroupLayout lyoCentralPanel = new GroupLayout(centralPanel);
215 centralPanel.setLayout(lyoCentralPanel);
216 lyoCentralPanel.setAutoCreateGaps(true);
217 lyoCentralPanel.setAutoCreateContainerGaps(true);
218 lyoCentralPanel.setHorizontalGroup(lyoCentralPanel.createParallelGroup(
219 GroupLayout.Alignment.CENTER)
220 .addComponent(figurePanel)
221 .addComponent(labShortcuts)
222 .addGroup(lyoCentralPanel.createSequentialGroup()
223 .addComponent(btnNewFragments)
224 .addComponent(btnNewGraph))
225 .addGroup(lyoCentralPanel.createSequentialGroup()
226 .addComponent(btnNewGA)
227 .addComponent(btnNewVirtualScreening))
228 .addGroup(lyoCentralPanel.createSequentialGroup()
229 .addComponent(btnTestFitness))
230 .addGroup(lyoCentralPanel.createSequentialGroup()
231 .addComponent(btnReadGAOutput)
232 .addComponent(btnReadFSEOutput))
233 .addComponent(labEmpty));
234 lyoCentralPanel.setVerticalGroup(lyoCentralPanel.createSequentialGroup()
235 .addComponent(figurePanel)
236 .addComponent(labShortcuts)
237 .addGroup(lyoCentralPanel.createParallelGroup(GroupLayout.Alignment.CENTER)
238 .addComponent(btnNewFragments)
239 .addComponent(btnNewGraph))
240 .addGroup(lyoCentralPanel.createParallelGroup(GroupLayout.Alignment.CENTER)
241 .addComponent(btnNewGA)
242 .addComponent(btnNewVirtualScreening))
243 .addGroup(lyoCentralPanel.createParallelGroup(GroupLayout.Alignment.CENTER)
244 .addComponent(btnTestFitness))
245 .addGroup(lyoCentralPanel.createParallelGroup(GroupLayout.Alignment.CENTER)
246 .addComponent(btnReadGAOutput)
247 .addComponent(btnReadFSEOutput))
248 .addComponent(labEmpty));
249
250 }
251}
Class of GUI panels meant to occupy one card in the deck-of-cards layout of the main panel.
GUIMainPanel mainPanel
The main panel (cards deck)
File opener for DENOPTIM GUI.
static File pickFolder(Component parent)
A panel that understands DENOPTIM graphs and allows to create and edit them.
A panel that allows to inspect the output of an combinatorial experiment exploring a fragment space.
A panel that allows to inspect the output of an artificial evolution experiment.
void importGARunData(File file, JComponent parent)
The main panel is a deck of cards that occupies all the GUI frame.
Component add(Component comp)
Add a component and a reference to such component in the main tool bar.
Master form containing all sub-forms that need to be filled to define the input parameters for FragSp...
Form that allows to test the configuration of a fitness provider.
Master form containing all sub-forms that need to be filled to define the input parameters for Denopt...
A panel with a viewer capable of visualising DENOPTIM fragments and allows to create and edit fragmen...
The home panel contains shortcuts buttons to perform the most common tasks.
Definition: HomePanel.java:53
void initialize()
Initialize the panel with figure and shortcuts and credit panels.
Definition: HomePanel.java:75
HomePanel(GUIMainPanel mainPanel)
Constructor.
Definition: HomePanel.java:65
static final long serialVersionUID
Version.
Definition: HomePanel.java:58