List of usage examples for java.awt GraphicsEnvironment getLocalGraphicsEnvironment
public static GraphicsEnvironment getLocalGraphicsEnvironment()
From source file:com.lfv.lanzius.application.Controller.java
public synchronized void settingsDialogOpen() { if (state != CLIENT_STATE_STARTED) return;//from ww w .j a v a2 s . c o m // This button is also used to stop the auto tester if (autoTesterEnabled) { autoTester.stopTester(); JOptionPane.showMessageDialog(view, "The auto tester has been stopped! The settings dialog\n" + "is unaccessible when the auto tester is enabled!", "Auto tester", JOptionPane.INFORMATION_MESSAGE); return; } if (settingsDialog == null) { boolean full = properties.getUserInterfaceStyle().equalsIgnoreCase("full"); if (!full) JDialog.setDefaultLookAndFeelDecorated(true); settingsDialog = new JDialog(view, "Settings", false); settingsDialog.setContentPane(new SettingsPane(this)); if (full) { settingsDialog.setResizable(false); settingsDialog.setUndecorated(true); Rectangle rect = view.getBounds(); rect.x += rect.width * 0.1; rect.y += rect.height * 0.1; rect.width *= 0.8; rect.height *= 0.8; settingsDialog.setBounds(rect); // Hide mouse cursor if stated in the properties file if (properties.isMouseCursorHidden()) settingsDialog.setCursor(InvisibleCursor.getCursor()); } else { GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); Rectangle rect = graphicsEnvironment.getMaximumWindowBounds(); rect.x += rect.width * 0.25; rect.y += rect.height * 0.25; rect.width *= 0.5; rect.height *= 0.5; settingsDialog.setBounds(rect); settingsDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); settingsDialog.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { settingsDialogClose(); } }); } settingsDialog.setVisible(true); } }
From source file:de.bwravencl.controllerbuddy.gui.Main.java
private void startOverlayTimerTask() { stopOverlayTimerTask();//from ww w . jav a 2 s .com overlayTimerTask = new TimerTask() { @Override public void run() { SwingUtilities.invokeLater(() -> { if (!isModalDialogShowing()) { if (overlayFrame != null) { overlayFrame.setAlwaysOnTop(false); overlayFrame.setAlwaysOnTop(true); } if (onScreenKeyboard.isVisible()) { onScreenKeyboard.setAlwaysOnTop(false); onScreenKeyboard.setAlwaysOnTop(true); } } final var maxWindowBounds = GraphicsEnvironment.getLocalGraphicsEnvironment() .getMaximumWindowBounds(); if (!maxWindowBounds.equals(prevMaxWindowBounds)) { prevMaxWindowBounds = maxWindowBounds; updateOverlayLocation(maxWindowBounds); onScreenKeyboard.updateLocation(); } repaintOverlay(); }); } }; timer.schedule(overlayTimerTask, OVERLAY_POSITION_UPDATE_INTERVAL, OVERLAY_POSITION_UPDATE_INTERVAL); }
From source file:com.peterbochs.PeterBochsDebugger.java
private void initChineseFont() { new Thread("initChineseFont thread") { public void run() { Font[] allfonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts(); String chinesesample = "\u4e00"; for (int j = 0; j < allfonts.length; j++) { if (allfonts[j].canDisplayUpTo(chinesesample) == -1) { // System.out.println(allfonts[j].getFontName()); JMenuItem jMenuItem = new JMenuItem(allfonts[j].getFontName()); jMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Setting.getInstance().setFontFamily(((JMenuItem) evt.getSource()).getText()); }//from w w w. j ava 2s .c om }); jMenu2.add(jMenuItem); } } for (int j = 0; j < allfonts.length; j++) { if (allfonts[j].canDisplayUpTo(chinesesample) != -1) { // System.out.println(allfonts[j].getFontName()); JMenuItem jMenuItem = new JMenuItem(allfonts[j].getFontName()); jMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Setting.getInstance().setFontFamily(((JMenuItem) evt.getSource()).getText()); } }); jMenu2.add(jMenuItem); } } } }.start(); }
From source file:lucee.runtime.img.Image.java
public static BufferedImage toBufferedImage(java.awt.Image image) { if (image instanceof BufferedImage) { return (BufferedImage) image; }/* w ww .j a va 2 s. c o m*/ // This code ensures that all the pixels in the image are loaded image = new ImageIcon(image).getImage(); // Determine if the image has transparent pixels; for this method's boolean hasAlpha = hasAlpha(image); // Create a buffered image with a format that's compatible with the screen BufferedImage bimage = null; GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); try { // Determine the type of transparency of the new buffered image int transparency = Transparency.OPAQUE; if (hasAlpha) { transparency = Transparency.BITMASK; } // Create the buffered image GraphicsDevice gs = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gs.getDefaultConfiguration(); bimage = gc.createCompatibleImage(image.getWidth(null), image.getHeight(null), transparency); } catch (HeadlessException e) { // The system does not have a screen } if (bimage == null) { // Create a buffered image using the default color model int type = BufferedImage.TYPE_INT_RGB; if (hasAlpha) { type = BufferedImage.TYPE_INT_ARGB; } bimage = new BufferedImage(image.getWidth(null), image.getHeight(null), type); } // Copy image to buffered image Graphics g = bimage.createGraphics(); // Paint the image onto the buffered image g.drawImage(image, 0, 0, null); g.dispose(); return bimage; }
From source file:com.lfv.lanzius.application.Controller.java
/** * Open the ISA dialog (if the radio has been silent for at least 2 seconds) * @return true if the dialog was opened *///from w w w . j av a 2 s .co m public boolean isaDialogOpen(int isaNumChoices, boolean isaExtendedMode, String isakeytext[]) { final int radioSilentLimit = 500; // Do not show ISA dialog until at least half a second of silence if (view == null) return true; // This might happen if ISA request when terminal is starting up, don't open ISA dialog if (isaDialog == null) { // Is radio or phone active? boolean codecActive = (radioEncoding || radioDecoding || phoneActive); // Wait for 2 seconds of radio silence if (codecActive || (System.currentTimeMillis() - radioIdleTime) < radioSilentLimit) { // Ignore ISA request if too busy return false; } boolean full = properties.getUserInterfaceStyle().equalsIgnoreCase("full"); if (!full) JDialog.setDefaultLookAndFeelDecorated(true); isaDialog = new JDialog(view, "Workload", false); isaDialog.setContentPane( new ISAPane(Controller.getInstance(), isaNumChoices, isaExtendedMode, isakeytext)); if (full) { isaDialog.setResizable(false); isaDialog.setUndecorated(true); Rectangle rect = view.getBounds(); if (isaExtendedMode) { rect.x += rect.width * 0.3; rect.y += rect.height * 0.3; rect.width *= 0.4; rect.height *= 0.5; } else { rect.x += rect.width * 0.2; rect.y += rect.height * 0.4; rect.width *= 0.6; rect.height *= 0.15; } isaDialog.setBounds(rect); // Hide mouse cursor if stated in the properties file if (properties.isMouseCursorHidden()) isaDialog.setCursor(InvisibleCursor.getCursor()); } else { GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); Rectangle rect = graphicsEnvironment.getMaximumWindowBounds(); if (isaExtendedMode) { rect.x = (int) (rect.width - (rect.width * 0.2)); rect.y = (int) (rect.height - (rect.height * 0.25)); rect.width *= 0.2; rect.height *= 0.25; } else { rect.x = (int) (rect.width - (rect.width * 0.3)); rect.y = (int) (rect.height - (rect.height * 0.1)); rect.width *= 0.3; rect.height *= 0.1; } isaDialog.setBounds(rect); isaDialog.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { isaValueChosen(0); } }); } isaDialog.setVisible(true); isaReqStartTime = System.currentTimeMillis(); clipNotify.playOnce(); } return true; }
From source file:org.pentaho.di.core.Const.java
public static String[] GetAvailableFontNames() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); Font[] fonts = ge.getAllFonts(); String[] FontName = new String[fonts.length]; for (int i = 0; i < fonts.length; i++) { FontName[i] = fonts[i].getFontName(); }/*from ww w .j ava 2 s .c o m*/ return FontName; }
From source file:edu.ku.brc.specify.Specify.java
/** * Restarts the app with a new or old database and user name and creates the core app UI. * @param window the login window// w w w . j a v a2 s . c o m * @param databaseNameArg the database name * @param userNameArg the user name * @param startOver tells the AppContext to start over * @param firstTime indicates this is the first time in the app and it should create all the UI for the core app */ public void restartApp(final Window window, final String databaseNameArg, final String userNameArg, final boolean startOver, final boolean firstTime) { log.debug("restartApp"); //$NON-NLS-1$ if (dbLoginPanel != null) { dbLoginPanel.getStatusBar().setText(getResourceString("Specify.INITIALIZING_APP")); //$NON-NLS-1$ } if (!firstTime) { checkAndSendStats(); } UIRegistry.dumpPaths(); try { AppPreferences.getLocalPrefs().flush(); } catch (BackingStoreException ex) { } AppPreferences.shutdownRemotePrefs(); AppPreferences.shutdownPrefs(); AppPreferences.setConnectedToDB(false); // Moved here because context needs to be set before loading prefs, we need to know the SpecifyUser // // NOTE: AppPreferences.startup(); is called inside setContext's implementation. // AppContextMgr.reset(); AppContextMgr.CONTEXT_STATUS status = AppContextMgr.getInstance().setContext(databaseNameArg, userNameArg, startOver, firstTime, !firstTime); if (status == AppContextMgr.CONTEXT_STATUS.OK) { // XXX Temporary Fix! SpecifyUser spUser = AppContextMgr.getInstance().getClassObject(SpecifyUser.class); if (spUser != null) { String dbPassword = spUser.getPassword(); if (StringUtils.isNotEmpty(dbPassword) && (!StringUtils.isAlphanumeric(dbPassword) || !UIHelper.isAllCaps(dbPassword) || dbPassword.length() < 25)) { String encryptedPassword = Encryption.encrypt(spUser.getPassword(), spUser.getPassword()); spUser.setPassword(encryptedPassword); DataProviderSessionIFace session = DataProviderFactory.getInstance().createSession(); try { session.beginTransaction(); session.saveOrUpdate(session.merge(spUser)); session.commit(); } catch (Exception ex) { session.rollback(); ex.printStackTrace(); } finally { session.close(); } } } } UsageTracker.setUserInfo(databaseNameArg, userNameArg); SpecifyAppPrefs.initialPrefs(); // Check Stats (this is mostly for the first time in. AppPreferences appPrefs = AppPreferences.getRemote(); Boolean canSendStats = appPrefs.getBoolean(sendStatsPrefName, null); //$NON-NLS-1$ Boolean canSendISAStats = appPrefs.getBoolean(sendISAStatsPrefName, null); //$NON-NLS-1$ // Make sure we have the proper defaults if (canSendStats == null) { canSendStats = true; appPrefs.putBoolean("usage_tracking.send_stats", canSendStats); //$NON-NLS-1$ } if (canSendISAStats == null) { canSendISAStats = true; appPrefs.putBoolean(sendISAStatsPrefName, canSendISAStats); //$NON-NLS-1$ } if (status == AppContextMgr.CONTEXT_STATUS.OK) { // XXX Get the current locale from prefs PREF if (AppContextMgr.getInstance().getClassObject(Discipline.class) == null) { return; } // "false" means that it should use any cached values it can find to automatically initialize itself if (firstTime) { GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment() .getDefaultScreenDevice().getDefaultConfiguration(); initialize(gc); topFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); UIRegistry.register(UIRegistry.FRAME, topFrame); } else { SubPaneMgr.getInstance().closeAll(); } preInitializePrefs(); initStartUpPanels(databaseNameArg, userNameArg); AppPrefsCache.addChangeListener("ui.formatting.scrdateformat", UIFieldFormatterMgr.getInstance()); if (changeCollectionMenuItem != null) { changeCollectionMenuItem.setEnabled( ((SpecifyAppContextMgr) AppContextMgr.getInstance()).getNumOfCollectionsForUser() > 1); } if (window != null) { window.setVisible(false); } // General DB Fixes independent of a release. if (!AppPreferences.getGlobalPrefs().getBoolean("CollectingEventsAndAttrsMaint1", false)) { // Temp Code to Fix issues with Release 6.0.9 and below SwingUtilities.invokeLater(new Runnable() { @Override public void run() { CollectingEventsAndAttrsMaint dbMaint = new CollectingEventsAndAttrsMaint(); dbMaint.performMaint(); } }); } /*if (!AppPreferences.getGlobalPrefs().getBoolean("FixAgentToDisciplinesV2", false)) { // Temp Code to Fix issues with Release 6.0.9 and below SwingUtilities.invokeLater(new Runnable() { @Override public void run() { FixDBAfterLogin fixer = new FixDBAfterLogin(); fixer.fixAgentToDisciplines(); } }); }*/ SwingUtilities.invokeLater(new Runnable() { @Override public void run() { performManualDBUdpatesAfterLogin(); } }); DataBuilder.mergeStandardGroups(AppContextMgr.getInstance().getClassObject(Collection.class)); } else if (status == AppContextMgr.CONTEXT_STATUS.Error) { if (dbLoginPanel != null) { dbLoginPanel.getWindow().setVisible(false); } if (AppContextMgr.getInstance().getClassObject(Collection.class) == null) { // TODO This is really bad because there is a Database Login with no Specify login JOptionPane.showMessageDialog(null, getResourceString("Specify.LOGIN_USER_MISMATCH"), //$NON-NLS-1$ getResourceString("Specify.LOGIN_USER_MISMATCH_TITLE"), //$NON-NLS-1$ JOptionPane.ERROR_MESSAGE); System.exit(0); } } CommandDispatcher.dispatch(new CommandAction("App", firstTime ? "StartUp" : "AppRestart", null)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ TaskMgr.requestInitalContext(); if (!UIRegistry.isRelease()) { DebugLoggerDialog dialog = new DebugLoggerDialog(null); dialog.configureLoggers(); } showApp(); if (dbLoginPanel != null) { dbLoginPanel.getWindow().setVisible(false); dbLoginPanel = null; } setDatabaseNameAndCollection(); }
From source file:org.simmi.GeneSetHead.java
License:asdf
public void initFSKeyListener(final Window window) { keylistener = new KeyListener() { @Override// w w w.j a v a 2s . c o m public void keyTyped(KeyEvent e) { } @Override public void keyReleased(KeyEvent e) { } @Override public void keyPressed(KeyEvent e) { GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); if (e.getKeyCode() == KeyEvent.VK_F11 && gd.isFullScreenSupported()) { Window w = gd.getFullScreenWindow(); if (w != null) { gd.setFullScreenWindow(null); } else { gd.setFullScreenWindow(window); } } } }; }
From source file:com.xilinx.ultrascale.gui.MainScreen_video.java
private void initVideoPlayer() { // jSlider1.setValue(0); //NativeLibrary.addSearchPath("libvlc", "/usr/local/lib/"); // sysout("initializing video player"); System.setProperty("jna.library.path", "/usr/local/lib/"); //JDesktopPane desktopPane; //desktopPane = new JDesktopPane(); videoFrame = new JFrame("Video Panel"); videoFrame.setSize(975, 300);//from w w w . j a v a 2 s. co m videoFrame.setBounds(0, 0, 975, 350); videoFrame.setResizable(false); videoFrame.setLocationRelativeTo(this); // videoFrame.getContentPane().setBackground(Color.BLACK); videoFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); //videoFrame.setContentPane(desktopPane); //videoFrame.add(desktopPane); videoFrame.setVisible(false); //videoFrame.setUndecorated(true); //videoFrame.setFocusableWindowState(false); //videoFrame.setEnabled(false); frame1 = new Window(videoFrame); frame1.setSize(480, 270); frame1.setBounds(videoFrame.getBounds().x + 5, videoFrame.getBounds().y + 50, 480, 270); //frame1.setUndecorated(true); //frame1.setAlwaysOnTop(true); //frame1.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); frame2 = new Window(videoFrame); frame2.setBounds(videoFrame.getBounds().x + 490, videoFrame.getBounds().y + 50, 480, 270); //frame2.setUndecorated(true); //frame2.setAlwaysOnTop(true); //frame2.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); //JInternalFrame jf1 = new JInternalFrame(); //jf1.setContentPane(frame1.getContentPane()); //JInternalFrame jf2 = new JInternalFrame(); //jf2.setContentPane(frame2.getContentPane()); //desktopPane.add(jf1); //desktopPane.add(jf2); screen = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); txMediaPlayer = create(frame1, 1); rxMediaPlayer = create(frame2, 0); txMediaPlayer.getVideoSurface().addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent event) { if (event.getClickCount() == 2) { if (screen.getFullScreenWindow() == null) { // System.out.println("TX fullscreen"); screen.setFullScreenWindow(frame1); txMediaPlayer.getMediaPlayer().setAspectRatio("16:10"); // System.out.println("aspect ratio: "+txMediaPlayer.getMediaPlayer().getAspectRatio() ); } else { // System.out.println("TX normalscreen"); screen.setFullScreenWindow(null); txMediaPlayer.getMediaPlayer().setAspectRatio(aspectRatio); // System.out.println("aspect ratio: "+txMediaPlayer.getMediaPlayer().getAspectRatio() ); } } } }); rxMediaPlayer.getVideoSurface().addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent event) { if (event.getClickCount() == 2) { if (screen.getFullScreenWindow() == null) { // System.out.println("RX fullscreen"); screen.setFullScreenWindow(frame2); rxMediaPlayer.getMediaPlayer().setAspectRatio("16:10"); // System.out.println("aspect ratio: "+rxMediaPlayer.getMediaPlayer().getAspectRatio() ); } else { // System.out.println("rX normalscreen"); screen.setFullScreenWindow(null); rxMediaPlayer.getMediaPlayer().setAspectRatio(aspectRatio); // System.out.println("aspect ratio: "+rxMediaPlayer.getMediaPlayer().getAspectRatio() ); } } } }); videoFrame.addComponentListener(new ComponentAdapter() { @Override public void componentMoved(ComponentEvent e) { super.componentMoved(e); //To change body of generated methods, choose Tools | Templates. frame1.setBounds(videoFrame.getBounds().x + 5, videoFrame.getBounds().y + 50, 480, 270); frame2.setBounds(videoFrame.getBounds().x + 490, videoFrame.getBounds().y + 50, 480, 270); //frame1.setBounds(videoFrame.getBounds().x + 50, videoFrame.getBounds().y + 50, 400, 400); //frame2.setBounds(videoFrame.getBounds().x + 500, videoFrame.getBounds().y + 50, 400, 400); } }); /*txCanvas = new Canvas(); txCanvas.setSize(videoWidth, VideoHeight);//(txVidPanel.getWidth(), txVidPanel.getHeight()); txVidPanel.add(txCanvas); txVidPanel.revalidate(); txVidPanel.repaint(); //Creation a media player : txMediaPlayerFactory = new MediaPlayerFactory(VLC_ARGS); txMediaPlayer = txMediaPlayerFactory.newEmbeddedMediaPlayer(); CanvasVideoSurface videoSurface = txMediaPlayerFactory.newVideoSurface(txCanvas); txMediaPlayer.setVideoSurface(videoSurface); // rx video rxCanvas = new Canvas(); rxCanvas.setSize(videoWidth, VideoHeight);//(rxVidPanel.getWidth(), rxVidPanel.getHeight()); rxVidPanel.add(rxCanvas); rxVidPanel.revalidate(); rxVidPanel.repaint(); //Creation a media player : rxMediaPlayerFactory = new MediaPlayerFactory(); rxMediaPlayer = rxMediaPlayerFactory.newEmbeddedMediaPlayer(); CanvasVideoSurface videorxSurface = rxMediaPlayerFactory.newVideoSurface(rxCanvas); rxMediaPlayer.setVideoSurface(videorxSurface); //frame to display video videoFrame = new JFrame("Video Panel"); videoFrame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent we) { // rxMediaPlayer.stop(); // txMediaPlayer.stop(); // videoFrame.hide(); } }); videoFrame.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); // videoFrame.add(videosPanel); videoFrame.setSize(videoWidth * 2, VideoHeight); videoFrame.setPreferredSize(new Dimension(videoWidth * 2, VideoHeight + 20)); videosPanel.setLocation(0, 0); videoFrame.setLayout(new BorderLayout()); videoFrame.add(videosPanel, BorderLayout.CENTER); //videoFrame.show();\ videoFrame.setResizable(false); videoFrame.pack(); sysout("video player initialized");*/ }