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:Main.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.add(new JPanel() {
        @Override//w  ww .j ava 2s  . c  om
        public Dimension getPreferredSize() {
            return new Dimension(320, 240);
        }

    });
    f.pack();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice defaultScreen = ge.getDefaultScreenDevice();
    Rectangle rect = defaultScreen.getDefaultConfiguration().getBounds();
    int x = (int) rect.getMaxX() - f.getWidth();
    int y = (int) rect.getMaxY() - f.getHeight();
    f.setLocation(x, y);
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.add(new JPanel() {
        @Override/*from   w  w  w . ja  v a  2 s .  c  om*/
        public Dimension getPreferredSize() {
            return new Dimension(320, 240);
        }

    });
    f.pack();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice defaultScreen = ge.getDefaultScreenDevice();
    Rectangle rect = defaultScreen.getDefaultConfiguration().getBounds();
    int x = (int) rect.getMaxX() - f.getWidth();
    int y = 0;
    f.setLocation(x, y);
    f.setVisible(true);

}

From source file:edu.umn.cs.spatialHadoop.core.ZCurvePartitioner.java

public static Rectangle getMBR(Rectangle mbr, long zMin, long zMax) {
    java.awt.Rectangle mbrInteger = getMBRInteger(zMin, zMax);
    Rectangle trueMBR = new Rectangle();
    trueMBR.x1 = (double) (mbrInteger.x) * mbr.getWidth() / Resolution + mbr.x1;
    trueMBR.y1 = (double) (mbrInteger.y) * mbr.getHeight() / Resolution + mbr.y1;
    trueMBR.x2 = (double) (mbrInteger.getMaxX()) * mbr.getWidth() / Resolution + mbr.x1;
    trueMBR.y2 = (double) (mbrInteger.getMaxY()) * mbr.getHeight() / Resolution + mbr.y1;
    return trueMBR;
}

From source file:ec.util.chart.swing.JTimeSeriesRendererSupport.java

private static Rectangle2D createHotspot(Rectangle bounds, double x, double y, double xOffset,
        Size2D blockSize) {/*from w w w .  j a va  2s .  co  m*/
    double xx = (x + xOffset + blockSize.width < bounds.getMaxX()) ? (x + xOffset)
            : (x - xOffset - blockSize.width);
    double halfHeight = blockSize.height / 2;
    double yy = (y - halfHeight < bounds.getMinY()) ? (bounds.getMinY())
            : (y + halfHeight > bounds.getMaxY()) ? (bounds.getMaxY() - blockSize.height) : (y - halfHeight);
    return new Rectangle2D.Double(xx, yy, blockSize.width, blockSize.height);
}

From source file:CopyAreaPerformance.java

protected void paintComponent(Graphics g) {
    long startTime = System.nanoTime();
    // prevVX is set to -10000 when first enabled
    if (useCopyArea && prevVX > -9999) {
        // Most of this code determines the proper areas to copy and clip
        int scrollX = viewX - prevVX;
        int scrollY = viewY - prevVY;
        int copyFromY, copyFromX;
        int clipFromY, clipFromX;
        if (scrollX == 0) {
            // vertical scroll
            if (scrollY < 0) {
                copyFromY = 0;/* w  w w .j a v  a  2s .  co  m*/
                clipFromY = 0;
            } else {
                copyFromY = scrollY;
                clipFromY = getHeight() - scrollY;
            }
            // copy the old content, set the clip to the new area
            g.copyArea(0, copyFromY, getWidth(), getHeight() - Math.abs(scrollY), 0, -scrollY);
            g.setClip(0, clipFromY, getWidth(), Math.abs(scrollY));
        } else {
            // horizontal scroll
            if (scrollX < 0) {
                copyFromX = 0;
                clipFromX = 0;
            } else {
                copyFromX = scrollX;
                clipFromX = getWidth() - scrollX;
            }
            // copy the old content, set the clip to the new area
            g.copyArea(copyFromX, 0, getWidth() - Math.abs(scrollX), getHeight(), -scrollX, 0);
            g.setClip(clipFromX, 0, Math.abs(scrollX), getHeight());
        }
    }
    // Track previous view position for next scrolling operation
    prevVX = viewX;
    prevVY = viewY;
    // Get the clip in case we need it later
    Rectangle clipRect = g.getClip().getBounds();
    int clipL = (int) (clipRect.getX());
    int clipT = (int) (clipRect.getY());
    int clipR = (int) (clipRect.getMaxX());
    int clipB = (int) (clipRect.getMaxY());
    g.setColor(Color.WHITE);
    g.fillRect(clipL, clipT, (int) clipRect.getWidth(), (int) clipRect.getHeight());
    for (int column = 0; column < 256; ++column) {
        int x = column * (SMILEY_SIZE + PADDING) - viewX;
        if (useClip) {
            if (x > clipR || (x + (SMILEY_SIZE + PADDING)) < clipL) {
                // trivial reject; outside to the left or right
                continue;
            }
        }
        for (int row = 0; row < 256; ++row) {
            int y = row * (SMILEY_SIZE + PADDING) - viewY;
            if (useClip) {
                if (y > clipB || (y + (SMILEY_SIZE + PADDING)) < clipT) {
                    // trivial reject; outside to the top or bottom
                    continue;
                }
            }
            Color faceColor = new Color(column, row, 0);
            drawSmiley(g, faceColor, x, y);
        }
    }
    long stopTime = System.nanoTime();
    System.out.println("Painted in " + ((stopTime - startTime) / 1000000) + " ms");
}

From source file:simulador.controle.GeradorGraficos.java

private Map<Float, Float> obterValoresCelulasRadial(Point pontoInicial, Point pontoFinal) {

    if (DEBUG) {//  ww  w  . j ava  2 s. co  m
        System.out.println("GeradorGraficos.obterValoresCelulasRadial");
    }

    // System.out.println("pontoInicial: ("+pontoInicial.x+", "+pontoInicial.y+")");
    // System.out.println("pontoFinal: ("+pontoFinal.x+", "+pontoFinal.y+")");
    float distanciaMaxPixels = (float) new Point(0, 0)
            .distance(new Point(painelDesign.getImagem().getWidth(), painelDesign.getImagem().getHeight()));
    float distanciaMaxMetros = (float) new Point2D.Float(0, 0)
            .distance(new Point2D.Float(ambiente.getLargura(), ambiente.getComprimento()));

    Map<Float, Float> valoresCelulasRadial = new HashMap();

    Line2D radial = new Line2D.Float(pontoInicial, pontoFinal);
    Rectangle boxRadial = radial.getBounds();

    int[] celRadialIncial = painelDesign.buscarCelula(new Point(boxRadial.x, boxRadial.y));
    int[] celRadialFinal = painelDesign
            .buscarCelula(new Point((int) boxRadial.getMaxX(), (int) boxRadial.getMaxY()));

    // System.out.println("celRadialInicial["+celRadialIncial[0]+"]["+celRadialIncial[1]+"]");
    // System.out.println("celRadialFinal["+celRadialFinal[0]+"]["+celRadialFinal[1]+"]");

    int linIncialRadial = celRadialIncial[0];
    int colIncialRadial = celRadialIncial[1];
    int linFinalRadial = celRadialFinal[0];
    int colFinalRadial = celRadialFinal[1];

    int[] coordCelPontoInicial = painelDesign.buscarCelula(pontoInicial);
    PainelDesign.Celula celPontoInicial = painelDesign.getMatrizCelulas().get(coordCelPontoInicial[0])
            .get(coordCelPontoInicial[1]);

    for (int i = linIncialRadial; i <= linFinalRadial; i++) {
        for (int j = colIncialRadial; j <= colFinalRadial; j++) {

            PainelDesign.Celula cel = painelDesign.getMatrizCelulas().get(i).get(j);

            //System.out.println("cel["+i+"]["+j+"]  interceptada ?");

            if (radial.intersects(cel)) {

                float distanciaPontosPixels = (float) new Point(celPontoInicial.x, celPontoInicial.y)
                        .distance(new Point(cel.x, cel.y));
                float distanciaPontosMetros = (float) ControladorDesign
                        .converterCoordenadas(distanciaPontosPixels, distanciaMaxPixels, distanciaMaxMetros);

                //System.out.println("sim");
                // System.out.println("potencia: "+cel.obterValor("potencia"));
                // System.out.println("distancia: "+distanciaPontosMetros);

                //cel.setCorFundoRGB(Color.BLUE.getRGB());

                valoresCelulasRadial.put(distanciaPontosMetros, //cel.obterValor("distancia"),
                        cel.obterValor("potencia"));

            }

        }
    }

    return valoresCelulasRadial;

}

From source file:com.projity.pm.graphic.gantt.GanttRenderer.java

public void updateShapes(ListIterator nodeIterator) {

    Rectangle bounds = ((GanttParams) graphInfo).getGanttBounds();
    CoordinatesConverter coord = ((GanttParams) graphInfo).getCoord();
    if (coord == null)
        return;//from   w  w w.  j  av  a  2s .c  o m
    double rowHeight = ((GanttParams) graphInfo).getRowHeight();

    int i0 = (int) Math.floor(bounds.getY() / rowHeight);
    int i1 = (int) Math.ceil(bounds.getMaxY() / rowHeight);
    double t0 = coord.toTime(bounds.getX());
    double t1 = coord.toTime(bounds.getMaxX());

    GraphicNode node;
    for (ListIterator i = nodeIterator; i.hasNext();) {
        node = (GraphicNode) i.next();
        node.setRow(i.previousIndex());
        if (i.previousIndex() >= i0 && i.previousIndex() < i1) {
            if (!node.isVoid())
                updateShape(node);
        }
    }
}

From source file:de.tor.tribes.ui.views.DSWorkbenchSelectionFrame.java

private void firePerformRegionSelectionEvent(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_firePerformRegionSelectionEvent
    if (evt.getSource() == jPerformSelection) {
        Point start = new Point((Integer) jStartX.getValue(), (Integer) jStartY.getValue());
        Point end = new Point((Integer) jEndX.getValue(), (Integer) jEndY.getValue());
        Rectangle mapDim = ServerSettings.getSingleton().getMapDimension();

        if (start.x < mapDim.getMinX() || start.x > mapDim.getMaxX() || start.y < mapDim.getMinY()
                || start.y > mapDim.getMaxY() || end.x < mapDim.getMinX() || end.x > mapDim.getMaxX()
                || end.y < mapDim.getMinY() || end.y > mapDim.getMaxY()) {
            showError("Ungltiger Start- oder Endpunkt");
        } else if ((Math.abs(end.x - start.x) * (end.y - start.y)) > 30000) {
            showError("<html>Die angegebene Auswahl k&ouml;nnte mehr als 10.000 D&ouml;rfer umfassen.<br/>"
                    + "Die Auswahl k&ouml;nnte so sehr lange dauern. Bitte verkleinere den gew&auml;hlten Bereich.");
        } else {//from w  ww . j a v  a2s .  c  om
            List<Village> selection = DataHolder.getSingleton().getVillagesInRegion(start, end);
            addVillages(selection);
        }
    }

    jRegionSelectDialog.setVisible(false);
}

From source file:com.projity.pm.graphic.gantt.GanttRenderer.java

public void paintNonWorkingDays(Graphics2D g2, Rectangle bounds) {
    BarFormat calFormat = getCalendarFormat();
    if (calFormat == null)
        return;/*w ww. ja  v  a 2 s  .c o  m*/
    //non working days
    Color oldColor = g2.getColor();
    Paint oldPaint = g2.getPaint();
    CoordinatesConverter coord = ((GanttParams) graphInfo).getCoord();
    Project project = coord.getProject();
    WorkingCalendar wc = (WorkingCalendar) project.getWorkCalendar();

    if (coord.getTimescaleManager().isShowWholeDays()) {
        boolean useScale2 = coord.getTimescaleManager().getCurrentScaleIndex() == 0; //valid only for current time scales
        TimeIterator i = coord.getTimeIterator(bounds.getX(), bounds.getMaxX(), useScale2);
        long startNonworking = -1L, endNonWorking = -1L;
        Calendar cal = DateTime.calendarInstance();

        PredefinedPaint paint = (PredefinedPaint) calFormat.getMiddle().getPaint();//new PredefinedPaint(PredefinedPaint.DOT_LINE,Colors.VERY_LIGHT_GRAY,Color.WHITE);
        paint.applyPaint(g2, useTextures());
        while (i.hasNext()) {
            TimeInterval interval = i.next();
            long s = interval.getStart();
            if (CalendarService.getInstance().getDay(wc, s).isWorking()) {
                if (startNonworking != -1L) {
                    drawNonWorking(g2, startNonworking, endNonWorking, cal, coord, bounds, useScale2);
                    startNonworking = endNonWorking = -1L;
                }
            } else {
                if (startNonworking == -1L)
                    startNonworking = s;
                endNonWorking = s;

            }
        }
        if (startNonworking != -1L) {
            drawNonWorking(g2, startNonworking, endNonWorking, cal, coord, bounds, useScale2);
            startNonworking = endNonWorking = -1L;
        }
    }

    if (container != null) {
        //scale2 separation lines
        TimeIterator i = coord.getTimeIterator(bounds.getX(), bounds.getMaxX(), true);
        g2.setPaint(new PredefinedPaint(PredefinedPaint.DOT_LINE2, Color.GRAY, g2.getBackground()));
        while (i.hasNext()) {
            TimeInterval interval = i.next();
            int startX = (int) Math.round(coord.toX(interval.getStart()));
            g2.drawLine(startX, bounds.y, startX, bounds.y + bounds.height);
        }

        //project start
        int projectStartX = (int) Math.round(coord.toX(project.getStart()));
        if (projectStartX >= bounds.getX() && projectStartX <= bounds.getMaxX()) {
            g2.setPaint(new PredefinedPaint(PredefinedPaint.DASH_LINE, Color.GRAY, g2.getBackground()));
            g2.drawLine(projectStartX, bounds.y, projectStartX, bounds.y + bounds.height);
        }

        //project start
        long statusDate = project.getStatusDate();
        if (statusDate != 0) {
            int statusDateX = (int) Math.round(coord.toX(statusDate));
            if (statusDateX >= bounds.getX() && statusDateX <= bounds.getMaxX()) {
                g2.setPaint(new PredefinedPaint(PredefinedPaint.DOT_LINE2, Color.GREEN, g2.getBackground()));
                g2.drawLine(statusDateX, bounds.y, statusDateX, bounds.y + bounds.height);
            }
        }

        if (oldColor != null)
            g2.setColor(oldColor);
        if (oldPaint != null)
            g2.setPaint(oldPaint);

    }
}

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

/**
 * Registers a rectangle that bounds the path currently being drawn.
 * /*from   w  w  w. ja  va  2s .  c  om*/
 * @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().findCropBox();

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

        float pageHeight;

        switch (this.getCurrentPage().findRotation()) {
        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.");
            }
        }
    }
}