當前位置: 首頁>>代碼示例>>Java>>正文


Java Transform.setRotation方法代碼示例

本文整理匯總了Java中org.eclipse.draw2d.geometry.Transform.setRotation方法的典型用法代碼示例。如果您正苦於以下問題:Java Transform.setRotation方法的具體用法?Java Transform.setRotation怎麽用?Java Transform.setRotation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.draw2d.geometry.Transform的用法示例。


在下文中一共展示了Transform.setRotation方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: draw

import org.eclipse.draw2d.geometry.Transform; //導入方法依賴的package包/類
@Override
public void draw(ArrowAttribute arrowAttr, Graphics graphics, ResourceManager resourceManager) {
  Color fgColor = graphics.getForegroundColor();
  Color bgColor = graphics.getBackgroundColor();
  Color rgb = getSwtColor(arrowAttr.lineColor, resourceManager);
  if (rgb != null) {
    graphics.setForegroundColor(rgb);
    graphics.setBackgroundColor(rgb);
  }

  try {
    float lineWidth = (float) ((DoubleToken) arrowAttr.lineWidth.getToken()).doubleValue();
    graphics.setLineWidthFloat(lineWidth);
    int x = (int) ((DoubleToken) arrowAttr.x.getToken()).doubleValue();
    int y = (int) ((DoubleToken) arrowAttr.y.getToken()).doubleValue();
    int width = (int) ((DoubleToken) arrowAttr.arrowWidth.getToken()).doubleValue();
    int length = (int) ((DoubleToken) arrowAttr.arrowLength.getToken()).doubleValue();
    int halfWidth = width/2;
    Point tlp = getTopLeftLocation(arrowAttr);
    Transform transform = new Transform();
    transform.setRotation(Math.atan2(y, x));
    PointList pList = new PointList();
    pList.addPoint(0, halfWidth);
    pList.addPoint(length + 3,  0);
    pList.addPoint(length,  halfWidth);
    pList.addPoint((int) Math.sqrt(x*x + y*y),  halfWidth);
    pList.addPoint(length,  halfWidth);
    pList.addPoint(length + 3,  width);
    pList = getTransformedPolygon(transform, pList);
    pList.translate(tlp);
    graphics.fillPolygon(pList);
    graphics.drawPolygon(pList);
  } catch (IllegalActionException e) {
    LOGGER.error("Error reading dimensions for " + arrowAttr.getFullName(), e);
  }
  graphics.setForegroundColor(fgColor);
  graphics.setBackgroundColor(bgColor);
}
 
開發者ID:eclipse,項目名稱:triquetrum,代碼行數:39,代碼來源:ArrowDrawingStrategy.java

示例2: rotatePoints

import org.eclipse.draw2d.geometry.Transform; //導入方法依賴的package包/類
/**
 * For a given angle, rotate the point list.
 * 
 * @param angle
 * @param points
 * @return
 */
protected PointList rotatePoints(double angle, PointList points) {
    Transform t = new Transform();
    t.setRotation(angle);
    
    Point center = new Point(getPreferredSize().width / 2, getPreferredSize().height / 2);

    PointList newEdges = TransformationHelper.rotatePoints(angle, edges, center);
    
    if (offset)
        newEdges.translate(t.getTransformed(new PrecisionPoint(DEFAULT_WIDTH * (RESIZEFACTOR - 1) / 2, -DEFAULT_WIDTH * (RESIZEFACTOR - 1) / 2)));
    
    return newEdges;
}
 
開發者ID:McGill-DP-Group,項目名稱:seg.jUCMNav,代碼行數:21,代碼來源:EndPointFigure.java

示例3: rotate

import org.eclipse.draw2d.geometry.Transform; //導入方法依賴的package包/類
/**
 * Apply a rotation to the edges PointList and set the rotated point list as the mainFigure's PointList.
 * 
 * Rotation takes into consideration the fact that the center moves when the number of branches changes.
 */
public void rotate(double angle) {
    if (this.angle != angle) {
        this.angle = angle;
        // build the transformation
        Transform t = new Transform();
        t.setRotation(angle);
        // build the new point list
        PointList newEdges = new PointList();

        // this is the center of the figure in the edges pointlist.
        Point center = new Point(DEFAULT_WIDTH / 2, DEFAULT_HEIGHT * branchCount / 2);

        // this is the center of the figure in the rotated, real size, point list.
        Point centerScaledRotated = new Point(getPreferredSize().width / 2, getPreferredSize().height / 2);

        // rotate edges points around center to generate newEdges
        for (int i = 0; i < edges.size(); i++) {
            Point newPoint = t.getTransformed(new Point(edges.getPoint(i).x - center.x, edges.getPoint(i).y - center.y));
            newEdges.addPoint(newPoint);
        }

        // move them to the center of the rotated figure
        newEdges.translate(centerScaledRotated.x, centerScaledRotated.y);
        mainFigure.setPoints(newEdges);

        // inform the edit part that we've rotated via anchor listeners.
        ((ChopboxAnchor) outgoingAnchor).ancestorMoved(this);
    }
}
 
開發者ID:McGill-DP-Group,項目名稱:seg.jUCMNav,代碼行數:35,代碼來源:AndForkJoinFigure.java

示例4: rotate

import org.eclipse.draw2d.geometry.Transform; //導入方法依賴的package包/類
public void rotate(double angle) {
    // make it always point towards bottom
    if (Math.cos(angle)>0)
        angle -= Math.PI;

    Transform t = new Transform();
    t.setRotation(angle);
    
    Point center = new Point(getPreferredSize().width / 2, getPreferredSize().height / 2);
    
    for (int j = 0; j < lines.size(); j++) {
        PointList points = (PointList) lines.get(j);
        Polyline line = (Polyline) rects.get(j);
        
        PointList newPoints = new PointList();
        for (int i = 0; i < points.size(); i++) {
            Point newPoint = t.getTransformed(new Point(points.getPoint(i).x - center.x, points.getPoint(i).y - center.y));
            //Point pt = new Point(newPoint.x - center.x, newPoint.y - center.y);
            
            newPoints.addPoint(newPoint);
        }
        
        newPoints.translate(center.x, center.y);
        
        line.setPoints(newPoints);
    }
    
    ((EllipseAnchor)outgoingAnchor).ancestorMoved(this);
}
 
開發者ID:McGill-DP-Group,項目名稱:seg.jUCMNav,代碼行數:30,代碼來源:FailurePointFigure.java

示例5: rotatePoints

import org.eclipse.draw2d.geometry.Transform; //導入方法依賴的package包/類
public static PointList rotatePoints(double angle, PointList points, Point center) {
    Transform t = new Transform();
    t.setRotation(angle);

    PointList newEdges = new PointList();

    for (int i = 0; i < points.size(); i++) {
        Point newPoint = t.getTransformed(new Point(points.getPoint(i).x - center.x, points.getPoint(i).y - center.y));
        Point pt = new Point(center.x - newPoint.x, center.y - newPoint.y);
        newEdges.addPoint(pt);
    }
    
    return newEdges;
}
 
開發者ID:McGill-DP-Group,項目名稱:seg.jUCMNav,代碼行數:15,代碼來源:TransformationHelper.java


注:本文中的org.eclipse.draw2d.geometry.Transform.setRotation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。