@Override public Rectangle getBounds() { if (_bounds == null) { _bounds = new Rectangle(); for (int i = 0; i < Screen.getNumberScreens(); i++) { _bounds = _bounds.union(Screen.getBounds(i)); } } return _bounds; }
@Override public ScreenImage capture(Rectangle rect) { Debug.log(5, "capture: " + rect); BufferedImage ret = new BufferedImage(rect.width, rect.height, BufferedImage.TYPE_INT_RGB); Graphics2D g2d = ret.createGraphics(); for (int i = 0; i < Screen.getNumberScreens(); i++) { Rectangle scrBound = Screen.getBounds(i); if (scrBound.intersects(rect)) { Rectangle inter = scrBound.intersection(rect); Debug.log(5, "scrBound: " + scrBound + ", inter: " + inter); int ix = inter.x, iy = inter.y; inter.x -= scrBound.x; inter.y -= scrBound.y; ScreenImage img = robots[i].captureScreen(inter); g2d.drawImage(img.getImage(), ix - rect.x, iy - rect.y, null); } } g2d.dispose(); return new ScreenImage(rect, ret); }
public int getIdFromPoint(int x, int y) { Debug.log(5, "union bound: " + getBounds()); Debug.log(5, "x, y: " + x + "," + y); x += getBounds().x; y += getBounds().y; Debug.log(5, "new x, y: " + x + "," + y); for (int i = 0; i < getNumberScreens(); i++) if (Screen.getBounds(i).contains(x, y)) { return i; } return 0; }
RootWindow(Container container, Screen screen, Format[] format, Client c) { super(screen.rootId); rootwindow = container; client = c; screen.setRoot((Window) this); this.width = (short) (screen.width); this.height = (short) (screen.height); this.screen = screen; depth = screen.rootDepth; id = screen.rootId; type = DRAWABLE_WINDOW; x = y = 0; origin.x = 0; origin.y = 0; clss = (byte) InputOutput; for (int i = 0; i < format.length; i++) { if (format[i].depth == screen.rootDepth) { this.bitsPerPixel = format[i].bpp; } } setVisual(screen.rootVisual); setBackgroundIsPixel(); background.pixel = screen.white; setBorderIsPixel(); border.pixel = screen.black; borderWidth = 0; Resource.add(this); makeOptional(); attr &= ~(1 << 3); // cursorIsNone optional.cursor = Cursor.rootCursor; setColormap(screen.defaultColormap); // if(rootwindow instanceof JFrame){ // rootwindow.setSize(this.width+10, this.height+30); // ?? // } // else{ rootwindow.setSize(this.width, this.height); // } try { ddxwindow = (DDXWindow) (Window.dDXWindow.newInstance()); } catch (Exception e) { System.err.println(e); /*ddxwindow=new DDXWindowImp();*/ } ddxwindow.init(this); ddxwindow.setLocation(0, 0); if (rootwindow instanceof Frame) { // ((Frame)rootwindow).setLayout(null); ((Frame) rootwindow).setResizable(false); ((Frame) rootwindow).setMenuBar(null); ((Frame) rootwindow).add((java.awt.Component) ddxwindow); } else if (rootwindow instanceof Applet) { ((Applet) rootwindow).add((java.awt.Component) ddxwindow); } /* else if(rootwindow instanceof JFrame){ ((JFrame)rootwindow).getContentPane().setLayout(null); ((JFrame)rootwindow).setResizable(false); ((JFrame)rootwindow).setJMenuBar(null); ((JFrame)rootwindow).getContentPane().add((java.awt.Component)ddxwindow); } else if(rootwindow instanceof JWindow){ ((JWindow)rootwindow).getContentPane().setLayout(null); ((JWindow)rootwindow).getContentPane().add((java.awt.Component)ddxwindow); } else if (rootwindow instanceof JApplet){ ((JApplet)rootwindow).setJMenuBar(null); ((JApplet)rootwindow).getContentPane().add((java.awt.Component)ddxwindow); } */ else { rootwindow.add((java.awt.Component) ddxwindow); } if (screen.windowmode != WeirdX.InBrowser) { rootwindow.addNotify(); } else { rootwindow.setVisible(true); } ddxwindow.setVisible(true); { rootwindow.validate(); Insets insets = rootwindow.getInsets(); rootwindow.setSize( this.width + insets.left + insets.right, this.height + insets.top + insets.bottom); ddxwindow.setLocation(insets.left, insets.top); rootwindow.validate(); } ddxwindow.requestFocus(); Window.focus.win = id; Window.LOCK = rootwindow.getTreeLock(); Client.LOCK = rootwindow.getTreeLock(); Resource.LOCK = rootwindow.getTreeLock(); spriteTrace[0] = this; sprite.win = this; }