當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。