java.awt.Rectangle#equals ( )源码实例Demo

下面列出了java.awt.Rectangle#equals ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

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.");
}
 
源代码2 项目: openjdk-jdk9   文件: Path2DCopyConstructor.java
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.");
}
 
源代码3 项目: dragonwell8_jdk   文件: Path2DCopyConstructor.java
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.");
}
 
源代码4 项目: jdk8u_jdk   文件: Path2DCopyConstructor.java
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.");
}
 
源代码5 项目: netbeans   文件: Central.java
/** 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));
    }
}
 
源代码6 项目: netbeans   文件: Central.java
/** 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));
    }
}
 
源代码7 项目: netbeans   文件: Central.java
/** 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);
}
 
源代码8 项目: rapidminer-studio   文件: AnnotationsDecorator.java
/**
 * 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);
	}
}
 
源代码9 项目: dragonwell8_jdk   文件: XContentWindow.java
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();
}
 
源代码10 项目: openjdk-jdk8u-backup   文件: XContentWindow.java
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();
}
 
源代码11 项目: jdk8u60   文件: XContentWindow.java
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();
}
 
源代码12 项目: openjdk-jdk8u   文件: XContentWindow.java
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();
}
 
源代码13 项目: netbeans   文件: ScreenshotComponent.java
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);
    }
}
 
源代码14 项目: seaglass   文件: SeaGlassRootPaneUI.java
/**
 * @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();
            }
        }
    }
}
 
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;

   }
 
源代码16 项目: Pixie   文件: ObjectPolygon.java
@Override
public boolean contains(Rectangle coordPanelBox, Resize resizeRate) {
    Rectangle outerBBoxPanel = resizeRate.originalToResized(outerBBox);

    return outerBBoxPanel.equals(coordPanelBox);
}
 
源代码17 项目: lizzie   文件: LizziePane.java
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();
      }
    }
  }
}
 
源代码18 项目: Pixie   文件: ObjectBBox.java
@Override
public boolean contains(Rectangle coordPanelBox, Resize resizeRate) {
    Rectangle outerBBoxPanel = resizeRate.originalToResized(outerBBox);

    return outerBBoxPanel.equals(coordPanelBox);
}
 
源代码19 项目: netbeans   文件: BufferedCanvasComponent.java
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;
    }
 
源代码20 项目: littleluck   文件: WindowMouseHandler.java
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();
        }
    }
}