Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
<include name="commons-math*.jar"/>
<include name="com.springsource*.jar"/>
<include name="org.apache.felix.bundlerepository-1.6.6.jar"/>
<include name="MultiTouchGesturesJava*.jar"/>
</fileset>
</copy>
<unjar src="modules/org.pathvisio.launcher.jar" dest="build/exe"/>
Expand Down
Binary file added lib/MultiTouchGesturesJava-1.0-SNAPSHOT.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@

import java.awt.Color;
import java.awt.Component;
import java.awt.FileDialog;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;

import javax.swing.AbstractAction;
Expand Down Expand Up @@ -112,6 +115,9 @@ public GexImportWizard (PvDesktop standaloneEngine)

setCurrentPanel(FilePage.IDENTIFIER);
}

private static final boolean useFileDialog =
System.getProperty("os.name").startsWith("Mac OS X");

private class FilePage extends WizardPanelDescriptor implements ActionListener
{
Expand Down Expand Up @@ -277,7 +283,7 @@ private String getFinalPgexFileLocation(String filepath) {
count++;
}
}

public void actionPerformed(ActionEvent e) {
String action = e.getActionCommand();

Expand All @@ -287,18 +293,45 @@ public void actionPerformed(ActionEvent e) {
PreferenceManager.getCurrent().get(GlobalPreference.DB_CONNECTSTRING_GDB)
);
} else if(ACTION_INPUT.equals(action)) {

File defaultdir = PreferenceManager.getCurrent().getFile(GlobalPreference.DIR_LAST_USED_EXPRESSION_IMPORT);
JFileChooser jfc = new JFileChooser();
jfc.setCurrentDirectory(defaultdir);
jfc.addChoosableFileFilter(new SimpleFileFilter("Data files", "*.txt|*.csv|*.tab", true));
int result = jfc.showDialog(null, "Select data file");
if (result == JFileChooser.APPROVE_OPTION)
File defaultDir = PreferenceManager.getCurrent().getFile(GlobalPreference.DIR_LAST_USED_EXPRESSION_IMPORT);
final File selectedFile;
final File selectedDirectory;
if (useFileDialog) {
FileDialog fileDialog = new FileDialog(new Frame(),"Select data file", FileDialog.LOAD);
fileDialog.setDirectory(defaultDir.getAbsolutePath());
fileDialog.setFilenameFilter(new FilenameFilter() {

@Override
public boolean accept(File dir, String name) {
return name.endsWith(".txt") ||
name.endsWith(".csv") || name.endsWith(".tab");
}
});
fileDialog.setVisible(true);
if (fileDialog.getDirectory() == null) {
selectedDirectory = null;
selectedFile = null;
} else {
selectedDirectory = new File(fileDialog.getDirectory());
selectedFile = new File(fileDialog.getDirectory() + "/" + fileDialog.getFile());
}
} else {
JFileChooser jfc = new JFileChooser();
jfc.setCurrentDirectory(defaultDir);
jfc.addChoosableFileFilter(new SimpleFileFilter("Data files", "*.txt|*.csv|*.tab", true));
int result = jfc.showDialog(null, "Select data file");
if (result == JFileChooser.APPROVE_OPTION) {
selectedFile = jfc.getSelectedFile();
selectedDirectory = jfc.getCurrentDirectory();
} else {
selectedFile = null;
selectedDirectory = null;
}
}
if (selectedFile != null)
{
File f = jfc.getSelectedFile();
defaultdir = jfc.getCurrentDirectory();
PreferenceManager.getCurrent().setFile(GlobalPreference.DIR_LAST_USED_EXPRESSION_IMPORT, defaultdir);
txtInput.setText("" + f);
PreferenceManager.getCurrent().setFile(GlobalPreference.DIR_LAST_USED_EXPRESSION_IMPORT, selectedDirectory);
txtInput.setText("" + selectedFile);
updateTxtFile ();
}
} else if(ACTION_OUTPUT.equals(action)) {
Expand Down
7 changes: 5 additions & 2 deletions modules/org.pathvisio.gui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ Require-Bundle: org.pathvisio.core;bundle-version="3.2.0",
org.bridgedb;bundle-version="2.0.0",
org.bridgedb.bio;bundle-version="2.0.0",
org.bridgedb.gui;bundle-version="2.0.0",
org.bridgedb.rdb;bundle-version="2.0.0"
org.bridgedb.rdb;bundle-version="2.0.0",
com.martijncourteaux.multitouchgestures;bundle-version="1.0"
Import-Package: org.osgi.framework;version="1.5.0",
javax.swing,
javax.swing.table,
javax.swing.text
javax.swing.text,
com.martijncourteaux.multitouchgestures,
com.martijncourteaux.multitouchgestures.event
Bundle-DocURL: http://www.pathvisio.org
Bundle-Vendor: PathVisio developers
Bundle-Copyright: 2006-2014 BiGCaT Bioinformatics
Expand Down
1 change: 1 addition & 0 deletions modules/org.pathvisio.gui/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<include name="org.bridgedb.bio.jar"/>
<include name="org.bridgedb.rdb.jar"/>
<include name="org.pathvisio.jgoodies.forms.jar"/>
<include name="MultiTouchGesturesJava-1.0-SNAPSHOT.jar"/>
</fileset>
<fileset dir="${bundle.dest}">
<include name="org.pathvisio.core.jar"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package org.pathvisio.gui;

import java.io.File;
import java.io.FilenameFilter;

import javax.swing.filechooser.FileFilter;

import org.pathvisio.core.model.PathwayIO;
Expand All @@ -26,7 +28,7 @@
* Can be used to create a {@link FileDialog} for importers or exporters.
* @author thomas
*/
public class PathwayFileFilter extends FileFilter {
public class PathwayFileFilter extends FileFilter implements FilenameFilter {
String[] exts;
String name;

Expand All @@ -39,6 +41,7 @@ public String getDefaultExtension() {
return exts[0];
}

@Override
public boolean accept(File f) {
if(f.isDirectory()) return true;

Expand All @@ -55,6 +58,7 @@ public boolean accept(File f) {
return false;
}

@Override
public String getDescription() {
StringBuilder extstr = new StringBuilder();
for(String e : exts) {
Expand All @@ -65,4 +69,9 @@ public String getDescription() {
String str = extstr.substring(0, extstr.length() - 2);
return name + " (" + str + ")";
}

@Override
public boolean accept(File dir, String name1) {
return accept(new File(dir.getAbsoluteFile() + "/" + name1));
}
}
31 changes: 27 additions & 4 deletions modules/org.pathvisio.gui/src/org/pathvisio/gui/SwingEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import java.awt.Component;
import java.awt.Container;
import java.awt.Desktop;
import java.awt.FileDialog;
import java.awt.Frame;
import java.io.File;
import java.net.URL;
import java.util.Comparator;
Expand Down Expand Up @@ -279,17 +281,23 @@ public boolean exportPathway()
return false;
}

private static final boolean useFileDialog =
System.getProperty("os.name").startsWith("Mac OS X");

/**
* A wrapper around JFileChooser that has the right defaults and File Filters.
*/
private class PathwayChooser
{
private final JFileChooser jfc;
private final FileDialog fileDialog;
private final String taskName;
private final Preference dirPreference;

public PathwayChooser(String taskName, int dialogType, Preference dirPreference, Set<? extends PathwayIO> set)
{
fileDialog = new FileDialog(new Frame(), taskName + " pathway", dialogType);
fileDialog.setDirectory(PreferenceManager.getCurrent().getFile(dirPreference).getAbsolutePath());
jfc = new JFileChooser();
this.taskName = taskName;
this.dirPreference = dirPreference;
Expand All @@ -313,15 +321,18 @@ public int compare(PathwayIO o1, PathwayIO o2) {
);
exporters.addAll(set);

FileFilter selectedFilter = null;
PathwayFileFilter selectedFilter = null;
for(PathwayIO exp : exporters) {
FileFilter ff = new PathwayFileFilter(exp);
PathwayFileFilter ff = new PathwayFileFilter(exp);
jfc.addChoosableFileFilter(ff);
if(exp instanceof GpmlFormat) {
selectedFilter = ff;
}
}
if(selectedFilter != null) jfc.setFileFilter(selectedFilter);
if(selectedFilter != null) {
jfc.setFileFilter(selectedFilter);
fileDialog.setFilenameFilter(selectedFilter);
}
}

public FileFilter getFileFilter()
Expand All @@ -331,6 +342,15 @@ public FileFilter getFileFilter()

public int show ()
{
if (useFileDialog) {
fileDialog.setVisible(true);
if (fileDialog.getDirectory() == null) {
return JFileChooser.CANCEL_OPTION;
} else {
PreferenceManager.getCurrent().setFile(dirPreference, new File(fileDialog.getDirectory()));
return JFileChooser.APPROVE_OPTION;
}
}
int status = jfc.showDialog(getApplicationPanel(), taskName);
if(status == JFileChooser.APPROVE_OPTION)
{
Expand All @@ -341,6 +361,9 @@ public int show ()

public File getSelectedFile()
{
if (useFileDialog) {
return new File(fileDialog.getDirectory() + "/" + fileDialog.getFile());
}
return jfc.getSelectedFile();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
//
package org.pathvisio.gui.view;

import com.martijncourteaux.multitouchgestures.GestureAdapter;
import com.martijncourteaux.multitouchgestures.MultiTouchGestureUtilities;
import com.martijncourteaux.multitouchgestures.event.MagnifyGestureEvent;
import com.martijncourteaux.multitouchgestures.event.RotateGestureEvent;
import com.martijncourteaux.multitouchgestures.event.ScrollGestureEvent;
import com.jgoodies.forms.builder.DefaultFormBuilder;
import com.jgoodies.forms.layout.FormLayout;

Expand All @@ -31,6 +36,7 @@
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter;
Expand Down Expand Up @@ -84,6 +90,9 @@ public class VPathwaySwing extends JPanel implements VPathwayWrapper,
protected VPathway child;

protected JScrollPane container;

private static boolean isOSX =
System.getProperty("os.name").startsWith("Mac OS X");

public VPathwaySwing(JScrollPane parent) {
super();
Expand All @@ -94,6 +103,39 @@ public VPathwaySwing(JScrollPane parent) {
addMouseMotionListener(this);
addKeyListener(this);
addMouseWheelListener(this);

if (isOSX) {
try {
MultiTouchGestureUtilities.addGestureListener(this, new GestureAdapter()
{

@Override
public void magnify(MagnifyGestureEvent me)
{
child.zoomToCursor(100 * child.getZoomFactor() * (1 + me.getMagnification()),
new Point((int) me.getMouseX(), (int) me.getMouseY()));

Component comp = container.getParent().getParent();
if (comp instanceof MainPanel)
((MainPanel)comp).updateZoomCombo();
}

@Override
public void scroll(ScrollGestureEvent e)
{
Rectangle r = container.getViewport().getViewRect();
int newx = Math.max((int) (r.getMinX() - e.getDeltaX()), 0);
int newy = Math.max((int) (r.getMinY() - e.getDeltaY()), 0);
scrollTo(newx, newy);
}

});
} catch (Throwable t) {
t.printStackTrace();
isOSX = false;
}
}


setFocusable(true);
setRequestFocusEnabled(true);
Expand Down Expand Up @@ -181,6 +223,12 @@ public void keyReleased(KeyEvent e) {
public void keyTyped(KeyEvent e) {
// TODO: find out how to handle this one
}

public void scrollTo(int newx, int newy) {
container.getViewport().setViewPosition(
new Point (newx, newy)
);
}

public void mouseDragged(MouseEvent e) {
Rectangle r = container.getViewport().getViewRect();
Expand All @@ -204,9 +252,7 @@ public void mouseDragged(MouseEvent e) {
{
newy = Math.max (newy - stepSize, 0);
}
container.getViewport().setViewPosition(
new Point (newx, newy)
);
scrollTo(newx, newy);
child.mouseMove(new SwingMouseEvent(e));
}

Expand All @@ -215,15 +261,30 @@ public void mouseMoved(MouseEvent e) {
}

public void mouseWheelMoved(MouseWheelEvent e) {
int notches = e.getWheelRotation();
if(notches < 0) {
child.zoomToCursor(child.getPctZoom() * 21 / 20, e.getPoint());
} else {
child.zoomToCursor(child.getPctZoom() * 20 / 21, e.getPoint());
}

Component comp = container.getParent().getParent();
if (comp instanceof MainPanel) ((MainPanel)comp).updateZoomCombo();
if (isOSX) {
return;
}
int notches = e.getWheelRotation();

if (false) {
if(notches < 0) {
child.zoomToCursor(child.getPctZoom() * 21 / 20, e.getPoint());
} else {
child.zoomToCursor(child.getPctZoom() * 20 / 21, e.getPoint());
}

Component comp = container.getParent().getParent();
if (comp instanceof MainPanel) ((MainPanel)comp).updateZoomCombo();
}

boolean horizontalScroll=((e.getModifiers() & ActionEvent.SHIFT_MASK) ==
ActionEvent.SHIFT_MASK)
|| ((e.getModifiers() & ActionEvent.META_MASK) == ActionEvent.META_MASK);

Rectangle r = container.getViewport().getViewRect();
int newx = Math.min((int) r.getMinX() + (horizontalScroll ? notches : 0), 0);
int newy = Math.min((int) r.getMinY() + (horizontalScroll ? 0 : notches), 0);
scrollTo(newx, newy);
}

public void registerKeyboardAction(KeyStroke k, Action a) {
Expand Down Expand Up @@ -467,6 +528,7 @@ public void dispose()
((JScrollPane)container).remove(this);
child.removeVPathwayListener(this);
child.removeVElementMouseListener(this);
MultiTouchGestureUtilities.removeAllGestureListeners(this);

removeMouseListener(this);
removeMouseMotionListener(this);
Expand Down
2 changes: 1 addition & 1 deletion tools/convert/SciTE.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
command.build.*.xsd=xmllint $(FileNameExt) -noout -schema XMLSchema.xsd
command.build.*.xsd=xmllint $(FileNameExt) -noout -schema XMLSchema.xsd
command.go.$(file.patterns.perl)=cmd /C perl -w $(FileNameExt) "E:\GenMAPP 2 Data\MAPPs\label_test.mapp" & pause
Loading