List of usage examples for java.awt.geom Point2D getY
public abstract double getY();
From source file:Polygon2D.java
public void addPoint(Point2D p) { addPoint((float) p.getX(), (float) p.getY()); }
From source file:com.wasteofplastic.beaconz.Register.java
/** * Deletes any links that starts// w w w . jav a2 s .c o m * @param faction * @param point * NOTE: THIS ISN'T USED ANYWHERE ***************************** */ public void deleteBeaconLinks(Team team, Point2D point) { Set<Line2D> linkSet = new HashSet<Line2D>(); if (links.containsKey(team)) { linkSet = links.get(team); } Iterator<Line2D> it = linkSet.iterator(); while (it.hasNext()) { Line2D line = it.next(); if (line.getP1().equals(point) || line.getP2().equals(point)) { // Devisualize - TODO: make async or something for (Iterator<Point2D> lineIt = new LineIterator(line); lineIt.hasNext();) { Point2D current = lineIt.next(); Block b = getBeaconzWorld().getBlockAt((int) current.getX(), getBeaconzWorld().getMaxHeight() - 1, (int) current.getY()); b.setType(Material.AIR); } it.remove(); getScorecard().refreshScores(team, "links"); } } }
From source file:org.jax.haplotype.analysis.visualization.SimplePhylogenyTreeImageFactory.java
/** * Transform the tree layout so that it fits nicely in the given image * dimensions/*ww w . j a va 2s .c o m*/ * @param treeLayout * the layout to transform * @param imageWidth * the image width * @param imageHeight * the image height */ private void transformTreeLayout(VisualTreeNode treeLayout, int imageWidth, int imageHeight, FontRenderContext frc) { Dimension2D maximalNodeLabelDimension = this.calculateMaximalNodeDimension(treeLayout, frc); double widthBuffer = maximalNodeLabelDimension.getWidth() + BORDER_WHITE_SPACE; double heightBuffer = maximalNodeLabelDimension.getHeight() + BORDER_WHITE_SPACE; // perform rotation to improve the use of space { // center around 0, 0 VisualTreeNode[] mostDistantPair = this.getMostDistantNodePair(treeLayout); Point2D distantPoint1 = mostDistantPair[0].getPosition(); Point2D distantPoint2 = mostDistantPair[1].getPosition(); double xDiff = distantPoint1.getX() - distantPoint2.getX(); double yDiff = distantPoint1.getY() - distantPoint2.getY(); this.translateTreeLayout(treeLayout, (xDiff / 2.0) - distantPoint1.getX(), (yDiff / 2.0) - distantPoint2.getY()); // rotate double thetaRadians = Math.atan2(yDiff, xDiff); if (imageWidth >= imageHeight) { this.rotateTreeLayout(treeLayout, -thetaRadians); } else { this.rotateTreeLayout(treeLayout, (Math.PI / 2.0 - thetaRadians)); } } Rectangle2D boundingRectangle = this.calculateBounds(treeLayout, null); // center around the middle of the display area this.translateTreeLayout(treeLayout, -boundingRectangle.getX(), -boundingRectangle.getY()); // grow the image to fill a larger area double xScale = (imageWidth - widthBuffer) / boundingRectangle.getWidth(); double yScale = (imageHeight - heightBuffer) / boundingRectangle.getHeight(); double smallerScale = Math.min(xScale, yScale); this.scaleTreeLayout(treeLayout, smallerScale); // center around the middle of the display area boundingRectangle = this.calculateBounds(treeLayout, null); this.translateTreeLayout(treeLayout, ((imageWidth - boundingRectangle.getWidth()) / 2.0) - boundingRectangle.getX(), ((imageHeight - boundingRectangle.getHeight()) / 2.0) - boundingRectangle.getY()); }
From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.link_and_brush.LinkAndBrushChartPanel.java
@Override public void mouseDragged(MouseEvent e) { // when not allowed to zoom / select, return if (blockSelectionOrZoom) { return;// ww w . j a va2s . c o m } // if the popup menu has already been triggered, then ignore dragging... if (getChartFieldValueByName("popup") != null && ((JPopupMenu) getChartFieldValueByName("popup")).isShowing()) { return; } // handle panning if we have a start point if (getChartFieldValueByName("panLast") != null) { double dx = e.getX() - ((Point) getChartFieldValueByName("panLast")).getX(); double dy = e.getY() - ((Point) getChartFieldValueByName("panLast")).getY(); if (dx == 0.0 && dy == 0.0) { return; } double wPercent = -dx / ((Double) getChartFieldValueByName("panW")); double hPercent = dy / ((Double) getChartFieldValueByName("panH")); boolean old = getChart().getPlot().isNotify(); getChart().getPlot().setNotify(false); Pannable p = (Pannable) getChart().getPlot(); if (p.getOrientation() == PlotOrientation.VERTICAL) { p.panDomainAxes(wPercent, getChartRenderingInfo().getPlotInfo(), (Point) getChartFieldValueByName("panLast")); p.panRangeAxes(hPercent, getChartRenderingInfo().getPlotInfo(), (Point) getChartFieldValueByName("panLast")); } else { p.panDomainAxes(hPercent, getChartRenderingInfo().getPlotInfo(), (Point) getChartFieldValueByName("panLast")); p.panRangeAxes(wPercent, getChartRenderingInfo().getPlotInfo(), (Point) getChartFieldValueByName("panLast")); } setChartFieldValue((getChartFieldByName("panLast")), e.getPoint()); getChart().getPlot().setNotify(old); return; } // if no initial zoom point was set, ignore dragging... if (getChartFieldValueByName("zoomPoint") == null) { return; } Graphics2D g2 = (Graphics2D) getGraphics(); // erase the previous zoom rectangle (if any). We only need to do // this is we are using XOR mode, which we do when we're not using // the buffer (if there is a buffer, then at the end of this method we // just trigger a repaint) if (!(Boolean) getChartFieldValueByName("useBuffer")) { drawZoomRectangle(g2, true); } boolean hZoom = false; boolean vZoom = false; if ((PlotOrientation) getChartFieldValueByName("orientation") == PlotOrientation.HORIZONTAL) { hZoom = (Boolean) getChartFieldValueByName("rangeZoomable"); vZoom = (Boolean) getChartFieldValueByName("domainZoomable"); } else { hZoom = (Boolean) getChartFieldValueByName("domainZoomable"); vZoom = (Boolean) getChartFieldValueByName("rangeZoomable"); } Point2D zoomPoint = (Point2D) getChartFieldValueByName("zoomPoint"); Rectangle2D scaledDataArea = getScreenDataArea((int) zoomPoint.getX(), (int) zoomPoint.getY()); if (hZoom && vZoom) { // selected rectangle shouldn't extend outside the data area... double xmax = Math.min(e.getX(), scaledDataArea.getMaxX()); double ymax = Math.min(e.getY(), scaledDataArea.getMaxY()); setChartFieldValue(getChartFieldByName("zoomRectangle"), new Rectangle2D.Double(zoomPoint.getX(), zoomPoint.getY(), xmax - zoomPoint.getX(), ymax - zoomPoint.getY())); } else if (hZoom) { double xmax = Math.min(e.getX(), scaledDataArea.getMaxX()); setChartFieldValue(getChartFieldByName("zoomRectangle"), new Rectangle2D.Double(zoomPoint.getX(), scaledDataArea.getMinY(), xmax - zoomPoint.getX(), scaledDataArea.getHeight())); } else if (vZoom) { double ymax = Math.min(e.getY(), scaledDataArea.getMaxY()); setChartFieldValue(getChartFieldByName("zoomRectangle"), new Rectangle2D.Double(scaledDataArea.getMinX(), zoomPoint.getY(), scaledDataArea.getWidth(), ymax - zoomPoint.getY())); } // Draw the new zoom rectangle... if ((Boolean) getChartFieldValueByName("useBuffer")) { repaint(); } else { // with no buffer, we use XOR to draw the rectangle "over" the // chart... drawZoomRectangle(g2, true); } g2.dispose(); }
From source file:gov.nih.nci.caintegrator.application.graphing.BoxAndWhiskerDotsRenderer.java
/** * Draws two dots to represent the average value of more than one outlier. * /*from w w w. j ava 2 s.c o m*/ * @param point the location * @param boxWidth the box width. * @param oRadius the radius. * @param g2 the graphics device. */ private void drawMultipleEllipse(Point2D point, double boxWidth, double oRadius, Graphics2D g2) { Ellipse2D dot1 = new Ellipse2D.Double(point.getX() - (boxWidth / 2) + oRadius, point.getY(), oRadius, oRadius); Ellipse2D dot2 = new Ellipse2D.Double(point.getX() + (boxWidth / 2), point.getY(), oRadius, oRadius); g2.draw(dot1); g2.draw(dot2); }
From source file:com.igormaznitsa.mindmap.swing.panel.MindMapPanel.java
private static void drawArrowToDestination(final Graphics2D gfx, final Rectangle2D start, final Rectangle2D destination, final Stroke lineStroke, final Stroke arrowStroke, final float arrowSize) { final double startx = start.getCenterX(); final double starty = start.getCenterY(); final Point2D arrowPoint = Utils.findRectEdgeIntersection(destination, startx, starty); if (arrowPoint != null) { gfx.setStroke(arrowStroke);/* w w w. j av a2 s . c om*/ double angle = findLineAngle(arrowPoint.getX(), arrowPoint.getY(), startx, starty); final double arrowAngle = Math.PI / 12.0d; final double x1 = arrowSize * Math.cos(angle - arrowAngle); final double y1 = arrowSize * Math.sin(angle - arrowAngle); final double x2 = arrowSize * Math.cos(angle + arrowAngle); final double y2 = arrowSize * Math.sin(angle + arrowAngle); final double cx = (arrowSize / 2.0f) * Math.cos(angle); final double cy = (arrowSize / 2.0f) * Math.sin(angle); final GeneralPath polygon = new GeneralPath(); polygon.moveTo(arrowPoint.getX(), arrowPoint.getY()); polygon.lineTo(arrowPoint.getX() + x1, arrowPoint.getY() + y1); polygon.lineTo(arrowPoint.getX() + x2, arrowPoint.getY() + y2); polygon.closePath(); gfx.fill(polygon); gfx.setStroke(lineStroke); gfx.drawLine((int) startx, (int) starty, (int) (arrowPoint.getX() + cx), (int) (arrowPoint.getY() + cy)); } }
From source file:org.squidy.designer.model.PipeShape.java
public void initialize() { if (pipe == null) { if (LOG.isErrorEnabled()) { LOG.error("Could not initialize PipeShape without a pipe instance. Removing from parent."); }/* w ww. ja v a 2 s .c o m*/ return; } visualization = new VisualizationShape(this); visualization.setScale(0.5); addChild(visualization); // ShapeUtils.setApparent(visualization, false); pipe.addProcessingFeedback(visualization); flowIncoming = new DataTypeShape(pipe.getInputTypes()); flowIncoming.setScale(0.1); addChild(flowIncoming); // ShapeUtils.setApparent(flowIncoming, false); flowOutgoing = new DataTypeShape(pipe.getOutputTypes()); flowOutgoing.setScale(0.1); addChild(flowOutgoing); // ShapeUtils.setApparent(flowOutgoing, false); final PropertyChangeListener changeListener = new PropertyChangeListener() { /* * (non-Javadoc) * * * @seejava.beans.PropertyChangeListener#propertyChange(java. * beans. PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent evt) { if (evt.getNewValue() != null) { setBounds(computeBounds()); positionVisualization(); } } }; addPropertyChangeListener(PNode.PROPERTY_PARENT, changeListener); source.addPropertyChangeListener(PNode.PROPERTY_FULL_BOUNDS, changeListener); target.addPropertyChangeListener(PNode.PROPERTY_FULL_BOUNDS, changeListener); pipe.addStatusChangeListener(Processable.STATUS_PROCESSABLE_DELETED, new PropertyChangeListener() { /* * (non-Javadoc) * * @see * java.beans.PropertyChangeListener#propertyChange(java * .beans.PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent evt) { if (source != null) { source.removePropertyChangeListener(changeListener); } if (target != null) { target.removePropertyChangeListener(changeListener); } removeFromParent(); } }); addInputEventListener(new PBasicInputEventHandler() { /* * (non-Javadoc) * * @see * edu.umd.cs.piccolo.event.PBasicInputEventHandler#mouseEntered * (edu.umd.cs.piccolo.event.PInputEvent) */ @Override public void mouseEntered(PInputEvent event) { super.mouseEntered(event); // ShapeUtils.setApparent(visualization, true); // ShapeUtils.setApparent(flowIncoming, true); // ShapeUtils.setApparent(flowOutgoing, true); } /* * (non-Javadoc) * * @see * edu.umd.cs.piccolo.event.PBasicInputEventHandler#mouseExited( * edu.umd.cs.piccolo.event.PInputEvent) */ @Override public void mouseExited(PInputEvent event) { super.mouseExited(event); // ShapeUtils.setApparent(visualization, false); // ShapeUtils.setApparent(flowIncoming, false); // ShapeUtils.setApparent(flowOutgoing, false); } /* * (non-Javadoc) * * @see * edu.umd.cs.piccolo.event.PBasicInputEventHandler#mousePressed * (edu.umd.cs.piccolo. event.PInputEvent) */ @Override public void mousePressed(PInputEvent event) { super.mousePressed(event); if (!event.isHandled()) { Point2D p = event.getPosition(); double x = p.getX(); double y = p.getY(); // Check intersection based on mouse position (5 pixel // around // position) // Rectangle2D rectangle = globalToLocal(new // Rectangle2D.Double(x, y, 100 * getGlobalScale(), // 100 * getGlobalScale())); // if (shape.intersects(rectangle)) { event.getInputManager().setKeyboardFocus(event.getPath()); // // if (event.isRightMouseButton()) { // globalToLocal(p); // System.out.println("Do you wan't to create a bendpoint at x=" // + p.getX() + " / y=" // + p.getY() + "?"); // } event.setHandled(true); // } } // PNode nextNode = event.getPath().nextPickedNode(); // if (nextNode != null) { // EventListenerList listenerList = nextNode.getListenerList(); // // if (listenerList != null) { // PBasicInputEventHandler[] listeners = // listenerList.getListeners(PBasicInputEventHandler.class); // for (PBasicInputEventHandler listener : listeners) { // listener.mousePressed(event); // } // } // } } /* * (non-Javadoc) * * @see * edu.umd.cs.piccolo.event.PBasicInputEventHandler#keyboardFocusGained * (edu.umd.cs.piccolo .event.PInputEvent) */ @Override public void keyboardFocusGained(PInputEvent event) { super.keyboardFocusGained(event); selected = true; moveToFront(); invalidatePaint(); } /* * (non-Javadoc) * * @see * edu.umd.cs.piccolo.event.PBasicInputEventHandler#keyboardFocusLost * (edu.umd.cs.piccolo .event.PInputEvent) */ @Override public void keyboardFocusLost(PInputEvent event) { super.keyboardFocusLost(event); selected = false; invalidatePaint(); } /* * (non-Javadoc) * * @see * edu.umd.cs.piccolo.event.PBasicInputEventHandler#keyPressed(edu * .umd.cs.piccolo.event .PInputEvent) */ @Override public void keyPressed(PInputEvent event) { super.keyPressed(event); if (KeyEvent.VK_DELETE == event.getKeyCode()) { // DrawingArea drawingArea = (DrawingArea) // event.getCamera().getComponent(); // drawingArea.removeEdge(Edge.this); if (LOG.isDebugEnabled()) { LOG.debug("Backspace has been pressed. Trigger deletion of edge?"); } pipe.delete(); Manager.get().notify(getPipe(), Action.DELETE); } } }); }
From source file:org.apache.fop.svg.AbstractFOPTextPainter.java
private void updateLocationFromACI(AttributedCharacterIterator aci, Point2D loc) { //Adjust position of span Float xpos = (Float) aci.getAttribute(GVTAttributedCharacterIterator.TextAttribute.X); Float ypos = (Float) aci.getAttribute(GVTAttributedCharacterIterator.TextAttribute.Y); Float dxpos = (Float) aci.getAttribute(GVTAttributedCharacterIterator.TextAttribute.DX); Float dypos = (Float) aci.getAttribute(GVTAttributedCharacterIterator.TextAttribute.DY); if (xpos != null) { loc.setLocation(xpos.doubleValue(), loc.getY()); }/* ww w.jav a2 s. c o m*/ if (ypos != null) { loc.setLocation(loc.getX(), ypos.doubleValue()); } if (dxpos != null) { loc.setLocation(loc.getX() + dxpos.doubleValue(), loc.getY()); } if (dypos != null) { loc.setLocation(loc.getX(), loc.getY() + dypos.doubleValue()); } }
From source file:com.projity.pm.graphic.pert.PertLayout.java
public void updateBounds() { dependencyGraph.updatePertLevels();/*from ww w.jav a 2 s . c o m*/ GraphicConfiguration config = GraphicConfiguration.getInstance(); Point2D origin = new Point2D.Double(config.getPertXOffset(), config.getPertYOffset()); Rectangle2D ref = new Rectangle2D.Double(config.getPertXOffset(), config.getPertYOffset(), config.getPertCellWidth(), config.getPertCellHeight()); int row = 0; int col = -1; setEmpty(); for (Iterator i = cache.getIterator(); i.hasNext();) { GraphicNode current = (GraphicNode) i.next(); int currentCol = cache.getPertLevel(current) - 1; if (currentCol <= col) row++; col = currentCol; TexturedShape texturedShape = findShape(current); if (texturedShape == null) continue; double centerX = origin.getX() + ref.getMaxX() * col + ref.getWidth() / 2; double centerY = origin.getY() + ref.getMaxY() * row + ref.getHeight() / 2; //System.out.println(centerX+"/"+centerY); GeneralPath shape = texturedShape.toGeneralPath(ref.getWidth(), ref.getHeight(), centerX - ref.getWidth() / 2, centerY, null); current.setPertShape(shape, centerX, centerY); Rectangle cellBounds = network.scale(shape.getBounds()); if (isEmpty()) bounds.setBounds(cellBounds); else Rectangle.union(bounds, cellBounds, bounds); } fireLayoutChanged(); }
From source file:sc.fiji.kappa.gui.KappaMenuBar.java
public void saveCurveFile(File file) { try {/* ww w . j a va 2s.c o m*/ PrintWriter out = new PrintWriter(new FileWriter(file)); out.println(frame.getCurves().size()); for (Curve c : frame.getCurves()) { // Outputs the curve properties: it's type, the number of keyframes, the number // of control points, etc. if (c instanceof BSpline) { out.println(KappaFrame.B_SPLINE); } else { out.println(KappaFrame.BEZIER_CURVE); } out.println(c.getNoKeyframes()); // Print out the correct number of control points depending on the curve type. if (c instanceof BSpline && !((BSpline) c).isOpen()) { out.println(c.getNoCtrlPts() - BSpline.B_SPLINE_DEGREE); } else { out.println(c.getNoCtrlPts()); } if (c instanceof BSpline) { if (((BSpline) c).isOpen()) { out.println(BSpline.OPEN); } else { out.println(BSpline.CLOSED); } } // Writes the control points and what keyframe they are at for each curve. for (Curve.BControlPoints b : c.getKeyframes()) { out.println(b.t); // If it's a closed B-Spline, we don't output the last redundant points that // make it closed if (c instanceof BSpline && !((BSpline) c).isOpen()) { for (int i = 0; i < b.defPoints.length - BSpline.B_SPLINE_DEGREE; i++) { Point2D p = b.defPoints[i]; out.println(p.getX()); out.println(p.getY()); } } // Otherwise, we output all the points else { for (Point2D p : b.defPoints) { out.println(p.getX()); out.println(p.getY()); } } } } out.close(); } catch (Exception err) { frame.getOverlay().setVisible(true); frame.getOverlay().drawNotification("There was an error saving the curve data", frame.getScrollPane().getVisibleRect()); } }