示例#1
0
 void render(Graphics3D g3d, ModelSet modelSet) { // , Rectangle rectClip
   if (!viewer.getRefreshing()) return;
   render1(g3d, modelSet); // , rectClip
   Rectangle band = viewer.getRubberBandSelection();
   if (band != null && g3d.setColix(viewer.getColixRubberband()))
     g3d.drawRect(band.x, band.y, 0, 0, band.width, band.height);
 }
示例#2
0
  String generateOutput(String type, Graphics3D g3d, ModelSet modelSet, String fileName) {

    viewer.finalizeTransformParameters();

    JmolRendererInterface g3dExport = null;
    Object output = null;
    boolean isOK = false;
    try {
      if (fileName == null) {
        output = new StringBuffer();
      } else {
        if (fileName.charAt(0) == '?') fileName = viewer.dialogAsk("save", fileName.substring(1));
        if (fileName == null) return null;
        output = fileName;
      }
      Class export3Dclass = Class.forName("org.jmol.export.Export3D");
      g3dExport = (JmolRendererInterface) export3Dclass.newInstance();
      isOK = g3dExport.initializeExporter(type, viewer, g3d, output);
    } catch (Exception e) {
    }
    if (!isOK) {
      Logger.error("Cannot export " + type);
      return null;
    }
    g3dExport.renderBackground();
    for (int i = 0; i < JmolConstants.SHAPE_MAX; ++i) {
      Shape shape = modelSet.getShape(i);
      if (shape == null) continue;
      ShapeRenderer generator = getGenerator(i, g3d);
      generator.setGenerator(true);
      generator.render(g3dExport, modelSet, shape);
      generator.setGenerator(false);
    }
    return g3dExport.finalizeOutput();
  }
示例#3
0
  private void render1(Graphics3D g3d, ModelSet modelSet) { // , Rectangle rectClip

    if (modelSet == null || !viewer.mustRenderFlag()) return;

    logTime = viewer.getTestFlag1();

    viewer.finalizeTransformParameters();

    if (logTime) Logger.startTimer();

    try {
      g3d.renderBackground();
      if (renderers == null) renderers = new ShapeRenderer[JmolConstants.SHAPE_MAX];
      for (int i = 0; i < JmolConstants.SHAPE_MAX && g3d.currentlyRendering(); ++i) {
        Shape shape = modelSet.getShape(i);
        if (shape == null) continue;
        getRenderer(i, g3d).render(g3d, modelSet, shape);
      }

    } catch (Exception e) {
      Logger.error("rendering error -- perhaps use \"set refreshing FALSE/TRUE\" ? ");
    }
    if (logTime) Logger.checkTimer("render time");
  }
示例#4
0
 private void repaintDisplay() {
   Component display = viewer.getDisplay();
   if (display == null) return;
   display.repaint();
 }