Java Code Examples for org.eclipse.draw2d.RelativeBendpoint#getLocation()
The following examples show how to use
org.eclipse.draw2d.RelativeBendpoint#getLocation() .
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 |
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 | 5 votes |
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() + ">"); } }