Java Code Examples for org.eclipse.draw2d.geometry.PointList#addPoint()

The following examples show how to use org.eclipse.draw2d.geometry.PointList#addPoint() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NoteFigure.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void fillShape(Graphics graphics) {
	graphics.setAlpha(200);

	Rectangle bounds = this.getBounds();

	Point topRight1 = bounds.getTopRight().translate(0, RETURN_WIDTH);
	Point topRight2 = bounds.getTopRight().translate(-RETURN_WIDTH, 0);

	PointList pointList = new PointList();
	pointList.addPoint(bounds.getTopLeft());
	pointList.addPoint(bounds.getBottomLeft());
	pointList.addPoint(bounds.getBottomRight());
	pointList.addPoint(topRight1);
	pointList.addPoint(topRight2);
	pointList.addPoint(bounds.getTopLeft());

	graphics.fillPolygon(pointList);
}
 
Example 2
Source File: CustomSequenceFlowEditPart.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @generated
 */
private RotatableDecoration createTargetDecoration() {
    final PolygonDecoration df = new PolygonDecoration();
    df.setFill(true);
    df.setBackgroundColor(ColorConstants.black);
    final PointList pl = new PointList();
    pl.addPoint(getMapMode().DPtoLP(0)
            , getMapMode().DPtoLP(0)
            );
    pl.addPoint(getMapMode().DPtoLP(-1)
            , getMapMode().DPtoLP(1)
            );
    pl.addPoint(getMapMode().DPtoLP(-1)
            , getMapMode().DPtoLP(-1)
            );
    pl.addPoint(getMapMode().DPtoLP(0)
            , getMapMode().DPtoLP(0)
            );
    df.setTemplate(pl);
    df.setScale(getMapMode().DPtoLP(7)
            , getMapMode().DPtoLP(3)
            );
    return df;
}
 
Example 3
Source File: NoteFigure.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void fillShape(final Graphics graphics) {
    graphics.setAlpha(200);

    final Rectangle bounds = getBounds();

    final Point topRight1 = bounds.getTopRight().translate(0, RETURN_WIDTH);
    final Point topRight2 = bounds.getTopRight().translate(-RETURN_WIDTH, 0);

    final PointList pointList = new PointList();
    pointList.addPoint(bounds.getTopLeft());
    pointList.addPoint(bounds.getBottomLeft());
    pointList.addPoint(bounds.getBottomRight());
    pointList.addPoint(topRight1);
    pointList.addPoint(topRight2);
    pointList.addPoint(bounds.getTopLeft());

    graphics.fillPolygon(pointList);
}
 
Example 4
Source File: DiagramElementsModifier.java    From txtUML with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Sets the points of a connection.
 * 
 * @param connection
 *            - The connection
 * @param bendpoints
 *            - Start, end and bending points
 */
public static void setConnectionPoints(ConnectionNodeEditPart connection, List<Point> bendpoints) {
	TransactionalEditingDomain editingDomain = connection.getEditingDomain();
	SetConnectionBendpointsCommand cmd = new SetConnectionBendpointsCommand(editingDomain);
	cmd.setEdgeAdapter(new EObjectAdapter(connection.getNotationView()));

	Point first = bendpoints.get(0);
	Point last = bendpoints.get(bendpoints.size() - 1);
	Point sourceRef = new Point(first.x(), first.y());
	Point targetRef = new Point(last.x(), last.y());
	PointList pointList = new PointList();

	for (Point bendpoint : bendpoints) {
		pointList.addPoint(new Point(bendpoint.x(), bendpoint.y()));
	}

	cmd.setNewPointList(pointList, sourceRef, targetRef);
	Command proxy = new ICommandProxy(cmd);
	proxy.execute();
}
 
Example 5
Source File: CustomANDGateway2EditPart.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected NodeFigure createNodePlate() {
	DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(FiguresHelper.GATEWAY_WIDTH, FiguresHelper.GATEWAY_WIDTH) {
		public PointList getPolygonPoints() {
			PointList points = new PointList(5);
			Rectangle anchRect = getHandleBounds();
			points.addPoint(anchRect.x+anchRect.width/2,anchRect.y);                         
			points.addPoint(anchRect.x + anchRect.width, anchRect.y+anchRect.height/2);                        
			points.addPoint(anchRect.x+anchRect.width/2,anchRect.y+anchRect.height); 
			points.addPoint(anchRect.x, anchRect.y+anchRect.height/2);       
			points.addPoint(anchRect.x+ anchRect.width/2,anchRect.y);
			return points;
		}
	};
	return result;
}
 
Example 6
Source File: IETargetDecoration.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
public IETargetDecoration() {
		super();

		PointList pointList = new PointList();

		pointList.addPoint(-13, -12);
		pointList.addPoint(-13, 0);
		pointList.addPoint(-1, -12);
		pointList.addPoint(-13, 0);
		pointList.addPoint(-1, 12);
		pointList.addPoint(-13, 0);
		pointList.addPoint(-13, 12);

		this.setTemplate(pointList);
		this.setScale(0.66, 0.66);
//		this.setScale(1, 1);
	}
 
Example 7
Source File: IETargetDecoration.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
public IETargetDecoration() {
    super();

    final PointList pointList = new PointList();

    pointList.addPoint(-13, -12);
    pointList.addPoint(-13, 0);
    pointList.addPoint(-1, -12);
    pointList.addPoint(-13, 0);
    pointList.addPoint(-1, 12);
    pointList.addPoint(-13, 0);
    pointList.addPoint(-13, 12);

    setTemplate(pointList);
    setScale(1, 1);
}
 
Example 8
Source File: ChoiceFigure.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @see org.eclipse.draw2d.Shape#outlineShape(org.eclipse.draw2d.Graphics)
 */
@Override
protected void outlineShape(Graphics graphics) {
	graphics.pushState();
	graphics.setForegroundColor(getForegroundColor());
	graphics.setBackgroundColor(getBackgroundColor());
	Rectangle f = Rectangle.SINGLETON;
	Rectangle r = getBounds();
	f.x = r.x + getLineWidth() / 2;
	f.y = r.y + getLineWidth() / 2;
	f.width = r.width - getLineWidth() - 1;
	f.height = r.height - getLineWidth() - 1;

	PointList pl = new PointList();
	pl.addPoint(f.getTop());
	pl.addPoint(f.getRight());
	pl.addPoint(f.getBottom());
	pl.addPoint(f.getLeft());

	graphics.drawPolygon(pl);
	graphics.popState();
}
 
Example 9
Source File: RailroadConnectionRouter.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void route(Connection connection) {
	PointList points = connection.getPoints();
	points.removeAllPoints();
	Point startPoint = getStartPoint(connection);
	connection.translateToRelative(startPoint);
	points.addPoint(startPoint);
	Point endPoint = getEndPoint(connection);
	connection.translateToRelative(endPoint);
	Object constraint = getConstraint(connection);
	if (constraint instanceof BendConstraint) {
		int dx = Integer.signum(endPoint.x - startPoint.x) * ILayoutConstants.CONNECTION_RADIUS;
		int dy = Integer.signum(endPoint.y - startPoint.y) * ILayoutConstants.CONNECTION_RADIUS;
		// can be simplified but becomes unreadable
		if (((BendConstraint) constraint).isConvex()) {
			if (((BendConstraint) constraint).isStart()) {
				points.addPoint(startPoint.x - dx, startPoint.y + dy);
				points.addPoint(startPoint.x - dx, endPoint.y - dy);
				points.addPoint(startPoint.x , endPoint.y);
			} else {
				points.addPoint(endPoint.x, startPoint.y);
				points.addPoint(endPoint.x + dx, startPoint.y + dy);
				points.addPoint(endPoint.x + dx, endPoint.y - dy);
			}
		} else {
			if (((BendConstraint) constraint).isStart()) {
				points.addPoint(startPoint.x + dx, startPoint.y + dy);
				points.addPoint(startPoint.x + dx, endPoint.y - dy);
				points.addPoint(startPoint.x + 2 * dx, endPoint.y);
			} else {
				points.addPoint(endPoint.x - 2 * dx, startPoint.y);
				points.addPoint(endPoint.x - dx, startPoint.y + dy);
				points.addPoint(endPoint.x - dx, endPoint.y - dy);
			}
		}
	}
	points.addPoint(endPoint);
	connection.setPoints(points);
}
 
Example 10
Source File: IEOneDecoration.java    From erflute with Apache License 2.0 5 votes vote down vote up
public IEOneDecoration() {
    super();

    final PointList pointList = new PointList();

    pointList.addPoint(-13, -12);
    pointList.addPoint(-13, 12);

    setTemplate(pointList);
    setScale(0.66, 0.66);
}
 
Example 11
Source File: Animation.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
static boolean playbackState(Connection conn) {
	if (!PLAYBACK) {
		return false;
	}

	PointList list1 = (PointList) initialStates.get(conn);
	PointList list2 = (PointList) finalStates.get(conn);
	if (list1 == null) {
		conn.setVisible(false);
		return true;
	}
	if (list1.size() == list2.size()) {
		Point pt1 = new Point(), pt2 = new Point();
		PointList points = conn.getPoints();
		points.removeAllPoints();
		for (int i = 0; i < list1.size(); i++) {
			list1.getPoint(pt2, i);
			list2.getPoint(pt1, i);
			pt1.x = (int) Math.round(pt1.x * progress + (1 - progress)
					* pt2.x);
			pt1.y = (int) Math.round(pt1.y * progress + (1 - progress)
					* pt2.y);
			points.addPoint(pt1);
		}
		conn.setPoints(points);
	}
	return true;
}
 
Example 12
Source File: ConnectionRouterImp.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void routeTopToBottom(Point start, Point end, PointList points) {
	int offsetY = GraphLayoutManager.verticalSpacing / 4;
	int midX = 0;
	if (Math.abs(start.x - end.x) < ProcessFigure.WIDTH) {
		midX = Math.max(start.x, end.x) + ProcessFigure.WIDTH;
	} else {
		midX = start.x + (end.x - start.x) / 2;
	}
	points.addPoint(start.x, start.y - offsetY);
	points.addPoint(midX, start.y - offsetY);
	points.addPoint(midX, end.y + offsetY);
	points.addPoint(end.x, end.y + offsetY);
}
 
Example 13
Source File: TreeConnectionRouter.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void route(Connection conn) {
	super.route(conn);
	if (conn.getSourceAnchor().getOwner() == null || conn.getTargetAnchor().getOwner() == null)
		return;
	PointList points = new PointList();
	points.addPoint(conn.getPoints().getFirstPoint());
	ProcessFigure source = getProcessFigure(conn.getSourceAnchor());
	ProcessFigure target = getProcessFigure(conn.getTargetAnchor());
	Point sourceLoc = source.getLocation();
	Point targetLoc = target.getLocation();
	Point firstPoint = conn.getPoints().getFirstPoint();
	Point lastPoint = conn.getPoints().getLastPoint();
	if (targetLoc.x < sourceLoc.x + source.getSize().width
			|| targetLoc.x > sourceLoc.x + source.getSize().width + LayoutManager.H_SPACE + target.getSize().width
			|| target == source) {
		points.addPoint(firstPoint.getTranslated(LayoutManager.H_SPACE / 2, 0));
		int y1 = sourceLoc.y < targetLoc.y ? targetLoc.y : sourceLoc.y;
		y1 -= LayoutManager.V_SPACE / 2;
		points.addPoint(firstPoint.getTranslated(LayoutManager.H_SPACE / 2, 0).x, y1);
		points.addPoint(lastPoint.getTranslated(-LayoutManager.H_SPACE / 2, 0).x, y1);
		points.addPoint(lastPoint.getTranslated(-LayoutManager.H_SPACE / 2, 0));
	} else {
		points.addPoint(firstPoint.getTranslated(LayoutManager.H_SPACE / 2, 0));
		points.addPoint(firstPoint.getTranslated(LayoutManager.H_SPACE / 2, 0).x, lastPoint.y);
	}
	points.addPoint(lastPoint);
	conn.setPoints(points);
}
 
Example 14
Source File: CustomRectilinearRouter.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Iterates through points of a polyline and does the following:
 * if 3 points lie on the same line the middle point is removed
 * 
 * @param line polyline's points
 */
private boolean removeRedundantPoints(PointList line) {
    int initialNumberOfPoints = line.size();
    if (line.size() > 2) {
        PointList newLine = new PointList(line.size());
        newLine.addPoint(line.removePoint(0));
        while (line.size() >= 2) {
            Point p0 = newLine.getLastPoint();
            Point p1 = line.getPoint(0);
            Point p2 = line.getPoint(1);
            if (p0.x == p1.x && p0.x == p2.x) {
                // Have two vertical segments in a row
                // get rid of the point between
                line.removePoint(0);
            } else if (p0.y == p1.y && p0.y == p2.y) {
                // Have two horizontal segments in a row
                // get rid of the point between
                line.removePoint(0);
            } else {
                newLine.addPoint(line.removePoint(0));
            }
        }
        while (line.size() > 0) {
            newLine.addPoint(line.removePoint(0));
        }
        line.removeAllPoints();
        line.addAll(newLine);
    }
    return line.size() != initialNumberOfPoints;
}
 
Example 15
Source File: PolygonController.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Set points as string
 * <p>
 * <code>
 * 1.5;2.5|1.5;2.5
 * </code>
 * </p>
 * 
 * @param points
 */
public void setPointsString ( final String pointsString )
{
    final PointList pointList = new PointList ();

    final String[] points = pointsString.split ( "\\|" );
    for ( final String point : points )
    {
        final String[] toks = point.split ( ";" );
        final PrecisionPoint p = new PrecisionPoint ( Double.parseDouble ( toks[0] ), Double.parseDouble ( toks[1] ) );
        pointList.addPoint ( p );
    }
    setPoints ( pointList );
}
 
Example 16
Source File: LineController.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Set points as string
 * <p>
 * <code>
 * 1.5;2.5|1.5;2.5
 * </code>
 * </p>
 * 
 * @param points
 */
public void setPointsString ( final String pointsString )
{
    final PointList pointList = new PointList ();

    final String[] points = pointsString.split ( "\\|" );
    for ( final String point : points )
    {
        final String[] toks = point.split ( ";" );
        final PrecisionPoint p = new PrecisionPoint ( Double.parseDouble ( toks[0] ), Double.parseDouble ( toks[1] ) );
        pointList.addPoint ( p );
    }
    setPoints ( pointList );
}
 
Example 17
Source File: InsertElementOnSequenceFlowCommand.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("restriction")
protected SetConnectionBendpointsCommand createSetBendpointsCommand(
        final IProgressMonitor monitor,
        final IAdaptable info,
        final Connector edge,
        final TransactionalEditingDomain domain) {
    final SetConnectionBendpointsCommand setConnectionBendPointsCommand = new SetConnectionBendpointsCommand(domain);
    setConnectionBendPointsCommand.setEdgeAdapter(new EObjectAdapter(edge));
    final PointList bendpoints = new PointList();
    bendpoints.addPoint(0, 0);
    bendpoints.addPoint(0, 0);
    setConnectionBendPointsCommand.setNewPointList(bendpoints, bendpoints.getFirstPoint(), bendpoints.getLastPoint());
    return setConnectionBendPointsCommand;
}
 
Example 18
Source File: SequenceFlowEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @generated
 */
private RotatableDecoration createTargetDecoration() {
	PolygonDecoration df = new PolygonDecoration();
	df.setFill(true);
	df.setBackgroundColor(ColorConstants.black);
	PointList pl = new PointList();
	pl.addPoint(getMapMode().DPtoLP(0), getMapMode().DPtoLP(0));
	pl.addPoint(getMapMode().DPtoLP(-1), getMapMode().DPtoLP(1));
	pl.addPoint(getMapMode().DPtoLP(-1), getMapMode().DPtoLP(-1));
	pl.addPoint(getMapMode().DPtoLP(0), getMapMode().DPtoLP(0));
	df.setTemplate(pl);
	df.setScale(getMapMode().DPtoLP(7), getMapMode().DPtoLP(3));
	return df;
}
 
Example 19
Source File: MessageFlowEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @generated
 */
private RotatableDecoration createTargetDecoration() {
	PolygonDecoration df = new PolygonDecoration();
	df.setFill(true);
	df.setBackgroundColor(ColorConstants.white);
	PointList pl = new PointList();
	pl.addPoint(getMapMode().DPtoLP(0), getMapMode().DPtoLP(0));
	pl.addPoint(getMapMode().DPtoLP(-1), getMapMode().DPtoLP(1));
	pl.addPoint(getMapMode().DPtoLP(-1), getMapMode().DPtoLP(-1));
	pl.addPoint(getMapMode().DPtoLP(0), getMapMode().DPtoLP(0));
	df.setTemplate(pl);
	df.setScale(getMapMode().DPtoLP(7), getMapMode().DPtoLP(3));
	return df;
}
 
Example 20
Source File: IEZeroOneDecoration.java    From ermasterr with Apache License 2.0 4 votes vote down vote up
public IEZeroOneDecoration() {
    super();

    final PointList pointList = new PointList();

    pointList.addPoint(-30, 2);
    pointList.addPoint(-30, -2);
    pointList.addPoint(-29, -3);
    pointList.addPoint(-29, -4);
    pointList.addPoint(-27, -6);
    pointList.addPoint(-26, -6);
    pointList.addPoint(-25, -7);
    pointList.addPoint(-21, -7);
    pointList.addPoint(-20, -6);
    pointList.addPoint(-19, -6);
    pointList.addPoint(-17, -4);
    pointList.addPoint(-17, -3);
    pointList.addPoint(-16, -2);

    pointList.addPoint(-16, 0);
    pointList.addPoint(-13, 0);
    pointList.addPoint(-13, -12);
    pointList.addPoint(-13, 12);
    pointList.addPoint(-13, 0);
    pointList.addPoint(-16, 0);

    pointList.addPoint(-16, 2);
    pointList.addPoint(-17, 3);
    pointList.addPoint(-17, 4);
    pointList.addPoint(-19, 6);
    pointList.addPoint(-20, 6);
    pointList.addPoint(-21, 7);
    pointList.addPoint(-25, 7);
    pointList.addPoint(-26, 6);
    pointList.addPoint(-27, 6);
    pointList.addPoint(-29, 4);
    pointList.addPoint(-29, 3);
    pointList.addPoint(-30, 2);
    pointList.addPoint(-30, -2);

    setTemplate(pointList);
    setScale(1, 1);
}