List of usage examples for java.awt Point Point
public Point(int x, int y)
From source file:fr.landel.utils.commons.CollectionUtils2Test.java
/** * Test method for//from w w w .j ava2 s .co m * {@link CollectionUtils2#transformIntoSet(java.lang.Iterable)}. */ @Test public void testTransformIntoSetIterableOfI() { try { List<Point> points = new ArrayList<>(); points.add(new Point(1, 2)); points.add(new Point(2, 0)); points.add(null); Set<String> strPoints = CollectionUtils2.transformIntoSet(points); assertThat(strPoints, Matchers.containsInAnyOrder("java.awt.Point[x=2,y=0]", "java.awt.Point[x=1,y=2]", null)); } catch (IllegalArgumentException e) { fail("The test isn't correct"); } }
From source file:net.java.sip.communicator.gui.AuthenticationSplash.java
/** * Centers the window on the screen./* ww w . ja va 2 s .c o m*/ */ private void centerWindow() { Rectangle screen = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()); Point center = new Point((int) screen.getCenterX(), (int) screen.getCenterY()); Point newLocation = new Point(center.x - this.getWidth() / 2, center.y - this.getHeight() / 2); if (screen.contains(newLocation.x, newLocation.y, this.getWidth(), this.getHeight())) { this.setLocation(newLocation); } }
From source file:simulador.controle.GeradorGraficos.java
@Override public void propertyChange(PropertyChangeEvent evt) { if (DEBUG) {/*from w w w.j ava 2s . c om*/ System.out.println("GeradorGraficos.propertyChange: " + evt.getPropertyName()); } switch (evt.getPropertyName()) { case BarraFerramentas.BT_SELECAO: Map<Integer, Point> pontosRadios = new HashMap(); Map<Integer, Boolean> valoresCheckbox = (Map) evt.getNewValue(); Map<Integer, Radio2D> radios2D = painelDesign.getRadios2D(); for (Map.Entry<Integer, Boolean> parCheckbox : valoresCheckbox.entrySet()) { System.out.println("parCheckbox[" + parCheckbox.getKey() + ", " + parCheckbox.getValue() + "]"); if (parCheckbox.getValue()) { Radio2D r2D = radios2D.get(parCheckbox.getKey()); Rectangle forma = (Rectangle) r2D.getForma(); Point localizacao = new Point((int) forma.getCenterX(), (int) forma.getCenterY()); System.out .println("radioCheckBox - localizacao: (" + localizacao.x + ", " + localizacao.y + ")"); pontosRadios.put(parCheckbox.getKey(), localizacao); } } //int[] coordCelPontoClicado = painelDesign.buscarCelula((Point) evt.getOldValue()); //PainelDesign.Celula cel = painelDesign.getMapaCelulas().get(coordCelPontoClicado[0]).get(coordCelPontoClicado[1]); //Point pontoFinal = new Point(cel.x, cel.y); Point pontoClicado = (Point) evt.getOldValue(); criarGraficoRadiais(pontosRadios, pontoClicado); break; } }
From source file:main.java.whiteSocket.Area.java
public static boolean[][] floodBorder(Area area, boolean[][] floodArea, int x, int y) { /**//from ww w.j a va 2s.c om * paint bucket-like algorithm to fill binary map border this filled * area becomes the area to be filtered through the stretch() area * pixels to be turned Color.WHITE (unless notified otherwise by user * dictation) * */ if (!floodArea[y][x]) { Queue<Point> queue = new LinkedList<Point>(); queue.add(new Point(x, y)); while (!queue.isEmpty()) { Point p = queue.remove(); if (!floodArea[p.y][p.x]) { floodArea[p.y][p.x] = true; // System.out.println("totalErase = " + totalErase); if (totalErase != null) totalErase[p.y][p.x] = true; queue.add(new Point(p.x + 1, p.y)); queue.add(new Point(p.x - 1, p.y)); queue.add(new Point(p.x, p.y + 1)); queue.add(new Point(p.x, p.y - 1)); } } } return floodArea; }
From source file:com.mirth.connect.connectors.jdbc.DatabaseMetadataDialog.java
private void checkTableNameSelected(java.awt.event.MouseEvent evt) { if (!evt.isPopupTrigger()) { int row = includedMetaDataTable.rowAtPoint(new Point(evt.getX(), evt.getY())); int column = includedMetaDataTable.columnAtPoint(new Point(evt.getX(), evt.getY())); if (row != -1 && column == 0) { String type = (String) includedMetaDataTable.getModel().getValueAt(row, 2); Boolean selected = (Boolean) includedMetaDataTable.getModel().getValueAt(row, 0); if (type.equals(TABLE_TYPE_COLUMN)) { RefreshTableModel model = (RefreshTableModel) includedMetaDataTable.getModel(); boolean nextTableFound = false; int tableLength = model.getRowCount(); int endRow = -1; for (int i = row + 1; !nextTableFound && i != tableLength; i++) { String nextType = (String) includedMetaDataTable.getModel().getValueAt(i, 2); if (nextType.equals(TABLE_TYPE_COLUMN)) { endRow = i;//www. ja v a 2s. c om nextTableFound = true; } else if (i + 1 == tableLength) { endRow = i + 1; } } if (endRow == -1) { return; } for (int i = row + 1; i < endRow; i++) { model.setValueAt(selected, i, 0); } } } } }
From source file:PSDReader.java
/** * Gets the subimage offset of layer n if it is smaller than the full frame * size.//ww w .ja v a 2 s . com * * @return Point indicating offset from upper left corner of frame. */ public Point getLayerOffset(int n) { Point p = null; if ((n >= 0) && (n < nLayers)) { int x = layers[n].x; int y = layers[n].y; p = new Point(x, y); } if (p == null) { p = new Point(0, 0); } return p; }
From source file:de.fhg.igd.mapviewer.waypoints.CustomWaypointPainter.java
/** * @see AbstractTileOverlayPainter#repaintTile(int, int, int, int, * PixelConverter, int)/*from w w w .j a v a2 s .c o m*/ */ @Override public BufferedImage repaintTile(int posX, int posY, int width, int height, PixelConverter converter, int zoom) { if (renderer == null) { return null; } int overlap = getMaxOverlap(); // overlap pixel coordinates Point topLeftPixel = new Point(Math.max(posX - overlap, 0), Math.max(posY - overlap, 0)); Point bottomRightPixel = new Point(posX + width + overlap, posY + height + overlap); // TODO // check // against // map // size // overlap geo positions GeoPosition topLeft = converter.pixelToGeo(topLeftPixel, zoom); GeoPosition bottomRight = converter.pixelToGeo(bottomRightPixel, zoom); // overlap geo positions in RTree CRS try { BoundingBox tileBounds = createSearchBB(topLeft, bottomRight); synchronized (waypoints) { Set<W> candidates = waypoints.query(tileBounds, matchTileVerifier); if (candidates != null) { // sort way-points List<W> sorted = new ArrayList<W>(candidates); Collections.sort(sorted, paintFirstComparator); BufferedImage image = createImage(width, height); Graphics2D gfx = image.createGraphics(); configureGraphics(gfx); try { // for each way-point within these bounds for (W w : sorted) { processWaypoint(w, posX, posY, width, height, converter, zoom, gfx); } /* * DEBUG String test = getClass().getSimpleName() + * " - x=" + posX + ", y=" + posY + ": " + * candidates.size() + " WPs"; gfx.setColor(Color.BLUE); * gfx.drawString(test, 4, height - 4); * * gfx.drawString("minX: " + tileBounds.getMinX(), 4, * height - 84); gfx.drawString("maxX: " + * tileBounds.getMaxX(), 4, height - 64); * gfx.drawString("minY: " + tileBounds.getMinY(), 4, * height - 44); gfx.drawString("maxY: " + * tileBounds.getMaxY(), 4, height - 24); * * gfx.drawRect(0, 0, width - 1, height - 1); */ } finally { gfx.dispose(); } return image; } else { return null; } } } catch (IllegalGeoPositionException e) { log.warn("Error painting waypoint tile: " + e.getMessage()); //$NON-NLS-1$ return null; } }
From source file:com.limegroup.gnutella.gui.notify.AnimatedWindow.java
public static void main(String[] args) { JPanel content = new JPanel(new BorderLayout()); content.setBorder(BorderFactory.createLineBorder(Color.black, 2)); JLabel label = new JLabel("Hello World"); label.setIcon(UIManager.getIcon("FileView.computerIcon")); label.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); content.add(label, BorderLayout.CENTER); final AnimatedWindow window = new AnimatedWindow(null); window.setFinalLocation(new Point(200, 200)); window.setContentPane(content);// ww w.java2s.co m JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 10, 10)); JButton button = new JButton("Bottom -> Top"); buttonPanel.add(button); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { window.setMode(AnimationMode.BOTTOM_TO_TOP); if (!window.isVisible() || window.isHideAnimationInProgress()) { window.doShow(); } else { window.doHide(); } } }); button = new JButton("Top -> Bottom"); buttonPanel.add(button); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { window.setMode(AnimationMode.TOP_TO_BOTTOM); if (!window.isVisible() || window.isHideAnimationInProgress()) { window.doShow(); } else { window.doHide(); } } }); button = new JButton("Fade"); buttonPanel.add(button); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { window.setMode(AnimationMode.FADE); if (!window.isVisible() || window.isHideAnimationInProgress()) { window.doShow(); } else { window.doHide(); } } }); JFrame app = new JFrame("AnimatedWindow Demo"); app.setContentPane(buttonPanel); app.pack(); app.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { System.exit(0); } }); app.setVisible(true); }
From source file:GraphicsUtil.java
/** * Creates a new raster that has a <b>copy</b> of the data in * <tt>ras</tt>. This is highly optimized for speed. There is * no provision for changing any aspect of the SampleModel. * However you can specify a new location for the returned raster. * * This method should be used when you need to change the contents * of a Raster that you do not "own" (ie the result of a * <tt>getData</tt> call)./*from w w w.jav a 2s . co m*/ * * @param ras The Raster to copy. * * @param minX The x location for the upper left corner of the * returned WritableRaster. * * @param minY The y location for the upper left corner of the * returned WritableRaster. * * @return A writable copy of <tt>ras</tt> */ public static WritableRaster copyRaster(Raster ras, int minX, int minY) { WritableRaster ret = Raster.createWritableRaster(ras.getSampleModel(), new Point(0, 0)); ret = ret.createWritableChild(ras.getMinX() - ras.getSampleModelTranslateX(), ras.getMinY() - ras.getSampleModelTranslateY(), ras.getWidth(), ras.getHeight(), minX, minY, null); // Use System.arraycopy to copy the data between the two... DataBuffer srcDB = ras.getDataBuffer(); DataBuffer retDB = ret.getDataBuffer(); if (srcDB.getDataType() != retDB.getDataType()) { throw new IllegalArgumentException("New DataBuffer doesn't match original"); } int len = srcDB.getSize(); int banks = srcDB.getNumBanks(); int[] offsets = srcDB.getOffsets(); for (int b = 0; b < banks; b++) { switch (srcDB.getDataType()) { case DataBuffer.TYPE_BYTE: { DataBufferByte srcDBT = (DataBufferByte) srcDB; DataBufferByte retDBT = (DataBufferByte) retDB; System.arraycopy(srcDBT.getData(b), offsets[b], retDBT.getData(b), offsets[b], len); } case DataBuffer.TYPE_INT: { DataBufferInt srcDBT = (DataBufferInt) srcDB; DataBufferInt retDBT = (DataBufferInt) retDB; System.arraycopy(srcDBT.getData(b), offsets[b], retDBT.getData(b), offsets[b], len); } case DataBuffer.TYPE_SHORT: { DataBufferShort srcDBT = (DataBufferShort) srcDB; DataBufferShort retDBT = (DataBufferShort) retDB; System.arraycopy(srcDBT.getData(b), offsets[b], retDBT.getData(b), offsets[b], len); } case DataBuffer.TYPE_USHORT: { DataBufferUShort srcDBT = (DataBufferUShort) srcDB; DataBufferUShort retDBT = (DataBufferUShort) retDB; System.arraycopy(srcDBT.getData(b), offsets[b], retDBT.getData(b), offsets[b], len); } } } return ret; }
From source file:com.kbot2.scriptable.methods.wrappers.Interface.java
public Point getRandomPointInside() { Rectangle rect = getArea();// w w w .j a v a 2s. com int randomX = random(rect.x, rect.x + rect.width); int randomY = random(rect.y, rect.y + rect.height); return new Point(randomX, randomY); }