本文整理汇总了Java中javafx.scene.shape.Rectangle.setHeight方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle.setHeight方法的具体用法?Java Rectangle.setHeight怎么用?Java Rectangle.setHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.shape.Rectangle
的用法示例。
在下文中一共展示了Rectangle.setHeight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: adjust_rectangle_properties
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
void adjust_rectangle_properties(double starting_point_x, double starting_point_y, double ending_point_x,
double ending_point_y, Rectangle given_rectangle) {
given_rectangle.setX(starting_point_x);
given_rectangle.setY(starting_point_y);
given_rectangle.setWidth(ending_point_x - starting_point_x);
given_rectangle.setHeight(ending_point_y - starting_point_y);
if (given_rectangle.getWidth() < 0) {
given_rectangle.setWidth(-given_rectangle.getWidth());
given_rectangle.setX(given_rectangle.getX() - given_rectangle.getWidth());
}
if (given_rectangle.getHeight() < 0) {
given_rectangle.setHeight(-given_rectangle.getHeight());
given_rectangle.setY(given_rectangle.getY() - given_rectangle.getHeight());
}
}
示例2: setFillImageKeepingAspectRatio
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public void setFillImageKeepingAspectRatio(Rectangle rectangle, Image image, Dimension2D gamingContextDimension2D) {
double imageWidth = image.getWidth();
double imageHeight = image.getHeight();
double imageHeightToWidthRatio = imageHeight / imageWidth;
double initialHeight = rectangle.getHeight();
double initialWidth = initialHeight / imageHeightToWidthRatio;
double positionX = (gamingContextDimension2D.getWidth() - initialWidth) / 2;
double positionY = (gamingContextDimension2D.getHeight() - initialHeight) / 2;
rectangle.setFill(new ImagePattern(image));
rectangle.setX(positionX);
rectangle.setY(positionY);
rectangle.setWidth(initialWidth);
rectangle.setHeight(initialHeight);
rectangle.setTranslateX(0);
rectangle.setScaleX(1);
rectangle.setScaleY(1);
rectangle.setScaleZ(1);
}
示例3: EmergencyStopControl
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public EmergencyStopControl() {
super("Emergency Stop", FlashboardSendableType.ESTOP);
statusRect = new Rectangle();
statusRect.setWidth(160);
statusRect.setHeight(40);
statusRect.setFill(Color.GREEN);
statusRect.setStroke(Color.BLACK);
button = new javafx.scene.control.Button("Emergency Stop");
button.setPrefWidth(160);
button.setPrefHeight(40);
button.setOnAction((e)->{
change();
});
root = new VBox();
root.setAlignment(Pos.CENTER);
root.setSpacing(2.0);
root.getChildren().addAll(button, statusRect);
}
示例4: onTouchDragged
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public void onTouchDragged(TouchEvent event){
Rectangle dragRectangle = dragRectangles.get(event.getTouchPoint().getId());
Point2D startPoint = dragStarts.get(event.getTouchPoint().getId());
if(event.getSource() instanceof AbstractNodeView){
dragRectangle.setWidth(Math.abs(((AbstractNodeView)event.getSource()).getX() + event.getTouchPoint().getX() - startPoint.getX()));
dragRectangle.setHeight(Math.abs(((AbstractNodeView)event.getSource()).getY() + event.getTouchPoint().getY() - startPoint.getY()));
dragRectangle.setX(Math.min(startPoint.getX(), ((AbstractNodeView)event.getSource()).getX() + event.getTouchPoint().getX()));
dragRectangle.setY(Math.min(startPoint.getY(), ((AbstractNodeView)event.getSource()).getY() + event.getTouchPoint().getY()));
} else {
dragRectangle.setWidth(Math.abs(startPoint.getX() - event.getTouchPoint().getX()));
dragRectangle.setHeight(Math.abs(startPoint.getY() - event.getTouchPoint().getY()));
dragRectangle.setX(Math.min(startPoint.getX(), event.getTouchPoint().getX()));
dragRectangle.setY(Math.min(startPoint.getY(), event.getTouchPoint().getY()));
}
}
示例5: createPieceRectangle
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
private Rectangle createPieceRectangle() {
Rectangle rec = new Rectangle();
rec.setX(-50);
rec.setY(-50);
rec.setWidth(SIZE);
rec.setHeight(SIZE);
return rec;
}
示例6: start
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
@Override
public void start(Stage stage) {
stage.setTitle("Toggle Button Sample");
stage.setWidth(250);
stage.setHeight(180);
HBox hbox = new HBox();
VBox vbox = new VBox();
Scene scene = new Scene(new Group(vbox));
stage.setScene(scene);
scene.getStylesheets().add("togglebuttonsample/ControlStyle.css");
Rectangle rect = new Rectangle();
rect.setHeight(50);
rect.setFill(Color.WHITE);
rect.setStroke(Color.DARKGRAY);
rect.setStrokeWidth(2);
rect.setArcHeight(10);
rect.setArcWidth(10);
final ToggleGroup group = new ToggleGroup();
group.selectedToggleProperty().addListener(
(ObservableValue<? extends Toggle> ov,
Toggle toggle, Toggle new_toggle) -> {
if (new_toggle == null)
rect.setFill(Color.WHITE);
else
rect.setFill((Color) group.getSelectedToggle().getUserData());
});
ToggleButton tb1 = new ToggleButton("Minor");
tb1.setToggleGroup(group);
tb1.setUserData(Color.LIGHTGREEN);
tb1.setSelected(true);
tb1.getStyleClass().add("toggle-button1");
ToggleButton tb2 = new ToggleButton("Major");
tb2.setToggleGroup(group);
tb2.setUserData(Color.LIGHTBLUE);
tb2.getStyleClass().add("toggle-button2");
ToggleButton tb3 = new ToggleButton("Critical");
tb3.setToggleGroup(group);
tb3.setUserData(Color.SALMON);
tb3.getStyleClass().add("toggle-button3");
hbox.getChildren().addAll(tb1, tb2, tb3);
vbox.getChildren().add(new Label("Priority:"));
vbox.getChildren().add(hbox);
vbox.getChildren().add(rect);
vbox.setPadding(new Insets(20, 10, 10, 20));
stage.show();
rect.setWidth(hbox.getWidth());
}
示例7: getVisual
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
@Override
public Node getVisual (Block block) {
Rectangle rect = super.getRectangle(block);
rect.setWidth(myWidth);
rect.setHeight(myHeight);
return rect;
}
示例8: finish
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
private void finish(Rectangle rectanlge){
aDrawPane.getChildren().remove(rectanlge);
try{
rectanlge.setWidth(0);
rectanlge.setHeight(0);
}catch (Exception e){
e.printStackTrace();
}
}
示例9: Clavier
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public Clavier(Instru instru) {
this.instru = instru;// l'objet de type Instru prend la valeur de l'objet passé en paramètre
Rectangle fond_clavier = new Rectangle();
fond_clavier.setWidth(400);
fond_clavier.setHeight(200);
fond_clavier.setArcWidth(30);
fond_clavier.setArcHeight(30);
fond_clavier.setFill( // on remplie notre rectangle avec un dégradé
new LinearGradient(0f, 0f, 0f, 1f, true, CycleMethod.NO_CYCLE,
new Stop[] { new Stop(0, Color.web("#333333")), new Stop(1, Color.web("#000000")) }));
Reflection r = new Reflection();// on applique un effet de réflection
r.setFraction(0.25);
r.setBottomOpacity(0);
r.setTopOpacity(0.5);
fond_clavier.setEffect(r);
touches = new Touche[] { new Touche("U", 50, 20, 60, instru), new Touche("I", 128, 20, 62, instru),
new Touche("O", 206, 20, 64, instru), new Touche("P", 284, 20, 65, instru),
new Touche("J", 75, 98, 67, instru), new Touche("K", 153, 98, 69, instru),
new Touche("L", 231, 98, 71, instru), new Touche("M", 309, 98, 72, instru) };
this.setTranslateX(50);
this.setTranslateY(250);
this.getChildren().add(fond_clavier);
for (Touche touche : touches) { // on insère chaque touche une par une.
this.getChildren().add(touche);
}
}
示例10: ColorPickerTool
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public ColorPickerTool(Color startColor) {
setMinWidth(USE_PREF_SIZE);
setMaxWidth(Double.MAX_VALUE);
setAlignment(Pos.BASELINE_LEFT);
getStyleClass().add("color-picker");
setTextFill(Color.WHITE);
color.set(startColor);
textProperty().bind(new StringBinding() {
{ bind(color); }
@Override protected String computeValue() {
return getWebColor(getColor());
}
});
setOnAction((ActionEvent arg0) -> {
if (popover == null) {
popover = new ColorPickerPopover();
popover.colorProperty().addListener((ObservableValue<? extends Color> arg1, Color arg2, Color newValue) -> {
setColor(newValue);
});
}
if (popover.isShowing()) {
popover.hide();
} else {
popover.setColor(getColor());
popover.show(ColorPickerTool.this);
}
});
Rectangle colorRect = new Rectangle();
colorRect.setWidth(16);
colorRect.setHeight(16);
colorRect.fillProperty().bind(new ObjectBinding<Paint>() { { bind(color); }
@Override protected Paint computeValue() {
return getColor();
}
});
colorRect.setEffect(new DropShadow(3, 0, 1, Color.rgb(0, 0, 0, 0.8)));
setGraphic(colorRect);
}
示例11: Group
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
public Group(){
body = new Pane();
background = new Rectangle();
background.setWidth(1000);
background.setHeight(1000);
body.getChildren().add(background);
}
示例12: setAnimation
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
private void setAnimation(){
// Initially hiding the Top Pane
clipRect = new Rectangle();
clipRect.setWidth(boxBounds.getWidth());
clipRect.setHeight(0);
clipRect.translateYProperty().set(boxBounds.getWidth());
laytable.setClip(clipRect);
laytable.translateYProperty().set(-boxBounds.getWidth());
// Animation for bouncing effect.
final Timeline timelineBounce = new Timeline();
timelineBounce.setCycleCount(2);
timelineBounce.setAutoReverse(true);
final KeyValue kv1 = new KeyValue(clipRect.heightProperty(), (boxBounds.getHeight()-15));
final KeyValue kv2 = new KeyValue(clipRect.translateYProperty(), 15);
final KeyValue kv3 = new KeyValue(laytable.translateYProperty(), -15);
final KeyFrame kf1 = new KeyFrame(Duration.millis(100), kv1, kv2, kv3);
timelineBounce.getKeyFrames().add(kf1);
// Event handler to call bouncing effect after the scroll down is finished.
EventHandler onFinished = new EventHandler() {
@Override
public void handle(Event event) {
timelineBounce.play();
}
};
timelineDown = new Timeline();
timelineUp = new Timeline();
// Animation for scroll down.
timelineDown.setCycleCount(1);
timelineDown.setAutoReverse(true);
final KeyValue kvDwn1 = new KeyValue(clipRect.heightProperty(), boxBounds.getWidth());
final KeyValue kvDwn2 = new KeyValue(clipRect.translateYProperty(), 0);
final KeyValue kvDwn3 = new KeyValue(laytable.translateYProperty(), 0);
final KeyFrame kfDwn = new KeyFrame(Duration.millis(1000), onFinished, kvDwn1, kvDwn2, kvDwn3);
timelineDown.getKeyFrames().add(kfDwn);
// Animation for scroll up.
timelineUp.setCycleCount(1);
timelineUp.setAutoReverse(true);
final KeyValue kvUp1 = new KeyValue(clipRect.heightProperty(), 0);
final KeyValue kvUp2 = new KeyValue(clipRect.translateYProperty(), boxBounds.getHeight());
final KeyValue kvUp3 = new KeyValue(laytable.translateYProperty(), -boxBounds.getHeight());
final KeyFrame kfUp = new KeyFrame(Duration.millis(1000), kvUp1, kvUp2, kvUp3);
timelineUp.getKeyFrames().add(kfUp);
}
示例13: setAnimation
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
private void setAnimation(){
// Initially hiding the Top Pane
clipRect = new Rectangle();
clipRect.setWidth(boxBounds.getWidth());
clipRect.setHeight(0);
clipRect.translateYProperty().set(boxBounds.getWidth());
layall.setClip(clipRect);
layall.translateYProperty().set(-boxBounds.getWidth());
layoffice.translateYProperty().set(-boxBounds.getWidth());
// Animation for bouncing effect.
final Timeline timelineBounce = new Timeline();
timelineBounce.setCycleCount(2);
timelineBounce.setAutoReverse(true);
final KeyValue kv1 = new KeyValue(clipRect.heightProperty(), (boxBounds.getHeight()-15));
final KeyValue kv2 = new KeyValue(clipRect.translateYProperty(), 15);
final KeyValue kv3 = new KeyValue(layall.translateYProperty(), -15);
final KeyFrame kf1 = new KeyFrame(Duration.millis(100), kv1, kv2, kv3);
timelineBounce.getKeyFrames().add(kf1);
// Event handler to call bouncing effect after the scroll down is finished.
EventHandler onFinished = new EventHandler() {
@Override
public void handle(Event event) {
timelineBounce.play();
}
};
timelineDown = new Timeline();
timelineUp = new Timeline();
timelineoffice= new Timeline();
// Animation for scroll down.
timelineDown.setCycleCount(1);
timelineDown.setAutoReverse(true);
final KeyValue kvDwn1 = new KeyValue(clipRect.heightProperty(), boxBounds.getWidth());
final KeyValue kvDwn2 = new KeyValue(clipRect.translateYProperty(), 0);
final KeyValue kvDwn3 = new KeyValue(layall.translateYProperty(), 0);
final KeyValue kvDwn4 = new KeyValue(layoffice.translateYProperty(), -boxBounds.getHeight()-190);
final KeyFrame kfDwn = new KeyFrame(Duration.millis(1000), onFinished, kvDwn1, kvDwn2, kvDwn3, kvDwn4);
timelineDown.getKeyFrames().add(kfDwn);
// Animation for scroll up.
timelineUp.setCycleCount(1);
timelineUp.setAutoReverse(true);
final KeyValue kvUp1 = new KeyValue(clipRect.heightProperty(), 0);
final KeyValue kvUp2 = new KeyValue(clipRect.translateYProperty(), boxBounds.getHeight());
final KeyValue kvUp3 = new KeyValue(layall.translateYProperty(), -boxBounds.getHeight()-190);
final KeyValue kvUp4 = new KeyValue(layoffice.translateYProperty(), -boxBounds.getHeight()-190);
final KeyFrame kfUp = new KeyFrame(Duration.millis(1000), kvUp1, kvUp2, kvUp3, kvUp4);
timelineUp.getKeyFrames().add(kfUp);
//Animation for the scrollside
timelineoffice.setCycleCount(1);
timelineoffice.setAutoReverse(true);
final KeyValue kvside1 = new KeyValue(clipRect.heightProperty(), boxBounds.getWidth());
final KeyValue kvside2 = new KeyValue(clipRect.translateYProperty(), 0);
final KeyValue kvside3 = new KeyValue(layoffice.translateYProperty(), 0);
final KeyValue kvside4 = new KeyValue(layall.translateYProperty(), -boxBounds.getHeight());
final KeyFrame kfside = new KeyFrame(Duration.millis(1000), kvside1, kvside2, kvside3, kvside4);
timelineoffice.getKeyFrames().add(kfside);
}
示例14: setAnimation
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
private void setAnimation(){
// Initially hiding the Top Pane
clipRect = new Rectangle();
clipRect.setWidth(boxBounds.getWidth());
clipRect.setHeight(0);
clipRect.translateXProperty().set(boxBounds.getWidth());
topPane.setClip(clipRect);
topPane.translateXProperty().set(-boxBounds.getWidth());
thirdpane.translateXProperty().set(-boxBounds.getWidth());
fourthpane.translateXProperty().set(-boxBounds.getWidth());
// Animation for bouncing effect.
final Timeline timelineBounce = new Timeline();
timelineBounce.setCycleCount(2);
timelineBounce.setAutoReverse(true);
final KeyValue kv1 = new KeyValue(clipRect.heightProperty(), (boxBounds.getHeight()-15));
final KeyValue kv2 = new KeyValue(clipRect.translateYProperty(), 15);
final KeyValue kv3 = new KeyValue(topPane.translateYProperty(), -15);
final KeyFrame kf1 = new KeyFrame(Duration.millis(100), kv1, kv2, kv3);
timelineBounce.getKeyFrames().add(kf1);
// Event handler to call bouncing effect after the scroll down is finished.
EventHandler onFinished = new EventHandler() {
@Override
public void handle(Event event) {
timelineBounce.play();
}
};
timelineDown = new Timeline();
timelineUp = new Timeline();
timelinethree= new Timeline();
timelinefour= new Timeline();
// Animation for scroll down.
timelineDown.setCycleCount(1);
timelineDown.setAutoReverse(true);
final KeyValue kvDwn1 = new KeyValue(clipRect.heightProperty(), boxBounds.getWidth());
final KeyValue kvDwn2 = new KeyValue(clipRect.translateXProperty(), 0);
final KeyValue kvDwn3 = new KeyValue(topPane.translateXProperty(), 0);
final KeyValue kvDwn4 = new KeyValue(thirdpane.translateXProperty(), -boxBounds.getHeight());
final KeyValue kvDwn5 = new KeyValue(fourthpane.translateXProperty(), -boxBounds.getHeight());
final KeyFrame kfDwn = new KeyFrame(Duration.millis(1000), onFinished, kvDwn1, kvDwn2, kvDwn3, kvDwn4, kvDwn5);
timelineDown.getKeyFrames().add(kfDwn);
// Animation for scroll up.
timelineUp.setCycleCount(1);
timelineUp.setAutoReverse(true);
final KeyValue kvUp1 = new KeyValue(clipRect.heightProperty(), 0);
final KeyValue kvUp2 = new KeyValue(clipRect.translateXProperty(), boxBounds.getHeight());
final KeyValue kvUp3 = new KeyValue(topPane.translateXProperty(), -boxBounds.getHeight());
final KeyValue kvUp4 = new KeyValue(thirdpane.translateXProperty(), -boxBounds.getHeight());
final KeyValue kvUp5 = new KeyValue(fourthpane.translateXProperty(), -boxBounds.getHeight());
final KeyFrame kfUp = new KeyFrame(Duration.millis(1000), kvUp1, kvUp2, kvUp3, kvUp4, kvUp5);
timelineUp.getKeyFrames().add(kfUp);
//Animation for the scrollside
timelinethree.setCycleCount(1);
timelinethree.setAutoReverse(true);
final KeyValue kvside1 = new KeyValue(clipRect.heightProperty(), boxBounds.getWidth());
final KeyValue kvside2 = new KeyValue(clipRect.translateXProperty(), 0);
final KeyValue kvside3 = new KeyValue(thirdpane.translateXProperty(), 0);
final KeyValue kvside4 = new KeyValue(fourthpane.translateXProperty(), -boxBounds.getHeight());
final KeyFrame kfside = new KeyFrame(Duration.millis(1000), kvside1, kvside2, kvside3, kvside4);
timelinethree.getKeyFrames().add(kfside);
timelinefour.setCycleCount(1);
timelinefour.setAutoReverse(true);
final KeyValue kvfourth1 = new KeyValue(clipRect.heightProperty(), boxBounds.getWidth());
final KeyValue kvfourth2 = new KeyValue(clipRect.translateXProperty(), 0);
final KeyValue kvfourth3 = new KeyValue(fourthpane.translateXProperty(), 0);
final KeyFrame kffourth = new KeyFrame(Duration.millis(1000), kvfourth1, kvfourth2, kvfourth3);
timelinefour.getKeyFrames().add(kffourth);
}
示例15: testContentBoundChanged
import javafx.scene.shape.Rectangle; //导入方法依赖的package包/类
@Test
public void testContentBoundChanged() throws Exception {
Rectangle rect = new Rectangle(128, 128, Color.RED);
pane.setContent(rect);
Thread.sleep(50);
rect.setWidth(1000);
rect.setHeight(1000);
Thread.sleep(50);
rect.setHeight(0);
rect.setHeight(0);
}