From 986525a32fda3945caa5bec54092495bdbb9632a Mon Sep 17 00:00:00 2001 From: Philipp Spohr <spohr.philipp@web.de> Date: Mon, 11 Dec 2017 12:23:08 +0100 Subject: [PATCH] Minor clean-up --- .../de/hhu/ba/yoshikoWrapper/CyActivator.java | 5 +-- .../de/hhu/ba/yoshikoWrapper/core/CyCore.java | 4 +- .../core/LocalizationManager.java | 40 +++++++++---------- .../hhu/ba/yoshikoWrapper/core/YoshUtil.java | 10 ----- .../cytoUtil/GraphAnalyzer.java | 16 ++++---- .../swing/components/HelpButton.java | 5 --- .../swing/components/IntegerInputField.java | 22 +++++----- .../yoshikoWrapper/tasks/GetClustersTask.java | 4 +- .../tasks/GetSolutionsTask.java | 1 - 9 files changed, 44 insertions(+), 63 deletions(-) delete mode 100644 src/main/java/de/hhu/ba/yoshikoWrapper/core/YoshUtil.java diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/CyActivator.java b/src/main/java/de/hhu/ba/yoshikoWrapper/CyActivator.java index 15bcfce..b48e411 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/CyActivator.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/CyActivator.java @@ -52,7 +52,6 @@ import static org.cytoscape.work.ServiceProperties.COMMAND_NAMESPACE; import de.hhu.ba.yoshikoWrapper.core.ConfigurationManager; import de.hhu.ba.yoshikoWrapper.core.CyCore; import de.hhu.ba.yoshikoWrapper.core.LocalizationManager; -import de.hhu.ba.yoshikoWrapper.core.YoshUtil; import de.hhu.ba.yoshikoWrapper.core.YoshikoLoader; import de.hhu.ba.yoshikoWrapper.swing.components.MainPanel; import de.hhu.ba.yoshikoWrapper.taskFactories.CommandTaskFactory; @@ -94,11 +93,11 @@ public class CyActivator extends AbstractCyActivator { CyCore.rootNetworkManager = getService(context,CyRootNetworkManager.class); //TODO: Not sure how to correctly infer arguments here CyCore.renderingEngineFactory = getService(context,RenderingEngineFactory.class); - CyCore.cloneNetworkTaskFactory = getService(context,CloneNetworkTaskFactory.class); + //CyCore.cloneNetworkTaskFactory = getService(context,CloneNetworkTaskFactory.class); CyCore.commandExecutorTaskFactory = getService(context,CommandExecutorTaskFactory.class); //Store a reference to the Version for easier access - YoshUtil.version = context.getBundle().getVersion(); + //YoshUtil.version = context.getBundle().getVersion(); //Set language according to settings -> Default to enUS LocalizationManager.switchLanguage(cm.getProperties().getProperty("locale", "enUS")); diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/core/CyCore.java b/src/main/java/de/hhu/ba/yoshikoWrapper/core/CyCore.java index 0707782..a7daab2 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/core/CyCore.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/core/CyCore.java @@ -55,7 +55,7 @@ public class CyCore { public static CyApplicationManager cy; public static DialogTaskManager dialogTaskManager; public static ConfigurationManager cm; - public static BundleContext context; + //public static BundleContext context; public static CyServiceRegistrar registrar; public static CyNetworkViewFactory networkViewFactory; public static CyNetworkFactory networkFactory; @@ -68,7 +68,7 @@ public class CyCore { public static VisualMappingFunctionFactory continuousMappingFactory; public static CyRootNetworkManager rootNetworkManager; public static RenderingEngineFactory<CyNetwork> renderingEngineFactory; - public static CloneNetworkTaskFactory cloneNetworkTaskFactory; + //public static CloneNetworkTaskFactory cloneNetworkTaskFactory; public static CommandExecutorTaskFactory commandExecutorTaskFactory; // 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 70a972e..7f55098 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/core/LocalizationManager.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/core/LocalizationManager.java @@ -1,16 +1,16 @@ /******************************************************************************* * 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 @@ -30,21 +30,21 @@ import java.util.ResourceBundle; * This class should never be initialized */ public class LocalizationManager { - + /** * Default constructor, hidden to prevent invocation */ private LocalizationManager() {}; - + //Locales - + static public final Locale usEnglish = new Locale("en","US"); static public final Locale german = new Locale("de","DE"); static public final Locale serbocroatianLatin = new Locale("hr","HR"); static public final Locale modernGreek = new Locale("el","EL"); //Map - + static private final HashMap<String, Locale> locales; static { @@ -56,12 +56,12 @@ public class LocalizationManager { } - + static private ResourceBundle currentBundle; - + static private Locale currentLocale = usEnglish; - + private static void updateBundle() { currentBundle = ResourceBundle.getBundle("YoshikoStrings",currentLocale); CyCore.cm.getProperties().setProperty( @@ -69,22 +69,22 @@ public class LocalizationManager { currentLocale.getLanguage()+currentLocale.getCountry() ); } - + //https://en.wikipedia.org/wiki/Regional_Indicator_Symbol -> Right now there are not enough fonts support this - public static String localeToUnicodeFlag(Locale locale) { - String countryCode = locale.getCountry(); - int firstLetter = Character.codePointAt(countryCode, 0)-0x41+0x1F1E6; - int secondLetter = Character.codePointAt(countryCode, 1)-0x41+0x1F1E6; - return new String(Character.toChars(firstLetter))+new String(Character.toChars(secondLetter)); - } +// public static String localeToUnicodeFlag(Locale locale) { +// String countryCode = locale.getCountry(); +// int firstLetter = Character.codePointAt(countryCode, 0)-0x41+0x1F1E6; +// int secondLetter = Character.codePointAt(countryCode, 1)-0x41+0x1F1E6; +// return new String(Character.toChars(firstLetter))+new String(Character.toChars(secondLetter)); +// } //SETTER/GETTER methods - + static public Collection<Locale> getLocales(){ return locales.values(); } - + /** * Returns the localized string corresponding to the given key. * This is the main method that should be used for accessing strings and is preferable to any use of constant strings. @@ -97,7 +97,7 @@ public class LocalizationManager { } return currentBundle.getString(key); } - + static public void switchLanguage(Locale lcl) { currentLocale = lcl; updateBundle(); diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/core/YoshUtil.java b/src/main/java/de/hhu/ba/yoshikoWrapper/core/YoshUtil.java deleted file mode 100644 index 9580bd5..0000000 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/core/YoshUtil.java +++ /dev/null @@ -1,10 +0,0 @@ -package de.hhu.ba.yoshikoWrapper.core; - - -import org.osgi.framework.Version; - -public class YoshUtil { - public static Version version; - - public static final String ABOUT_LINK = "https://spqrph.github.io/cytoscape-tutorials/presentations/yoshiko/yoshiko.html#/title"; -} diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/cytoUtil/GraphAnalyzer.java b/src/main/java/de/hhu/ba/yoshikoWrapper/cytoUtil/GraphAnalyzer.java index b569a77..1ef7cc8 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/cytoUtil/GraphAnalyzer.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/cytoUtil/GraphAnalyzer.java @@ -55,14 +55,14 @@ public class GraphAnalyzer { return false; } - public static boolean isDirected(CyNetwork net) { - for (CyEdge e: net.getEdgeList()) { - if (e.isDirected()) { - return true; - } - } - return false; - } +// public static boolean isDirected(CyNetwork net) { +// for (CyEdge e: net.getEdgeList()) { +// if (e.isDirected()) { +// return true; +// } +// } +// return false; +// } /** * Generates a fitting bitmask by choosing the reduction rules that appear to be the best choice based on current research diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/HelpButton.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/HelpButton.java index bb7a004..fc2dc18 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/HelpButton.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/HelpButton.java @@ -4,16 +4,11 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; -import java.io.IOException; -import java.net.URI; -import java.util.HashMap; import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JButton; -import javax.swing.JOptionPane; -import org.cytoscape.command.CommandExecutorTaskFactory; import de.hhu.ba.yoshikoWrapper.core.LocalizationManager; import de.hhu.ba.yoshikoWrapper.cytoUtil.CommandExecutor; diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/IntegerInputField.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/IntegerInputField.java index 04ffa2f..d7d3376 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/IntegerInputField.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/IntegerInputField.java @@ -1,16 +1,16 @@ /******************************************************************************* * 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 @@ -31,21 +31,21 @@ import de.hhu.ba.yoshikoWrapper.swing.FormatHelper; */ @SuppressWarnings("serial") public class IntegerInputField extends JFormattedTextField{ - + private final NumberFormatter formatter; - public IntegerInputField(int minValue, int maxValue) { - super(); - formatter = FormatHelper.getIntegerFormatter(minValue,maxValue); - this.setFormatter(formatter); - this.setColumns(8); - } +// public IntegerInputField(int minValue, int maxValue) { +// super(); +// formatter = FormatHelper.getIntegerFormatter(minValue,maxValue); +// this.setFormatter(formatter); +// this.setColumns(8); +// } public IntegerInputField() { super(); formatter = FormatHelper.getIntegerFormatter(); this.setFormatter(formatter); - this.setColumns(8); + this.setColumns(8); } public int getValueAsInt() { diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/GetClustersTask.java b/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/GetClustersTask.java index 9975bba..0afa05e 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/GetClustersTask.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/GetClustersTask.java @@ -34,9 +34,7 @@ public class GetClustersTask implements ObservableTask { } @Override - public void cancel() { - - } + public void cancel() {} @SuppressWarnings("unchecked") @Override 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 318cc18..cac56b2 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/GetSolutionsTask.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/GetSolutionsTask.java @@ -1,6 +1,5 @@ package de.hhu.ba.yoshikoWrapper.tasks; -import java.util.ArrayList; import java.util.Collection; import org.cytoscape.work.ObservableTask; -- GitLab