View Javadoc

1   /*
2    * Copyright 2006 - 2012 Christina Bohk and Roland Ewald
3    *  
4    * Licensed under the Apache License, Version 2.0 (the "License"); 
5    * you may not use this file except in compliance with the License. 
6    * You may obtain a copy of the License at 
7    *  
8    *  http://www.apache.org/licenses/LICENSE-2.0
9    *  
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
13   * See the License for the specific language governing permissions and 
14   * limitations under the License. 
15   */
16  package p3j.gui.dialogs;
17  
18  import java.awt.BorderLayout;
19  import java.awt.Dimension;
20  import java.awt.Frame;
21  import java.awt.event.ActionEvent;
22  import java.awt.event.ActionListener;
23  import java.util.ArrayList;
24  import java.util.List;
25  
26  import javax.swing.BoxLayout;
27  import javax.swing.DefaultComboBoxModel;
28  import javax.swing.DefaultListModel;
29  import javax.swing.JButton;
30  import javax.swing.JComboBox;
31  import javax.swing.JDialog;
32  import javax.swing.JLabel;
33  import javax.swing.JList;
34  import javax.swing.JPanel;
35  import javax.swing.JScrollPane;
36  import javax.swing.JTextArea;
37  import javax.swing.JTextField;
38  import javax.swing.event.ListSelectionEvent;
39  import javax.swing.event.ListSelectionListener;
40  
41  import p3j.gui.P3J;
42  import p3j.gui.misc.ParameterListCellRenderer;
43  import p3j.misc.Misc;
44  import p3j.misc.gui.GUI;
45  import p3j.misc.math.Matrix;
46  import p3j.pppm.ProjectionModel;
47  import p3j.pppm.parameters.ParameterAssignment;
48  import p3j.pppm.parameters.ParameterInstance;
49  import p3j.pppm.sets.Set;
50  import p3j.pppm.sets.SetType;
51  
52  /**
53   * Dialog to edit {@link Set} objects.
54   * 
55   * TODO: Needs major refactoring. Display error message and close, if number of
56   * Settypes is 0.
57   * 
58   * Created on February 4, 2007
59   * 
60   * @author Christina Bohk
61   * @author Roland Ewald
62   * 
63   */
64  @Deprecated
65  public class EditSetsDialog extends JDialog {
66  
67  	/** Serialization ID. */
68  	private static final long serialVersionUID = -5975274418446080442L;
69  
70  	/** The height of the panel showing the available sets. */
71  	private static final int AVAILABLE_SET_PANEL_HEIGHT = 350;
72  
73  	/** The width of the panel showing the available sets. */
74  	private static final int AVAILABLE_SETS_PANEL_WIDTH = 200;
75  
76  	/** The height of the panel showing existing matrices. */
77  	private static final int EXISTING_MATRIX_PANEL_HEIGHT = 350;
78  
79  	/** The width of the panel showing existing matrices. */
80  	private static final int EXISTING_MATRIX_PANEL_WIDTH = 200;
81  
82  	/** The height of the panel showing available parameters. */
83  	private static final int AVAILABLE_PARAMS_PANEL_HEIGHT = 350;
84  
85  	/** The widht of the panel showing available parameters. */
86  	private static final int AVAILABLE_PARAMS_PANEL_WIDTH = 400;
87  
88  	/** Width of the dialog. */
89  	public static final int DIALOG_WIDTH = 1200;
90  
91  	/** Height of the dialog. */
92  	public static final int DIALOG_HEIGHT = 640;
93  
94  	/** Reference to current scenario. */
95  	private final ProjectionModel projection;
96  
97  	/** Reference to current Settype. */
98  	private SetType currentSetType;
99  
100 	/** Reference to current set. */
101 	private Set currentSet;
102 
103 	/** Reference to current parameter instance. */
104 	private ParameterInstance currentParameter;
105 
106 	/** Reference to current parameter assignment. */
107 	private ParameterAssignment currentParameterAssignment;
108 
109 	// Dialog structure
110 
111 	/** Panel to store all UI elements. */
112 	private JPanel contentPanel;
113 
114 	/** Panel for set editing. */
115 	private JPanel setEditingPanel;
116 
117 	/** Panel for editing the current set's attributes. */
118 	private JPanel editSetPanel;
119 
120 	/** Panel to hold elements for choosing another Settype and to create sets. */
121 	private JPanel chooseTypeCreateSetPanel;
122 
123 	/** Panel to edit the contents of sets. */
124 	private JPanel setContentEditingPanel;
125 
126 	/** Panel to edit current matrix. */
127 	private JPanel editMatrixPanel;
128 
129 	/** Panel to show existing matrices. */
130 	private JPanel showExistingMatricesPanel;
131 
132 	/** Panel to show available parameters (in this Settype). */
133 	private JPanel showAvailableParametersPanel;
134 
135 	/** Panel to show available sets. */
136 	private JPanel showAvailableSetsPanel;
137 
138 	// Lists
139 
140 	/** List of matrices for given parameter and set. */
141 	private JList matricesList = new JList(new DefaultListModel());
142 	{
143 		matricesList.addListSelectionListener(new ListSelectionListener() {
144 			@Override
145 			public void valueChanged(ListSelectionEvent e) {
146 				currentParameterAssignment = (ParameterAssignment) matricesList
147 				    .getSelectedValue();
148 				updateMatrixFields();
149 			}
150 		});
151 	}
152 
153 	/** Renderer for parameter list. */
154 	private final ParameterListCellRenderer paramListRenderer = new ParameterListCellRenderer(
155 	    this);
156 
157 	/** List of parameters for given set. */
158 	private final JList parametersList = new JList(new DefaultListModel());
159 	{
160 		parametersList.setCellRenderer(paramListRenderer);
161 		parametersList.addListSelectionListener(new ListSelectionListener() {
162 			@Override
163 			public void valueChanged(ListSelectionEvent e) {
164 				currentParameter = (ParameterInstance) parametersList
165 				    .getSelectedValue();
166 				refreshAssignments(0);
167 			}
168 		});
169 	}
170 
171 	/** List of sets for given Settype. */
172 	private final JList setsList = new JList(new DefaultListModel());
173 	{
174 		setsList.addListSelectionListener(new ListSelectionListener() {
175 			@Override
176 			public void valueChanged(ListSelectionEvent e) {
177 				currentSet = (Set) setsList.getSelectedValue();
178 				updateSetFields();
179 				refreshAssignments(0);
180 			}
181 		});
182 	}
183 
184 	// Set attributes
185 
186 	/** Field to edit the current set's name. */
187 	private final JTextField currentSetName = new JTextField(15);
188 
189 	/** Field to edit the current set's probability. */
190 	private final JTextField currentSetProb = new JTextField(3);
191 
192 	/** Field to edit the name of a set to be created. */
193 	private final JTextField newSetName = new JTextField(15);
194 
195 	/** Field to edit the current set's description. */
196 	private final JTextArea currentSetDesc = new JTextArea(5, 30);
197 
198 	/** Box with all available Settypes. */
199 	private final JComboBox availableSetTypes = new JComboBox();
200 	{
201 		availableSetTypes.addActionListener(new ActionListener() {
202 			@Override
203 			public void actionPerformed(ActionEvent e) {
204 				currentSetType = (SetType) availableSetTypes.getSelectedItem();
205 				refreshSetType(0, 0);
206 			}
207 		});
208 	}
209 
210 	/** Field to edit the name of the current matrix. */
211 	private final JTextField currentMatrixName = new JTextField(15);
212 
213 	/** Field to edit the probability of the current matrix. */
214 	private final JTextField currentMatrixProb = new JTextField(3);
215 
216 	/** Field to edit the description of the current matrix. */
217 	private final JTextArea currentMatrixDesc = new JTextArea(7, 15);
218 
219 	/**
220 	 * Combo box to select a type of the current Settype, to which the current
221 	 * matrix will be copied.
222 	 */
223 	private final JComboBox availableSetsCombo = new JComboBox();
224 
225 	/** Box with all available parameters. */
226 	private final JComboBox availableParametersCombo = new JComboBox();
227 
228 	// Control elements
229 
230 	/** Button to change the attributes of the current set. */
231 	private final JButton changeCurrentSetButton = new JButton("Change");
232 	{
233 		changeCurrentSetButton.addActionListener(new ActionListener() {
234 			@Override
235 			public void actionPerformed(ActionEvent e) {
236 				storeSetFields();
237 			}
238 		});
239 	}
240 
241 	/** Button to delete the attributes of the current set. */
242 	private final JButton deleteCurrentSetButton = new JButton("Delete");
243 	{
244 		deleteCurrentSetButton.addActionListener(new ActionListener() {
245 			@Override
246 			public void actionPerformed(ActionEvent e) {
247 				deleteCurrentSet();
248 			}
249 		});
250 	}
251 
252 	/** Button to create a new set. */
253 	private final JButton createNewSetButton = new JButton("Add");
254 	{
255 		createNewSetButton.addActionListener(new ActionListener() {
256 			@Override
257 			public void actionPerformed(ActionEvent e) {
258 				currentSetType.createSet(newSetName.getText(),
259 				    "Edit set description here.", 0);
260 				refreshSetType(currentSetType.getNumOfSets() - 1, -1);
261 			}
262 		});
263 	}
264 
265 	/** Button to edit the values of the matrix. */
266 	private final JButton editCurrentMatrixButton = new JButton("Edit values");
267 	{
268 		editCurrentMatrixButton.addActionListener(new ActionListener() {
269 			@Override
270 			public void actionPerformed(ActionEvent e) {
271 				editCurrentMatrix();
272 			}
273 		});
274 	}
275 
276 	/** Button to delete the current matrix. */
277 	private final JButton deleteCurrentMatrixButton = new JButton("Delete");
278 	{
279 		deleteCurrentMatrixButton.addActionListener(new ActionListener() {
280 			@Override
281 			public void actionPerformed(ActionEvent e) {
282 				deleteCurrentMatrix();
283 			}
284 		});
285 	}
286 
287 	/**
288 	 * Button to apply the changes to the matrix (except for value changes, these
289 	 * will always be stored).
290 	 */
291 	private final JButton changeCurrentMatrixButton = new JButton("Save");
292 	{
293 		changeCurrentMatrixButton.addActionListener(new ActionListener() {
294 			@Override
295 			public void actionPerformed(ActionEvent e) {
296 				storeMatrixFields();
297 			}
298 		});
299 	}
300 
301 	/** Button to create a new matrix. */
302 	private final JButton newMatrixButton = new JButton("New");
303 	{
304 		newMatrixButton.addActionListener(new ActionListener() {
305 			@Override
306 			public void actionPerformed(ActionEvent e) {
307 				createNewMatrix();
308 			}
309 		});
310 	}
311 
312 	/** Button to copy a matrix. */
313 	private final JButton copyMatrixButton = new JButton("Copy");
314 	{
315 		copyMatrixButton.addActionListener(new ActionListener() {
316 			@Override
317 			public void actionPerformed(ActionEvent e) {
318 				copyMatrix();
319 			}
320 		});
321 	}
322 
323 	/**
324 	 * Default constructor.
325 	 * 
326 	 * @param owner
327 	 *          the owner of this dialog
328 	 * @param proj
329 	 *          the projection to be edited
330 	 */
331 	public EditSetsDialog(Frame owner, ProjectionModel proj) {
332 		super(owner);
333 
334 		this.projection = proj;
335 
336 		availableSetTypes.setModel(new DefaultComboBoxModel(projection
337 		    .getUserDefinedTypes().toArray()));
338 
339 		initialize();
340 		resetUI();
341 	}
342 
343 	/**
344 	 * Copy a matrix.
345 	 */
346 	protected void copyMatrix() {
347 
348 		Set targetSet = (Set) availableSetsCombo.getSelectedItem();
349 		int setIndex = availableSetsCombo.getSelectedIndex();
350 		ParameterInstance targetParameter = (ParameterInstance) availableParametersCombo
351 		    .getSelectedItem();
352 		int parameterIndex = availableParametersCombo.getSelectedIndex();
353 
354 		if (targetSet == null || targetParameter == null) {
355 			return;
356 		}
357 
358 		ParameterAssignment paramAssign = new ParameterAssignment(targetParameter);
359 
360 		paramAssign.setName(currentMatrixName.getText());
361 		paramAssign.setDescription(currentMatrixDesc.getText());
362 		paramAssign.setProbability(Misc.parseToDoubleProb(currentMatrixProb
363 		    .getText()));
364 		paramAssign
365 		    .setMatrix(currentParameterAssignment != null ? currentParameterAssignment
366 		        .getMatrix().copy() : new Matrix(currentParameter
367 		        .createEmptyValue()));
368 
369 		targetSet.addParameterAssignment(paramAssign);
370 
371 		this.currentSet = targetSet;
372 		this.currentParameter = targetParameter;
373 
374 		refreshSets(false, setIndex);
375 		refreshParameters(true, parameterIndex);
376 	}
377 
378 	/**
379 	 * Resets user interface.
380 	 */
381 	public final void resetUI() {
382 		if (projection.getNumOfSetTypes() > 0) {
383 			availableSetTypes.setSelectedIndex(0);
384 			currentSetType = (SetType) availableSetTypes.getSelectedItem();
385 			refreshSetType(0, 0);
386 		}
387 	}
388 
389 	/**
390 	 * Initializes user interface.
391 	 */
392 	private void initialize() {
393 		this.setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
394 		this.setContentPane(getContentPanel());
395 		this.setTitle("Edit Sets");
396 	}
397 
398 	// Refreshing
399 
400 	@Override
401 	public void setVisible(boolean visible) {
402 		availableSetTypes.setModel(new DefaultComboBoxModel(projection
403 		    .getUserDefinedTypes().toArray()));
404 		super.setVisible(visible);
405 	}
406 
407 	/**
408 	 * Refreshes after a Settype change.
409 	 * 
410 	 * @param setIndex
411 	 *          currently selected set
412 	 * @param matrixIndex
413 	 *          currently selected assumption matrix
414 	 */
415 	final void refreshSetType(int setIndex, int matrixIndex) {
416 		if (currentSetType == null) {
417 			return;
418 		}
419 		refreshSets(false, setIndex);
420 		refreshParameters(false, -1);
421 		refreshAssignments(matrixIndex);
422 	}
423 
424 	/**
425 	 * Refreshes a set change.
426 	 * 
427 	 * @param refreshAll
428 	 *          if true, the refresh is propagated further (to dependent lists)
429 	 * @param setIndex
430 	 *          the index of the set to be selected
431 	 */
432 	final void refreshSets(boolean refreshAll, int setIndex) {
433 
434 		List<Set> sets = currentSetType.getSets();
435 		availableSetsCombo.setModel(new DefaultComboBoxModel(sets.toArray()));
436 
437 		GUI.replaceListContents((DefaultListModel) setsList.getModel(), sets);
438 
439 		Set selectedSet = sets.size() > setIndex ? sets.get(setIndex) : null;
440 		currentSet = selectedSet;
441 
442 		if (selectedSet != null) {
443 			setsList.setSelectedIndex(setIndex);
444 		} else if (sets.size() > 0) {
445 			setsList.setSelectedIndex(0);
446 			currentSet = sets.get(0);
447 		}
448 
449 		updateSetFields();
450 
451 		if (refreshAll) {
452 			refreshAssignments(0);
453 		}
454 	}
455 
456 	/**
457 	 * Refreshes a parameters change.
458 	 * 
459 	 * @param refreshAll
460 	 *          flag that determines if selected assignment shall be re-set too
461 	 * @param selIndex
462 	 *          index of the selected parameter
463 	 */
464 	final void refreshParameters(boolean refreshAll, int selIndex) {
465 
466 		int selectedIndex = selIndex < 0 ? parametersList.getSelectedIndex()
467 		    : selIndex;
468 
469 		List<ParameterInstance> parameters = currentSetType.getDefinedParameters();
470 		availableParametersCombo.setModel(new DefaultComboBoxModel(parameters
471 		    .toArray()));
472 
473 		GUI.replaceListContents((DefaultListModel) parametersList.getModel(),
474 		    parameters);
475 
476 		ParameterInstance selectedParameter = parameters.size() > selectedIndex
477 		    && selectedIndex >= 0 ? parameters.get(selectedIndex) : null;
478 
479 		currentParameter = selectedParameter;
480 
481 		if (selectedParameter != null) {
482 			parametersList.setSelectedIndex(selectedIndex);
483 		} else if (parameters.size() > 0) {
484 			parametersList.setSelectedIndex(0);
485 			currentParameter = parameters.get(0);
486 		}
487 
488 		if (refreshAll) {
489 			refreshAssignments(0);
490 		}
491 	}
492 
493 	/**
494 	 * Refreshes list of parameter assignments.
495 	 * 
496 	 * @param matIndex
497 	 *          the index of the selected matrix
498 	 */
499 	final void refreshAssignments(int matIndex) {
500 
501 		int matrixIndex = Math.max(0, matIndex);
502 
503 		List<ParameterAssignment> matrices = null;
504 
505 		if (currentSet != null && currentParameter != null) {
506 			matrices = new ArrayList<ParameterAssignment>(currentSet
507 			    .getParameterAssignments(currentParameter).getAssignments());
508 		}
509 
510 		GUI.replaceListContents((DefaultListModel) matricesList.getModel(),
511 		    matrices);
512 
513 		if (matrices != null) {
514 			ParameterAssignment selectedMatrix = matrices.size() > matrixIndex ? matrices
515 			    .get(matrixIndex) : null;
516 
517 			if (selectedMatrix != null) {
518 				matricesList.setSelectedIndex(matrixIndex);
519 				currentParameterAssignment = matrices.get(matrixIndex);
520 			} else if (matrices.size() > 0) {
521 				matricesList.setSelectedIndex(0);
522 				currentParameterAssignment = matrices.get(0);
523 			}
524 		}
525 
526 		updateMatrixFields();
527 
528 	}
529 
530 	// Function to implement button actions
531 
532 	/**
533 	 * Updates all fields that show the properties of the current set.
534 	 */
535 	final void updateSetFields() {
536 		currentSetName.setText(currentSet == null ? "" : currentSet.getName());
537 		currentSetProb.setText(currentSet == null ? "" : Double.toString(currentSet
538 		    .getProbability()));
539 		currentSetDesc.setText(currentSet == null ? "" : currentSet
540 		    .getDescription());
541 	}
542 
543 	/**
544 	 * Updates all fields that display the current parameter assignment's
545 	 * properties.
546 	 */
547 	final void updateMatrixFields() {
548 		currentMatrixName.setText(currentParameterAssignment == null ? ""
549 		    : currentParameterAssignment.getName());
550 		currentMatrixProb.setText(currentParameterAssignment == null ? "" : Double
551 		    .toString(currentParameterAssignment.getProbability()));
552 		currentMatrixDesc.setText(currentParameterAssignment == null ? ""
553 		    : currentParameterAssignment.getDescription());
554 	}
555 
556 	/**
557 	 * Stores set fields to current set.
558 	 */
559 	void storeSetFields() {
560 
561 		if (currentSet == null) {
562 			return;
563 		}
564 
565 		currentSet.setName(currentSetName.getText());
566 		currentSet.setDescription(currentSetDesc.getText());
567 		currentSet.setProbability(Double.parseDouble(currentSetProb.getText()));
568 
569 		setsList.repaint();
570 	}
571 
572 	/**
573 	 * Stores matrix fields to the current matrix.
574 	 */
575 	void storeMatrixFields() {
576 		if (currentParameterAssignment == null) {
577 			return;
578 		}
579 		currentParameterAssignment.setName(currentMatrixName.getText());
580 		currentParameterAssignment.setDescription(currentMatrixDesc.getText());
581 		currentParameterAssignment.setProbability(Misc
582 		    .parseToDoubleProb(currentMatrixProb.getText()));
583 
584 		matricesList.repaint();
585 	}
586 
587 	/**
588 	 * Deletes current set.
589 	 */
590 	void deleteCurrentSet() {
591 
592 		if (currentSet == null) {
593 			return;
594 		}
595 
596 		currentSetType.removeSet(currentSet);
597 		refreshSetType(setsList.getSelectedIndex() - 1,
598 		    matricesList.getSelectedIndex());
599 	}
600 
601 	/**
602 	 * Deletes current matrix.
603 	 */
604 	void deleteCurrentMatrix() {
605 
606 		if (currentSet == null || currentParameterAssignment == null) {
607 			return;
608 		}
609 
610 		int selectedIndex = matricesList.getSelectedIndex();
611 		currentSet.removeParameterAssignment(currentParameterAssignment);
612 		refreshAssignments(selectedIndex - 1);
613 
614 	}
615 
616 	/**
617 	 * Create a new parameter assignment (a matrix).
618 	 */
619 	void createNewMatrix() {
620 
621 		if (currentSet == null || currentParameter == null) {
622 			return;
623 		}
624 
625 		ParameterAssignment paramAssign = new ParameterAssignment(currentParameter);
626 
627 		paramAssign.setName(currentMatrixName.getText());
628 		paramAssign.setDescription(currentMatrixDesc.getText());
629 		paramAssign.setProbability(Misc.parseToDoubleProb(currentMatrixProb
630 		    .getText()));
631 		paramAssign
632 		    .setMatrix(currentParameterAssignment != null ? currentParameterAssignment
633 		        .getMatrix().copy() : new Matrix(currentParameter
634 		        .createEmptyValue()));
635 
636 		currentSet.addParameterAssignment(paramAssign);
637 
638 		refreshAssignments(currentSet.getNumberOfAssignments(currentParameter) - 1);
639 	}
640 
641 	/**
642 	 * Edit the current matrix.
643 	 */
644 	void editCurrentMatrix() {
645 		if (currentParameterAssignment == null) {
646 			return;
647 		}
648 		EditMatrixDialog editMatrixDialog = new EditMatrixDialog(P3J.getInstance(),
649 		    currentParameterAssignment);
650 		editMatrixDialog.setVisible(true);
651 	}
652 
653 	// User interface
654 
655 	/**
656 	 * Initializes content panel.
657 	 * 
658 	 * @return initialized content panel
659 	 */
660 	private JPanel getContentPanel() {
661 		if (contentPanel == null) {
662 			contentPanel = new JPanel(GUI.getStdBorderLayout());
663 			contentPanel.add(getSetEditingPanel(), BorderLayout.NORTH);
664 			contentPanel.add(getSetContentEditingPanel(), BorderLayout.CENTER);
665 			contentPanel.add(getCopyMatrixPanel(), BorderLayout.SOUTH);
666 		}
667 		return contentPanel;
668 	}
669 
670 	/**
671 	 * Initializes panel for editing sets.
672 	 * 
673 	 * @return javax.swing.JPanel
674 	 */
675 	private JPanel getSetEditingPanel() {
676 		if (setEditingPanel == null) {
677 			setEditingPanel = new JPanel(GUI.getStdBorderLayout());
678 			setEditingPanel.add(getChooseTypeAndCreateSetsPanel(), BorderLayout.WEST);
679 			setEditingPanel.add(getEditSetPanel(), BorderLayout.CENTER);
680 		}
681 		return setEditingPanel;
682 	}
683 
684 	/**
685 	 * Gets the set content editing panel.
686 	 * 
687 	 * @return javax.swing.JPanel
688 	 */
689 	private JPanel getSetContentEditingPanel() {
690 
691 		if (setContentEditingPanel == null) {
692 			setContentEditingPanel = new JPanel();
693 			setContentEditingPanel.add(getShowAvailableSetsPanel());
694 			setContentEditingPanel.add(getShowAvailableParametersPanel());
695 			setContentEditingPanel.add(getShowExistingMatricesPanel());
696 			setContentEditingPanel.add(getEditMatrixPanel());
697 		}
698 
699 		return setContentEditingPanel;
700 	}
701 
702 	/**
703 	 * Gets the edit matrix panel.
704 	 * 
705 	 * @return panel to edit current parameter assignment (matrix)
706 	 */
707 	private JPanel getEditMatrixPanel() {
708 
709 		if (editMatrixPanel == null) {
710 			editMatrixPanel = new JPanel(GUI.getStdBorderLayout());
711 			editMatrixPanel.add(new JLabel("Edit matrix:"), BorderLayout.NORTH);
712 
713 			JPanel editMatrixInnerPanel = new JPanel(GUI.getStdBorderLayout());
714 			editMatrixPanel.add(editMatrixInnerPanel, BorderLayout.CENTER);
715 
716 			// Name + Probability
717 			JPanel editNameProbPanel = new JPanel(GUI.getStdBorderLayout());
718 			editMatrixInnerPanel.add(editNameProbPanel, BorderLayout.NORTH);
719 
720 			JPanel editNamePanel = new JPanel();
721 			editNameProbPanel.add(editNamePanel, BorderLayout.NORTH);
722 			editNamePanel.add(new JLabel(Misc.GUI_LABEL_NAME));
723 			editNamePanel.add(currentMatrixName);
724 			editNamePanel.add(editCurrentMatrixButton);
725 
726 			JPanel editProbPanel = new JPanel();
727 			editNameProbPanel.add(editProbPanel, BorderLayout.SOUTH);
728 			editProbPanel.add(new JLabel(Misc.GUI_LABEL_PROBABILITY));
729 			editProbPanel.add(currentMatrixProb);
730 
731 			// Description
732 			JPanel editDescriptionPanel = new JPanel(GUI.getStdBorderLayout());
733 			editMatrixInnerPanel.add(editDescriptionPanel, BorderLayout.CENTER);
734 			editDescriptionPanel.add(new JLabel("Description:"), BorderLayout.NORTH);
735 			editDescriptionPanel.add(currentMatrixDesc, BorderLayout.CENTER);
736 
737 			JPanel buttonPanel = new JPanel();
738 			editDescriptionPanel.add(buttonPanel, BorderLayout.SOUTH);
739 			buttonPanel.add(deleteCurrentMatrixButton);
740 			buttonPanel.add(changeCurrentMatrixButton);
741 			buttonPanel.add(newMatrixButton);
742 		}
743 
744 		return editMatrixPanel;
745 	}
746 
747 	/**
748 	 * Gets the copy matrix panel.
749 	 * 
750 	 * @return panel for fast matrix copy
751 	 */
752 	private JPanel getCopyMatrixPanel() {
753 		JPanel returnPanel = new JPanel(GUI.getStdBorderLayout());
754 		returnPanel.add(new JPanel(), BorderLayout.CENTER);
755 
756 		JPanel copyMatrixPanel = new JPanel(GUI.getStdBorderLayout());
757 		copyMatrixPanel.add(new JLabel("Copy matrix to:"), BorderLayout.NORTH);
758 		JPanel comboBoxPanel = new JPanel();
759 		copyMatrixPanel.add(comboBoxPanel, BorderLayout.CENTER);
760 		comboBoxPanel.setLayout(new BoxLayout(comboBoxPanel, BoxLayout.Y_AXIS));
761 		comboBoxPanel.add(availableSetsCombo);
762 		comboBoxPanel.add(availableParametersCombo);
763 		copyMatrixPanel.add(copyMatrixButton, BorderLayout.EAST);
764 
765 		returnPanel.add(copyMatrixPanel, BorderLayout.EAST);
766 		return returnPanel;
767 	}
768 
769 	/**
770 	 * Gets the show existing matrices panel.
771 	 * 
772 	 * @return panel to show existing parameter assignments (= matrices)
773 	 */
774 	private JPanel getShowExistingMatricesPanel() {
775 
776 		if (showExistingMatricesPanel == null) {
777 			showExistingMatricesPanel = new JPanel(GUI.getStdBorderLayout());
778 
779 			showExistingMatricesPanel.add(new JLabel("Matrices in Set: "),
780 			    BorderLayout.NORTH);
781 
782 			JScrollPane matricesScrollPane = new JScrollPane();
783 			matricesScrollPane.setPreferredSize(new Dimension(
784 			    EXISTING_MATRIX_PANEL_WIDTH, EXISTING_MATRIX_PANEL_HEIGHT));
785 			matricesScrollPane.getViewport().add(matricesList);
786 			showExistingMatricesPanel.add(matricesScrollPane, BorderLayout.CENTER);
787 
788 		}
789 
790 		return showExistingMatricesPanel;
791 	}
792 
793 	/**
794 	 * Gets the show available parameters panel.
795 	 * 
796 	 * @return panel to show available parameters
797 	 */
798 	private JPanel getShowAvailableParametersPanel() {
799 		if (showAvailableParametersPanel == null) {
800 			showAvailableParametersPanel = new JPanel(GUI.getStdBorderLayout());
801 
802 			showAvailableParametersPanel.add(new JLabel("Parameters of Set: "),
803 			    BorderLayout.NORTH);
804 
805 			JScrollPane parametersScrollPane = new JScrollPane();
806 			parametersScrollPane.setPreferredSize(new Dimension(
807 			    AVAILABLE_PARAMS_PANEL_WIDTH, AVAILABLE_PARAMS_PANEL_HEIGHT));
808 			parametersScrollPane.getViewport().add(parametersList);
809 			showAvailableParametersPanel.add(parametersScrollPane,
810 			    BorderLayout.CENTER);
811 		}
812 		return showAvailableParametersPanel;
813 	}
814 
815 	/**
816 	 * Gets the show available sets panel.
817 	 * 
818 	 * @return panel to show available sets
819 	 */
820 	private JPanel getShowAvailableSetsPanel() {
821 
822 		if (showAvailableSetsPanel == null) {
823 			showAvailableSetsPanel = new JPanel(GUI.getStdBorderLayout());
824 
825 			showAvailableSetsPanel.add(new JLabel("Parameters of Set: "),
826 			    BorderLayout.NORTH);
827 
828 			JScrollPane setsScrollPane = new JScrollPane();
829 			setsScrollPane.setPreferredSize(new Dimension(AVAILABLE_SETS_PANEL_WIDTH,
830 			    AVAILABLE_SET_PANEL_HEIGHT));
831 			setsScrollPane.getViewport().add(setsList);
832 			showAvailableSetsPanel.add(setsScrollPane, BorderLayout.CENTER);
833 		}
834 
835 		return showAvailableSetsPanel;
836 	}
837 
838 	/**
839 	 * Gets the choose type and create sets panel.
840 	 * 
841 	 * @return javax.swing.JPanel
842 	 */
843 	final JPanel getChooseTypeAndCreateSetsPanel() {
844 
845 		if (chooseTypeCreateSetPanel == null) {
846 
847 			chooseTypeCreateSetPanel = new JPanel(GUI.getStdBorderLayout());
848 
849 			JPanel chooseSetType = new JPanel();
850 			chooseTypeCreateSetPanel.add(chooseSetType, BorderLayout.NORTH);
851 			chooseSetType.add(new JLabel("Choose Settype:"));
852 			chooseSetType.add(availableSetTypes);
853 
854 			JPanel createNewSet = new JPanel();
855 			chooseTypeCreateSetPanel.add(createNewSet, BorderLayout.SOUTH);
856 			createNewSet.add(new JLabel("Create new set:"));
857 			createNewSet.add(newSetName);
858 			createNewSet.add(createNewSetButton);
859 
860 		}
861 
862 		return chooseTypeCreateSetPanel;
863 	}
864 
865 	/**
866 	 * Gets the edit set panel.
867 	 * 
868 	 * @return javax.swing.JPanel
869 	 */
870 	final JPanel getEditSetPanel() {
871 		if (editSetPanel == null) {
872 			editSetPanel = new JPanel(GUI.getStdBorderLayout());
873 
874 			JPanel nameProbPanel = new JPanel();
875 			nameProbPanel.setLayout(new BoxLayout(nameProbPanel, BoxLayout.Y_AXIS));
876 			editSetPanel.add(nameProbPanel, BorderLayout.WEST);
877 			JPanel editCurrentSetNamePanel = new JPanel();
878 			editCurrentSetNamePanel.add(new JLabel(Misc.GUI_LABEL_NAME));
879 			editCurrentSetNamePanel.add(currentSetName);
880 			JPanel editCurrentSetProbPanel = new JPanel();
881 			editCurrentSetProbPanel.add(new JLabel(Misc.GUI_LABEL_PROBABILITY));
882 			editCurrentSetProbPanel.add(currentSetProb);
883 			nameProbPanel.add(editCurrentSetNamePanel);
884 			nameProbPanel.add(editCurrentSetProbPanel);
885 
886 			JPanel descPanel = new JPanel();
887 			descPanel.setLayout(new BoxLayout(descPanel, BoxLayout.Y_AXIS));
888 			editSetPanel.add(descPanel, BorderLayout.CENTER);
889 			descPanel.add(new JLabel("Description:"));
890 			descPanel.add(currentSetDesc);
891 
892 			JPanel buttonPanel = new JPanel();
893 			editSetPanel.add(buttonPanel, BorderLayout.SOUTH);
894 			buttonPanel.add(changeCurrentSetButton);
895 			buttonPanel.add(deleteCurrentSetButton);
896 		}
897 		return editSetPanel;
898 	}
899 
900 	/**
901 	 * Gets the current set.
902 	 * 
903 	 * @return Returns the currentSet.
904 	 */
905 	public Set getCurrentSet() {
906 		return currentSet;
907 	}
908 
909 }