package pointGroups.gui;

import java.awt.BorderLayout;
import java.util.concurrent.Future;

import javax.swing.JButton;
import javax.swing.JPanel;

import de.jreality.plugin.JRViewer;
import de.jreality.scene.Viewer;


public class SchlegelView
  extends JPanel
{

  private static final long serialVersionUID = -3642299900579728806L;

  protected Future<JRViewer> viewerFuture;
  protected JRViewer schlegelViewer;
  protected Viewer schlegelView;

  public SchlegelView() {
    super();

    setLayout(new BorderLayout());

    JButton button3 = new JButton("VIEW");
    add(button3, BorderLayout.PAGE_END);

    viewerFuture = UiViewer.viewerFactory(this);
  }

  public Viewer getSchlegelView() {
    try {
      schlegelViewer = viewerFuture.get();
      schlegelView = schlegelViewer.getViewer();
    }
    catch (Exception e) {
      e.printStackTrace();
    }

    return schlegelView;
  }

  public void dispose() {
    UiViewer.dispose(viewerFuture);
  }
}

package pointGroups.gui;

import java.awt.BorderLayout;

import javax.swing.JButton;
import javax.swing.JPanel;

import de.jreality.geometry.Primitives;


public class SchlegelView
  extends JPanel
{

  private static final long serialVersionUID = -3642299900579728806L;

  protected final UiViewer uiViewer = new UiViewer(this);

  public SchlegelView() {
    super();

    setLayout(new BorderLayout());

    JButton button3 = new JButton("VIEW");
    add(button3, BorderLayout.PAGE_END);

    // TODO: remove me, just a placeholder geometry
    uiViewer.setGeometry(Primitives.cone(15));
  }

  public void dispose() {
    uiViewer.dispose();
  }
}

use the UiViewer to manage jReality in the SchlegelView