本文整理汇总了Java中java.awt.geom.Point2D.clone方法的典型用法代码示例。如果您正苦于以下问题:Java Point2D.clone方法的具体用法?Java Point2D.clone怎么用?Java Point2D.clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.geom.Point2D
的用法示例。
在下文中一共展示了Point2D.clone方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toroidalPaint
import java.awt.geom.Point2D; //导入方法依赖的package包/类
protected void toroidalPaint(Graphics2D g2d, Topology tp, Point2D p1, Point2D p2,
boolean wrapX, boolean wrapY){
Point2D p1b = (Point2D) p1.clone();
Point2D p2b = (Point2D) p2.clone();
if (wrapX){
if (p1.getX() < p2.getX()) {
p1b.setLocation(p1b.getX() + tp.getWidth(), p1b.getY());
p2b.setLocation(p2b.getX() - tp.getWidth(), p2b.getY());
}else{
p1b.setLocation(p1b.getX() - tp.getWidth(), p1b.getY());
p2b.setLocation(p2b.getX() + tp.getWidth(), p2b.getY());
}
}
if (wrapY){
if (p1.getY() < p2.getY()) {
p1b.setLocation(p1b.getX(), p1b.getY() + tp.getHeight());
p2b.setLocation(p2b.getX(), p2b.getY() - tp.getHeight());
}else{
p1b.setLocation(p1b.getX(), p1b.getY() - tp.getHeight());
p2b.setLocation(p2b.getX(), p2b.getY() + tp.getHeight());
}
}
drawLine(g2d, p1, p2b);
drawLine(g2d, p1b, p2);
}
示例2: getPoint2D
import java.awt.geom.Point2D; //导入方法依赖的package包/类
/**
* Returns the corresponding destination point for a given source point.
*
* This Op will return the source point unchanged.
*
* @param src The source point.
* @param dst The destination point.
*/
public final Point2D getPoint2D(Point2D src, Point2D dst)
{
if (dst == null)
return (Point2D) src.clone();
dst.setLocation(src);
return dst;
}
示例3: getForceforNode
import java.awt.geom.Point2D; //导入方法依赖的package包/类
/**
* Computes the force experienced by node
* @param node
* @return force vector
*/
@SuppressWarnings("unchecked")
private Point2D getForceforNode(Vertex node) {
double numNodes = graph.getVertices().size();
// double aIndivisual = node.degree() > 1 ? 1+((a-1)/node.degree()) : a;
Point2D mDot = new Point2D.Double();
Point2D x = transform((V)node);
Point2D origin = new Point2D.Double(0.0,0.0);
if (x.distance(origin) == 0.0) {
return mDot;
}
for (Object o : getGraph().getNeighbors((V)node)) {
Vertex otherNode = (Vertex) o;
if (node != otherNode) {
Point2D otherNodeX = transform((V) otherNode);
if (otherNodeX == null || otherNodeX.distance(origin) == 0.0) {
continue;
}
Point2D temp = (Point2D) otherNodeX.clone();
temp.setLocation(temp.getX() - x.getX(), temp.getY() - x.getY());
double multiplier = a-1;
multiplier *= attraction / Math.sqrt(numNodes);
Point2D addition = (Point2D) temp.clone();
addition.setLocation(addition.getX() * multiplier, addition.getY() * multiplier);
mDot.setLocation(mDot.getX() + addition.getX(), mDot.getY() + addition.getY());
}
}
// calculate attraction and repulsion from center of masses
if (incremental && mDot.distance(origin) > forceCutoff) {
double mult = forceCutoff / mDot.distance(origin);
mDot.setLocation(mDot.getX() * mult, mDot.getY() * mult);
}
return mDot;
}
示例4: setZoomPosition
import java.awt.geom.Point2D; //导入方法依赖的package包/类
public void setZoomPosition(Point2D position) {
zoomPos = (Point2D) position.clone();
}
示例5: getPoint2D
import java.awt.geom.Point2D; //导入方法依赖的package包/类
/**
* Returns the corresponding destination point for a source point. Because
* this is not a geometric operation, the destination and source points will
* be identical.
*
* @param src The source point.
* @param dst The transformed destination point.
* @return The transformed destination point.
*/
public final Point2D getPoint2D(Point2D src, Point2D dst)
{
if (dst == null) return (Point2D)src.clone();
dst.setLocation(src);
return dst;
}
示例6: getPoint2D
import java.awt.geom.Point2D; //导入方法依赖的package包/类
/**
* Returns the corresponding destination point for a source point.
* Because this is not a geometric operation, the destination and source
* points will be identical.
*
* @param src The source point.
* @param dst The transformed destination point.
* @return The transformed destination point.
*/
public final Point2D getPoint2D(Point2D src, Point2D dst)
{
if (dst == null)
return (Point2D)src.clone();
dst.setLocation(src);
return dst;
}
示例7: getPoint2D
import java.awt.geom.Point2D; //导入方法依赖的package包/类
/**
* 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;
}
示例8: setDirection
import java.awt.geom.Point2D; //导入方法依赖的package包/类
/**
* Sets the direction angle of this node using the specified reference
* point. Only the resulting angle matters (not the particular location of
* the reference point).
*
* @param p The reference point.
*/
public void setDirection(Point2D p, boolean opposite) {
Point2D p2 = (Point2D) p.clone();
if (opposite)
p2.setLocation(2 * getX() - p.getX(), 2 * getY() - p.getY());
setDirection(p2);
}
示例9: setPosition
import java.awt.geom.Point2D; //导入方法依赖的package包/类
/**
* Sets the position of the vertex to an already created one
* @param position
*/
public void setPosition(Point2D position){
this.position = (Point2D) position.clone();
}