java translate_Java Label.setTranslateX方法代码示例

import javafx.scene.control.Label; //导入方法依赖的package包/类

private void initializePropertyTag() {

final TagPresentation propertyTag = controller.propertyTag;

final Line propertyTagLine = controller.propertyTagLine;

propertyTag.setComponent(controller.getComponent());

propertyTag.setLocationAware(controller.getNail());

// Bind the line to the tag

BindingHelper.bind(propertyTagLine, propertyTag);

// Bind the color of the tag to the color of the component

propertyTag.bindToColor(controller.getComponent().colorProperty(), controller.getComponent().colorIntensityProperty());

// Updates visibility and placeholder of the tag depending on the type of nail

final Consumer updatePropertyType = (propertyType) -> {

// If it is not a property nail hide the tag otherwise show it and write proper placeholder

if(propertyType.equals(Edge.PropertyType.NONE)) {

propertyTag.setVisible(false);

} else {

// Show the property tag since the nail is a property nail

propertyTag.setVisible(true);

// Set and bind the location of the property tag

if((controller.getNail().getPropertyX() != 0) && (controller.getNail().getPropertyY() != 0)) {

propertyTag.setTranslateX(controller.getNail().getPropertyX());

propertyTag.setTranslateY(controller.getNail().getPropertyY());

}

controller.getNail().propertyXProperty().bind(propertyTag.translateXProperty());

controller.getNail().propertyYProperty().bind(propertyTag.translateYProperty());

Label propertyLabel = controller.propertyLabel;

if(propertyType.equals(Edge.PropertyType.SELECTION)) {

propertyTag.setPlaceholder("Select");

propertyLabel.setText(":");

propertyLabel.setTranslateX(-3);

propertyLabel.setTranslateY(-8);

propertyTag.setAndBindString(controller.getEdge().selectProperty());

} else if(propertyType.equals(Edge.PropertyType.GUARD)) {

propertyTag.setPlaceholder("Guard");

propertyLabel.setText("

propertyLabel.setTranslateX(-3);

propertyLabel.setTranslateY(-7);

propertyTag.setAndBindString(controller.getEdge().guardProperty());

} else if(propertyType.equals(Edge.PropertyType.SYNCHRONIZATION)) {

propertyTag.setPlaceholder("Sync");

propertyLabel.setText("!?");

propertyLabel.setTranslateX(-6);

propertyLabel.setTranslateY(-7);

propertyTag.setAndBindString(controller.getEdge().syncProperty());

} else if(propertyType.equals(Edge.PropertyType.UPDATE)) {

propertyTag.setPlaceholder("Update");

propertyLabel.setText("=");

propertyLabel.setTranslateX(-3);

propertyLabel.setTranslateY(-7);

propertyTag.setAndBindString(controller.getEdge().updateProperty());

}

propertyTag.requestTextFieldFocus();

propertyTag.requestTextFieldFocus(); // Requesting it twice is needed for some reason

}

};

// Whenever the property type updates update the tag

controller.getNail().propertyTypeProperty().addListener((obs, oldPropertyType, newPropertyType) -> {

updatePropertyType.accept(newPropertyType);

});

// Update the tag initially

updatePropertyType.accept(controller.getNail().getPropertyType());

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值