List of usage examples for java.awt Point Point
public Point(int x, int y)
From source file:org.nekorp.workflow.desktop.servicio.reporte.orden.servicio.OrdenServicioDataFactory.java
private void generaImagenDamage(ShapeView fondo, List<DamageDetailsVB> danios, File outputfile, int width, int height) { try {//from www.j a va2s .c o m Point contexto = new Point((width - fondo.getShapeWidth()) / 2, (height - fondo.getShapeHeight()) / 2); BufferedImage off_Image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = off_Image.createGraphics(); g2.setColor(Color.WHITE); g2.fillRect(0, 0, width, height); AffineTransform saveXform = g2.getTransform(); AffineTransform toCenterAt = new AffineTransform(); toCenterAt.translate(contexto.getX(), contexto.getY()); g2.transform(toCenterAt); fondo.paint(g2); g2.setTransform(saveXform); for (DamageDetailsVB x : danios) { DamageDetailGraphicsView obj = new DamageDetailGraphicsView(); obj.setPosicion(new Point(x.getX(), x.getY())); obj.setContexto(contexto); if (x.getX() <= fondo.getShapeWidth() / 2) { if (x.getY() <= fondo.getShapeHeight() / 2) { obj.setOrientacion(DamageDetailGraphicsView.SuperiorIzquierda); } else { obj.setOrientacion(DamageDetailGraphicsView.InferiorIzquierda); } } else { if (x.getY() <= fondo.getShapeHeight() / 2) { obj.setOrientacion(DamageDetailGraphicsView.SuperiorDerecha); } else { obj.setOrientacion(DamageDetailGraphicsView.InferiorDerecha); } } obj.setCategoria(x.getCategoria()); obj.setCaracteristica(x.getCaracteristica()); obj.paint(g2); } saveJPG(off_Image, outputfile); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:fr.landel.utils.commons.CollectionUtils2Test.java
/** * Test method for {@link CollectionUtils2#transformIntoSet(I[])}. *///w ww . j a va 2 s . com @Test public void testTransformIntoSetIArray() { try { Point[] points = new Point[3]; points[0] = new Point(1, 2); points[1] = new Point(2, 0); Set<String> pointsList = CollectionUtils2.transformIntoSet(points); assertNotNull(pointsList); assertTrue(pointsList.size() > 0); assertThat(pointsList, Matchers.containsInAnyOrder("java.awt.Point[x=1,y=2]", "java.awt.Point[x=2,y=0]", null)); } catch (IllegalArgumentException e) { fail("The test isn't correct"); } }
From source file:org.tsho.dmc2.core.chart.jfree.DmcChartPanel.java
/** * Translates a Java2D point on the chart to a screen location. * * @param java2DPoint the Java2D point. * * @return the screen location./*from w w w.j a v a2s .co m*/ */ public Point translateJava2DToScreen(Point2D java2DPoint) { Insets insets = getInsets(); int x = (int) (java2DPoint.getX() + insets.left); int y = (int) (java2DPoint.getY() + insets.top); return new Point(x, y); }
From source file:de.tor.tribes.ui.panels.MinimapPanel.java
public Point mousePosToMapPosition(double pX, double pY) { int x = rVisiblePart.x; int y = rVisiblePart.y; //calc dots per village double dpvx = (double) getWidth() / (double) rVisiblePart.width; double dpvy = (double) getHeight() / (double) rVisiblePart.height; x += (int) Math.round(pX / dpvx); y += (int) Math.round(pY / dpvy); return new Point(x, y); }
From source file:ireport_5_6_0.view.JRViewer.java
/** * *//*from ww w . j a v a2 s. c o m*/ public void gotoHyperlink(JRPrintHyperlink hyperlink) { switch (hyperlink.getHyperlinkTypeValue()) { case REFERENCE: { if (isOnlyHyperlinkListener()) { System.out.println("Hyperlink reference : " + hyperlink.getHyperlinkReference()); System.out.println("Implement your own JRHyperlinkListener to manage this type of event."); } break; } case LOCAL_ANCHOR: { if (hyperlink.getHyperlinkAnchor() != null) { Map<String, JRPrintAnchorIndex> anchorIndexes = jasperPrint.getAnchorIndexes(); JRPrintAnchorIndex anchorIndex = anchorIndexes.get(hyperlink.getHyperlinkAnchor()); if (anchorIndex.getPageIndex() != pageIndex) { setPageIndex(anchorIndex.getPageIndex()); refreshPage(); } Container container = pnlInScroll.getParent(); if (container instanceof JViewport) { JViewport viewport = (JViewport) container; int newX = (int) (anchorIndex.getElementAbsoluteX() * realZoom); int newY = (int) (anchorIndex.getElementAbsoluteY() * realZoom); int maxX = pnlInScroll.getWidth() - viewport.getWidth(); int maxY = pnlInScroll.getHeight() - viewport.getHeight(); if (newX < 0) { newX = 0; } if (newX > maxX) { newX = maxX; } if (newY < 0) { newY = 0; } if (newY > maxY) { newY = maxY; } viewport.setViewPosition(new Point(newX, newY)); } } break; } case LOCAL_PAGE: { int page = pageIndex + 1; if (hyperlink.getHyperlinkPage() != null) { page = hyperlink.getHyperlinkPage().intValue(); } if (page >= 1 && page <= jasperPrint.getPages().size() && page != pageIndex + 1) { setPageIndex(page - 1); refreshPage(); Container container = pnlInScroll.getParent(); if (container instanceof JViewport) { JViewport viewport = (JViewport) container; viewport.setViewPosition(new Point(0, 0)); } } break; } case REMOTE_ANCHOR: { if (isOnlyHyperlinkListener()) { System.out.println("Hyperlink reference : " + hyperlink.getHyperlinkReference()); System.out.println("Hyperlink anchor : " + hyperlink.getHyperlinkAnchor()); System.out.println("Implement your own JRHyperlinkListener to manage this type of event."); } break; } case REMOTE_PAGE: { if (isOnlyHyperlinkListener()) { System.out.println("Hyperlink reference : " + hyperlink.getHyperlinkReference()); System.out.println("Hyperlink page : " + hyperlink.getHyperlinkPage()); System.out.println("Implement your own JRHyperlinkListener to manage this type of event."); } break; } case CUSTOM: { if (isOnlyHyperlinkListener()) { System.out.println("Hyperlink of type " + hyperlink.getLinkType()); System.out.println("Implement your own JRHyperlinkListener to manage this type of event."); } break; } case NONE: default: { break; } } }
From source file:com.diversityarrays.kdxplore.curate.CurationTableModel.java
@Override public Object getValueAt(int rowIndex, int columnIndex) { Object result = null;//from w w w. j av a 2 s.c om Point pt = new Point(columnIndex, rowIndex); result = temporaryValues.get(pt); if (result == null) { if (columnIndex < showFeatures.size()) { Plot plot = getPlotAtRowIndex(rowIndex); DartEntityFeature<?> feature = showFeatures.get(columnIndex); result = feature.readValue(plot); } else { int vfIndex = columnIndex - showFeatures.size(); if (vfIndex < valueRetrievers.size()) { ValueRetriever<?> vr = valueRetrievers.get(vfIndex); PlotOrSpecimen pos = plotOrSpecimens.get(rowIndex); result = vr.getAttributeValue(curationData, pos, null); } } } return result; }
From source file:knop.psfj.BeadFrameList.java
/** * Gets the certain number of beads contained inside a defined zone. The * zone should be in pixel and in the image space. * /*from w w w. j a va 2s.c o m*/ * @param zone * the zone * @param max * the maximum number of beads to be retrieved * @return the sample from corner */ public BeadFrameList getSampleFromCorner(Rectangle zone, int max) { BeadFrameList list = new BeadFrameList(); int count = 0; for (BeadFrame frame : this) { if (zone.contains(new Point(frame.getFrameX(), frame.getFrameY())) && frame.getAlterEgo() != null) { list.add(frame); count++; } if (count >= max) break; } return list; }
From source file:de.fhg.igd.mapviewer.waypoints.CustomWaypointPainter.java
/** * Find the way-points in a given polygon * /*from ww w. ja va 2s. c om*/ * @param poly the polygon * @return the way-points in the polygon area */ public Set<W> findWaypoints(final Polygon poly) { Rectangle viewPort = getMapKit().getMainMap().getViewportBounds(); final int zoom = getMapKit().getMainMap().getZoom(); final PixelConverter converter = getMapKit().getMainMap().getTileFactory().getTileProvider().getConverter(); de.fhg.igd.geom.Point2D[] points = new de.fhg.igd.geom.Point2D[poly.npoints]; // create a metamodel polygon for (int i = 0; i < poly.npoints; i++) { int worldX = viewPort.x + poly.xpoints[i]; int worldY = viewPort.y + poly.ypoints[i]; // convert to geo position GeoPosition pos = converter.pixelToGeo(new Point(worldX, worldY), zoom); // convert to common CRS try { pos = GeotoolsConverter.getInstance().convert(pos, SelectableWaypoint.COMMON_EPSG); } catch (IllegalGeoPositionException e) { log.warn("Error converting polygon point for query"); //$NON-NLS-1$ return new HashSet<W>(); } points[i] = new de.fhg.igd.geom.Point2D(pos.getX(), pos.getY()); } final de.fhg.igd.geom.shape.Polygon verifyPolygon = new de.fhg.igd.geom.shape.Polygon(points); // we need a 3D search bounding box for the R-Tree BoundingBox searchBox = verifyPolygon.getBoundingBox(); searchBox.setMinZ(-2.0); searchBox.setMaxZ(2.0); poly.translate(viewPort.x, viewPort.y); try { Set<W> wps = waypoints.query(searchBox, new Verifier<W, BoundingBox>() { @Override public boolean verify(W wp, BoundingBox second) { try { Point2D wpPixel = converter.geoToPixel(wp.getPosition(), zoom); int dx = (int) wpPixel.getX(); int dy = (int) wpPixel.getY(); poly.translate(-dx, -dy); try { Area area = wp.getMarker().getArea(zoom); if (area != null) { return area.containedIn(poly); } else { // something that has not been painted yet may // not be selected return false; } } finally { poly.translate(dx, dy); } } catch (IllegalGeoPositionException e) { log.warn("Could not convert waypoint position to pixel", e); // fall back to simple method return verifyPolygon.contains(wp.getBoundingBox().toExtent()); } } }); if (wps == null) { return new HashSet<W>(); } else { return wps; } } finally { poly.translate(-viewPort.x, -viewPort.y); } }
From source file:it.unibas.spicygui.controllo.provider.intermediatezone.WidgetCreator.java
public Widget createDefinedChainWidget(Scene scene, LayerWidget mainLayer, LayerWidget connectionLayer, Point point, GraphSceneGlassPane glassPane, Scenario scenario) { ChainWidget rootWidget = new ChainWidget(scene, point, scenario.getImageNumber()); CaratteristicheWidgetChainComposition caratteristicheWidget = new CaratteristicheWidgetChainComposition( new MutableMappingTask(scenario.getMappingTask())); caratteristicheWidget.setTreeType(Costanti.COMPOSITION_TYPE); // rootWidget.getActions().addAction(ActionFactory.createEditAction(new MyEditProviderFunction(caratteristicheWidget))); rootWidget.getActions().addAction(ActionFactory.createConnectAction(connectionLayer, new ActionUndefinedChainConnection(connectionLayer, mainLayer, caratteristicheWidget))); MyPopupProviderWidgetChainComposition loadDataSource = new MyPopupProviderWidgetChainComposition(scene, connectionLayer);/*from w w w . ja v a 2 s .co m*/ loadDataSource.setEnable(false); rootWidget.getActions().addAction(ActionFactory.createPopupMenuAction(loadDataSource)); // rootWidget.getActions().addAction(ActionFactory.createPopupMenuAction(new MyPopupProviderDeleteFunc(glassPane))); // rootWidget.getActions().addAction(ActionFactory.createMoveAction()); CaratteristicheBarra caratteristicheBarra = new CaratteristicheBarra(rootWidget, Costanti.INTERMEDIE_BARRA); IconNodeWidget barra = new IconNodeWidget(scene); barra.setImage(ImageUtilities.loadImage(Costanti.ICONA_MOVE)); Point pointBarra = new Point(rootWidget.getPreferredLocation().x - Costanti.OFF_SET_X_WIDGET_BARRA, rootWidget.getPreferredLocation().y - Costanti.OFF_SET_Y_WIDGET_BARRA); barra.setPreferredLocation(pointBarra); MyMoveProviderGeneric moveProvider = new MyMoveProviderGeneric(); barra.getActions().addAction(ActionFactory.createMoveAction(moveProvider, moveProvider)); caratteristicheWidget.setWidgetBarra(barra); mainLayer.addChild(rootWidget, caratteristicheWidget); mainLayer.addChild(barra, caratteristicheBarra); glassPane.addFunction(rootWidget); glassPane.addFunction(barra); scene.validate(); // scenario.setInComposition(true); return rootWidget; }
From source file:fr.landel.utils.commons.CollectionUtils2Test.java
/** * Test method for {@link CollectionUtils2#transformIntoSet(I[], boolean)}. *///from w w w. j av a2 s. com @Test public void testTransformIntoSetIArrayB() { try { Point[] points = new Point[3]; points[0] = new Point(1, 2); points[1] = new Point(2, 0); Set<String> pointsList = CollectionUtils2.transformIntoSet(points, true); assertNotNull(pointsList); assertTrue(pointsList.size() > 0); assertThat(pointsList, Matchers.containsInAnyOrder("java.awt.Point[x=1,y=2]", "java.awt.Point[x=2,y=0]", "null")); } catch (IllegalArgumentException e) { fail("The test isn't correct"); } }