本文整理匯總了Java中javafx.beans.InvalidationListener.invalidated方法的典型用法代碼示例。如果您正苦於以下問題:Java InvalidationListener.invalidated方法的具體用法?Java InvalidationListener.invalidated怎麽用?Java InvalidationListener.invalidated使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.beans.InvalidationListener
的用法示例。
在下文中一共展示了InvalidationListener.invalidated方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: fixup
import javafx.beans.InvalidationListener; //導入方法依賴的package包/類
/** Fix table: Delete empty rows in middle, but keep one empty final row
* @param changed_row Row to check, and remove if it's empty
*/
private void fixup(final int changed_row)
{
// Check if edited row is now empty and should be deleted
if (changed_row < data.size())
{
final MacroItem item = data.get(changed_row);
final String name = item.getName().trim();
final String value = item.getValue().trim();
if (name.isEmpty() && value.isEmpty())
data.remove(changed_row);
}
// Assert one empty row at bottom
final int len = data.size();
if (len <= 0 ||
(data.get(len-1).getName().trim().length() > 0 &&
data.get(len-1).getValue().trim().length() > 0) )
data.add(new MacroItem("", ""));
for (InvalidationListener listener : listeners)
listener.invalidated(data);
}
示例2: notifyChanged
import javafx.beans.InvalidationListener; //導入方法依賴的package包/類
public void notifyChanged() {
InvalidationListener[] listenersArray = listeners.toArray(new InvalidationListener[listeners.size()]);
for (InvalidationListener listener : listenersArray) {
try {
listener.invalidated(this);
} catch (Throwable e) {
Thread.currentThread().getUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e);
}
}
}
示例3: bindSingleton
import javafx.beans.InvalidationListener; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public static <T> void bindSingleton(ObservableValue<T> singleton, ObservableList<? super T> collection) {
InvalidationListener listener = dummy -> {
T val = singleton.getValue();
if (val == null) {
collection.clear();
} else {
collection.setAll(val);
}
};
singleton.addListener(listener);
listener.invalidated(singleton);
}
示例4: drawCell
import javafx.beans.InvalidationListener; //導入方法依賴的package包/類
@Override
protected void drawCell(FileItem item, Node node) {
progressIndicator.visibleProperty().bind(item.isProgressingProperty());
progressIndicator.progressProperty().bind(item.progressProperty());
Bindings.bindBidirectional(fileSize.textProperty(), item.sizeProperty(), new StringConverter<Number>() {
@Override
public Number fromString(String string) {
return fromSizeString(string);
}
@Override
public String toString(Number object) {
return toSizeString(object.longValue());
};
});
fileIcon.getStyleClass().clear();
fileIcon.getStyleClass().add(item.getType().toString());
fileUserTime.setText(String.format("%s, %s", item.getUser().getNickname(),
item.getDate() == null ? "" : dateFormat.format(item.getDate())));
fileName.setText(item.getFile().getName());
InvalidationListener downPlayChanged = (observable) -> {
downPlayingIcon.getStyleClass().clear();
if (item.isPlayingProperty().get() && item.getType().equals(FileType.MUSIC)) {
downPlayingIcon.getStyleClass().add("playing");
} else if (item.isPhantomProperty().get()) {
downPlayingIcon.getStyleClass().add("down");
}
};
downPlayChanged.invalidated(null);
item.isPlayingProperty().addListener(downPlayChanged);
item.isPhantomProperty().addListener(downPlayChanged);
downPlayingIcon.visibleProperty().bind(item.isProgressingProperty().not());
downPlayingIcon.setUserData(item);
}
示例5: notifyListeners
import javafx.beans.InvalidationListener; //導入方法依賴的package包/類
private void notifyListeners()
{
for (InvalidationListener il : listeners_)
{
il.invalidated(this);
}
}
示例6: Arrow
import javafx.beans.InvalidationListener; //導入方法依賴的package包/類
private Arrow(Line line, Line arrow1, Line arrow2) {
super(line, arrow1, arrow2);
this.line = line;
/* The color of the arrow should follow the color of the main line. */
arrow1.strokeProperty().bind(line.strokeProperty());
arrow2.strokeProperty().bind(line.strokeProperty());
/* Listener to redraw the arrow parts when the line position changes. */
InvalidationListener updater = o -> {
double ex = getEndX();
double ey = getEndY();
double sx = getStartX();
double sy = getStartY();
arrow1.setEndX(ex);
arrow1.setEndY(ey);
arrow2.setEndX(ex);
arrow2.setEndY(ey);
if (ex == sx && ey == sy) {
/* The line is just a point. Don't draw the arrowhead. */
arrow1.setStartX(ex);
arrow1.setStartY(ey);
arrow2.setStartX(ex);
arrow2.setStartY(ey);
} else {
double factor = ARROW_HEAD_LENGTH / Math.hypot(sx-ex, sy-ey);
double factorO = ARROW_HEAD_WIDTH / Math.hypot(sx-ex, sy-ey);
// part in direction of main line
double dx = (sx - ex) * factor;
double dy = (sy - ey) * factor;
// part ortogonal to main line
double ox = (sx - ex) * factorO;
double oy = (sy - ey) * factorO;
arrow1.setStartX(ex + dx - oy);
arrow1.setStartY(ey + dy + ox);
arrow2.setStartX(ex + dx + oy);
arrow2.setStartY(ey + dy - ox);
}
};
/* Attach updater to properties */
startXProperty().addListener(updater);
startYProperty().addListener(updater);
endXProperty().addListener(updater);
endYProperty().addListener(updater);
updater.invalidated(null);
}
示例7: Arrow
import javafx.beans.InvalidationListener; //導入方法依賴的package包/類
private Arrow(double positionX, double positionY, double destinationX, double destinationY) {
this.line = new Line(positionX, positionY, destinationX, destinationY);
InvalidationListener updater = o -> {
double ex = getEndX();
double ey = getEndY();
double sx = getStartX();
double sy = getStartY();
arrow1.setEndX(ex);
arrow1.setEndY(ey);
arrow2.setEndX(ex);
arrow2.setEndY(ey);
if (ex == sx && ey == sy) {
arrow1.setStartX(ex);
arrow1.setStartY(ey);
arrow2.setStartX(ex);
arrow2.setStartY(ey);
}
else {
double factor = ARROW_LENGTH / Math.hypot(sx-ex, sy-ey);
double factorO = ARROW_WIDTH / Math.hypot(sx-ex, sy-ey);
double dx = (sx - ex) * factor;
double dy = (sy - ey) * factor;
double ox = (sx - ex) * factorO;
double oy = (sy - ey) * factorO;
arrow1.setStartX(ex + dx - oy);
arrow1.setStartY(ey + dy + ox);
arrow2.setStartX(ex + dx + oy);
arrow2.setStartY(ey + dy - ox);
}
};
startXProperty().addListener(updater);
startYProperty().addListener(updater);
endXProperty().addListener(updater);
endYProperty().addListener(updater);
updater.invalidated(null);
this.getChildren().add(line);
this.getChildren().add(arrow1);
this.getChildren().add(arrow2);
}
示例8: createVisualisation
import javafx.beans.InvalidationListener; //導入方法依賴的package包/類
@Override
public Node createVisualisation(SimpleObjectProperty<Data> boundTo, boolean readonly) {
Button showButton = new Button("", uniformDesign.createIcon(FontAwesome.Glyph.PENCIL));
showButton.setOnAction(event -> navigateToData.accept(boundTo.get()));
showButton.disableProperty().bind(boundTo.isNull());
Button selectButton = new Button();
uniformDesign.addIcon(selectButton,FontAwesome.Glyph.SEARCH_PLUS);
selectButton.setOnAction(event -> {
final Optional<Data> toAdd = new DataChoiceDialog().show(possibleValuesProvider.get(), selectButton.getScene().getWindow(), uniformDesign);
toAdd.ifPresent(data -> boundTo.set(data));
});
selectButton.setDisable(!isUserEditable || !isUserSelectable || readonly);
Button newButton = new Button();
uniformDesign.addIcon(newButton,FontAwesome.Glyph.PLUS);
newButton.setOnAction(event -> {
addNewReference(newButton.getScene().getWindow());
});
newButton.setDisable(!isUserEditable || !isUserCreateable || readonly);
Button deleteButton = new Button();
uniformDesign.addDangerIcon(deleteButton,FontAwesome.Glyph.TIMES);
deleteButton.setOnAction(event -> remover.run());
deleteButton.disableProperty().bind(boundTo.isNull().or(new SimpleBooleanProperty(!isUserEditable)).or(new SimpleBooleanProperty(readonly).or(new SimpleBooleanProperty(!isUserDeletable))));
TextField textField = new TextField();
InvalidationListener invalidationListener = observable -> {
if (boundTo.get() == null) {
textField.setText(null);
} else {
textField.setText(boundTo.get().internal().getDisplayText());
}
};
invalidationListener.invalidated(boundTo);
boundTo.addListener(invalidationListener);
HBox.setHgrow(textField, Priority.ALWAYS);
textField.setEditable(false);
textField.setOnMouseClicked(mouseEvent -> {
if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) {
if (mouseEvent.getClickCount() == 2 && boundTo.get()!=null) {
navigateToData.accept(boundTo.get());
}
}
});
textField.disableProperty().bind(showButton.disabledProperty());
HBox hBox = new HBox();
hBox.setSpacing(3);
hBox.getChildren().add(textField);
hBox.getChildren().add(showButton);
hBox.getChildren().add(selectButton);
hBox.getChildren().add(newButton);
hBox.getChildren().add(deleteButton);
showButton.setTooltip(new Tooltip(uniformDesign.getText(editText)));
selectButton.setTooltip(new Tooltip(uniformDesign.getText(selectText)));
newButton.setTooltip(new Tooltip(uniformDesign.getText(addText)));
deleteButton.setTooltip(new Tooltip(uniformDesign.getText(deleteText)));
return hBox;
}
示例9: invalidate
import javafx.beans.InvalidationListener; //導入方法依賴的package包/類
protected void invalidate(){
for(InvalidationListener listener: invalidationListeners){
listener.invalidated(this);
}
}