Example usage for java.awt Rectangle getMaxX

List of usage examples for java.awt Rectangle getMaxX

Introduction

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

Prototype

public double getMaxX() 

Source Link

Document

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

Usage

From source file:at.knowcenter.wag.egov.egiz.pdfbox2.pdf.PDFPage.java

/**
 * Registers a rectangle that bounds the path currently being drawn.
 * /*from  ww  w .  j a  va2s  . co m*/
 * @param bounds
 *            A rectangle depicting the bounds (coordinates originating from
 *            bottom left).
 * @author Datentechnik Innovation GmbH
 */
public void registerPathBounds(Rectangle bounds) {
    if (!bounds.isEmpty()) {
        logger.debug("Registering path bounds: " + bounds);

        // vertical start of rectangle (counting from top of page)
        float upperBoundYPositionFromTop;

        // vertical end of rectangle (counting from top of page)
        // this depicts the current end of path-related page content
        float lowerBoundYPositionFromTop;

        PDRectangle boundaryBox = this.getCurrentPage().getCropBox();

        if (boundaryBox == null) {
            boundaryBox = this.getCurrentPage().getMediaBox();
        }

        float pageHeight;

        switch (this.getCurrentPage().getRotation()) {
        case 90: // CW
            pageHeight = boundaryBox.getWidth();
            upperBoundYPositionFromTop = (float) bounds.getMinX();
            lowerBoundYPositionFromTop = (float) bounds.getMaxX();
            break;
        case 180:
            pageHeight = boundaryBox.getHeight();
            upperBoundYPositionFromTop = (float) bounds.getMinY();
            lowerBoundYPositionFromTop = (float) bounds.getMaxY();
            break;
        case 270: // CCW
            pageHeight = boundaryBox.getWidth();
            upperBoundYPositionFromTop = pageHeight - (float) bounds.getMaxX();
            lowerBoundYPositionFromTop = pageHeight - (float) bounds.getMinX();
            break;
        default:
            pageHeight = boundaryBox.getHeight();
            upperBoundYPositionFromTop = pageHeight - (float) bounds.getMaxY();
            lowerBoundYPositionFromTop = pageHeight - (float) bounds.getMinY();
            break;
        }

        // new maximum ?
        if (lowerBoundYPositionFromTop > maxPathRelatedYPositionFromTop) {
            // Is the rectangle (at least partly) located above the footer
            // line?
            // (effective page height := page height - footer line)
            if (upperBoundYPositionFromTop <= effectivePageHeight) {
                // yes: update current end of path-related page content
                maxPathRelatedYPositionFromTop = lowerBoundYPositionFromTop;
                logger.trace("New max path related y position (from top): " + maxPathRelatedYPositionFromTop);
            } else {
                // no: rectangle is fully located below the footer line ->
                // ignore
                logger.trace("Ignoring path bound below the footer line.");
            }
        }
    }
}

From source file:de.tor.tribes.ui.windows.DSWorkbenchMainFrame.java

private void refreshMap() {
    //ensure that within map range
    Rectangle mapDim = ServerSettings.getSingleton().getMapDimension();
    if (dCenterX < mapDim.getMinX() || dCenterX > mapDim.getMaxX() || dCenterY < mapDim.getMinY()
            || dCenterY > mapDim.getMaxX()) {
        //find out where we tried to leaf map and set these valuese to max / min
        if (dCenterX < mapDim.getMinX()) {
            dCenterX = (int) mapDim.getMinX();
            jCenterX.setText(Integer.toString((int) dCenterX));
        } else if (dCenterX > mapDim.getMaxX()) {
            dCenterX = (int) mapDim.getMaxX();
            jCenterX.setText(Integer.toString((int) dCenterX));
        }/* www. java 2s.  c o  m*/

        if (dCenterY < mapDim.getMinY()) {
            dCenterY = (int) mapDim.getMinY();
            jCenterY.setText(Integer.toString((int) dCenterY));
        } else if (dCenterY > mapDim.getMaxX()) {
            dCenterY = (int) mapDim.getMaxX();
            jCenterY.setText(Integer.toString((int) dCenterY));
        }
    }

    double w = (double) MapPanel.getSingleton().getWidth() / GlobalOptions.getSkin().getBasicFieldWidth()
            * dZoomFactor;
    double h = (double) MapPanel.getSingleton().getHeight() / GlobalOptions.getSkin().getBasicFieldHeight()
            * dZoomFactor;
    MinimapPanel.getSingleton().setSelection((int) Math.floor(dCenterX), (int) Math.floor(dCenterY),
            (int) Math.rint(w), (int) Math.rint(h));
    MapPanel.getSingleton().updateMapPosition(dCenterX, dCenterY, true);
}

From source file:org.broad.igv.renderer.SpliceJunctionRenderer.java

/**
 * Note:  assumption is that featureList is sorted by pStart position.
 *
 * @param featureList/*w ww .  j  a v  a 2  s . c o m*/
 * @param context
 * @param trackRectangle
 * @param track
 */
@Override
public void render(List<IGVFeature> featureList, RenderContext context, Rectangle trackRectangle, Track track) {

    double origin = context.getOrigin();
    double locScale = context.getScale();

    // TODO -- use enum instead of string "Color"
    if ((featureList != null) && !featureList.isEmpty()) {

        // Create a graphics object to draw font names.  Graphics are not cached
        // by font, only by color, so its neccessary to create a new one to prevent
        // affecting other tracks.
        Font font = FontManager.getFont(track.getFontSize());
        Graphics2D fontGraphics = (Graphics2D) context.getGraphic2DForColor(Color.BLACK).create();

        if (PreferenceManager.getInstance().getAsBoolean(PreferenceManager.ENABLE_ANTIALISING)) {
            fontGraphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                    RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

        }
        fontGraphics.setFont(font);

        //determine whether to show flanking regions
        PreferenceManager prefs = PreferenceManager.getInstance();
        boolean shouldShowFlankingRegions = prefs
                .getAsBoolean(PreferenceManager.SAM_SHOW_JUNCTION_FLANKINGREGIONS);

        // Track coordinates
        double trackRectangleX = trackRectangle.getX();
        double trackRectangleMaxX = trackRectangle.getMaxX();

        SpliceJunctionFeature selectedFeature = (SpliceJunctionFeature) ((FeatureTrack) track)
                .getSelectedFeature();

        // Start of Roche-Tessella modification
        if (track.getAutoScale()) {
            Frequency f = new Frequency();
            List<Integer> scores = new ArrayList<Integer>();

            for (IGVFeature feature : featureList) {
                SpliceJunctionFeature junctionFeature = (SpliceJunctionFeature) feature;
                f.addValue(junctionFeature.getScore());
                scores.add((int) junctionFeature.getScore());
            }

            Collections.sort(scores);
            Collections.reverse(scores);
            for (int s : scores) {
                if (f.getCumPct(s) < 0.99) {
                    maxDepth = s;
                    break;
                }
            }

        }
        // End of Roche-Tessella modification

        for (IGVFeature feature : featureList) {
            SpliceJunctionFeature junctionFeature = (SpliceJunctionFeature) feature;
            //if same junction as selected feature, highlight
            boolean shouldHighlight = false;
            if (selectedFeature != null && selectedFeature.isSameJunction(junctionFeature)) {
                setHighlightFeature(junctionFeature);
                shouldHighlight = true;
            }

            // Get the pStart and pEnd of the entire feature.  at extreme zoom levels the
            // virtual pixel value can be too large for an int, so the computation is
            // done in double precision and cast to an int only when its confirmed its
            // within the field of view.
            int flankingStart = junctionFeature.getStart();
            int flankingEnd = junctionFeature.getEnd();

            int junctionStart = junctionFeature.getJunctionStart();
            int junctionEnd = junctionFeature.getJunctionEnd();

            double virtualPixelStart = Math.round((flankingStart - origin) / locScale);
            double virtualPixelEnd = Math.round((flankingEnd - origin) / locScale);

            double virtualPixelJunctionStart = Math.round((junctionStart - origin) / locScale);
            double virtualPixelJunctionEnd = Math.round((junctionEnd - origin) / locScale);

            // If the any part of the feature fits in the
            // Track rectangle draw it
            if ((virtualPixelEnd >= trackRectangleX) && (virtualPixelStart <= trackRectangleMaxX)) {

                //
                int displayPixelEnd = (int) Math.min(trackRectangleMaxX, virtualPixelEnd);
                int displayPixelStart = (int) Math.max(trackRectangleX, virtualPixelStart);

                float depth = junctionFeature.getJunctionDepth();
                Color color = feature.getColor();

                drawFeature((int) virtualPixelStart, (int) virtualPixelEnd, (int) virtualPixelJunctionStart,
                        (int) virtualPixelJunctionEnd, depth, trackRectangle, context, feature.getStrand(),
                        junctionFeature, shouldHighlight, color, shouldShowFlankingRegions);
            }
        }

        //draw a central horizontal line
        Graphics2D g2D = context.getGraphic2DForColor(COLOR_CENTERLINE);
        g2D.drawLine((int) trackRectangleX, (int) trackRectangle.getCenterY(), (int) trackRectangleMaxX,
                (int) trackRectangle.getCenterY());

    }
}

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

/**
 * Render the features in the supplied rectangle.
 *
 * @param context/*from   w  w  w.j  av a 2  s.  c  om*/
 * @param trackRectangle
 * @param packedFeatures
 */
@Override
protected void renderFeatureImpl(RenderContext context, Rectangle trackRectangle,
        PackedFeatures packedFeatures) {

    Graphics2D g2D = context.getGraphics();

    top = trackRectangle.y;
    Rectangle visibleRectangle = context.getVisibleRect();

    // A disposable rect -- note this gets modified all over the place, bad practice
    Rectangle tmpRect = new Rectangle(trackRectangle);
    tmpRect.height = getGenotypeBandHeight();
    tmpRect.y = trackRectangle.y;

    Rectangle bandRect = new Rectangle(tmpRect);
    bandRect.y += getVariantsHeight();
    drawBackground(g2D, bandRect, visibleRectangle, BackgroundType.DATA);

    List<PackedFeatures.FeatureRow> rows = packedFeatures.getRows();

    int overallFeatureRectHeight = getVariantsHeight();
    int overallSampleRectHeight = trackRectangle.height - overallFeatureRectHeight;
    Rectangle overallSampleRect = new Rectangle(trackRectangle.x, top + overallFeatureRectHeight,
            trackRectangle.width, overallSampleRectHeight);

    int curRowTop = top;

    if (rows.size() > 0) {
        final double locScale = context.getScale();
        final double origin = context.getOrigin();

        final double pXMin = tmpRect.getMinX();
        final double pXMax = tmpRect.getMaxX();
        tmpRect.height = variantBandHeight;

        int lastEndX = -1;
        int minSpacing = 3;
        for (PackedFeatures.FeatureRow row : rows) {
            List<Feature> features = row.getFeatures();
            for (Feature feature : features) {
                Variant variant = (Variant) feature;

                if (hideFiltered && variant.isFiltered()) {
                    continue;
                }

                int start = variant.getStart();
                int end = variant.getEnd();
                int pX = (int) ((start - origin) / locScale);
                int dX = (int) Math.max(2, (end - start) / locScale);

                if (pX + dX < pXMin) {
                    continue;
                }
                if (pX > pXMax) {
                    break;
                }
                int w = dX;
                int x = pX;

                if (w < 3) {
                    w = 3;
                    x--;
                }

                //Make sure we have some whitespace between this
                //feature and the previous one, but only if they don't
                //actually overlap and the current size is reasonably large
                int spacing = x - lastEndX;
                if (spacing > 0 && spacing < minSpacing && w > 2 * minSpacing) {
                    x += minSpacing - spacing;
                }

                tmpRect.y = curRowTop;
                if (tmpRect.intersects(visibleRectangle)) {
                    renderer.renderSiteBand(variant, tmpRect, x, w, context);
                    lastEndX = x + w - 1;
                }

                renderSamples(g2D, visibleRectangle, variant, context, overallSampleRect, x, w);
                boolean isSelected = selectedVariant != null && selectedVariant == variant;
                if (isSelected) {
                    Graphics2D selectionGraphics = context.getGraphic2DForColor(Color.black);
                    selectionGraphics.drawRect(x, curRowTop, w, getHeight());
                }

            }
            if (areFeaturesStacked()) {
                curRowTop += variantBandHeight;
                lastEndX = -1;
            }
        }
    } else {
        tmpRect.height = variantBandHeight;
        tmpRect.y = trackRectangle.y;
        g2D.setColor(Color.gray);
        GraphicUtils.drawCenteredText("No Variants Found", trackRectangle, g2D);
    }

    renderBoundaryLines(g2D, trackRectangle, visibleRectangle);

}

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

/**
 * Renders the top line, bottom track line, and border between variants / genotypes
 *
 * @param g2D//from  w  w w .  j av a 2s  .  co m
 * @param trackRectangle
 * @param visibleRectangle
 */
private void renderBoundaryLines(Graphics2D g2D, Rectangle trackRectangle, Rectangle visibleRectangle) {
    top = trackRectangle.y;
    final int left = trackRectangle.x;
    final int right = (int) trackRectangle.getMaxX();

    //Top line
    drawLineIfVisible(g2D, visibleRectangle, Color.black, top + 1, left, right);

    // Bottom border
    int bottomY = trackRectangle.y + trackRectangle.height;
    drawLineIfVisible(g2D, visibleRectangle, borderGray, bottomY, left, right);

    // Variant / Genotype border
    int variantGenotypeBorderY = trackRectangle.y + getVariantsHeight();
    drawVariantBandBorder(g2D, visibleRectangle, variantGenotypeBorderY, left, right);

    if (grouped) {
        g2D.setColor(Color.black);
        int y = trackRectangle.y + getVariantsHeight();
        for (Map.Entry<String, List<String>> entry : samplesByGroups.entrySet()) {
            y += entry.getValue().size() * getGenotypeBandHeight() + GROUP_BORDER_WIDTH;
            g2D.drawLine(trackRectangle.x, y, trackRectangle.x + trackRectangle.width, y);
        }
    }
}

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//w ww . jav  a 2s. com
 * @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/*  w  w w. j av a2s  .c om*/
 * @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();//  w w w  . ja  v  a 2  s  .  co 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//from  w  w w .  j av  a  2s .co  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 ww . ja v  a 2  s .  c om
    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;
}