Skip to content
Snippets Groups Projects
Commit 1987f083 authored by Philipp Spohr's avatar Philipp Spohr
Browse files

Basic work on localization

Basic work on implementing visual representation of solution
parent 41c9ae92
No related branches found
No related tags found
No related merge requests found
Showing
with 204 additions and 67 deletions
......@@ -14,6 +14,7 @@ import de.hhu.ba.yoshikoWrapper.core.Core;
import de.hhu.ba.yoshikoWrapper.core.YoshikoLoader;
import de.hhu.ba.yoshikoWrapper.gui.MainPanel;
import de.hhu.ba.yoshikoWrapper.gui.MainPanelAction;
import de.hhu.ba.yoshikoWrapper.gui.SolutionsPanel;
public class CyActivator extends AbstractCyActivator {
......@@ -42,12 +43,11 @@ public class CyActivator extends AbstractCyActivator {
CySwingApplication cytoscapeDesktopService = getService(context,CySwingApplication.class);
//main panel and result panel
MainPanel mainPanel = new MainPanel();
SolutionsPanel solutionsPanel = new SolutionsPanel();
registerService(context,mainPanel,CytoPanelComponent.class, new Properties());
MainPanelAction controlPanelAction = new MainPanelAction(cytoscapeDesktopService,mainPanel);
registerService(context,controlPanelAction,CyAction.class, new Properties());
registerService(context,solutionsPanel,CytoPanelComponent.class, new Properties());
}
}
package de.hhu.ba.yoshikoWrapper.core;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Locale;
import java.util.ResourceBundle;
public class LocalizationManager {
//Locales
static public final Locale usEnglish = new Locale("en","US");
static public final Locale german = new Locale("de","DE");
//List of Locales
static public final ArrayList<Locale> locales = new ArrayList<Locale>(
Arrays.asList(
usEnglish,
german
)
);
static private ResourceBundle currentBundle;
static public Locale currentLanguage = usEnglish;
static public ResourceBundle yoshikoStrings() {
if (currentBundle == null) {
currentBundle = ResourceBundle.getBundle("YoshikoStrings",currentLanguage);
}
return currentBundle;
}
static public void switchLanguage(Locale lcl) {
currentLanguage = lcl;
currentBundle = ResourceBundle.getBundle("YoshikoStrings",currentLanguage);
}
}
......@@ -49,16 +49,13 @@ public class NetworkParser {
if (weightColumn != null){
//Check if the column contains an entry for the respective edge
//It is possible, that there are missing entries
if (edgeEntry.getAllValues().containsKey(weightColumn.getName())){
//Find out if the weights are double or integer and cast accordingly
Class<?> weightType = weightColumn.getType();
if (weightType == Integer.class) {
weight = (int)edgeEntry.get(weightColumn.getName(), weightType);
if (edgeEntry.get(weightColumn.getName(), weightColumn.getType()) != null){
if (weightColumn.getType() == Integer.class) {
weight = edgeEntry.get(weightColumn.getName(), Integer.class);
}
else if(weightType == Double.class) {
weight = (double)edgeEntry.get(weightColumn.getName(), weightType);
else if (weightColumn.getType() == Double.class) {
weight = edgeEntry.get(weightColumn.getName(), Double.class);
}
}
}
......@@ -67,17 +64,18 @@ public class NetworkParser {
boolean permanent = false;
if (permanentColumn != null) {
//Additional check as it is not required to have a value in every row
if (edgeEntry.getAllValues().containsKey(permanentColumn.getName())) {
if (edgeEntry.get(permanentColumn.getName(), Boolean.class) != null) {
permanent = (boolean)edgeEntry.get(permanentColumn.getName(), Boolean.class);
}
}
if (forbiddenColumn != null) {
//Additional check as it is not required to have a value in every row
if (edgeEntry.getAllValues().containsKey(forbiddenColumn.getName())) {
if (edgeEntry.get(forbiddenColumn.getName(), Boolean.class) != null) {
forbidden = (boolean)edgeEntry.get(forbiddenColumn.getName(), Boolean.class);
}
}
System.out.println("Found Edge: "+edgeEntry.get("name", String.class)+ " with weight:"+weight);
logger.debug("Found Edge: "+edgeEntry.get("name", String.class)+ " with weight:"+weight);
......
......@@ -3,9 +3,6 @@ package de.hhu.ba.yoshikoWrapper.gui;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
......
......@@ -3,7 +3,6 @@ package de.hhu.ba.yoshikoWrapper.gui;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EtchedBorder;
import org.cytoscape.model.CyColumn;
......
......@@ -13,7 +13,6 @@ public class FormatHelper {
formatter.setValueClass(Integer.class);
formatter.setMinimum(0);
formatter.setMaximum(Integer.MAX_VALUE);
formatter.setAllowsInvalid(false);
formatter.setCommitsOnValidEdit(true);
return formatter;
......@@ -25,7 +24,6 @@ public class FormatHelper {
formatter.setValueClass(Double.class);
formatter.setMinimum(minValue);
formatter.setMaximum(maxValue);
formatter.setAllowsInvalid(false);
formatter.setCommitsOnValidEdit(true);
return formatter;
......
package de.hhu.ba.yoshikoWrapper.gui;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Locale;
import javax.swing.JComboBox;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
@SuppressWarnings( "serial")
public class LanguageSwitcher extends JComboBox<Locale>{
public LanguageSwitcher() {
for (Locale l: LocalizationManager.locales) {
this.addItem(l);
}
this.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("HI");
LocalizationManager.switchLanguage(getItemAt(getSelectedIndex()));
}
});
}
}
package de.hhu.ba.yoshikoWrapper.gui;
import java.awt.Color;
import javax.swing.JLabel;
public class LibStatusPanel extends JLabel {
......@@ -11,10 +13,12 @@ public class LibStatusPanel extends JLabel {
public void setStyle(boolean libraryLoaded) {
if(libraryLoaded) {
this.setText("YOSHIKO LOADED: TRUE");
this.setText("YOSHIKO LIBRARY READY!");
this.setForeground(Color.GREEN);
}
else {
this.setText("YOSHIKO LOADED: FALSE");
this.setText("YOSHIKO LIBRARY NOT LOADED :(");
this.setForeground(Color.RED);
}
}
......
package de.hhu.ba.yoshikoWrapper.gui;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.border.EtchedBorder;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
import de.hhu.ba.yoshikoWrapper.core.YoshikoLoader;
import de.hhu.ba.yoshikoWrapper.swig.LibraryInterface;
@SuppressWarnings("serial")
public class LibraryPanel extends ComfortPanel {
//SYMBOLIC LINKS
private LibraryPanel self = this;
private LibStatusPanel libStatusPanel;
private JButton searchLibButton;
private JLabel yoshikoVersionLabel;
public LibraryPanel() {
this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
//SWING COMPONENT INITIALIZATION
libStatusPanel = new LibStatusPanel();
searchLibButton = new JButton(LocalizationManager.yoshikoStrings().getString("resolveLibPath"));
yoshikoVersionLabel = new JLabel(LocalizationManager.yoshikoStrings().getString("yoshVersion"));
libStatusPanel.setStyle(YoshikoLoader.isLibraryLoaded());
if (YoshikoLoader.isLibraryLoaded()) {
yoshikoVersionLabel.setText(LibraryInterface.getVersionString());
searchLibButton.setEnabled(false);
}
searchLibButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final YLibChooser c = new YLibChooser();
int returnVal = c.showOpenDialog(self);
if (returnVal == JFileChooser.APPROVE_OPTION) {
YoshikoLoader.loadLibrary(c.getSelectedFile().getAbsolutePath());
}
libStatusPanel.setStyle(YoshikoLoader.isLibraryLoaded());
yoshikoVersionLabel.setText(LibraryInterface.getVersionString());
searchLibButton.setEnabled(false);
}
});
this.addAll(libStatusPanel,yoshikoVersionLabel,searchLibButton);
//Decoration/Visual
this.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
}
}
......@@ -9,15 +9,12 @@ import javax.swing.ButtonGroup;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JRadioButton;
import org.cytoscape.application.swing.CytoPanelComponent;
import org.cytoscape.application.swing.CytoPanelName;
import de.hhu.ba.yoshikoWrapper.core.Core;
import de.hhu.ba.yoshikoWrapper.core.YoshikoLoader;
import de.hhu.ba.yoshikoWrapper.swig.LibraryInterface;
/**This class describes the Swing Panel that the user interacts with in cytoscape
* @author Philipp Spohr, Aug 6, 2017
......@@ -26,26 +23,23 @@ import de.hhu.ba.yoshikoWrapper.swig.LibraryInterface;
@SuppressWarnings("serial")
public class MainPanel extends ComfortPanel implements CytoPanelComponent {
//SYMBOLIC LINKS
private MainPanel self = this; //for lambda function references
//SWING COMPONENTS
private LibStatusPanel libStatusPanel;
private JButton searchLibButton;
private JLabel yoshikoVersionLabel;
private final LanguageSwitcher langSwitcher;
private final LibraryPanel libraryPanel;
private EditCostPanel ecPanel;
private final EditCostPanel ecPanel;
private ButtonGroup heuristicGroup;
private JRadioButton useHeuristic;
private JRadioButton useILP;
private final ButtonGroup heuristicGroup;
private final JRadioButton useHeuristic;
private final JRadioButton useILP;
private TimeLimitSetter timeLimitSetter;
private final TimeLimitSetter timeLimitSetter;
private ReductionRulesChooser reductionRulesChooser;
private final ReductionRulesChooser reductionRulesChooser;
private JCheckBox useTriangleCutsBox;
private JCheckBox usePartitionCutsBox;
private final JCheckBox useTriangleCutsBox;
private final JCheckBox usePartitionCutsBox;
......@@ -56,15 +50,9 @@ public class MainPanel extends ComfortPanel implements CytoPanelComponent {
this.setLayout(new BoxLayout(this,BoxLayout.PAGE_AXIS));
//SWING COMPONENT INITIALIZATION
libStatusPanel = new LibStatusPanel();
libStatusPanel.setStyle(YoshikoLoader.isLibraryLoaded());
yoshikoVersionLabel = new JLabel("YOSHIKO VERSION");
if (LibraryInterface.getVersionString() != null) {
yoshikoVersionLabel.setText(LibraryInterface.getVersionString());
}
searchLibButton = new JButton("POINT TO LIB");
//Initialize Swing components
langSwitcher = new LanguageSwitcher();
libraryPanel = new LibraryPanel();
ecPanel = new EditCostPanel();
......@@ -75,20 +63,6 @@ public class MainPanel extends ComfortPanel implements CytoPanelComponent {
heuristicGroup.add(useILP);
heuristicGroup.add(useHeuristic);
searchLibButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final YLibChooser c = new YLibChooser();
int returnVal = c.showOpenDialog(self);
if (returnVal == JFileChooser.APPROVE_OPTION) {
YoshikoLoader.loadLibrary(c.getSelectedFile().getAbsolutePath());
}
libStatusPanel.setStyle(YoshikoLoader.isLibraryLoaded());
yoshikoVersionLabel.setText(LibraryInterface.getVersionString());
}
});
JButton runButton = new JButton("RUN");
runButton.addActionListener(new ActionListener() {
......@@ -120,9 +94,8 @@ public class MainPanel extends ComfortPanel implements CytoPanelComponent {
this.addAll(
libStatusPanel,
yoshikoVersionLabel,
searchLibButton,
langSwitcher,
libraryPanel,
ecPanel,
useILP,
useHeuristic,
......@@ -155,7 +128,7 @@ public class MainPanel extends ComfortPanel implements CytoPanelComponent {
public String getTitle() {
//TODO: Be creative I guess
return "Yoshiko Wrapper Panel";
return "Yoshiko";
}
......
package de.hhu.ba.yoshikoWrapper.gui;
import java.awt.Component;
import javax.swing.Icon;
import org.cytoscape.application.swing.CytoPanelComponent;
import org.cytoscape.application.swing.CytoPanelName;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
@SuppressWarnings("serial")//Will never be serialized
public class SolutionsPanel extends ComfortPanel implements CytoPanelComponent{
@Override
public Component getComponent() {
return this;
}
@Override
public CytoPanelName getCytoPanelName() {
return CytoPanelName.EAST;
}
@Override
public String getTitle() {
return LocalizationManager.yoshikoStrings().getString("resultsPanelTitle");
}
@Override
public Icon getIcon() {
// TODO Auto-generated method stub
return null;
}
}
resultsPanelTitle = Yoshiko Results
yoshVersion = Yoshiko Version
resolveLibPath = Resolve Yoshiko Library Path
\ No newline at end of file
resultsPanelTitle = Yoshiko Ergebnisse
resolveLibPath = Yoshiko Library suchen
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment