Java Code Examples for java.awt.geom.Point2D#setLocation()

The following examples show how to use java.awt.geom.Point2D#setLocation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BoxConnector.java    From jclic with GNU General Public License v2.0 6 votes vote down vote up
public static void drawLine(Graphics2D g2, Point2D origin, Point2D dest, boolean arrow, Color color, Color xorColor,
    double arrow_l, double arrowAngle, float strokeWidth) {
  Stroke oldStroke = g2.getStroke();
  Object oldStrokeHint = g2.getRenderingHint(RenderingHints.KEY_STROKE_CONTROL);
  g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT);
  g2.setColor(color);
  if (USE_XOR && xorColor != null)
    g2.setXORMode(xorColor);
  g2.setStroke(strokeWidth == LINE_WIDTH ? BASIC_STROKE : new BasicStroke(strokeWidth));
  g2.drawLine((int) origin.getX(), (int) origin.getY(), (int) dest.getX(), (int) dest.getY());
  if (arrow) {
    double beta = Math.atan2(origin.getY() - dest.getY(), dest.getX() - origin.getX());
    Point2D arp = new Point2D.Double(dest.getX() - arrow_l * Math.cos(beta + arrowAngle),
        dest.getY() + arrow_l * Math.sin(beta + arrowAngle));
    g2.drawLine((int) dest.getX(), (int) dest.getY(), (int) arp.getX(), (int) arp.getY());
    arp.setLocation(dest.getX() - arrow_l * Math.cos(beta - arrowAngle),
        dest.getY() + arrow_l * Math.sin(beta - arrowAngle));
    g2.drawLine((int) dest.getX(), (int) dest.getY(), (int) arp.getX(), (int) arp.getY());
  }
  if (USE_XOR && xorColor != null)
    g2.setPaintMode();
  g2.setStroke(oldStroke);
  g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, oldStrokeHint);
}
 
Example 2
Source File: GraphicsLib.java    From osp with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Compute the intersection of two line segments.
 * @param a1x the x-coordinate of the first endpoint of the first line
 * @param a1y the y-coordinate of the first endpoint of the first line
 * @param a2x the x-coordinate of the second endpoint of the first line
 * @param a2y the y-coordinate of the second endpoint of the first line
 * @param b1x the x-coordinate of the first endpoint of the second line
 * @param b1y the y-coordinate of the first endpoint of the second line
 * @param b2x the x-coordinate of the second endpoint of the second line
 * @param b2y the y-coordinate of the second endpoint of the second line
 * @param intersect a Point in which to store the intersection point
 * @return the intersection code. One of {@link #NO_INTERSECTION},
 * {@link #COINCIDENT}, or {@link #PARALLEL}.
 */
public static int intersectLineLine(double a1x, double a1y, double a2x, double a2y, double b1x, double b1y, double b2x, double b2y, Point2D intersect) {
  double ua_t = (b2x-b1x)*(a1y-b1y)-(b2y-b1y)*(a1x-b1x);
  double ub_t = (a2x-a1x)*(a1y-b1y)-(a2y-a1y)*(a1x-b1x);
  double u_b = (b2y-b1y)*(a2x-a1x)-(b2x-b1x)*(a2y-a1y);
  if(u_b!=0) {
    double ua = ua_t/u_b;
    double ub = ub_t/u_b;
    if((0<=ua)&&(ua<=1)&&(0<=ub)&&(ub<=1)) {
      intersect.setLocation(a1x+ua*(a2x-a1x), a1y+ua*(a2y-a1y));
      return 1;
    }
    return NO_INTERSECTION;
  }
  return(((ua_t==0)||(ub_t==0)) ? COINCIDENT : PARALLEL);
}
 
Example 3
Source File: ShadowFilter.java    From Pixelitor with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Point2D getPoint2D(Point2D srcPt, Point2D dstPt) {
    if (dstPt == null) {
        dstPt = new Point2D.Double();
    }

    if (addMargins) {
        float xOffset = distance * (float) Math.cos(angle);
        float yOffset = -distance * (float) Math.sin(angle);
        float topShadow = Math.max(0, radius - yOffset);
        float leftShadow = Math.max(0, radius - xOffset);
        dstPt.setLocation(srcPt.getX() + leftShadow, srcPt.getY() + topShadow);
    } else {
        dstPt.setLocation(srcPt.getX(), srcPt.getY());
    }

    return dstPt;
}
 
Example 4
Source File: WtgPropertyHelper.java    From workcraft with MIT License 6 votes vote down vote up
private static Point2D newSignalPosition(VisualWaveform visualWaveform) {
    Point2D result = null;
    for (VisualComponent visualComponent : visualWaveform.getComponents()) {
        if (visualComponent instanceof VisualSignal) {
            VisualSignal visualSignal = (VisualSignal) visualComponent;
            if (result == null) {
                result = new Point2D.Double(visualSignal.getX(), visualSignal.getY());
            } else if (visualSignal.getY() > result.getY()) {
                result.setLocation(visualSignal.getX(), visualSignal.getY());
            }
        }
    }
    Point2D waveformCenter = visualWaveform.getCenter();
    if (result != null) {
        result.setLocation(result.getX() + waveformCenter.getX(),
                result.getY() + DtdSettings.getVerticalSeparation() + waveformCenter.getY());
    } else {
        result = waveformCenter;
    }
    return result;
}
 
Example 5
Source File: BrushedMetalFilter.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Point2D getPoint2D(final Point2D SOURCE_POINT, Point2D dstPt) {
    if (dstPt == null) {
        dstPt = new Point2D.Double();
    }
    dstPt.setLocation(SOURCE_POINT.getX(), SOURCE_POINT.getY());
    return dstPt;
}
 
Example 6
Source File: TextLayout.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Convert a hit to a point in standard coordinates.  The point is
 * on the baseline of the character at the leading or trailing
 * edge of the character, as appropriate.  If the path is
 * broken at the side of the character represented by the hit, the
 * point will be adjacent to the character.
 * @param hit the hit to check.  This must be a valid hit on
 * the TextLayout.
 * @param point the returned point. The point is in standard
 *     coordinates.
 * @throws IllegalArgumentException if the hit is not valid for the
 * TextLayout.
 * @throws NullPointerException if hit or point is null.
 * @since 1.6
 */
public void hitToPoint(TextHitInfo hit, Point2D point) {
    if (hit == null || point == null) {
        throw new NullPointerException((hit == null ? "hit" : "point") +
                                       " can't be null");
    }
    ensureCache();
    checkTextHit(hit);

    float adv = 0;
    float off = 0;

    int ix = hit.getCharIndex();
    boolean leading = hit.isLeadingEdge();
    boolean ltr;
    if (ix == -1 || ix == textLine.characterCount()) {
        ltr = textLine.isDirectionLTR();
        adv = (ltr == (ix == -1)) ? 0 : lineMetrics.advance;
    } else {
        ltr = textLine.isCharLTR(ix);
        adv = textLine.getCharLinePosition(ix, leading);
        off = textLine.getCharYPosition(ix);
    }
    point.setLocation(adv, off);
    LayoutPath lp = textLine.getLayoutPath();
    if (lp != null) {
        lp.pathToPoint(point, ltr != leading, point);
    }
}
 
Example 7
Source File: ImageFrameFullScreen.java    From orbit-image-analysis with GNU General Public License v3.0 5 votes vote down vote up
public ImageFrameFullScreen(ImageFrame frame, Point2D offs, double scale) {
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Dimension size = toolkit.getScreenSize();
        offs.setLocation(offs.getX() - (size.width / 2d), offs.getY() - (size.height / 2d));
        RecognitionFrame rf;
        try {
            rf = new RecognitionFrame(frame.recognitionFrame, true);
            newFrame = new ImageFrame(rf);
            newFrame.setExclusive(true);
            rf.setViewPortSize(size);
            rf.setViewPortOffset(offs);
            rf.setScale(scale);

            newFrame.getOpacitySlider().setVisible(false);

            setLayout(null);
            newFrame.getRootPane().setSize(size);
            newFrame.getRootPane().setBounds(0, 0, size.width, size.height);
            add(newFrame.getRootPane());

            //	grid = renderGrid;

//		grid = new RenderGrid(newFrame.recognitionFrame.bimg);
//		grid.setImageSize(new Dimension(newFrame.recognitionFrame.bimg.image.getWidth(),newFrame.recognitionFrame.bimg.image.getHeight()));
//		grid.setBounds(/*size.width*/1000-200,0,200,200);
            //	add(grid);

            //setSize(size);
            //setBounds(0, 0, size.width, size.height);

        } catch (Exception e) {
            e.printStackTrace();
            logger.error("error: ", e);
        }
    }
 
Example 8
Source File: TextLayout.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Convert a hit to a point in standard coordinates.  The point is
 * on the baseline of the character at the leading or trailing
 * edge of the character, as appropriate.  If the path is
 * broken at the side of the character represented by the hit, the
 * point will be adjacent to the character.
 * @param hit the hit to check.  This must be a valid hit on
 * the TextLayout.
 * @param point the returned point. The point is in standard
 *     coordinates.
 * @throws IllegalArgumentException if the hit is not valid for the
 * TextLayout.
 * @throws NullPointerException if hit or point is null.
 * @since 1.6
 */
public void hitToPoint(TextHitInfo hit, Point2D point) {
    if (hit == null || point == null) {
        throw new NullPointerException((hit == null ? "hit" : "point") +
                                       " can't be null");
    }
    ensureCache();
    checkTextHit(hit);

    float adv = 0;
    float off = 0;

    int ix = hit.getCharIndex();
    boolean leading = hit.isLeadingEdge();
    boolean ltr;
    if (ix == -1 || ix == textLine.characterCount()) {
        ltr = textLine.isDirectionLTR();
        adv = (ltr == (ix == -1)) ? 0 : lineMetrics.advance;
    } else {
        ltr = textLine.isCharLTR(ix);
        adv = textLine.getCharLinePosition(ix, leading);
        off = textLine.getCharYPosition(ix);
    }
    point.setLocation(adv, off);
    LayoutPath lp = textLine.getLayoutPath();
    if (lp != null) {
        lp.pathToPoint(point, ltr != leading, point);
    }
}
 
Example 9
Source File: ConvolveOp.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the location of the destination point given a
 * point in the source.  If dstPt is non-null, it will
 * be used to hold the return value.  Since this is not a geometric
 * operation, the srcPt will equal the dstPt.
 */
public final Point2D getPoint2D(Point2D srcPt, Point2D dstPt) {
    if (dstPt == null) {
        dstPt = new Point2D.Float();
    }
    dstPt.setLocation(srcPt.getX(), srcPt.getY());

    return dstPt;
}
 
Example 10
Source File: PerspectiveTransform.java    From Pixelitor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Transforms an array of point objects by this transform.
 * @param ptSrc The array containing the source point objects.
 * @param ptDst The array where the transform point objects are returned.
 * @param srcOff The offset to the first point object to be transformed
 *               in the source array.
 * @param dstOff The offset to the location where the first transformed
 *               point object is stored in the destination array.
 * @param numPts The number of point objects to be transformed.
 * @throws IllegalArgumentException       if ptSrc is null
 * @throws IllegalArgumentException       if ptDst is null
 * @throws ArrayIndexOutOfBoundsException if ptSrc is too small
 */
public void transform(Point2D[] ptSrc, int srcOff,
                      Point2D[] ptDst, int dstOff,
                      int numPts) {

    if (ptSrc == null || ptDst == null) {
        throw new IllegalArgumentException(JaiI18N.getString("Generic0"));
    }

    while (numPts-- > 0) {
        /* Copy source coords into local variables in case src == dst. */
        Point2D src = ptSrc[srcOff++];
        Point2D dst = ptDst[dstOff++];
        if (dst == null) {
            if (src instanceof Point2D.Double) {
                dst = new Point2D.Double();
            } else {
                dst = new Point2D.Float();
            }
            ptDst[dstOff - 1] = dst;
        }

        double x = src.getX();
        double y = src.getY();
        double w = m20 * x + m21 * y + m22;

        if (w == 0) {
            dst.setLocation(x, y);
        } else {
            dst.setLocation((m00 * x + m01 * y + m02) / w,
                    (m10 * x + m11 * y + m12) / w);
        }
    }
}
 
Example 11
Source File: LayoutPathImpl.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public void pathToPoint(Point2D location, boolean preceding, Point2D point) {
    if (tx != null) {
        tx.transform(location, point);
    } else {
        point.setLocation(location);
    }
}
 
Example 12
Source File: TextLayout.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Convert a hit to a point in standard coordinates.  The point is
 * on the baseline of the character at the leading or trailing
 * edge of the character, as appropriate.  If the path is
 * broken at the side of the character represented by the hit, the
 * point will be adjacent to the character.
 * @param hit the hit to check.  This must be a valid hit on
 * the TextLayout.
 * @param point the returned point. The point is in standard
 *     coordinates.
 * @throws IllegalArgumentException if the hit is not valid for the
 * TextLayout.
 * @throws NullPointerException if hit or point is null.
 * @since 1.6
 */
public void hitToPoint(TextHitInfo hit, Point2D point) {
    if (hit == null || point == null) {
        throw new NullPointerException((hit == null ? "hit" : "point") +
                                       " can't be null");
    }
    ensureCache();
    checkTextHit(hit);

    float adv = 0;
    float off = 0;

    int ix = hit.getCharIndex();
    boolean leading = hit.isLeadingEdge();
    boolean ltr;
    if (ix == -1 || ix == textLine.characterCount()) {
        ltr = textLine.isDirectionLTR();
        adv = (ltr == (ix == -1)) ? 0 : lineMetrics.advance;
    } else {
        ltr = textLine.isCharLTR(ix);
        adv = textLine.getCharLinePosition(ix, leading);
        off = textLine.getCharYPosition(ix);
    }
    point.setLocation(adv, off);
    LayoutPath lp = textLine.getLayoutPath();
    if (lp != null) {
        lp.pathToPoint(point, ltr != leading, point);
    }
}
 
Example 13
Source File: RectangleAnchor.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the (x, y) coordinates of the specified anchor.
 *
 * @param rectangle  the rectangle.
 * @param anchor  the anchor.
 *
 * @return The (x, y) coordinates.
 */
public static Point2D coordinates(final Rectangle2D rectangle,
                                  final RectangleAnchor anchor) {
    Point2D result = new Point2D.Double();
    if (anchor == RectangleAnchor.CENTER) {
        result.setLocation(rectangle.getCenterX(), rectangle.getCenterY());
    }
    else if (anchor == RectangleAnchor.TOP) {
        result.setLocation(rectangle.getCenterX(), rectangle.getMinY());
    }
    else if (anchor == RectangleAnchor.BOTTOM) {
        result.setLocation(rectangle.getCenterX(), rectangle.getMaxY());
    }
    else if (anchor == RectangleAnchor.LEFT) {
        result.setLocation(rectangle.getMinX(), rectangle.getCenterY());
    }
    else if (anchor == RectangleAnchor.RIGHT) {
        result.setLocation(rectangle.getMaxX(), rectangle.getCenterY());
    }
    else if (anchor == RectangleAnchor.TOP_LEFT) {
        result.setLocation(rectangle.getMinX(), rectangle.getMinY());
    }
    else if (anchor == RectangleAnchor.TOP_RIGHT) {
        result.setLocation(rectangle.getMaxX(), rectangle.getMinY());
    }
    else if (anchor == RectangleAnchor.BOTTOM_LEFT) {
        result.setLocation(rectangle.getMinX(), rectangle.getMaxY());
    }
    else if (anchor == RectangleAnchor.BOTTOM_RIGHT) {
        result.setLocation(rectangle.getMaxX(), rectangle.getMaxY());
    }
    return result;
}
 
Example 14
Source File: AbstractMathTransform2D.java    From sis with Apache License 2.0 5 votes vote down vote up
/**
 * Implementation of {@link #transform(Point2D, Point2D)} shared by the inverse transform.
 */
static Point2D transform(final AbstractMathTransform tr, final Point2D ptSrc, final Point2D ptDst) throws TransformException {
    final double[] ord = new double[] {ptSrc.getX(), ptSrc.getY()};
    tr.transform(ord, 0, ord, 0, false);
    if (ptDst != null) {
        ptDst.setLocation(ord[0], ord[1]);
        return ptDst;
    } else {
        return new Point2D.Double(ord[0], ord[1]);
    }
}
 
Example 15
Source File: PainterShaped.java    From Logisim with GNU General Public License v3.0 4 votes vote down vote up
private static int[] getInputLineLengths(GateAttributes attrs, AbstractGate factory) {
	int inputs = attrs.inputs;
	int mainHeight = ((Integer) attrs.size.getValue()).intValue();
	Integer key = Integer.valueOf(inputs * 31 + mainHeight);
	Object ret = INPUT_LENGTHS.get(key);
	if (ret != null) {
		return (int[]) ret;
	}

	Direction facing = attrs.facing;
	if (facing != Direction.EAST) {
		attrs = (GateAttributes) attrs.clone();
		attrs.facing = Direction.EAST;
	}

	int[] lengths = new int[inputs];
	INPUT_LENGTHS.put(key, lengths);
	int width = mainHeight;
	Location loc0 = OrGate.FACTORY.getInputOffset(attrs, 0);
	Location locn = OrGate.FACTORY.getInputOffset(attrs, inputs - 1);
	int totalHeight = 10 + loc0.manhattanDistanceTo(locn);
	if (totalHeight < width)
		totalHeight = width;

	GeneralPath path = computeShield(width, totalHeight);
	for (int i = 0; i < inputs; i++) {
		Location loci = OrGate.FACTORY.getInputOffset(attrs, i);
		Point2D p = new Point2D.Float(loci.getX() + 1, loci.getY());
		int iters = 0;
		while (path.contains(p) && iters < 15) {
			iters++;
			p.setLocation(p.getX() + 1, p.getY());
		}
		if (iters >= 15)
			iters = 0;
		lengths[i] = iters;
	}

	/*
	 * used prior to 2.5.1, when moved to GeneralPath int wingHeight = (totalHeight
	 * - mainHeight) / 2; double wingCenterX = wingHeight * Math.sqrt(3) / 2; double
	 * mainCenterX = mainHeight * Math.sqrt(3) / 2;
	 * 
	 * for (int i = 0; i < inputs; i++) { Location loci =
	 * factory.getInputOffset(attrs, i); int disti = 5 +
	 * loc0.manhattanDistanceTo(loci); if (disti > totalHeight - disti) { // ensure
	 * on top half disti = totalHeight - disti; } double dx; if (disti < wingHeight)
	 * { // point is on wing int dy = wingHeight / 2 - disti; dx =
	 * Math.sqrt(wingHeight * wingHeight - dy * dy) - wingCenterX; } else { // point
	 * is on main shield int dy = totalHeight / 2 - disti; dx = Math.sqrt(mainHeight
	 * * mainHeight - dy * dy) - mainCenterX; } lengths[i] = (int) (dx - 0.5); }
	 */
	return lengths;
}
 
Example 16
Source File: BristleStroke.java    From pumpernickel with MIT License 4 votes vote down vote up
public Shape createStrokedShape(Shape p) {
	GeneralPath path = new GeneralPath();
	Random r = new Random(randomSeed);

	MeasuredShape[] paths = MeasuredShape.getSubpaths(p);

	for (int a = 0; a < layers; a++) {
		float k1 = ((float) a) / ((float) (layers - 1));
		float k2 = (k1 - .5f) * 2; // range from [-1,1]

		float k3 = thickness;
		float minGapDistance = (4 + 10 * k3) / (1 + 9 * spacing);
		float maxGapDistance = (40 + 10 * k3) / (1 + 9 * spacing);

		Point2D p2 = new Point2D.Float();
		float x, y;

		for (int b = 0; b < paths.length; b++) {
			r.setSeed(randomSeed + 1000 * a + 10000 * b);

			float d = r.nextFloat() * (maxGapDistance - minGapDistance)
					+ minGapDistance * (1
							+ 20 * (1 - thickness) * Math.abs(k2 * k2));
			while (d < paths[b].getOriginalDistance()) {
				float gapDistance = r.nextFloat()
						* (maxGapDistance - minGapDistance)
						+ minGapDistance * (1
								+ 20 * (1 - thickness) * Math.abs(k2 * k2));

				paths[b].getPoint(d, p2);
				float angle = paths[b].getTangentSlope(d);
				float dx = (float) (k2 * width
						* Math.cos(angle + Math.PI / 2) / 2.0);
				float dy = (float) (k2 * width
						* Math.sin(angle + Math.PI / 2) / 2.0);

				p2.setLocation(p2.getX() + dx, p2.getY() + dy);

				x = (float) p2.getX();
				y = (float) p2.getY();

				float rotation = r.nextFloat() * 2 * 3.145f;

				boolean isTriangle = r.nextBoolean();

				if (isTriangle) {
					path.moveTo(
							(float) (x + grain / 2.0
									* Math.cos(rotation + 2 * Math.PI / 3)),
							(float) (y + grain / 2.0 * Math
									.sin(rotation + 2 * Math.PI / 3)));
					path.lineTo(
							(float) (x + grain / 2.0
									* Math.cos(rotation + 4 * Math.PI / 3)),
							(float) (y + grain / 2.0 * Math
									.sin(rotation + 4 * Math.PI / 3)));
					path.lineTo(
							(float) (x + grain / 2.0 * Math.cos(rotation)),
							(float) (y + grain / 2.0 * Math.sin(rotation)));
					path.closePath();
				} else {
					path.moveTo(
							(float) (x + grain / 2.0
									* Math.cos(rotation + 2 * Math.PI / 4)),
							(float) (y + grain / 2.0 * Math
									.sin(rotation + 2 * Math.PI / 4)));
					path.lineTo(
							(float) (x + grain / 2.0
									* Math.cos(rotation + 4 * Math.PI / 4)),
							(float) (y + grain / 2.0 * Math
									.sin(rotation + 4 * Math.PI / 4)));
					path.lineTo(
							(float) (x + grain / 2.0
									* Math.cos(rotation + 6 * Math.PI / 4)),
							(float) (y + grain / 2.0 * Math
									.sin(rotation + 6 * Math.PI / 4)));
					path.lineTo(
							(float) (x + grain / 2.0 * Math.cos(rotation)),
							(float) (y + grain / 2.0 * Math.sin(rotation)));
					path.closePath();
				}

				d = d + gapDistance;
			}
		}
	}
	return path;
}
 
Example 17
Source File: LayoutPathImpl.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
public void pointToPath(double x, double y, Point2D pt) {
    pt.setLocation(x, y);
    pointToPath(pt, pt);
}
 
Example 18
Source File: LookupOp.java    From openjdk-jdk9 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns the location of the destination point given a
 * point in the source.  If {@code dstPt} is not
 * {@code null}, it will be used to hold the return value.
 * Since this is not a geometric operation, the {@code srcPt}
 * will equal the {@code dstPt}.
 * @param srcPt a {@code Point2D} that represents a point
 *        in the source image
 * @param dstPt a {@code Point2D} that represents the location
 *        in the destination
 * @return the {@code Point2D} in the destination that
 *         corresponds to the specified point in the source.
 */
public final Point2D getPoint2D (Point2D srcPt, Point2D dstPt) {
    if (dstPt == null) {
        dstPt = new Point2D.Float();
    }
    dstPt.setLocation(srcPt.getX(), srcPt.getY());

    return dstPt;
}
 
Example 19
Source File: LookupOp.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns the location of the destination point given a
 * point in the source.  If <code>dstPt</code> is not
 * <code>null</code>, it will be used to hold the return value.
 * Since this is not a geometric operation, the <code>srcPt</code>
 * will equal the <code>dstPt</code>.
 * @param srcPt a <code>Point2D</code> that represents a point
 *        in the source image
 * @param dstPt a <code>Point2D</code>that represents the location
 *        in the destination
 * @return the <code>Point2D</code> in the destination that
 *         corresponds to the specified point in the source.
 */
public final Point2D getPoint2D (Point2D srcPt, Point2D dstPt) {
    if (dstPt == null) {
        dstPt = new Point2D.Float();
    }
    dstPt.setLocation(srcPt.getX(), srcPt.getY());

    return dstPt;
}
 
Example 20
Source File: BandCombineOp.java    From Java8CN with Apache License 2.0 3 votes vote down vote up
/**
 * Returns the location of the corresponding destination point given a
 * point in the source <CODE>Raster</CODE>.  If <CODE>dstPt</CODE> is
 * specified, it is used to hold the return value.
 * Since this is not a geometric operation, the point returned
 * is the same as the specified <CODE>srcPt</CODE>.
 *
 * @param srcPt The <code>Point2D</code> that represents the point in
 *              the source <code>Raster</code>
 * @param dstPt The <CODE>Point2D</CODE> in which to store the result.
 *
 * @return The <CODE>Point2D</CODE> in the destination image that
 * corresponds to the specified point in the source image.
 */
public final Point2D getPoint2D (Point2D srcPt, Point2D dstPt) {
    if (dstPt == null) {
        dstPt = new Point2D.Float();
    }
    dstPt.setLocation(srcPt.getX(), srcPt.getY());

    return dstPt;
}