List of usage examples for java.awt Rectangle getSize
public Dimension getSize()
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 w w.j av a 2s .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;/*w ww .j a va2 s. c o m*/ 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:Main.java
public static boolean canVScroll(JViewport viewport) { JScrollPane scrollPane = (JScrollPane) viewport.getParent(); Rectangle availR = scrollPane.getBounds(); Component view = viewport.getView(); Dimension viewPrefSize = view != null ? view.getPreferredSize() : new Dimension(0, 0); Dimension extentSize = viewport.toViewCoordinates(availR.getSize()); boolean canVScroll = true; if (view instanceof Scrollable) canVScroll = !((Scrollable) view).getScrollableTracksViewportHeight(); if (canVScroll && (viewPrefSize.height <= extentSize.height)) canVScroll = false;/* www. j a v a2 s . co m*/ return canVScroll; }
From source file:Main.java
public static boolean canHScroll(JViewport viewport) { JScrollPane scrollPane = (JScrollPane) viewport.getParent(); Rectangle availR = scrollPane.getBounds(); Component view = viewport.getView(); Dimension viewPrefSize = view != null ? view.getPreferredSize() : new Dimension(0, 0); Dimension extentSize = viewport.toViewCoordinates(availR.getSize()); boolean canHScroll = true; if (view instanceof Scrollable) canHScroll = !((Scrollable) view).getScrollableTracksViewportWidth(); if (canHScroll && (viewPrefSize.width <= extentSize.width)) canHScroll = false;/*from w w w. j a va 2 s . c o m*/ return canHScroll; }
From source file:Main.java
/** * returns the virtual screensize in a multimonitor system * /*from w w w . j av a2s. co m*/ * @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:gate.Main.java
/** Run the user interface. */ protected static void runGui() throws GateException { Thread.currentThread().setPriority(Thread.MIN_PRIORITY); // initialise the library and load user CREOLE directories try {/*w w w . j a v a 2 s. co m*/ Gate.init(); } catch (Throwable t) { log.error("Problem while initialising GATE", t); int selection = JOptionPane.showOptionDialog(null, "Error during initialisation:\n" + t.toString() + "\nDo you still want to start GATE?", "GATE", JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, new String[] { "Cancel", "Start anyway" }, "Cancel"); if (selection != 1) { System.exit(1); } } //create the main frame, show it SwingUtilities.invokeLater(new Runnable() { @Override public void run() { GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment() .getDefaultScreenDevice().getDefaultConfiguration(); //this needs to run before any GUI component is constructed. applyUserPreferences(); //all the defaults tables have been updated; build the GUI frame = MainFrame.getInstance(gc); if (DEBUG) Out.prln("constructing GUI"); // run the GUI frame.setTitleChangable(true); frame.setTitle(name + " " + version + " build " + build); // Set title from Java properties String title = System.getProperty(GateConstants.TITLE_JAVA_PROPERTY_NAME); if (title != null) { frame.setTitle(title); } // if frame.setTitleChangable(false); // Set icon from Java properties // iconName could be absolute or "gate:/img/..." String iconName = System.getProperty(GateConstants.APP_ICON_JAVA_PROPERTY_NAME); if (iconName != null) { try { frame.setIconImage(Toolkit.getDefaultToolkit().getImage(new URL(iconName))); } catch (MalformedURLException mue) { log.warn("Could not load application icon.", mue); } } // if // Validate frames that have preset sizes frame.validate(); // Center the window Rectangle screenBounds = gc.getBounds(); Dimension screenSize = screenBounds.getSize(); Dimension frameSize = frame.getSize(); if (frameSize.height > screenSize.height) { frameSize.height = screenSize.height; } if (frameSize.width > screenSize.width) { frameSize.width = screenSize.width; } frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); frame.setVisible(true); //load session if required and available; //do everything from a new thread. Runnable runnable = new Runnable() { @Override public void run() { try { File sessionFile = Gate.getUserSessionFile(); if (sessionFile.exists()) { MainFrame.lockGUI("Loading saved session..."); PersistenceManager.loadObjectFromFile(sessionFile); } } catch (Exception e) { log.warn("Failed to load session data", e); } finally { MainFrame.unlockGUI(); } } }; Thread thread = new Thread(Thread.currentThread().getThreadGroup(), runnable, "Session loader"); thread.setPriority(Thread.MIN_PRIORITY); thread.start(); } }); registerCreoleUrls(); }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; Rectangle r = new Rectangle(100, 100, 200, 200); g2.fill(r);//from w ww. j a v a2 s. c om System.out.println(r.getSize()); }
From source file:com.projity.pm.graphic.spreadsheet.SpreadSheet.java
public boolean isOnIcon(MouseEvent e) { Point p = e.getPoint();// w w w. j a v a2s . c o m int row = rowAtPoint(p); int col = columnAtPoint(p); Rectangle bounds = getCellRect(row, col, false); SpreadSheetModel model = (SpreadSheetModel) getModel(); GraphicNode node = model.getNode(row); return NameCellComponent.isOnIcon( new Point((int) (p.getX() - bounds.getX()), (int) (p.getY() - bounds.getY())), bounds.getSize(), model.getCache().getLevel(node)); }
From source file:com.projity.pm.graphic.spreadsheet.SpreadSheet.java
public boolean isOnText(MouseEvent e) { Point p = e.getPoint();/*from w ww .j a va 2 s . c o m*/ int row = rowAtPoint(p); int col = columnAtPoint(p); Rectangle bounds = getCellRect(row, col, false); SpreadSheetModel model = (SpreadSheetModel) getModel(); GraphicNode node = model.getNode(row); return NameCellComponent.isOnText( new Point((int) (p.getX() - bounds.getX()), (int) (p.getY() - bounds.getY())), bounds.getSize(), model.getCache().getLevel(node)); }
From source file:edu.stanford.epadd.launcher.Splash.java
public Splash() { final SplashScreen splash = (System.getProperty("nobrowseropen") == null) ? SplashScreen.getSplashScreen() : null;/*from w ww. j av a 2 s . co m*/ if (splash == null) { System.out.println("SplashScreen.getSplashScreen() returned null"); return; } Rectangle r = splash.getBounds(); g = splash.createGraphics(); if (g == null) { System.out.println("splash.createGraphics() returned null"); return; } System.out.println("splash url = " + splash.getImageURL() + " w=" + r.getWidth() + " h=" + r.getHeight() + " size=" + r.getSize() + " loc=" + r.getLocation()); // setVisible(true); // toFront(); }