List of usage examples for java.awt Point getY
public double getY()
From source file:org.cytoscape.ding.impl.cyannotator.dialogs.LoadImageDialog.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { try {// ww w. j a v a 2s .c o m //Read the selected Image, create an Image Annotation, repaint the whole network and then dispose off this Frame File imageFile = jFileChooser1.getSelectedFile(); // Get the file BufferedImage image = ImageIO.read(imageFile); URL url = imageFile.toURI().toURL(); //The Attributes are x, y, Image, componentNumber, scaleFactor ImageAnnotationImpl newOne = new ImageAnnotationImpl(cyAnnotator, view, (int) startingLocation.getX(), (int) startingLocation.getY(), url, image, view.getZoom(), cgm); newOne.addComponent(null); cyAnnotator.addAnnotation(newOne); newOne.getCanvas().repaint(); // Set this shape to be resized cyAnnotator.resizeShape(newOne); try { // Warp the mouse to the starting location (if supported) Point start = newOne.getComponent().getLocationOnScreen(); Robot robot = new Robot(); robot.mouseMove((int) start.getX() + 100, (int) start.getY() + 100); } catch (Exception e) { } this.dispose(); } catch (Exception ex) { logger.warn("Unable to load the selected image", ex); } }
From source file:org.kalypso.ogc.gml.widgets.base.PanToWidget.java
@Override public void mousePressed(final MouseEvent e) { if (!ArrayUtils.contains(m_mouseButtons, e.getButton())) return;/*from ww w . ja va 2s . c om*/ final IMapPanel mapPanel = getMapPanel(); if (mapPanel == null) return; final Point point = e.getPoint(); m_world2screen = mapPanel.getProjection(); if (m_world2screen == null) return; final GM_Position pixelPos = GeometryFactory.createGM_Position(point.getX(), point.getY()); m_startPoint = m_world2screen.getSourcePoint(pixelPos); m_endPoint = null; }
From source file:net.sf.jasperreports.customizers.shape.AbstractShapeCustomizer.java
/** * *//*from w w w . j a v a 2 s . com*/ protected Rectangle2D getBounds(ShapePoints shape) { Rectangle2D bounds = null; List<Point> points = shape.getPoints(); if (points != null && !points.isEmpty()) { Integer top = null; Integer bottom = null; Integer left = null; Integer right = null; for (int i = 0; i < points.size(); i++) { Point point = points.get(i); if (top == null || point.getY() < top) { top = point.getY(); } if (bottom == null || point.getY() > bottom) { bottom = point.getY(); } if (left == null || point.getX() < left) { left = point.getX(); } if (right == null || point.getX() > right) { right = point.getX(); } } bounds = new Rectangle(left, top, right - left, bottom - top); } return bounds; }
From source file:net.sf.jasperreports.customizers.shape.AbstractShapeCustomizer.java
/** * Builds an ellipse shape./*from ww w . j a va 2 s . co m*/ * * @return the ellipse or null if its size is not specified */ protected Shape buildEllipse() { Ellipse2D ellipse = null; Dimension2D size = getSize(); if (size != null) { Point offset = getOffset(size); ellipse = new Ellipse2D.Float(-offset.getX(), -offset.getY(), (float) size.getWidth(), (float) size.getHeight()); } return ellipse; }
From source file:net.sf.jasperreports.customizers.shape.AbstractShapeCustomizer.java
/** * Builds a rectangle shape./* ww w. ja v a 2s .c o m*/ * * @return the rectangle or null if its size is not specified */ protected Shape buildRectangle() { Rectangle2D rectangle = null; Dimension2D size = getSize(); if (size != null) { Point offset = getOffset(size); rectangle = new Rectangle2D.Float(-offset.getX(), -offset.getY(), (float) size.getWidth(), (float) size.getHeight()); } return rectangle; }
From source file:mulavito.gui.control.AbstractPopupMousePlugin.java
/** * Reduced functionality of super class method and extended by own * content-aware editing.//w ww. j a v a 2s . c om */ @SuppressWarnings("unchecked") @Override protected final void handlePopup(final MouseEvent e) { if (checkModifiers(e)) { final LV vv = (LV) e.getSource(); final Layout<V, E> layout = vv.getGraphLayout(); final L graph = (L) layout.getGraph(); final Point p = e.getPoint(); final List<V> sel_vertices = getSelectedVertices(); final List<E> sel_edges = getSelectedEdges(); GraphElementAccessor<V, E> pickSupport = vv.getPickSupport(); if (pickSupport != null) { V vertex = pickSupport.getVertex(layout, p.getX(), p.getY()); E edge = pickSupport.getEdge(layout, p.getX(), p.getY()); if (vertex != null && !sel_vertices.contains(vertex)) sel_vertices.add(vertex); if (edge != null && !sel_edges.contains(edge)) sel_edges.add(edge); } popup.removeAll(); if (sel_vertices.size() > 0) createVertexMenuEntries(p, graph, vv, sel_vertices); else if (sel_edges.size() > 0) createEdgeMenuEntries(p, graph, vv, sel_edges); else createGeneralMenuEntries(p, graph, vv); if (popup.getComponentCount() > 0) popup.show(vv, e.getX(), e.getY()); } }
From source file:net.sf.jasperreports.customizers.shape.AbstractShapeCustomizer.java
/** * Uses the points to build a polyline/*ww w . j a v a 2 s . c om*/ * * @param baseShape the points of the polyline * @return a polyline shape or null if it can't be build from the current configuration */ protected Shape buildPolyline(ShapePoints baseShape) { Path2D path = null; List<Point> points = baseShape.getPoints(); if (points != null && !points.isEmpty()) { float scaleFactorX = 1.0f; float scaleFactorY = 1.0f; Rectangle2D bounds = getBounds(baseShape); Integer width = getWidth(); Integer height = getHeight(); if (width != null) { scaleFactorX = (float) (width / bounds.getWidth()); } if (height != null) { scaleFactorY = (float) (height / bounds.getHeight()); } path = new Path2D.Double(); if (points.size() > 1) { Point offset = getOffset(bounds); Point point = points.get(0); path.moveTo((point.getX() - offset.getX()) * scaleFactorX, (point.getY() - offset.getY()) * scaleFactorY); for (int i = 1; i < points.size(); i++) { point = points.get(i); path.lineTo((point.getX() - offset.getX()) * scaleFactorX, (point.getY() - offset.getY()) * scaleFactorY); } } } return path; }
From source file:net.sf.jasperreports.customizers.shape.AbstractShapeCustomizer.java
/** * Builds a polygon shape.//from www . ja v a 2 s . c om * * @param shapePoints the points of the polygon * @return the polygon or null if it can't be build from the current configuration */ protected Shape buildPolygon(ShapePoints shapePoints) { Polygon polygon = null; List<Point> points = shapePoints.getPoints(); if (points != null && !points.isEmpty()) { float scaleFactorX = 1.0f; float scaleFactorY = 1.0f; Rectangle2D bounds = getBounds(shapePoints); Integer width = getWidth(); Integer height = getHeight(); if (width != null) { scaleFactorX = (float) width / (float) bounds.getWidth(); } if (height != null) { scaleFactorY = (float) height / (float) bounds.getHeight(); } Point offset = getOffset(bounds); int[] pointsX = new int[points.size()]; int[] pointsY = new int[points.size()]; for (int i = 0; i < points.size(); i++) { Point point = points.get(i); pointsX[i] = Math.round((point.getX() - offset.getX()) * scaleFactorX); pointsY[i] = Math.round((point.getY() - offset.getY()) * scaleFactorY); } polygon = new Polygon(pointsX, pointsY, points.size()); } return polygon; }
From source file:msi.gama.outputs.layers.charts.FastXYItemRenderer.java
/** {@inheritDoc} */ @Override/*from w w w. j ava2 s . co m*/ public void drawItem(final Graphics2D g2, final XYItemRendererState state, final Rectangle2D dataArea, final PlotRenderingInfo info, final XYPlot plot, final ValueAxis domainAxis, final ValueAxis rangeAxis, final XYDataset dataset, final int series, final int item, final CrosshairState crosshairState, final int pass) { if (!getItemVisible(series, item)) { return; } // setup for collecting optional entity info... boolean bAddEntity = false; Shape entityArea = null; EntityCollection entities = null; if (info != null) { entities = info.getOwner().getEntityCollection(); } final PlotOrientation orientation = plot.getOrientation(); final Paint paint = getItemPaint(series, item); final Stroke seriesStroke = getItemStroke(series, item); g2.setPaint(paint); g2.setStroke(seriesStroke); // get the data point... final double x1 = dataset.getXValue(series, item); final double y1 = dataset.getYValue(series, item); if (Double.isNaN(x1) || Double.isNaN(y1)) { return; } final RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); final RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); final double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation); final double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation); if (getPlotLines()) { if (item == 0) { if (this.drawSeriesLineAsPath) { final State s = (State) state; s.seriesPath.reset(); s.lastPointGood = false; } previousDrawnItem = 0; } if (this.drawSeriesLineAsPath) { final State s = (State) state; // update path to reflect latest point if (!Double.isNaN(transX1) && !Double.isNaN(transY1)) { float x = (float) transX1; float y = (float) transY1; if (orientation == PlotOrientation.HORIZONTAL) { x = (float) transY1; y = (float) transX1; } if (s.isLastPointGood()) { // TODO: check threshold s.seriesPath.lineTo(x, y); } else { s.seriesPath.moveTo(x, y); } s.setLastPointGood(true); } else { s.setLastPointGood(false); } if (item == dataset.getItemCount(series) - 1) { // draw path g2.setStroke(getSeriesStroke(series)); g2.setPaint(getSeriesPaint(series)); g2.draw(s.seriesPath); } } else if (item != 0) { // get the previous data point... final double x0 = dataset.getXValue(series, item - previousDrawnItem); final double y0 = dataset.getYValue(series, item - previousDrawnItem); if (!Double.isNaN(x0) && !Double.isNaN(y0)) { boolean drawLine = true; if (getPlotDiscontinuous()) { // only draw a line if the gap between the current and // previous data point is within the threshold final int numX = dataset.getItemCount(series); final double minX = dataset.getXValue(series, 0); final double maxX = dataset.getXValue(series, numX - 1); if (this.gapThresholdType == UnitType.ABSOLUTE) { drawLine = Math.abs(x1 - x0) <= this.gapThreshold; } else { drawLine = Math.abs(x1 - x0) <= (maxX - minX) / numX * getGapThreshold(); } } if (drawLine) { final double transX0 = domainAxis.valueToJava2D(x0, dataArea, xAxisLocation); final double transY0 = rangeAxis.valueToJava2D(y0, dataArea, yAxisLocation); // only draw if we have good values if (Double.isNaN(transX0) || Double.isNaN(transY0) || Double.isNaN(transX1) || Double.isNaN(transY1)) { return; } // Only draw line if it is more than a pixel away from the previous one if (transX1 - transX0 > 2 || transX1 - transX0 < -2 || transY1 - transY0 > 2 || transY1 - transY0 < -2 || 0 == previousDrawnItem) { previousDrawnItem = 1; if (orientation == PlotOrientation.HORIZONTAL) { state.workingLine.setLine(transY0, transX0, transY1, transX1); } else if (orientation == PlotOrientation.VERTICAL) { state.workingLine.setLine(transX0, transY0, transX1, transY1); } if (state.workingLine.intersects(dataArea)) { g2.draw(state.workingLine); } } else { // Increase counter for the previous drawn item. previousDrawnItem++; bAddEntity = false; } } } } } if (getBaseShapesVisible()) { Shape shape = getItemShape(series, item); if (orientation == PlotOrientation.HORIZONTAL) { shape = ShapeUtilities.createTranslatedShape(shape, transY1, transX1); } else if (orientation == PlotOrientation.VERTICAL) { shape = ShapeUtilities.createTranslatedShape(shape, transX1, transY1); } if (shape.intersects(dataArea)) { bAddEntity = true; if (getItemShapeFilled(series, item)) { g2.fill(shape); } else { g2.draw(shape); } } entityArea = shape; } if (getPlotImages()) { final Image image = getImage(plot, series, item, transX1, transY1); if (image != null) { final Point hotspot = getImageHotspot(plot, series, item, transX1, transY1, image); g2.drawImage(image, (int) (transX1 - hotspot.getX()), (int) (transY1 - hotspot.getY()), null); entityArea = new Rectangle2D.Double(transX1 - hotspot.getX(), transY1 - hotspot.getY(), image.getWidth(null), image.getHeight(null)); } } // draw the item label if there is one... if (isItemLabelVisible(series, item)) { double xx = transX1; double yy = transY1; if (orientation == PlotOrientation.HORIZONTAL) { xx = transY1; yy = transX1; } drawItemLabel(g2, orientation, dataset, series, item, xx, yy, y1 < 0.0); } updateCrosshairValues(crosshairState, x1, y1, transX1, transY1, orientation); // add an entity for the item... if (entities != null && bAddEntity) { addEntity(entities, entityArea, dataset, series, item, transX1, transY1); } }
From source file:gda.plots.SimpleXYItemRenderer.java
/** * Draws the visual representation of a single data item. This mostly reproduces the code of StandardXYItemRenderer * but using the line by line information stored in the SimpleXYSeries instead of the series indexed information * stored in the Renderer itself.//from w w w . j ava 2 s . co m * * @param g2 * the graphics device. * @param state * the renderer state. * @param dataArea * the area within which the data is being drawn. * @param info * collects information about the drawing. * @param plot * the plot (can be used to obtain standard color information etc). * @param domainAxis * the domain axis. * @param rangeAxis * the range axis. * @param dataset * the dataset. * @param series * the series index (zero-based). * @param item * the item index (zero-based). * @param crosshairState * crosshair information for the plot ( <code>null</code> permitted). * @param pass * the pass index. */ @Override public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { SimpleXYSeries sxys = (SimpleXYSeries) ((SimpleXYSeriesCollection) dataset).getSeries(series); if (!sxys.isVisible()) { return; } // setup for collecting optional entity info... Shape entityArea = null; EntityCollection entities = null; if (info != null) { entities = info.getOwner().getEntityCollection(); } PlotOrientation orientation = plot.getOrientation(); g2.setPaint(sxys.getPaint()); g2.setStroke(sxys.getStroke()); // get the data point double x1 = dataset.getXValue(series, item); double y1 = dataset.getYValue(series, item); // Test x1 = xValueTransformer.transformValue(x1); if (Double.isNaN(x1) || Double.isNaN(y1)) { return; } RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation); double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation); if (sxys.isDrawLines()) { if (item > 0) { // get the previous data point... double x0 = dataset.getXValue(series, item - 1); double y0 = dataset.getYValue(series, item - 1); // Test // System.out.print("tranformed " + x0); x0 = xValueTransformer.transformValue(x0); // Message.debug(" to " + x0); if (!Double.isNaN(x0) && !Double.isNaN(y0)) { boolean drawLine = true; if (getPlotDiscontinuous()) { // only draw a line if the gap between the current and // previous data // point is within the threshold int numX = dataset.getItemCount(series); double minX = dataset.getXValue(series, 0); double maxX = dataset.getXValue(series, numX - 1); drawLine = (x1 - x0) <= ((maxX - minX) / numX * getGapThreshold()); } if (drawLine) { double transX0 = domainAxis.valueToJava2D(x0, dataArea, xAxisLocation); double transY0 = rangeAxis.valueToJava2D(y0, dataArea, yAxisLocation); // only draw if we have good values if (Double.isNaN(transX0) || Double.isNaN(transY0) || Double.isNaN(transX1) || Double.isNaN(transY1)) { return; } if (orientation == PlotOrientation.HORIZONTAL) { state.workingLine.setLine(transY0, transX0, transY1, transX1); } else if (orientation == PlotOrientation.VERTICAL) { state.workingLine.setLine(transX0, transY0, transX1, transY1); } if (state.workingLine.intersects(dataArea)) { g2.draw(state.workingLine); } } } } } if (sxys.isDrawMarkers()) { Shape shape = sxys.getSymbol(); if (orientation == PlotOrientation.HORIZONTAL) { shape = ShapeUtilities.createTranslatedShape(shape, transY1, transX1); } else if (orientation == PlotOrientation.VERTICAL) { shape = ShapeUtilities.createTranslatedShape(shape, transX1, transY1); } if (shape.intersects(dataArea)) { g2.setPaint(sxys.getSymbolPaint()); // Always use full stroke for drawing marker g2.setStroke(new BasicStroke()); if (sxys.getFilled()) { g2.fill(shape); } else { g2.draw(shape); } g2.setPaint(sxys.getPaint()); g2.setStroke(sxys.getStroke()); } entityArea = shape; } if (getPlotImages()) { // use shape scale with transform?? // double scale = getShapeScale(plot, series, item, transX1, // transY1); Image image = getImage(plot, series, item, transX1, transY1); if (image != null) { Point hotspot = getImageHotspot(plot, series, item, transX1, transY1, image); g2.drawImage(image, (int) (transX1 - hotspot.getX()), (int) (transY1 - hotspot.getY()), null); entityArea = new Rectangle2D.Double(transX1 - hotspot.getX(), transY1 - hotspot.getY(), image.getWidth(null), image.getHeight(null)); } } // draw the item label if there is one... if (isItemLabelVisible(series, item)) { drawItemLabel(g2, orientation, dataset, series, item, transX1, transY1, (y1 < 0.0)); } updateCrosshairValues(crosshairState, x1, y1, transX1, transY1, orientation); // add an entity for the item... if (entities != null) { addEntity(entities, entityArea, dataset, series, item, transX1, transY1); } }