当前位置: 首页>>代码示例>>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;未经允许,请勿转载。