From 961a991bcb578a534eb2af6b4853d0c66fe92085 Mon Sep 17 00:00:00 2001 From: Philipp Spohr <spohr.philipp@web.de> Date: Thu, 17 Aug 2017 12:03:12 +0200 Subject: [PATCH] Added more "clean" logging Some more components representing parameters --- .../ba/yoshikoWrapper/core/YoshikoLoader.java | 9 ++- .../yoshikoWrapper/gui/DoubleInputField.java | 6 +- .../ba/yoshikoWrapper/gui/EditCostPanel.java | 26 +++++++++ .../ba/yoshikoWrapper/gui/FormatHelper.java | 6 +- .../hhu/ba/yoshikoWrapper/gui/MainPanel.java | 10 ++-- .../gui/ModificationCostMapper.java | 2 +- .../yoshikoWrapper/gui/YoshikoHelpDialog.java | 14 +++++ .../yoshikoWrapper/gui/YoshikoHelpModel.java | 57 +++++++++++++++++++ .../yoshikoWrapper/logging/YoshikoLogger.java | 28 +++++++++ .../yoshikoWrapper/logging/package-info.java | 4 ++ 10 files changed, 149 insertions(+), 13 deletions(-) create mode 100644 src/main/java/de/hhu/ba/yoshikoWrapper/gui/EditCostPanel.java create mode 100644 src/main/java/de/hhu/ba/yoshikoWrapper/gui/YoshikoHelpDialog.java create mode 100644 src/main/java/de/hhu/ba/yoshikoWrapper/gui/YoshikoHelpModel.java create mode 100644 src/main/java/de/hhu/ba/yoshikoWrapper/logging/YoshikoLogger.java create mode 100644 src/main/java/de/hhu/ba/yoshikoWrapper/logging/package-info.java diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/core/YoshikoLoader.java b/src/main/java/de/hhu/ba/yoshikoWrapper/core/YoshikoLoader.java index 3e0563a..1c9440e 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/core/YoshikoLoader.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/core/YoshikoLoader.java @@ -2,17 +2,24 @@ package de.hhu.ba.yoshikoWrapper.core; import java.io.File; +import org.slf4j.Logger; + +import de.hhu.ba.yoshikoWrapper.logging.YoshikoLogger; + public class YoshikoLoader { private static ConfigurationManager cm; private static boolean isLoaded; + //Symbolic Links + private static Logger logger = YoshikoLogger.getInstance().getLogger(); + public static void loadLibrary(String libPath) { //Attempt to load from a previously stored path File f = new File (libPath); if (!f.exists()) { - System.out.println("Could not find a previously saved yoshiko library path, needs to be set manually!"); + logger.info("Could not load the Yoshiko-library from a previously saved path! You might need to set the path manually."); return; } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/DoubleInputField.java b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/DoubleInputField.java index ba89382..aea5181 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/DoubleInputField.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/DoubleInputField.java @@ -7,9 +7,9 @@ import javax.swing.JFormattedTextField; */ @SuppressWarnings("serial") public class DoubleInputField extends JFormattedTextField{ - - public DoubleInputField() { - super(FormatHelper.getDoubleFormatter()); + + public DoubleInputField(double minValue,double maxValue) { + super(FormatHelper.getDoubleFormatter(minValue,maxValue)); this.setColumns(8); } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/EditCostPanel.java b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/EditCostPanel.java new file mode 100644 index 0000000..d131859 --- /dev/null +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/EditCostPanel.java @@ -0,0 +1,26 @@ +package de.hhu.ba.yoshikoWrapper.gui; + +import javax.swing.JLabel; + +@SuppressWarnings("serial") //Will never be serialized +public class EditCostPanel extends ComfortPanel { + + //SWING COMPONENTS + private ModificationCostMapper modCostMapper; + private DoubleInputField icField; + private DoubleInputField dcField; + private JLabel icLabel; + private JLabel dcLabel; + + public EditCostPanel() { + modCostMapper = new ModificationCostMapper(); + icField = new DoubleInputField(0,Double.NEGATIVE_INFINITY); + dcField = new DoubleInputField(0,Double.POSITIVE_INFINITY); + icLabel = new JLabel("Insertion Cost:"); + dcLabel = new JLabel("Deletion Cost:"); + icLabel.setLabelFor(icField); + dcLabel.setLabelFor(dcField); + this.addAll(modCostMapper,icField,dcField,icLabel,dcLabel); + } + +} diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/FormatHelper.java b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/FormatHelper.java index dd44818..770d241 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/FormatHelper.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/FormatHelper.java @@ -18,12 +18,12 @@ public class FormatHelper { return formatter; } - public static NumberFormatter getDoubleFormatter() { + public static NumberFormatter getDoubleFormatter(double minValue, double maxValue) { NumberFormat format = NumberFormat.getInstance(); NumberFormatter formatter = new NumberFormatter(format); formatter.setValueClass(Integer.class); - formatter.setMinimum(0); - formatter.setMaximum(Integer.MAX_VALUE); + formatter.setMinimum(minValue); + formatter.setMaximum(maxValue); formatter.setAllowsInvalid(false); formatter.setCommitsOnValidEdit(true); diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/MainPanel.java b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/MainPanel.java index a50e9be..403ceb4 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/MainPanel.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/MainPanel.java @@ -33,8 +33,8 @@ public class MainPanel extends ComfortPanel implements CytoPanelComponent { private LibStatusPanel libStatusPanel; private JButton searchLibButton; private JLabel yoshikoVersionLabel; - - private ModificationCostMapper modCostMapper; + + private EditCostPanel ecPanel; private ButtonGroup heuristicGroup; private JRadioButton useHeuristic; @@ -65,8 +65,8 @@ public class MainPanel extends ComfortPanel implements CytoPanelComponent { yoshikoVersionLabel.setText(LibraryInterface.getVersionString()); } searchLibButton = new JButton("POINT TO LIB"); - - modCostMapper = new ModificationCostMapper(); + + ecPanel = new EditCostPanel(); heuristicGroup = new ButtonGroup(); useILP = new JRadioButton("Use Integer Linear Programming"); @@ -116,7 +116,7 @@ public class MainPanel extends ComfortPanel implements CytoPanelComponent { libStatusPanel, yoshikoVersionLabel, searchLibButton, - modCostMapper, + ecPanel, useILP, useHeuristic, timeLimitSetter, diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/ModificationCostMapper.java b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/ModificationCostMapper.java index dbccbf3..78c74b1 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/ModificationCostMapper.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/ModificationCostMapper.java @@ -37,7 +37,7 @@ public class ModificationCostMapper extends ComfortPanel { updateValues(); //Add a focus listener to update values //TODO: This might be a bit inelegant but there is no way to get a callback from CS when a table changes values - this.addFocusListener(new FocusListener() { + tableFields.addFocusListener(new FocusListener() { @Override public void focusGained(FocusEvent e) { diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/YoshikoHelpDialog.java b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/YoshikoHelpDialog.java new file mode 100644 index 0000000..e30e48b --- /dev/null +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/YoshikoHelpDialog.java @@ -0,0 +1,14 @@ +package de.hhu.ba.yoshikoWrapper.gui; + +import javax.swing.JDialog; +import javax.swing.JTree; + +@SuppressWarnings("serial") +public class YoshikoHelpDialog extends JDialog { + private JTree navigationTree; + + public YoshikoHelpDialog() { + navigationTree = new JTree(); + this.add(navigationTree); + } +} diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/YoshikoHelpModel.java b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/YoshikoHelpModel.java new file mode 100644 index 0000000..241ac67 --- /dev/null +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/YoshikoHelpModel.java @@ -0,0 +1,57 @@ +package de.hhu.ba.yoshikoWrapper.gui; + +import javax.swing.event.TreeModelListener; +import javax.swing.tree.TreeModel; +import javax.swing.tree.TreePath; + +public class YoshikoHelpModel implements TreeModel { + + @Override + public Object getRoot() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Object getChild(Object parent, int index) { + // TODO Auto-generated method stub + return null; + } + + @Override + public int getChildCount(Object parent) { + // TODO Auto-generated method stub + return 0; + } + + @Override + public boolean isLeaf(Object node) { + // TODO Auto-generated method stub + return false; + } + + @Override + public void valueForPathChanged(TreePath path, Object newValue) { + // TODO Auto-generated method stub + + } + + @Override + public int getIndexOfChild(Object parent, Object child) { + // TODO Auto-generated method stub + return 0; + } + + @Override + public void addTreeModelListener(TreeModelListener l) { + // TODO Auto-generated method stub + + } + + @Override + public void removeTreeModelListener(TreeModelListener l) { + // TODO Auto-generated method stub + + } + +} diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/logging/YoshikoLogger.java b/src/main/java/de/hhu/ba/yoshikoWrapper/logging/YoshikoLogger.java new file mode 100644 index 0000000..cbedca6 --- /dev/null +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/logging/YoshikoLogger.java @@ -0,0 +1,28 @@ +package de.hhu.ba.yoshikoWrapper.logging; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class YoshikoLogger { + + //SINGLETON TEMPLATE// + private static YoshikoLogger instance; + private YoshikoLogger() {}; + public static YoshikoLogger getInstance() { + if (instance == null) { + instance = new YoshikoLogger(); + } + return instance; + } + + private Logger logger; + + public Logger getLogger() { + if (logger == null) { + logger = LoggerFactory.getLogger(getClass()); + } + return logger; + } + + +} diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/logging/package-info.java b/src/main/java/de/hhu/ba/yoshikoWrapper/logging/package-info.java new file mode 100644 index 0000000..4e8e500 --- /dev/null +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/logging/package-info.java @@ -0,0 +1,4 @@ +/** + * + */ +package de.hhu.ba.yoshikoWrapper.logging; \ No newline at end of file -- GitLab