本文整理汇总了Java中javafx.scene.transform.Scale类的典型用法代码示例。如果您正苦于以下问题:Java Scale类的具体用法?Java Scale怎么用?Java Scale使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Scale类属于javafx.scene.transform包,在下文中一共展示了Scale类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import javafx.scene.transform.Scale; //导入依赖的package包/类
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Digital Clock");
Group root = new Group();
Scene scene = new Scene(root, 480, 412);
// add background image
ImageView background = new ImageView(new Image(getClass().getResourceAsStream("DigitalClock-background.png")));
// add digital clock
clock = new Clock(Color.ORANGERED, Color.rgb(50,50,50));
clock.setLayoutX(45);
clock.setLayoutY(186);
clock.getTransforms().add(new Scale(0.83f, 0.83f, 0, 0));
// add background and clock to sample
root.getChildren().addAll(background, clock);
primaryStage.setScene(scene);
primaryStage.show();
}
示例2: chartsToImages
import javafx.scene.transform.Scale; //导入依赖的package包/类
/**
* Converts charts to Java {@link WritableImage}s
*
* @param charts the charts to be converted to {@link WritableImage}s
* @return a {@link List} of {@link WritableImage}s
*/
private List<WritableImage> chartsToImages(List<Chart> charts) {
List<WritableImage> chartImages = new ArrayList<>();
// Scaling the chart image gives it a higher resolution
// which results in a better image quality when the
// image is exported to the pdf
SnapshotParameters snapshotParameters = new SnapshotParameters();
snapshotParameters.setTransform(new Scale(2, 2));
for (Chart chart : charts) {
chartImages.add(chart.snapshot(snapshotParameters, null));
}
return chartImages;
}
示例3: printJob
import javafx.scene.transform.Scale; //导入依赖的package包/类
/********************************
* 작성일 : 2016. 6. 29. 작성자 : KYJ
*
* print 처리.
*
* @param window
* @param target
********************************/
public static void printJob(Window window, Node target) {
Printer printer = Printer.getDefaultPrinter();
// PrinterAttributes printerAttributes = printer.getPrinterAttributes();
//
Paper a4 = Paper.A4;
// Paper a4 = PrintHelper.createPaper("Rotate A4", Paper.A4.getHeight(),
// Paper.A4.getWidth(), Units.MM);
PageLayout pageLayout = printer.createPageLayout(a4, PageOrientation.REVERSE_PORTRAIT, MarginType.DEFAULT);
PrinterJob printerJob = PrinterJob.createPrinterJob();
// JobSettings jobSettings = printerJob.getJobSettings();
// jobSettings.setPrintSides(PrintSides.TUMBLE);
ImageView imageView = new ImageView();
// 화면 사이즈에 맞게 크기 조절.
Callback<SnapshotResult, Void> callback = param -> {
final WritableImage image = param.getImage();
imageView.setImage(image);
final double scaleX = pageLayout.getPrintableWidth() / imageView.getBoundsInParent().getWidth();
final double scaleY = pageLayout.getPrintableHeight() / imageView.getBoundsInParent().getHeight();
imageView.getTransforms().add(new Scale(scaleX, scaleY));
return null;
};
target.snapshot(callback, null, null);
if (printerJob.showPrintDialog(window) && printerJob.printPage(pageLayout, imageView))
printerJob.endJob();
}
示例4: maxScale
import javafx.scene.transform.Scale; //导入依赖的package包/类
private List<Point2D> maxScale(List<Point2D> points, double factor) {
List<Point2D> scaledList = new ArrayList<>();
if (!drawPath.getElements().isEmpty()) {
// scale and center
Bounds b0 = drawPath.getBoundsInParent();
if (b0.getWidth() > 0 && b0.getHeight() > 0) {
final double w = drawPane.getWidth() - 2 * factor * MARGIN;
final double h = drawPane.getHeight() - 2 * factor * MARGIN;
final double scale = Math.min(w / b0.getWidth(), h / b0.getHeight());
affine = new Affine(new Scale(scale, scale, factor * MARGIN, factor * MARGIN));
affine.append(new Translate(factor * MARGIN - b0.getMinX() + (w - scale * b0.getWidth()) / 2d / scale,
factor * MARGIN - b0.getMinY() + (h - scale * b0.getHeight()) / 2d / scale));
for (Point2D p : points) {
scaledList.add(affine.transform(p));
}
}
}
return scaledList;
}
示例5: resize
import javafx.scene.transform.Scale; //导入依赖的package包/类
private void resize() {
double width = getWidth() - getInsets().getLeft() - getInsets().getRight();
double height = getHeight() - getInsets().getTop() - getInsets().getBottom();
size = width < height ? width : height;
if (width > 0 && height > 0) {
pane.setMaxSize(size, size);
pane.relocate((getWidth() - size) * 0.5, (getHeight() - size) * 0.5);
double center = size * 0.5;
scaleFactor = size / PREFERRED_WIDTH;
ring.getTransforms().setAll(new Scale(scaleFactor, scaleFactor, 0, 0));
mainCircle.setRadius(size * 0.21016949);
mainCircle.setCenterX(center); mainCircle.setCenterY(center);
}
}
示例6: initViewport
import javafx.scene.transform.Scale; //导入依赖的package包/类
private void initViewport(double w, double h) {
Viewport viewport = getViewport();
gameRoot.layoutXProperty().bind(viewport.xProperty().negate());
gameRoot.layoutYProperty().bind(viewport.yProperty().negate());
Scale scale = new Scale();
scale.pivotXProperty().bind(viewport.xProperty());
scale.pivotYProperty().bind(viewport.yProperty());
scale.xProperty().bind(viewport.zoomProperty());
scale.yProperty().bind(viewport.zoomProperty());
gameRoot.getTransforms().add(scale);
Rotate rotate = new Rotate(0, Rotate.Z_AXIS);
rotate.pivotXProperty().bind(viewport.xProperty().add(w / 2));
rotate.pivotYProperty().bind(viewport.yProperty().add(h / 2));
rotate.angleProperty().bind(viewport.angleProperty().negate());
gameRoot.getTransforms().add(rotate);
}
示例7: GetTransformation
import javafx.scene.transform.Scale; //导入依赖的package包/类
private Transform GetTransformation(int width, int height)
{
double centerX = width * GetDoubleAttribute("X") / MaximumX;
double centerY = height * GetDoubleAttribute("Y") / MaximumY;
double skewX = 90 * (GetDoubleAttribute("SkewX") - MaximumX / 2.0) / MaximumX;
double skewY = 90 * (GetDoubleAttribute("SkewY") - MaximumY / 2.0) / MaximumY;
double scaleX = GetDoubleAttribute("Width");
double scaleY = GetDoubleAttribute("Height");
double rotation = (GetDoubleAttribute("Rotation") / MaximumX) * 360;
Shear skewTransform = new Shear(skewX, skewY, centerX, centerY);
Rotate rotateTransform = new Rotate(rotation, centerX, centerY);
Scale scaleTransform = new Scale(scaleX, scaleY, centerX, centerY);
return rotateTransform.createConcatenation(scaleTransform).createConcatenation(skewTransform);
}
示例8: updateModelSizeIndicators
import javafx.scene.transform.Scale; //导入依赖的package包/类
/** Update lines that indicate model's size in edit mode */
private void updateModelSizeIndicators()
{
int width = model.propWidth().getValue();
int height = model.propHeight().getValue();
final ObservableList<Transform> transforms = widget_parent.getTransforms();
if (transforms.size() > 0 && transforms.get(0) instanceof Scale)
{
final Scale scale = (Scale) transforms.get(0);
width *= scale.getX();
height *= scale.getY();
}
horiz_bound.setStartY(height);
horiz_bound.setEndX(width);
horiz_bound.setEndY(height);
vert_bound.setStartX(width);
vert_bound.setEndY(height);
vert_bound.setEndX(width);
}
示例9: createJFXNode
import javafx.scene.transform.Scale; //导入依赖的package包/类
@Override
public ScrollPane createJFXNode() throws Exception
{
// inner.setScaleX() and setScaleY() zoom from the center
// and not the top-left edge, requiring adjustments to
// inner.setTranslateX() and ..Y() to compensate.
// Using a separate Scale transformation does not have that problem.
// See http://stackoverflow.com/questions/10707880/javafx-scale-and-translate-operation-results-in-anomaly
inner = new Pane();
inner.getTransforms().add(zoom = new Scale());
scroll = new ScrollPane(inner);
// Panning tends to 'jerk' the content when clicked
// scroll.setPannable(true);
if (!toolkit.isEditMode())
{ // Hide border around the ScrollPane
// Details changed w/ JFX versions, see
// http://stackoverflow.com/questions/17540137/javafx-scrollpane-border-and-background/17540428#17540428
scroll.setStyle("-fx-background-color:transparent;");
}
return scroll;
}
示例10: layoutChildren
import javafx.scene.transform.Scale; //导入依赖的package包/类
@Override
protected void layoutChildren() {
// calculate scale
double scale = getWidth() / computePrefWidth(-1);
getChildren().stream().filter(child -> child instanceof Region).forEach(child -> {
Region region = (Region) child;
if (region.getShape() != null) {
region.resize(
region.getShape().getLayoutBounds().getMaxX(),
region.getShape().getLayoutBounds().getMaxY()
);
region.getTransforms().setAll(new Scale(scale, scale, 0, 0));
} else {
region.autosize();
}
});
}
示例11: Bone
import javafx.scene.transform.Scale; //导入依赖的package包/类
public Bone(double scale, Point3D posJoint) {
Box origin=new Box(10,10,10);
origin.setMaterial(new PhongMaterial(Color.ORANGE));
Cylinder bone = new Cylinder(5, posJoint.magnitude()/scale);
double angle = Math.toDegrees(Math.acos((new Point3D(0,1,0)).dotProduct(posJoint)/posJoint.magnitude()));
Point3D axis = (new Point3D(0,1,0)).crossProduct(posJoint);
bone.getTransforms().addAll(new Rotate(angle,0,0,0,axis), new Translate(0,posJoint.magnitude()/2d/scale, 0));
bone.setMaterial(new PhongMaterial(Color.CADETBLUE));
Sphere end = new Sphere(6);
end.getTransforms().addAll(new Translate(posJoint.getX()/scale,posJoint.getY()/scale,posJoint.getZ()/scale));
end.setMaterial(new PhongMaterial(Color.YELLOW));
getChildren().addAll(origin, bone, end);
getTransforms().add(new Scale(scale, scale, scale));
}
示例12: Axes
import javafx.scene.transform.Scale; //导入依赖的package包/类
public Axes(double scale) {
Cylinder axisX = new Cylinder(3, 60);
axisX.getTransforms().addAll(new Rotate(90, Rotate.Z_AXIS), new Translate(0, 30, 0));
axisX.setMaterial(new PhongMaterial(Color.RED));
Cylinder axisY = new Cylinder(3, 60);
axisY.getTransforms().add(new Translate(0, 30, 0));
axisY.setMaterial(new PhongMaterial(Color.GREEN));
Cylinder axisZ = new Cylinder(3, 60);
axisZ.setMaterial(new PhongMaterial(Color.BLUE));
axisZ.getTransforms().addAll(new Rotate(90, Rotate.X_AXIS), new Translate(0, 30, 0));
getChildren().addAll(axisX, axisY, axisZ);
getTransforms().add(new Scale(scale, scale, scale));
}
示例13: layoutChildren
import javafx.scene.transform.Scale; //导入依赖的package包/类
@Override
protected void layoutChildren()
{
// calculate scale
double scale = this.getWidth() / this.computePrefWidth(-1);
for (Node child : this.getChildren())
{
if (child instanceof Region)
{
Region region = (Region) child;
if (region.getShape() != null)
{
region.resize(region.getShape().getLayoutBounds().getMaxX(), region
.getShape().getLayoutBounds().getMaxY());
region.getTransforms().setAll(new Scale(scale, scale, 0, 0));
}
else
{
region.autosize();
}
}
}
}
示例14: DigitalClock
import javafx.scene.transform.Scale; //导入依赖的package包/类
public DigitalClock() {
super(480, 412);
// add background image
ImageView background = new ImageView(new Image(getClass().getResourceAsStream("DigitalClock-background.png")));
// add digital clock
clock = new Clock(Color.ORANGERED, Color.rgb(50,50,50));
clock.setLayoutX(45);
clock.setLayoutY(186);
clock.getTransforms().add(new Scale(0.83f, 0.83f, 0, 0));
// add background and clock to sample
getChildren().addAll(background, clock);
}
示例15: printDefefaultJob
import javafx.scene.transform.Scale; //导入依赖的package包/类
public static void printDefefaultJob(Window window, Node target) {
printJob(window, target, (param, imageView) -> {
// ImageView imageView = new ImageView();
final WritableImage image = param.getImage();
imageView.setImage(image);
// final double scaleX = pageLayout.getPrintableWidth() /
// imageView.getBoundsInParent().getWidth();
// final double scaleY = pageLayout.getPrintableHeight() /
// imageView.getBoundsInParent().getHeight();
imageView.getTransforms().add(new Scale(1, 1));
});
}