List of usage examples for java.awt.geom Point2D getY
public abstract double getY();
From source file:inflor.core.gates.ui.RectangleGateAnnotation.java
@Override public XYGateAnnotation updateVertex(Point2D v, double dx, double dy, double xHandleSize, double yHandleSize) { double xMin = (v.getX() - xHandleSize); double xMax = (v.getX() + xHandleSize); double yMin = (v.getY() - yHandleSize); double yMax = (v.getY() + yHandleSize); if ((xMin <= x0 && x0 <= xMax)) { x0 = x0 + dx;//from www .ja v a 2 s. c o m } if ((xMin <= x1 && x1 <= xMax)) { x1 = x1 + dx; } if ((yMin <= y0 && y0 <= yMax)) { y0 = y0 + dy; } if ((yMin <= y1 && y1 <= yMax)) { y1 = y1 + dy; } return new RectangleGateAnnotation(subsetName, domainAxisName, rangeAxisName, x0, y0, x1, y1, LookAndFeel.SELECTED_STROKE, LookAndFeel.SELECTED_GATE_COLOR); }
From source file:gui.ReEditingPopupGraphMousePlugin.java
@SuppressWarnings({ "unchecked", "serial" }) protected void handlePopup(MouseEvent e) { final VisualizationViewer<V, E> vv = (VisualizationViewer<V, E>) e.getSource(); final Layout<V, E> layout = vv.getGraphLayout(); final Graph<V, E> graph = layout.getGraph(); final Point2D p = e.getPoint(); final Point2D ivp = p; GraphElementAccessor<V, E> pickSupport = vv.getPickSupport(); if (pickSupport != null) { final V vertex = pickSupport.getVertex(layout, ivp.getX(), ivp.getY()); final E edge = pickSupport.getEdge(layout, ivp.getX(), ivp.getY()); final PickedState<V> pickedVertexState = vv.getPickedVertexState(); final PickedState<E> pickedEdgeState = vv.getPickedEdgeState(); if (vertex != null) { Set<V> picked = pickedVertexState.getPicked(); if (picked.size() > 0) { if (graph instanceof UndirectedGraph == false) { JMenu directedMenu = new JMenu("Create Directed Edge"); popup.add(directedMenu); for (final V other : picked) { directedMenu.add(new AbstractAction("[" + other + "," + vertex + "]") { public void actionPerformed(ActionEvent e) { graph.addEdge(edgeFactory.create(), other, vertex, EdgeType.DIRECTED); vv.repaint(); }/* www .jav a 2 s . c o m*/ }); } } if (graph instanceof DirectedGraph == false) { JMenu undirectedMenu = new JMenu("Create Undirected Edge"); popup.add(undirectedMenu); for (final V other : picked) { undirectedMenu.add(new AbstractAction("[" + other + "," + vertex + "]") { public void actionPerformed(ActionEvent e) { graph.addEdge(edgeFactory.create(), other, vertex); vv.repaint(); } }); } } } popup.add(new AbstractAction("Delete TETRA Vertex") { public void actionPerformed(ActionEvent e) { pickedVertexState.pick(vertex, false); graph.removeVertex(vertex); vv.repaint(); } }); } else if (edge != null) { popup.add(new AbstractAction("Delete Edge") { public void actionPerformed(ActionEvent e) { pickedEdgeState.pick(edge, false); graph.removeEdge(edge); vv.repaint(); } }); } else { popup.add(new AbstractAction("Create TETRA Vertex") { public void actionPerformed(ActionEvent e) { V newVertex = vertexFactory.create(); graph.addVertex(newVertex); layout.setLocation(newVertex, vv.getRenderContext().getMultiLayerTransformer().inverseTransform(p)); vv.repaint(); } }); } if (popup.getComponentCount() > 0) { popup.show(vv, e.getX(), e.getY()); } } }
From source file:at.knowcenter.wag.egov.egiz.pdf.operator.path.construction.CurveTo.java
@Override public void process(PDFOperator operator, List<COSBase> operands) throws IOException { try {// w w w .j a v a 2 s. c o m PDFPage pdfPage = (PDFPage) context; COSNumber x1 = (COSNumber) operands.get(0); COSNumber y1 = (COSNumber) operands.get(1); COSNumber x2 = (COSNumber) operands.get(2); COSNumber y2 = (COSNumber) operands.get(3); COSNumber x3 = (COSNumber) operands.get(4); COSNumber y3 = (COSNumber) operands.get(5); Point2D p1 = transform(x1.doubleValue(), y1.doubleValue()); Point2D p2 = transform(x2.doubleValue(), y2.doubleValue()); Point2D p3 = transform(x3.doubleValue(), y3.doubleValue()); pdfPage.getCurrentPath().curveTo((float) p1.getX(), (float) p1.getY(), (float) p2.getX(), (float) p2.getY(), (float) p3.getX(), (float) p3.getY()); if (log.isTraceEnabled()) { log.trace("Appending cubic Bezier curve with x1:" + p1.getX() + ",y1:" + p1.getY() + ", x2:" + p2.getX() + ",y2:" + p2.getY() + ", x3:" + p3.getX() + ",y3:" + p3.getY()); } } catch (Exception e) { log.warn("Error processing operator 'c'.", e); } }
From source file:mulavito.gui.components.LayerViewer.java
/** * @return the extent of the graph according to its vertices' location *//*from ww w . ja v a2 s . com*/ public void updateGraphBoundsCache() { double minX = Double.MAX_VALUE; double minY = Double.MAX_VALUE; double maxX = -Double.MAX_VALUE; double maxY = -Double.MAX_VALUE; for (V v : getGraphLayout().getGraph().getVertices()) { Point2D p = getGraphLayout().transform(v); minX = Math.min(minX, p.getX()); minY = Math.min(minY, p.getY()); maxX = Math.max(maxX, p.getX()); maxY = Math.max(maxY, p.getY()); } // no point if (minX > maxX || minY > maxY) minX = maxX = minY = maxY = 0; if (graphBoundsCache == null) graphBoundsCache = new Rectangle2D.Double(); graphBoundsCache.setRect(minX, minY, maxX - minX, maxY - minY); double excess = Math.max(Math.max(graphBoundsCache.width * 0.1, graphBoundsCache.height * 0.1), 10); // include the given excess graphBoundsCache.setRect(graphBoundsCache.x - excess, graphBoundsCache.y - excess, graphBoundsCache.width + 2 * excess, graphBoundsCache.height + 2 * excess); }
From source file:com.jhlabs.awt.TextStroke.java
public Shape createStrokedShape(Shape shape) { FontRenderContext frc = new FontRenderContext(null, true, true); GlyphVector glyphVector = font.createGlyphVector(frc, text); GeneralPath result = new GeneralPath(); PathIterator it = new FlatteningPathIterator(shape.getPathIterator(null), FLATNESS); float points[] = new float[6]; float moveX = 0, moveY = 0; float lastX = 0, lastY = 0; float thisX = 0, thisY = 0; int type = 0; float next = 0; int currentChar = 0; int length = glyphVector.getNumGlyphs(); if (length == 0) return result; float factor = stretchToFit ? measurePathLength(shape) / (float) glyphVector.getLogicalBounds().getWidth() : 1.0f;// w w w . j ava2 s. c o m float height = (float) glyphVector.getLogicalBounds().getHeight(); float nextAdvance = 0; while (currentChar < length && !it.isDone()) { type = it.currentSegment(points); switch (type) { case PathIterator.SEG_MOVETO: moveX = lastX = points[0]; moveY = lastY = points[1]; result.moveTo(moveX, moveY); nextAdvance = glyphVector.getGlyphMetrics(currentChar).getAdvance() * 0.5f; next = nextAdvance; break; case PathIterator.SEG_CLOSE: points[0] = moveX; points[1] = moveY; // Fall into.... case PathIterator.SEG_LINETO: thisX = points[0]; thisY = points[1]; float dx = thisX - lastX; float dy = thisY - lastY; float distance = (float) FastMath.sqrt(dx * dx + dy * dy); if (distance >= next) { float r = 1.0f / distance; float angle = (float) FastMath.atan2(dy, dx); while (currentChar < length && distance >= next) { Shape glyph = glyphVector.getGlyphOutline(currentChar); Point2D p = glyphVector.getGlyphPosition(currentChar); float px = (float) p.getX(); float py = (float) p.getY(); float x = lastX + next * dx * r; float y = lastY + next * dy * r; float advance = nextAdvance; nextAdvance = currentChar < length - 1 ? glyphVector.getGlyphMetrics(currentChar + 1).getAdvance() * 0.5f : 0; t.setToTranslation(x, y); t.rotate(angle); t.translate(-px - advance, -py + height * factor / 2.0f); result.append(t.createTransformedShape(glyph), false); next += (advance + nextAdvance) * factor; currentChar++; if (repeat) currentChar %= length; } } next -= distance; lastX = thisX; lastY = thisY; break; } it.next(); } return result; }
From source file:com.sciaps.listener.JFreeChartMouseListener.java
@Override public void chartMouseClicked(ChartMouseEvent cme) { if (cme.getTrigger().isControlDown()) { Point2D p = cme.getTrigger().getPoint(); Rectangle2D plotArea = chartPanel_.getScreenDataArea(); XYPlot plot = (XYPlot) jFreeChart_.getPlot(); double chartX = plot.getDomainAxis().java2DToValue(p.getX(), plotArea, plot.getDomainAxisEdge()); double chartY = plot.getRangeAxis().java2DToValue(p.getY(), plotArea, plot.getRangeAxisEdge()); if (callback_ != null) { callback_.jFreeChartOnClicked(chartX, chartY); }//from ww w . j a v a2 s. c o m } }
From source file:at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.construction.CurveTo.java
@Override public void process(Operator operator, List<COSBase> operands) throws IOException { try {//from www . j av a 2 s .c om PDFPage pdfPage = (PDFPage) context; COSNumber x1 = (COSNumber) operands.get(0); COSNumber y1 = (COSNumber) operands.get(1); COSNumber x2 = (COSNumber) operands.get(2); COSNumber y2 = (COSNumber) operands.get(3); COSNumber x3 = (COSNumber) operands.get(4); COSNumber y3 = (COSNumber) operands.get(5); Point2D p1 = transform(x1.doubleValue(), y1.doubleValue()); Point2D p2 = transform(x2.doubleValue(), y2.doubleValue()); Point2D p3 = transform(x3.doubleValue(), y3.doubleValue()); pdfPage.getCurrentPath().curveTo((float) p1.getX(), (float) p1.getY(), (float) p2.getX(), (float) p2.getY(), (float) p3.getX(), (float) p3.getY()); if (log.isTraceEnabled()) { log.trace("Appending cubic Bezier curve with x1:" + p1.getX() + ",y1:" + p1.getY() + ", x2:" + p2.getX() + ",y2:" + p2.getY() + ", x3:" + p3.getX() + ",y3:" + p3.getY()); } } catch (Exception e) { log.warn("Error processing operator 'c'.", e); } }
From source file:views.network.MyRadialTreeLayout.java
public Point2D transform(V v) { PolarPoint pp = polarLocations.get(v); double centerX = getSize().getWidth() / 2; double centerY = getSize().getHeight() / 2; Point2D cartesian = PolarPoint.polarToCartesian(pp); cartesian.setLocation(cartesian.getX() + centerX, cartesian.getY() + centerY); return cartesian; }
From source file:views.network.MyRadialTreeLayout.java
private Point2D getMaxXY() { double maxx = 0; double maxy = 0; for (Point2D p : locations.values()) { maxx = Math.max(maxx, p.getX()); maxy = Math.max(maxy, p.getY()); }//from www . j a v a2 s . c om return new Point2D.Double(maxx, maxy); }
From source file:at.knowcenter.wag.egov.egiz.pdf.operator.path.construction.CurveToReplicateInitialPoint.java
@Override public void process(PDFOperator operator, List<COSBase> operands) throws IOException { try {/* w w w .ja v a 2s .co m*/ PDFPage pdfPage = (PDFPage) context; COSNumber x2 = (COSNumber) operands.get(0); COSNumber y2 = (COSNumber) operands.get(1); COSNumber x3 = (COSNumber) operands.get(2); COSNumber y3 = (COSNumber) operands.get(3); Point2D currentPoint = pdfPage.getCurrentPath().getCurrentPoint(); Point2D p2 = transform(x2.doubleValue(), y2.doubleValue()); Point2D p3 = transform(x3.doubleValue(), y3.doubleValue()); pdfPage.getCurrentPath().curveTo((float) currentPoint.getX(), (float) currentPoint.getY(), (float) p2.getX(), (float) p2.getY(), (float) p3.getX(), (float) p3.getY()); if (log.isTraceEnabled()) { log.trace("Appending cubic Bezier curve with x2:" + p2.getX() + ",y2:" + p2.getY() + ", x3:" + p3.getX() + ",y3:" + p3.getY() + ", using current point x:" + currentPoint.getX() + ",y:" + currentPoint.getY()); } } catch (Exception e) { log.warn("Error processing operator 'v'.", e); } }