List of usage examples for java.awt Rectangle union
public Rectangle union(Rectangle r)
From source file:Main.java
public static void main(String[] args) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); Rectangle vBounds = new Rectangle(); GraphicsDevice[] gdArray = ge.getScreenDevices(); for (int i = 0; i < gdArray.length; i++) { GraphicsDevice gd = gdArray[i]; GraphicsConfiguration[] gcArray = gd.getConfigurations(); for (int j = 0; j < gcArray.length; j++) vBounds = vBounds.union(gcArray[j].getBounds()); }// w ww . j a va2 s . c om Point origin = vBounds.getLocation(); System.out.println("Virtual x = " + origin.x); System.out.println("Virtual y = " + origin.y); Dimension size = vBounds.getSize(); System.out.println("Virtual width = " + size.width); System.out.println("Virtual height = " + size.height); }
From source file:MainClass.java
public static void main(String[] args) { GraphicsEnvironment ge;/*from w w w .j av a2 s . c om*/ ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); Rectangle vBounds = new Rectangle(); GraphicsDevice[] gdArray = ge.getScreenDevices(); for (int i = 0; i < gdArray.length; i++) { GraphicsDevice gd = gdArray[i]; GraphicsConfiguration[] gcArray = gd.getConfigurations(); for (int j = 0; j < gcArray.length; j++) vBounds = vBounds.union(gcArray[j].getBounds()); } Point origin = vBounds.getLocation(); System.out.println("Virtual x = " + origin.x); System.out.println("Virtual y = " + origin.y); Dimension size = vBounds.getSize(); System.out.println("Virtual width = " + size.width); System.out.println("Virtual height = " + size.height); }
From source file:GuiScreens.java
public static void main(String[] args) { Rectangle virtualBounds = new Rectangle(); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gs = ge.getScreenDevices(); JFrame frame[][] = new JFrame[gs.length][]; for (int j = 0; j < gs.length; j++) { GraphicsDevice gd = gs[j]; System.out.println("Device " + j + ": " + gd); GraphicsConfiguration[] gc = gd.getConfigurations(); frame[j] = new JFrame[gc.length]; for (int i = 0; i < gc.length; i++) { System.out.println(" Configuration " + i + ": " + gc[i]); System.out.println(" Bounds: " + gc[i].getBounds()); virtualBounds = virtualBounds.union(gc[i].getBounds()); frame[j][i] = new JFrame("Config: " + i, gc[i]); frame[j][i].setBounds(50, 50, 400, 100); frame[j][i].setLocation((int) gc[i].getBounds().getX() + 50, (int) gc[i].getBounds().getY() + 50); frame[j][i].getContentPane().add(new JTextArea("Config:\n" + gc[i])); frame[j][i].setVisible(true); }/*from w w w . j a v a2 s . c o m*/ System.out.println("Overall bounds: " + virtualBounds); } }
From source file:Main.java
public static Rectangle getRowBounds(JTable table, int first, int last) { Rectangle result = table.getCellRect(first, -1, true); result = result.union(table.getCellRect(last, -1, true)); Insets i = table.getInsets(); result.x = i.left;//from ww w .java 2 s .c om result.width = table.getWidth() - i.left - i.right; return result; }
From source file:Main.java
public static Rectangle computeVirtualGraphicsBounds() { Rectangle virtualBounds = new Rectangle(); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gs = ge.getScreenDevices(); for (GraphicsDevice gd : gs) { GraphicsConfiguration gc = gd.getDefaultConfiguration(); virtualBounds = virtualBounds.union(gc.getBounds()); }/*from w ww. jav a 2s . c o m*/ return virtualBounds; }
From source file:Main.java
public static Dimension getPreferredSize(JComponent c, String text, Icon icon, int iconTextGap, int verticalAlignment, int horizontalAlignment, int verticalTextAlignment, int horizontalTextAlignment, Rectangle viewRect, Rectangle iconRect, Rectangle textRect) { viewRect.x = viewRect.y = 0;/* ww w .j a v a 2s.co m*/ viewRect.width = viewRect.height = Short.MAX_VALUE; layoutComponent(c, text, icon, iconTextGap, verticalAlignment, horizontalAlignment, verticalTextAlignment, horizontalTextAlignment, viewRect, iconRect, textRect); Rectangle size = iconRect.union(textRect); if (c.getInsets() != null) { addInsets(size, c.getInsets()); } return new Dimension(size.width, size.height); }
From source file:Main.java
/** * returns the virtual screensize in a multimonitor system * /*www . j a v a2s.c om*/ * @return */ public static Dimension getVirtualScreenSize() { Rectangle virtualBounds = new Rectangle(); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gs = ge.getScreenDevices(); for (int j = 0; j < gs.length; j++) { GraphicsDevice gd = gs[j]; GraphicsConfiguration[] gc = gd.getConfigurations(); for (int i = 0; i < gc.length; i++) { virtualBounds = virtualBounds.union(gc[i].getBounds()); } } return virtualBounds.getSize(); }
From source file:com.seleniumtests.driver.CustomEventFiringWebDriver.java
/** * Returns the rectangle of all screens on the system * @return/*from ww w. ja va2s . c o 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:Main.java
/** * Updates {@link #SCREEN_SIZE_PRIMARY } and {@link #SCREEN_SIZE_TOTAL} *//* w w w.j av a2s . c om*/ public static void calculateScreenSizes() { Rectangle totalBounds = new Rectangle(); Rectangle primaryBounds = null; GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gs = ge.getScreenDevices(); for (int j = 0; j < gs.length; j++) { GraphicsDevice gd = gs[j]; if (gd == ge.getDefaultScreenDevice()) { primaryBounds = new Rectangle(); } GraphicsConfiguration[] gc = gd.getConfigurations(); for (int i = 0; i < gc.length; i++) { Rectangle bounds = gc[i].getBounds(); Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets(gc[i]); bounds.x += screenInsets.left; bounds.y += screenInsets.top; bounds.height -= screenInsets.bottom; bounds.width -= screenInsets.right; totalBounds = totalBounds.union(bounds); if (primaryBounds != null) { primaryBounds = primaryBounds.union(bounds); } } if (primaryBounds != null) { SCREEN_SIZE_PRIMARY = primaryBounds; primaryBounds = null; } } SCREEN_SIZE_TOTAL = totalBounds; }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Rectangle r = new Rectangle(10, 10, 50, 40); r = r.union(new Rectangle(20, 20, 60, 60)); g2.fill(r);//from w ww.j ava 2s . co m }