List of usage examples for java.awt GraphicsEnvironment getLocalGraphicsEnvironment
public static GraphicsEnvironment getLocalGraphicsEnvironment()
From source file:org.jas.dnd.Jdk6u10TransparencyManager.java
@Override public GraphicsConfiguration getTranslucencyCapableGC() { GraphicsEnvironment localGraphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice defaultScreenDevice = localGraphicsEnvironment.getDefaultScreenDevice(); GraphicsConfiguration translucencyCapableGC = defaultScreenDevice.getDefaultConfiguration(); if (!isTranslucencyCapable(translucencyCapableGC)) { translucencyCapableGC = null;/* w w w.ja va 2 s . c o m*/ log.info("Default graphics configuration does not support translucency"); GraphicsEnvironment env = localGraphicsEnvironment; GraphicsDevice[] devices = env.getScreenDevices(); for (int i = 0; i < devices.length && translucencyCapableGC == null; i++) { GraphicsConfiguration[] configs = devices[i].getConfigurations(); for (int j = 0; j < configs.length && translucencyCapableGC == null; j++) { if (isTranslucencyCapable(configs[j])) { translucencyCapableGC = configs[j]; } } } } if (translucencyCapableGC == null) { log.warn("Translucency capable graphics configuration not found"); } return translucencyCapableGC; }
From source file:com.seleniumtests.driver.CustomEventFiringWebDriver.java
/** * Returns the rectangle of all screens on the system * @return/* ww w.j av a 2 s .co m*/ */ private static Rectangle getScreensRectangle() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); Rectangle screenRect = new Rectangle(0, 0, 0, 0); for (GraphicsDevice gd : ge.getScreenDevices()) { screenRect = screenRect.union(gd.getDefaultConfiguration().getBounds()); } return screenRect; }
From source file:net.sf.maltcms.chromaui.charts.FastHeatMapPlot.java
/** * * @return//from w w w. j av a 2 s . co m */ public GraphicsConfiguration getGraphicsConfiguration() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gs = ge.getDefaultScreenDevice(); return gs.getDefaultConfiguration(); }
From source file:MixedTest.java
protected Canvas3D createCanvas3D() { GraphicsConfigTemplate3D gc3D = new GraphicsConfigTemplate3D(); gc3D.setSceneAntialiasing(GraphicsConfigTemplate.PREFERRED); GraphicsDevice gd[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices(); Canvas3D c3d = new Canvas3D(gd[0].getBestConfiguration(gc3D)); c3d.setSize(getCanvas3dWidth(c3d), getCanvas3dHeight(c3d)); return c3d;// www.j a v a2s . c om }
From source file:pl.edu.icm.visnow.geometries.viewer3d.Display3DPanel.java
/** * Creates new form Display3DPanel/*ww w. j a v a 2 s .c o m*/ */ public Display3DPanel() { initComponents(); effectiveHeight = getHeight(); effectiveWidth = getWidth(); logger.debug("creating Display3DPanel"); this.setMinimumSize(new Dimension(200, 200)); this.setPreferredSize(new Dimension(800, 600)); GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D(); template.setStereo(GraphicsConfigTemplate3D.PREFERRED); // Get the GraphicsConfiguration that best fits our needs. logger.debug("getting config"); GraphicsConfiguration gcfg = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice() .getBestConfiguration(template); logger.debug("creating canvas"); canvas = new Canvas3D(gcfg) { @Override public void postRender() { vGraphics = super.getGraphics2D(); vGraphics.setFont(new Font("sans-serif", Font.PLAIN, 10)); vGraphics.setColor(Color.YELLOW); locToWin.update(); fireProjectionChanged(new ProjectionEvent(this, locToWin)); draw2D(vGraphics, locToWin, effectiveWidth, effectiveHeight); vGraphics.flush(false); } @Override public void postSwap() { if (postRenderSilent || waitForExternalTrigger) { return; } if (!(storingJPEG || storingPNG || storingFrames)) { fireFrameRendered(); } if (storingFrames) { if (storingJPEG) { writeImage(new File(controlsPanel.getMovieCreationPanel().getCurrentFrameFileName())); } else { writeYUV(controlsPanel.getMovieCreationPanel().getGenericFrameFileName()); } } } }; canvas.setStereoEnable(false); add("Center", canvas); pickObject = new PickObject(canvas, objScene, rootObject.getGeometryObj(), objRotate); canvas.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { if (evt.isShiftDown()) { // if (e.isShiftDown()) // System.out.println(""+e.getX() + " " + e.getY()); } if (evt.getButton() == MouseEvent.BUTTON1) { if (evt.getClickCount() > 1) { reset(); } else if (pickObject.consumeEmulated3DPick(evt.getX(), evt.getY())) { /* Nothing must be done - everything was done in consumeEmulated3DPick() */ } else { pickObject.consume2DSelectModule(evt.getX(), evt.getY()); } rootObject.firePickChanged(evt, locToWin); } if (evt.getButton() == MouseEvent.BUTTON3) { if (getControlsFrame() != null) { getControlsFrame().setBounds(evt.getXOnScreen() - 130, evt.getYOnScreen(), 240, 500); getControlsFrame().setVisible(true); } else if (getTransientControlsFrame() != null) { getTransientControlsFrame().setBounds(evt.getXOnScreen() - 130, evt.getYOnScreen(), 240, 500); getTransientControlsFrame().setVisible(true); } else if (application != null) { application.getFrames().getGuiPanel().selectModule(name); } } if (evt.getButton() == MouseEvent.BUTTON2) { reset(); } } @Override public void mouseEntered(java.awt.event.MouseEvent evt) { mouseOn = true; mouseObserverThread = new Thread(new MouseObserver()); mouseObserverThread.start(); } @Override public void mouseExited(java.awt.event.MouseEvent evt) { mouseObserverThread = null; mouseOn = false; } }); canvas.addMouseMotionListener(new java.awt.event.MouseMotionListener() { @Override public void mouseDragged(MouseEvent e) { // if (e.isShiftDown()) // System.out.println(""+e.getX() + " " + e.getY()); } @Override public void mouseMoved(MouseEvent e) { } }); canvas.addMouseWheelListener(new java.awt.event.MouseWheelListener() { @Override public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt) { rescaleFromMouseWheel(evt); } }); canvas.addKeyListener(new java.awt.event.KeyAdapter() { @Override public void keyTyped(KeyEvent evt) { formKeyTyped(evt); } @Override public void keyPressed(KeyEvent evt) { formKeyPressed(evt); } @Override public void keyReleased(KeyEvent evt) { formKeyReleased(evt); } }); ToolTipManager.sharedInstance().setLightWeightPopupEnabled(true); universe = new SimpleUniverse(canvas); view = canvas.getView(); view.setProjectionPolicy(View.PERSPECTIVE_PROJECTION); view.setTransparencySortingPolicy(View.TRANSPARENCY_SORT_GEOMETRY); objScene.addChild(rootObject.getGeometryObj()); rootObject.setRenderingWindow(this); rootObject.getGeometryObj().setUserData(null); bg.setCapability(Background.ALLOW_COLOR_WRITE); bg.setCapability(Background.ALLOW_COLOR_READ); bg.setCapability(Background.ALLOW_IMAGE_WRITE); bg.setCapability(Background.ALLOW_IMAGE_READ); bg.setCapability(Background.ALLOW_IMAGE_SCALE_MODE_READ); bg.setCapability(Background.ALLOW_IMAGE_SCALE_MODE_WRITE); bg.setImageScaleMode(Background.SCALE_FIT_ALL); bg.setApplicationBounds(bounds); myFog.setCapability(LinearFog.ALLOW_DISTANCE_WRITE); myFog.setCapability(LinearFog.ALLOW_COLOR_WRITE); myFog.setInfluencingBounds(bounds); myFog.setFrontDistance(1.); myFog.setBackDistance(4.); myFogGroup.addChild(myFog); mouseRotate.setTransformGroup(objRotate); mouseRotate.setSchedulingBounds(bounds); mouseRotate.setFactor(mouseRotateSensitivity); mouseTranslate.setTransformGroup(objRotate); mouseTranslate.setSchedulingBounds(bounds); mouseTranslate.setFactor(mouseTranslateSensitivity); mouseZoom.setTransformGroup(objRotate); mouseZoom.setSchedulingBounds(bounds); windowRootObject.addChild(mouseRotate); windowRootObject.addChild(mouseTranslate); windowRootObject.addChild(mouseZoom); objTranslate.addChild(objScene); objScale.addChild(objTranslate); objRotate.addChild(bg); objRotate.addChild(objScale); windowRootObject.addChild(objRotate); ambientLight = new EditableAmbientLight(new Color3f(.25f, .25f, .25f), bounds, "ambient light", true); windowRootObject.addChild(ambientLight.getLight()); directionalLights.add(new EditableDirectionalLight(new Color3f(0.4f, 0.4f, 0.4f), new Vector3f(.1f, .08f, -.5f), bounds, "light 1", true, true)); directionalLights.add(new EditableDirectionalLight(new Color3f(0.2f, 0.15f, 0.1f), new Vector3f(-1.f, -0.4f, -.5f), bounds, "light 2", true, false)); directionalLights.add(new EditableDirectionalLight(new Color3f(0.1f, 0.1f, 0.15f), new Vector3f(0.f, 0.6f, -1.f), bounds, "light 3", true, false)); directionalLights.add(new EditableDirectionalLight(new Color3f(0.1f, 0.1f, 0.15f), new Vector3f(0.f, -0.6f, -1.f), bounds, "light 3", false, false)); for (int i = 0; i < directionalLights.size(); i++) { TransformGroup lightTransform = new TransformGroup(); lightTransform.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); lightTransform.setName("light" + i + "Transform"); directionalLightTransforms.add(lightTransform); OpenBranchGroup lightGroup = new OpenBranchGroup(); EditableDirectionalLight light = directionalLights.get(i); lightGroup.addChild(light.getLight()); lightGroup.addChild(light.getBackLight()); lightTransform.addChild(lightGroup); windowRootObject.addChild(lightTransform); } modelClip.setCapability(ModelClip.ALLOW_ENABLE_READ); modelClip.setCapability(ModelClip.ALLOW_ENABLE_WRITE); modelClip.setCapability(ModelClip.ALLOW_PLANE_READ); modelClip.setCapability(ModelClip.ALLOW_PLANE_WRITE); modelClip.setInfluencingBounds(bounds); objScene.addChild(modelClip); pointLights .add(new EditablePointLight(new Color3f(0.4f, 0.4f, 0.4f), bounds, null, null, "light 1", false)); pointLights .add(new EditablePointLight(new Color3f(0.4f, 0.4f, 0.4f), bounds, null, null, "light 1", false)); pointLights .add(new EditablePointLight(new Color3f(0.4f, 0.4f, 0.4f), bounds, null, null, "light 1", false)); for (int i = 0; i < pointLights.size(); i++) { TransformGroup lightTransform = new TransformGroup(); lightTransform.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); lightTransform.setName("light" + i + "Transform"); pointLightTransforms.add(lightTransform); OpenBranchGroup lightGroup = new OpenBranchGroup(); EditablePointLight light = pointLights.get(i); lightGroup.addChild(light.getLight()); lightTransform.addChild(lightGroup); windowRootObject.addChild(lightTransform); } alternateTransformObj.addChild(alternateRootObj); alternateTransormBranch.addChild(alternateTransformObj); windowRootObject.addChild(alternateTransormBranch); universe.getViewingPlatform().setNominalViewingTransform(); universe.addBranchGraph(windowRootObject); view.getPhysicalBody().getLeftEyePosition(defaultLeftEye); view.getPhysicalBody().getRightEyePosition(defaultRightEye); controlsFrame = new Display3DControlsFrame(this); controlsPanel = controlsFrame.getControlPanel(); universe.getViewingPlatform().getViewPlatformTransform().getTransform(initialCameraTransform); objReper.addChild(reper.getGeometryObj()); positionedReper.addChild(objReper); positionedReper.setTransform( new Transform3D(new float[] { .15f, 0, 0, -.8f, 0, .15f, 0, .76f, 0, 0, .15f, 0, 0, 0, 0, 1 })); reperGroup.addChild(positionedReper); OpenBranchGroup reperLightGroup = new OpenBranchGroup(); reperLightGroup.addChild(new AmbientLight(new Color3f(.6f, .6f, .6f))); reperLightGroup.addChild(new EditableDirectionalLight(new Color3f(0.4f, 0.4f, 0.4f), new Vector3f(.1f, .08f, -1f), bounds, "light 1", true, true).getLight()); reperGroup.addChild(reperLightGroup); universe.addBranchGraph(reperGroup); locToWin = new LocalToWindow(rootObject.getGeometryObj(), canvas); /** * The line below binds reper with scene rotation when using any method that calls * objRotate.setTransform(), so: keyboard (explicitly calling), mouse (Java3D is calling * setTransform) and some custom ways (e.g. in haptic pointer) */ objRotate.addTransformListener(objReper); // mouseRotate.setupCallback(objReper); // it is not needed, because Java3D calls objRotate.setTranform which fires callback to the reper }
From source file:org.geopublishing.atlasViewer.AtlasConfig.java
/** * Registers the Fonts in {@link #getFonts()} to the system, if they are not * registered yet.// w w w . j a va 2 s .c o m */ public void registerFonts() { for (Font f : getFonts()) { // if (Font.decode(f.getName()) == null) { LOGGER.debug("Registering user font " + f); GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(f); org.geotools.renderer.style.FontCache fc = org.geotools.renderer.style.FontCache.getDefaultInstance(); fc.registerFont(f); // } } }
From source file:com.floreantpos.config.ui.TerminalConfigurationView.java
private void initializeFontConfig() { GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment(); Font[] fonts = e.getAllFonts(); // Get the fonts DefaultComboBoxModel<String> model = (DefaultComboBoxModel<String>) cbFonts.getModel(); model.addElement("<select>"); //$NON-NLS-1$ for (Font f : fonts) { model.addElement(f.getFontName()); }/*from www . j a v a2 s .co m*/ String uiDefaultFont = TerminalConfig.getUiDefaultFont(); if (StringUtils.isNotEmpty(uiDefaultFont)) { cbFonts.setSelectedItem(uiDefaultFont); } }
From source file:tvbrowser.ui.mainframe.MainFrame.java
/** * Switch the fullscreen mode of TV-Browser *///from w ww . j a va 2 s .c o m public void switchFullscreenMode() { dispose(); SwingUtilities.invokeLater(new Runnable() { public void run() { GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); if (isFullScreenMode()) { // switch back from fullscreen device.setFullScreenWindow(null); setUndecorated(false); setBounds(mXPos, mYPos, mWidth, mHeight); if (mMenuBar != null) { mMenuBar.setFullscreenItemChecked(false); mMenuBar.setVisible(true); } if (mToolBarPanel != null) { mToolBarPanel.setVisible(Settings.propIsToolbarVisible.getBoolean()); } if (mStatusBar != null) { mStatusBar.setVisible(Settings.propIsStatusbarVisible.getBoolean()); } if (mChannelChooser != null) { mChannelChooser.setVisible(Settings.propShowChannels.getBoolean()); } if (mFinderPanel != null) { mFinderPanel.getComponent().setVisible(Settings.propShowDatelist.getBoolean()); } setVisible(true); setShowPluginOverview(Settings.propShowPluginView.getBoolean(), false); setShowTimeButtons(Settings.propShowTimeButtons.getBoolean(), false); setShowDatelist(Settings.propShowDatelist.getBoolean(), false); setShowChannellist(Settings.propShowChannels.getBoolean(), false); } else { // switch into fullscreen mXPos = getX(); mYPos = getY(); mWidth = getWidth(); mHeight = getHeight(); setShowPluginOverview(false, false); setShowTimeButtons(false, false); setShowDatelist(false, false); setShowChannellist(false, false); if (mStatusBar != null) { mMenuBar.setFullscreenItemChecked(true); mStatusBar.setVisible(false); } if (mChannelChooser != null) { mChannelChooser.setVisible(false); } if (mMenuBar != null) { mMenuBar.setVisible(false); } if (mToolBarPanel != null) { mToolBarPanel.setVisible(false); } if (mFinderPanel != null) { mFinderPanel.getComponent().setVisible(false); } setUndecorated(true); final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); if (device.isFullScreenSupported() && OperatingSystem.isMacOs()) { device.setFullScreenWindow(MainFrame.getInstance()); } else { setLocation(0, 0); setSize(screen); } setVisible(true); mProgramTableScrollPane.requestFocusInWindow(); new Thread("Fullscreen border detection") { public void run() { setPriority(Thread.MIN_PRIORITY); while (isFullScreenMode()) { final Point p = MouseInfo.getPointerInfo().getLocation(); SwingUtilities.convertPointFromScreen(p, MainFrame.this); if (isActive()) { // mouse pointer is at top if (p.y <= 10) { if (mToolBarPanel != null && mToolBar.getToolbarLocation() .compareTo(BorderLayout.NORTH) == 0) { if (!mToolBarPanel.isVisible()) { mToolBarPanel .setVisible(Settings.propIsToolbarVisible.getBoolean()); } } if (p.y <= 0) { mMenuBar.setVisible(true); } } else if (p.y > (mMenuBar != null && mMenuBar.isVisible() ? mMenuBar.getHeight() : 0) + (Settings.propIsToolbarVisible.getBoolean() ? mToolBarPanel.getHeight() : 0)) { if (mMenuBar.isVisible()) { mMenuBar.setVisible(!isFullScreenMode()); } if (mToolBarPanel != null && mToolBarPanel.isVisible() && mToolBar .getToolbarLocation().compareTo(BorderLayout.NORTH) == 0) { mToolBarPanel.setVisible(!isFullScreenMode()); } } // mouse pointer is at the bottom if (p.y >= screen.height - 1) { if (mStatusBar != null && !mStatusBar.isVisible()) { mStatusBar.setVisible(Settings.propIsStatusbarVisible.getBoolean()); } } else if (mStatusBar != null && mStatusBar.isVisible() && p.y < screen.height - mStatusBar.getHeight()) { mStatusBar.setVisible(!isFullScreenMode()); } // mouse pointer is on the left side if (p.x <= 5) { if (p.x == 0 && mToolBarPanel != null && mToolBar.getToolbarLocation() .compareTo(BorderLayout.WEST) == 0) { if (!mToolBarPanel.isVisible()) { mToolBarPanel .setVisible(Settings.propIsToolbarVisible.getBoolean()); } } if (Settings.propPluginViewIsLeft.getBoolean()) { if (Settings.propShowPluginView.getBoolean()) { SwingUtilities.invokeLater(new Runnable() { public void run() { setShowPluginOverview(true, false); } }); } } else { checkIfToShowTimeDateChannelList(); } } else { int toolBarWidth = (mToolBarPanel != null && mToolBarPanel.isVisible() && mToolBar.getToolbarLocation().compareTo(BorderLayout.WEST) == 0) ? mToolBarPanel.getWidth() : 0; if (p.x > toolBarWidth && toolBarWidth != 0) { mToolBarPanel.setVisible(!isFullScreenMode()); } if (Settings.propPluginViewIsLeft.getBoolean()) { if (Settings.propShowPluginView.getBoolean() && mPluginView != null && mPluginView.isVisible() && p.x > mPluginView.getWidth() + toolBarWidth + 25) { SwingUtilities.invokeLater(new Runnable() { public void run() { setShowPluginOverview(!isFullScreenMode(), false); } }); } } else if (Settings.propShowChannels.getBoolean() || Settings.propShowDatelist.getBoolean() || Settings.propShowTimeButtons.getBoolean()) { SwingUtilities.invokeLater(new Runnable() { public void run() { if (mChannelChooser != null && mChannelChooser.isVisible() && p.x > mChannelChooser.getWidth()) { setShowChannellist(!isFullScreenMode(), false); } if (mFinderPanel != null && mFinderPanel.getComponent().isVisible() && p.x > mFinderPanel.getComponent().getWidth()) { setShowDatelist(!isFullScreenMode(), false); } if (mTimeChooserPanel != null && mTimeChooserPanel.isVisible() && p.x > mTimeChooserPanel.getWidth()) { setShowTimeButtons(!isFullScreenMode(), false); } } }); } } // mouse pointer is on the right side if (p.x >= screen.width - 1) { if (!Settings.propPluginViewIsLeft.getBoolean()) { if (Settings.propShowPluginView.getBoolean()) { SwingUtilities.invokeLater(new Runnable() { public void run() { setShowPluginOverview(true, false); } }); } } else { checkIfToShowTimeDateChannelList(); } } else { if (!Settings.propPluginViewIsLeft.getBoolean()) { if (Settings.propShowPluginView.getBoolean() && mPluginView != null && mPluginView.isVisible() && p.x < screen.width - mPluginView.getWidth()) { SwingUtilities.invokeLater(new Runnable() { public void run() { setShowPluginOverview(!isFullScreenMode(), false); } }); } } else if (Settings.propShowChannels.getBoolean() || Settings.propShowDatelist.getBoolean() || Settings.propShowTimeButtons.getBoolean()) { SwingUtilities.invokeLater(new Runnable() { public void run() { if (mChannelChooser != null && mChannelChooser.isVisible() && p.x < screen.width - mChannelChooser.getWidth()) { setShowChannellist(!isFullScreenMode(), false); } if (mFinderPanel != null && mFinderPanel.getComponent().isVisible() && p.x < screen.width - mFinderPanel.getComponent().getWidth()) { setShowDatelist(!isFullScreenMode(), false); } if (mTimeChooserPanel != null && mTimeChooserPanel.isVisible() && p.x < screen.width - mTimeChooserPanel.getWidth()) { setShowTimeButtons(!isFullScreenMode(), false); } } }); } } } try { Thread.sleep(200); } catch (Exception e) { } } } }.start(); } } }); }
From source file:coolmap.canvas.datarenderer.renderer.impl.NumberToColor.java
private void updateGradient() { // System.out.println("Gradient updated.."); _gradient.reset();/*from w ww .j a v a2 s . c om*/ for (int i = 0; i < editor.getNumPoints(); i++) { Color c = editor.getColorAt(i); float p = editor.getColorPositionAt(i); if (c == null || p < 0 || p > 1) { continue; } _gradient.addColor(c, p); } _gradientColors = _gradient.generateGradient(CImageGradient.InterType.Linear); int width = DEFAULT_LEGEND_WIDTH; int height = DEFAULT_LEGENT_HEIGHT; legend = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice() .getDefaultConfiguration().createCompatibleImage(width, height, Transparency.TRANSLUCENT); Graphics2D g = (Graphics2D) legend.createGraphics(); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); LinearGradientPaint paint = editor.getLinearGradientPaint(0, 0, width, 0); g.setPaint(paint); g.fillRoundRect(0, 0, width, height - 12, 5, 5); g.setColor(UI.colorBlack2); g.setFont(UI.fontMono.deriveFont(10f)); DecimalFormat format = new DecimalFormat("#.##"); g.drawString(format.format(_minValue), 2, 23); String maxString = format.format(_maxValue); int swidth = g.getFontMetrics().stringWidth(maxString); g.drawString(maxString, width - 2 - swidth, 23); g.dispose(); // System.out.println("===Gradient updated===" + _gradientColors + " " + this); }
From source file:co.com.soinsoftware.hotelero.view.JFRoom.java
private void setMaximized() { final GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); this.setMaximizedBounds(env.getMaximumWindowBounds()); this.setExtendedState(this.getExtendedState() | JFrame.MAXIMIZED_BOTH); }