/** * Tests if the given {@code GraphicsEnvironment} supports accelleration * * @param pEnv the environment * @return {@code true} if the {@code GraphicsEnvironment} supports * acceleration */ private static boolean supportsAcceleration(GraphicsEnvironment pEnv) { try { // Acceleration only supported in non-headless environments, on 1.4+ VMs return /*VM_SUPPORTS_ACCELERATION &&*/ !pEnv.isHeadlessInstance(); } catch (LinkageError ignore) { // Means we are not in a 1.4+ VM, so skip testing for headless again VM_SUPPORTS_ACCELERATION = false; } // If the invocation fails, assume no accelleration is possible return false; }
private static GraphicsConfiguration getDefaultGraphicsConfiguration() { try { GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); if (!env.isHeadlessInstance()) { return env.getDefaultScreenDevice().getDefaultConfiguration(); } } catch (LinkageError e) { // Means we are not in a 1.4+ VM, so skip testing for headless again VM_SUPPORTS_ACCELERATION = false; } return null; }
/** * Tests if the given {@code GraphicsEnvironment} supports accelleration * * @param pEnv the environment * @return {@code true} if the {@code GraphicsEnvironment} supports * acceleration */ private static boolean supportsAcceleration(GraphicsEnvironment pEnv) { try { // Acceleration only supported in non-headless environments, on 1.4+ VMs return /*VM_SUPPORTS_ACCELERATION &&*/ !pEnv.isHeadlessInstance(); } catch (LinkageError ignore) { // Means we are not in a 1.4+ VM, so skip testing for headless again VM_SUPPORTS_ACCELERATION = false; } // If the invocation fails, assume no accelleration is possible return false; }
/** * Tests if the given {@code GraphicsEnvironment} supports accelleration * * @param pEnv the environment * @return {@code true} if the {@code GraphicsEnvironment} supports * acceleration */ private static boolean supportsAcceleration(GraphicsEnvironment pEnv) { try { // Acceleration only supported in non-headless environments, on 1.4+ VMs return /*VM_SUPPORTS_ACCELERATION &&*/ !pEnv.isHeadlessInstance(); } catch (LinkageError ignore) { // Means we are not in a 1.4+ VM, so skip testing for headless again VM_SUPPORTS_ACCELERATION = false; } // If the invocation fails, assume no accelleration is possible return false; }
public static boolean isHeadless() { return GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance(); } }
private static GraphicsConfiguration getDefaultGraphicsConfiguration() { try { GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); if (!env.isHeadlessInstance()) { return env.getDefaultScreenDevice().getDefaultConfiguration(); } } catch (LinkageError e) { // Means we are not in a 1.4+ VM, so skip testing for headless again VM_SUPPORTS_ACCELERATION = false; } return null; }
private static GraphicsConfiguration getDefaultGraphicsConfiguration() { try { GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); if (!env.isHeadlessInstance()) { return env.getDefaultScreenDevice().getDefaultConfiguration(); } } catch (LinkageError e) { // Means we are not in a 1.4+ VM, so skip testing for headless again VM_SUPPORTS_ACCELERATION = false; } return null; }
private static Rectangle getWindowSafeBoundsFromGraphEnv() { // https://stackoverflow.com/questions/32555329/java-get-maximized-state-window-size GraphicsEnvironment gc = GraphicsEnvironment.getLocalGraphicsEnvironment(); if (gc.isHeadlessInstance()) return null; GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); Rectangle bounds = gd.getDefaultConfiguration().getBounds(); Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gd.getDefaultConfiguration()); int x = bounds.x + insets.left; int y = bounds.y + insets.top; int width = bounds.width - (insets.left + insets.right); int height = bounds.height - (insets.top + insets.bottom); log.warn("Get screen size from grahics environment."); return new Rectangle(x, y, width, height); }
/** * Determines if the specified rectangle is (at least partially) visible on * a screen. * @param rectangle The rectangle. * @return true if the specified rectangle is partially or fully visible on some screen, * otherwise false. */ public static boolean isVisibleOnScreen(@Nonnull Rectangle rectangle) { GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); if(graphicsEnvironment.isHeadlessInstance()) { return false; } GraphicsDevice[] screenDevices = graphicsEnvironment.getScreenDevices(); return Stream .of(screenDevices) .map(screenDevice -> screenDevice.getDefaultConfiguration().getBounds()) .anyMatch(screenBounds -> screenBounds.intersects(rectangle)); }
if (ge.isHeadlessInstance()) { bimage = new BufferedImage(width, height, biType); } else {
@BeforeClass public static void internalSetupSpec() { assumeFalse( "Cannot run JavaFX in headless environment", GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance() ); }
if (ge.isHeadlessInstance()) { bimage = new BufferedImage(width, height, biType); } else {
if (ge.isHeadlessInstance()) { bimage = new BufferedImage(width, height, biType); } else {
public void run(final String arg) { final String options = Macro.getOptions(); System.out.println("Got options " + options); if (GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance()) { runHeadless(options); } else { runWithUI(arg); } } }
protected AbstractTreeTransferHandler(DNDTree tree, int action, boolean drawIcon) { this.tree = tree; drawImage = drawIcon; if (!GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance()) { dragSource = new DragSource(); dgr = dragSource.createDefaultDragGestureRecognizer(tree, action, this); dropTarget = new DropTarget(tree, action, this); } else { dragSource = null; dgr = null; dropTarget = null; } }
/** * If called on a headless runtime, the test will halt and be ignored. */ public static void assumeDisplayPresent() { try { assumeFalse( GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance() ); String display = System.getenv( "DISPLAY" ); assumeThat( display, is( notNullValue() ) ); assumeTrue( display.length() > 0 ); } catch( UnsatisfiedLinkError e ) { // assuming that this is caused due to missing video subsystem, or similar assumeNoException( "Grahics system is missing?", e ); } }
/** * If called on a headless runtime, the test will halt and be ignored. */ public static void assumeDisplayPresent() { try { assumeFalse( GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance() ); String display = System.getenv( "DISPLAY" ); assumeThat( display, is( notNullValue() ) ); assumeTrue( display.length() > 0 ); } catch( UnsatisfiedLinkError e ) { // assuming that this is caused due to missing video subsystem, or similar assumeNoException( "Grahics system is missing?", e ); } }
/** * If called on a headless runtime, the test will halt and be ignored. */ public static void assumeDisplayPresent() { try { assumeFalse( GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance() ); String display = System.getenv( "DISPLAY" ); assumeThat( display, is( notNullValue() ) ); assumeTrue( display.length() > 0 ); } catch( UnsatisfiedLinkError e ) { // assuming that this is caused due to missing video subsystem, or similar assumeNoException( "Grahics system is missing?", e ); } }
/** Gets information about all the displays connected to this machine. */ @NonNull private static Iterable<? extends DisplayDetails> getDisplayDetails() { List<DisplayDetails> displays = new ArrayList<>(); GraphicsEnvironment graphics = HostData.getGraphicsEnvironment(); if (!graphics.isHeadlessInstance()) { for (GraphicsDevice device : graphics.getScreenDevices()) { Rectangle bounds = device.getDefaultConfiguration().getBounds(); displays.add( DisplayDetails.newBuilder() .setHeight(bounds.height) .setWidth(bounds.width) .build()); } } return displays; }
public VectorGraphics2D() { this.commands = new MutableCommandSequence(); emit(new CreateCommand(this)); GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice graphicsDevice = null; if (!graphicsEnvironment.isHeadlessInstance()) { graphicsDevice = graphicsEnvironment.getDefaultScreenDevice(); deviceConfig = graphicsDevice.getDefaultConfiguration(); } else { deviceConfig = null; } fontRenderContext = new FontRenderContext(null, false, true); state = new GraphicsState(); // Ensure that document state matches default state of Graphics2D // TODO: Default graphics state does not need to be printed in the document. // Use filters in the appropriate documents setColor(Color.BLACK); // Required for EPS, PDF, and SVG setStroke(new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10f, null, 0f)); // EPS and PDF }