Example usage for com.badlogic.gdx.backends.lwjgl LwjglAWTCanvas LwjglAWTCanvas

List of usage examples for com.badlogic.gdx.backends.lwjgl LwjglAWTCanvas LwjglAWTCanvas

Introduction

In this page you can find the example usage for com.badlogic.gdx.backends.lwjgl LwjglAWTCanvas LwjglAWTCanvas.

Prototype

public LwjglAWTCanvas(ApplicationListener listener) 

Source Link

Usage

From source file:com.xoppa.blog.libgdx.Main.java

License:Apache License

public boolean runApp(final AppDesc appDesc) {
    ApplicationListener listener;//from w  w  w  .  j  a  va  2 s. co m
    try {
        listener = appDesc.clazz.newInstance();
    } catch (InstantiationException e) {
        return false;
    } catch (IllegalAccessException e) {
        return false;
    }
    data = (appDesc.data == null || appDesc.data.isEmpty()) ? "data" : appDesc.data;

    Container container = getContentPane();
    if (currentTest != null)
        container.remove(currentTest.getCanvas());

    currentTest = new LwjglAWTCanvas(listener);
    currentTest.getCanvas().setSize(appDesc.width, appDesc.height);
    container.add(currentTest.getCanvas(), BorderLayout.CENTER);
    pack();
    return true;
}

From source file:de.bioviz.desktop.DesktopLauncher.java

License:Open Source License

/**
 * Creates a desktop launcher.//from   w w w.  j ava 2  s  .c  o m
 *
 * @param file
 *       the file to be opened by default
 */
public DesktopLauncher(final File file) {
    singleton = this;
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    tabsToFilenames = new HashMap<>();

    if (file == null) {
        currentViz = new BioViz();
    } else {
        currentViz = new BioViz(file);
    }
    canvas = new LwjglAWTCanvas(currentViz);
    editor = new BioVizEditor(currentViz);
    hardErrorsViewer = new ErrorViewer(currentViz, "Parser errors", ErrorViewer.ERRORTYPE.HARD);
    softErrorsViewer = new ErrorViewer(currentViz, "Parser warnings", ErrorViewer.ERRORTYPE.SOFT);
    annotationViewer = new AnnotationViewer(currentViz);

    currentViz.addCloseFileListener(new CloseFileCallback());

    final Container container = getContentPane();
    container.setLayout(new BorderLayout());

    this.setTitle(BioVizInfo.PROGNAME);

    logger.debug("Starting DesktopLauncher with file \"{}\"", file);

    initializeTabs(file);

    /**
     * Needed to pipe through the keyboard events to the libgdx application
     */
    KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    manager.addKeyEventDispatcher(new MyDispatcher());

    JPanel panel = initializePanel();

    infoPanel = new InfoPanel(currentViz);

    this.setJMenuBar(initializeMenubar());

    input = new LwjglAWTInput(canvas);

    container.add(panel, BorderLayout.WEST);

    JPanel tabContainer = new JPanel(new BorderLayout());

    container.add(tabContainer, BorderLayout.CENTER);

    container.add(infoPanel, BorderLayout.EAST);

    tabContainer.add(visualizationTabs, BorderLayout.NORTH);
    tabContainer.add(canvas.getCanvas(), BorderLayout.CENTER);

    loadedCB = new LoadedFileCallback();
    currentViz.addLoadedFileListener(loadedCB);

    saveCB = new SaveFileCallback();
    currentViz.addSaveFileListener(saveCB);

    currentViz.addPickColourListener(new ColourPickCallback());

    String iconPath = "";
    try {
        iconPath = "/" + currentViz.getApplicationIcon().path();
        this.setIconImage(ImageIO.read(getFileFromStream(iconPath)));
    } catch (final Exception e) {
        logger.error("Could not set application icon: " + e.getMessage() + " with path: " + iconPath);
    }

    editor.setIcon(iconPath);
    softErrorsViewer.setIcon(iconPath);
    hardErrorsViewer.setIcon(iconPath);
    annotationViewer.setIcon(iconPath);

    pack();
    setVisible(true);

    setSize(DEFAULT_X_WIDTH, DEFAULT_Y_WIDTH);

    currentViz.addReloadFileListener(() -> {
        reloadTab();
        reloadViewers();
    });
}

From source file:dk.jener.atlasGenerator.Window.java

License:Open Source License

public void createCanvas() {
    canvas = new LwjglAWTCanvas(new Engine());
    getContentPane().add(canvas.getCanvas(), BorderLayout.CENTER);
}