-
-
Notifications
You must be signed in to change notification settings - Fork 768
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a new visualizer panel for rendering using NEWT for better perf…
…ormance (#2602)
- Loading branch information
Showing
12 changed files
with
519 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...zer/src/main/java/com/willwinder/ugs/nbm/visualizer/jogl/NewtKeyboardListenerAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
Copyright 2024 Will Winder | ||
This file is part of Universal Gcode Sender (UGS). | ||
UGS is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
UGS 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 General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with UGS. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.willwinder.ugs.nbm.visualizer.jogl; | ||
|
||
import com.jogamp.newt.event.KeyEvent; | ||
import com.jogamp.newt.event.KeyListener; | ||
|
||
import java.awt.Component; | ||
|
||
/** | ||
* A keyboard listener adapter for translating between events from the NEWT JOGL canvas to AWT listeners. | ||
* | ||
* @author Joacim Breiler | ||
*/ | ||
public class NewtKeyboardListenerAdapter implements KeyListener { | ||
private final java.awt.event.KeyListener keyListener; | ||
private final Component component; | ||
|
||
public NewtKeyboardListenerAdapter(Component component, java.awt.event.KeyListener keyListener) { | ||
this.keyListener = keyListener; | ||
this.component = component; | ||
} | ||
|
||
@Override | ||
public void keyPressed(KeyEvent e) { | ||
this.keyListener.keyPressed(new java.awt.event.KeyEvent(component, 0, e.getWhen(), e.getModifiers(), e.getKeyCode(), e.getKeyChar())); | ||
} | ||
|
||
@Override | ||
public void keyReleased(KeyEvent e) { | ||
this.keyListener.keyPressed(new java.awt.event.KeyEvent(component, 0, e.getWhen(), e.getModifiers(), e.getKeyCode(), e.getKeyChar())); | ||
} | ||
} |
84 changes: 84 additions & 0 deletions
84
...alizer/src/main/java/com/willwinder/ugs/nbm/visualizer/jogl/NewtMouseListenerAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
Copyright 2024 Will Winder | ||
This file is part of Universal Gcode Sender (UGS). | ||
UGS is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
UGS 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 General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with UGS. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.willwinder.ugs.nbm.visualizer.jogl; | ||
|
||
import com.jogamp.newt.event.MouseListener; | ||
|
||
import java.awt.Component; | ||
import java.awt.event.MouseMotionListener; | ||
import java.awt.event.MouseWheelEvent; | ||
import java.awt.event.MouseWheelListener; | ||
|
||
|
||
public class NewtMouseListenerAdapter implements MouseListener { | ||
|
||
private final java.awt.event.MouseListener mouseListener; | ||
private final MouseWheelListener mouseWheelListener; | ||
private final MouseMotionListener mouseMotionListener; | ||
private final Component component; | ||
|
||
public NewtMouseListenerAdapter(Component component, java.awt.event.MouseListener mouseListener, MouseWheelListener mouseWheelListener, MouseMotionListener mouseMotionListener) { | ||
this.component = component; | ||
this.mouseListener = mouseListener; | ||
this.mouseWheelListener = mouseWheelListener; | ||
this.mouseMotionListener = mouseMotionListener; | ||
} | ||
|
||
@Override | ||
public void mouseClicked(com.jogamp.newt.event.MouseEvent e) { | ||
mouseListener.mouseClicked(new java.awt.event.MouseEvent(component, 0, e.getWhen(), e.getModifiers(), e.getX(), e.getY(), e.getClickCount(), false, e.getButton())); | ||
} | ||
|
||
@Override | ||
public void mouseEntered(com.jogamp.newt.event.MouseEvent e) { | ||
mouseListener.mouseEntered(new java.awt.event.MouseEvent(component, 0, e.getWhen(), e.getModifiers(), e.getX(), e.getY(), e.getClickCount(), false, e.getButton())); | ||
} | ||
|
||
@Override | ||
public void mouseExited(com.jogamp.newt.event.MouseEvent e) { | ||
mouseListener.mouseExited(new java.awt.event.MouseEvent(component, 0, e.getWhen(), e.getModifiers(), e.getX(), e.getY(), e.getClickCount(), false, e.getButton())); | ||
} | ||
|
||
@Override | ||
public void mousePressed(com.jogamp.newt.event.MouseEvent e) { | ||
mouseListener.mousePressed(new java.awt.event.MouseEvent(component, 0, e.getWhen(), e.getModifiers(), e.getX(), e.getY(), e.getClickCount(), false, e.getButton())); | ||
} | ||
|
||
@Override | ||
public void mouseReleased(com.jogamp.newt.event.MouseEvent e) { | ||
mouseListener.mouseReleased(new java.awt.event.MouseEvent(component, 0, e.getWhen(), e.getModifiers(), e.getX(), e.getY(), e.getClickCount(), false, e.getButton())); | ||
} | ||
|
||
@Override | ||
public void mouseMoved(com.jogamp.newt.event.MouseEvent e) { | ||
mouseMotionListener.mouseMoved(new java.awt.event.MouseEvent(component, 0, e.getWhen(), e.getModifiers(), e.getX(), e.getY(), e.getClickCount(), false, e.getButton())); | ||
|
||
} | ||
|
||
@Override | ||
public void mouseDragged(com.jogamp.newt.event.MouseEvent e) { | ||
mouseMotionListener.mouseDragged(new java.awt.event.MouseEvent(component, 0, e.getWhen(), e.getModifiers(), e.getX(), e.getY(), e.getClickCount(), false, e.getButton())); | ||
|
||
} | ||
|
||
@Override | ||
public void mouseWheelMoved(com.jogamp.newt.event.MouseEvent e) { | ||
mouseWheelListener.mouseWheelMoved(new MouseWheelEvent(component, 0, e.getWhen(), e.getModifiers(), e.getX(), e.getY(), e.getClickCount(), false, MouseWheelEvent.WHEEL_UNIT_SCROLL, Math.round(e.getRotationScale()), Math.round(e.getRotation()[1]))); | ||
} | ||
} |
Oops, something went wrong.