org.eclipse.draw2d.RelativeBendpoint Java Examples

The following examples show how to use org.eclipse.draw2d.RelativeBendpoint. 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: ConnData.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
public void printBendpointLocations() {
	System.out.println("Bendpoints for " + conn);
	Object routingConstraint = conn.getRoutingConstraint();
	if (routingConstraint instanceof List) {
		List<?> bendpointList = (List<?>) routingConstraint;
		for (Object bpobj : bendpointList) {
			if (bpobj instanceof RelativeBendpoint) {
				RelativeBendpoint relBp = (RelativeBendpoint) bpobj;
				Point bp = relBp.getLocation();
				System.out.println("- " + bp);
			} else {
				System.err.println("[ERR] unknown bend point " + bpobj);
			}
		}
	} else if (routingConstraint != null) {
		System.out.println("[ERR] unknown routing constraint " + routingConstraint);
	}
}
 
Example #2
Source File: RelativeBendpointUtil.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
public List<Point> convertConstraintToListOfPoint(Connection conn) {
	List<Point> list = new ArrayList<>();
	Object routingConstraint = conn.getRoutingConstraint();
	if (routingConstraint instanceof List) {
		List<?> bendpointList = (List<?>) routingConstraint;
		for (Object bpobj : bendpointList) {
			if (bpobj instanceof RelativeBendpoint) {
				list.add(((RelativeBendpoint) bpobj).getLocation());
			} else {
				System.err.println("[ERR] unknown bend point " + bpobj);
			}
		}
	} else if (routingConstraint != null) {
		System.out.println("[ERR] unknown routing constraint " + routingConstraint);
	}
	return list;
}
 
Example #3
Source File: RelativeBendpointUtil.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
public void forceLocation(Connection conn, RelativeBendpoint relbp, double locX, double locY) {
	float w = 0;
	Dimension d2 = new Dimension();
	PrecisionDimension d1 = new PrecisionDimension();

	// compute d1 based on source anchor
	PrecisionPoint a1 = new PrecisionPoint(conn.getSourceAnchor().getReferencePoint());
	Point a1Copy = a1.getCopy();
	conn.translateToRelative(a1Copy);

	// x = a1.preciseX() + d1.preciseWidth()
	// <=> x - a1.preciseX() = d1.preciseWidth()
	d1.setPreciseWidth(locX - a1Copy.preciseX());
	d1.setPreciseHeight(locY - a1Copy.preciseY());

	relbp.setRelativeDimensions(d1, d2);
	relbp.setWeight(w);

	// ensure location is correct
	Point location = relbp.getLocation();
	if (Math.abs(location.preciseX() - locX) > 0.1) {
		throw new IllegalStateException(
				"cannot force location-x: expected <" + locX + "> but got <" + location.preciseX() + ">");
	}
	if (Math.abs(location.preciseY() - locY) > 0.1) {
		throw new IllegalStateException(
				"cannot force location-y: expected <" + locY + "> but got <" + location.preciseY() + ">");
	}
}
 
Example #4
Source File: RubberBandRoutingSupport.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
protected List<RelativeBendpoint> createConstraint(Connection conn, List<PrecisionPoint> list) {
	List<RelativeBendpoint> constraint = new ArrayList<>();
	for (Point p : list) {
		RelativeBendpoint relbp = new RelativeBendpoint();
		relbp.setConnection(conn);
		relbpUtil.forceLocation(conn, relbp, p.preciseX(), p.preciseY());
		constraint.add(relbp);
	}
	return constraint;
}
 
Example #5
Source File: JConnection.java    From JDeodorant with MIT License 5 votes vote down vote up
public PolylineConnection setSlightBendRouter(){
	BendpointConnectionRouter router = new BendpointConnectionRouter();
	RelativeBendpoint bp1 = new RelativeBendpoint(this);
	bp1.setRelativeDimensions(new Dimension(20,20), new Dimension(20, 20));
	bp1.setWeight(0.5f);

	router.setConstraint(this, Arrays.asList(new Bendpoint[] {bp1}));

	this.setConnectionRouter(router);

	return this;
}
 
Example #6
Source File: JConnection.java    From JDeodorant with MIT License 5 votes vote down vote up
public PolylineConnection setFullBendRouter(int bendHeightX){
	float weight = 0.3f;
	int bendHeightY = 50;

	int secondBendHeight = -(bendHeightX+(bendHeightX/3));

	/*int gap =10;
	if(classWidth<0)
		gap = -gap-25;
	 */

	BendpointConnectionRouter router = new BendpointConnectionRouter();


	RelativeBendpoint bp2 = new RelativeBendpoint(this);
	bp2.setRelativeDimensions(new Dimension(secondBendHeight,0), new Dimension(0,0));
	bp2.setWeight(weight);

	RelativeBendpoint bp3 = new RelativeBendpoint(this);
	bp3.setRelativeDimensions(new Dimension(-bendHeightX,bendHeightY), new Dimension(-bendHeightX,-bendHeightY));
	//bp1.setWeight(weight);

	RelativeBendpoint bp4 = new RelativeBendpoint(this);
	bp4.setRelativeDimensions(new Dimension(0,0), new Dimension(secondBendHeight,0));
	bp4.setWeight(1 - weight);

	/*RelativeBendpoint bp5 = new RelativeBendpoint(this);
	bp5.setRelativeDimensions(new Dimension(0,0), new Dimension(-((classWidth/2)+gap),0));
	bp5.setWeight(1);*/

	router.setConstraint(this, Arrays.asList(new Bendpoint[] {bp2, bp3, bp4}));

	this.setConnectionRouter(router);

	return this;
}
 
Example #7
Source File: RubberBandRoutingSupport.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
protected void forceInitialLocations(ConnData cd) {
	List<RelativeBendpoint> constraint = createConstraint(cd.conn, cd.initialVisualPoints);
	ConnectionRouter router = cd.conn.getConnectionRouter();
	router.setConstraint(cd.conn, constraint);
	router.route(cd.conn);
}