Java Code Examples for javafx.scene.transform.Affine#getTy()

The following examples show how to use javafx.scene.transform.Affine#getTy() . 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: NodeUtils.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Returns <code>true</code> if the given {@link Affine}s are equal.
 * Otherwise returns <code>false</code>.
 *
 * @param a1
 *            The first operand.
 * @param a2
 *            The second operand.
 * @return <code>true</code> if the given {@link Affine}s are equal,
 *         otherwise <code>false</code>.
 */
public static boolean equals(Affine a1, Affine a2) {
	// TODO: verify if Affine#equals() works with Java 8
	// Affine does not properly implement equals, so we have to implement
	// that here
	return a1.getMxx() == a2.getMxx() && a1.getMxy() == a2.getMxy()
			&& a1.getMxz() == a2.getMxz() && a1.getMyx() == a2.getMyx()
			&& a1.getMyy() == a2.getMyy() && a1.getMyz() == a2.getMyz()
			&& a1.getMzx() == a2.getMzx() && a1.getMzy() == a2.getMzy()
			&& a1.getMzz() == a2.getMzz() && a1.getTx() == a2.getTx()
			&& a1.getTy() == a2.getTy() && a1.getTz() == a2.getTz();
}
 
Example 2
Source File: InfiniteCanvas.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Sets the transformation matrix of the {@link #getContentTransform()
 * viewport transform} to the values specified by the given {@link Affine}.
 *
 * @param tx
 *            The {@link Affine} determining the new
 *            {@link #getContentTransform() viewport transform}.
 */
public void setContentTransform(Affine tx) {
	Affine viewportTransform = contentTransformProperty.get();
	// Unregister bounds listeners so that transformation changes do not
	// cause updates. Use flag to be aware if the transformation changed.
	unregisterUpdateScrollBarsOnBoundsChanges();
	boolean valuesChanged = false;
	if (viewportTransform.getMxx() != tx.getMxx()) {
		viewportTransform.setMxx(tx.getMxx());
		valuesChanged = true;
	}
	if (viewportTransform.getMxy() != tx.getMxy()) {
		viewportTransform.setMxy(tx.getMxy());
		valuesChanged = true;
	}
	if (viewportTransform.getMyx() != tx.getMyx()) {
		viewportTransform.setMyx(tx.getMyx());
		valuesChanged = true;
	}
	if (viewportTransform.getMyy() != tx.getMyy()) {
		viewportTransform.setMyy(tx.getMyy());
		valuesChanged = true;
	}
	if (viewportTransform.getTx() != tx.getTx()) {
		viewportTransform.setTx(tx.getTx());
		valuesChanged = true;
	}
	if (viewportTransform.getTy() != tx.getTy()) {
		viewportTransform.setTy(tx.getTy());
		valuesChanged = true;
	}
	// Update scrollbars if the transformation changed.
	if (valuesChanged) {
		updateScrollBars();
	}
	// Register previously unregistered listeners.
	registerUpdateScrollBarsOnBoundsChanges();
}
 
Example 3
Source File: IBendableContentPart.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
@Override
default void setContentSize(Dimension totalSize) {
	// determine visual offset
	Affine visualTransform = getContentTransform();
	double currentX = visualTransform.getTx();
	double currentY = visualTransform.getTy();
	// resize content bend points
	List<BendPoint> resizedBendPoints = BendPoint.resize(
			getContentBendPoints(), currentX, currentY, getContentSize(),
			totalSize);
	setContentBendPoints(resizedBendPoints);
}
 
Example 4
Source File: IBendableContentPart.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
@Override
default void setVisualSize(Dimension totalSize) {
	List<BendPoint> visualBendPoints = getVisualBendPoints();
	// determine visual offset
	Affine visualTransform = BendPoint.computeTranslation(visualBendPoints);
	double currentX = visualTransform.getTx();
	double currentY = visualTransform.getTy();
	// resize visual bend points
	List<BendPoint> resizedBendPoints = BendPoint.resize(visualBendPoints,
			currentX, currentY, BendPoint.computeSize(visualBendPoints),
			totalSize);
	setVisualBendPoints(resizedBendPoints);
}
 
Example 5
Source File: ResizableTransformableBoundsProvider.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public IGeometry get() {
	IVisualPart<? extends Node> part = getAdaptable();
	Bounds boundsInParent = part.getVisual().getBoundsInLocal();// getBoundsInParent();

	// determine x and y offset
	double x, y;
	if (part instanceof IBendableContentPart) {
		// return null if there are no free bend points
		boolean isEmpty = true;
		List<BendPoint> bendPoints = ((IBendableContentPart<?>) part)
				.getVisualBendPoints();
		for (BendPoint bp : bendPoints) {
			if (!bp.isAttached()) {
				isEmpty = false;
				break;
			}
		}
		if (isEmpty) {
			return null;
		}

		// TODO: generalize for ITransformableContentPart (transform corner
		// points of local bounds to scene and take axis parallel bounds
		// around that)
		Affine visualTransform = ((ITransformableContentPart<? extends Node>) part)
				.getVisualTransform();
		x = visualTransform.getTx();
		y = visualTransform.getTy();
	} else {
		x = boundsInParent.getMinX();
		y = boundsInParent.getMinY();
	}

	// determine width and height
	double w, h;
	if (part instanceof IBendableContentPart) {
		// TODO: generalize for IResizableContentPart (transform corner
		// points of local bounds to scene and take axis parallel bounds
		// around that)
		Dimension visualSize = ((IResizableContentPart<? extends Node>) part)
				.getVisualSize();
		w = visualSize.width;
		h = visualSize.height;
	} else {
		w = boundsInParent.getWidth();
		h = boundsInParent.getHeight();
	}

	// construct bounds and transform to local
	return // FX2Geometry.toRectangle(part.getVisual().parentToLocal(
			// Geometry2FX.toFXBounds(
	new Rectangle(x, y, w, h);
	// )));
}