Commit 7ea3d8d5 authored by Philipp Spohr's avatar Philipp Spohr
Browse files

Added "About" panel and various small fixes

Bumped up version number to 0.1
parent a3c19b48
......@@ -33,7 +33,7 @@
<groupId>de.hhu.ba</groupId>
<artifactId>yoshikoWrapper</artifactId>
<version>0.0.3</version>
<version>0.1.0</version>
<name>YoshikoWrapper</name>
......
......@@ -55,6 +55,7 @@ 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.gui.HintManager;
import de.hhu.ba.yoshikoWrapper.gui.MainPanel;
......@@ -92,6 +93,9 @@ public class CyActivator extends AbstractCyActivator {
CyCore.renderingEngineFactory = getService(context,RenderingEngineFactory.class);
CyCore.cloneNetworkTaskFactory = getService(context,CloneNetworkTaskFactory.class);
//Store a reference to the Version
YoshUtil.version = context.getBundle().getVersion();
//Set language according to settings
LocalizationManager.switchLanguage(cm.getProperties().getProperty("locale", "enUS"));
......
......@@ -152,7 +152,7 @@ public class AlgorithmTask extends AbstractTask {
@Override
public void updateGap(double gap) {
taskMonitor.setStatusMessage(LocalizationManager.get("currentGap")+": "+Util.twoDecimals.format(gap)+"%");
taskMonitor.setStatusMessage(LocalizationManager.get("currentGap")+": "+YoshUtil.twoDecimals.format(gap)+"%");
}
}
......@@ -161,8 +161,14 @@ public class AlgorithmTask extends AbstractTask {
result = ca.run();
taskMonitor.setProgress(0.9);
if (result == null) {
throw new Exception(LocalizationManager.get("noFeasible"));
}
long numberOfSolutions = result.getNumberOfSolutions();
if (numberOfSolutions == 0) {
throw new Exception(LocalizationManager.get("noFeasible"));
}
taskMonitor.setStatusMessage("Found: "+numberOfSolutions+" solutions!"); //TODO localize
YoshikoResult yoshikoResult = new YoshikoResult();
......
......@@ -35,6 +35,7 @@ public class GraphicsLoader {
private static BufferedImage yoshikoLogo;
private static BufferedImage yoshikoLogo_solved;
private static BufferedImage yoshikoText;
private static BufferedImage infoIcon;
public final static Color yoshikoGreen = new Color(0,128,0);
......@@ -57,6 +58,19 @@ public class GraphicsLoader {
return new ImageIcon(flags.get(lcl).getScaledInstance(width, height, Image.SCALE_SMOOTH));
}
public static ImageIcon getInfoIcon(int size) {
if (infoIcon == null) {
try {
infoIcon = ImageIO.read(
classLoader.getResource("graphics/Info.png")
);
} catch (IOException e) {
e.printStackTrace();
}
}
return new ImageIcon(infoIcon.getScaledInstance(size, size, Image.SCALE_SMOOTH));
}
public static ImageIcon getLogo(int size) {
if (yoshikoLogo == null) {
try {
......
......@@ -2,6 +2,9 @@ package de.hhu.ba.yoshikoWrapper.core;
import java.text.DecimalFormat;
public class Util {
import org.osgi.framework.Version;
public class YoshUtil {
final static DecimalFormat twoDecimals =new DecimalFormat("0.00");
public static Version version;
}
package de.hhu.ba.yoshikoWrapper.gui;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
import de.hhu.ba.yoshikoWrapper.core.YoshUtil;
/**Factory for a simple About-Dialog that provides some basic info about the software
*
*/
public class AboutDialog{
private static JPanel getDialogPanel() {
JPanel ret = new JPanel();
final YoshikoHeader header;
final JLabel version;
final JLabel text;
header = new YoshikoHeader();
version = new JLabel(LocalizationManager.get("wrapperVersion")+": "+YoshUtil.version);
text = new JLabel(LocalizationManager.get("about"));
SwingUtil.addAll(ret, header,version,text);
GroupLayout layout = new GroupLayout(ret);
layout.setAutoCreateGaps(true);
layout.setHorizontalGroup(layout.createParallelGroup(Alignment.CENTER)
.addComponent(header)
.addComponent(version)
.addComponent(text)
);
layout.setVerticalGroup(layout.createSequentialGroup()
.addComponent(header)
.addComponent(version)
.addComponent(text)
);
ret.setLayout(layout);
return ret;
}
public static void showDialog() {
JOptionPane.showMessageDialog(
null,
getDialogPanel(),
LocalizationManager.get("aboutTitle"),
JOptionPane.PLAIN_MESSAGE);
}
}
......@@ -42,6 +42,7 @@ import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.LayoutStyle;
import org.cytoscape.application.swing.CytoPanelComponent;
import org.cytoscape.application.swing.CytoPanelName;
......@@ -67,6 +68,8 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
private final YoshikoHeader header;
private final JButton about;
private final JCheckBox showAdvancedOptions;
private final ArrayList<JComponent> advancedOptions;
......@@ -93,6 +96,16 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
//Initialize Swing components
header = new YoshikoHeader();
about = new JButton(GraphicsLoader.getInfoIcon(16));
about.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
AboutDialog.showDialog();
}
});
showAdvancedOptions = new JCheckBox(LocalizationManager.get("showAdvanced"));
showAdvancedOptions.addActionListener(toggleAdvancedOptionsListener);
......@@ -123,6 +136,7 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
//Add components to main panel
SwingUtil.addAll(this,
header,
about,
showAdvancedOptions,
langPanel,
libraryPanel,
......@@ -145,28 +159,40 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
//Layout
GroupLayout layout = new GroupLayout(this);
layout.setAutoCreateGaps(true);
layout.setAutoCreateContainerGaps(true);
layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING,true)
.addComponent(header,DEFAULT_SIZE, PREFERRED_SIZE,PREFERRED_SIZE)
.addComponent(showAdvancedOptions,DEFAULT_SIZE, PREFERRED_SIZE,PREFERRED_SIZE)
.addComponent(langPanel,DEFAULT_SIZE, PREFERRED_SIZE,PREFERRED_SIZE)
.addComponent(libraryPanel,DEFAULT_SIZE, PREFERRED_SIZE,PREFERRED_SIZE)
.addComponent(ecPanelWrapper,DEFAULT_SIZE, PREFERRED_SIZE,PREFERRED_SIZE)
.addComponent(reductionWrapper,DEFAULT_SIZE, PREFERRED_SIZE,PREFERRED_SIZE)
.addComponent(opWrapper,DEFAULT_SIZE, PREFERRED_SIZE,PREFERRED_SIZE)
.addComponent(runButton,DEFAULT_SIZE, PREFERRED_SIZE,PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addComponent(header,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
//"SPRING" Functionality ; eats all the space that is available
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(about,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
)
.addGap(4)
.addComponent(showAdvancedOptions,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
.addComponent(langPanel,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
.addComponent(libraryPanel,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
.addComponent(ecPanelWrapper,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
.addComponent(reductionWrapper,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
.addComponent(opWrapper,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
.addComponent(runButton,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
);
layout.setVerticalGroup(layout.createSequentialGroup()
.addComponent(header,PREFERRED_SIZE,PREFERRED_SIZE,PREFERRED_SIZE)
.addComponent(showAdvancedOptions,PREFERRED_SIZE,PREFERRED_SIZE,PREFERRED_SIZE)
.addComponent(langPanel,PREFERRED_SIZE,PREFERRED_SIZE,PREFERRED_SIZE)
.addComponent(libraryPanel,PREFERRED_SIZE,PREFERRED_SIZE,PREFERRED_SIZE)
.addComponent(ecPanelWrapper,PREFERRED_SIZE,PREFERRED_SIZE,PREFERRED_SIZE)
.addComponent(reductionWrapper,PREFERRED_SIZE,PREFERRED_SIZE,PREFERRED_SIZE)
.addComponent(opWrapper,PREFERRED_SIZE,PREFERRED_SIZE,PREFERRED_SIZE)
.addComponent(runButton,PREFERRED_SIZE,PREFERRED_SIZE,PREFERRED_SIZE)
.addGroup(layout.createParallelGroup()
.addComponent(header,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
.addComponent(about,Alignment.TRAILING,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
)
.addGap(4)
.addComponent(showAdvancedOptions,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
.addComponent(langPanel,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
.addComponent(libraryPanel,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
.addComponent(ecPanelWrapper,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
.addComponent(reductionWrapper,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
.addComponent(opWrapper,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
.addComponent(runButton,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
);
this.setLayout(layout);
......
......@@ -117,7 +117,7 @@ public class ReductionRulesChooser extends JPanel{
.addComponent(useHERule, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(usePDRRule, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(useSNRule, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(SNPanel, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(SNPanel, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE)
);
this.setLayout(layout);
......
......@@ -21,13 +21,14 @@
******************************************************************************/
package de.hhu.ba.yoshikoWrapper.gui;
import java.awt.Container;
import javax.swing.JComponent;
import javax.swing.JPanel;
public class SwingUtil {
static void addAll(JPanel panel, JComponent ... components) {
static void addAll(Container container, JComponent ... components) {
for (JComponent c: components) {
panel.add(c);
container.add(c);
}
}
}
......@@ -21,6 +21,7 @@
#-------------------------------------------------------------------------------
resultsPanelTitle = Yoshiko Results
yoshVersion = Yoshiko Version
wrapperVersion = Yoshiko Plugin for Cytoscape Version
resolveLibPath = Resolve Yoshiko Library Path
yoshTask = Performing Yoshiko Algorithm
solution = Solution
......@@ -65,6 +66,9 @@ gap = Gap
currentGap = [ILP] Current Instance Gap
disableMultiThreading = Disable Multithreading
yoshikoHint = Yoshiko Hint
aboutTitle = Yoshiko Plugin Info
getYoshiko = Get Yoshiko Library
noFeasible = No feasible solution found!
noMappingHint = You haven't mapped the cost value to a column in your edge table.\nYoshiko runs significantly faster and generates better solutions if you map values.
firstStart = Thanks for using the Yoshiko Clustering Tool!\nIt appears, that this is your first time using this tool.\nIf you want an in-depth explanation of the algorithm please refer to: [INSERT COOL LINK HERE]
\ No newline at end of file
firstStart = Thanks for using the Yoshiko Clustering Tool!\nIt appears, that this is your first time using this tool.\nIf you want an in-depth explanation of the algorithm please refer to: [INSERT COOL LINK HERE]
about = INSERT SOME AMAZING INFO ABOUT THIS APPLICATION,\n THE AUTHOR AND WHERE TO FIND MORE INFO HERE\n <a href=\"www.hhu.de\" >LINK</a>
\ No newline at end of file
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