当前位置: 首页>>代码示例>>Java>>正文


Java Point2D.clone方法代码示例

本文整理汇总了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);
}
 
开发者ID:acasteigts,项目名称:JBotSim,代码行数:26,代码来源:ToroidalLinkPainter.java

示例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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:LookupOp.java

示例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;
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:53,代码来源:ARF3Layout.java

示例4: setZoomPosition

import java.awt.geom.Point2D; //导入方法依赖的package包/类
public void setZoomPosition(Point2D position) {
	zoomPos = (Point2D) position.clone();
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:4,代码来源:GraphMouseImpl.java

示例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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:ConvolveOp.java

示例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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:ColorConvertOp.java

示例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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:BandCombineOp.java

示例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);
}
 
开发者ID:acasteigts,项目名称:JBotSim,代码行数:14,代码来源:Node.java

示例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();
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:8,代码来源:Vertex.java


注:本文中的java.awt.geom.Point2D.clone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。