JOGL v2.6.0-rc-20250706
JOGL, High-Performance Graphics Binding for Java™ (public API).
AWTGraphicsScreen.java
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved.
3 * Copyright (c) 2010 JogAmp Community. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * - Redistribution of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * - Redistribution in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * Neither the name of Sun Microsystems, Inc. or the names of
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * This software is provided "AS IS," without a warranty of any kind. ALL
21 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
22 * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
23 * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
24 * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
25 * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
26 * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
27 * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
28 * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
29 * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
30 * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
31 * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
32 *
33 * You acknowledge that this software is not designed or intended for use
34 * in the design, construction, operation or maintenance of any nuclear
35 * facility.
36 *
37 * Sun gratefully acknowledges that this software was originally authored
38 * and developed by Kenneth Bradley Russell and Christopher John Kline.
39 */
40
41package com.jogamp.nativewindow.awt;
42
43import java.awt.GraphicsDevice;
44import java.awt.GraphicsEnvironment;
45import com.jogamp.nativewindow.*;
46
47
48
49/** A wrapper for an AWT GraphicsDevice (screen) allowing it to be
50 handled in a toolkit-independent manner. */
51
52public class AWTGraphicsScreen extends DefaultGraphicsScreen implements Cloneable {
53
54 public AWTGraphicsScreen(final AWTGraphicsDevice device) {
55 super(device, findScreenIndex(device.getGraphicsDevice()));
56 }
57
58 public static GraphicsDevice getScreenDevice(final int index) {
59 if(index<0) return null;
60 final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
61 final GraphicsDevice[] gs = ge.getScreenDevices();
62 if(index<gs.length) {
63 return gs[index];
64 }
65 return null;
66 }
67
68 public static int findScreenIndex(final GraphicsDevice awtDevice) {
69 if(null==awtDevice) return -1;
70 final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
71 final GraphicsDevice[] gs = ge.getScreenDevices();
72 for (int j = 0; j < gs.length; j++) {
73 if(gs[j] == awtDevice) return j;
74 }
75 return -1;
76 }
77
78 public static AbstractGraphicsScreen createScreenDevice(final GraphicsDevice awtDevice, final int unitID) {
79 return new AWTGraphicsScreen(new AWTGraphicsDevice(awtDevice, unitID));
80 }
81
82 public static AbstractGraphicsScreen createScreenDevice(final int index, final int unitID) {
83 return createScreenDevice(getScreenDevice(index), unitID);
84 }
85
88 }
89
90 @Override
91 public Object clone() {
92 return super.clone();
93 }
94}
95
A wrapper for an AWT GraphicsDevice allowing it to be handled in a toolkit-independent manner.
A wrapper for an AWT GraphicsDevice (screen) allowing it to be handled in a toolkit-independent manne...
static AbstractGraphicsScreen createScreenDevice(final int index, final int unitID)
static int findScreenIndex(final GraphicsDevice awtDevice)
static AbstractGraphicsScreen createDefault()
static GraphicsDevice getScreenDevice(final int index)
AWTGraphicsScreen(final AWTGraphicsDevice device)
static AbstractGraphicsScreen createScreenDevice(final GraphicsDevice awtDevice, final int unitID)
A interface describing a graphics screen in a toolkit-independent manner.