List of usage examples for java.awt.geom Point2D getX
public abstract double getX();
From source file:com.projity.pm.graphic.xbs.XbsLayout.java
protected int updateBounds(Point2D origin, Rectangle2D ref) {//cache in current version isn't a tree double x = origin.getX() + ref.getWidth() / 2; double y = origin.getY() + ref.getHeight() / 2; GraphicNode node, previous = null;/*from w w w .j av a 2 s . co m*/ int maxLevel = 0; for (ListIterator i = cache.getIterator(); i.hasNext();) { node = (GraphicNode) i.next(); if (node.getLevel() > maxLevel) maxLevel = node.getLevel(); if (previous != null && node.getLevel() <= previous.getLevel()) { setShape(previous, ref, x, y + (previous.getLevel() - 1) * (ref.getMaxY())); x += ref.getMaxX(); } previous = node; } if (previous != null) { setShape(previous, ref, x, y + (previous.getLevel() - 1) * (ref.getMaxY())); } return maxLevel; }
From source file:algorithms.quality.ColorDivergenceVariance.java
@Override public double getQuality(Colormap colormap) { DescriptiveStatistics stats = new DescriptiveStatistics(); Iterator<Point2D> ptIt = strategy.getPoints().iterator(); while (ptIt.hasNext()) { Point2D p1 = ptIt.next(); if (!ptIt.hasNext()) break; Point2D p2 = ptIt.next(); double dist = p1.distance(p2); Color colorA = colormap.getColor(p1.getX(), p1.getY()); Color colorB = colormap.getColor(p2.getX(), p2.getY()); // roughly 0-100 double cdist = MedianDivergenceComputer.colorDiff(colorA, colorB); double ratio = cdist / dist; stats.addValue(ratio);/*from w w w . j a v a2 s. c o m*/ } return stats.getStandardDeviation(); }
From source file:lu.lippmann.cdb.graph.mouse.CadralEditingGraphMousePlugin.java
/** * Function to draw the arrow while drawing * @param down/* w w w. j a va2s .com*/ * @param out */ private void transformArrowShape(Point2D down, Point2D out) { float x1 = (float) down.getX(); float y1 = (float) down.getY(); float x2 = (float) out.getX(); float y2 = (float) out.getY(); AffineTransform xform = AffineTransform.getTranslateInstance(x2, y2); float dx = x2 - x1; float dy = y2 - y1; float thetaRadians = (float) Math.atan2(dy, dx); xform.rotate(thetaRadians); arrowShape = xform.createTransformedShape(rawArrowShape); }
From source file:lu.lippmann.cdb.graph.mouse.CadralEditingGraphMousePlugin.java
/** * Function to create the edge shape while drawing * @param down/*from w w w.j a v a2s . com*/ * @param out */ private void transformEdgeShape(Point2D down, Point2D out) { float x1 = (float) down.getX(); float y1 = (float) down.getY(); float x2 = (float) out.getX(); float y2 = (float) out.getY(); AffineTransform xform = AffineTransform.getTranslateInstance(x1, y1); float dx = x2 - x1; float dy = y2 - y1; float thetaRadians = (float) Math.atan2(dy, dx); xform.rotate(thetaRadians); float dist = (float) Math.sqrt(dx * dx + dy * dy); xform.scale((double) dist / rawEdge.getBounds().getWidth(), 1.0d); edgeShape = xform.createTransformedShape(rawEdge); }
From source file:com.anrisoftware.globalpom.format.point.PointFormat.java
private void formatPoint(StringBuffer buff, Point2D point) { buff.append("("); numberFormat.format(point.getX(), buff, new FieldPosition(0)); buff.append(", "); numberFormat.format(point.getY(), buff, new FieldPosition(0)); buff.append(")"); }
From source file:org.gvsig.symbology.fmap.symbols.JFreeChartSymbol.java
public void draw(Graphics2D g, AffineTransform affineTransform, FShape shp, Cancellable cancel) { FPoint2D fp = (FPoint2D) shp;/* w ww .j a va 2s . com*/ Point2D p = new Point2D.Double(fp.getX(), fp.getY()); if (renderPlot == null) { renderPlot = getMapPlot(); } double size = getSize(); double halfSize = size * 0.5; double minx = p.getX() - halfSize; double miny = p.getY() - halfSize; renderPlot.draw(g, new Rectangle2D.Double(minx, miny, size, size), p, plotState, plotRenderingInfo); }
From source file:org.mwc.cmap.grideditor.chart.DataPointsDragTracker.java
public void chartMouseReleased(final ChartMouseEvent event) { if (!myDragSubject.isEmpty() && myDragSubject.getLastDomainPoint() != null) { try {//from ww w . j av a2 s . c o m final Point2D finalPoint = myDragSubject.getLastDomainPoint(); dragCompleted(myDragSubject.getDraggedItem(), finalPoint.getX(), finalPoint.getY()); } catch (final Exception e) { e.printStackTrace(); } } if (!myDragSubject.isEmpty()) { myDragSubject.setSubject(null); myChartPanel.redrawCanvas(); } }
From source file:inflor.core.gates.ui.PolygonGateAnnotation.java
@Override public boolean matchesVertex(Point2D v, double xHandleSize, double yHandleSize) { double[] x = getDomainPoints(); double[] y = getRangePoints(); double xMin = v.getX() - xHandleSize; double xMax = v.getX() + xHandleSize; double yMin = v.getY() - yHandleSize; double yMax = v.getY() + yHandleSize; for (int i = 0; i < x.length; i++) { if (xMin <= x[i] && x[i] <= xMax && yMin <= y[i] && y[i] <= yMax) { return true; }// w w w . j a v a 2 s . c o m } return false; }
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;//from w w w . ja v a2 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:views.network.MyRadialTreeLayout.java
private void setRadialLocations() { Point2D max = getMaxXY(); double maxx = max.getX(); double maxy = max.getY(); maxx = Math.max(maxx, size.width); double theta = 2 * Math.PI / maxx; double deltaRadius = Math.min(size.width, size.height) / 2 / maxy; for (Map.Entry<V, Point2D> entry : locations.entrySet()) { V v = entry.getKey();/*from w w w . j a v a 2 s . c o m*/ Point2D p = entry.getValue(); PolarPoint polarPoint = new PolarPoint(p.getX() * theta, (p.getY() - 50) * deltaRadius); polarLocations.put(v, polarPoint); } }