Search in sources :

Example 1 with GcodeRenderer

use of com.willwinder.ugs.nbm.visualizer.shared.GcodeRenderer in project Universal-G-Code-Sender by winder.

the class Visualizer2TopComponent method makeWindow.

private GLJPanel makeWindow() {
    GLCapabilities glCaps = new GLCapabilities(null);
    final GLJPanel p = new GLJPanel(glCaps);
    GcodeRenderer renderer = Lookup.getDefault().lookup(GcodeRenderer.class);
    if (renderer == null) {
        throw new IllegalArgumentException("Failed to access GcodeRenderer.");
    }
    FPSAnimator animator = new FPSAnimator(p, 15);
    this.rih = new RendererInputHandler(renderer, animator, new VisualizerPopupMenu(backend, renderer), backend.getSettings());
    Preferences pref = NbPreferences.forModule(VisualizerOptionsPanel.class);
    pref.addPreferenceChangeListener(this.rih);
    File f = (backend.getProcessedGcodeFile() != null) ? backend.getProcessedGcodeFile() : backend.getGcodeFile();
    if (f != null) {
        this.rih.setGcodeFile(f.getAbsolutePath());
    }
    // Install listeners...
    backend.addControllerListener(this.rih);
    backend.addUGSEventListener(this.rih);
    // shutdown hook...
    // frame.addWindowListener(this.rih);
    // key listener...
    p.addKeyListener(this.rih);
    // mouse wheel...
    p.addMouseWheelListener(this.rih);
    // mouse motion...
    p.addMouseMotionListener(this.rih);
    // mouse...
    p.addMouseListener(this.rih);
    p.addGLEventListener(renderer);
    return p;
}
Also used : FPSAnimator(com.jogamp.opengl.util.FPSAnimator) GLCapabilities(com.jogamp.opengl.GLCapabilities) GLJPanel(com.jogamp.opengl.awt.GLJPanel) GcodeRenderer(com.willwinder.ugs.nbm.visualizer.shared.GcodeRenderer) Preferences(java.util.prefs.Preferences) NbPreferences(org.openide.util.NbPreferences) File(java.io.File)

Aggregations

GLCapabilities (com.jogamp.opengl.GLCapabilities)1 GLJPanel (com.jogamp.opengl.awt.GLJPanel)1 FPSAnimator (com.jogamp.opengl.util.FPSAnimator)1 GcodeRenderer (com.willwinder.ugs.nbm.visualizer.shared.GcodeRenderer)1 File (java.io.File)1 Preferences (java.util.prefs.Preferences)1 NbPreferences (org.openide.util.NbPreferences)1