Commit 605d3c99 authored by Philipp Spohr's avatar Philipp Spohr
Browse files

Refactor

parent 2c902e53
......@@ -16,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
\ No newline at end of file
......@@ -52,9 +52,9 @@ import de.hhu.ba.yoshikoWrapper.core.ConfigurationManager;
import de.hhu.ba.yoshikoWrapper.core.CyCore;
import de.hhu.ba.yoshikoWrapper.core.Hint;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
import de.hhu.ba.yoshikoWrapper.core.NetChangeListener;
import de.hhu.ba.yoshikoWrapper.core.YoshUtil;
import de.hhu.ba.yoshikoWrapper.core.YoshikoLoader;
import de.hhu.ba.yoshikoWrapper.cytoUtil.NetChangeListener;
import de.hhu.ba.yoshikoWrapper.swing.HintManager;
import de.hhu.ba.yoshikoWrapper.swing.components.MainPanel;
......
......@@ -34,6 +34,7 @@ import org.cytoscape.work.AbstractTask;
import org.cytoscape.work.TaskMonitor;
import org.slf4j.Logger;
import de.hhu.ba.yoshikoWrapper.cytoUtil.NodeMap;
import de.hhu.ba.yoshikoWrapper.graphModel.YoshikoCluster;
import de.hhu.ba.yoshikoWrapper.graphModel.YoshikoResult;
import de.hhu.ba.yoshikoWrapper.graphModel.YoshikoSolution;
......
......@@ -29,6 +29,7 @@ import org.cytoscape.model.CyNetwork;
import org.cytoscape.model.CyRow;
import org.slf4j.Logger;
import de.hhu.ba.yoshikoWrapper.cytoUtil.NodeMap;
import de.hhu.ba.yoshikoWrapper.logging.YoshikoLogger;
import de.hhu.ba.yoshikoWrapper.swig.LibraryInput;
......
......@@ -72,6 +72,10 @@ public class StatusInformer extends CplexInformer {
else if (state == YoshikoState.REDUCTION_SN) {
taskMonitor.setStatusMessage(LocalizationManager.get("status_reductionSN"));
}
else if (state == YoshikoState.SOLVING_ILP) {
taskMonitor.setStatusMessage(LocalizationManager.get("status_solvingILP"));
}
}
......
......@@ -19,7 +19,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
******************************************************************************/
package de.hhu.ba.yoshikoWrapper.core;
package de.hhu.ba.yoshikoWrapper.cytoUtil;
import org.cytoscape.application.events.SetCurrentNetworkEvent;
import org.cytoscape.application.events.SetCurrentNetworkListener;
......@@ -34,6 +34,7 @@ import org.cytoscape.model.events.RemovedEdgesListener;
import org.cytoscape.session.events.SessionLoadedEvent;
import org.cytoscape.session.events.SessionLoadedListener;
import de.hhu.ba.yoshikoWrapper.core.CyCore;
import de.hhu.ba.yoshikoWrapper.swing.components.ColumnMapper;
public class NetChangeListener
......
......@@ -19,7 +19,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
******************************************************************************/
package de.hhu.ba.yoshikoWrapper.core;
package de.hhu.ba.yoshikoWrapper.cytoUtil;
import java.util.HashMap;
import java.util.Map.Entry;
......
/*******************************************************************************
* Copyright (C) 2017 Philipp Spohr
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
******************************************************************************/
package de.hhu.ba.yoshikoWrapper.help;
import java.awt.Container;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.WeakHashMap;
import org.slf4j.Logger;
import de.hhu.ba.yoshikoWrapper.logging.YoshikoLogger;
import de.hhu.ba.yoshikoWrapper.swing.components.EditCostPanel;
/**
* Helper class that provides URIs to access the Bachelor Thesis paper sections that can be used as a manual
*
*/
public final class HelpLinks {
//SYMBOLIC LINKS
/**
* Convenience function for better code readability
*/
private static final Logger logger = YoshikoLogger.getInstance().getLogger();
//
/**
* The base location of the bachelor thesis paper
*/
private static final String docLocation = "file:///home/philipp/workspace/cs/BachelorThesis/YoshikoWrapper/thesis/tex/Thesis.pdf";
private static final HashMap <Class<?>,URI> helpLinks;
/**
* A HashMap linking Classes to a link, pointing to a specific subsection of the BachelorThesis paper that is relevant for understanding the Class
*/
private static final WeakHashMap <Class<? extends Container>,URI> helpLinks;
/**
* Initialization for the HashMap
*/
static {
helpLinks = new HashMap<Class<?>,URI>();
helpLinks = new WeakHashMap<Class<? extends Container>,URI>();
try {
helpLinks.put(EditCostPanel.class, (buildURI("subsubsection.2.2.1")));
} catch (URISyntaxException e) {
e.printStackTrace();
logger.error("Error initializing URI for help file:\n"+e.getMessage());
}
}
public static URI getHelpLink(Class<?> c) {
/**
* Returns the URI that leads to the relevant help section for the class provided
* @param c The Container class for which the help link should be fetched
* @return The help link as URI
*/
public static URI getHelpLink(Class<? extends Container> c) {
if (helpLinks.containsKey(c)) {
return helpLinks.get(c);
}
return null;
}
/**
* Internal helper function that builds a valid URI from the base address and the fragment denoting the relevant section
* @param fragment The fragment naming the nameddest in the pdf file
* @return The compound URI made from base address and fragment
* @throws URISyntaxException If invalid -> Should never be called during runtime in a stable version
*/
private static URI buildURI(String fragment) throws URISyntaxException {
return new URI(null,docLocation,"nameddest="+fragment);
}
......
/*******************************************************************************
* Copyright (C) 2017 Philipp Spohr
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
......@@ -27,19 +27,19 @@ import java.text.NumberFormat;
import javax.swing.text.NumberFormatter;
public class FormatHelper {
public static NumberFormatter getIntegerFormatter() {
return getIntegerFormatter(0, Integer.MAX_VALUE);
}
public static NumberFormatter getIntegerFormatter(int minValue, int maxValue) {
NumberFormat format = NumberFormat.getInstance();
NumberFormatter formatter = new NumberFormatter(format);
formatter.setValueClass(Integer.class);
formatter.setMinimum(minValue);
formatter.setMaximum(maxValue);
formatter.setCommitsOnValidEdit(true);
formatter.setAllowsInvalid(true);
applySharedAttributes(formatter);
return formatter;
}
......@@ -50,11 +50,15 @@ public class FormatHelper {
formatter.setValueClass(Double.class);
formatter.setMinimum(minValue);
formatter.setMaximum(maxValue);
formatter.setCommitsOnValidEdit(true);
formatter.setAllowsInvalid(true);
applySharedAttributes(formatter);
return formatter;
}
private static void applySharedAttributes(NumberFormatter formatter) {
formatter.setCommitsOnValidEdit(true);
formatter.setAllowsInvalid(true);
}
}
......@@ -19,7 +19,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
******************************************************************************/
package de.hhu.ba.yoshikoWrapper.core;
package de.hhu.ba.yoshikoWrapper.swing;
import java.awt.Color;
import java.awt.Image;
......@@ -31,6 +31,8 @@ import java.util.Locale;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
public class GraphicsLoader {
//TODO: Organize Images in HashMap for better readability / flexibility
......
......@@ -9,7 +9,6 @@ import javax.swing.JOptionPane;
import org.slf4j.Logger;
import de.hhu.ba.yoshikoWrapper.core.CyCore;
import de.hhu.ba.yoshikoWrapper.core.GraphicsLoader;
import de.hhu.ba.yoshikoWrapper.core.Hint;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
import de.hhu.ba.yoshikoWrapper.logging.YoshikoLogger;
......@@ -19,9 +18,11 @@ import de.hhu.ba.yoshikoWrapper.logging.YoshikoLogger;
*
*/
public class HintManager {
//TODO: Implement as HashMap
private static Logger logger = YoshikoLogger.getInstance().getLogger();
private static final Runnable useMappingHint = new Runnable() {
@Override
......@@ -30,7 +31,7 @@ public class HintManager {
}
};
private static final Runnable firstStart = new Runnable() {
@Override
......@@ -41,7 +42,7 @@ public class HintManager {
};
private final static Map<Hint,Runnable> hints;
static {
Map<Hint, Runnable> map = new HashMap<Hint,Runnable>();
map.put(Hint.USE_MAPPING, useMappingHint);
......@@ -54,9 +55,9 @@ public class HintManager {
CyCore.getConfig(
hint.toString()+"shown"
) == null
)
)
{
//Save property so we dont show this again
CyCore.cm.getProperties().setProperty(hint.toString()+ "shown", "1");
if (hints.get(hint) != null) {
......@@ -65,10 +66,10 @@ public class HintManager {
else {
logger.warn("Asked for a hint that doesnt exist with hint name: "+hint.toString());
}
}
}
}
......@@ -35,9 +35,9 @@ import javax.swing.border.Border;
import org.cytoscape.model.CyNode;
import org.cytoscape.util.swing.BasicCollapsiblePanel;
import de.hhu.ba.yoshikoWrapper.core.GraphicsLoader;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
import de.hhu.ba.yoshikoWrapper.graphModel.YoshikoCluster;
import de.hhu.ba.yoshikoWrapper.swing.GraphicsLoader;
import de.hhu.ba.yoshikoWrapper.swing.SwingUtil;
@SuppressWarnings("serial")
......
......@@ -11,16 +11,25 @@ import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import de.hhu.ba.yoshikoWrapper.core.GraphicsLoader;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
import de.hhu.ba.yoshikoWrapper.help.HelpLinks;
import de.hhu.ba.yoshikoWrapper.swing.GraphicsLoader;
@SuppressWarnings("serial")
public class HelpButton extends JButton{
/**
* The final size (width and height) of the help button in pixel, declared here for better code maintainability
*/
private static final int SIZE = 16;
/**
* The default icon for the help button that should be shown if the button is not highlighted
*/
private static final ImageIcon defaultIcon = GraphicsLoader.getInfoIcon(SIZE);
/**
* The icon tor the help button that should be shown if the button is highlighted
*/
private static final ImageIcon hlIcon = GraphicsLoader.getInfoIconHL(SIZE);
public HelpButton() {
......
......@@ -8,7 +8,7 @@ import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListCellRenderer;
import de.hhu.ba.yoshikoWrapper.core.GraphicsLoader;
import de.hhu.ba.yoshikoWrapper.swing.GraphicsLoader;
@SuppressWarnings("serial")
class LanguageRenderer extends JPanel implements ListCellRenderer<Locale>{
......
......@@ -25,7 +25,7 @@ import java.awt.Color;
import javax.swing.JLabel;
import de.hhu.ba.yoshikoWrapper.core.GraphicsLoader;
import de.hhu.ba.yoshikoWrapper.swing.GraphicsLoader;
/**
* Simple JLabel visually representing whether or not the Yoshiko Lib is loaded
*
......
......@@ -52,12 +52,12 @@ import org.cytoscape.work.TaskIterator;
import de.hhu.ba.yoshikoWrapper.core.AlgorithmTask;
import de.hhu.ba.yoshikoWrapper.core.CyCore;
import de.hhu.ba.yoshikoWrapper.core.GraphicsLoader;
import de.hhu.ba.yoshikoWrapper.core.Hint;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
import de.hhu.ba.yoshikoWrapper.core.ParameterSet;
import de.hhu.ba.yoshikoWrapper.core.YoshikoLoader;
import de.hhu.ba.yoshikoWrapper.swing.AboutDialogFactory;
import de.hhu.ba.yoshikoWrapper.swing.GraphicsLoader;
import de.hhu.ba.yoshikoWrapper.swing.HintManager;
import de.hhu.ba.yoshikoWrapper.swing.LanguageSwitcherPanelFactory;
import de.hhu.ba.yoshikoWrapper.swing.LibraryPanelFactory;
......
......@@ -40,10 +40,10 @@ import org.cytoscape.application.swing.CytoPanelName;
import org.cytoscape.util.swing.BasicCollapsiblePanel;
import de.hhu.ba.yoshikoWrapper.core.CyCore;
import de.hhu.ba.yoshikoWrapper.core.GraphicsLoader;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
import de.hhu.ba.yoshikoWrapper.graphModel.YoshikoResult;
import de.hhu.ba.yoshikoWrapper.graphModel.YoshikoSolution;
import de.hhu.ba.yoshikoWrapper.swing.GraphicsLoader;
import de.hhu.ba.yoshikoWrapper.swing.SwingUtil;
/**Swing component that contains ALL solutions that are found during one run.
......
......@@ -27,7 +27,7 @@ import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import de.hhu.ba.yoshikoWrapper.core.GraphicsLoader;
import de.hhu.ba.yoshikoWrapper.swing.GraphicsLoader;
@SuppressWarnings("serial")
public class YoshikoHeader extends JPanel {
......
......@@ -71,6 +71,7 @@ status_reductionMR = Applying "Merging" reduction rule
status_reductionPD = Applying "Parameter-Dependent" reduction rule
status_reductionSN = Applying "Similar-Neighborhood" reduction rule
status_solvingILP = Solving ILP
switchLanguage = Plugin language
timeLimitILP = Use time limit for ILP (s):
......
......@@ -2,7 +2,7 @@ The Yoshiko Wrapper provides a clean and simple interface to generate the model.
\subparagraph{Mapping edge costs}
The user has the possibility to use a numeric Cytoscape column of the node table as a source for the edge-cost function $C$.
\subparagraph{Insertion and deletion cost}
The default values $C_I$ and $C_D$ can be set by the user and default to $C_I=-1$ and $C_D=1$.
The default values $C_I$ and $C_D$ can be set by the user with the default values being $C_I=-1$ and $C_D=1$.
It should be noted, that the insertion cost value is not normalized or in any way adjusted when a mapping is used. This means that the user needs to adjust this value wisely to fit the data.
As an example the user might have mapped the edge costs to a column containing values in the range of $10^6-10^7$.
The default insertion cost of $-1$ will be irrelevant in comparison and the algorithm will most likely insert all missing edges and generate one big cluster as a solution.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment