當前位置: 首頁>>代碼示例>>Java>>正文


Java GraphicsConfiguration類代碼示例

本文整理匯總了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();
   }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:Utilities.java

示例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);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:VolatileImageConfigurationTest.java

示例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);
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:PopupMenuLocation.java

示例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;
    }
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:26,代碼來源:bug8071705.java

示例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;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:23,代碼來源:IncorrectAlphaConversionBicubic.java

示例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);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:BufferedCanvasComponent.java

示例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;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:23,代碼來源:VolatileSurfaceManager.java

示例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");
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:21,代碼來源:TransformSetGet.java

示例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);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:28,代碼來源:TranslucentWindowPainter.java

示例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);
      }
  }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:OptionsDisplayerImpl.java

示例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);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:38,代碼來源:TooltipWindow.java

示例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());
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:23,代碼來源:FancyDropDownButton.java

示例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;		
}
 
開發者ID:CognitiveModeling,項目名稱:BrainControl,代碼行數:31,代碼來源:LevelScene.java

示例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);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:21,代碼來源:SourceClippingBlitTest.java

示例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);
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:19,代碼來源:NonOpaqueDestLCDAATest.java


注:本文中的java.awt.GraphicsConfiguration類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。