Skip to content

Commit

Permalink
Merge pull request #8 from twogee/master
Browse files Browse the repository at this point in the history
Gesture support and new icons...
  • Loading branch information
twogee authored Jan 15, 2017
2 parents 821921b + 0b3082e commit c5ce026
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 68 deletions.
4 changes: 2 additions & 2 deletions build.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
product.version=0.8.3
product.version=0.8.4
grand-core.version=1.9.4

eclipse.version=4.6.2
Expand Down Expand Up @@ -44,7 +44,7 @@ url.gef=${eclipse.gef.download.site}/${eclipse.gef.version}/R${eclipse.gef.times
# JzGraph
jzgraph.download.site=https://github.com/Ant-Grand/GrandUI/releases/download/0.8
url.jzgraph.jar=${jzgraph.download.site}/jzgraph.jar
url.blacksun-util.jar=${jzgraph.download.site}/blacksun_util.jar
url.blacksun-util.jar=${jzgraph.download.site}/blacksun-util.jar

# Oro
url.oro.jar=http://repo1.maven.org/maven2/oro/oro/2.0.8/oro-2.0.8.jar
Expand Down
5 changes: 4 additions & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,16 @@
<fixcrlf srcdir="tmp/${product.fullname}" includes="*.bat" eol="dos"/>

<copy todir="tmp">
<fileset dir="${scriptdir}" includes="${bundle.name}/**"/>
<fileset dir="${scriptdir}" includes="${bundle.name}/**" excludes="**/*.icns"/>
<filterset>
<filter token="VENDOR" value="${product.vendor}"/>
<filter token="VERSION" value="${product.version}"/>
<filter token="YEARS" value="${years}"/>
</filterset>
</copy>
<copy todir="tmp">
<fileset dir="${scriptdir}" includes="**/*.icns"/>
</copy>
<copy todir="tmp/${bundle.name}/Contents/Resources" flatten="true">
<fileset dir=".">
<include name="README.txt"/>
Expand Down
4 changes: 4 additions & 0 deletions src/main/config/Grand.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/main/java/net/ggtools/grand/ui/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ private void initResources() throws IOException {
LOG.debug("Initializing colors");
}
// Put the same icons for all windows & dialogs.
Window.setDefaultImage(getImage(APPLICATION_ICON));
if (!SWT.getPlatform().equals("cocoa"))
Window.setDefaultImage(getImage(APPLICATION_ICON));

LoggerManager.setFactory(new CommonsLoggingLoggerFactory());
}
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/net/ggtools/grand/ui/graph/GraphController.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import net.ggtools.grand.exceptions.GrandException;
import net.ggtools.grand.filters.GraphFilter;
import net.ggtools.grand.graph.Graph;
import net.ggtools.grand.output.DotWriter;
import net.ggtools.grand.ui.Application;
import net.ggtools.grand.ui.GrandUiPrefStore;
import net.ggtools.grand.ui.RecentFilesManager;
Expand All @@ -59,7 +58,6 @@
import org.eclipse.draw2d.PrintFigureOperation;
import org.eclipse.draw2d.SWTGraphics;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.operation.ModalContext;
import org.eclipse.jface.util.IPropertyChangeListener;
Expand Down
120 changes: 69 additions & 51 deletions src/main/java/net/ggtools/grand/ui/widgets/GraphTabItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,12 @@
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.GestureEvent;
import org.eclipse.swt.events.GestureListener;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseWheelListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;

/**
Expand All @@ -84,41 +86,6 @@
*/
public class GraphTabItem extends CTabItem
implements GraphDisplayer, GraphListener {
/**
* @author Christophe Labouisse
*/
private final class MouseWheelZoomListener implements Listener {
/**
* Constructor for MouseWheelZoomListener.
*/
private MouseWheelZoomListener() {
}

/**
* Method handleEvent.
* @param event Event
* @see org.eclipse.swt.widgets.Listener#handleEvent(Event)
*/
public void handleEvent(final Event event) {
final float zoomBefore = getZoom();
event.doit = false;
if (event.count > 0) {
zoomIn();
} else {
zoomOut();
}
final float zoomAfter = getZoom();
if (zoomAfter != zoomBefore) {
final Point location = canvas.getViewport().getViewLocation();
final int newX = (int) (((location.x + event.x) / zoomBefore) * zoomAfter)
- event.x;
final int newY = (int) (((location.y + event.y) / zoomBefore) * zoomAfter)
- event.y;
canvas.scrollTo(newX, newY);
}
}
}

/**
* @author Christophe Labouisse
*/
Expand Down Expand Up @@ -322,6 +289,11 @@ public int hashCode() {
*/
private final StyledText textDisplayer;

/**
* Field doGesture.
*/
private boolean doGesture = false;

/**
* Creates a tab to display a new graph. The tab will contain two sash forms
* a vertical one with the source panel as the bottom part and a second
Expand Down Expand Up @@ -369,7 +341,54 @@ public void selectionChanged(final SelectionChangedEvent event) {
canvas.getViewport().setContentsTracksWidth(true);
canvas.setBackground(ColorConstants.white);
canvas.setScrollBarVisibility(FigureCanvas.AUTOMATIC);
canvas.addListener(SWT.MouseWheel, new MouseWheelZoomListener());
canvas.addMouseWheelListener(new MouseWheelListener() {
@Override
public void mouseScrolled(MouseEvent event) {
if (doGesture)
return;
final float zoomBefore = getZoom();
if (event.count > 0) {
zoomIn();
} else {
zoomOut();
}
final float zoomAfter = getZoom();
if (zoomAfter != zoomBefore) {
final Point location = canvas.getViewport().getViewLocation();
final int newX = (int) (((location.x + event.x) / zoomBefore) * zoomAfter)
- event.x;
final int newY = (int) (((location.y + event.y) / zoomBefore) * zoomAfter)
- event.y;
canvas.scrollTo(newX, newY);
}
}
});
// TODO horisontal swipe to switch tabs
canvas.addGestureListener(new GestureListener() {
@Override
public void gesture(GestureEvent gestureEvent) {
float zoomBefore = 1.0f;
Point locationBefore = new Point();
switch (gestureEvent.detail) {
case SWT.GESTURE_BEGIN:
doGesture = true;
zoomBefore = getZoom();
locationBefore = canvas.getViewport().getViewLocation();
break;
case SWT.GESTURE_MAGNIFY:
setZoom((float) (zoomBefore * gestureEvent.magnification));
break;
case SWT.GESTURE_PAN:
canvas.scrollTo(locationBefore.x + gestureEvent.x,
locationBefore.y + gestureEvent.y);
break;
case SWT.GESTURE_END:
doGesture = false;
default:
break;
}
}
});

canvasScroller = new CanvasScroller(canvas);
contextMenuManager = new GraphMenu(this);
Expand Down Expand Up @@ -532,22 +551,21 @@ public final void setRichSource(final SourceElement[] richSource) {
for (final AntTargetNode.SourceElement element : richSource) {
Color textColor;
switch (element.getStyle()) {
case AntTargetNode.SOURCE_ATTRIBUTE:
textColor = ColorConstants.darkGreen;
break;

case AntTargetNode.SOURCE_MARKUP:
textColor = ColorConstants.darkBlue;
break;
case AntTargetNode.SOURCE_ATTRIBUTE:
textColor = ColorConstants.darkGreen;
break;

case AntTargetNode.SOURCE_TEXT:
textColor = ColorConstants.black;
break;
case AntTargetNode.SOURCE_MARKUP:
textColor = ColorConstants.darkBlue;
break;

default:
textColor = ColorConstants.lightGray;
case AntTargetNode.SOURCE_TEXT:
textColor = ColorConstants.black;
break;

break;
default:
textColor = ColorConstants.lightGray;
break;
}
textDisplayer.setStyleRange(new StyleRange(start, element.getText().length(),
textColor, textDisplayer.getBackground()));
Expand Down
11 changes: 6 additions & 5 deletions src/main/resources/log4j.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<!DOCTYPE log4j:configuration PUBLIC
"-//APACHE//DTD LOG4J 1.2//EN" "http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd">

<!-- ===================================================================== -->
<!-- -->
Expand All @@ -10,11 +11,11 @@
<!-- $Id: log4j.xml,v 1.13.2.8 2003/09/23 14:16:27 slaboure Exp $ -->

<!--
| For more configuration infromation and examples see the Jakarta Log4j
| owebsite: http://jakarta.apache.org/log4j
| For more configuration information and examples see the Jakarta Log4j
| website: http://jakarta.apache.org/log4j
-->

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
<log4j:configuration debug="false" xmlns:log4j="http://jakarta.apache.org/log4j/">

<!-- ================================= -->
<!-- Preserve messages in a local file -->
Expand All @@ -26,7 +27,7 @@
<param name="Append" value="true"/>
<param name="MaxFileSize" value="100KB"/>
<param name="MaxBackupIndex" value="2"/>

<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
<!--param name="ConversionPattern" value="%d %-5p [%c] %m%n"/-->
Expand Down
10 changes: 5 additions & 5 deletions src/main/resources/net/ggtools/grand/ui/buildnum.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sat, 31 Dec 2016 19:29:00 +0100
#Sun, 15 Jan 2017 21:02:39 +0100
#Tue Jul 04 20:50:51 CEST 2006
build.time=19\:29\:00
build.number=306
build.version.string=0.8.3
build.date=2016-12-31
build.time=21\:02\:39
build.number=307
build.version.string=0.8.4
build.date=2017-01-15
Binary file modified src/main/resources/net/ggtools/grand/ui/resource/application.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/main/scripts/GrandUI.app/Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>JavaAppLauncher</string>
<key>CFBundleIconFile</key>
<string>GenericApp.icns</string>
<string>Grand.icns</string>
<key>CFBundleGetInfoString</key>
<string>Grand UI @VERSION@ for Mac OS X</string>
<key>CFBundleIdentifier</key>
Expand Down
Binary file not shown.
Binary file not shown.

0 comments on commit c5ce026

Please sign in to comment.