From: <ha...@us...> - 2012-09-08 20:50:33
|
Revision: 17535 http://jmol.svn.sourceforge.net/jmol/?rev=17535&view=rev Author: hansonr Date: 2012-09-08 20:50:26 +0000 (Sat, 08 Sep 2012) Log Message: ----------- refactoring for JavaScript Modified Paths: -------------- trunk/Jmol/src/org/jmol/viewer/ShapeManager.java trunk/Jmol/src/org/jmol/viewer/TransformManager.java trunk/Jmol/src/org/jmol/viewer/Viewer.java Added Paths: ----------- trunk/Jmol/src/org/jmol/api/JmolRepaintInterface.java trunk/Jmol/src/org/jmol/render/RepaintManager.java Removed Paths: ------------- trunk/Jmol/src/org/jmol/viewer/RepaintManager.java Added: trunk/Jmol/src/org/jmol/api/JmolRepaintInterface.java =================================================================== --- trunk/Jmol/src/org/jmol/api/JmolRepaintInterface.java (rev 0) +++ trunk/Jmol/src/org/jmol/api/JmolRepaintInterface.java 2012-09-08 20:50:26 UTC (rev 17535) @@ -0,0 +1,36 @@ +package org.jmol.api; + +import java.util.BitSet; + +import javax.vecmath.Point3f; + +import org.jmol.modelset.ModelSet; +import org.jmol.util.GData; +import org.jmol.viewer.ShapeManager; +import org.jmol.viewer.Viewer; + +public interface JmolRepaintInterface { + + void set(Viewer viewer, ShapeManager shapeManager); + + boolean isRepaintPending(); + + void popHoldRepaint(boolean andRepaint); + + boolean refresh(); + + void pushHoldRepaint(); + + void repaintDone(); + + void requestRepaintAndWait(); + + void clear(int iShape); + + void render(GData gdata, ModelSet modelSet, boolean isFirstPass, + BitSet bsAtoms, Point3f ptOffset); + + String renderExport(String type, GData gdata, ModelSet modelSet, + String fileName); + +} Copied: trunk/Jmol/src/org/jmol/render/RepaintManager.java (from rev 17502, trunk/Jmol/src/org/jmol/viewer/RepaintManager.java) =================================================================== --- trunk/Jmol/src/org/jmol/render/RepaintManager.java (rev 0) +++ trunk/Jmol/src/org/jmol/render/RepaintManager.java 2012-09-08 20:50:26 UTC (rev 17535) @@ -0,0 +1,261 @@ +/* $RCSfile$ + * $Author$ + * $Date$ + * $Revision$ + * + * 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 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.render; + +import org.jmol.api.JmolRendererInterface; +import org.jmol.api.JmolRepaintInterface; +import org.jmol.g3d.Graphics3D; +import org.jmol.modelset.ModelSet; +import org.jmol.shape.Shape; +import org.jmol.util.Colix; +import org.jmol.util.GData; +import org.jmol.util.Logger; +import org.jmol.util.Rectangle; +import org.jmol.viewer.JmolConstants; +import org.jmol.viewer.ShapeManager; +import org.jmol.viewer.Viewer; + +import java.util.BitSet; + +import javax.vecmath.Point3f; + +public class RepaintManager implements JmolRepaintInterface { + + private Viewer viewer; + private ShapeManager shapeManager; + private ShapeRenderer[] renderers; + + public RepaintManager() { + // required for reflection + } + + public void set(Viewer viewer, ShapeManager shapeManager) { + this.viewer = viewer; + this.shapeManager = shapeManager; + } + + /////////// thread management /////////// + + private int holdRepaint = 0; + private boolean repaintPending; + + + public boolean isRepaintPending() { + return repaintPending; + } + + + public void pushHoldRepaint() { + ++holdRepaint; + //System.out.println("repaintManager pushHoldRepaint holdRepaint=" + holdRepaint + " thread=" + Thread.currentThread().getName()); + } + + + public void popHoldRepaint(boolean andRepaint) { + --holdRepaint; + //System.out.println("repaintManager popHoldRepaint holdRepaint=" + holdRepaint + " thread=" + Thread.currentThread().getName()); + if (holdRepaint <= 0) { + holdRepaint = 0; + if (andRepaint) { + repaintPending = true; + //System.out.println("RM popholdrepaint TRUE " + (test++)); + viewer.repaint(); + } + } + } + + + public boolean refresh() { + if (repaintPending) + return false; + repaintPending = true; + if (holdRepaint == 0) { + //System.out.println("RM refresh() " + (test++)); + viewer.repaint(); + } + return true; + } + + + synchronized public void repaintDone() { + repaintPending = false; + //System.out.println("repaintManager repaintDone thread=" + Thread.currentThread().getName()); + notify(); // to cancel any wait in requestRepaintAndWait() + } + + + synchronized public void requestRepaintAndWait() { + //System.out.println("RM requestRepaintAndWait() " + (test++)); + viewer.repaint(); + try { + //System.out.println("repaintManager requestRepaintAndWait I am waiting for a repaint: thread=" + Thread.currentThread().getName()); + wait(viewer.getRepaintWait()); // more than a second probably means we are locked up here + if (repaintPending) { + Logger.error("repaintManager requestRepaintAndWait timeout"); + repaintDone(); + } + } catch (InterruptedException e) { + //System.out.println("repaintManager requestRepaintAndWait interrupted thread=" + Thread.currentThread().getName()); + } + //System.out.println("repaintManager requestRepaintAndWait I am no longer waiting for a repaint: thread=" + Thread.currentThread().getName()); + } + + /////////// renderer management /////////// + + + public void clear(int iShape) { + if (renderers == null) + return; + if (iShape >= 0) + renderers[iShape] = null; + else + for (int i = 0; i < JmolConstants.SHAPE_MAX; ++i) + renderers[i] = null; + } + + private ShapeRenderer getRenderer(int shapeID, Graphics3D g3d) { + if (renderers[shapeID] != null) + return renderers[shapeID]; + String className = JmolConstants.getShapeClassName(shapeID, true) + "Renderer"; + try { + Class<?> shapeClass = Class.forName(className); + ShapeRenderer renderer = (ShapeRenderer) shapeClass.newInstance(); + renderer.setViewerG3dShapeID(viewer, g3d, shapeID); + return renderers[shapeID] = renderer; + } catch (Exception e) { + Logger.error("Could not instantiate renderer:" + className, e); + return null; + } + } + + /////////// actual rendering /////////// + + private boolean logTime; + + + public void render(GData gdata, ModelSet modelSet, boolean isFirstPass, BitSet bsAtoms, Point3f ptOffset) { + if (modelSet == null || !viewer.mustRenderFlag()) + return; + logTime = false;//viewer.getTestFlag(2); + if (logTime) + Logger.startTimer(); + viewer.finalizeTransformParameters(); + try { + Graphics3D g3d = (Graphics3D) gdata; + g3d.renderBackground(null); + if (isFirstPass) { + int[] minMax = shapeManager.transformAtoms(bsAtoms, ptOffset); + bsAtoms = null; + if (minMax != null) + renderCrossHairs(g3d, minMax); + renderSelectionRubberBand(g3d); + } + if (renderers == null) + renderers = new ShapeRenderer[JmolConstants.SHAPE_MAX]; + for (int i = 0; i < JmolConstants.SHAPE_MAX && g3d.currentlyRendering(); ++i) { + Shape shape = shapeManager.getShape(i); + if (shape == null) + continue; + getRenderer(i, g3d).render(g3d, modelSet, shape); + if (logTime) + Logger.checkTimer("render time " + JmolConstants.getShapeClassName(i, false)); + } + } catch (Exception e) { + e.printStackTrace(); + Logger.error("rendering error? "); + } + } + + + public String renderExport(String type, GData gdata, ModelSet modelSet, + String fileName) { + + JmolRendererInterface g3dExport = null; + Object output = null; + boolean isOK; + viewer.finalizeTransformParameters(); + try { + shapeManager.transformAtoms(null, null); + output = (fileName == null ? new StringBuffer() : fileName); + Class<?> export3Dclass = Class.forName("org.jmol.export.Export3D"); + g3dExport = (JmolRendererInterface) export3Dclass.newInstance(); + isOK = viewer.initializeExporter(g3dExport, type, output); + } catch (Exception e) { + isOK = false; + } + if (!isOK) { + Logger.error("Cannot export " + type); + return null; + } + g3dExport.renderBackground(g3dExport); + for (int i = 0; i < JmolConstants.SHAPE_MAX; ++i) { + Shape shape = shapeManager.getShape(i); + if (shape != null) + getRenderer(i, (Graphics3D) gdata).render(g3dExport, modelSet, shape); + } + return g3dExport.finalizeOutput(); + } + + /////////// special rendering /////////// + + private void renderCrossHairs(Graphics3D g3d, int[] minMax) { + // this is the square and crosshairs for the navigator + Point3f navOffset = new Point3f(viewer.getNavigationOffset()); + boolean antialiased = g3d.isAntialiased(); + float navDepth = viewer.getNavigationDepthPercent(); + g3d.setColix(navDepth < 0 ? Colix.RED + : navDepth > 100 ? Colix.GREEN : Colix.GOLD); + int x = Math.max(Math.min(viewer.getScreenWidth(), (int) navOffset.x), 0); + int y = Math.max(Math.min(viewer.getScreenHeight(), (int) navOffset.y), 0); + int z = (int) navOffset.z + 1; + // TODO: fix for antialiasDisplay + int off = (antialiased ? 8 : 4); + int h = (antialiased ? 20 : 10); + int w = (antialiased ? 2 : 1); + g3d.drawRect(x - off, y, z, 0, h, w); + g3d.drawRect(x, y - off, z, 0, w, h); + g3d.drawRect(x - off, y - off, z, 0, h, h); + off = h; + h = h >> 1; + g3d.setColix(minMax[1] < navOffset.x ? Colix.YELLOW + : Colix.GREEN); + g3d.drawRect(x - off, y, z, 0, h, w); + g3d.setColix(minMax[0] > navOffset.x ? Colix.YELLOW + : Colix.GREEN); + g3d.drawRect(x + h, y, z, 0, h, w); + g3d.setColix(minMax[3] < navOffset.y ? Colix.YELLOW + : Colix.GREEN); + g3d.drawRect(x, y - off, z, 0, w, h); + g3d.setColix(minMax[2] > navOffset.y ? Colix.YELLOW + : Colix.GREEN); + g3d.drawRect(x, y + h, z, 0, w, h); + } + + private void renderSelectionRubberBand(Graphics3D g3d) { + Rectangle band = viewer.getRubberBandSelection(); + if (band != null && g3d.setColix(viewer.getColixRubberband())) + g3d.drawRect(band.x, band.y, 0, 0, band.width, band.height); + } + +} Deleted: trunk/Jmol/src/org/jmol/viewer/RepaintManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/RepaintManager.java 2012-09-08 19:47:47 UTC (rev 17534) +++ trunk/Jmol/src/org/jmol/viewer/RepaintManager.java 2012-09-08 20:50:26 UTC (rev 17535) @@ -1,265 +0,0 @@ -/* $RCSfile$ - * $Author$ - * $Date$ - * $Revision$ - * - * 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 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.viewer; - -import org.jmol.api.JmolRendererInterface; -import org.jmol.g3d.Graphics3D; -import org.jmol.modelset.ModelSet; -import org.jmol.render.ShapeRenderer; -import org.jmol.shape.Shape; -import org.jmol.util.Colix; -import org.jmol.util.GData; -import org.jmol.util.Logger; -import org.jmol.util.Rectangle; - -import java.util.BitSet; - -import javax.vecmath.Point3f; - -class RepaintManager { - - private Viewer viewer; - private ShapeManager shapeManager; - private ShapeRenderer[] renderers; - - RepaintManager(Viewer viewer, ShapeManager shapeManager) { - this.viewer = viewer; - this.shapeManager = shapeManager; - } - - /////////// thread management /////////// - - private int holdRepaint = 0; - boolean repaintPending; - - void pushHoldRepaint() { - ++holdRepaint; - //System.out.println("repaintManager pushHoldRepaint holdRepaint=" + holdRepaint + " thread=" + Thread.currentThread().getName()); - } - - void popHoldRepaint(boolean andRepaint) { - --holdRepaint; - //System.out.println("repaintManager popHoldRepaint holdRepaint=" + holdRepaint + " thread=" + Thread.currentThread().getName()); - if (holdRepaint <= 0) { - holdRepaint = 0; - if (andRepaint) { - repaintPending = true; - //System.out.println("RM popholdrepaint TRUE " + (test++)); - viewer.repaint(); - } - } - } - - boolean refresh() { - if (repaintPending) - return false; - repaintPending = true; - if (holdRepaint == 0) { - //System.out.println("RM refresh() " + (test++)); - viewer.repaint(); - } - return true; - } - - synchronized void repaintDone() { - repaintPending = false; - //System.out.println("repaintManager repaintDone thread=" + Thread.currentThread().getName()); - notify(); // to cancel any wait in requestRepaintAndWait() - } - - synchronized void requestRepaintAndWait() { - //System.out.println("RM requestRepaintAndWait() " + (test++)); - viewer.repaint(); - try { - //System.out.println("repaintManager requestRepaintAndWait I am waiting for a repaint: thread=" + Thread.currentThread().getName()); - wait(viewer.getRepaintWait()); // more than a second probably means we are locked up here - if (repaintPending) { - Logger.error("repaintManager requestRepaintAndWait timeout"); - repaintDone(); - } - } catch (InterruptedException e) { - //System.out.println("repaintManager requestRepaintAndWait interrupted thread=" + Thread.currentThread().getName()); - } - //System.out.println("repaintManager requestRepaintAndWait I am no longer waiting for a repaint: thread=" + Thread.currentThread().getName()); - } - - /////////// renderer management /////////// - - void clear(int iShape) { - if (renderers == null) - return; - if (iShape >= 0) - renderers[iShape] = null; - else - for (int i = 0; i < JmolConstants.SHAPE_MAX; ++i) - renderers[i] = null; - } - - private ShapeRenderer getRenderer(int shapeID, Graphics3D g3d) { - if (renderers[shapeID] != null) - return renderers[shapeID]; - String className = JmolConstants.getShapeClassName(shapeID, true) + "Renderer"; - try { - Class<?> shapeClass = Class.forName(className); - ShapeRenderer renderer = (ShapeRenderer) shapeClass.newInstance(); - renderer.setViewerG3dShapeID(viewer, g3d, shapeID); - return renderers[shapeID] = renderer; - } catch (Exception e) { - Logger.error("Could not instantiate renderer:" + className, e); - return null; - } - } - - /////////// actual rendering /////////// - - private boolean logTime; - - void render(GData gdata, ModelSet modelSet, boolean isFirstPass) { - if (modelSet == null || !viewer.mustRenderFlag()) - return; - logTime = false;//viewer.getTestFlag(2); - if (logTime) - Logger.startTimer(); - viewer.finalizeTransformParameters(); - try { - Graphics3D g3d = (Graphics3D) gdata; - g3d.renderBackground(null); - if (isFirstPass) { - int[] minMax = shapeManager.transformAtoms(bsAtoms, ptOffset); - bsAtoms = null; - if (minMax != null) - renderCrossHairs(g3d, minMax); - renderSelectionRubberBand(g3d); - } - if (renderers == null) - renderers = new ShapeRenderer[JmolConstants.SHAPE_MAX]; - for (int i = 0; i < JmolConstants.SHAPE_MAX && g3d.currentlyRendering(); ++i) { - Shape shape = shapeManager.getShape(i); - if (shape == null) - continue; - getRenderer(i, g3d).render(g3d, modelSet, shape); - if (logTime) - Logger.checkTimer("render time " + JmolConstants.getShapeClassName(i, false)); - } - } catch (Exception e) { - e.printStackTrace(); - Logger.error("rendering error? "); - } - } - - String renderExport(String type, GData gdata, ModelSet modelSet, - String fileName) { - - JmolRendererInterface g3dExport = null; - Object output = null; - boolean isOK; - viewer.finalizeTransformParameters(); - try { - shapeManager.transformAtoms(null, null); - output = (fileName == null ? new StringBuffer() : fileName); - Class<?> export3Dclass = Class.forName("org.jmol.export.Export3D"); - g3dExport = (JmolRendererInterface) export3Dclass.newInstance(); - isOK = viewer.initializeExporter(g3dExport, type, output); - } catch (Exception e) { - isOK = false; - } - if (!isOK) { - Logger.error("Cannot export " + type); - return null; - } - g3dExport.renderBackground(g3dExport); - for (int i = 0; i < JmolConstants.SHAPE_MAX; ++i) { - Shape shape = shapeManager.getShape(i); - if (shape != null) - getRenderer(i, (Graphics3D) gdata).render(g3dExport, modelSet, shape); - } - return g3dExport.finalizeOutput(); - } - - /////////// Allow during-rendering mouse operations /////////// - - private BitSet bsAtoms; - private Point3f ptOffset = new Point3f(); - - void setSelectedTranslation(BitSet bsAtoms, char xyz, int xy) { - this.bsAtoms = bsAtoms; - switch (xyz) { - case 'X': - case 'x': - ptOffset.x += xy; - break; - case 'Y': - case 'y': - ptOffset.y += xy; - break; - case 'Z': - case 'z': - ptOffset.z += xy; - break; - } - //System.out.println(xyz + " " + xy + " " + ptOffset); - } - - /////////// special rendering /////////// - - private void renderCrossHairs(Graphics3D g3d, int[] minMax) { - // this is the square and crosshairs for the navigator - Point3f navOffset = new Point3f(viewer.getNavigationOffset()); - boolean antialiased = g3d.isAntialiased(); - float navDepth = viewer.getNavigationDepthPercent(); - g3d.setColix(navDepth < 0 ? Colix.RED - : navDepth > 100 ? Colix.GREEN : Colix.GOLD); - int x = Math.max(Math.min(viewer.getScreenWidth(), (int) navOffset.x), 0); - int y = Math.max(Math.min(viewer.getScreenHeight(), (int) navOffset.y), 0); - int z = (int) navOffset.z + 1; - // TODO: fix for antialiasDisplay - int off = (antialiased ? 8 : 4); - int h = (antialiased ? 20 : 10); - int w = (antialiased ? 2 : 1); - g3d.drawRect(x - off, y, z, 0, h, w); - g3d.drawRect(x, y - off, z, 0, w, h); - g3d.drawRect(x - off, y - off, z, 0, h, h); - off = h; - h = h >> 1; - g3d.setColix(minMax[1] < navOffset.x ? Colix.YELLOW - : Colix.GREEN); - g3d.drawRect(x - off, y, z, 0, h, w); - g3d.setColix(minMax[0] > navOffset.x ? Colix.YELLOW - : Colix.GREEN); - g3d.drawRect(x + h, y, z, 0, h, w); - g3d.setColix(minMax[3] < navOffset.y ? Colix.YELLOW - : Colix.GREEN); - g3d.drawRect(x, y - off, z, 0, w, h); - g3d.setColix(minMax[2] > navOffset.y ? Colix.YELLOW - : Colix.GREEN); - g3d.drawRect(x, y + h, z, 0, w, h); - } - - private void renderSelectionRubberBand(Graphics3D g3d) { - Rectangle band = viewer.getRubberBandSelection(); - if (band != null && g3d.setColix(viewer.getColixRubberband())) - g3d.drawRect(band.x, band.y, 0, 0, band.width, band.height); - } - -} Modified: trunk/Jmol/src/org/jmol/viewer/ShapeManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/ShapeManager.java 2012-09-08 19:47:47 UTC (rev 17534) +++ trunk/Jmol/src/org/jmol/viewer/ShapeManager.java 2012-09-08 20:50:26 UTC (rev 17535) @@ -301,7 +301,7 @@ return bsRenderableAtoms; } - Shape getShape(int i) { + public Shape getShape(int i) { //RepaintManager return (shapes == null ? null : shapes[i]); } @@ -402,7 +402,7 @@ private final int[] navigationCrossHairMinMax = new int[4]; - int[] transformAtoms(BitSet bsAtoms, Point3f ptOffset) { + public int[] transformAtoms(BitSet bsAtoms, Point3f ptOffset) { if (bsAtoms != null) { // translateSelected operation Point3f ptCenter = viewer.getAtomSetCenter(bsAtoms); Modified: trunk/Jmol/src/org/jmol/viewer/TransformManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/TransformManager.java 2012-09-08 19:47:47 UTC (rev 17534) +++ trunk/Jmol/src/org/jmol/viewer/TransformManager.java 2012-09-08 20:50:26 UTC (rev 17535) @@ -2809,6 +2809,7 @@ Point3f[] frameOffsets; final Point3f frameOffset = new Point3f(); + void setFrameOffset(int modelIndex) { if (frameOffsets == null || modelIndex < 0 || modelIndex >= frameOffsets.length) frameOffset.set(0, 0, 0); @@ -2827,5 +2828,29 @@ void navigateSurface(float timeSeconds, String name) { } + /////////// Allow during-rendering mouse operations /////////// + + BitSet bsAtoms; + Point3f ptOffset = new Point3f(); + + void setSelectedTranslation(BitSet bsAtoms, char xyz, int xy) { + this.bsAtoms = bsAtoms; + switch (xyz) { + case 'X': + case 'x': + ptOffset.x += xy; + break; + case 'Y': + case 'y': + ptOffset.y += xy; + break; + case 'Z': + case 'z': + ptOffset.z += xy; + break; + } + //System.out.println(xyz + " " + xy + " " + ptOffset); + } + } Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2012-09-08 19:47:47 UTC (rev 17534) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2012-09-08 20:50:26 UTC (rev 17535) @@ -52,6 +52,7 @@ import org.jmol.api.JmolCallbackListener; import org.jmol.api.JmolImageCreatorInterface; import org.jmol.api.JmolRendererInterface; +import org.jmol.api.JmolRepaintInterface; import org.jmol.api.JmolScriptEditorInterface; import org.jmol.api.JmolSelectionListener; import org.jmol.api.JmolStatusListener; @@ -289,7 +290,7 @@ private ShapeManager shapeManager; private ModelManager modelManager; private ModelSet modelSet; - private RepaintManager repaintManager; + private JmolRepaintInterface repaintManager; private ScriptManager scriptManager; private SelectionManager selectionManager; private StateManager stateManager; @@ -391,7 +392,10 @@ tempManager = new TempArray(); dataManager = new DataManager(this); animationManager = new AnimationManager(this); - repaintManager = new RepaintManager(this, shapeManager); + repaintManager = (JmolRepaintInterface) (Interface + .getOptionInterface("render.RepaintManager")); + if (repaintManager != null) + repaintManager.set(this, shapeManager); initialize(true); fileManager = new FileManager(this); compiler = new ScriptCompiler(this); @@ -539,7 +543,7 @@ return htmlName; } - boolean mustRenderFlag() { + public boolean mustRenderFlag() { return mustRender && (refreshing || creatingImage); } @@ -1057,7 +1061,7 @@ if (bsAtoms != null) { if (xy == 0) return; - repaintManager.setSelectedTranslation(bsAtoms, xyz, xy); + transformManager.setSelectedTranslation(bsAtoms, xyz, xy); } else { switch (xyz) { case 'X': @@ -1188,7 +1192,7 @@ return transformManager.getUnscaledTransformMatrix(); } - void finalizeTransformParameters() { + public void finalizeTransformParameters() { // FrameRenderer // InitializeModel @@ -1769,7 +1773,7 @@ } } - Rectangle getRubberBandSelection() { + public Rectangle getRubberBandSelection() { return (haveDisplay ? actionManager.getRubberBand() : null); } @@ -2740,7 +2744,7 @@ ligandModelSet = null; clearModelDependentObjects(); fileManager.clear(); - repaintManager.clear(-1); + clearRepaintManager(-1); animationManager.clear(); transformManager.clear(); selectionManager.clear(); @@ -3924,37 +3928,40 @@ pushHoldRepaint(null); } + private boolean refreshing = true; + + private void setRefreshing(boolean TF) { + refreshing = TF; + } + + public boolean getRefreshing() { + return refreshing; + } + /** * * @param why */ public void pushHoldRepaint(String why) { // System.out.println("viewer pushHoldRepaint " + why); - repaintManager.pushHoldRepaint(); + if (repaintManager != null) + repaintManager.pushHoldRepaint(); } @Override public void popHoldRepaint() { //System.out.println("viewer popHoldRepaint don't know why"); - repaintManager.popHoldRepaint(true); + if (repaintManager != null) + repaintManager.popHoldRepaint(true); } public void popHoldRepaint(String why) { //if (!why.equals("pause")) //System.out.println("viewer popHoldRepaint " + why); - repaintManager.popHoldRepaint(!why.equals("pause")); + if (repaintManager != null) + repaintManager.popHoldRepaint(!why.equals("pause")); } - private boolean refreshing = true; - - private void setRefreshing(boolean TF) { - refreshing = TF; - } - - public boolean getRefreshing() { - return refreshing; - } - /** * initiate a repaint/update sequence if it has not already been requested. * invoked whenever any operation causes changes that require new rendering. @@ -4009,20 +4016,24 @@ // called by AnimationThread run() // called by TransformationManager move and moveTo // called by TransformationManager11 navigate, navigateSurface, navigateTo - if (!haveDisplay) + if (!haveDisplay || repaintManager == null) return; repaintManager.requestRepaintAndWait(); setSync(); } - private void setSync() { - if (statusManager.doSync()) - statusManager.setSync(null); + public void clearShapeRenderers() { + clearRepaintManager(-1); } + boolean isRepaintPending() { + return (repaintManager == null ? false : repaintManager.isRepaintPending()); + } + @Override public void notifyViewerRepaintDone() { - repaintManager.repaintDone(); + if (repaintManager != null) + repaintManager.repaintDone(); animationManager.repaintDone(); } @@ -4114,7 +4125,7 @@ @Override public String generateOutput(String type, String[] fileName, int width, int height) { - if (noGraphicsAllowed) + if (noGraphicsAllowed || repaintManager == null) return null; String fName = null; if (fileName != null) { @@ -4136,6 +4147,11 @@ return data; } + private void clearRepaintManager(int iShape) { + if (repaintManager != null) + repaintManager.clear(iShape); + } + @Override public void renderScreenImage(Object gLeft, Object gRight, int width, int height) { @@ -4151,13 +4167,15 @@ if (isTainted || getSlabEnabled()) setModelVisibility(); isTainted = false; - if (width != 0) - setScreenDimension(width, height); - if (gRight == null) { - getScreenImage(gLeft); - } else { - render1(gRight, getImage(true), 0, 0); - render1(gLeft, getImage(false), 0, 0); + if (repaintManager != null) { + if (width != 0) + setScreenDimension(width, height); + if (gRight == null) { + getScreenImage(gLeft); + } else { + render1(gRight, getImage(true), 0, 0); + render1(gLeft, getImage(false), 0, 0); + } } } // System.out.println(Thread.currentThread() + @@ -4206,13 +4224,13 @@ } private void render() { - if (!refreshing && !creatingImage) + if (!refreshing && !creatingImage || repaintManager == null) return; boolean antialias2 = antialiasDisplay && global.antialiasTranslucent; - repaintManager.render(gdata, modelSet, true); + repaintManager.render(gdata, modelSet, true, transformManager.bsAtoms, transformManager.ptOffset); if (gdata.setPass2(antialias2)) { transformManager.setAntialias(antialias2); - repaintManager.render(gdata, modelSet, false); + repaintManager.render(gdata, modelSet, false, null, null); transformManager.setAntialias(antialiasDisplay); } } @@ -4993,10 +5011,6 @@ refresh(3, "hover off"); } - public void clearShapeRenderers() { - repaintManager.clear(-1); - } - public int getBfactor100Hi() { return modelSet.getBfactor100Hi(); } @@ -5127,6 +5141,11 @@ // //////////////status manager dispatch////////////// + private void setSync() { + if (statusManager.doSync()) + statusManager.setSync(null); + } + @Override public void setJmolCallbackListener(JmolCallbackListener jmolCallbackListener) { statusManager.setJmolCallbackListener(jmolCallbackListener); @@ -9247,7 +9266,7 @@ selectionManager.processDeletedModelAtoms(bsDeleted); setAnimationRange(0, 0); eval.deleteAtomsInVariables(bsDeleted); - repaintManager.clear(-1); + clearRepaintManager(-1); animationManager.clear(); animationManager.initializePointers(1); setCurrentModelIndex(getModelCount() > 1 ? -1 : 0, getModelCount() > 1); @@ -9372,7 +9391,7 @@ return ""; if (modelSet != null) shapeManager.releaseShape(currentShapeID); - repaintManager.clear(currentShapeID); + clearRepaintManager(currentShapeID); return JmolConstants.getShapeClassName(currentShapeID, false) + " " + currentShapeState; } @@ -9438,10 +9457,6 @@ return modelSet.getMoInfo(modelIndex); } - boolean isRepaintPending() { - return repaintManager.repaintPending; - } - public Map<String, ScriptVariable> getContextVariables() { return eval.getContextVariables(); } @@ -9491,7 +9506,7 @@ animationManager.currentModelIndex); } - void repaint() { + public void repaint() { // from RepaintManager if (haveDisplay) apiPlatform.repaint(display); @@ -9934,7 +9949,7 @@ shapeManager.resetShapes(); if (andCreateNew) { shapeManager.loadDefaultShapes(modelSet); - repaintManager.clear(-1); + clearRepaintManager(-1); } } @@ -10348,7 +10363,7 @@ // reset after a state script is read } - boolean initializeExporter(JmolRendererInterface g3dExport, String type, + public boolean initializeExporter(JmolRendererInterface g3dExport, String type, Object output) { return g3dExport.initializeExporter(type, this, privateKey, gdata, output); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |