List of usage examples for com.badlogic.gdx.backends.lwjgl LwjglAWTInput LwjglAWTInput
public LwjglAWTInput(Canvas canvas)
From source file:de.bioviz.desktop.DesktopLauncher.java
License:Open Source License
/** * Creates a desktop launcher./*w w w .j a v a 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(); }); }