本文整理汇总了Java中org.eclipse.draw2d.Polyline.setPoints方法的典型用法代码示例。如果您正苦于以下问题:Java Polyline.setPoints方法的具体用法?Java Polyline.setPoints怎么用?Java Polyline.setPoints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.draw2d.Polyline
的用法示例。
在下文中一共展示了Polyline.setPoints方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFigure
import org.eclipse.draw2d.Polyline; //导入方法依赖的package包/类
/**
* A simple line, as wide as the bounds.
*
* @see seg.jUCMNav.figures.PathNodeFigure#createFigure()
*/
protected void createFigure() {
mainFigure = new Polygon();
edges = new PointList();
int barWidth = 6 / 2;
edges.addPoint(DEFAULT_WIDTH / 2 - barWidth, 1);
edges.addPoint(DEFAULT_WIDTH / 2 - barWidth, DEFAULT_HEIGHT-1);
edges.addPoint(DEFAULT_WIDTH / 2 + barWidth, DEFAULT_HEIGHT-1);
edges.addPoint(DEFAULT_WIDTH / 2 + barWidth, 1);
edges.addPoint(DEFAULT_WIDTH / 2 - barWidth, 1);
mainFigure.setLineWidth(2);
mainFigure.setPoints(edges);
mainFigure.setAntialias(GeneralPreferencePage.getAntialiasingPref());
mainFigure.setForegroundColor(ColorManager.GRAY);
mainFigure.setBackgroundColor(ColorManager.LINE);
mainFigure.setFill(true);
add(mainFigure);
line = new Polyline();
linePts = new PointList();
linePts.addPoint(new Point(DEFAULT_WIDTH / 2 - barWidth+1, 0));
linePts.addPoint(new Point(DEFAULT_WIDTH / 2 + barWidth-1, DEFAULT_HEIGHT - 1));
line.setPoints(linePts);
line.setLineWidth(2);
line.setAntialias(GeneralPreferencePage.getAntialiasingPref());
line.setForegroundColor(ColorManager.WHITE);
add(line);
}
示例2: rotate
import org.eclipse.draw2d.Polyline; //导入方法依赖的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);
}
示例3: createFigure
import org.eclipse.draw2d.Polyline; //导入方法依赖的package包/类
/**
* An ellipse that fills 2/3 of the area.
*
* @see seg.jUCMNav.figures.PathNodeFigure#createFigure()
*/
protected void createFigure() {
int width = preferredSize.width;
int height = preferredSize.height;
ellipse = new Ellipse();
ellipse.setBounds(new Rectangle(13, 13, 16, 16));
ellipse.setBackgroundColor(ColorManager.LINE);
ellipse.setAntialias(GeneralPreferencePage.getAntialiasingPref());
add(ellipse);
// create the text inside the main figure
flowPage = new FlowPage();
stubTypeText = new TextFlow();
stubTypeText.setLayoutManager(new SimpleTextLayout(stubTypeText));
// TODO CONCERNS: should use default font?
stubTypeText.setFont(new Font(null, "Verdana", 12, SWT.BOLD)); //$NON-NLS-1$
stubTypeText.setText("F"); //$NON-NLS-1$
stubTypeText.setForegroundColor(ColorManager.WHITE);
flowPage.add(stubTypeText);
// TODO CONCERNS: depends on font size!
flowPage.setBounds(new Rectangle(16, 12, 20, 20));
flowPage.setVisible(false);
add(flowPage);
// The lightning for an abort failure point
PointList pts = new PointList();
pts.addPoint(23, 27);
pts.addPoint(27, 33);
pts.addPoint(20, 32);
pts.addPoint(28, 42);
pts.addPoint(28, 37);
pts.addPoint(28, 42);
pts.addPoint(23, 41);
lightning = new Polyline();
lightning.setLineWidth(2);
lightning.setAntialias(GeneralPreferencePage.getAntialiasingPref());
lightning.setPoints(pts);
lightning.setVisible(false);
add(lightning);
bar = new Polyline();
bar.addPoint(new Point(15, 15));
bar.addPoint(new Point(27, 27));
bar.setLineWidth(3);
bar.setVisible(false);
bar.setForegroundColor(ColorManager.WHITE);
add(bar);
}
示例4: createFigure
import org.eclipse.draw2d.Polyline; //导入方法依赖的package包/类
@Override
protected void createFigure() {
int width = getPreferredSize().width;
int height = getPreferredSize().height;
lines = new Vector();
rects = new Vector();
rect1 = new Polyline();
line1 = new PointList();
line1.addPoint(new Point((width - 20) / 2, 18));
line1.addPoint(new Point((width - 20) / 2 + 20, 18));
rect1.setPoints(line1);
rect1.setBackgroundColor(ColorManager.BLACK);
rect1.setLineWidth(2);
rect1.setAntialias(GeneralPreferencePage.getAntialiasingPref());
lines.add(line1);
rects.add(rect1);
add(rect1);
rect2 = new Polyline();
line2 = new PointList();
line2.addPoint(new Point((width - 14) / 2, 13));
line2.addPoint(new Point((width - 14) / 2 + 14, 13));
rect2.setPoints(line2);
rect2.setBackgroundColor(ColorManager.BLACK);
rect2.setLineWidth(2);
rect2.setAntialias(GeneralPreferencePage.getAntialiasingPref());
lines.add(line2);
rects.add(rect2);
add(rect2);
rect3 = new Polyline();
line3 = new PointList();
line3.addPoint(new Point((width - 8) / 2, 8));
line3.addPoint(new Point((width - 8) / 2 + 8, 8));
rect3.setPoints(line3);
rect3.setBackgroundColor(ColorManager.BLACK);
rect3.setLineWidth(2);
rect3.setAntialias(GeneralPreferencePage.getAntialiasingPref());
lines.add(line3);
rects.add(rect3);
add(rect3);
}
示例5: makeShapes
import org.eclipse.draw2d.Polyline; //导入方法依赖的package包/类
private void makeShapes(RelationshipType relationshipType){
List<Point2D.Float> points = new ArrayList<Point2D.Float>();
mFillColor = ColorConstants.black;
boolean isLineDashed = false;
// construct points as percentages inside canvas
switch(relationshipType){
case AGGREGATION:
case HYPER_AGGREGATION:
mFillColor = ColorConstants.white;
case COMPOSITION:
case HYPER_COMPOSITION:
points.add(new Point2D.Float(0.5f, 0.05f));
points.add(new Point2D.Float(0.3f, 0.3f));
points.add(new Point2D.Float(0.5f, 0.55f));
points.add(new Point2D.Float(0.7f, 0.3f));
break;
case DEPENDENCY:
case HYPER_DEPENDENCY:
isLineDashed = true;
case DIRECTEDASSOCIATION:
case HYPER_DIRECTEDASSOCIATION:
points.add(new Point2D.Float(0.5f, 0.05f));
points.add(new Point2D.Float(0.2f, 0.3f));
points.add(new Point2D.Float(0.5f, 0.05f));
points.add(new Point2D.Float(0.8f, 0.3f));
break;
case REALIZATION:
case HYPER_REALIZATION:
isLineDashed = true;
case GENERALIZATION:
case HYPER_GENERALIZATION:
mFillColor = ColorConstants.white;
points.add(new Point2D.Float(0.5f, 0.1f));
points.add(new Point2D.Float(0.25f, 0.4f));
points.add(new Point2D.Float(0.75f, 0.4f));
break;
case ASSOCIATION:
case HYPER_ASSOCIATION:
// no head
break;
default:
throw new RuntimeException("Relationship type not supported.");
}
// scale polygon to fit in the canvas
if(points.size() > 0){
mPolygon = new PointList();
for(int i=0; i < points.size(); ++i){
Point2D.Float p = points.get(i);
mPolygon.addPoint(new Point((int) (p.x * CANVAS.width()),
(int) (p.y * CANVAS.height())));
}
}
else{
mPolygon = null;
}
mLinePoints = new PointList();
mLinePoints.addPoint((int) (0.5f * CANVAS.width()), (int) (0.05f * CANVAS.height()));
mLinePoints.addPoint((int) (0.5f * CANVAS.width()), (int) (0.95f * CANVAS.height()));
mLine = new Polyline();
mLine.setPoints(mLinePoints);
if(isLineDashed){
mLine.setLineDash(LINE_DASH);
mLine.setLineStyle(SWT.LINE_DASH);
}
else{
mLine.setLineStyle(SWT.LINE_SOLID);
}
}