Search in sources :

Example 1 with SurfaceBase

use of spacegraph.space2d.SurfaceBase in project narchy by automenta.

the class AWTSurface method start.

@Override
public void start(@Nullable SurfaceBase parent) {
    synchronized (this) {
        super.start(parent);
        AtomicBoolean busy = new AtomicBoolean(false);
        ons = root().onUpdate(w -> {
            if (!busy.compareAndSet(false, true))
                return;
            // if (component.getIgnoreRepaint() && !component.is)
            SwingUtilities.invokeLater(() -> {
                try {
                    buffer = AWTCamera.get(component, buffer);
                    tex.update(buffer);
                } finally {
                    busy.set(false);
                }
            });
        });
    }
}
Also used : InputEvent(java.awt.event.InputEvent) BufferedImage(java.awt.image.BufferedImage) NOBUTTON(java.awt.event.MouseEvent.NOBUTTON) Keyboard(spacegraph.input.key.Keyboard) VK_UNDEFINED(java.awt.event.KeyEvent.VK_UNDEFINED) Tex(spacegraph.video.Tex) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) AWTCamera(spacegraph.util.AWTCamera) KeyEvent(com.jogamp.newt.event.KeyEvent) spacegraph.util.math.v2(spacegraph.util.math.v2) MouseEvent(java.awt.event.MouseEvent) Widget(spacegraph.space2d.widget.windo.Widget) InvocationTargetException(java.lang.reflect.InvocationTargetException) java.awt(java.awt) Nullable(org.jetbrains.annotations.Nullable) SurfaceBase(spacegraph.space2d.SurfaceBase) On(jcog.event.On) Finger(spacegraph.input.finger.Finger) Method(java.lang.reflect.Method) javax.swing(javax.swing) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean)

Example 2 with SurfaceBase

use of spacegraph.space2d.SurfaceBase in project narchy by automenta.

the class ConsoleGUI method start.

@Override
public void start(@Nullable SurfaceBase parent) {
    synchronized (this) {
        super.start(parent);
        // thr.start();
        try {
            screen = new TerminalScreen(term);
            screen.startScreen();
            gui = new MultiWindowTextGUI(MyStupidGUIThread::new, screen);
            // TODO try to avoid wrapping it in Window
            window = new BasicWindow();
            window.setPosition(new TerminalPosition(0, 0));
            TerminalSize size = term.getTerminalSize();
            window.setSize(new TerminalSize(size.getColumns(), size.getRows()));
            window.setHints(List.of(Window.Hint.FULL_SCREEN, Window.Hint.NO_DECORATIONS));
            window.setTheme(DARK);
            window.setEnableDirectionBasedMovements(true);
            gui.addWindow(window);
            gui.setActiveWindow(window);
            gui.setEOFWhenNoWindows(true);
            init(window);
            TextGUIThread guiThread = gui.getGUIThread();
            updates = root().onUpdate((s) -> {
                try {
                    guiThread.processEventsAndUpdate();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            });
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
Also used : TerminalScreen(com.googlecode.lanterna.screen.TerminalScreen) TerminalSize(com.googlecode.lanterna.TerminalSize) DefaultVirtualTerminal(com.googlecode.lanterna.terminal.virtual.DefaultVirtualTerminal) com.googlecode.lanterna.gui2(com.googlecode.lanterna.gui2) IOException(java.io.IOException) TextColor(com.googlecode.lanterna.TextColor) EOFException(java.io.EOFException) Nullable(org.jetbrains.annotations.Nullable) TerminalScreen(com.googlecode.lanterna.screen.TerminalScreen) List(java.util.List) SurfaceBase(spacegraph.space2d.SurfaceBase) SimpleTheme(com.googlecode.lanterna.graphics.SimpleTheme) On(jcog.event.On) TerminalPosition(com.googlecode.lanterna.TerminalPosition) Theme(com.googlecode.lanterna.graphics.Theme) TerminalPosition(com.googlecode.lanterna.TerminalPosition) TerminalSize(com.googlecode.lanterna.TerminalSize) IOException(java.io.IOException)

Aggregations

On (jcog.event.On)2 Nullable (org.jetbrains.annotations.Nullable)2 SurfaceBase (spacegraph.space2d.SurfaceBase)2 TerminalPosition (com.googlecode.lanterna.TerminalPosition)1 TerminalSize (com.googlecode.lanterna.TerminalSize)1 TextColor (com.googlecode.lanterna.TextColor)1 SimpleTheme (com.googlecode.lanterna.graphics.SimpleTheme)1 Theme (com.googlecode.lanterna.graphics.Theme)1 com.googlecode.lanterna.gui2 (com.googlecode.lanterna.gui2)1 TerminalScreen (com.googlecode.lanterna.screen.TerminalScreen)1 DefaultVirtualTerminal (com.googlecode.lanterna.terminal.virtual.DefaultVirtualTerminal)1 KeyEvent (com.jogamp.newt.event.KeyEvent)1 java.awt (java.awt)1 InputEvent (java.awt.event.InputEvent)1 VK_UNDEFINED (java.awt.event.KeyEvent.VK_UNDEFINED)1 MouseEvent (java.awt.event.MouseEvent)1 NOBUTTON (java.awt.event.MouseEvent.NOBUTTON)1 BufferedImage (java.awt.image.BufferedImage)1 EOFException (java.io.EOFException)1 IOException (java.io.IOException)1