Commit ab985a68 authored by Thomas Van Parys's avatar Thomas Van Parys
Browse files

No commit message

No commit message
parent 191debec
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="be/ugent/psb/graphicalmodule/elements/ConditionAnnotationLegend.java|be/ugent/psb/graphicalmodule/elements/ConditionAnnotationMatrix.java|be/ugent/psb/graphicalmodule/actions/ExportToEPSAction.java|be/ugent/psb/graphicalmodule/actions/LoadAracycAction.java|be/ugent/psb/graphicalmodule/actions/LoadBiNGOAction.java|be/ugent/psb/graphicalmodule/actions/LoadConditionAnnotationAction.java|be/ugent/psb/graphicalmodule/actions/LoadGeneCheckListAction.java|be/ugent/psb/graphicalmodule/actions/LoadGeneLinkAction.java|be/ugent/psb/graphicalmodule/actions/LoadGeneMapAction.java|be/ugent/psb/graphicalmodule/actions/LoadMotifFileAction.java|be/ugent/psb/graphicalmodule/actions/LoadTopRegulatorsAction.java|be/ugent/psb/moduleviewer/actions/LoadAracycAction.java|be/ugent/psb/moduleviewer/actions/LoadBiNGOAction.java|be/ugent/psb/moduleviewer/actions/LoadConditionAnnotationAction.java|be/ugent/psb/moduleviewer/actions/LoadGeneCheckListAction.java|be/ugent/psb/moduleviewer/actions/LoadGeneLinkAction.java|be/ugent/psb/moduleviewer/actions/LoadGeneMapAction.java|be/ugent/psb/moduleviewer/actions/LoadMotifFileAction.java|be/ugent/psb/moduleviewer/actions/LoadTopRegulatorsAction.java|be/ugent/psb/moduleviewer/elements/ConditionAnnotationLegend.java|be/ugent/psb/moduleviewer/elements/ConditionAnnotationMatrix.java|docs/|be/ugent/psb/moduleviewer/parsers/LemoneXMLHandler.java|be/ugent/psb/moduleviewer/parsers/ModuleNetworkParser.java|be/ugent/psb/moduleviewer/OldDefaultCanvas.java" kind="src" path=""/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry combineaccessrules="false" kind="src" path="/ModuleGraphics"/>
<classpathentry kind="output" path=""/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ModuleViewer</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
#Fri Apr 01 13:12:30 CEST 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6
package be.ugent.psb.moduleviewer;
import java.awt.Dimension;
import be.ugent.psb.modulegraphics.elements.Canvas;
import be.ugent.psb.modulegraphics.elements.Spacer;
import be.ugent.psb.moduleviewer.elements.ConditionLabels;
import be.ugent.psb.moduleviewer.elements.EnigmaColorizer;
import be.ugent.psb.moduleviewer.elements.ExpressionMatrix;
import be.ugent.psb.moduleviewer.elements.GeneNames;
import be.ugent.psb.moduleviewer.elements.Title;
import be.ugent.psb.moduleviewer.model.GUIModel;
import be.ugent.psb.moduleviewer.model.Model;
import be.ugent.psb.moduleviewer.model.Module;
import be.ugent.psb.moduleviewer.model.ModuleNetwork;
/**
* A Default layout for a Canvas that looks up which elements to
* draw in the graphical model of the module.
*
* The Module itself is drawn anyway. If topregulators are given, they are drawn as well, together
* with the tree structure.
*
* @author thpar
*
*/
public class DefaultCanvas extends Canvas {
private ModuleNetwork modnet;
private Module mod;
private GUIModel guiModel;
private String title;
private Model model;
public DefaultCanvas(Module mod, Model model, GUIModel guiModel, String title){
this.modnet = mod.getModuleNetwork();
this.mod = mod;
this.model = model;
this.guiModel = guiModel;
this.title = title;
this.composeCanvas();
}
private void composeCanvas() {
//general settings
this.setHorizontalSpacing(5);
this.setVerticalSpacing(5);
this.setMargin(20);
//title
if (guiModel.isDrawFileName()){
this.add(new Title(title));
this.getLastAddedElement().setBottomMargin(10);
this.newRow();
}
if (model.getRegulatorFile()!=null && mod.getRegulatorTree()!=null){
ExpressionMatrix regulatorMatrix = new ExpressionMatrix(mod.getRegulatorTree().getColumns(),
mod.getConditionTree(),
new EnigmaColorizer(modnet.getSigma(),modnet.getMean()),
true);
this.add(regulatorMatrix);
GeneNames regNames = new GeneNames(mod.getRegulatorTree().getColumns());
this.add(regNames);
this.newRow();
this.add(new Spacer(new Dimension(0,10)));
this.newRow();
}
ExpressionMatrix expressionMatrix = new ExpressionMatrix(mod.getGeneTree().getColumns(),
mod.getConditionTree(),
new EnigmaColorizer(modnet.getSigma(),modnet.getMean()),
true);
this.add(expressionMatrix);
GeneNames geneNames = new GeneNames(mod.getGeneTree().getColumns());
this.add(geneNames);
this.newRow();
ConditionLabels condLabels = new ConditionLabels(mod.getConditionTree(), true);
this.add(condLabels);
}
}
package be.ugent.psb.moduleviewer;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Observable;
import java.util.Observer;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import be.ugent.psb.moduleviewer.actions.ChangeEpsOutputDirAction;
import be.ugent.psb.moduleviewer.actions.ExportToEPSAction;
import be.ugent.psb.moduleviewer.actions.LoadAnnotationAction;
import be.ugent.psb.moduleviewer.actions.LoadConditionTreeAction;
import be.ugent.psb.moduleviewer.actions.LoadDataAction;
import be.ugent.psb.moduleviewer.actions.LoadGeneTreeAction;
import be.ugent.psb.moduleviewer.actions.LoadRegulatorTreeAction;
import be.ugent.psb.moduleviewer.actions.LoadSessionAction;
import be.ugent.psb.moduleviewer.actions.SaveSessionAsAction;
import be.ugent.psb.moduleviewer.model.GUIModel;
import be.ugent.psb.moduleviewer.model.Model;
public class MainMenu extends JMenuBar implements Observer{
private static final long serialVersionUID = 1L;
private JMenuItem saveSessionAsItem;
private Model model;
private GUIModel guiModel;
public MainMenu(Model model, final GUIModel guiModel){
this.model = model;
model.addObserver(this);
this.guiModel = guiModel;
JMenu fileMenu = new JMenu("File");
JMenuItem loadDataItem = new JMenuItem(new LoadDataAction(model, guiModel));
JMenuItem loadGeneTreeItem = new JMenuItem(new LoadGeneTreeAction(model, guiModel));
JMenuItem loadConditionTreeItem = new JMenuItem(new LoadConditionTreeAction(model, guiModel));
JMenuItem loadRegTreeItem = new JMenuItem(new LoadRegulatorTreeAction(model, guiModel));
JMenuItem loadAnnotItem = new JMenuItem(new LoadAnnotationAction(model, guiModel));
saveSessionAsItem = new JMenuItem(new SaveSessionAsAction(model, guiModel));
saveSessionAsItem.setEnabled(false);
JMenuItem loadSessionItem = new JMenuItem(new LoadSessionAction(model, guiModel));
JMenuItem exportItem = new JMenuItem(new ExportToEPSAction(model, guiModel));
JMenuItem exitItem = new JMenuItem("Exit");
exitItem.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
fileMenu.add(loadDataItem);
fileMenu.add(loadGeneTreeItem);
fileMenu.add(loadConditionTreeItem);
fileMenu.add(loadRegTreeItem);
fileMenu.add(loadAnnotItem);
fileMenu.addSeparator();
fileMenu.add(saveSessionAsItem);
fileMenu.add(loadSessionItem);
fileMenu.addSeparator();
fileMenu.add(exportItem);
fileMenu.addSeparator();
fileMenu.add(exitItem);
JMenu settingsMenu = new JMenu("Settings");
JMenuItem epsOutputDirItem = new JMenuItem(new ChangeEpsOutputDirAction(guiModel));
settingsMenu.add(epsOutputDirItem);
JMenu helpMenu = new JMenu("Help");
JMenuItem aboutItem = new JMenuItem("About...");
aboutItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(guiModel.getTopContainer(), "LeMoNe Viewer. Written by thpar");
}
});
helpMenu.add(aboutItem);
add(fileMenu);
add(settingsMenu);
add(helpMenu);
}
@Override
public void update(Observable o, Object arg) {
this.saveSessionAsItem.setEnabled(model.isEssentialsLoaded());
}
}
package be.ugent.psb.moduleviewer;
import java.awt.Dimension;
import java.util.Observable;
import java.util.Observer;
import javax.swing.ImageIcon;
import be.ugent.psb.modulegraphics.display.CanvasLabel;
import be.ugent.psb.modulegraphics.elements.Element;
import be.ugent.psb.moduleviewer.model.ConditionNode;
import be.ugent.psb.moduleviewer.model.GUIModel;
import be.ugent.psb.moduleviewer.model.Model;
import be.ugent.psb.moduleviewer.model.Module;
import be.ugent.psb.moduleviewer.model.ModuleNetwork;
import be.ugent.psb.moduleviewer.model.UnknownItemException;
public class ModuleLabel extends CanvasLabel implements Observer{
private static final long serialVersionUID = 1L;
private GUIModel guiModel;
// private int currentPaintedModule = -1;
private ModuleNetwork modnet;
private Dimension currentCanvasSize = new Dimension();
//FIXME DONT DO THIS HARD CODED!
private final String GENEFETCH = "http://bioinformatics.psb.ugent.be/webtools/genefetch/search.html";
private Model model;
public ModuleLabel(Model model, GUIModel guiModel){
this.model = model;
this.modnet = model.getModnet();
this.guiModel = guiModel;
this.guiModel.addObserver(this);
this.setSplash(new ImageIcon(this.getClass().getResource("/icons/lemone.png")));
}
public Element initCanvas() {
//don't even start if we don't have the essential data loaded
if (!model.isEssentialsLoaded()) return null;
int displayedModule = guiModel.getDisplayedModule();
Module mod = null;
try {
mod = modnet.getModule(displayedModule);
} catch (UnknownItemException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ConditionNode n = mod.getConditionTree();
// mod.hierarchicalTree = n;
// for (TreeNode node : mod.hierarchicalTree.getInternalNodes()){
// Collections.sort(node.testSplits);
// node.regulationSplit = node.testSplits.get(0);
// }
DefaultCanvas canvas = new DefaultCanvas(mod, model, guiModel, "Module "+displayedModule);
setCanvas(canvas);
// addCanvasListeners(canvas);
currentCanvasSize = canvas.getDimension(this.getGraphics());
setPreferredSize(currentCanvasSize);
revalidate();
// this.currentPaintedModule = displayedModule;
return canvas;
}
// private void addCanvasListeners(DefaultCanvas canvas) {
// canvas.getGeneNames().addMouseListener(new MouseAdapter(){
// @Override
// public void mouseClicked(MouseEvent e) {
// GeneNames gn = (GeneNames)e.getSource();
// String gnString = gn.getHitGeneName(e.getX(), e.getY());
// if (Desktop.isDesktopSupported()){
// guiModel.setStateString("GeneFetching: "+gnString);
// Desktop desktop = Desktop.getDesktop();
// if (desktop.isSupported(Desktop.Action.BROWSE)) {
// try {
// URI uri = new URI(GENEFETCH+"?gene="+gnString);
// desktop.browse(uri);
// } catch (URISyntaxException e1) {
// // TODO Auto-generated catch block
// e1.printStackTrace();
// } catch (IOException e1) {
// // TODO Auto-generated catch block
// e1.printStackTrace();
// }
//
// } else {
// System.err.println("Can't identify web browser");
// }
// } else {
// System.err.println("No Desktop operations supported!");
// }
// }
// });
//
// canvas.getMatrix().addMouseListener(new MouseAdapter(){
// @Override
// public void mouseClicked(MouseEvent e) {
// ExpressionMatrix matrix = (ExpressionMatrix)e.getSource();
// double data = matrix.getHitData(e.getX(), e.getY());
// guiModel.setStateString(String.valueOf(data));
// }
// });
//
// ExpressionMatrix topRegMatrix = canvas.getTopRegMatrix();
// if (topRegMatrix!=null){
// topRegMatrix.addMouseListener(new MouseAdapter(){
// @Override
// public void mouseClicked(MouseEvent e) {
// ExpressionMatrix matrix = (ExpressionMatrix)e.getSource();
// double data = matrix.getHitData(e.getX(), e.getY());
// guiModel.setStateString(String.valueOf(data));
// }
// });
// }
//
// GeneNames topRegGeneNames = canvas.getTopRegGeneNames();
// if (topRegGeneNames!=null){
// canvas.getTopRegGeneNames().addMouseListener(new MouseAdapter(){
// @Override
// public void mouseClicked(MouseEvent e) {
// GeneNames gn = (GeneNames)e.getSource();
// String gnString = gn.getHitGeneName(e.getX(), e.getY());
// guiModel.setStateString(gnString);
// }
// });
// }
// canvas.getConditionLabels().addMouseListener(new MouseAdapter(){
// @Override
// public void mouseClicked(MouseEvent e) {
// ConditionLabels cl = (ConditionLabels)e.getSource();
// String cnString = cl.getHitConditionName(e.getX(), e.getY());
// guiModel.setStateString(cnString);
// }
// });
//// ConditionAnnotationMatrix condAnnotMatrix = canvas.getConditionAnnotationMatrix();
//// if (condAnnotMatrix!=null){
//// canvas.getConditionAnnotationMatrix().addMouseListener(new MouseAdapter(){
//// @Override
//// public void mouseClicked(MouseEvent e) {
//// ConditionAnnotationMatrix cam = (ConditionAnnotationMatrix)e.getSource();
//// String cnString = cam.getHitAnnotation(e.getX(), e.getY());
//// guiModel.setStateString(cnString);
//// }
//// });
//// }
// }
@Override
public void update(Observable o, Object arg) {
initCanvas();
repaint();
}
public Dimension getCurrentCanvasSize() {
return currentCanvasSize;
}
}
package be.ugent.psb.moduleviewer;
public class ModuleViewer {
public static void main(String[] args) {
ViewerGUI gui = new ViewerGUI();
gui.startGUI();
}
}
package be.ugent.psb.moduleviewer;
import java.awt.Dimension;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.Observable;
import java.util.Observer;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JToolBar;
import be.ugent.psb.moduleviewer.actions.ExportToEPSAction;
import be.ugent.psb.moduleviewer.actions.NavModuleAction;
import be.ugent.psb.moduleviewer.model.GUIModel;
import be.ugent.psb.moduleviewer.model.Model;
import be.ugent.psb.moduleviewer.model.ModuleNetwork;
public class NavigationToolBar extends JToolBar implements Observer, FocusListener, KeyListener{
private static final long serialVersionUID = 1L;
private JLabel totalLabel;
private GUIModel guiModel;
private JTextField locationField;
private Model model;
public NavigationToolBar(Model model, GUIModel guiModel){
super("LeMoNe Navigation");
this.model = model;
this.guiModel = guiModel;
guiModel.addObserver(this);
locationField = new JTextField();
locationField.setColumns(4);
locationField.setMaximumSize(new Dimension(30, 50));
locationField.addFocusListener(this);
locationField.addKeyListener(this);
totalLabel = new JLabel();
JButton nextButton = new JButton();
JButton prevButton = new JButton();
JButton exportButton = new JButton();
nextButton.setAction(new NavModuleAction(new ImageIcon(getClass().getResource("/icons/next.png")),+1, guiModel));
prevButton.setAction(new NavModuleAction(new ImageIcon(getClass().getResource("/icons/prev.png")),-1, guiModel));
exportButton.setAction(new ExportToEPSAction(new ImageIcon(getClass().getResource("/icons/eps_icon.jpg")),model, guiModel));
setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
add(locationField);
add(totalLabel);
add(prevButton);
add(nextButton);
add(new JToolBar.Separator());
add(exportButton);
this.update(null, null);
}
@Override
public void update(Observable o, Object arg) {
int modnr = guiModel.getDisplayedModule();
ModuleNetwork modnet = model.getModnet();
locationField.setText(String.valueOf(modnr));
int totalModnr = 0;
String totalString;
if (modnet.getModules() != null){
totalModnr= modnet.getModules().size();
totalString = new String("/"+totalModnr);
} else {
totalString = new String("--");
}
totalLabel.setText(totalString);
}
@Override
public void focusGained(FocusEvent e) {
// TODO Auto-generated method stub
}
@Override
public void focusLost(FocusEvent e) {
goToModule();
}
private void goToModule(){
String content = locationField.getText();
try {
int contNr = Integer.parseInt(content);
guiModel.setDisplayedModule(contNr);
} catch (NumberFormatException e1) {
locationField.setText(String.valueOf(guiModel.getDisplayedModule()));
}
}
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyChar()=='\n'){
goToModule();
}
}
@Override
public void keyReleased(KeyEvent e) {
// TODO Auto-generated method stub
}
@Override
public void keyTyped(KeyEvent e) {
// TODO Auto-generated method stub
}
}
package be.ugent.psb.moduleviewer;
import be.ugent.psb.modulegraphics.elements.Canvas;
import be.ugent.psb.modulegraphics.elements.Element;
import be.ugent.psb.moduleviewer.elements.ConditionLabels;
import be.ugent.psb.moduleviewer.elements.ExpressionMatrix;
import be.ugent.psb.moduleviewer.elements.GeneNames;
import be.ugent.psb.moduleviewer.elements.Title;
import be.ugent.psb.moduleviewer.model.GUIModel;
import be.ugent.psb.moduleviewer.model.Module;
import be.ugent.psb.moduleviewer.model.ModuleNetwork;
/**
* A Default layout for a Canvas that looks up which elements to
* draw in the graphical model of the module.
*
* The Module itself is drawn anyway. If topregulators are given, they are drawn as well, together
* with the tree structure.
*
* @author thpar
*
*/
public class OldDefaultCanvas extends Canvas {
ModuleNetwork modnet;
private ExpressionMatrix matrix;
private GeneNames geneNames;
private ExpressionMatrix topRegMatrix;
private GeneNames topRegGeneNames;
// private ConditionAnnotationMatrix conditionAnnotationMatrix;
private Element conditionLabels;
public OldDefaultCanvas(Module mod, GUIModel guiModel, String title){
this.modnet = mod.getModuleNetwork();