Java Code Examples for java.awt.Rectangle.equals()

The following are Jave code examples for showing how to use equals() of the java.awt.Rectangle class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Pixie   File: GUILabelingTool.java   View Source Code Vote up 6 votes
/**
 * When selecting the scribble object (not one of its crops), the user
 * cannot edit its size by increasing/decreasing options, therefore they are
 * deactivated from the menu.
 *
 * @param selectedObj the object selected by the user
 */
private void disableEditOptScribbleObj(Objects selectedObj) {
    if (selectedObj == null) {
        return;
    }

    // get the box which was selected
    DisplayBBox selectedBox = gc.getdPImgToLabel().getSelectedBox();

    if (selectedBox != null) {
        // convert coordinates to panel coordinates to be able to compare
        Rectangle objBoxPanel = gc.getdPImgToLabel().getResize().originalToResized(selectedObj.getOuterBBox());

        // if the outer box of the obejct and the selection match, it means the scribble object is selected (not a crop)
        if (objBoxPanel.equals(selectedBox.getPanelBox())
                && (((ObjectScribble) selectedObj).getCrop(selectedBox.getPanelBox(), gc.getdPImgToLabel().getResize()) == null)) {
            // the selected object is the scribble obejct itself; disable some edit options
            enableEditButtons(false);
        }
    }
}
 
Example 2
Project: incubator-netbeans   File: TimelineSelectionManager.java   View Source Code Vote up 6 votes
public final void setSelectionBounds(Rectangle selectionBounds) {
    if (selectionBounds == null && this.selectionBounds == null) return;

    normalizeBounds(selectionBounds);

    if (this.selectionBounds != null && this.selectionBounds.equals(selectionBounds) ||
        selectionBounds != null && selectionBounds.equals(this.selectionBounds)) return;

    Rectangle oldSelectionBounds = this.selectionBounds == null ? null :
                                   new Rectangle(this.selectionBounds);

    if (selectionBounds == null) this.selectionBounds = null;
    else if (this.selectionBounds == null) this.selectionBounds = new Rectangle(selectionBounds);
    else this.selectionBounds.setBounds(selectionBounds);

    fireSelectionBoundsChanged(this.selectionBounds, oldSelectionBounds);
}
 
Example 3
Project: incubator-netbeans   File: Central.java   View Source Code Vote up 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 4
Project: incubator-netbeans   File: Central.java   View Source Code Vote up 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 5
Project: incubator-netbeans   File: Central.java   View Source Code Vote up 6 votes
/** Sets editor area bounds into model and requests view (if needed). */
public void setEditorAreaBounds(Rectangle editorAreaBounds) {
    if(editorAreaBounds == null) {
        return;
    }
    
    Rectangle old = getEditorAreaBounds();
    if(old.equals(editorAreaBounds)) {
        return;
    }
    
    model.setEditorAreaBounds(editorAreaBounds);
    
    if(isVisible()) {
        viewRequestor.scheduleRequest(
            new ViewRequest(null, View.CHANGE_EDITOR_AREA_BOUNDS_CHANGED,
                        old, editorAreaBounds));
    }
}
 
Example 6
Project: incubator-netbeans   File: Central.java   View Source Code Vote up 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
Project: rapidminer   File: AnnotationsDecorator.java   View Source Code Vote up 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 8
Project: TrabalhoFinalEDA2   File: mxGraphOutline.java   View Source Code Vote up 6 votes
/**
 * 
 */
public void updateFinderBounds(Rectangle bounds, boolean repaint)
{
	if (bounds != null && !bounds.equals(finderBounds))
	{
		Rectangle old = new Rectangle(finderBounds);
		finderBounds = bounds;

		// LATER: Fix repaint region to be smaller
		if (repaint)
		{
			old = old.union(finderBounds);
			old.grow(3, 3);
			repaint(old);
		}
	}
}
 
Example 9
Project: geomapapp   File: GridImage.java   View Source Code Vote up 6 votes
public void setLandMask( Grid2D.Boolean landMask ) {
	Rectangle maskBounds = landMask.getBounds();
	Rectangle bounds = grid.getBounds();
	if( !maskBounds.equals(bounds) ) return;
	this.landMask = landMask;
	land = false;
	ocean = false;
	for( int y=bounds.y ; y<bounds.y+bounds.height ; y++) {
		for( int x=bounds.x ; x<bounds.x+bounds.width ; x++) {
			if( landMask.booleanValue(x,y) ) {
				land=true;
			} else {
				ocean=true;
			}
			if( land==ocean )return;
		}
	}
}
 
Example 10
Project: Tarski   File: mxGraphHandler.java   View Source Code Vote up 6 votes
/**
 * 
 */
public void setPreviewBounds(Rectangle bounds) {
  if ((bounds == null && previewBounds != null) || (bounds != null && previewBounds == null)
      || (bounds != null && previewBounds != null && !bounds.equals(previewBounds))) {
    Rectangle dirty = null;

    if (isVisible()) {
      dirty = previewBounds;

      if (dirty != null) {
        dirty.add(bounds);
      } else {
        dirty = bounds;
      }
    }

    previewBounds = bounds;

    if (dirty != null) {
      graphComponent.getGraphControl().repaint(dirty.x - 1, dirty.y - 1, dirty.width + 2,
          dirty.height + 2);
    }
  }
}
 
Example 11
Project: openjdk-jdk10   File: Path2DCopyConstructor.java   View Source Code Vote up 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 12
Project: incubator-netbeans   File: ScreenshotComponent.java   View Source Code Vote up 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 13
Project: incubator-netbeans   File: DropGlassPane.java   View Source Code Vote up 5 votes
/** Set drop line. Given line is used by paint method.
 * @param line drop line */
public void setDropLine(Line2D line) {
    if( !isValid() )
        return;
    
    if( null != prevLineRect 
        && ((null != line
            && (!prevLineRect.contains( line.getP1() )
                || !prevLineRect.contains( line.getP2() )))
            || null == line) ) {
        
        repaint( prevLineRect );
    }

    this.line = line;
    Rectangle newLineRect = null;
    if( null != this.line ) {
        checkLineBounds( this.line );
        newLineRect = line.getBounds();
        newLineRect.grow( 5, 5 );
    }
    
    if( null != newLineRect && !newLineRect.equals( prevLineRect ) ) {
        repaint( newLineRect );
    }
    prevLineRect = newLineRect;
}
 
Example 14
Project: incubator-netbeans   File: ChartSelectionManager.java   View Source Code Vote up 5 votes
public final void setSelectionBounds(Rectangle selectionBounds) {
    if (selectionBounds == null && this.selectionBounds == null) return;
    if (this.selectionBounds != null && this.selectionBounds.equals(selectionBounds) ||
        selectionBounds != null && selectionBounds.equals(this.selectionBounds)) return;

    Rectangle oldSelectionBounds = this.selectionBounds == null ? null :
                                   new Rectangle(this.selectionBounds);

    if (selectionBounds == null) this.selectionBounds = null;
    else if (this.selectionBounds == null) this.selectionBounds = new Rectangle(selectionBounds);
    else this.selectionBounds.setBounds(selectionBounds);

    fireSelectionBoundsChanged(this.selectionBounds, oldSelectionBounds);
}
 
Example 15
Project: OpenJSharp   File: XContentWindow.java   View Source Code Vote up 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 16
Project: text-position-detector   File: UniresolutionTextPositionDetector.java   View Source Code Vote up 5 votes
/**
 * Detects text region in an edge map. See Fig6.
 * @param edgeMap The already computed edge map.
 * @return All text regions found in the edge map.
 */
public static List<Rectangle> getRegions(GrayImage edgeMap) {

	List<Rectangle>
		regionsQueue = new LinkedList<>(),
		validRegions = new LinkedList<>(),
		tentativeHorizontalRegions = new LinkedList<>(),
		tentativeVerticalRegions = new LinkedList<>();

	regionsQueue.add(
		new Rectangle(edgeMap.getWidth(), edgeMap.getHeight())
	);

	while (!regionsQueue.isEmpty()) {

		Rectangle region = regionsQueue.remove(0);
		tentativeHorizontalRegions =
			getHorizontalSubRegions(edgeMap, region);

		for (Rectangle hSubRegion : tentativeHorizontalRegions) {

			boolean hIndivisible = hSubRegion.equals(region);
			tentativeVerticalRegions =
				getVerticalSubRegions(edgeMap, hSubRegion, hIndivisible);

			for (Rectangle vSubRegion : tentativeVerticalRegions) {

				// indivisible region
				if (vSubRegion.equals(hSubRegion)) {
					validRegions.add(vSubRegion);
				} else {
					regionsQueue.add(vSubRegion);
				}
			}
		}
	}

	return validRegions;
}
 
Example 17
Project: jdk8u-jdk   File: XContentWindow.java   View Source Code Vote up 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 18
Project: openjdk-jdk10   File: XContentWindow.java   View Source Code Vote up 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()));
        boolean needPaint = width <= 0 || height <= 0;
        reshape(newBounds);
        if (needHandleResize) {
            insLog.fine("Sending RESIZED");
            handleResize(newBounds);
        }
        if (needPaint) {
            postPaintEvent(target, 0, 0, newBounds.width, newBounds.height);
        }
    } finally {
        XToolkit.awtUnlock();
    }
}
 
Example 19
Project: incubator-netbeans   File: BufferedCanvasComponent.java   View Source Code Vote up 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 20
Project: Pixie   File: ObjectBBox.java   View Source Code Vote up 4 votes
@Override
public boolean contains(Rectangle coordPanelBox, Resize resizeRate) {
    Rectangle outerBBoxPanel = resizeRate.originalToResized(outerBBox);

    return outerBBoxPanel.equals(coordPanelBox);
}