List of usage examples for java.awt Rectangle getMaxY
public double getMaxY()
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); f.add(new JPanel() { @Override//from w ww. ja v a 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: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 av a 2s .c o 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 .jav a 2s . c o 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) {//from w w w .j a v a2s. 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;// w w w . j a v 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önnte mehr als 10.000 Dörfer umfassen.<br/>" + "Die Auswahl könnte so sehr lange dauern. Bitte verkleinere den gewählten Bereich."); } else {/*w ww . ja v a 2 s. co m*/ 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 paint(Graphics g, Rectangle visibleBounds) { Graphics2D g2 = (Graphics2D) g; //CoordinatesConverter coord=((GanttParams)graphInfo).getCoord(); Rectangle clipBounds = g2.getClipBounds(); Rectangle svgClip = clipBounds; if (clipBounds == null) { clipBounds = ((GanttParams) getGraphInfo()).getGanttBounds(); //start at O,O because it's already translated if (visibleBounds == null) clipBounds = new Rectangle(0, 1, clipBounds.width, clipBounds.height - 2);//1 pixel offset needed for edge // else clipBounds=new Rectangle(visibleBounds.x-clipBounds.x,visibleBounds.y-clipBounds.y,visibleBounds.width,visibleBounds.height); else {//from www . j a va 2s. com clipBounds = visibleBounds; g2.setClip(clipBounds); } } paintNonWorkingDays(g2, clipBounds); //Modif for offline graphics double rowHeight = ((GanttParams) graphInfo).getRowHeight(); int i0 = (int) Math.floor(clipBounds.getY() / rowHeight); int i1; if (visibleBounds == null) i1 = (int) Math.ceil(clipBounds.getMaxY() / rowHeight); else i1 = (int) Math.floor(clipBounds.getMaxY() / rowHeight); //double t0=coord.toTime(clipBounds.getX()); //double t1=coord.toTime(clipBounds.getMaxX()); nodeList.clear(); GraphicNode node; // for (ListIterator i=graph.getModel().getNodeIterator(i0);i.hasNext()&&i.nextIndex()<=i1;){ // node=(GraphicNode)i.next(); // if (!node.isSchedule()) continue; // nodeList.add(node); // node.setRow(i.previousIndex()); // paintNode(g2,node,true); // } //Because row not initialized for some nodes NodeModelCache cache = graphInfo.getCache(); for (ListIterator i = cache.getIterator(); i.hasNext();) { node = (GraphicNode) i.next(); node.setRow(i.previousIndex()); if (i.previousIndex() >= i0 && i.previousIndex() < i1) { if (!node.isSchedule()) continue; nodeList.add(node); paintAnnotation(g2, node); paintNode(g2, node, true); paintHorizontalLine(g2, node); } } GraphicDependency dependency; for (Iterator i = cache.getEdgesIterator(); i.hasNext();) { dependency = (GraphicDependency) i.next(); //if (nodeList.contains(dependency.getPredecessor())||nodeList.contains(dependency.getSuccessor())) paintLink(g2, dependency); } for (ListIterator i = nodeList.listIterator(); i.hasNext();) { node = (GraphicNode) i.next(); paintNode(g2, node, false); } if (visibleBounds != null) g2.setClip(svgClip); }
From source file:at.knowcenter.wag.egov.egiz.pdf.PDFPage.java
/** * Registers a rectangle that bounds the path currently being drawn. * // w w w . jav a2 s . c o 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().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."); } } } }
From source file:at.knowcenter.wag.egov.egiz.pdfbox2.pdf.PDFPage.java
/** * Registers a rectangle that bounds the path currently being drawn. * //from w ww . ja v a2 s . c o 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."); } } } }