本文整理匯總了Java中java.awt.GraphicsConfiguration類的典型用法代碼示例。如果您正苦於以下問題:Java GraphicsConfiguration類的具體用法?Java GraphicsConfiguration怎麽用?Java GraphicsConfiguration使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
GraphicsConfiguration類屬於java.awt包,在下文中一共展示了GraphicsConfiguration類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getCurrentGraphicsConfiguration
import java.awt.GraphicsConfiguration; //導入依賴的package包/類
/**
* Finds out the monitor where the user currently has the input focus.
* This method is usually used to help the client code to figure out on
* which monitor it should place newly created windows/frames/dialogs.
*
* @return the GraphicsConfiguration of the monitor which currently has the
* input focus
*/
private static GraphicsConfiguration getCurrentGraphicsConfiguration() {
Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
if (focusOwner != null) {
Window w = SwingUtilities.getWindowAncestor(focusOwner);
if (w != null) {
return w.getGraphicsConfiguration();
} else {
//#217737 - try to find the main window which could be placed in secondary screen
for( Frame f : Frame.getFrames() ) {
if( "NbMainWindow".equals(f.getName())) { //NOI18N
return f.getGraphicsConfiguration();
}
}
}
}
return GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
}
示例2: drawBackingStoreImage
import java.awt.GraphicsConfiguration; //導入依賴的package包/類
private void drawBackingStoreImage(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
GraphicsConfiguration gc = g2d.getDeviceConfiguration();
if (vImg == null ||
vImg.validate(gc) == VolatileImage.IMAGE_INCOMPATIBLE) {
/* Create a new volatile image */
vImg = createVolatileImage(PANEL_WIDTH, PANEL_HEIGHT / 3);
}
Graphics vImgGraphics = vImg.createGraphics();
vImgGraphics.setColor(Color.WHITE);
vImgGraphics.fillRect(0, 0, PANEL_WIDTH, PANEL_HEIGHT / 3);
drawInfo(vImgGraphics,
PANEL_X,
PANEL_Y,
"Backbuffer",
Color.MAGENTA);
g.drawImage(vImg, 0, PANEL_Y * 2, this);
}
示例3: main
import java.awt.GraphicsConfiguration; //導入依賴的package包/類
public static void main(final String[] args) throws Exception {
GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] sds = ge.getScreenDevices();
for (GraphicsDevice sd : sds) {
GraphicsConfiguration gc = sd.getDefaultConfiguration();
Rectangle bounds = gc.getBounds();
Point point = new Point(bounds.x, bounds.y);
Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
while (point.y < bounds.y + bounds.height - insets.bottom - SIZE) {
while (point.x
< bounds.x + bounds.width - insets.right - SIZE) {
test(point);
point.translate(bounds.width / 5, 0);
}
point.setLocation(bounds.x, point.y + bounds.height / 5);
}
}
}
示例4: checkConfigs
import java.awt.GraphicsConfiguration; //導入依賴的package包/類
private static GraphicsDevice checkConfigs(GraphicsDevice[] devices) {
GraphicsDevice correctDevice = null;
if (devices.length < 2) {
return correctDevice;
}
Toolkit toolkit = Toolkit.getDefaultToolkit();
Rectangle screenBounds = new Rectangle(toolkit.getScreenSize());
int halfScreen = screenBounds.height/2;
for(int i = 0; i < devices.length; i++) {
if(devices[i].getType() == GraphicsDevice.TYPE_RASTER_SCREEN) {
GraphicsConfiguration conf =
devices[i].getDefaultConfiguration();
Rectangle bounds = conf.getBounds();
if (bounds.y >= halfScreen) {
// found
correctDevice = devices[i];
break;
}
}
}
return correctDevice;
}
示例5: makeUnmanagedBI
import java.awt.GraphicsConfiguration; //導入依賴的package包/類
private static BufferedImage makeUnmanagedBI(GraphicsConfiguration gc,
int type) {
BufferedImage img = gc.createCompatibleImage(SIZE, SIZE, type);
Graphics2D g2d = img.createGraphics();
g2d.setColor(RGB);
g2d.fillRect(0, 0, SIZE, SIZE);
g2d.dispose();
final DataBuffer db = img.getRaster().getDataBuffer();
if (db instanceof DataBufferInt) {
((DataBufferInt) db).getData();
} else if (db instanceof DataBufferShort) {
((DataBufferShort) db).getData();
} else if (db instanceof DataBufferByte) {
((DataBufferByte) db).getData();
} else {
try {
img.setAccelerationPriority(0.0f);
} catch (final Throwable ignored) {
}
}
return img;
}
示例6: updateOffscreenImage
import java.awt.GraphicsConfiguration; //導入依賴的package包/類
private int updateOffscreenImage() {
// Update offscreen image reference
if (offscreenImage == null) offscreenImage = offscreenImageReference.get();
// Offscreen image not available
if (offscreenImage == null) return VolatileImage.IMAGE_INCOMPATIBLE;
// Buffered image is always valid
if (bufferType != BUFFER_VOLATILE_IMAGE) return VolatileImage.IMAGE_OK;
// Determine GraphicsConfiguration context
GraphicsConfiguration gConfiguration = getGraphicsConfiguration();
if (gConfiguration == null) return VolatileImage.IMAGE_INCOMPATIBLE;
// Return Volatile image state
return ((VolatileImage)offscreenImage).validate(gConfiguration);
}
示例7: getBackupSurface
import java.awt.GraphicsConfiguration; //導入依賴的package包/類
/**
* Creates a software-based surface (of type BufImgSurfaceData).
* The software representation is only created when needed, which
* is only during some situation in which the hardware surface
* cannot be allocated. This allows apps to at least run,
* albeit more slowly than they would otherwise.
*/
protected SurfaceData getBackupSurface() {
if (sdBackup == null) {
GraphicsConfiguration gc = vImg.getGraphicsConfig();
AffineTransform tx = gc.getDefaultTransform();
double scaleX = tx.getScaleX();
double scaleY = tx.getScaleY();
BufferedImage bImg = vImg.getBackupImage(scaleX, scaleY);
// Sabotage the acceleration capabilities of the BufImg surface
SunWritableRaster.stealTrackable(bImg
.getRaster()
.getDataBuffer()).setUntrackable();
sdBackup = BufImgSurfaceData.createData(bImg, scaleX, scaleY);
}
return sdBackup;
}
示例8: main
import java.awt.GraphicsConfiguration; //導入依賴的package包/類
public static void main(final String[] args) {
final GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
final GraphicsConfiguration gc =
ge.getDefaultScreenDevice().getDefaultConfiguration();
final VolatileImage vi = gc.createCompatibleVolatileImage(200, 200);
final SunGraphics2D sg2d = (SunGraphics2D) vi.createGraphics();
sg2d.constrain(0, 61, 100, 100);
final AffineTransform expected = sg2d.cloneTransform();
sg2d.setTransform(sg2d.getTransform());
final AffineTransform actual = sg2d.cloneTransform();
sg2d.dispose();
vi.flush();
if (!expected.equals(actual)) {
System.out.println("Expected = " + expected);
System.out.println("Actual = " + actual);
throw new RuntimeException("Wrong transform");
}
}
示例9: createInstance
import java.awt.GraphicsConfiguration; //導入依賴的package包/類
/**
* Creates an instance of the painter for particular peer.
*/
public static TranslucentWindowPainter createInstance(WWindowPeer peer) {
GraphicsConfiguration gc = peer.getGraphicsConfiguration();
if (!forceSW && gc instanceof AccelGraphicsConfig) {
String gcName = gc.getClass().getSimpleName();
AccelGraphicsConfig agc = (AccelGraphicsConfig)gc;
// this is a heuristic to check that we have a pcix board
// (those have higher transfer rate from gpu to cpu)
if ((agc.getContextCapabilities().getCaps() & CAPS_PS30) != 0 ||
forceOpt)
{
// we check for name to avoid loading classes unnecessarily if
// a pipeline isn't enabled
if (gcName.startsWith("D3D")) {
return new VIOptD3DWindowPainter(peer);
} else if (forceOpt && gcName.startsWith("WGL")) {
// on some boards (namely, ATI, even on pcix bus) ogl is
// very slow reading pixels back so for now it is disabled
// unless forced
return new VIOptWGLWindowPainter(peer);
}
}
}
return new BIWindowPainter(peer);
}
示例10: getUserLocation
import java.awt.GraphicsConfiguration; //導入依賴的package包/類
private Point getUserLocation(GraphicsConfiguration gconf, OptionsPanel optionsPanel) {
final Rectangle screenBounds = Utilities.getUsableScreenBounds(gconf);
int x = NbPreferences.forModule(OptionsDisplayerImpl.class).getInt("OptionsX", Integer.MAX_VALUE);//NOI18N
int y = NbPreferences.forModule(OptionsDisplayerImpl.class).getInt("OptionsY", Integer.MAX_VALUE);//NOI18N
Dimension userSize = optionsPanel.getUserSize();
if (x > screenBounds.x + screenBounds.getWidth() || y > screenBounds.y + screenBounds.getHeight()
|| x + userSize.width > screenBounds.x + screenBounds.getWidth()
|| y + userSize.height > screenBounds.y + screenBounds.getHeight()
|| (x < screenBounds.x && screenBounds.x >= 0)
|| (x > screenBounds.x && screenBounds.x < 0)
|| (y < screenBounds.y && screenBounds.y >= 0)
|| (y > screenBounds.y && screenBounds.y < 0)){
return null;
} else {
return new Point(x, y);
}
}
示例11: show
import java.awt.GraphicsConfiguration; //導入依賴的package包/類
public void show(Point location) {
Rectangle screenBounds = null;
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gds = ge.getScreenDevices();
for (GraphicsDevice device : gds) {
GraphicsConfiguration gc = device.getDefaultConfiguration();
screenBounds = gc.getBounds();
if (screenBounds.contains(location)) {
break;
}
}
// showing the popup tooltip
cp = new TooltipContentPanel(master.getTextComponent());
Window w = SwingUtilities.windowForComponent(master.getTextComponent());
contentWindow = new JWindow(w);
contentWindow.add(cp);
contentWindow.pack();
Dimension dim = contentWindow.getSize();
if (location.y + dim.height + SCREEN_BORDER > screenBounds.y + screenBounds.height) {
dim.height = (screenBounds.y + screenBounds.height) - (location.y + SCREEN_BORDER);
}
if (location.x + dim.width + SCREEN_BORDER > screenBounds.x + screenBounds.width) {
dim.width = (screenBounds.x + screenBounds.width) - (location.x + SCREEN_BORDER);
}
contentWindow.setSize(dim);
contentWindow.setLocation(location.x, location.y - 1); // slight visual adjustment
contentWindow.setVisible(true);
Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.KEY_EVENT_MASK);
w.addWindowFocusListener(this);
contentWindow.addWindowFocusListener(this);
}
示例12: actionPerformed
import java.awt.GraphicsConfiguration; //導入依賴的package包/類
@Override
public void actionPerformed(ActionEvent ae) {
JPopupMenu popup = getPopupMenu();
popup.addPopupMenuListener(popupMenuListener);
int popupPrefHeight = (int) popup.getPreferredSize().getHeight();
int buttonY = mainButton.getLocationOnScreen().y;
boolean showOnTop = false;
GraphicsConfiguration graphicsConf = ApplicationFrame.getApplicationFrame().getGraphicsConfiguration();
if (graphicsConf != null) {
int windowHeight = (int) graphicsConf.getBounds().getHeight();
showOnTop = buttonY + mainButton.getHeight() + popupPrefHeight > windowHeight;
}
if (showOnTop) {
popup.show(mainButton, 0, -popupPrefHeight);
} else {
popup.show(mainButton, 0, mainButton.getHeight());
}
}
示例13: LevelScene
import java.awt.GraphicsConfiguration; //導入依賴的package包/類
/**
* Constructor
*
* @param graphicsConfiguration
* @param renderer
* @param seed
* @param levelDifficulty
* @param type
* @param levelLength
* @param timeLimit
*/
public LevelScene(GraphicsConfiguration graphicsConfiguration,
GameWorld renderer, long seed, int levelDifficulty,
int type, int levelLength, int timeLimit, String ownLevelName)
{
this.graphicsConfiguration = graphicsConfiguration;
this.renderer = renderer;
this.levelSeed = seed;
this.levelDifficulty = levelDifficulty;
this.levelType = type;
this.levelLength = levelLength;
this.totalTime = timeLimit;
// TODO should these be initialized in an object constructor?
killedCreaturesTotal = 0;
killedCreaturesByFireBall = 0;
killedCreaturesByStomp = 0;
killedCreaturesByGrumpy = 0;
playersAtEnd = 0;
this.ownLevelName = ownLevelName;
}
示例14: initImage
import java.awt.GraphicsConfiguration; //導入依賴的package包/類
static void initImage(GraphicsConfiguration gc, Image image) {
Graphics g = image.getGraphics();
g.setColor(Color.RED);
int w = image.getWidth(null);
int h = image.getHeight(null);
g.fillRect(0, 0, w, h);
g.dispose();
// need to 'accelerate' the image
if (dstImage == null) {
dstImage =
gc.createCompatibleVolatileImage(TESTW, TESTH,
Transparency.OPAQUE);
}
dstImage.validate(gc);
g = dstImage.getGraphics();
g.drawImage(image, 0, 0, null);
g.drawImage(image, 0, 0, null);
g.drawImage(image, 0, 0, null);
}
示例15: initImages
import java.awt.GraphicsConfiguration; //導入依賴的package包/類
private void initImages(int w, int h) {
if (images == null) {
images = new Image[6];
GraphicsConfiguration gc = getGraphicsConfiguration();
for (int i = OPAQUE; i <= TRANSLUCENT; i++) {
VolatileImage vi =
gc.createCompatibleVolatileImage(w,h/images.length,i);
images[i-1] = vi;
vi.validate(gc);
String s = "LCD AA Text rendered to " + tr[i - 1] + " HW destination";
render(vi, i, s);
s = "LCD AA Text rendered to " + tr[i - 1] + " SW destination";
images[i-1+3] = gc.createCompatibleImage(w, h/images.length, i);
render(images[i-1+3], i, s);
}
}
}