Java Code Examples for java.awt.Rectangle#equals()
The following examples show how to use
java.awt.Rectangle#equals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Path2DCopyConstructor.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
static void testGetBounds(Path2D pathA, Path2D pathB) { final Rectangle rA = pathA.getBounds(); final Rectangle rB = pathB.getBounds(); if (!rA.equals(rB)) { throw new IllegalStateException("Bounds are not equals [" + rA + "|" + rB + "] !"); } final Rectangle2D r2dA = pathA.getBounds2D(); final Rectangle2D r2dB = pathB.getBounds2D(); if (!equalsRectangle2D(r2dA, r2dB)) { throw new IllegalStateException("Bounds2D are not equals [" + r2dA + "|" + r2dB + "] !"); } log("testGetBounds: passed."); }
Example 2
Source File: SeaGlassRootPaneUI.java From seaglass with Apache License 2.0 | 6 votes |
/** * @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent) */ public void mouseDragged(MouseEvent ev) { Window w = (Window) ev.getSource(); Point pt = ev.getPoint(); if (isMovingWindow) { Point eventLocationOnScreen = ev.getLocationOnScreen(); w.setLocation(eventLocationOnScreen.x - dragOffsetX, eventLocationOnScreen.y - dragOffsetY); } else if (dragCursor != 0) { Rectangle r = w.getBounds(); Rectangle startBounds = new Rectangle(r); Dimension min = w.getMinimumSize(); switch (dragCursor) { case Cursor.E_RESIZE_CURSOR: adjust(r, min, 0, 0, pt.x + (dragWidth - dragOffsetX) - r.width, 0); break; case Cursor.S_RESIZE_CURSOR: adjust(r, min, 0, 0, 0, pt.y + (dragHeight - dragOffsetY) - r.height); break; case Cursor.N_RESIZE_CURSOR: adjust(r, min, 0, pt.y - dragOffsetY, 0, -(pt.y - dragOffsetY)); break; case Cursor.W_RESIZE_CURSOR: adjust(r, min, pt.x - dragOffsetX, 0, -(pt.x - dragOffsetX), 0); break; case Cursor.NE_RESIZE_CURSOR: adjust(r, min, 0, pt.y - dragOffsetY, pt.x + (dragWidth - dragOffsetX) - r.width, -(pt.y - dragOffsetY)); break; case Cursor.SE_RESIZE_CURSOR: adjust(r, min, 0, 0, pt.x + (dragWidth - dragOffsetX) - r.width, pt.y + (dragHeight - dragOffsetY) - r.height); break; case Cursor.NW_RESIZE_CURSOR: adjust(r, min, pt.x - dragOffsetX, pt.y - dragOffsetY, -(pt.x - dragOffsetX), -(pt.y - dragOffsetY)); break; case Cursor.SW_RESIZE_CURSOR: adjust(r, min, pt.x - dragOffsetX, 0, -(pt.x - dragOffsetX), pt.y + (dragHeight - dragOffsetY) - r.height); break; default: break; } if (!r.equals(startBounds)) { w.setBounds(r); // Defer repaint/validate on mouseReleased unless dynamic // layout is active. if (Toolkit.getDefaultToolkit().isDynamicLayoutActive()) { w.validate(); getRootPane().repaint(); } } } }
Example 3
Source File: Path2DCopyConstructor.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
static void testGetBounds(Path2D pathA, Path2D pathB) { final Rectangle rA = pathA.getBounds(); final Rectangle rB = pathB.getBounds(); if (!rA.equals(rB)) { throw new IllegalStateException("Bounds are not equals [" + rA + "|" + rB + "] !"); } final Rectangle2D r2dA = pathA.getBounds2D(); final Rectangle2D r2dB = pathB.getBounds2D(); if (!equalsRectangle2D(r2dA, r2dB)) { throw new IllegalStateException("Bounds2D are not equals [" + r2dA + "|" + r2dB + "] !"); } log("testGetBounds: passed."); }
Example 4
Source File: Path2DCopyConstructor.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
static void testGetBounds(Path2D pathA, Path2D pathB) { final Rectangle rA = pathA.getBounds(); final Rectangle rB = pathB.getBounds(); if (!rA.equals(rB)) { throw new IllegalStateException("Bounds are not equals [" + rA + "|" + rB + "] !"); } final Rectangle2D r2dA = pathA.getBounds2D(); final Rectangle2D r2dB = pathB.getBounds2D(); if (!equalsRectangle2D(r2dA, r2dB)) { throw new IllegalStateException("Bounds2D are not equals [" + r2dA + "|" + r2dB + "] !"); } log("testGetBounds: passed."); }
Example 5
Source File: AnnotationsDecorator.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
/** * Makes sure the current editor height matches its content if the annotation was never resized. * If the annotation has been manually resized before, does nothing. * * @param anno * the annotation currently in the editor */ private void updateEditorHeight(final WorkflowAnnotation anno) { if (anno.wasResized()) { return; } Rectangle bounds = editPane.getBounds(); // height is either the pref height or the current height, depending on what is bigger int prefHeight; if (anno instanceof ProcessAnnotation) { prefHeight = (int) Math.max(getContentHeightOfEditor((int) bounds.getWidth()), bounds.getHeight()); } else { prefHeight = Math.max(getContentHeightOfEditor((int) bounds.getWidth()), OperatorAnnotation.MIN_HEIGHT); } Rectangle newBounds = new Rectangle((int) bounds.getX(), (int) bounds.getY(), (int) bounds.getWidth(), prefHeight); if (!bounds.equals(newBounds)) { editPane.setBounds(newBounds); updateEditPanelPosition(newBounds, true); view.getModel().fireAnnotationMiscChanged(anno); } }
Example 6
Source File: Central.java From netbeans with Apache License 2.0 | 6 votes |
/** Sets bounds into model and requests view (if needed). */ public void setModeBounds(ModeImpl mode, Rectangle bounds) { if(bounds == null) { return; } Rectangle old = getModeBounds(mode); if(old.equals(bounds)) { return; } model.setModeBounds(mode, bounds); if(isVisible() && getEditorAreaState() == Constants.EDITOR_AREA_SEPARATED) { viewRequestor.scheduleRequest(new ViewRequest( mode, View.CHANGE_MODE_BOUNDS_CHANGED, old, bounds)); } mode.doFirePropertyChange(ModeImpl.PROP_BOUNDS, old, bounds); }
Example 7
Source File: Path2DCopyConstructor.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
static void testGetBounds(Path2D pathA, Path2D pathB) { final Rectangle rA = pathA.getBounds(); final Rectangle rB = pathB.getBounds(); if (!rA.equals(rB)) { throw new IllegalStateException("Bounds are not equals [" + rA + "|" + rB + "] !"); } final Rectangle2D r2dA = pathA.getBounds2D(); final Rectangle2D r2dB = pathB.getBounds2D(); if (!equalsRectangle2D(r2dA, r2dB)) { throw new IllegalStateException("Bounds2D are not equals [" + r2dA + "|" + r2dB + "] !"); } log("testGetBounds: passed."); }
Example 8
Source File: Central.java From netbeans with Apache License 2.0 | 6 votes |
/** Sets main window bounds (joined[tiled] state) into model and requests view (if needed). */ public void setMainWindowBoundsJoined(Rectangle mainWindowBoundsJoined) { if(mainWindowBoundsJoined == null) { return; } Rectangle old = getMainWindowBoundsJoined(); if(old.equals(mainWindowBoundsJoined)) { return; } model.setMainWindowBoundsJoined(mainWindowBoundsJoined); if(isVisible()) { viewRequestor.scheduleRequest( new ViewRequest(null, View.CHANGE_MAIN_WINDOW_BOUNDS_JOINED_CHANGED, old, mainWindowBoundsJoined)); } }
Example 9
Source File: Central.java From netbeans with Apache License 2.0 | 6 votes |
/** Sets main window bounds (separated state) into model and requests view (if needed). */ public void setMainWindowBoundsSeparated(Rectangle mainWindowBoundsSeparated) { if(mainWindowBoundsSeparated == null) { return; } Rectangle old = getMainWindowBoundsSeparated(); if(old.equals(mainWindowBoundsSeparated)) { return; } model.setMainWindowBoundsSeparated(mainWindowBoundsSeparated); if(isVisible()) { viewRequestor.scheduleRequest( new ViewRequest(null, View.CHANGE_MAIN_WINDOW_BOUNDS_SEPARATED_CHANGED, old, mainWindowBoundsSeparated)); } }
Example 10
Source File: XContentWindow.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
void setContentBounds(WindowDimensions dims) { XToolkit.awtLock(); try { // Bounds of content window are of the same size as bounds of Java window and with // location as -(insets) Rectangle newBounds = dims.getBounds(); Insets in = dims.getInsets(); if (in != null) { newBounds.setLocation(-in.left, -in.top); } if (insLog.isLoggable(PlatformLogger.Level.FINE)) { insLog.fine("Setting content bounds {0}, old bounds {1}", newBounds, getBounds()); } // Fix for 5023533: // Change in the size of the content window means, well, change of the size // Change in the location of the content window means change in insets boolean needHandleResize = !(newBounds.equals(getBounds())); reshape(newBounds); if (needHandleResize) { insLog.fine("Sending RESIZED"); handleResize(newBounds); } } finally { XToolkit.awtUnlock(); } validateSurface(); }
Example 11
Source File: XContentWindow.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
void setContentBounds(WindowDimensions dims) { XToolkit.awtLock(); try { // Bounds of content window are of the same size as bounds of Java window and with // location as -(insets) Rectangle newBounds = dims.getBounds(); Insets in = dims.getInsets(); if (in != null) { newBounds.setLocation(-in.left, -in.top); } if (insLog.isLoggable(PlatformLogger.Level.FINE)) { insLog.fine("Setting content bounds {0}, old bounds {1}", newBounds, getBounds()); } // Fix for 5023533: // Change in the size of the content window means, well, change of the size // Change in the location of the content window means change in insets boolean needHandleResize = !(newBounds.equals(getBounds())); reshape(newBounds); if (needHandleResize) { insLog.fine("Sending RESIZED"); handleResize(newBounds); } } finally { XToolkit.awtUnlock(); } validateSurface(); }
Example 12
Source File: XContentWindow.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
void setContentBounds(WindowDimensions dims) { XToolkit.awtLock(); try { // Bounds of content window are of the same size as bounds of Java window and with // location as -(insets) Rectangle newBounds = dims.getBounds(); Insets in = dims.getInsets(); if (in != null) { newBounds.setLocation(-in.left, -in.top); } if (insLog.isLoggable(PlatformLogger.Level.FINE)) { insLog.fine("Setting content bounds {0}, old bounds {1}", newBounds, getBounds()); } // Fix for 5023533: // Change in the size of the content window means, well, change of the size // Change in the location of the content window means change in insets boolean needHandleResize = !(newBounds.equals(getBounds())); reshape(newBounds); if (needHandleResize) { insLog.fine("Sending RESIZED"); handleResize(newBounds); } } finally { XToolkit.awtUnlock(); } validateSurface(); }
Example 13
Source File: XContentWindow.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
void setContentBounds(WindowDimensions dims) { XToolkit.awtLock(); try { // Bounds of content window are of the same size as bounds of Java window and with // location as -(insets) Rectangle newBounds = dims.getBounds(); Insets in = dims.getInsets(); if (in != null) { newBounds.setLocation(-in.left, -in.top); } if (insLog.isLoggable(PlatformLogger.Level.FINE)) { insLog.fine("Setting content bounds {0}, old bounds {1}", newBounds, getBounds()); } // Fix for 5023533: // Change in the size of the content window means, well, change of the size // Change in the location of the content window means change in insets boolean needHandleResize = !(newBounds.equals(getBounds())); reshape(newBounds); if (needHandleResize) { insLog.fine("Sending RESIZED"); handleResize(newBounds); } } finally { XToolkit.awtUnlock(); } validateSurface(); }
Example 14
Source File: ScreenshotComponent.java From netbeans with Apache License 2.0 | 5 votes |
private void selectComponent(ComponentInfo ci, boolean reActivated) { Node node = null; if (ci != null) { Rectangle oldSelection = null; if (selection != null) { oldSelection = selection; } selection = ci.getWindowBounds(); if (oldSelection != null) { if (oldSelection.equals(selection) && !reActivated) { return ; // already selected } repaint((int) (scale * oldSelection.x), (int) (scale * oldSelection.y), (int) (scale * oldSelection.width) + 3, (int) (scale * oldSelection.height) + 3); } repaint((int) (scale * selection.x), (int) (scale * selection.y), (int) (scale * selection.width) + 3, (int) (scale * selection.height) + 3); logger.fine("New selection = "+selection); node = componentNodes.findNodeFor(ci); logger.fine("FindNodeFor("+ci+") on '"+componentNodes+"' gives: "+node); } Node[] nodes; if (node != null) { nodes = new Node[] { node }; } else { nodes = new Node[] {}; } logger.fine("setActivated/SelectedNodes("+Arrays.toString(nodes)+")"); setActivatedNodes(nodes); try { ComponentHierarchy.getInstance().getExplorerManager().setSelectedNodes(nodes); } catch (PropertyVetoException ex) { Exceptions.printStackTrace(ex); } }
Example 15
Source File: BufferedCanvasComponent.java From netbeans with Apache License 2.0 | 4 votes |
protected boolean canDirectlyAccessGraphics() { // TODO: what about popup windows / tooltips??? // TODO: some of the queries could be cached instead of polling, // for example isShowing(), isOpaque(), getParent() etc. ////// // Shouldn't access graphics - no buffering would cause flickering ////// if (bufferType == BUFFER_NONE) return false; // Cannot access graphics - there are some child components if (getComponentCount() != 0) return false; // Cannot access graphics - component doesn't fully control its area if (!isOpaque()) return false; // Cannot access graphics - not in Swing tree if (!(getParent() instanceof JComponent)) return false; // Cannot access graphics - component not showing, doesn't make sense if (!isShowing()) return false; // Cannot access graphics - component area is not up-to-date Rectangle dirtyRegion = RepaintManager.currentManager(this). getDirtyRegion((JComponent)getParent()); if (dirtyRegion != null && dirtyRegion.width > 0 && dirtyRegion.height > 0) return false; // --- Reused from JViewport ------------------------------------------- Rectangle clip = new Rectangle(0, 0, getWidth(), getHeight()); Rectangle oldClip = new Rectangle(); Rectangle tmp2 = null; Container parent; Component lastParent = null; int x, y, w, h; for (parent = this; parent != null && isLightweightComponent(parent); parent = parent.getParent()) { x = parent.getX(); y = parent.getY(); w = parent.getWidth(); h = parent.getHeight(); oldClip.setBounds(clip); SwingUtilities.computeIntersection(0, 0, w, h, clip); if (!clip.equals(oldClip)) return false; if (lastParent != null && parent instanceof JComponent && !((JComponent)parent).isOptimizedDrawingEnabled()) { Component comps[] = parent.getComponents(); int index = 0; for (int i = comps.length - 1 ;i >= 0; i--) { if (comps[i] == lastParent) { index = i - 1; break; } } while (index >= 0) { tmp2 = comps[index].getBounds(tmp2); if (tmp2.intersects(clip)) return false; index--; } } clip.x += x; clip.y += y; lastParent = parent; } // No Window parent. if (parent == null) return false; return true; }
Example 16
Source File: ObjectBBox.java From Pixie with MIT License | 4 votes |
@Override public boolean contains(Rectangle coordPanelBox, Resize resizeRate) { Rectangle outerBBoxPanel = resizeRate.originalToResized(outerBBox); return outerBBoxPanel.equals(coordPanelBox); }
Example 17
Source File: LizziePane.java From lizzie with GNU General Public License v3.0 | 4 votes |
public void mouseDragged(MouseEvent e) { Window w = (Window) e.getSource(); Point pt = e.getPoint(); if (isMovingWindow) { Point eventLocationOnScreen = e.getLocationOnScreen(); w.setLocation(eventLocationOnScreen.x - dragOffsetX, eventLocationOnScreen.y - dragOffsetY); } else if (dragCursor != 0) { Rectangle r = w.getBounds(); Rectangle startBounds = new Rectangle(r); Dimension min = w.getMinimumSize(); switch (dragCursor) { case Cursor.E_RESIZE_CURSOR: adjust(r, min, 0, 0, pt.x + (dragWidth - dragOffsetX) - r.width, 0); break; case Cursor.S_RESIZE_CURSOR: adjust(r, min, 0, 0, 0, pt.y + (dragHeight - dragOffsetY) - r.height); break; case Cursor.N_RESIZE_CURSOR: adjust(r, min, 0, pt.y - dragOffsetY, 0, -(pt.y - dragOffsetY)); break; case Cursor.W_RESIZE_CURSOR: adjust(r, min, pt.x - dragOffsetX, 0, -(pt.x - dragOffsetX), 0); break; case Cursor.NE_RESIZE_CURSOR: adjust( r, min, 0, pt.y - dragOffsetY, pt.x + (dragWidth - dragOffsetX) - r.width, -(pt.y - dragOffsetY)); break; case Cursor.SE_RESIZE_CURSOR: adjust( r, min, 0, 0, pt.x + (dragWidth - dragOffsetX) - r.width, pt.y + (dragHeight - dragOffsetY) - r.height); break; case Cursor.NW_RESIZE_CURSOR: adjust( r, min, pt.x - dragOffsetX, pt.y - dragOffsetY, -(pt.x - dragOffsetX), -(pt.y - dragOffsetY)); break; case Cursor.SW_RESIZE_CURSOR: adjust( r, min, pt.x - dragOffsetX, 0, -(pt.x - dragOffsetX), pt.y + (dragHeight - dragOffsetY) - r.height); break; default: break; } if (!r.equals(startBounds)) { w.setBounds(r); // Defer repaint/validate on mouseReleased unless dynamic // layout is active. if (Toolkit.getDefaultToolkit().isDynamicLayoutActive()) { w.validate(); getRootPane().repaint(); } } } }
Example 18
Source File: ObjectPolygon.java From Pixie with MIT License | 4 votes |
@Override public boolean contains(Rectangle coordPanelBox, Resize resizeRate) { Rectangle outerBBoxPanel = resizeRate.originalToResized(outerBBox); return outerBBoxPanel.equals(coordPanelBox); }
Example 19
Source File: RenderedImageSrc.java From healthcare-dicom-dicomweb-adapter with Apache License 2.0 | 4 votes |
private void getFromParam() { try { tileWidth = param.getTileWidth(); tileHeight = param.getTileHeight(); tileXOffset = param.getTileGridXOffset(); tileYOffset = param.getTileGridYOffset(); } catch(IllegalStateException e) { param.setTilingMode(param.MODE_EXPLICIT); if (inputIsRaster) { param.setTiling(raster.getWidth(), raster.getHeight(), raster.getMinX(), raster.getMinY()); } else { param.setTiling(src.getWidth(), src.getHeight(), src.getMinX(), src.getMinY()); } tileWidth = param.getTileWidth(); tileHeight = param.getTileHeight(); tileXOffset = param.getTileGridXOffset(); tileYOffset = param.getTileGridYOffset(); } scaleX = param.getSourceXSubsampling(); scaleY = param.getSourceYSubsampling(); xOffset = param.getSubsamplingXOffset(); yOffset = param.getSubsamplingYOffset(); sourceRegion.translate(xOffset, yOffset); sourceRegion.width -= xOffset; sourceRegion.height -= yOffset; xOffset = sourceRegion.x % scaleX; yOffset = sourceRegion.y % scaleY; minX = sourceRegion.x / scaleX; minY = sourceRegion.y / scaleY; w = (sourceRegion.width + scaleX - 1) / scaleX; h = (sourceRegion.height + scaleY - 1) / scaleY; tileXOffset += (minX - tileXOffset)/tileWidth * tileWidth; tileYOffset += (minY - tileYOffset)/tileHeight * tileHeight; destinationRegion = new Rectangle(minX, minY, w, h); if (!destinationRegion.equals(sourceRegion) || tileWidth != sm.getWidth() || tileHeight != sm.getHeight() || (!inputIsRaster && (tileXOffset != src.getTileGridXOffset() || tileYOffset != src.getTileGridYOffset())) || (inputIsRaster && (tileXOffset != raster.getMinX() || tileYOffset != raster.getMinY()))) noTransform = false; }
Example 20
Source File: WindowMouseHandler.java From littleluck with Apache License 2.0 | 2 votes |
public void updateBound(Point pt, Window w) { Rectangle r = w.getBounds(); Rectangle startBounds = new Rectangle(r); Dimension min = w.getMinimumSize(); switch (dragCursor) { case Cursor.E_RESIZE_CURSOR: adjust(r, min, 0, 0, pt.x + (dragWidth - dragOffsetX) - r.width, 0); break; case Cursor.S_RESIZE_CURSOR: adjust(r, min, 0, 0, 0, pt.y + (dragHeight - dragOffsetY) - r.height); break; case Cursor.N_RESIZE_CURSOR: adjust(r, min, 0, pt.y - dragOffsetY, 0, -(pt.y - dragOffsetY)); break; case Cursor.W_RESIZE_CURSOR: adjust(r, min, pt.x - dragOffsetX, 0, -(pt.x - dragOffsetX), 0); break; case Cursor.NE_RESIZE_CURSOR: adjust(r, min, 0, pt.y - dragOffsetY, pt.x + (dragWidth - dragOffsetX) - r.width, -(pt.y - dragOffsetY)); break; case Cursor.SE_RESIZE_CURSOR: adjust(r, min, 0, 0, pt.x + (dragWidth - dragOffsetX) - r.width, pt.y + (dragHeight - dragOffsetY) - r.height); break; case Cursor.NW_RESIZE_CURSOR: adjust(r, min, pt.x - dragOffsetX, pt.y - dragOffsetY, -(pt.x - dragOffsetX), -(pt.y - dragOffsetY)); break; case Cursor.SW_RESIZE_CURSOR: adjust(r, min, pt.x - dragOffsetX, 0, -(pt.x - dragOffsetX), pt.y + (dragHeight - dragOffsetY) - r.height); break; default: break; } if(!r.equals(startBounds)) { w.setBounds(r); if (Toolkit.getDefaultToolkit().isDynamicLayoutActive()) { w.validate(); w.repaint(); } } }