/** * Constructs a <code>LinearGradientPaint</code>. * * @param start the gradient axis start <code>Point</code> in user space * @param end the gradient axis end <code>Point</code> in user space * @param fractions numbers ranging from 0.0 to 1.0 specifying the distribution of colors along * the gradient * @param colors array of colors corresponding to each fractional value * @param cycleMethod either NO_CYCLE, REFLECT, or REPEAT * @param colorSpace which colorspace to use for interpolation, either SRGB or LINEAR_RGB * @param gradientTransform transform to apply to the gradient * @throws NullPointerException if one of the points is null, or gradientTransform is null * @throws IllegalArgumentException if start and end points are the same points, or if * fractions.length != colors.length, or if colors is less than 2 in size. */ public LinearGradientPaint( Point2D start, Point2D end, float[] fractions, Color[] colors, CycleMethodEnum cycleMethod, ColorSpaceEnum colorSpace, AffineTransform gradientTransform) { super(fractions, colors, cycleMethod, colorSpace, gradientTransform); // // Check input parameters // if (start == null || end == null) { throw new NullPointerException("Start and end points must be" + "non-null"); } if (start.equals(end)) { throw new IllegalArgumentException("Start point cannot equal" + "endpoint"); } // copy the points... this.start = (Point2D) start.clone(); this.end = (Point2D) end.clone(); }
/** JDGradientPaintの複製を作成します. */ public JDGradientPaint clone() { return new JDGradientPaint( (Point2D) p1.clone(), (Point2D) p2.clone(), c1, c2, controlPoints.clone(), colors.clone(), gType); }
/** Copies the control points to the edit point list. */ private void copyConnectionPointsToEditPoints() { editpoints.clear(); editedOffset = 0; for (Point2D point : getConnection().getPoints()) { editpoints.add((Point2D) point.clone()); } }
public Frame(Point2D point, Vector2D vec1, Vector2D vec2) throws NoninvertibleTransformException { toStd_ = new AffineTransform( vec1.getX(), vec1.getY(), vec2.getX(), vec2.getY(), point.getX(), point.getY()); fromStd_ = toStd_.createInverse(); origin_ = (Point2D) point.clone(); xAxis_ = new Vector2D(vec1); yAxis_ = new Vector2D(vec2); }
/** * Computes the destination point corresponding to the supplied point. * * @param sourcePt the position in source image coordinates to map to destination image * coordinates. * @return a <code>Point2D</code> of the same class as <code>sourcePt</code>. * @throws IllegalArgumentException if <code>sourcePt</code> is <code>null</code>. * @since JAI 1.1.2 */ public Point2D mapSourcePoint(Point2D sourcePt) { if (sourcePt == null) { throw new IllegalArgumentException(JaiI18N.getString("Generic0")); } Point2D pt = (Point2D) sourcePt.clone(); pt.setLocation(sourcePt.getX() / 4.0, sourcePt.getY() / 4.0); return pt; }
/** * Computes the source point corresponding to the supplied point. * * @param destPt the position in destination image coordinates to map to source image coordinates. * @return a <code>Point2D</code> of the same class as <code>destPt</code>. * @throws IllegalArgumentException if <code>destPt</code> is <code>null</code>. * @since JAI 1.1.2 */ public Point2D mapDestPoint(Point2D destPt) { if (destPt == null) { throw new IllegalArgumentException(JaiI18N.getString("Generic0")); } Point2D pt = (Point2D) destPt.clone(); pt.setLocation(destPt.getX() * 4.0, destPt.getY() * 4.0); return pt; }
public Point2D evaluate(Point2D v0, Point2D v1, float fraction) { if (value == null) { // TODO: Note that future calls to this Evaluator may // use a different subclass of Point2D, so the precision of the // result may vary because we are caching a clone of // the first instance we received value = (Point2D) v0.clone(); } double x = v0.getX() + ((v1.getX() - v0.getX()) * fraction); double y = v0.getY() + ((v1.getY() - v0.getY()) * fraction); value.setLocation(x, y); return value; }
/** {@inheritDoc} */ public void processInput() { if (nextInput == null) { return; } final PInputEvent e = new PInputEvent(this, nextInput); Point2D newCurrentCanvasPosition = null; Point2D newLastCanvasPosition = null; if (e.isMouseEvent()) { if (e.isMouseEnteredOrMouseExited()) { final PPickPath aPickPath = nextInputSource.pick( ((MouseEvent) nextInput).getX(), ((MouseEvent) nextInput).getY(), 1); setMouseOver(aPickPath); previousMouseOver = aPickPath; newCurrentCanvasPosition = (Point2D) currentCanvasPosition.clone(); newLastCanvasPosition = (Point2D) lastCanvasPosition.clone(); } else { lastCanvasPosition.setLocation(currentCanvasPosition); currentCanvasPosition.setLocation( ((MouseEvent) nextInput).getX(), ((MouseEvent) nextInput).getY()); final PPickPath aPickPath = nextInputSource.pick(currentCanvasPosition.getX(), currentCanvasPosition.getY(), 1); setMouseOver(aPickPath); } } nextInput = null; nextInputSource = null; processEvent(e, nextType); if (newCurrentCanvasPosition != null && newLastCanvasPosition != null) { currentCanvasPosition.setLocation(newCurrentCanvasPosition); lastCanvasPosition.setLocation(newLastCanvasPosition); } }
public Frame(Point2D origin, Point2D ptX, Point2D ptY) throws NoninvertibleTransformException { toStd_ = new AffineTransform( ptX.getX() - origin.getX(), ptX.getY() - origin.getY(), ptY.getX() - origin.getX(), ptY.getY() - origin.getY(), origin.getX(), origin.getY()); fromStd_ = toStd_.createInverse(); origin_ = (Point2D) origin.clone(); xAxis_ = new Vector2D(origin, ptX).normalized(); yAxis_ = new Vector2D(origin, ptY).normalized(); }
private Shape createArrowHead(Graphics g) { if (line == null) return null; double size = getLineHeadSize(); Point2D lineStart = line.getP1(); Point2D lineEnd = line.getP2(); double d = Math.max(1.0, lineEnd.distance(lineStart)); double ax = -(size * (lineEnd.getX() - lineStart.getX()) / d); double ay = -(size * (lineEnd.getY() - lineStart.getY()) / d); Polygon poly = new Polygon(); poly.addPoint((int) lineEnd.getX(), (int) lineEnd.getY()); poly.addPoint((int) (lineEnd.getX() + ax + ay / 2), (int) (lineEnd.getY() + ay - ax / 2)); Point2D last = (Point2D) lineEnd.clone(); lineEnd.setLocation(lineEnd.getX() + ax, lineEnd.getY() + ay); poly.addPoint((int) (last.getX() + ax - ay / 2), (int) (last.getY() + ay + ax / 2)); return poly; }
/** Returns the reference point of this marker. */ public Point2D getRef() { return (Point2D) ref.clone(); }
public Point2D getPoint() { return (Point2D) point.clone(); }
/** {@inheritDoc} */ public Point2D getPoint2D(Point2D srcPt, Point2D dstPt) { return (Point2D) srcPt.clone(); }
private void movePoint(int ptIndex, Point2D newPt, boolean adjustBounds) { points.set(ptIndex, (Point2D) newPt.clone()); // TODO: implement adjustBounds == true }
private void calulatePoints() { Point2D sourcePos = null; Point2D destinationPos = null; if (link.getNode1() != link.getNode2()) { /* Ako veza spaja razlicite cvorove. */ sourcePos = link.getNode1().getPosition(); destinationPos = link.getNode2().getPosition(); } else { /* Ako je u pitanju rekurzivna veza. */ double x = link.getNode1().getPosition().getX(); double y = link.getNode1().getPosition().getY(); sourcePos = new Point2D.Double(x - NodePainter.NODE_RADIOUS, y); destinationPos = new Point2D.Double(x, y - NodePainter.NODE_RADIOUS); } /* Rastojanje izmedju tacaka krajeva krive. */ double distance = Math.sqrt( Math.pow(sourcePos.getX() - destinationPos.getX(), 2) + Math.pow(sourcePos.getY() - destinationPos.getY(), 2)); /* * Pocetna tacka. Podesava se tako da pocinje na ivici kruga koji * predstavlja cvor. */ if (link.getNode1() != link.getNode2()) { begin = new Point2D.Double( sourcePos.getX() - NodePainter.NODE_RADIOUS * (sourcePos.getX() - destinationPos.getX()) / distance, sourcePos.getY() - NodePainter.NODE_RADIOUS * (sourcePos.getY() - destinationPos.getY()) / distance); /* Koordinate krajnje tacke veze. */ end = new Point2D.Double( destinationPos.getX() - NodePainter.NODE_RADIOUS * (destinationPos.getX() - sourcePos.getX()) / distance, destinationPos.getY() - NodePainter.NODE_RADIOUS * (destinationPos.getY() - sourcePos.getY()) / distance); } else { begin = (Point2D) sourcePos.clone(); end = (Point2D) destinationPos.clone(); } /* * Znak faktora. Omogucava iscrtavanje veze sa obe strane duzi koja * spaja cvorove. */ int curveFactor = graphView.getPaintedLinkCounter().getNumberOfLinks(link.getNode1(), link.getNode2()); int factorSign = 1; if (link.getNode1() != link.getNode2()) { /* Ako veza spaja razlicite cvorove. */ curveFactor++; factorSign = (curveFactor % 2 == 0 ? 1 : -1); } else { /* Ako je u pitanju rekurzivna veza. */ curveFactor += 4 + graphView.getPaintedLinkCounter().getNumberOfLinks(link.getNode1(), link.getNode2()) / 1; } /* Izracunavanje konacnog faktora zakrivljenosti. */ double factor = factorSign * (curveFactor / 2) * 20; /* Koordinate tacke bezierove krive. */ bezierCurveCoords = calculatePoint( new Point2D.Double(begin.getX(), begin.getY()), new Point2D.Double(end.getX(), end.getY()), factor); /* Koordinate kruga na sredini veze. */ middleCircleCoords = calculatePoint( new Point2D.Double(begin.getX(), begin.getY()), new Point2D.Double(end.getX(), end.getY()), factor * 3.75 / 5); double size4 = graphView.sizeToUserSpace(4); double size8 = graphView.sizeToUserSpace(8); shape = new Ellipse2D.Double( middleCircleCoords.getX() - size4, middleCircleCoords.getY() - size4, size8, size8); /* Trougao. */ triangle = new Polygon(); triangle.addPoint( (int) Math.round((-size4 * Math.sqrt(3) / 2 + 0.1)), (int) Math.round((size4 / 2 + 0.1))); triangle.addPoint(0, (int) -size4); triangle.addPoint( (int) Math.round((size4 * Math.sqrt(3) / 2 + 0.1)), (int) Math.round(size4 / 2 + 0.1)); }
/** * Return corresponding destination point for source point. Because this is not a geometric * operation, it simply returns a copy of the source. * * @param src The source point. * @param dst The destination point. * @return dst The destination point. * @see java.awt.image.RasterOp#getPoint2D(java.awt.geom.Point2D, java.awt.geom.Point2D) */ public final Point2D getPoint2D(Point2D src, Point2D dst) { if (dst == null) return (Point2D) src.clone(); dst.setLocation(src); return dst; }
/** * gets the difference of two points * * @param tar * @param src * @return difference */ public static Point2D diff(Point2D tar, Point2D src) { Point2D result = (Point2D) tar.clone(); result.setLocation(result.getX() - src.getX(), result.getY() - src.getY()); return result; }