summaryrefslogtreecommitdiff
path: root/src/de/lmu/ifi/dbs/elki/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/de/lmu/ifi/dbs/elki/gui')
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/GUIUtil.java2
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/configurator/AbstractParameterConfigurator.java2
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/configurator/AbstractSingleParameterConfigurator.java2
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/configurator/ClassListParameterConfigurator.java8
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/configurator/ClassParameterConfigurator.java6
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/configurator/ConfiguratorPanel.java6
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/configurator/EnumParameterConfigurator.java6
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/configurator/FileParameterConfigurator.java2
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/configurator/FlagParameterConfigurator.java2
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/configurator/ParameterConfigurator.java2
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/configurator/TextParameterConfigurator.java2
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/configurator/package-info.java2
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/icons/StockIcon.java6
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/icons/package-info.java2
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/minigui/MiniGUI.java15
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/minigui/package-info.java2
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/multistep/MultiStepGUI.java121
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/multistep/package-info.java2
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/multistep/panels/AlgorithmTabPanel.java38
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/multistep/panels/EvaluationTabPanel.java13
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/multistep/panels/InputTabPanel.java2
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/multistep/panels/LoggingTabPanel.java12
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/multistep/panels/OutputTabPanel.java13
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/multistep/panels/ParameterTabPanel.java36
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/multistep/panels/SavedSettingsTabPanel.java27
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/multistep/panels/package-info.java2
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/package-info.java2
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/util/DynamicParameters.java6
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/util/LogPane.java2
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/util/LogPanel.java4
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/util/ParameterTable.java299
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/util/ParametersModel.java2
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/util/SavedSettingsFile.java17
-rw-r--r--src/de/lmu/ifi/dbs/elki/gui/util/package-info.java2
34 files changed, 396 insertions, 271 deletions
diff --git a/src/de/lmu/ifi/dbs/elki/gui/GUIUtil.java b/src/de/lmu/ifi/dbs/elki/gui/GUIUtil.java
index 11a2725f..27cccded 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/GUIUtil.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/GUIUtil.java
@@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.gui;
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
- Copyright (C) 2012
+ Copyright (C) 2013
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
diff --git a/src/de/lmu/ifi/dbs/elki/gui/configurator/AbstractParameterConfigurator.java b/src/de/lmu/ifi/dbs/elki/gui/configurator/AbstractParameterConfigurator.java
index 977af410..c6883653 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/configurator/AbstractParameterConfigurator.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/configurator/AbstractParameterConfigurator.java
@@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.gui.configurator;
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
- Copyright (C) 2012
+ Copyright (C) 2013
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
diff --git a/src/de/lmu/ifi/dbs/elki/gui/configurator/AbstractSingleParameterConfigurator.java b/src/de/lmu/ifi/dbs/elki/gui/configurator/AbstractSingleParameterConfigurator.java
index 6d30ce25..240515cd 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/configurator/AbstractSingleParameterConfigurator.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/configurator/AbstractSingleParameterConfigurator.java
@@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.gui.configurator;
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
- Copyright (C) 2012
+ Copyright (C) 2013
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
diff --git a/src/de/lmu/ifi/dbs/elki/gui/configurator/ClassListParameterConfigurator.java b/src/de/lmu/ifi/dbs/elki/gui/configurator/ClassListParameterConfigurator.java
index 603a52a9..182c7a0a 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/configurator/ClassListParameterConfigurator.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/configurator/ClassListParameterConfigurator.java
@@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.gui.configurator;
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
- Copyright (C) 2012
+ Copyright (C) 2013
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
@@ -76,7 +76,7 @@ public class ClassListParameterConfigurator extends AbstractSingleParameterConfi
/**
* The combobox we are abusing to produce the popup
*/
- final JComboBox combo;
+ final JComboBox<String> combo;
/**
* The popup menu.
@@ -96,7 +96,7 @@ public class ClassListParameterConfigurator extends AbstractSingleParameterConfi
button.setToolTipText(param.getShortDescription());
button.addActionListener(this);
// So the first item doesn't get automatically selected
- combo = new JComboBox();
+ combo = new JComboBox<>();
combo.setEditable(true);
combo.setPrototypeDisplayValue(cp.getRestrictionClass().getSimpleName());
popup = new SuperPopup(combo);
@@ -193,7 +193,7 @@ public class ClassListParameterConfigurator extends AbstractSingleParameterConfi
*
* @param combo Combo box used for data storage.
*/
- public SuperPopup(JComboBox combo) {
+ public SuperPopup(JComboBox<String> combo) {
super(combo);
}
diff --git a/src/de/lmu/ifi/dbs/elki/gui/configurator/ClassParameterConfigurator.java b/src/de/lmu/ifi/dbs/elki/gui/configurator/ClassParameterConfigurator.java
index 4fdcac10..cbe03a4f 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/configurator/ClassParameterConfigurator.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/configurator/ClassParameterConfigurator.java
@@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.gui.configurator;
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
- Copyright (C) 2012
+ Copyright (C) 2013
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
@@ -49,7 +49,7 @@ import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters.Parameter;
* @apiviz.uses ClassParameter
*/
public class ClassParameterConfigurator extends AbstractSingleParameterConfigurator<ClassParameter<?>> implements ActionListener, ChangeListener {
- final JComboBox value;
+ final JComboBox<String> value;
final ConfiguratorPanel child;
@@ -60,7 +60,7 @@ public class ClassParameterConfigurator extends AbstractSingleParameterConfigura
GridBagConstraints constraints = new GridBagConstraints();
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.weightx = 1.0;
- value = new JComboBox();
+ value = new JComboBox<>();
value.setToolTipText(param.getShortDescription());
value.setPrototypeDisplayValue(cp.getRestrictionClass().getSimpleName());
parent.add(value, constraints);
diff --git a/src/de/lmu/ifi/dbs/elki/gui/configurator/ConfiguratorPanel.java b/src/de/lmu/ifi/dbs/elki/gui/configurator/ConfiguratorPanel.java
index c21d11a4..440d5d0a 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/configurator/ConfiguratorPanel.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/configurator/ConfiguratorPanel.java
@@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.gui.configurator;
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
- Copyright (C) 2012
+ Copyright (C) 2013
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
@@ -61,12 +61,12 @@ public class ConfiguratorPanel extends JPanel implements ChangeListener {
/**
* Keep a map of parameter
*/
- private Map<Object, ParameterConfigurator> childconfig = new HashMap<Object, ParameterConfigurator>();
+ private Map<Object, ParameterConfigurator> childconfig = new HashMap<>();
/**
* Child options
*/
- private ArrayList<ParameterConfigurator> children = new ArrayList<ParameterConfigurator>();
+ private ArrayList<ParameterConfigurator> children = new ArrayList<>();
/**
* The event listeners for this panel.
diff --git a/src/de/lmu/ifi/dbs/elki/gui/configurator/EnumParameterConfigurator.java b/src/de/lmu/ifi/dbs/elki/gui/configurator/EnumParameterConfigurator.java
index 0e5740a8..f361efa2 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/configurator/EnumParameterConfigurator.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/configurator/EnumParameterConfigurator.java
@@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.gui.configurator;
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
- Copyright (C) 2012
+ Copyright (C) 2013
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
@@ -44,7 +44,7 @@ import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters.EnumParameter;
* @apiviz.uses EnumParameter
*/
public class EnumParameterConfigurator extends AbstractSingleParameterConfigurator<EnumParameter<?>> implements ActionListener {
- final JComboBox value;
+ final JComboBox<String> value;
public EnumParameterConfigurator(EnumParameter<?> cp, JComponent parent) {
super(cp, parent);
@@ -53,7 +53,7 @@ public class EnumParameterConfigurator extends AbstractSingleParameterConfigurat
GridBagConstraints constraints = new GridBagConstraints();
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.weightx = 1.0;
- value = new JComboBox();
+ value = new JComboBox<>();
value.setToolTipText(param.getShortDescription());
value.setPrototypeDisplayValue(cp.getPossibleValues().iterator().next());
parent.add(value, constraints);
diff --git a/src/de/lmu/ifi/dbs/elki/gui/configurator/FileParameterConfigurator.java b/src/de/lmu/ifi/dbs/elki/gui/configurator/FileParameterConfigurator.java
index f9355579..1fce49f0 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/configurator/FileParameterConfigurator.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/configurator/FileParameterConfigurator.java
@@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.gui.configurator;
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
- Copyright (C) 2012
+ Copyright (C) 2013
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
diff --git a/src/de/lmu/ifi/dbs/elki/gui/configurator/FlagParameterConfigurator.java b/src/de/lmu/ifi/dbs/elki/gui/configurator/FlagParameterConfigurator.java
index bec04b70..5f73663c 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/configurator/FlagParameterConfigurator.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/configurator/FlagParameterConfigurator.java
@@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.gui.configurator;
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
- Copyright (C) 2012
+ Copyright (C) 2013
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
diff --git a/src/de/lmu/ifi/dbs/elki/gui/configurator/ParameterConfigurator.java b/src/de/lmu/ifi/dbs/elki/gui/configurator/ParameterConfigurator.java
index 9bd879f6..6118355c 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/configurator/ParameterConfigurator.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/configurator/ParameterConfigurator.java
@@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.gui.configurator;
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
- Copyright (C) 2012
+ Copyright (C) 2013
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
diff --git a/src/de/lmu/ifi/dbs/elki/gui/configurator/TextParameterConfigurator.java b/src/de/lmu/ifi/dbs/elki/gui/configurator/TextParameterConfigurator.java
index 582381cb..411d056d 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/configurator/TextParameterConfigurator.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/configurator/TextParameterConfigurator.java
@@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.gui.configurator;
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
- Copyright (C) 2012
+ Copyright (C) 2013
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
diff --git a/src/de/lmu/ifi/dbs/elki/gui/configurator/package-info.java b/src/de/lmu/ifi/dbs/elki/gui/configurator/package-info.java
index 5c8f2f4e..cb7ef043 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/configurator/package-info.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/configurator/package-info.java
@@ -8,7 +8,7 @@
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
-Copyright (C) 2012
+Copyright (C) 2013
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
diff --git a/src/de/lmu/ifi/dbs/elki/gui/icons/StockIcon.java b/src/de/lmu/ifi/dbs/elki/gui/icons/StockIcon.java
index 4896bce0..c0550da3 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/icons/StockIcon.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/icons/StockIcon.java
@@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.gui.icons;
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
- Copyright (C) 2012
+ Copyright (C) 2013
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
@@ -88,7 +88,7 @@ public class StockIcon {
public static final String PROCESS_STOP = "process-stop";
- private static final Map<String, SoftReference<Icon>> iconcache = new HashMap<String, SoftReference<Icon>>();
+ private static final Map<String, SoftReference<Icon>> iconcache = new HashMap<>();
/**
* Get a particular stock icon.
@@ -107,7 +107,7 @@ public class StockIcon {
java.net.URL imgURL = StockIcon.class.getResource(name + ".png");
if(imgURL != null) {
Icon icon = new ImageIcon(imgURL);
- iconcache.put(name, new SoftReference<Icon>(icon));
+ iconcache.put(name, new SoftReference<>(icon));
return icon;
}
else {
diff --git a/src/de/lmu/ifi/dbs/elki/gui/icons/package-info.java b/src/de/lmu/ifi/dbs/elki/gui/icons/package-info.java
index 986b2de1..c7ffb7d0 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/icons/package-info.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/icons/package-info.java
@@ -5,7 +5,7 @@
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
-Copyright (C) 2012
+Copyright (C) 2013
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
diff --git a/src/de/lmu/ifi/dbs/elki/gui/minigui/MiniGUI.java b/src/de/lmu/ifi/dbs/elki/gui/minigui/MiniGUI.java
index 36010fc5..f60ac69e 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/minigui/MiniGUI.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/minigui/MiniGUI.java
@@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.gui.minigui;
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
- Copyright (C) 2012
+ Copyright (C) 2013
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
@@ -59,6 +59,7 @@ import de.lmu.ifi.dbs.elki.gui.util.ParameterTable;
import de.lmu.ifi.dbs.elki.gui.util.ParametersModel;
import de.lmu.ifi.dbs.elki.gui.util.SavedSettingsFile;
import de.lmu.ifi.dbs.elki.logging.Logging;
+import de.lmu.ifi.dbs.elki.utilities.Alias;
import de.lmu.ifi.dbs.elki.utilities.FormatUtil;
import de.lmu.ifi.dbs.elki.utilities.exceptions.UnableToComplyException;
import de.lmu.ifi.dbs.elki.utilities.optionhandling.ParameterException;
@@ -78,6 +79,7 @@ import de.lmu.ifi.dbs.elki.workflow.OutputStep;
* @apiviz.owns ParameterTable
* @apiviz.owns DynamicParameters
*/
+@Alias({"mini", "minigui"})
public class MiniGUI extends AbstractApplication {
/**
* Filename for saved settings.
@@ -127,7 +129,7 @@ public class MiniGUI extends AbstractApplication {
/**
* Combo box for saved settings.
*/
- protected JComboBox savedCombo;
+ protected JComboBox<String> savedCombo;
/**
* Model to link the combobox with.
@@ -165,7 +167,7 @@ public class MiniGUI extends AbstractApplication {
// Combo box for saved settings
savedSettingsModel = new SettingsComboboxModel(store);
- savedCombo = new JComboBox(savedSettingsModel);
+ savedCombo = new JComboBox<>(savedSettingsModel);
savedCombo.setEditable(true);
savedCombo.setSelectedItem("[Saved Settings]");
buttonPanel.add(savedCombo);
@@ -259,7 +261,7 @@ public class MiniGUI extends AbstractApplication {
});
// Create parameter table
- parameterTable = new ParameterTable(parameterModel, parameters);
+ parameterTable = new ParameterTable(frame, parameterModel, parameters);
// Create the scroll pane and add the table to it.
JScrollPane scrollPane = new JScrollPane(parameterTable);
@@ -341,6 +343,7 @@ public class MiniGUI extends AbstractApplication {
List<String> remainingParameters = config.getRemainingParameters();
// update table:
+ parameterTable.removeEditor();
parameterTable.setEnabled(false);
parameters.updateFromTrackParameters(track);
// Add remaining parameters
@@ -473,7 +476,7 @@ public class MiniGUI extends AbstractApplication {
*
* @apiviz.composedOf de.lmu.ifi.dbs.elki.gui.util.SavedSettingsFile
*/
- class SettingsComboboxModel extends AbstractListModel implements ComboBoxModel {
+ class SettingsComboboxModel extends AbstractListModel<String> implements ComboBoxModel<String> {
/**
* Serial version.
*/
@@ -512,7 +515,7 @@ public class MiniGUI extends AbstractApplication {
}
@Override
- public Object getElementAt(int index) {
+ public String getElementAt(int index) {
return store.getElementAt(store.size() - 1 - index).first;
}
diff --git a/src/de/lmu/ifi/dbs/elki/gui/minigui/package-info.java b/src/de/lmu/ifi/dbs/elki/gui/minigui/package-info.java
index 944b4a8e..7acb0045 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/minigui/package-info.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/minigui/package-info.java
@@ -5,7 +5,7 @@
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
-Copyright (C) 2012
+Copyright (C) 2013
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
diff --git a/src/de/lmu/ifi/dbs/elki/gui/multistep/MultiStepGUI.java b/src/de/lmu/ifi/dbs/elki/gui/multistep/MultiStepGUI.java
index 820bc543..11a45d25 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/multistep/MultiStepGUI.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/multistep/MultiStepGUI.java
@@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.gui.multistep;
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
- Copyright (C) 2012
+ Copyright (C) 2013
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
@@ -32,12 +32,12 @@ import java.util.ArrayList;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
-import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
-import javax.swing.UIManager;
import de.lmu.ifi.dbs.elki.KDDTask;
+import de.lmu.ifi.dbs.elki.application.AbstractApplication;
+import de.lmu.ifi.dbs.elki.gui.GUIUtil;
import de.lmu.ifi.dbs.elki.gui.minigui.MiniGUI;
import de.lmu.ifi.dbs.elki.gui.multistep.panels.AlgorithmTabPanel;
import de.lmu.ifi.dbs.elki.gui.multistep.panels.EvaluationTabPanel;
@@ -48,8 +48,11 @@ import de.lmu.ifi.dbs.elki.gui.multistep.panels.SavedSettingsTabPanel;
import de.lmu.ifi.dbs.elki.gui.util.LogPanel;
import de.lmu.ifi.dbs.elki.gui.util.SavedSettingsFile;
import de.lmu.ifi.dbs.elki.logging.Logging;
+import de.lmu.ifi.dbs.elki.utilities.Alias;
+import de.lmu.ifi.dbs.elki.utilities.exceptions.UnableToComplyException;
import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization;
import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.Parameterization;
+import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.SerializedParameterization;
import de.lmu.ifi.dbs.elki.workflow.OutputStep;
/**
@@ -65,32 +68,51 @@ import de.lmu.ifi.dbs.elki.workflow.OutputStep;
* @apiviz.composedOf OutputTabPanel
* @apiviz.composedOf SavedSettingsTabPanel
*/
-public class MultiStepGUI extends JPanel {
+@Alias({ "multi", "multigui", "multistepgui" })
+public class MultiStepGUI extends AbstractApplication {
/**
- * Serial version
+ * ELKI logger for the GUI
*/
- private static final long serialVersionUID = 1L;
+ private static final Logging LOG = Logging.getLogger(MultiStepGUI.class);
/**
- * ELKI logger for the GUI
+ * The frame
*/
- private static final Logging LOG = Logging.getLogger(MultiStepGUI.class);
+ JFrame frame;
/**
* Logging output area.
*/
protected LogPanel outputArea;
+ /**
+ * Input panel.
+ */
private InputTabPanel inputTab;
+ /**
+ * Algorithm panel.
+ */
private AlgorithmTabPanel algTab;
+ /**
+ * Evaluation panel.
+ */
private EvaluationTabPanel evalTab;
+ /**
+ * Output panel.
+ */
private OutputTabPanel outTab;
+ /**
+ * Logging panel.
+ */
private LoggingTabPanel logTab;
+ /**
+ * Saved settingspanel.
+ */
private SavedSettingsTabPanel setTab;
/**
@@ -98,7 +120,15 @@ public class MultiStepGUI extends JPanel {
*/
public MultiStepGUI() {
super();
- this.setLayout(new GridBagLayout());
+ frame = new JFrame("ELKI ExpGUI");
+ frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+ try {
+ frame.setIconImage(new ImageIcon(KDDTask.class.getResource("elki-icon.png")).getImage());
+ } catch (Exception e) {
+ // Ignore - icon not found is not fatal.
+ }
+
+ frame.setLayout(new GridBagLayout());
{
// setup text output area
outputArea = new LogPanel();
@@ -114,7 +144,7 @@ public class MultiStepGUI extends JPanel {
constraints.gridy = 1;
constraints.weightx = 1;
constraints.weighty = 1;
- add(outputPane, constraints);
+ frame.add(outputPane, constraints);
// reconfigure logging
outputArea.becomeDefaultLogger();
@@ -130,24 +160,23 @@ public class MultiStepGUI extends JPanel {
constraints.gridy = 0;
constraints.weightx = 1;
constraints.weighty = 1;
- add(panels, constraints);
+ frame.add(panels, constraints);
addPanels(panels);
}
+ frame.pack();
}
private void addPanels(JTabbedPane panels) {
SavedSettingsFile settings = new SavedSettingsFile(MiniGUI.SAVED_SETTINGS_FILENAME);
try {
settings.load();
- }
- catch(FileNotFoundException e) {
+ } catch (FileNotFoundException e) {
LOG.warning("Error loading saved settings.", e);
- }
- catch(IOException e) {
+ } catch (IOException e) {
LOG.exception(e);
}
-
+
inputTab = new InputTabPanel();
algTab = new AlgorithmTabPanel(inputTab);
evalTab = new EvaluationTabPanel(inputTab, algTab);
@@ -173,15 +202,15 @@ public class MultiStepGUI extends JPanel {
// Clear errors after each step, so they don't consider themselves failed
// because of earlier errors.
logTab.setParameters(config);
- //config.clearErrors();
+ // config.clearErrors();
inputTab.setParameters(config);
- //config.clearErrors();
+ // config.clearErrors();
algTab.setParameters(config);
- //config.clearErrors();
+ // config.clearErrors();
evalTab.setParameters(config);
- //config.clearErrors();
+ // config.clearErrors();
outTab.setParameters(config);
- //config.clearErrors();
+ // config.clearErrors();
}
/**
@@ -198,36 +227,11 @@ public class MultiStepGUI extends JPanel {
outTab.appendParameters(params);
return params.serialize();
}
-
- /**
- * Create the GUI and show it. For thread safety, this method should be
- * invoked from the event-dispatching thread.
- */
- protected static void createAndShowGUI() {
- // Create and set up the window.
- JFrame frame = new JFrame("ELKI ExpGUI");
- frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- try {
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- }
- catch(Exception e) {
- // ignore
- }
- try {
- frame.setIconImage(new ImageIcon(KDDTask.class.getResource("elki-icon.png")).getImage());
- }
- catch(Exception e) {
- // Ignore - icon not found is not fatal.
- }
-
- // Create and set up the content pane.
- MultiStepGUI newContentPane = new MultiStepGUI();
- newContentPane.setOpaque(true); // content panes must be opaque
- frame.setContentPane(newContentPane);
- // Display the window.
- frame.pack();
+ @Override
+ public void run() throws UnableToComplyException {
frame.setVisible(true);
+ outputArea.becomeDefaultLogger();
}
/**
@@ -235,13 +239,26 @@ public class MultiStepGUI extends JPanel {
*
* @param args command line parameters
*/
- public static void main(String[] args) {
+ public static void main(final String[] args) {
+ GUIUtil.logUncaughtExceptions(LOG);
+ GUIUtil.setLookAndFeel();
OutputStep.setDefaultHandlerVisualizer();
+
javax.swing.SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
- createAndShowGUI();
+ try {
+ final MultiStepGUI gui = new MultiStepGUI();
+ gui.run();
+ if (args != null && args.length > 0) {
+ gui.setParameters(new SerializedParameterization(args));
+ } else {
+ gui.setParameters(new SerializedParameterization());
+ }
+ } catch (UnableToComplyException e) {
+ LOG.exception(e);
+ }
}
});
}
-} \ No newline at end of file
+}
diff --git a/src/de/lmu/ifi/dbs/elki/gui/multistep/package-info.java b/src/de/lmu/ifi/dbs/elki/gui/multistep/package-info.java
index 35a08689..3e8f11b2 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/multistep/package-info.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/multistep/package-info.java
@@ -5,7 +5,7 @@
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
-Copyright (C) 2012
+Copyright (C) 2013
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
diff --git a/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/AlgorithmTabPanel.java b/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/AlgorithmTabPanel.java
index f6eb2955..d6622e8f 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/AlgorithmTabPanel.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/AlgorithmTabPanel.java
@@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.gui.multistep.panels;
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
- Copyright (C) 2012
+ Copyright (C) 2013
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
@@ -26,7 +26,6 @@ package de.lmu.ifi.dbs.elki.gui.multistep.panels;
import java.lang.ref.WeakReference;
import de.lmu.ifi.dbs.elki.database.Database;
-import de.lmu.ifi.dbs.elki.utilities.designpattern.Observer;
import de.lmu.ifi.dbs.elki.utilities.exceptions.AbortException;
import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.Parameterization;
import de.lmu.ifi.dbs.elki.workflow.AlgorithmStep;
@@ -36,7 +35,7 @@ import de.lmu.ifi.dbs.elki.workflow.AlgorithmStep;
*
* @author Erich Schubert
*/
-public class AlgorithmTabPanel extends ParameterTabPanel implements Observer<Object> {
+public class AlgorithmTabPanel extends ParameterTabPanel {
/**
* Serial version.
*/
@@ -65,13 +64,13 @@ public class AlgorithmTabPanel extends ParameterTabPanel implements Observer<Obj
public AlgorithmTabPanel(InputTabPanel input) {
super();
this.input = input;
- input.addObserver(this);
+ input.addPanelListener(this);
}
@Override
protected synchronized void configureStep(Parameterization config) {
algorithms = config.tryInstantiate(AlgorithmStep.class);
- if(config.getErrors().size() > 0) {
+ if (config.getErrors().size() > 0) {
algorithms = null;
}
basedOnDatabase = null;
@@ -79,10 +78,10 @@ public class AlgorithmTabPanel extends ParameterTabPanel implements Observer<Obj
@Override
protected void executeStep() {
- if(input.canRun() && !input.isComplete()) {
+ if (input.canRun() && !input.isComplete()) {
input.execute();
}
- if(!input.isComplete()) {
+ if (!input.isComplete()) {
throw new AbortException("Input data not available.");
}
// Get the database and run the algorithms
@@ -93,18 +92,17 @@ public class AlgorithmTabPanel extends ParameterTabPanel implements Observer<Obj
@Override
protected Status getStatus() {
- if(algorithms == null) {
+ if (algorithms == null) {
return Status.STATUS_UNCONFIGURED;
}
- if(!input.canRun()) {
+ if (!input.canRun()) {
return Status.STATUS_CONFIGURED;
}
checkDependencies();
- if(input.isComplete() && basedOnDatabase != null) {
- if(algorithms.getResult() == null) {
+ if (input.isComplete() && basedOnDatabase != null) {
+ if (algorithms.getResult() == null) {
return Status.STATUS_FAILED;
- }
- else {
+ } else {
return Status.STATUS_COMPLETE;
}
}
@@ -117,15 +115,15 @@ public class AlgorithmTabPanel extends ParameterTabPanel implements Observer<Obj
* @return Algorithm step
*/
public AlgorithmStep getAlgorithmStep() {
- if(algorithms == null) {
+ if (algorithms == null) {
throw new AbortException("Algorithms not configured.");
}
return algorithms;
}
@Override
- public void update(Object o) {
- if(o == input) {
+ public void panelUpdated(ParameterTabPanel o) {
+ if (o == input) {
checkDependencies();
updateStatus();
}
@@ -135,12 +133,12 @@ public class AlgorithmTabPanel extends ParameterTabPanel implements Observer<Obj
* Test if the dependencies are still valid.
*/
private void checkDependencies() {
- if(basedOnDatabase != null) {
- if(!input.isComplete() || basedOnDatabase.get() != input.getInputStep().getDatabase()) {
+ if (basedOnDatabase != null) {
+ if (!input.isComplete() || basedOnDatabase.get() != input.getInputStep().getDatabase()) {
// We've become invalidated, notify.
basedOnDatabase = null;
- observers.notifyObservers(this);
+ firePanelUpdated();
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/EvaluationTabPanel.java b/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/EvaluationTabPanel.java
index 9a74e250..d8d4153c 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/EvaluationTabPanel.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/EvaluationTabPanel.java
@@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.gui.multistep.panels;
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
- Copyright (C) 2012
+ Copyright (C) 2013
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
@@ -27,7 +27,6 @@ import java.lang.ref.WeakReference;
import de.lmu.ifi.dbs.elki.database.Database;
import de.lmu.ifi.dbs.elki.result.HierarchicalResult;
-import de.lmu.ifi.dbs.elki.utilities.designpattern.Observer;
import de.lmu.ifi.dbs.elki.utilities.exceptions.AbortException;
import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.Parameterization;
import de.lmu.ifi.dbs.elki.workflow.EvaluationStep;
@@ -37,7 +36,7 @@ import de.lmu.ifi.dbs.elki.workflow.EvaluationStep;
*
* @author Erich Schubert
*/
-public class EvaluationTabPanel extends ParameterTabPanel implements Observer<Object> {
+public class EvaluationTabPanel extends ParameterTabPanel {
/**
* Serial version.
*/
@@ -72,8 +71,8 @@ public class EvaluationTabPanel extends ParameterTabPanel implements Observer<Ob
super();
this.input = input;
this.algs = algs;
- input.addObserver(this);
- algs.addObserver(this);
+ input.addPanelListener(this);
+ algs.addPanelListener(this);
}
@Override
@@ -136,7 +135,7 @@ public class EvaluationTabPanel extends ParameterTabPanel implements Observer<Ob
}
@Override
- public void update(Object o) {
+ public void panelUpdated(ParameterTabPanel o) {
if (o == input || o == algs) {
checkDependencies();
updateStatus();
@@ -151,7 +150,7 @@ public class EvaluationTabPanel extends ParameterTabPanel implements Observer<Ob
if (!input.isComplete() || !algs.isComplete() || basedOnResult.get() != algs.getAlgorithmStep().getResult()) {
// We've become invalidated, notify.
basedOnResult = null;
- observers.notifyObservers(this);
+ firePanelUpdated();
}
}
}
diff --git a/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/InputTabPanel.java b/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/InputTabPanel.java
index 9d88e900..2f4d027b 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/InputTabPanel.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/InputTabPanel.java
@@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.gui.multistep.panels;
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
- Copyright (C) 2012
+ Copyright (C) 2013
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
diff --git a/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/LoggingTabPanel.java b/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/LoggingTabPanel.java
index 5bf4c086..c4933673 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/LoggingTabPanel.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/LoggingTabPanel.java
@@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.gui.multistep.panels;
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
- Copyright (C) 2012
+ Copyright (C) 2013
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
@@ -23,9 +23,10 @@ package de.lmu.ifi.dbs.elki.gui.multistep.panels;
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+import de.lmu.ifi.dbs.elki.application.AbstractApplication;
import de.lmu.ifi.dbs.elki.logging.LoggingConfiguration;
import de.lmu.ifi.dbs.elki.logging.LoggingUtil;
-import de.lmu.ifi.dbs.elki.utilities.optionhandling.OptionID;
+import de.lmu.ifi.dbs.elki.logging.Logging.Level;
import de.lmu.ifi.dbs.elki.utilities.optionhandling.WrongParameterValueException;
import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.Parameterization;
import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameters.Flag;
@@ -51,13 +52,14 @@ public class LoggingTabPanel extends ParameterTabPanel {
@Override
protected synchronized void configureStep(Parameterization config) {
- StringParameter debugParam = new StringParameter(OptionID.DEBUG);
+ StringParameter debugParam = new StringParameter(AbstractApplication.Parameterizer.DEBUG_ID);
debugParam.setOptional(true);
- Flag verboseFlag = new Flag(OptionID.VERBOSE_FLAG);
+ Flag verboseFlag = new Flag(AbstractApplication.Parameterizer.VERBOSE_ID);
// Verbose mode is a lot simpler
if (config.grab(verboseFlag) && verboseFlag.isTrue()) {
- LoggingConfiguration.setVerbose(true);
+ LoggingConfiguration.setVerbose(Level.VERBOSE);
}
+ // FIXME: add second level of verbosity!
if (config.grab(debugParam)) {
try {
LoggingUtil.parseDebugParameter(debugParam);
diff --git a/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/OutputTabPanel.java b/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/OutputTabPanel.java
index 48ddc344..12af18d3 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/OutputTabPanel.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/OutputTabPanel.java
@@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.gui.multistep.panels;
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
- Copyright (C) 2012
+ Copyright (C) 2013
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
@@ -26,7 +26,6 @@ package de.lmu.ifi.dbs.elki.gui.multistep.panels;
import java.lang.ref.WeakReference;
import de.lmu.ifi.dbs.elki.result.HierarchicalResult;
-import de.lmu.ifi.dbs.elki.utilities.designpattern.Observer;
import de.lmu.ifi.dbs.elki.utilities.exceptions.AbortException;
import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.Parameterization;
import de.lmu.ifi.dbs.elki.workflow.OutputStep;
@@ -36,7 +35,7 @@ import de.lmu.ifi.dbs.elki.workflow.OutputStep;
*
* @author Erich Schubert
*/
-public class OutputTabPanel extends ParameterTabPanel implements Observer<Object> {
+public class OutputTabPanel extends ParameterTabPanel {
/**
* Serial version.
*/
@@ -71,8 +70,8 @@ public class OutputTabPanel extends ParameterTabPanel implements Observer<Object
super();
this.input = input;
this.evals = evals;
- input.addObserver(this);
- evals.addObserver(this);
+ input.addPanelListener(this);
+ evals.addPanelListener(this);
}
@Override
@@ -121,7 +120,7 @@ public class OutputTabPanel extends ParameterTabPanel implements Observer<Object
}
@Override
- public void update(Object o) {
+ public void panelUpdated(ParameterTabPanel o) {
if (o == input || o == evals) {
checkDependencies();
updateStatus();
@@ -136,7 +135,7 @@ public class OutputTabPanel extends ParameterTabPanel implements Observer<Object
if (!input.isComplete() || !evals.isComplete() || basedOnResult.get() != evals.getEvaluationStep().getResult()) {
// We've become invalidated, notify.
basedOnResult = null;
- observers.notifyObservers(this);
+ firePanelUpdated();
}
}
}
diff --git a/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/ParameterTabPanel.java b/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/ParameterTabPanel.java
index cb72e6cd..667960a1 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/ParameterTabPanel.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/ParameterTabPanel.java
@@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.gui.multistep.panels;
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
- Copyright (C) 2012
+ Copyright (C) 2013
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
@@ -40,8 +40,6 @@ import javax.swing.event.ChangeListener;
import de.lmu.ifi.dbs.elki.gui.configurator.ConfiguratorPanel;
import de.lmu.ifi.dbs.elki.logging.Logging;
import de.lmu.ifi.dbs.elki.utilities.FormatUtil;
-import de.lmu.ifi.dbs.elki.utilities.designpattern.Observer;
-import de.lmu.ifi.dbs.elki.utilities.designpattern.Observers;
import de.lmu.ifi.dbs.elki.utilities.optionhandling.ParameterException;
import de.lmu.ifi.dbs.elki.utilities.optionhandling.UnspecifiedParameterException;
import de.lmu.ifi.dbs.elki.utilities.optionhandling.parameterization.ListParameterization;
@@ -131,11 +129,6 @@ public abstract class ParameterTabPanel extends JPanel implements ChangeListener
private final JLabel statusText;
/**
- * Observers of this panel
- */
- protected final Observers<ParameterTabPanel> observers = new Observers<ParameterTabPanel>();
-
- /**
* Input pane
*/
public ParameterTabPanel() {
@@ -237,7 +230,7 @@ public abstract class ParameterTabPanel extends JPanel implements ChangeListener
// Update status and notify observers
updateStatus();
- observers.notifyObservers(this);
+ firePanelUpdated();
}
/**
@@ -291,7 +284,7 @@ public abstract class ParameterTabPanel extends JPanel implements ChangeListener
LOG.exception(e);
}
updateStatus();
- observers.notifyObservers(this);
+ firePanelUpdated();
}
/**
@@ -347,12 +340,18 @@ public abstract class ParameterTabPanel extends JPanel implements ChangeListener
runButton.setEnabled(canRun());
}
- public void addObserver(Observer<? super ParameterTabPanel> o) {
- observers.add(o);
+ protected void firePanelUpdated() {
+ for (ParameterTabPanel p : listenerList.getListeners(ParameterTabPanel.class)) {
+ p.panelUpdated(this);
+ }
+ }
+
+ public void addPanelListener(ParameterTabPanel o) {
+ listenerList.add(ParameterTabPanel.class, o);
}
- public void removeObserver(Observer<? super ParameterTabPanel> o) {
- observers.remove(o);
+ public void removePanelListener(ParameterTabPanel o) {
+ listenerList.remove(ParameterTabPanel.class, o);
}
@Override
@@ -362,4 +361,13 @@ public abstract class ParameterTabPanel extends JPanel implements ChangeListener
updateParameterTable();
}
}
+
+ /**
+ * Called when an observed panel changes.
+ *
+ * @param o Observed panel
+ */
+ void panelUpdated(ParameterTabPanel o) {
+ // Do nothing by default.
+ };
}
diff --git a/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/SavedSettingsTabPanel.java b/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/SavedSettingsTabPanel.java
index 845df73c..acebdc16 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/SavedSettingsTabPanel.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/SavedSettingsTabPanel.java
@@ -1,9 +1,10 @@
package de.lmu.ifi.dbs.elki.gui.multistep.panels;
+
/*
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
- Copyright (C) 2012
+ Copyright (C) 2013
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
@@ -73,7 +74,7 @@ public class SavedSettingsTabPanel extends JPanel {
/**
* The combo box to use
*/
- JComboBox savedCombo;
+ JComboBox<String> savedCombo;
/**
* The UI to set parameters on.
@@ -96,7 +97,7 @@ public class SavedSettingsTabPanel extends JPanel {
// Dropdown for saved settings
{
savedSettingsModel = new SettingsComboboxModel(store);
- savedCombo = new JComboBox(savedSettingsModel);
+ savedCombo = new JComboBox<>(savedSettingsModel);
savedCombo.setEditable(true);
savedCombo.setSelectedItem("[Saved Settings]");
GridBagConstraints constraints = new GridBagConstraints();
@@ -111,7 +112,7 @@ public class SavedSettingsTabPanel extends JPanel {
{
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
-
+
// button to load settings
JButton loadButton = new JButton("Load");
loadButton.setMnemonic(KeyEvent.VK_L);
@@ -137,8 +138,7 @@ public class SavedSettingsTabPanel extends JPanel {
store.put(key, gui.serializeParameters());
try {
store.save();
- }
- catch(IOException e1) {
+ } catch (IOException e1) {
LOG.exception(e1);
}
savedSettingsModel.update();
@@ -155,8 +155,7 @@ public class SavedSettingsTabPanel extends JPanel {
store.remove(key);
try {
store.save();
- }
- catch(IOException e1) {
+ } catch (IOException e1) {
LOG.exception(e1);
}
savedCombo.setSelectedItem("[Saved Settings]");
@@ -164,7 +163,7 @@ public class SavedSettingsTabPanel extends JPanel {
}
});
buttonPanel.add(removeButton);
-
+
GridBagConstraints constraints = new GridBagConstraints();
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.gridx = 0;
@@ -182,7 +181,7 @@ public class SavedSettingsTabPanel extends JPanel {
*
* @apiviz.composedOf de.lmu.ifi.dbs.elki.gui.util.SavedSettingsFile
*/
- class SettingsComboboxModel extends AbstractListModel implements ComboBoxModel {
+ class SettingsComboboxModel extends AbstractListModel<String> implements ComboBoxModel<String> {
/**
* Serial version
*/
@@ -215,14 +214,14 @@ public class SavedSettingsTabPanel extends JPanel {
@Override
public void setSelectedItem(Object anItem) {
- if(anItem instanceof String) {
+ if (anItem instanceof String) {
selected = (String) anItem;
}
}
@Override
- public Object getElementAt(int index) {
- return store.getElementAt(index).first;
+ public String getElementAt(int index) {
+ return store.getElementAt(store.size() - 1 - index).first;
}
@Override
@@ -237,4 +236,4 @@ public class SavedSettingsTabPanel extends JPanel {
fireContentsChanged(this, 0, getSize() + 1);
}
}
-} \ No newline at end of file
+}
diff --git a/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/package-info.java b/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/package-info.java
index b9d4d90a..77d1779d 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/package-info.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/multistep/panels/package-info.java
@@ -5,7 +5,7 @@
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
-Copyright (C) 2012
+Copyright (C) 2013
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
diff --git a/src/de/lmu/ifi/dbs/elki/gui/package-info.java b/src/de/lmu/ifi/dbs/elki/gui/package-info.java
index 34a29371..8fa23e0d 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/package-info.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/package-info.java
@@ -5,7 +5,7 @@
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
-Copyright (C) 2012
+Copyright (C) 2013
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
diff --git a/src/de/lmu/ifi/dbs/elki/gui/util/DynamicParameters.java b/src/de/lmu/ifi/dbs/elki/gui/util/DynamicParameters.java
index e9c80da6..d974a6d6 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/util/DynamicParameters.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/util/DynamicParameters.java
@@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.gui.util;
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
- Copyright (C) 2012
+ Copyright (C) 2013
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
@@ -122,7 +122,7 @@ public class DynamicParameters {
*/
public DynamicParameters() {
super();
- this.parameters = new ArrayList<Node>();
+ this.parameters = new ArrayList<>();
}
/**
@@ -213,7 +213,7 @@ public class DynamicParameters {
* @return Array list of String parameters.
*/
public synchronized ArrayList<String> serializeParameters() {
- ArrayList<String> p = new ArrayList<String>(2 * parameters.size());
+ ArrayList<String> p = new ArrayList<>(2 * parameters.size());
for (Node t : parameters) {
if (t.param != null) {
if (t.param instanceof RemainingOptions) {
diff --git a/src/de/lmu/ifi/dbs/elki/gui/util/LogPane.java b/src/de/lmu/ifi/dbs/elki/gui/util/LogPane.java
index dcc2cf5b..4664b852 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/util/LogPane.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/util/LogPane.java
@@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.gui.util;
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
- Copyright (C) 2012
+ Copyright (C) 2013
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
diff --git a/src/de/lmu/ifi/dbs/elki/gui/util/LogPanel.java b/src/de/lmu/ifi/dbs/elki/gui/util/LogPanel.java
index cb410ee9..23bbb3f2 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/util/LogPanel.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/util/LogPanel.java
@@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.gui.util;
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
- Copyright (C) 2012
+ Copyright (C) 2013
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
@@ -67,7 +67,7 @@ public class LogPanel extends JPanel {
/**
* Current progress bars
*/
- protected HashMap<Progress, JProgressBar> pbarmap = new HashMap<Progress, JProgressBar>();
+ protected HashMap<Progress, JProgressBar> pbarmap = new HashMap<>();
/**
* Constructor.
diff --git a/src/de/lmu/ifi/dbs/elki/gui/util/ParameterTable.java b/src/de/lmu/ifi/dbs/elki/gui/util/ParameterTable.java
index a28d3f43..105242c0 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/util/ParameterTable.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/util/ParameterTable.java
@@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.gui.util;
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
- Copyright (C) 2012
+ Copyright (C) 2013
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
@@ -27,21 +27,29 @@ import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
+import java.awt.FileDialog;
+import java.awt.Frame;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
import java.io.File;
import java.util.BitSet;
import javax.swing.AbstractCellEditor;
+import javax.swing.Action;
+import javax.swing.ActionMap;
import javax.swing.DefaultCellEditor;
+import javax.swing.InputMap;
import javax.swing.JButton;
import javax.swing.JComboBox;
-import javax.swing.JFileChooser;
+import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.JTextField;
+import javax.swing.KeyStroke;
+import javax.swing.SwingUtilities;
import javax.swing.plaf.basic.BasicComboPopup;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellEditor;
@@ -94,6 +102,11 @@ public class ParameterTable extends JTable {
static final Color COLOR_DEFAULT_VALUE = new Color(0xDFDFDF);
/**
+ * Containing frame.
+ */
+ protected Frame frame;
+
+ /**
* The parameters we edit.
*/
protected DynamicParameters parameters;
@@ -101,11 +114,13 @@ public class ParameterTable extends JTable {
/**
* Constructor
*
+ * @param frame Containing frame
* @param pm Parameter Model
* @param parameters Parameter storage
*/
- public ParameterTable(ParametersModel pm, DynamicParameters parameters) {
+ public ParameterTable(Frame frame, ParametersModel pm, DynamicParameters parameters) {
super(pm);
+ this.frame = frame;
this.parameters = parameters;
this.setPreferredScrollableViewportSize(new Dimension(800, 400));
this.setFillsViewportHeight(true);
@@ -141,16 +156,16 @@ public class ParameterTable extends JTable {
@Override
public void setValue(Object value) {
- if(value instanceof String) {
+ if (value instanceof String) {
setText((String) value);
setToolTipText(null);
return;
}
- if(value instanceof DynamicParameters.Node) {
+ if (value instanceof DynamicParameters.Node) {
Parameter<?> o = ((DynamicParameters.Node) value).param;
// Simulate a tree using indentation - there is no JTreeTable AFAICT
StringBuilder buf = new StringBuilder();
- for(int i = 1; i < ((DynamicParameters.Node) value).depth; i++) {
+ for (int i = 1; i < ((DynamicParameters.Node) value).depth; i++) {
buf.append(' ');
}
buf.append(o.getOptionID().getName());
@@ -165,27 +180,24 @@ public class ParameterTable extends JTable {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
- if(row < parameters.size()) {
- BitSet flags = parameters.getNode(row).flags;
- // TODO: don't hardcode black - maybe mix the other colors, too?
- c.setForeground(Color.BLACK);
- if((flags.get(DynamicParameters.BIT_INVALID))) {
- c.setBackground(COLOR_SYNTAX_ERROR);
- }
- else if((flags.get(DynamicParameters.BIT_SYNTAX_ERROR))) {
- c.setBackground(COLOR_SYNTAX_ERROR);
- }
- else if((flags.get(DynamicParameters.BIT_INCOMPLETE))) {
- c.setBackground(COLOR_INCOMPLETE);
- }
- else if((flags.get(DynamicParameters.BIT_DEFAULT_VALUE))) {
- c.setBackground(COLOR_DEFAULT_VALUE);
- }
- else if((flags.get(DynamicParameters.BIT_OPTIONAL))) {
- c.setBackground(COLOR_OPTIONAL);
- }
- else {
- c.setBackground(null);
+ if (!hasFocus) {
+ if (row < parameters.size()) {
+ BitSet flags = parameters.getNode(row).flags;
+ // TODO: don't hardcode black - maybe mix the other colors, too?
+ c.setForeground(Color.BLACK);
+ if ((flags.get(DynamicParameters.BIT_INVALID))) {
+ c.setBackground(COLOR_SYNTAX_ERROR);
+ } else if ((flags.get(DynamicParameters.BIT_SYNTAX_ERROR))) {
+ c.setBackground(COLOR_SYNTAX_ERROR);
+ } else if ((flags.get(DynamicParameters.BIT_INCOMPLETE))) {
+ c.setBackground(COLOR_INCOMPLETE);
+ } else if ((flags.get(DynamicParameters.BIT_DEFAULT_VALUE))) {
+ c.setBackground(COLOR_DEFAULT_VALUE);
+ } else if ((flags.get(DynamicParameters.BIT_OPTIONAL))) {
+ c.setBackground(COLOR_OPTIONAL);
+ } else {
+ c.setBackground(null);
+ }
}
}
return c;
@@ -204,75 +216,89 @@ public class ParameterTable extends JTable {
private static final long serialVersionUID = 1L;
/**
+ * We need a panel to ensure focusing.
+ */
+ final JPanel panel;
+
+ /**
* Combo box to use
*/
- private final JComboBox comboBox;
+ private final JComboBox<String> comboBox;
/**
* Constructor.
*
* @param comboBox Combo box we're going to use
*/
- public DropdownEditor(JComboBox comboBox) {
+ public DropdownEditor(JComboBox<String> comboBox) {
super(comboBox);
this.comboBox = comboBox;
+ panel = new DispatchingPanel((JComponent) comboBox.getEditor().getEditorComponent());
+ panel.setLayout(new BorderLayout());
+ panel.add(comboBox, BorderLayout.CENTER);
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
- Component c = super.getTableCellEditorComponent(table, value, isSelected, row, column);
// remove old contents
comboBox.removeAllItems();
// Put the current value in first.
Object val = table.getValueAt(row, column);
- if(val != null) {
- comboBox.addItem(val);
- comboBox.setSelectedIndex(0);
+ if (val != null && val instanceof String) {
+ String sval = (String) val;
+ if (sval.equals(DynamicParameters.STRING_OPTIONAL)) {
+ sval = "";
+ }
+ if (sval.startsWith(DynamicParameters.STRING_USE_DEFAULT)) {
+ sval = "";
+ }
+ if (sval != "") {
+ comboBox.addItem(sval);
+ comboBox.setSelectedIndex(0);
+ }
}
- if(row < parameters.size()) {
+ if (row < parameters.size()) {
Parameter<?> option = parameters.getNode(row).param;
// We can do dropdown choices for class parameters
- if(option instanceof ClassParameter<?>) {
+ if (option instanceof ClassParameter<?>) {
ClassParameter<?> cp = (ClassParameter<?>) option;
// For parameters with a default value, offer using the default
// For optional parameters, offer not specifying them.
- if(cp.hasDefaultValue()) {
+ if (cp.hasDefaultValue()) {
comboBox.addItem(DynamicParameters.STRING_USE_DEFAULT + cp.getDefaultValueAsString());
- }
- else if(cp.isOptional()) {
+ } else if (cp.isOptional()) {
comboBox.addItem(DynamicParameters.STRING_OPTIONAL);
}
// Offer the shorthand version of class names.
- for(Class<?> impl : cp.getKnownImplementations()) {
+ for (Class<?> impl : cp.getKnownImplementations()) {
comboBox.addItem(ClassParameter.canonicalClassName(impl, cp.getRestrictionClass()));
}
}
// and for Flag parameters.
- else if(option instanceof Flag) {
- if(!Flag.SET.equals(val)) {
+ else if (option instanceof Flag) {
+ if (!Flag.SET.equals(val)) {
comboBox.addItem(Flag.SET);
}
- if(!Flag.NOT_SET.equals(val)) {
+ if (!Flag.NOT_SET.equals(val)) {
comboBox.addItem(Flag.NOT_SET);
}
}
// and for Enum parameters.
- else if(option instanceof EnumParameter<?>) {
+ else if (option instanceof EnumParameter<?>) {
EnumParameter<?> ep = (EnumParameter<?>) option;
- for(String s : ep.getPossibleValues()) {
- if(ep.hasDefaultValue() && ep.getDefaultValueAsString().equals(s)) {
- if(!(DynamicParameters.STRING_USE_DEFAULT + ep.getDefaultValueAsString()).equals(val)) {
+ for (String s : ep.getPossibleValues()) {
+ if (ep.hasDefaultValue() && ep.getDefaultValueAsString().equals(s)) {
+ if (!(DynamicParameters.STRING_USE_DEFAULT + ep.getDefaultValueAsString()).equals(val)) {
comboBox.addItem(DynamicParameters.STRING_USE_DEFAULT + s);
}
- }
- else if(!s.equals(val)) {
+ } else if (!s.equals(val)) {
comboBox.addItem(s);
}
}
}
// No completion for others
}
- return c;
+ return panel;
}
}
@@ -290,7 +316,7 @@ public class ParameterTable extends JTable {
/**
* We need a panel to put our components on.
*/
- final JPanel panel = new JPanel();
+ final JPanel panel;
/**
* Text field to store the name
@@ -303,10 +329,16 @@ public class ParameterTable extends JTable {
final JButton button = new JButton("...");
/**
+ * File selector mode.
+ */
+ int mode = FileDialog.LOAD;
+
+ /**
* Constructor.
*/
public FileNameEditor() {
button.addActionListener(this);
+ panel = new DispatchingPanel(textfield);
panel.setLayout(new BorderLayout());
panel.add(textfield, BorderLayout.CENTER);
panel.add(button, BorderLayout.EAST);
@@ -317,19 +349,35 @@ public class ParameterTable extends JTable {
*/
@Override
public void actionPerformed(ActionEvent e) {
- final JFileChooser fc = new JFileChooser(new File("."));
+ final FileDialog fc = new FileDialog(frame);
+ fc.setDirectory((new File(".")).getAbsolutePath());
+ fc.setMode(mode);
final String curr = textfield.getText();
if (curr != null && curr.length() > 0) {
- fc.setSelectedFile(new File(curr));
+ fc.setFile(curr);
}
- int returnVal = fc.showOpenDialog(button);
-
- if(returnVal == JFileChooser.APPROVE_OPTION) {
- textfield.setText(fc.getSelectedFile().getPath());
- }
- else {
- // Do nothing on cancel.
+ fc.setVisible(true);
+ String filename = fc.getFile();
+ if (filename != null) {
+ textfield.setText(new File(fc.getDirectory(), filename).getPath());
}
+ fc.dispose();
+ textfield.requestFocus();
+
+ // Swing file chooser. Currently much worse on Linux/GTK.
+ // final JFileChooser fc = new JFileChooser(new File("."));
+ // final String curr = textfield.getText();
+ // if (curr != null && curr.length() > 0) {
+ // fc.setSelectedFile(new File(curr));
+ // }
+ // int returnVal = fc.showOpenDialog(button);
+ //
+ // if(returnVal == JFileChooser.APPROVE_OPTION) {
+ // textfield.setText(fc.getSelectedFile().getPath());
+ // }
+ // else {
+ // // Do nothing on cancel.
+ // }
fireEditingStopped();
}
@@ -346,23 +394,24 @@ public class ParameterTable extends JTable {
*/
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
- if(row < parameters.size()) {
+ if (row < parameters.size()) {
Parameter<?> option = parameters.getNode(row).param;
- if(option instanceof FileParameter) {
+ if (option instanceof FileParameter) {
FileParameter fp = (FileParameter) option;
File f = null;
- if(fp.isDefined()) {
+ mode = FileParameter.FileType.INPUT_FILE.equals(fp.getFileType()) ? FileDialog.LOAD : FileDialog.SAVE;
+ if (fp.isDefined()) {
f = fp.getValue();
}
- if(f != null) {
+ if (f != null) {
String fn = f.getPath();
textfield.setText(fn);
- }
- else {
+ } else {
textfield.setText("");
}
}
}
+ textfield.requestFocus();
return panel;
}
}
@@ -381,7 +430,7 @@ public class ParameterTable extends JTable {
/**
* We need a panel to put our components on.
*/
- final JPanel panel = new JPanel();
+ final JPanel panel;
/**
* Text field to store the name
@@ -396,7 +445,7 @@ public class ParameterTable extends JTable {
/**
* The combobox we are abusing to produce the popup
*/
- final JComboBox combo = new JComboBox();
+ final JComboBox<String> combo = new JComboBox<>();
/**
* The popup menu.
@@ -413,6 +462,8 @@ public class ParameterTable extends JTable {
combo.addActionListener(this);
popup = new SuperPopup(combo);
+ panel = new DispatchingPanel(textfield);
+
panel.setLayout(new BorderLayout());
panel.add(textfield, BorderLayout.CENTER);
panel.add(button, BorderLayout.EAST);
@@ -423,31 +474,28 @@ public class ParameterTable extends JTable {
*/
@Override
public void actionPerformed(ActionEvent e) {
- if(e.getSource() == button) {
+ if (e.getSource() == button) {
popup.show(panel);
- }
- else if(e.getSource() == combo) {
+ } else if (e.getSource() == combo) {
String newClass = (String) combo.getSelectedItem();
- if(newClass != null && newClass.length() > 0) {
+ if (newClass != null && newClass.length() > 0) {
String val = textfield.getText();
- if(val.equals(DynamicParameters.STRING_OPTIONAL)) {
+ if (val.equals(DynamicParameters.STRING_OPTIONAL)) {
val = "";
}
- if(val.startsWith(DynamicParameters.STRING_USE_DEFAULT)) {
+ if (val.startsWith(DynamicParameters.STRING_USE_DEFAULT)) {
val = "";
}
- if(val.length() > 0) {
+ if (val.length() > 0) {
val = val + ClassListParameter.LIST_SEP + newClass;
- }
- else {
+ } else {
val = newClass;
}
textfield.setText(val);
popup.hide();
}
fireEditingStopped();
- }
- else {
+ } else {
LoggingUtil.warning("Unrecognized action event in ClassListEditor: " + e);
}
}
@@ -470,7 +518,7 @@ public class ParameterTable extends JTable {
*
* @param combo Combo box used for data storage.
*/
- public SuperPopup(JComboBox combo) {
+ public SuperPopup(JComboBox<String> combo) {
super(combo);
}
@@ -516,30 +564,28 @@ public class ParameterTable extends JTable {
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
combo.removeAllItems();
- if(row < parameters.size()) {
+ if (row < parameters.size()) {
Parameter<?> option = parameters.getNode(row).param;
// We can do dropdown choices for class parameters
- if(option instanceof ClassListParameter<?>) {
+ if (option instanceof ClassListParameter<?>) {
ClassListParameter<?> cp = (ClassListParameter<?>) option;
// Offer the shorthand version of class names.
String prefix = cp.getRestrictionClass().getPackage().getName() + ".";
- for(Class<?> impl : cp.getKnownImplementations()) {
+ for (Class<?> impl : cp.getKnownImplementations()) {
String name = impl.getName();
- if(name.startsWith(prefix)) {
+ if (name.startsWith(prefix)) {
name = name.substring(prefix.length());
}
combo.addItem(name);
}
}
- if(option.isDefined()) {
- if(option.tookDefaultValue()) {
+ if (option.isDefined()) {
+ if (option.tookDefaultValue()) {
textfield.setText(DynamicParameters.STRING_USE_DEFAULT + option.getDefaultValueAsString());
- }
- else {
+ } else {
textfield.setText(option.getValueAsString());
}
- }
- else {
+ } else {
textfield.setText("");
}
}
@@ -593,7 +639,7 @@ public class ParameterTable extends JTable {
* Constructor.
*/
public AdjustingEditor() {
- final JComboBox combobox = new JComboBox();
+ final JComboBox<String> combobox = new JComboBox<>();
combobox.setEditable(true);
this.dropdownEditor = new DropdownEditor(combobox);
this.plaintextEditor = new DefaultCellEditor(new JTextField());
@@ -603,7 +649,7 @@ public class ParameterTable extends JTable {
@Override
public Object getCellEditorValue() {
- if(activeEditor == null) {
+ if (activeEditor == null) {
return null;
}
return activeEditor.getCellEditorValue();
@@ -611,31 +657,31 @@ public class ParameterTable extends JTable {
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
- if(value instanceof String) {
+ if (value instanceof String) {
String s = (String) value;
- if(s.startsWith(DynamicParameters.STRING_USE_DEFAULT)) {
+ if (s.startsWith(DynamicParameters.STRING_USE_DEFAULT)) {
value = s.substring(DynamicParameters.STRING_USE_DEFAULT.length());
}
}
- if(row < parameters.size()) {
+ if (row < parameters.size()) {
Parameter<?> option = parameters.getNode(row).param;
- if(option instanceof Flag) {
+ if (option instanceof Flag) {
activeEditor = dropdownEditor;
return dropdownEditor.getTableCellEditorComponent(table, value, isSelected, row, column);
}
- if(option instanceof ClassListParameter<?>) {
+ if (option instanceof ClassListParameter<?>) {
activeEditor = classListEditor;
return classListEditor.getTableCellEditorComponent(table, value, isSelected, row, column);
}
- if(option instanceof ClassParameter<?>) {
+ if (option instanceof ClassParameter<?>) {
activeEditor = dropdownEditor;
return dropdownEditor.getTableCellEditorComponent(table, value, isSelected, row, column);
}
- if(option instanceof FileParameter) {
+ if (option instanceof FileParameter) {
activeEditor = fileNameEditor;
return fileNameEditor.getTableCellEditorComponent(table, value, isSelected, row, column);
}
- if(option instanceof EnumParameter<?>) {
+ if (option instanceof EnumParameter<?>) {
activeEditor = dropdownEditor;
return dropdownEditor.getTableCellEditorComponent(table, value, isSelected, row, column);
}
@@ -644,4 +690,57 @@ public class ParameterTable extends JTable {
return plaintextEditor.getTableCellEditorComponent(table, value, isSelected, row, column);
}
}
-} \ No newline at end of file
+
+ /**
+ * This is a panel that will dispatch keystrokes to a particular component.
+ *
+ * This makes the tabular GUI much more user friendly.
+ *
+ * @author Erich Schubert
+ *
+ * @apiviz.exclude
+ */
+ private class DispatchingPanel extends JPanel {
+ /**
+ * Serial version.
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Component to dispatch to.
+ */
+ protected JComponent component;
+
+ /**
+ * Constructor.
+ *
+ * @param component Component to dispatch to.
+ */
+ public DispatchingPanel(JComponent component) {
+ super();
+ this.component = component;
+ setRequestFocusEnabled(true);
+ }
+
+ @Override
+ public void addNotify() {
+ super.addNotify();
+ component.requestFocus();
+ }
+
+ @Override
+ protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) {
+ InputMap map = component.getInputMap(condition);
+ ActionMap am = component.getActionMap();
+
+ if (map != null && am != null && isEnabled()) {
+ Object binding = map.get(ks);
+ Action action = (binding == null) ? null : am.get(binding);
+ if (action != null) {
+ return SwingUtilities.notifyAction(action, ks, e, component, e.getModifiers());
+ }
+ }
+ return false;
+ }
+ };
+}
diff --git a/src/de/lmu/ifi/dbs/elki/gui/util/ParametersModel.java b/src/de/lmu/ifi/dbs/elki/gui/util/ParametersModel.java
index 2f910977..42f0a1af 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/util/ParametersModel.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/util/ParametersModel.java
@@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.gui.util;
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
- Copyright (C) 2012
+ Copyright (C) 2013
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
diff --git a/src/de/lmu/ifi/dbs/elki/gui/util/SavedSettingsFile.java b/src/de/lmu/ifi/dbs/elki/gui/util/SavedSettingsFile.java
index cf9f5d62..a99b7414 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/util/SavedSettingsFile.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/util/SavedSettingsFile.java
@@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.gui.util;
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
- Copyright (C) 2012
+ Copyright (C) 2013
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team
@@ -64,7 +64,7 @@ public class SavedSettingsFile implements Iterable<Pair<String, ArrayList<String
public SavedSettingsFile(String filename) {
super();
this.file = new File(filename);
- this.store = new ArrayList<Pair<String, ArrayList<String>>>();
+ this.store = new ArrayList<>();
}
/**
@@ -93,7 +93,7 @@ public class SavedSettingsFile implements Iterable<Pair<String, ArrayList<String
*/
public void load() throws FileNotFoundException, IOException {
BufferedReader is = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
- ArrayList<String> buf = new ArrayList<String>();
+ ArrayList<String> buf = new ArrayList<>();
while (is.ready()) {
String line = is.readLine();
// skip comments
@@ -102,17 +102,18 @@ public class SavedSettingsFile implements Iterable<Pair<String, ArrayList<String
}
if (line.length() == 0 && buf.size() > 0) {
String title = buf.remove(0);
- store.add(new Pair<String,ArrayList<String>>(title, buf));
- buf = new ArrayList<String>();
+ store.add(new Pair<>(title, buf));
+ buf = new ArrayList<>();
} else {
buf.add(line);
}
}
if (buf.size() > 0) {
String title = buf.remove(0);
- store.add(new Pair<String,ArrayList<String>>(title, buf));
- buf = new ArrayList<String>();
+ store.add(new Pair<>(title, buf));
+ buf = new ArrayList<>();
}
+ is.close();
}
@Override
@@ -175,7 +176,7 @@ public class SavedSettingsFile implements Iterable<Pair<String, ArrayList<String
return;
}
}
- store.add(new Pair<String, ArrayList<String>>(key, value));
+ store.add(new Pair<>(key, value));
}
/**
diff --git a/src/de/lmu/ifi/dbs/elki/gui/util/package-info.java b/src/de/lmu/ifi/dbs/elki/gui/util/package-info.java
index de9f582a..706f587a 100644
--- a/src/de/lmu/ifi/dbs/elki/gui/util/package-info.java
+++ b/src/de/lmu/ifi/dbs/elki/gui/util/package-info.java
@@ -5,7 +5,7 @@
This file is part of ELKI:
Environment for Developing KDD-Applications Supported by Index-Structures
-Copyright (C) 2012
+Copyright (C) 2013
Ludwig-Maximilians-Universität München
Lehr- und Forschungseinheit für Datenbanksysteme
ELKI Development Team