Example usage for java.awt Rectangle getMaxY

List of usage examples for java.awt Rectangle getMaxY

Introduction

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

Prototype

public double getMaxY() 

Source Link

Document

Returns the largest Y coordinate of the framing rectangle of the Shape in double precision.

Usage

From source file:org.broad.igv.variant.VariantTrack.java

private void drawLineIfVisible(Graphics2D g2D, Rectangle visibleRectangle, Color color, int yLoc, int left,
        int right) {
    if (yLoc >= visibleRectangle.y && yLoc <= visibleRectangle.getMaxY()) {
        if (color != null)
            g2D.setColor(color);/*from  www  . j  av a  2s . c o  m*/
        g2D.drawLine(left, yLoc, right, yLoc);
    }
}

From source file:org.photovault.dcraw.AHDInterpolateOp.java

/**
 * Conpute a rectangle of destination image using AHD interpolation
 * @param img Array of soruce images (containing just one image in this case
 * @param dst Raster for the results/*from   ww  w .j  av a2s  . c o  m*/
 * @param area Area of dst that needs to be computed
 */
private void computeRectAHD(PlanarImage[] img, WritableRaster dst, Rectangle area) {
    log.debug("entry: computeAHD " + area);
    long entryTime = System.currentTimeMillis();

    // RandomIterFactory.create( img[0], area);
    int minx = Math.max((int) area.getMinX() - 3, 0);
    int miny = Math.max((int) area.getMinY() - 3, 0);
    int maxx = Math.min((int) area.getMaxX() + 3, getWidth() - 1);
    int maxy = Math.min((int) area.getMaxY() + 3, getHeight() - 1);
    Rectangle enlargedArea = new Rectangle(minx, miny, maxx - minx + 1, maxy - miny + 1);
    int[][][][] rgb = new int[2][(int) enlargedArea.getWidth()][(int) enlargedArea.getHeight()][3];
    int[][][][] lab = new int[2][(int) enlargedArea.getWidth()][(int) enlargedArea.getHeight()][3];
    byte[][][] homo = new byte[2][(int) enlargedArea.getWidth()][(int) enlargedArea.getHeight()];

    RandomIter riter = RandomIterFactory.create(img[0], enlargedArea);

    double xyz[] = new double[3];
    // Copy the data to temp array
    for (int y = 0; y < maxy - miny; y++) {
        for (int x = 0; x < maxx - minx; x++) {
            int color = fc(y + miny, x + minx);
            if (color == 3)
                color = 1;
            rgb[0][x][y][color] = rgb[1][x][y][color] = (int) (mult[color]
                    * riter.getSample(x + minx, y + miny, 0));

        }
    }

    // Interpolate green
    for (int y = 2; y < maxy - miny - 2; y++) {
        int firstColor = fc(y + miny, minx + 3);
        int startCol = minx + 3 - (firstColor % 2);
        for (int x = startCol - minx; x < maxx - minx - 2; x += 2) {
            int c = fc(y + miny, x + minx);
            if (c == 3) {
                c = 1;
            }
            int tc = rgb[0][x][y][c];
            int eg = rgb[0][x - 1][y][1];
            int wg = rgb[0][x + 1][y][1];
            int sg = rgb[0][x][y + 1][1];
            int ng = rgb[0][x][y - 1][1];
            int ec = rgb[0][x - 2][y][c];
            int wc = rgb[0][x + 2][y][c];
            int sc = rgb[0][x][y + 2][c];
            int nc = rgb[0][x][y - 2][c];

            // Horizonally
            int green = 2 * (wg + tc + eg) - (wc + ec);
            green >>= 2;
            if (green < 0)
                green = 0;
            rgb[0][x][y][1] = green;
            // Vertically
            green = 2 * (ng + tc + sg) - (nc + sc);
            green >>= 2;
            if (green < 0)
                green = 0;
            rgb[1][x][y][1] = green;
        }
    }
    // Interpolate R & B
    for (int dir = 0; dir < 2; dir++) {
        for (int y = 3; y < maxy - miny - 3; y++) {
            for (int x = 3; x < maxx - minx - 3; x++) {
                int color = fc(y + miny, x + minx);
                if (color == 1 || color == 3) {
                    // We need to interpolate both red and blue
                    int c = fc(y + 1 + miny, x + minx);
                    int tg = rgb[dir][x][y][1];
                    int ng = rgb[dir][x][y - 1][1];
                    int sg = rgb[dir][x][y + 1][1];
                    int eg = rgb[dir][x + 1][y][1];
                    int wg = rgb[dir][x - 1][y][1];
                    int nc = rgb[dir][x][y - 1][c];
                    int sc = rgb[dir][x][y + 1][c];
                    int wo = rgb[dir][x - 1][y][2 - c];
                    int eo = rgb[dir][x + 1][y][2 - c];
                    int val = tg + ((wo + eo - ng - sg) >> 1);
                    if (val < 0)
                        val = 0;
                    rgb[dir][x][y][2 - c] = val;
                    val = tg + ((nc + sc - ng - sg) >> 1);
                    if (val < 0)
                        val = 0;
                    rgb[dir][x][y][c] = val;
                } else {
                    /*
                    This pixel is either red or blue so only one of those needs
                    to be interpolated
                     */
                    int c = 2 - color;
                    int tg = rgb[dir][x][y][1];
                    int nwg = rgb[dir][x - 1][y - 1][1];
                    int seg = rgb[dir][x + 1][y + 1][1];
                    int swg = rgb[dir][x - 1][y + 1][1];
                    int neg = rgb[dir][x + 1][y - 1][1];
                    int nwc = rgb[dir][x - 1][y - 1][c];
                    int nec = rgb[dir][x + 1][y - 1][c];
                    int swc = rgb[dir][x - 1][y + 1][c];
                    int sec = rgb[dir][x + 1][y + 1][c];
                    int val = tg + ((nwc + nec + sec + swc - nwg - neg - swg - seg) >> 2);
                    if (val < 0)
                        val = 0;
                    rgb[dir][x][y][c] = val;
                }
                xyz[0] = xyz[1] = xyz[2] = 0.5;
                // Convert to cielab
                for (int i = 0; i < 3; i++) {
                    xyz[0] += xyz_cam[0][i] * rgb[dir][x][y][i];
                    xyz[1] += xyz_cam[1][i] * rgb[dir][x][y][i];
                    xyz[2] += xyz_cam[2][i] * rgb[dir][x][y][i];
                }
                xyz[0] = cbrt[Math.max(0, (int) Math.min(xyz[0], 65535.0))];
                xyz[1] = cbrt[Math.max(0, (int) Math.min(xyz[1], 65535.0))];
                xyz[2] = cbrt[Math.max(0, (int) Math.min(xyz[2], 65535.0))];
                lab[dir][x][y][0] = Math.max(0, (int) (64.0 * (116.0 * xyz[1] - 16.0)));
                lab[dir][x][y][1] = 0x8000 + 10 * (int) (64.0 * 500.0 * (xyz[0] - xyz[1]));
                lab[dir][x][y][2] = 0x8000 + 10 * (int) (64.0 * 200.0 * (xyz[1] - xyz[2]));
            }
        }
    }

    // Calculate the homogeneity maps
    int ldiff[][] = new int[2][4];
    int abdiff[][] = new int[2][4];
    int dx[] = { -1, 1, 0, 0 };
    int dy[] = { 0, 0, -1, 1 };
    for (int y = 2; y < maxy - miny - 2; y++) {
        for (int x = 2; x < maxx - minx - 2; x++) {
            for (int d = 0; d < 2; d++) {
                for (int i = 0; i < 4; i++) {
                    ldiff[d][i] = Math.abs(lab[d][x][y][0] - lab[d][x + dx[i]][y + dy[i]][0]);
                    int da = lab[d][x][y][1] - lab[d][x + dx[i]][y + dy[i]][1];
                    int db = lab[d][x][y][1] - lab[d][x + dx[i]][y + dy[i]][1];
                    abdiff[d][i] = da * da + db * db;
                }
            }
            int leps = Math.min(Math.max(ldiff[0][0], ldiff[0][1]), Math.max(ldiff[1][2], ldiff[1][3]));
            int abeps = Math.min(Math.max(abdiff[0][0], abdiff[0][1]), Math.max(abdiff[1][2], abdiff[1][3]));
            for (int d = 0; d < 2; d++) {
                for (int i = 0; i < 4; i++) {
                    if (ldiff[d][i] <= leps && abdiff[d][i] <= abeps) {
                        homo[d][x][y]++;
                    }
                }
            }
        }
    }

    int dstMinx = Math.max((int) area.getMinX(), 5);
    int dstMiny = Math.max((int) area.getMinY(), 5);
    int dstMaxy = Math.min((int) area.getMaxY(), getHeight() - 5);
    int dstMaxx = Math.min((int) area.getMaxX(), getWidth() - 5);
    for (int row = dstMiny; row < dstMaxy; row++) {
        for (int col = dstMinx; col < dstMaxx; col++) {
            int hm0 = 0, hm1 = 0;
            for (int i = row - miny - 1; i <= row - miny + 1; i++) {
                for (int j = col - minx - 1; j <= col - minx + 1; j++) {
                    hm0 += homo[0][j][i];
                    hm1 += homo[1][j][i];
                }
            }
            if (hm0 < hm1) {
                dst.setPixel(col, row, rgb[1][col - minx][row - miny]);
            } else if (hm0 > hm1) {
                dst.setPixel(col, row, rgb[0][col - minx][row - miny]);
            } else {
                for (int i = 0; i < 3; i++) {
                    rgb[0][col - minx][row - miny][i] += rgb[1][col - minx][row - miny][i];
                    rgb[0][col - minx][row - miny][i] /= 2;
                }
                dst.setPixel(col, row, rgb[0][col - minx][row - miny]);
            }
        }
    }
    long dur = System.currentTimeMillis() - entryTime;
    log.debug("exit: computeRectAHD in " + dur + "ms");
}

From source file:org.photovault.dcraw.AHDInterpolateOp.java

/**
 * Compute a rectangle of destination image by downsampling original
 * @param img Array of soruce images (containing just one image in this case
 * @param dst Raster for the results//  ww w. j av  a 2s.co  m
 * @param area Area of dst that needs to be computed
 */
private void computeDownsample(PlanarImage[] img, WritableRaster dst, Rectangle area) {
    log.debug("entry: computeDownsample " + area);
    long entryTime = System.currentTimeMillis();

    // Current line of image
    int rgb[][] = new int[(int) area.getWidth()][3];
    int sampleCount[][] = new int[(int) area.getWidth()][3];

    Rectangle srcArea = mapDestRect(area, 0);
    int srcMinx = (int) srcArea.getMinX();
    int srcMaxx = (int) srcArea.getMaxX();
    int srcMiny = (int) srcArea.getMinY();
    int srcMaxy = (int) srcArea.getMaxY();
    int dstY = (int) area.getMinY();
    int dstMinx = (int) area.getMinX();
    int sampleY = 0;
    RandomIter riter = RandomIterFactory.create(img[0], srcArea);

    for (int y = srcMiny; y < srcMaxy; y++) {
        int sampleX = 0;
        int dstX = 0;
        for (int x = srcMinx; x < srcMaxx; x++) {
            int val = riter.getSample(x, y, 0);
            int color = fc(y, x);
            color = (color == 3) ? 1 : color;
            rgb[dstX][color] += val;
            sampleCount[dstX][color]++;
            sampleX++;
            if (sampleX >= downSample) {
                dstX++;
                sampleX = 0;
            }
        }
        sampleY++;
        if (sampleY >= downSample) {
            for (int x = 0; x < rgb.length; x++) {
                for (int c = 0; c < 3; c++) {
                    int count = sampleCount[x][c];
                    if (count == 0) {
                        throw new IllegalStateException("zero samples for color component");
                    }
                    rgb[x][c] /= count;
                    rgb[x][c] = (int) (rgb[x][c] * mult[c]);
                }
                dst.setPixel(dstMinx + x, dstY, rgb[x]);
            }
            for (int x = 0; x < rgb.length; x++) {
                for (int c = 0; c < 3; c++) {
                    rgb[x][c] = 0;
                    sampleCount[x][c] = 0;
                }
            }
            sampleY = 0;
            dstY++;
        }
    }
    long dur = System.currentTimeMillis() - entryTime;
    log.debug("exit: computeDownsample in " + dur + "ms");
}

From source file:org.photovault.dcraw.DCRawReaderOp.java

@Override
protected void computeRect(PlanarImage[] srcs, WritableRaster dst, Rectangle area) {
    log.debug("entry: computeRect " + area);
    checkDataUnpacked();//from  ww w.jav  a2 s .c o  m
    int[] intVals = new int[1];
    for (int row = (int) area.getMinY(); row < area.getMaxY(); row++) {
        int py = row / 2;
        for (int col = (int) area.getMinX(); col < area.getMaxX(); col++) {
            int px = col / 2;
            int color = fc(row, col);
            intVals[0] = lrd.image.getChar(8 * (py * lrd.sizes.iwidth + px) + 2 * color) - black;
            if (intVals[0] < 0)
                intVals[0] = 0;
            dst.setPixel(col, row, intVals);
        }
    }
    log.debug("exit: computeRect" + area);
}

From source file:org.uva.itast.blended.omr.pages.PageImage.java

/**
 * @param templateRectPx/*www .  jav  a 2 s  . c  o m*/
 * @return
 */
public Rectangle2D toMilimeters(Rectangle boxPx) {
    Point2D p1 = toMilimeters(boxPx.x, boxPx.y);
    Point2D p2 = toMilimeters((int) boxPx.getMaxX(), (int) boxPx.getMaxY());
    Rectangle2D bbox = new Rectangle();
    bbox.setFrameFromDiagonal(p1, p2);

    return bbox;
}

From source file:ru.runa.wfe.graph.image.figure.AbstractFigure.java

public Line createBorderLine(AngleInfo angle) {
    Line line = null;/*from  w  w w .  ja v a  2s. co m*/
    Rectangle r = getRectangle();

    switch (angle.getQuarter()) {
    case AngleInfo.QUARTER_I:
        line = LineUtils.createLine(new Point((int) r.getMaxX(), (int) r.getMinY()),
                new Point((int) r.getMaxX(), (int) r.getMaxY()));
        break;
    case AngleInfo.QUARTER_II:
        line = LineUtils.createLine(new Point((int) r.getMinX(), (int) r.getMinY()),
                new Point((int) r.getMaxX(), (int) r.getMinY()));
        break;
    case AngleInfo.QUARTER_III:
        line = LineUtils.createLine(new Point((int) r.getMinX(), (int) r.getMinY()),
                new Point((int) r.getMinX(), (int) r.getMaxY()));
        break;
    case AngleInfo.QUARTER_IV:
        line = LineUtils.createLine(new Point((int) r.getMinX(), (int) r.getMaxY()),
                new Point((int) r.getMaxX(), (int) r.getMaxY()));
        break;
    }
    return line;
}