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

The following examples show how to use javafx.scene.transform.Affine#setTx() . 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 6 votes vote down vote up
/**
 * Assigns the transformation values of the <i>src</i> {@link Affine} to the
 * <i>dst</i> {@link Affine}.
 *
 * @param dst
 *            The destination {@link Affine}.
 * @param src
 *            The source {@link Affine}.
 * @return The destination {@link Affine} for convenience.
 */
public static Affine setAffine(Affine dst, Affine src) {
	dst.setMxx(src.getMxx());
	dst.setMxy(src.getMxy());
	dst.setMxz(src.getMxz());
	dst.setMyx(src.getMyx());
	dst.setMyy(src.getMyy());
	dst.setMyz(src.getMyz());
	dst.setMzx(src.getMzx());
	dst.setMzy(src.getMzy());
	dst.setMzz(src.getMzz());
	dst.setTx(src.getTx());
	dst.setTy(src.getTy());
	dst.setTz(src.getTz());
	return dst;
}
 
Example 2
Source File: LayoutSnippet.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
private void setAffine(Affine dst, AffineTransform src) {
	dst.setMxx(src.getM00());
	dst.setMxy(src.getM01());
	dst.setMyx(src.getM10());
	dst.setMyy(src.getM11());
	dst.setTx(src.getTranslateX());
	dst.setTy(src.getTranslateY());
}
 
Example 3
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 4
Source File: TransformLabelPolicy.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Enforce that label is preserved at its respective relative location.
 *
 * @return Whether the position was adjusted or not.
 */
public boolean preserveLabelOffset() {
	if (initialOffset == null) {
		return false;
	}
	Point currentLabelOffset = getLabelOffsetInParent();
	Point delta = currentLabelOffset.getTranslated(initialOffset.getNegated());
	TransformVisualOperation op = ((TransformVisualOperation) getOperation());
	Affine newTransform = op.getNewTransform();
	newTransform.setTx(op.getInitialTransform().getTx() - delta.x);
	newTransform.setTy(op.getInitialTransform().getTy() - delta.y);
	locallyExecuteOperation();
	return true;
}
 
Example 5
Source File: Geometry2FX.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Converts the given {@link AffineTransform} to a JavaFX {@link Affine}.
 * 
 * @param transform
 *            The {@link AffineTransform} to convert.
 * @return The new {@link Affine}.
 */
public static final Affine toFXAffine(AffineTransform transform) {
	Affine affine = new Affine();
	affine.setMxx(transform.getM00());
	affine.setMxy(transform.getM01());
	affine.setMyx(transform.getM10());
	affine.setMyy(transform.getM11());
	affine.setTx(transform.getTranslateX());
	affine.setTy(transform.getTranslateY());
	return affine;
}
 
Example 6
Source File: Line3D.java    From BowlerStudio with GNU General Public License v3.0 4 votes vote down vote up
public Line3D(double startX,
           double startY,
           double startZ,
           double endX,
           double endY,
           double endZ){
	super(0.1,
			Math.sqrt(	Math.pow(endX-startX, 2)+
					Math.pow(endY-startY, 2)+
					Math.pow(endZ-startZ, 2))
			);
	double xdiff = endX-startX;
	double ydiff = endY-startY;
	double zdiff = endZ-startZ;
	
	double lineLen = getHeight();
	
	double xyProjection = Math.sqrt(	Math.pow(xdiff, 2)+
			Math.pow(ydiff, 2)
			);
	
	double rotZ =  Math.toDegrees(Math.atan2(xdiff, ydiff));
	double rotY =  Math.toDegrees(Math.atan2(xyProjection, zdiff));
	Affine xy = new Affine();
	xy.appendRotation(-90-rotY, 0, 0, 0, 0, 1, 0);
	
	Affine orent = new Affine();
	orent.appendRotation(90, 0, 0, 0, 0, 0, 1);
	
	Affine orent2 = new Affine();
	orent.setTx(lineLen/2);
	
	Affine zp = new Affine();
	zp.appendRotation(-90-rotZ, 0, 0, 0, 0, 0, 1);
	Affine zTrans = new Affine();
	zTrans.setTx(startX);
	zTrans.setTy(startY);
	zTrans.setTz(startZ);

	
	getTransforms().add(zTrans);
	getTransforms().add(zp);
	getTransforms().add(xy);

	getTransforms().add(orent);
	getTransforms().add(orent2);
}
 
Example 7
Source File: Axis.java    From BowlerStudio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Instantiates a new axis.
 *
 * @param i the i
 */
//
public Axis(int i) {


	
	
	Affine xp = new Affine();
	xp.setTx(i/2);
	xText = new Label("+X");
	xText.getTransforms().add(xp);
	
	Affine yp = new Affine();
	yp.setTy(i/2);
	yText = new Label("+Y");
	yText.getTransforms().add(yp);
	
	//zp.setTz(i/2);
	Affine zTextAffine = new Affine();
	zTextAffine.setTz(i/2);
	zTextAffine.setTx(i/2);
	zTextAffine.appendRotation(-90, 0, 0, 0, 1, 0, 0);
	zTextAffine.appendRotation(180, 0, 0, 0, 0, 0, 1);
	zText = new Label("+Z");
	zText.getTransforms().add(zTextAffine);
	//zText.smoothProperty().set(false);
	double strokWidth=0.1;
	double inset = 0;
	xAxis = new Line3D(0,inset,0,i,inset,0);
	yAxis = new Line3D(inset,0,0,inset,i,0);
	zAxis = new Line3D(inset,0,0,inset,0,i);
	
	xAxis.setStrokeWidth(strokWidth);
	xAxis.setStroke(Color.RED);
	
	yAxis.setStrokeWidth(strokWidth);
	yAxis.setStroke(Color.GREEN);
	
	zAxis.setStrokeWidth(strokWidth);
	zAxis.setStroke(Color.BLUE);
	
	show();
}