javafx.scene.transform.Affine#getMxx ( )源码实例Demo

下面列出了javafx.scene.transform.Affine#getMxx ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: gef   文件: NodeUtils.java
/**
 * 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();
}
 
源代码2 项目: gef   文件: InfiniteCanvas.java
/**
 * 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();
}
 
源代码3 项目: gef   文件: CreationMenuOnClickHandler.java
/**
 * Callback method called when an item is clicked.
 */
protected void onItemClick() {
	// compute width and height deltas to the content layer
	Node itemVisual = templateGroup.getChildren().get(0);
	Bounds bounds = itemVisual.getLayoutBounds();
	Bounds boundsInContent = getHost().getRoot().getVisual().sceneToLocal(itemVisual.localToScene(bounds));
	double dx = bounds.getWidth() - boundsInContent.getWidth();
	double dy = bounds.getHeight() - boundsInContent.getHeight();

	// compute translation based on the bounds, scaling, and width/height
	// deltas
	Affine contentsTransform = getViewer().getCanvas().contentTransformProperty().get();
	double x = boundsInContent.getMinX() - bounds.getMinX() / contentsTransform.getMxx() - dx / 2;
	double y = boundsInContent.getMinY() - bounds.getMinY() / contentsTransform.getMyy() - dy / 2;

	// close the creation menu
	closeMenu();

	// create the new semantic element
	ICreationMenuItem item = items.get(currentItemIndex);
	Object toCreate = item.createContent();

	// build create operation
	IRootPart<? extends Node> root = getHost().getRoot();
	CreationPolicy creationPolicy = root.getAdapter(CreationPolicy.class);
	creationPolicy.init();
	IContentPart<? extends Node> contentPart = creationPolicy.create(toCreate, root,
			root.getContentPartChildren().size(), HashMultimap.<IContentPart<? extends Node>, String> create(),
			false, false);

	// relocate to final position
	TransformPolicy txPolicy = contentPart.getAdapter(TransformPolicy.class);
	txPolicy.init();
	txPolicy.setTransform(new AffineTransform(1, 0, 0, 1, x, y));

	// assemble operations
	ReverseUndoCompositeOperation rev = new ReverseUndoCompositeOperation("CreateOnClick");
	rev.add(creationPolicy.commit());
	rev.add(txPolicy.commit());

	try {
		getViewer().getDomain().execute(rev, new NullProgressMonitor());
	} catch (ExecutionException e) {
		throw new RuntimeException(e);
	}
}