本文整理汇总了Java中org.eclipse.draw2d.geometry.Transform类的典型用法代码示例。如果您正苦于以下问题:Java Transform类的具体用法?Java Transform怎么用?Java Transform使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Transform类属于org.eclipse.draw2d.geometry包,在下文中一共展示了Transform类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doFillShape
import org.eclipse.draw2d.geometry.Transform; //导入依赖的package包/类
@Override
public void doFillShape(ResizablePolygonAttribute polygonAttr, Graphics graphics, Rectangle bounds) throws IllegalActionException {
PointList pList = getPolygonPoints(polygonAttr);
Dimension dim = bounds.getSize();
Point tlp = bounds.getTopLeft();
Dimension rawDim = getRawBounds(pList).getSize();
// Ptolemy scales x and y potentially differently, depending on the ratios
// of dim width & height and rawDim width & height respectively.
double scaleWidth = dim.preciseWidth() / rawDim.preciseWidth();
double scaleHeight = dim.preciseHeight() / rawDim.preciseHeight();
Transform transform = new Transform();
transform.setScale(scaleWidth, scaleHeight);
pList = getTransformedPolygon(transform, pList);
pList.translate(tlp);
graphics.fillPolygon(pList);
}
示例2: doDrawBorder
import org.eclipse.draw2d.geometry.Transform; //导入依赖的package包/类
@Override
public void doDrawBorder(ResizablePolygonAttribute polygonAttr, Graphics graphics, Rectangle bounds) throws IllegalActionException {
PointList pList = getPolygonPoints(polygonAttr);
Dimension dim = bounds.getSize();
Point tlp = bounds.getTopLeft();
Dimension rawDim = getRawBounds(pList).getSize();
// Ptolemy scales x and y potentially differently, depending on the ratios
// of dim width & height and rawDim width & height respectively.
double scaleWidth = dim.preciseWidth() / rawDim.preciseWidth();
double scaleHeight = dim.preciseHeight() / rawDim.preciseHeight();
Transform transform = new Transform();
transform.setScale(scaleWidth, scaleHeight);
pList = getTransformedPolygon(transform, pList);
pList.translate(tlp);
graphics.drawPolygon(pList);
}
示例3: 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);
}
示例4: getTransformedPolygon
import org.eclipse.draw2d.geometry.Transform; //导入依赖的package包/类
/**
* Applies the given transformation to all points in the pointList.
* (really just filling a gap in the PointList API)
* @param trf
* @param pointList
* @return the list of transformed points
*/
protected final PointList getTransformedPolygon(Transform trf, PointList pointList) {
PointList result = new PointList(pointList.size());
for (int i=0; i<pointList.size(); ++i ) {
result.addPoint(trf.getTransformed(pointList.getPoint(i)));
}
return result;
}
示例5: 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;
}
示例6: 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);
}
}
示例7: 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);
}
示例8: 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;
}