List of usage examples for java.awt Rectangle contains
public boolean contains(Rectangle r)
From source file:com.kbot2.scriptable.methods.wrappers.Interface.java
public void doClick() { Rectangle rect = getArea(); final Point mousePos = getMethods().getMousePos(); if (rect.contains(mousePos)) { int random = random(0, 5); if (random < 4) { botEnv.mouse.clickMouse(true); return; } else if (random == 4) { Point ranPoint = new Point(mousePos.x + random(-5, 5), mousePos.y + random(-5, 5)); if (rect.contains(ranPoint)) { botEnv.methods.clickMouse(ranPoint, true); return; }//w w w . j a v a2 s . c om } } int randomX = random(rect.x, rect.x + rect.width); int randomY = random(rect.y, rect.y + rect.height); botEnv.methods.clickMouse(new Point(randomX, randomY), true); }
From source file:OAT.ui.BarChartFrame.java
@Override protected void init() { // setJMenuBar(new MainMenuBar(this)); // setContentPane(chartPanel); // setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); //set getItemCount and location //Rectangle mainBound = Main.frame.getBounds(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); screenSize.height = screenSize.height - MENU_BAR_HEIGHT; //Dimension chartFrameSize = getChartPanelSize(); //chartFrameSize.height += MENU_BAR_HEIGHT; int gridRows = Main.chartFramesGrid.length; int gridColumns = Main.chartFramesGrid[0].length; boolean isOccupied = false; for (int c = 0; c < gridColumns; c++) { for (int r = 0; r < gridRows; r++) { Rectangle bound = Main.chartFramesGrid[r][c]; for (BarChartFrame existingFrame : Main.chartFrames) { if (bound.contains(existingFrame.getLocation()) || existingFrame.getBounds().contains(bound.intersection(new Rectangle(screenSize)))) { isOccupied = true;/*from w w w . jav a 2 s . c o m*/ break; } } if (!isOccupied) { setBounds(bound); break; } } if (!isOccupied) { break; } } if (isOccupied) { setBounds(Main.chartFramesGrid[Main.lastChartFrameGridId % gridRows][(Main.lastChartFrameGridId / gridRows) % gridColumns]); } Main.lastChartFrameGridId++; Main.chartFrames.add(this); addComponentListener(new java.awt.event.ComponentAdapter() { @Override public void componentHidden(java.awt.event.ComponentEvent evt) { formComponentHidden(evt); } }); //pack and display pack(); }
From source file:edu.ku.brc.ui.dnd.SimpleGlassPane.java
/** * @param e/* w ww . ja v a 2 s.c om*/ */ protected void checkMouseEvent(MouseEvent e) { Rectangle r = getInternalBounds(); Point p = e.getPoint(); if (r.contains(p)) { if (!dblClickProgBar || !getProgressBarRect().contains(p)) { e.consume(); } } }
From source file:com.tag.FramePreferences.java
private boolean isOffScreen(Dimension size, Point location) { Rectangle bounds = getGraphicsBounds(); int padding = 10; bounds.x -= (size.width - padding);//from w w w .ja va 2 s. co m bounds.y -= padding; bounds.width += (size.width - padding); bounds.height += padding; // window is off screen return !bounds.contains(location); }
From source file:com.kbotpro.randoms.GraveDigger.java
boolean clickExit(IComponent i) { IComponent xpCounter = interfaces.getComponent(746, 221); if (!game.isFixedMode() && i.getBounds().intersects(xpCounter.getBounds())) { Rectangle r = xpCounter.getBounds(); r.x -= 2;/*from w ww .j av a2 s . c o m*/ r.height += 2; r = i.getBounds().intersection(r); Point p = getSomeFuckingPoint(i.getBounds()); while (r.contains(p) && !i.getBounds().contains(p)) { p = getSomeFuckingPoint(i.getBounds()); } mouse.moveMouse(p); return menu.atMenu("Close"); } else { return i.doAction("Close"); } }
From source file:mobac.gui.components.JMapSourceTree.java
/** * Check if the mouse cursor was over a clickable node * // w w w .j a v a 2s. com * @param eventPoint * - a mouse position coordinates * @return true if a node was clickable, false otherwise */ public boolean isLocationClickable(Point eventPoint) { int x = (int) eventPoint.getX(); int y = (int) eventPoint.getY(); TreePath treePathForXY = getPathForLocation(x, y); // If a node is an ancestor of a currently selected node - it can't be closed, so it is unclickable. if (treePathForXY != null && treePathForXY.isDescendant(findTreePathOfMapSource(selectedMapSource))) { return false; } boolean isInside = false; if (treePathForXY != null) { Rectangle pathBounds = this.getPathBounds(treePathForXY); isInside = pathBounds.contains(eventPoint); } return isInside; }
From source file:knop.psfj.BeadFrameList.java
/** * Gets the certain number of beads contained inside a defined zone. The * zone should be in pixel and in the image space. * /* w ww . j av a 2 s.c o m*/ * @param zone * the zone * @param max * the maximum number of beads to be retrieved * @return the sample from corner */ public BeadFrameList getSampleFromCorner(Rectangle zone, int max) { BeadFrameList list = new BeadFrameList(); int count = 0; for (BeadFrame frame : this) { if (zone.contains(new Point(frame.getFrameX(), frame.getFrameY())) && frame.getAlterEgo() != null) { list.add(frame); count++; } if (count >= max) break; } return list; }
From source file:com.dhenton9000.selenium.generic.GenericAutomationRepository.java
/** * Determines visibility of an element in a window. * @param w//from ww w . j ava 2s. c om * @return true if the element is in the window, false if not */ public boolean isElementScrolledIntoView(WebElement w) { if (w == null) { return false; } Point p = w.getLocation(); Dimension d = getDriver().manage().window().getSize(); java.awt.Rectangle r = new java.awt.Rectangle(d.getWidth(), d.getHeight()); java.awt.Point awtPoint = new java.awt.Point(p.x, p.y); return r.contains(awtPoint); }
From source file:com.kbot2.scriptable.methods.data.Bank.java
/** * Checks if the item is clickable/* ww w . ja v a 2 s . co m*/ * * @param item * @return */ public boolean isItemClickable(Interface item) { Rectangle bounds = getBankInterfaceGroup().getInterface(BANK_ITEMPANE).getArea(); Rectangle rect = item.getArea(); return bounds.contains(rect); }
From source file:edu.ku.brc.specify.tasks.subpane.LocalityMapperSubPane.java
/** * @param mousePnt//from w ww .j a v a2 s .c o m */ public void checkMouseLocation(final Point mousePnt, final boolean showInfo) { if (dirty) { markerRects.clear(); Point pnt = imageLabel.getLocation(); //System.out.println("***************** "+pnt+" "+imageLabel.getBounds()+" "+imageLabel.getParent()+" "+this); for (Point p : localityMapper.getMarkerLocations()) { //System.out.println("*** "+(pnt.x+p.x-5)+" "+(pnt.y+p.y-5)); markerRects.add(new Rectangle(pnt.x + p.x - 5, pnt.y + p.y - 5, 10, 10)); } dirty = false; } int inx = 0; for (Rectangle r : markerRects) { //System.out.println(mousePnt.x+" "+mousePnt.y+" "+r); if (r.contains(mousePnt)) { if (showInfo) { Hashtable<String, Object> map = valueList.get(inx); multiView.setData(map); localityMapper.setCurrentLoc(collectingEvents.get(inx).getLocality()); } else { setCursor(handCursor); } return; } // else setCursor(defCursor); inx++; } //multiView.setData(null); }