Example usage for java.awt Rectangle clone

List of usage examples for java.awt Rectangle clone

Introduction

In this page you can find the example usage for java.awt Rectangle clone.

Prototype

public Object clone() 

Source Link

Document

Creates a new object of the same class and with the same contents as this object.

Usage

From source file:tilt.image.Blob.java

/**
 * Is this blob surrounded by a wide band of white?
 * @param wr the raster to search in//  www  .j  a  v a2  s .c o m
 * @param hStandoff the amount of white horizontal standoff
 * @param vStandoff the amount of vertical white standoff
 * @return true if it is
 */
boolean hasWhiteStandoff(WritableRaster wr, int hStandoff, int vStandoff) {
    // 1. original blob bounds
    Rectangle inner = new Rectangle(topLeft().x, topLeft().y, getWidth(), getHeight());
    Rectangle outer = (Rectangle) inner.clone();
    // 2. outset rect by standoff
    if (outer.x >= hStandoff)
        outer.x -= hStandoff;
    else
        outer.x = 0;
    if (outer.y - vStandoff > 0)
        outer.y -= vStandoff;
    else
        outer.y = 0;
    if (outer.x + outer.width + hStandoff * 2 < wr.getWidth())
        outer.width += hStandoff * 2;
    else
        outer.width = wr.getWidth() - outer.x;
    if (outer.y + outer.height + vStandoff * 2 < wr.getHeight())
        outer.height += vStandoff * 2;
    else
        outer.height = wr.getHeight() - outer.y;
    // 3. test for black pixels in that area
    int[] iArray = new int[1];
    int maxY = outer.y + outer.height;
    int maxX = outer.x + outer.width;
    int nBlacks = 0;
    int maxRogues = opts.getInt(Options.Keys.maxRoguePixels);
    for (int y = outer.y; y < maxY; y++) {
        for (int x = outer.x; x < maxX; x++) {
            Point loc = new Point(x, y);
            if (!inner.contains(loc)) {
                wr.getPixel(x, y, iArray);
                if (iArray[0] == 0) {
                    if (nBlacks == maxRogues) {
                        return false;
                    } else
                        nBlacks++;
                }
            }
        }
    }
    return true;
}

From source file:edu.umd.cfar.lamp.viper.geometry.BoundingBox.java

/**
 * Creates a new bounding box from the given <code>java.awt.Rectangle</code>.
 * //  ww  w . ja va2 s  .  c  o m
 * @param dimensions
 *            the box to use
 */
public BoundingBox(Rectangle dimensions) {
    rect = (Rectangle) dimensions.clone();
}

From source file:de.tor.tribes.ui.panels.MinimapPanel.java

public void setVisiblePart(Rectangle pVisible) {
    visiblePart = (Rectangle) pVisible.clone();
}

From source file:knop.psfj.BeadImage.java

/**
 * Gets the bead max intensity.//from   w ww .ja va2 s  .co  m
 *
 * @param r the r
 * @return the bead max intensity
 */
public double getBeadMaxIntensity(Rectangle r) {

    ImageProcessor middleImage = getMiddleImage();
    middleImage.setRoi((Rectangle) r.clone());
    double max = middleImage.getStatistics().max;
    middleImage.resetRoi();
    return max;
}