Java Code Examples for org.eclipse.draw2d.geometry.PrecisionDimension#setPreciseWidth()

The following examples show how to use org.eclipse.draw2d.geometry.PrecisionDimension#setPreciseWidth() . 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: FigureController.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
public void setPreferredWidth ( final double value )
{
    final PrecisionDimension dim = new PrecisionDimension ();
    dim.setPreciseWidth ( value );
    dim.setPreciseHeight ( getPropertyFigure ().getPreferredSize ().preciseHeight () );

    getPropertyFigure ().setPreferredSize ( dim );
}
 
Example 2
Source File: FigureController.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
public void setPreferredHeight ( final double value )
{
    final PrecisionDimension dim = new PrecisionDimension ();
    dim.setPreciseWidth ( getPropertyFigure ().getPreferredSize ().preciseWidth () );
    dim.setPreciseHeight ( value );

    getPropertyFigure ().setPreferredSize ( dim );
}
 
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() + ">");
	}
}