From: <ha...@us...> - 2011-10-20 06:19:34
|
Revision: 16378 http://jmol.svn.sourceforge.net/jmol/?rev=16378&view=rev Author: hansonr Date: 2011-10-20 06:19:28 +0000 (Thu, 20 Oct 2011) Log Message: ----------- pretty well broken. See note in JmolActivity.java Modified Paths: -------------- trunk/Jmol-Android/AndroidManifest.xml trunk/Jmol-Android/bin/JmolAndroid.apk trunk/Jmol-Android/src/org/openscience/jmolandroid/JmolActivity.java trunk/Jmol-Android/src/org/openscience/jmolandroid/api/AndroidUpdateListener.java trunk/Jmol-Android/src/org/openscience/jmolandroid/api/Platform.java Modified: trunk/Jmol-Android/AndroidManifest.xml =================================================================== --- trunk/Jmol-Android/AndroidManifest.xml 2011-10-20 02:56:33 UTC (rev 16377) +++ trunk/Jmol-Android/AndroidManifest.xml 2011-10-20 06:19:28 UTC (rev 16378) @@ -5,7 +5,7 @@ <uses-sdk android:minSdkVersion="8" /> <!-- android:largeHeap="true" --> - <application android:icon="@drawable/icon" android:label="@string/app_name"> + <application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true"> <activity android:label="@string/app_name" android:name=".JmolActivity" android:screenOrientation="portrait"> <intent-filter> <action android:name="android.intent.action.MAIN" /> Modified: trunk/Jmol-Android/bin/JmolAndroid.apk =================================================================== (Binary files differ) Modified: trunk/Jmol-Android/src/org/openscience/jmolandroid/JmolActivity.java =================================================================== --- trunk/Jmol-Android/src/org/openscience/jmolandroid/JmolActivity.java 2011-10-20 02:56:33 UTC (rev 16377) +++ trunk/Jmol-Android/src/org/openscience/jmolandroid/JmolActivity.java 2011-10-20 06:19:28 UTC (rev 16378) @@ -14,7 +14,9 @@ import android.app.Activity; import android.app.ProgressDialog; +import android.content.Context; import android.content.Intent; +import android.graphics.Canvas; import android.os.AsyncTask; import android.os.Bundle; import android.util.Log; @@ -27,6 +29,36 @@ public class JmolActivity extends Activity implements JmolStatusListener { + /* + * Mario: + * + * It seems to me we need to subclass ImageView so that we can add the + * + * onDraw(Canvas) + * + * method. The sequence should be: + * + * + * I. + * System calls onDraw(Canvas) + * Jmol draws onto it + * + * II. + * Jmol gets an event and needs an update + * Jmol sends imageView.invalidate() + * System calls onDraw(Canvas) + * + * + * but I don't see yet how you get that started. + * + * Bob + * + * + * + * + */ + + private final static String TEST_SCRIPT = "set debug;set debugscript;load http://chemapps.stolaf.edu/jmol/docs/examples-12/data/caffeine.xyz;"; //labels on; background labels white;spacefill on"; @@ -35,8 +67,22 @@ public static float SCALE_FACTOR; + class JmolImageView extends SurfaceView { + + public JmolImageView(Context context) { + super(context); + // TODO Auto-generated constructor stub + } + + @Override + protected void onDraw(Canvas canvas) { + viewer.renderScreenImage(canvas, null, canvas.getWidth(), canvas.getHeight()); + } + } + + private JmolViewer viewer; - private SurfaceView imageView; + private JmolImageView imageView; private AndroidUpdateListener updateListener; private boolean opening; private ScaleGestureDetector scaleDetector; @@ -48,7 +94,7 @@ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.main); + setContentView(imageView = new JmolImageView(this)); viewer = null; SCALE_FACTOR = getResources().getDisplayMetrics().density + 0.5f; @@ -78,12 +124,13 @@ protected void onResume() { super.onResume(); - Log.w("Jmol", "onResume..."); + Log.w("Jmol", "onResume..." + viewer); // am I correct that imageView is null if and only if viewer is null? // otherwise we could have a different imageView in updateListener than here - if (imageView == null) - imageView = (SurfaceView) findViewById(R.id.imageMolecule); +// if (imageView == null) { +// imageView = (SurfaceView) findViewById(R.id.imageMolecule); +// } if (viewer == null) { updateListener = new AndroidUpdateListener(this); @@ -97,11 +144,10 @@ viewer.script(STARTUP_SCRIPT); } - Log.w("Jmol", "onResume... viewer=" + viewer); - Log.w("Jmol", "onResume... opening " + opening); + Log.w("Jmol", "onResume... viewer=" + viewer + " opening=" + opening); updateListener.setPaused(false); if (viewer.getAtomCount() > 0 && !updateListener.isShowingDialog()) { - updateListener.repaintEvent(); + imageView.invalidate(); } else { // this.setTitle(R.string.app_name); if (!opening) { @@ -114,6 +160,7 @@ } opening = false; } + Log.w("Jmol", "onResume... done"); }; @@ -130,42 +177,67 @@ /* if (scaleDetector.onTouchEvent(event)) return true; */ + final int index = event.findPointerIndex(0); + if (index < 0 || updateListener == null) + return true; + Log.w("Jmol","onTouchEvent " + index + " " + event); + /* + + + int e = Integer.MIN_VALUE; + switch (event.getAction()) { + case MotionEvent.ACTION_DOWN: + e = Event.MOUSE_DOWN; + break; + case MotionEvent.ACTION_MOVE: + e = Event.MOUSE_DRAG; + break; + case MotionEvent.ACTION_UP: + e = Event.MOUSE_UP; + break; + default: + return true; + } + scaleDetector.onTouchEvent(event); - - // Log.w("Jmol","onTouchEvent " + event); + + updateListener.mouseEvent(e, (int) event.getX(index), + (int) event.getY(index), Event.MOUSE_LEFT, event.getEventTime()); +*/ +/* switch (event.getAction()) { case MotionEvent.ACTION_DOWN: new AsyncTask<MotionEvent, Void, Void>() { @Override protected Void doInBackground(MotionEvent... event) { - viewer.mouseEvent(Event.MOUSE_DOWN, (int) event[0].getX(), - (int) event[0].getY(), Event.MOUSE_LEFT, event[0].getDownTime()); + updateListener.mouseEvent(Event.MOUSE_DOWN, (int) event[index].getX(), + (int) event[index].getY(), Event.MOUSE_LEFT, event[index].getDownTime()); return null; } }.execute(event); break; - case MotionEvent.ACTION_UP: + case MotionEvent.ACTION_MOVE: new AsyncTask<MotionEvent, Object, Object>() { @Override protected Void doInBackground(MotionEvent... event) { - viewer.mouseEvent(Event.MOUSE_UP, (int) event[0].getX(), - (int) event[0].getY(), Event.MOUSE_LEFT, event[0].getDownTime()); + updateListener.mouseEvent(Event.MOUSE_DRAG, (int) event[index].getX(), + (int) event[index].getY(), Event.MOUSE_LEFT, event[index].getDownTime()); return null; } }.execute(event); break; - case MotionEvent.ACTION_MOVE: + case MotionEvent.ACTION_UP: new AsyncTask<MotionEvent, Object, Object>() { @Override protected Void doInBackground(MotionEvent... event) { - viewer.mouseEvent(Event.MOUSE_DRAG, (int) event[0].getX(), - (int) event[0].getY(), Event.MOUSE_LEFT, event[0].getDownTime()); + updateListener.mouseEvent(Event.MOUSE_UP, (int) event[index].getX(), + (int) event[index].getY(), Event.MOUSE_LEFT, event[index].getDownTime()); return null; } }.execute(event); break; } - +*/ return true; }; Modified: trunk/Jmol-Android/src/org/openscience/jmolandroid/api/AndroidUpdateListener.java =================================================================== --- trunk/Jmol-Android/src/org/openscience/jmolandroid/api/AndroidUpdateListener.java 2011-10-20 02:56:33 UTC (rev 16377) +++ trunk/Jmol-Android/src/org/openscience/jmolandroid/api/AndroidUpdateListener.java 2011-10-20 06:19:28 UTC (rev 16378) @@ -1,5 +1,6 @@ package org.openscience.jmolandroid.api; +import org.jmol.api.Event; import org.jmol.api.JmolViewer; import org.openscience.jmolandroid.JmolActivity; @@ -36,7 +37,8 @@ dialog.dismiss(); dialog = null; } - repaintEvent(); + ja.getImageView().invalidate(); + //repaintEvent(); } public void repaintEvent() { @@ -95,4 +97,14 @@ return dialog != null; } + boolean eventRunning; + public void mouseEvent(int id, int x, int y, int modifiers, long when) { + if (id == Event.MOUSE_DRAG && eventRunning) + return; + eventRunning = true; + viewer.mouseEvent(id, x, y, modifiers, when); + eventRunning = false; + } + } + Modified: trunk/Jmol-Android/src/org/openscience/jmolandroid/api/Platform.java =================================================================== --- trunk/Jmol-Android/src/org/openscience/jmolandroid/api/Platform.java 2011-10-20 02:56:33 UTC (rev 16377) +++ trunk/Jmol-Android/src/org/openscience/jmolandroid/api/Platform.java 2011-10-20 06:19:28 UTC (rev 16378) @@ -168,4 +168,8 @@ return Font.newFont(fontFace, isBold, isItalic, fontSize); } + public Object getJsObjectInfo(Object jsObject, String method, Object[] args) { + return null; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |