Skip to content

Commit

Permalink
- fixed bug in new proguard config
Browse files Browse the repository at this point in the history
- fixed build.xml to do better dependencies with proguard 
- initial attempt to detect wintab relative mode
- added jtablet 0.x detection on JTabletExtension
  • Loading branch information
marcello3d committed Mar 2, 2010
1 parent 42093ac commit 771b1e1
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 27 deletions.
35 changes: 28 additions & 7 deletions build.xml
Expand Up @@ -182,8 +182,15 @@

<target name="jtablet.jar.compress" depends="jtablet.jar" description="compress the jtablet jar" >
<dependset>
<srcfilelist dir="." files="proguard.conf"/>
<targetfileset dir="${dist.version}" includes="jtablet2.original.jar"/>
<srcfilelist
dir="."
files="proguard.conf"/>
<srcfilelist
dir="${dist.version}"
files="jtablet2.original.jar" />
<targetfileset
dir="${dist.version}"
includes="jtablet2.compressed.jar" />
</dependset>

<proguard configuration="proguard.conf">
Expand Down Expand Up @@ -254,8 +261,15 @@

<target name="jtablet.thin.jar.compress" depends="jtablet.thin.jar" description="compress the thin jtablet jar" >
<dependset>
<srcfilelist dir="." files="proguard.conf"/>
<targetfileset dir="${dist.version}" includes="jtablet2.thin.original.jar"/>
<srcfilelist
dir="."
files="proguard.conf"/>
<srcfilelist
dir="${dist.version}"
files="jtablet2.thin.original.jar" />
<targetfileset
dir="${dist.version}"
includes="jtablet2.thin.compressed.jar"/>
</dependset>
<proguard configuration="proguard.conf">
<libraryjar location="/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Classes/classes.jar" filter="java/**,javax/**"/>
Expand All @@ -267,19 +281,26 @@



<target name="jtablet.install.mac" depends="jtablet.jar,jtabletjpen.compile.osx">
<target name="jtablet.install.mac" depends="jtablet.jar.compress,jtabletjpen.compile.osx">
<mkdir dir="${user.home}/Library/Java/Extensions"/>
<mkdir dir="${user.home}/.jtablet"/>
<copy
file="${dist.version}/jtablet2.original.jar"
file="${dist.version}/jtablet2.compressed.jar"
tofile="${user.home}/Library/Java/Extensions/jtablet.jar"/>

<copy
file="${dist.version}/libjtablet2.jnilib"
todir="${user.home}/.jtablet"/>
</target>


<target name="jtablet.remove.mac">
<delete file="${user.home}/Library/Java/Extensions/jtablet.jar"/>
<delete file="${user.home}/.jtablet/libjtablet2.jnilib"/>
</target>


<target name="jtablet.dist" depends="jtablet.jar.compress,jtablet.thin.jar.compress,javadocs" />

<!-- demo package -->
<path id="demo.classpath">
<!-- <fileset dir="lib" includes="**/*.jar"/> -->
Expand Down
5 changes: 3 additions & 2 deletions design/release-todo.txt
@@ -1,5 +1,5 @@
- don't rename anything public/protected with proguard (only remove classes)
- repackage jpen as something outside of cello.jtablet
XX- don't rename anything public/protected with proguard (only remove classes)
XX- repackage jpen as something outside of cello.jtablet
- get extensionloader working
- detect jtablet 0.9.x installation
- package installed jtablet.jar vs. applet/application jtablet2.jar that is included with apps so they can run without jtablet installed
Expand All @@ -12,4 +12,5 @@
- windows 32
- windows 64



7 changes: 7 additions & 0 deletions proguard.conf
Expand Up @@ -9,6 +9,10 @@

-verbose

-dontnote cello.jtablet.installer.BrowserLauncher
-dontnote cello.jtablet.installer.JTabletExtension


-keep public class cello.jtablet.* {
public protected *;
}
Expand All @@ -21,6 +25,9 @@
-keep public class cello.tablet.* {
public protected *;
}
-keep public class cello.repackaged.jpen.provider.osx.CocoaAccess {
public protected *;
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
Expand Down
33 changes: 19 additions & 14 deletions src/cello/jtablet/impl/MouseTabletManager.java
@@ -1,5 +1,5 @@
/*!
* Copyright (c) 2009 Marcello Bastéa-Forte (marcello@cellosoft.com)
* Copyright (c) 2009 Marcello BastŽa-Forte (marcello@cellosoft.com)
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
Expand Down Expand Up @@ -42,8 +42,8 @@
*/
public class MouseTabletManager extends TabletManager {

private boolean enabled = true;
private int lastModifiersEx;
private boolean firingEvents = true;
private int lastModifiersEx = 0;

public void addScreenTabletListener(TabletListener l) {
throw new UnsupportedOperationException(getClass()+" does not support screen listeners");
Expand All @@ -56,6 +56,8 @@ public void removeScreenTabletListener(TabletListener l) {
private final ConcurrentHashMap<TabletListener,MagicListener> listenerMap
= new ConcurrentHashMap<TabletListener,MagicListener>();

private MouseEvent lastEvent;

public void addTabletListener(Component c, TabletListener l) {
synchronized (l) {
MagicListener magicListener = listenerMap.get(l);
Expand Down Expand Up @@ -85,17 +87,17 @@ public void removeTabletListener(Component c, TabletListener listener) {
}

/**
* @param enabled
* @param firingEvents
*/
public void setEnabled(boolean enabled) {
this.enabled = enabled;
public void setFiringEvents(boolean firingEvents) {
this.firingEvents = firingEvents;
}

/**
* @return if this listener is enabled
*/
public boolean isEnabled() {
return enabled;
public boolean isFiringEvents() {
return firingEvents;
}

private class MagicListener implements MouseListener, MouseMotionListener, MouseWheelListener {
Expand All @@ -117,8 +119,9 @@ public void increment() {
}

private void fireTabletEvent(MouseEvent e) {
lastEvent = e;
lastModifiersEx = e.getModifiersEx();
if (!enabled) {
if (!firingEvents) {
return;
}
TabletEvent.Type type = null;
Expand Down Expand Up @@ -181,7 +184,7 @@ public void mouseMoved(MouseEvent e) {
}

public void mouseWheelMoved(MouseWheelEvent e) {
if (!enabled) {
if (!firingEvents) {
return;
}
float deltaX=0,deltaY=0;
Expand Down Expand Up @@ -212,9 +215,11 @@ public void mouseWheelMoved(MouseWheelEvent e) {
public int getLastModifiersEx() {
return lastModifiersEx;
}


// public void setHints(TabletManagerFactory.Hints hints) {
//
// }
/**
* @return the last event received by any mouse listener
*/
public MouseEvent getLastEvent() {
return lastEvent;
}
}
1 change: 1 addition & 0 deletions src/cello/jtablet/impl/ScreenMouseTabletManager.java
Expand Up @@ -40,6 +40,7 @@
class ScreenMouseTabletManager extends ScreenTabletManager {

ScreenMouseTabletManager() {
// trigger any security warnings immediately
start();
stop();
}
Expand Down
38 changes: 35 additions & 3 deletions src/cello/jtablet/impl/jpen/WinTabTabletManager.java
@@ -1,5 +1,5 @@
/*!
* Copyright (c) 2009 Marcello Bastéa-Forte (marcello@cellosoft.com)
* Copyright (c) 2009 Marcello BastŽa-Forte (marcello@cellosoft.com)
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
Expand Down Expand Up @@ -27,6 +27,7 @@
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
Expand Down Expand Up @@ -87,6 +88,9 @@ private class WinTabCursor {
private final LevelRange rotationRange;
private final TabletDevice device;
private final int cursorType;
private boolean relativeMode = false;
private int absoluteCount = 0;
private int relativeCount = 0;


private Support getSupported(int capabilityMask, int capability) {
Expand Down Expand Up @@ -154,6 +158,24 @@ public WinTabCursor(final int cursorId, final int physicalId, String identifier)
public TabletDevice getDevice() {
return device;
}

public Point updateRelativeMode(float tabletScreenX, float tabletScreenY, MouseEvent mouseEvent) {
Point mouse = mouseEvent.getLocationOnScreen();
float dx = mouse.x - tabletScreenX;
float dy = mouse.y - tabletScreenY;
float distance = dx*dx+dy*dy;
if (distance > 20*20) {
relativeCount++;
relativeMode = true;
absoluteCount = 0;
} else if (distance < 5*5) {
absoluteCount++;
if (absoluteCount > 50) {
relativeMode = false;
}
}
return relativeMode ? mouse : null;
}
}

private class WinTabDevice extends AbstractTabletDevice {
Expand Down Expand Up @@ -191,7 +213,7 @@ protected void readPackets() {
r.add(graphicsConfiguration.getBounds());
}
while (wa.nextPacket()) {
mouseListener.setEnabled(false);
mouseListener.setFiringEvents(false);
boolean newCursor = checkCursor();

readValues();
Expand All @@ -204,6 +226,15 @@ protected void readPackets() {

x += r.x;
y += r.y;

MouseEvent mouseEvent = mouseListener.getLastEvent();
if (mouseEvent != null) {
Point mouse = cursor.updateRelativeMode(x, y, mouseEvent);
if (mouse != null) {
x = mouse.x;
y = mouse.y;
}
}

float pressure = toFloat(this.pressure, cursor.pressureRange);
float sidePressure = toFloat(this.sidePressure, cursor.sidePressureRange);
Expand Down Expand Up @@ -270,10 +301,11 @@ protected void readPackets() {
if (cursor != null && when - lastTime > 100) {
generateDeviceEvents(cursor != null ? cursor.getDevice() : null, when, modifiers, false);
cursor = null;
mouseListener.setEnabled(true);
mouseListener.setFiringEvents(true);
}
}


private LevelRange getLevelRangeObject(int type) {
return new LevelRange(wa.getLevelRange(type));
}
Expand Down
30 changes: 29 additions & 1 deletion src/cello/jtablet/installer/JTabletExtension.java
Expand Up @@ -3,6 +3,7 @@
import java.applet.Applet;
import java.awt.Component;
import java.io.IOException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
Expand Down Expand Up @@ -68,7 +69,7 @@ public enum InstallStatus {
public static String getInstalledVersion() {
Package p = getInstalledPackage();
if (p == null) {
return null;
return getLegacyJTabletVersion();
}
return p.getImplementationVersion();
}
Expand Down Expand Up @@ -141,6 +142,33 @@ public static boolean checkCompatibility(Component parentComponent, String desir
}
return true;
}

private static String getLegacyJTabletVersion() {
try {
// Get a class object through Reflection API
Class<?> jtablet = Class.forName("cello.tablet.JTablet");
// Create an instance of the object
Object tablet = jtablet.newInstance();
try {
// getVersion() was added in 0.2 BETA 2
// You can safely assume this function will exist, since the 0.1 BETA
// was distributed to a select group of users.
// If the user is using 0.1 BETA, you aren't required to support them
// so you can simply recommend an upgrade.
Method tablet_getVersion = jtablet.getMethod("getVersion");

// Invoke function
return (String)tablet_getVersion.invoke(tablet);
} catch (Exception e) {
// If the class exists but the getVersion method doesn't,
// they are using the old 0.1 beta version (highly unlikely)
return "0.1.0-beta";
}
} catch (Exception e) {
// No JTablet found
return null;
}
}

private static Package getInstalledPackage() {
if (!PluginConstant.IS_PLUGIN) {
Expand Down

0 comments on commit 771b1e1

Please sign in to comment.