diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/core/LocalizationManager.java b/src/main/java/de/hhu/ba/yoshikoWrapper/core/LocalizationManager.java index 7f55098e4ac0cc4f00a45c4ad02d5e01934489fb..6a50738fe90f45dc2662296bf13371c75201846b 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/core/LocalizationManager.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/core/LocalizationManager.java @@ -53,7 +53,6 @@ public class LocalizationManager { locales.put("deDE", german); locales.put("hrHR", serbocroatianLatin); locales.put("elEL", modernGreek); - } @@ -104,7 +103,7 @@ public class LocalizationManager { } public static void switchLanguage(String key) { - System.out.println("DEBUG: SWITCHING TO: "+key); + //System.out.println("DEBUG: SWITCHING TO: "+key); currentLocale = locales.get(key); updateBundle(); } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/core/NetworkParsingException.java b/src/main/java/de/hhu/ba/yoshikoWrapper/core/NetworkParsingException.java index 65b9c43f636b55db41004897497493859df510aa..c556b9d2a906d896b01282bbe1aefaf26eab65a7 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/core/NetworkParsingException.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/core/NetworkParsingException.java @@ -1,5 +1,10 @@ package de.hhu.ba.yoshikoWrapper.core; +/** + * Simple Exception that should be thrown when the CyNetwork combined with the given parameters can not be parsed in a meaningful WCE instance + * @author Philipp Spohr, Dec 12, 2017 + * + */ @SuppressWarnings("serial") public class NetworkParsingException extends Exception { diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/core/ParameterSet.java b/src/main/java/de/hhu/ba/yoshikoWrapper/core/ParameterSet.java index 79d7daaa14067a70c1b07172010d8ce87a83cea9..08ac18a7aa2ab569817cdbee9f7f90dcf7467331 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/core/ParameterSet.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/core/ParameterSet.java @@ -1,10 +1,14 @@ package de.hhu.ba.yoshikoWrapper.core; +import java.io.IOException; + import org.cytoscape.model.CyColumn; import org.cytoscape.work.Tunable; +import org.cytoscape.work.TunableValidator; -public class ParameterSet { +public class ParameterSet implements TunableValidator +{ @Tunable(description="Time Limit for the ILP mode", context="nogui") public int timeLimit = -1; @@ -21,7 +25,7 @@ public class ParameterSet { @Tunable(description="The default deletion cost that is to be used for edges without an associated weight",context="nogui") public double defaultDeletionCost = 1; - @Tunable(description="A bitmask representing which reduction rules should be used",context="nogui") //TODO: Filter bad bitmasks + @Tunable(description="A bitmask representing which reduction rules should be used",context="nogui") public String reductionRulesBitMask = "000000"; @Tunable(description="A value controlling the resolution of the SNR reduction rule. Higher values mean a longer running time but possibly better reduction.",context="nogui") public double snrMultFactor = 1.0; @@ -44,4 +48,35 @@ public class ParameterSet { /**Describes whether auto configuration of the reduction rules is to be used. Overrides the bit mask.**/ public boolean suggestReduction = true; + @Override + public ValidationState getValidationState(Appendable errMsg) { + if (!checkBitmask(reductionRulesBitMask)) { + try { + errMsg.append("The Bitmask provided is invalid! Needs to be six bit binary (example: 011001)"); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return ValidationState.INVALID; + } + return ValidationState.OK; + } + + /** + * Helper function that verifies a String and checks if it represents a 6-bit bitmask + * @param mask + * @return + */ + private boolean checkBitmask(String mask) { + if (mask.length() != 6) { + return false; + } + for (byte c : mask.getBytes()) { + if (((char)c)!='0'&&((char)c)!='0') { + return false; + } + } + return true; + } + } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoResult.java b/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoResult.java index 0a4ea3bb435ac149f946368b277bbdfe2a9e1498..d6af2cf7e707541e5542495db92681d8a1eedca1 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoResult.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoResult.java @@ -21,7 +21,6 @@ ******************************************************************************/ package de.hhu.ba.yoshikoWrapper.graphModel; -import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -67,7 +66,6 @@ public class YoshikoResult{ return flags; } - public void addSolution(YoshikoSolution solution) { solutions.put(solution.getId(),solution); } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoSolution.java b/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoSolution.java index 1a2024545425a27700c38d06d47bed5021d201a7..e86274532bc5875c091a2f3d8967c57d9a22ee71 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoSolution.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoSolution.java @@ -34,11 +34,23 @@ import org.slf4j.Logger; import de.hhu.ba.yoshikoWrapper.core.CyCore; import de.hhu.ba.yoshikoWrapper.logging.YoshikoLogger; +/** + * Represents a solution found by the Yoshiko algorithm. + * @author Philipp Spohr, Dec 12, 2017 + * + */ public class YoshikoSolution { + /**A reference to the result (and thus the Yoshiko run) to which this solution belongs + * TODO: I hate this codestyle wise maybe replace in the long run + */ private final YoshikoResult result; + /** + * The CyNetwork representing the meta-graph for this solution if such a graph exists. + */ private CyNetwork metaGraph; + private HashMap<YoshikoCluster, CyNode> metaGraphMap; diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/FormatHelper.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/FormatHelper.java index 284757e6193f955770852f07e54aca96689b110f..2a7fbfffbf329000e249b46f08de951a6e8c3e42 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/FormatHelper.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/FormatHelper.java @@ -26,12 +26,27 @@ import java.text.NumberFormat; import javax.swing.text.NumberFormatter; +/** + * Serves as a Factory for various formatters that might be helpful for restricted input fields. + * @author Philipp Spohr, Dec 12, 2017 + * + */ public class FormatHelper { + /**Returns a basic integer input formatter accepting only positive integers + * Equivalent to getIntegerFormatter(0,Integer.MAX_VALUE) + * @return The NumberFormatter object + */ public static NumberFormatter getIntegerFormatter() { return getIntegerFormatter(0, Integer.MAX_VALUE); } + /** + * Returns a basic integer input formatter accepting only integers in the given range + * @param minValue The smallest, accepted integer + * @param maxValue The largest, accepted integer + * @return A NumberFormatter object accepting only integers in the given range + */ public static NumberFormatter getIntegerFormatter(int minValue, int maxValue) { NumberFormat format = NumberFormat.getInstance(); NumberFormatter formatter = new NumberFormatter(format); diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/GraphicsLoader.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/GraphicsLoader.java index ee1ae4b3dcf2e2526c133c4300ea4cf4dbed11a8..27a5272c86eb4bc433f5348a423f4d9345785385 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/GraphicsLoader.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/GraphicsLoader.java @@ -43,6 +43,9 @@ public class GraphicsLoader { private static BufferedImage infoIcon; private static BufferedImage infoIcon_highlighted; + /** + * The fixed Yoshiko styled color, for quick reference + */ public final static Color yoshikoGreen = new Color(0,128,0); private final static ClassLoader classLoader = GraphicsLoader.class.getClassLoader(); diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/SwingUtil.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/SwingUtil.java index b190b5a375f7332e3cd60781d6578608ee844950..003518eda2042735150532f483ee34ccdfc4465f 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/SwingUtil.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/SwingUtil.java @@ -26,7 +26,13 @@ import java.text.DecimalFormat; import javax.swing.JComponent; +/** + * Contains some basic convenience functions for working with Swing that have no other place (as of now) + * @author Philipp Spohr, Dec 12, 2017 + * + */ public class SwingUtil { + public static void addAll(Container container, JComponent ... components) { for (JComponent c: components) { container.add(c); diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/AlgorithmTask.java b/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/AlgorithmTask.java index 8f7299e3bf46ccaafbff8b6c06bc045fac50e7af..d764f9e387b34b9411110f0fd78a14efcfbc81f4 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/AlgorithmTask.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/AlgorithmTask.java @@ -24,6 +24,8 @@ package de.hhu.ba.yoshikoWrapper.tasks; import java.awt.Window; import java.util.Properties; +import javax.swing.SwingUtilities; + import org.cytoscape.application.swing.CytoPanel; import org.cytoscape.application.swing.CytoPanelComponent; import org.cytoscape.application.swing.CytoPanelName; @@ -243,6 +245,16 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask { eastPanel.setSelectedIndex(eastPanel.indexOfComponent(resultPanel)); //Show (might be invisible) eastPanel.setState(CytoPanelState.DOCK); + //Blackest magic, attempts to scale the result panel to a good size + SwingUtilities.invokeLater( + new Runnable() { + @Override + public void run() { + eastPanel.getThisComponent().setMinimumSize(eastPanel.getThisComponent().getPreferredSize()); + eastPanel.getThisComponent().revalidate(); + } + } + ); //eastPanel.getThisComponent().revalidate(); } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/GetSolutionsTask.java b/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/GetSolutionsTask.java index cac56b267d25cd5290e1f5f3782d009ce487e18e..b36ef963bb0ea5351638f4897718f6e571fa21f3 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/GetSolutionsTask.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/GetSolutionsTask.java @@ -29,7 +29,6 @@ public class GetSolutionsTask implements ObservableTask { @Override public void cancel() { // TODO Auto-generated method stub - } @SuppressWarnings("unchecked")