From: <ha...@us...> - 2011-09-26 12:11:53
|
Revision: 16119 http://jmol.svn.sourceforge.net/jmol/?rev=16119&view=rev Author: hansonr Date: 2011-09-26 12:11:42 +0000 (Mon, 26 Sep 2011) Log Message: ----------- org.jmol.awt.Event org.jmol.util.Rectangle Modified Paths: -------------- trunk/Jmol/src/org/jmol/api/JmolSimpleViewer.java trunk/Jmol/src/org/jmol/api/JmolViewer.java trunk/Jmol/src/org/jmol/applet/Jmol.java trunk/Jmol/src/org/jmol/modelset/AtomCollection.java trunk/Jmol/src/org/jmol/viewer/ActionManager.java trunk/Jmol/src/org/jmol/viewer/MouseManager14.java trunk/Jmol/src/org/jmol/viewer/RepaintManager.java trunk/Jmol/src/org/jmol/viewer/TransformManager11.java trunk/Jmol/src/org/jmol/viewer/Viewer.java trunk/Jmol/src/org/jmol/viewer/binding/Binding.java Added Paths: ----------- trunk/Jmol/src/org/jmol/awt/ trunk/Jmol/src/org/jmol/awt/Event.java trunk/Jmol/src/org/jmol/util/Rectangle.java Modified: trunk/Jmol/src/org/jmol/api/JmolSimpleViewer.java =================================================================== --- trunk/Jmol/src/org/jmol/api/JmolSimpleViewer.java 2011-09-25 20:38:18 UTC (rev 16118) +++ trunk/Jmol/src/org/jmol/api/JmolSimpleViewer.java 2011-09-26 12:11:42 UTC (rev 16119) @@ -50,9 +50,17 @@ null, null, null, null, null); } - abstract public void renderScreenImage(Graphics g, Dimension size, - Rectangle clip); + /** + * @param g + * @param size + * @param clip + */ + public void renderScreenImage(Graphics g, Dimension size, + Rectangle clip) { + renderScreenImage(g, size); + } + abstract protected void renderScreenImage(Graphics g, Dimension size); abstract public String evalFile(String strFilename); abstract public String evalString(String strScript); Modified: trunk/Jmol/src/org/jmol/api/JmolViewer.java =================================================================== --- trunk/Jmol/src/org/jmol/api/JmolViewer.java 2011-09-25 20:38:18 UTC (rev 16118) +++ trunk/Jmol/src/org/jmol/api/JmolViewer.java 2011-09-26 12:11:42 UTC (rev 16119) @@ -29,7 +29,6 @@ import java.awt.Event; import java.awt.Graphics; import java.awt.Image; -import java.awt.Rectangle; import java.io.OutputStream; import java.io.Reader; import java.net.URL; @@ -134,8 +133,7 @@ * @param size * @param clip */ - abstract public void renderScreenImage(Graphics gLeft, Graphics gRight, Dimension size, - Rectangle clip); + abstract public void renderScreenImage(Graphics gLeft, Graphics gRight, Dimension size); static public String getJmolVersion() { return Viewer.getJmolVersion(); Modified: trunk/Jmol/src/org/jmol/applet/Jmol.java =================================================================== --- trunk/Jmol/src/org/jmol/applet/Jmol.java 2011-09-25 20:38:18 UTC (rev 16118) +++ trunk/Jmol/src/org/jmol/applet/Jmol.java 2011-09-26 12:11:42 UTC (rev 16119) @@ -554,7 +554,7 @@ viewer.notifyViewerRepaintDone(); } else { if (!isStereoSlave) - viewer.renderScreenImage(g, gRight, size, null);//rectClip); + viewer.renderScreenImage(g, gRight, size); } if (showPaintTime) { Added: trunk/Jmol/src/org/jmol/awt/Event.java =================================================================== --- trunk/Jmol/src/org/jmol/awt/Event.java (rev 0) +++ trunk/Jmol/src/org/jmol/awt/Event.java 2011-09-26 12:11:42 UTC (rev 16119) @@ -0,0 +1,47 @@ +/* $RCSfile$ + * $Author$ + * $Date$ + * $Revision$ + * + * Copyright (C) 2006 The Jmol Development Team + * + * Contact: jmo...@li... + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +package org.jmol.awt; + +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; + +public class Event { + + public static final int SHIFT_MASK = InputEvent.SHIFT_MASK; + public static final int ALT_MASK = InputEvent.ALT_MASK; + public static final int CTRL_MASK = InputEvent.CTRL_MASK; + public static final int META_MASK = InputEvent.META_MASK; + public static final int VK_SHIFT = KeyEvent.VK_SHIFT; + public static final int VK_ALT = KeyEvent.VK_ALT; + public static final int VK_CONTROL = KeyEvent.VK_CONTROL; + public static final int VK_LEFT = KeyEvent.VK_LEFT; + public static final int VK_RIGHT = KeyEvent.VK_RIGHT; + public static final int VK_PERIOD = KeyEvent.VK_PERIOD; + public static final int VK_SPACE = KeyEvent.VK_SPACE; + public static final int VK_DOWN = KeyEvent.VK_DOWN; + public static final int VK_UP = KeyEvent.VK_UP; + +} Modified: trunk/Jmol/src/org/jmol/modelset/AtomCollection.java =================================================================== --- trunk/Jmol/src/org/jmol/modelset/AtomCollection.java 2011-09-25 20:38:18 UTC (rev 16118) +++ trunk/Jmol/src/org/jmol/modelset/AtomCollection.java 2011-09-26 12:11:42 UTC (rev 16119) @@ -25,7 +25,6 @@ package org.jmol.modelset; -import java.awt.Rectangle; import java.util.ArrayList; import java.util.Arrays; import java.util.BitSet; @@ -53,6 +52,7 @@ import org.jmol.util.JmolEdge; import org.jmol.util.Logger; import org.jmol.util.Parser; +import org.jmol.util.Rectangle; import org.jmol.util.Measure; import org.jmol.util.Quaternion; Added: trunk/Jmol/src/org/jmol/util/Rectangle.java =================================================================== --- trunk/Jmol/src/org/jmol/util/Rectangle.java (rev 0) +++ trunk/Jmol/src/org/jmol/util/Rectangle.java 2011-09-26 12:11:42 UTC (rev 16119) @@ -0,0 +1,38 @@ +/* $RCSfile$ + * $Author: hansonr $ + * $Date: 2007-10-14 12:33:20 -0500 (Sun, 14 Oct 2007) $ + * $Revision: 8408 $ + + * + * Copyright (C) 2003-2005 The Jmol Development Team + * + * Contact: jmo...@li... + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.jmol.util; + +public class Rectangle { + + public int x; + public int y; + public int width; + public int height; + public boolean contains(int X, int Y) { + return (X >= x && Y >= y && X - x < width && Y - y < height); + } + +} Modified: trunk/Jmol/src/org/jmol/viewer/ActionManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/ActionManager.java 2011-09-25 20:38:18 UTC (rev 16118) +++ trunk/Jmol/src/org/jmol/viewer/ActionManager.java 2011-09-26 12:11:42 UTC (rev 16119) @@ -23,8 +23,6 @@ */ package org.jmol.viewer; -import java.awt.Rectangle; -import java.awt.event.KeyEvent; import java.util.ArrayList; import java.util.BitSet; import java.util.Hashtable; @@ -34,6 +32,7 @@ import javax.vecmath.Point3f; +import org.jmol.awt.Event; import org.jmol.g3d.Graphics3D; import org.jmol.i18n.GT; import org.jmol.modelset.Atom; @@ -45,6 +44,7 @@ import org.jmol.util.Escape; import org.jmol.util.Logger; import org.jmol.util.Point3fi; +import org.jmol.util.Rectangle; import org.jmol.util.TextFormat; import org.jmol.viewer.binding.DragBinding; import org.jmol.viewer.binding.Binding; @@ -579,68 +579,63 @@ /** * called by MouseManager.keyPressed - * @param ke + * @param key + * @param modifiers */ - public void keyPressed(KeyEvent ke) { - if (viewer.isApplet()) - ke.consume(); + public void keyPressed(int key, int modifiers) { if (keyProcessing) return; hoverOff(); //System.out.println("ActionmManager keyPressed: " + ke.getKeyCode()); keyProcessing = true; - int i = ke.getKeyCode(); - switch(i) { - case KeyEvent.VK_ALT: + switch(key) { + case Event.VK_ALT: if (dragSelectedMode && isAltKeyReleased) viewer.moveSelected(Integer.MIN_VALUE, 0, Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE, null, false, false); isAltKeyReleased = false; moved.modifiers |= Binding.ALT; break; - case KeyEvent.VK_SHIFT: + case Event.VK_SHIFT: dragged.modifiers |= Binding.SHIFT; moved.modifiers |= Binding.SHIFT; break; - case KeyEvent.VK_CONTROL: + case Event.VK_CONTROL: moved.modifiers |= Binding.CTRL; } int action = Binding.LEFT+Binding.SINGLE_CLICK+moved.modifiers; if(!labelMode && !binding.isUserAction(action) && !isSelectAction(action)) checkMotionRotateZoom(action, current.x, 0, 0, false); if (viewer.getNavigationMode()) { - int m = ke.getModifiers(); // if (viewer.getBooleanProperty("showKeyStrokes", false)) // viewer.evalStringQuiet("!set echo bottom left;echo " // + (i == 0 ? "" : i + " " + m)); - switch (i) { - case KeyEvent.VK_UP: - case KeyEvent.VK_DOWN: - case KeyEvent.VK_LEFT: - case KeyEvent.VK_RIGHT: - case KeyEvent.VK_SPACE: - case KeyEvent.VK_PERIOD: - viewer.navigate(i, m); + switch (key) { + case Event.VK_UP: + case Event.VK_DOWN: + case Event.VK_LEFT: + case Event.VK_RIGHT: + case Event.VK_SPACE: + case Event.VK_PERIOD: + viewer.navigate(key, modifiers); break; } } keyProcessing = false; } - public void keyReleased(KeyEvent ke) { + public void keyReleased(int key) { //System.out.println("ActionmManager keyReleased: " + ke.getKeyCode()); - ke.consume(); - int i = ke.getKeyCode(); - switch(i) { - case KeyEvent.VK_ALT: + switch(key) { + case Event.VK_ALT: if (dragSelectedMode) viewer.moveSelected(Integer.MAX_VALUE, 0, Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE, null, false, false); isAltKeyReleased = true; moved.modifiers &= ~Binding.ALT; break; - case KeyEvent.VK_SHIFT: + case Event.VK_SHIFT: moved.modifiers &= ~Binding.SHIFT; break; - case KeyEvent.VK_CONTROL: + case Event.VK_CONTROL: moved.modifiers &= ~Binding.CTRL; } if (moved.modifiers == 0) @@ -649,11 +644,11 @@ return; //if (viewer.getBooleanProperty("showKeyStrokes", false)) //viewer.evalStringQuiet("!set echo bottom left;echo;"); - switch (i) { - case KeyEvent.VK_UP: - case KeyEvent.VK_DOWN: - case KeyEvent.VK_LEFT: - case KeyEvent.VK_RIGHT: + switch (key) { + case Event.VK_UP: + case Event.VK_DOWN: + case Event.VK_LEFT: + case Event.VK_RIGHT: viewer.navigate(0, 0); break; } @@ -954,7 +949,7 @@ ); } - public Rectangle getRubberBand() { + Rectangle getRubberBand() { if (!rubberbandSelectionMode || rectRubber.x == Integer.MAX_VALUE) return null; return rectRubber; Modified: trunk/Jmol/src/org/jmol/viewer/MouseManager14.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/MouseManager14.java 2011-09-25 20:38:18 UTC (rev 16118) +++ trunk/Jmol/src/org/jmol/viewer/MouseManager14.java 2011-09-26 12:11:42 UTC (rev 16119) @@ -224,11 +224,14 @@ } public void keyPressed(KeyEvent ke) { - actionManager.keyPressed(ke); + if (viewer.isApplet()) + ke.consume(); + actionManager.keyPressed(ke.getKeyCode(), ke.getModifiers()); } public void keyReleased(KeyEvent ke) { - actionManager.keyReleased(ke); + ke.consume(); + actionManager.keyReleased(ke.getKeyCode()); } private String keyBuffer = ""; Modified: trunk/Jmol/src/org/jmol/viewer/RepaintManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/RepaintManager.java 2011-09-25 20:38:18 UTC (rev 16118) +++ trunk/Jmol/src/org/jmol/viewer/RepaintManager.java 2011-09-26 12:11:42 UTC (rev 16119) @@ -24,13 +24,13 @@ package org.jmol.viewer; import org.jmol.api.JmolRendererInterface; -import org.jmol.g3d.*; +import org.jmol.g3d.Graphics3D; import org.jmol.modelset.ModelSet; import org.jmol.shape.Shape; import org.jmol.shape.ShapeRenderer; import org.jmol.util.Logger; +import org.jmol.util.Rectangle; -import java.awt.Rectangle; import java.util.BitSet; import javax.vecmath.Point3f; Modified: trunk/Jmol/src/org/jmol/viewer/TransformManager11.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/TransformManager11.java 2011-09-25 20:38:18 UTC (rev 16118) +++ trunk/Jmol/src/org/jmol/viewer/TransformManager11.java 2011-09-26 12:11:42 UTC (rev 16119) @@ -23,17 +23,15 @@ */ package org.jmol.viewer; +import org.jmol.awt.Event; +import org.jmol.g3d.Graphics3D; import org.jmol.util.Escape; import org.jmol.util.Logger; import javax.vecmath.Point3f; import javax.vecmath.Vector3f; -import java.awt.event.KeyEvent; -import java.awt.event.InputEvent; -import org.jmol.g3d.Graphics3D; - class TransformManager11 extends TransformManager { private float navigationSlabOffset; @@ -498,22 +496,22 @@ if (nHits % 10 == 0) multiplier *= (multiplier == 4 ? 1 : 2); boolean navigateSurface = viewer.getNavigateSurface(); - boolean isShiftKey = ((modifiers & InputEvent.SHIFT_MASK) > 0); - boolean isAltKey = ((modifiers & InputEvent.ALT_MASK) > 0); - boolean isCtrlKey = ((modifiers & InputEvent.CTRL_MASK) > 0); + boolean isShiftKey = ((modifiers & Event.SHIFT_MASK) > 0); + boolean isAltKey = ((modifiers & Event.ALT_MASK) > 0); + boolean isCtrlKey = ((modifiers & Event.CTRL_MASK) > 0); float speed = viewer.getNavigationSpeed() * (isCtrlKey ? 10 : 1); // race condition viewer.cancelRendering(); switch (keyCode) { - case KeyEvent.VK_PERIOD: + case Event.VK_PERIOD: navX = navY = navZ = 0; homePosition(true); return; - case KeyEvent.VK_SPACE: + case Event.VK_SPACE: if (!navOn) return; navX = navY = navZ = 0; return; - case KeyEvent.VK_UP: + case Event.VK_UP: if (navOn) { if (isAltKey) { navY += multiplier; @@ -544,7 +542,7 @@ * (viewer.getNavigationPeriodic() ? 1 : multiplier); navMode = NAV_MODE_NEWZ; break; - case KeyEvent.VK_DOWN: + case Event.VK_DOWN: if (navOn) { if (isAltKey) { navY -= multiplier; @@ -575,7 +573,7 @@ * (viewer.getNavigationPeriodic() ? 1 : multiplier); navMode = NAV_MODE_NEWZ; break; - case KeyEvent.VK_LEFT: + case Event.VK_LEFT: if (navOn) { navX -= multiplier; value = navX; @@ -594,7 +592,7 @@ null); navMode = NAV_MODE_NEWXYZ; break; - case KeyEvent.VK_RIGHT: + case Event.VK_RIGHT: if (navOn) { navX += multiplier; value = navX; Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2011-09-25 20:38:18 UTC (rev 16118) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2011-09-26 12:11:42 UTC (rev 16119) @@ -32,6 +32,8 @@ import org.jmol.script.ScriptVariable; import org.jmol.script.Token; import org.jmol.shape.Shape; +import org.jmol.g3d.Font3D; +import org.jmol.g3d.Graphics3D; import org.jmol.i18n.GT; import org.jmol.modelset.Atom; import org.jmol.modelset.AtomCollection; @@ -44,7 +46,23 @@ import org.jmol.modelset.ModelCollection.StateScript; import org.jmol.adapter.smarter.SmarterJmolAdapter; -import org.jmol.api.*; +import org.jmol.api.AtomIndexIterator; +import org.jmol.api.Interface; +import org.jmol.api.JmolAdapter; +import org.jmol.api.JmolAppConsoleInterface; +import org.jmol.api.JmolCallbackListener; +import org.jmol.api.JmolImageCreatorInterface; +import org.jmol.api.JmolModelKitInterface; +import org.jmol.api.JmolPromptInterface; +import org.jmol.api.JmolRendererInterface; +import org.jmol.api.JmolScriptEditorInterface; +import org.jmol.api.JmolSelectionListener; +import org.jmol.api.JmolStatusListener; +import org.jmol.api.JmolViewer; +import org.jmol.api.MepCalculationInterface; +import org.jmol.api.MinimizerInterface; +import org.jmol.api.SmilesMatcherInterface; +import org.jmol.api.SymmetryInterface; import org.jmol.atomdata.AtomData; import org.jmol.atomdata.AtomDataServer; import org.jmol.atomdata.RadiusData; @@ -53,7 +71,6 @@ import org.jmol.constant.EnumStructure; import org.jmol.constant.EnumStereoMode; import org.jmol.constant.EnumVdw; -import org.jmol.g3d.*; import org.jmol.util.Base64; import org.jmol.util.BitSetUtil; import org.jmol.util.BoxInfo; @@ -67,6 +84,7 @@ import org.jmol.util.Logger; import org.jmol.util.OutputStringBuffer; import org.jmol.util.Parser; +import org.jmol.util.Rectangle; import org.jmol.util.SurfaceFileTyper; import org.jmol.util.Measure; @@ -83,7 +101,6 @@ import java.awt.Dimension; import java.awt.MediaTracker; import java.awt.Point; -import java.awt.Rectangle; import java.awt.Event; import java.awt.Toolkit; import java.awt.image.BufferedImage; @@ -4014,7 +4031,7 @@ @Override public void renderScreenImage(Graphics gLeft, Graphics gRight, - Dimension size, Rectangle clip) { + Dimension size) { // from paint/update event // gRight is for second stereo applet // when this is the stereoSlave, no rendering occurs through this applet @@ -4042,7 +4059,7 @@ } @Override - public void renderScreenImage(Graphics g, Dimension size, Rectangle clip) { + public void renderScreenImage(Graphics g, Dimension size) { /* * Jmol repaint/update system: * @@ -4052,7 +4069,7 @@ * repaintManager.repaintDone()<-- which sets repaintPending false and does * notify(); */ - renderScreenImage(g, null, size, clip); + renderScreenImage(g, null, size); } private Image getImage(boolean isDouble) { Modified: trunk/Jmol/src/org/jmol/viewer/binding/Binding.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/binding/Binding.java 2011-09-25 20:38:18 UTC (rev 16118) +++ trunk/Jmol/src/org/jmol/viewer/binding/Binding.java 2011-09-26 12:11:42 UTC (rev 16119) @@ -1,6 +1,5 @@ package org.jmol.viewer.binding; -import java.awt.Event; import java.util.ArrayList; import java.util.Arrays; import java.util.Hashtable; @@ -8,6 +7,7 @@ import java.util.List; import java.util.Map; +import org.jmol.awt.Event; import org.jmol.util.Escape; import org.jmol.util.Logger; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |