Java Code Examples for javafx.beans.InvalidationListener#invalidated()
The following examples show how to use
javafx.beans.InvalidationListener#invalidated() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MacrosTable.java From phoebus with Eclipse Public License 1.0 | 6 votes |
/** 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); }
Example 2
Source File: ListListenerHelperEx.java From gef with Eclipse Public License 2.0 | 6 votes |
/** * Notifies all registered {@link InvalidationListener}s. */ protected void notifyInvalidationListeners() { if (invalidationListeners != null) { try { lockInvalidationListeners = true; for (InvalidationListener l : invalidationListeners) { try { l.invalidated(source); } catch (Exception e) { Thread.currentThread().getUncaughtExceptionHandler() .uncaughtException(Thread.currentThread(), e); } } } finally { lockInvalidationListeners = false; } } }
Example 3
Source File: SetListenerHelperEx.java From gef with Eclipse Public License 2.0 | 6 votes |
/** * Notifies all registered {@link InvalidationListener}s. */ protected void notifyInvalidationListeners() { if (invalidationListeners != null) { try { lockInvalidationListeners = true; for (InvalidationListener l : invalidationListeners) { try { l.invalidated(source); } catch (Exception e) { Thread.currentThread().getUncaughtExceptionHandler() .uncaughtException(Thread.currentThread(), e); } } } finally { lockInvalidationListeners = false; } } }
Example 4
Source File: SetMultimapListenerHelper.java From gef with Eclipse Public License 2.0 | 6 votes |
/** * Notifies all registered {@link InvalidationListener}s. */ protected void notifyInvalidationListeners() { if (invalidationListeners != null) { try { lockInvalidationListeners = true; for (InvalidationListener l : invalidationListeners) { try { l.invalidated(source); } catch (Exception e) { Thread.currentThread().getUncaughtExceptionHandler() .uncaughtException(Thread.currentThread(), e); } } } finally { lockInvalidationListeners = false; } } }
Example 5
Source File: MultisetListenerHelper.java From gef with Eclipse Public License 2.0 | 6 votes |
/** * Notifies all registered {@link InvalidationListener}s. */ protected void notifyInvalidationListeners() { if (invalidationListeners != null) { try { lockInvalidationListeners = true; for (InvalidationListener l : invalidationListeners) { try { l.invalidated(source); } catch (Exception e) { Thread.currentThread().getUncaughtExceptionHandler() .uncaughtException(Thread.currentThread(), e); } } } finally { lockInvalidationListeners = false; } } }
Example 6
Source File: MapListenerHelperEx.java From gef with Eclipse Public License 2.0 | 6 votes |
/** * Notifies all registered {@link InvalidationListener}s. */ protected void notifyInvalidationListeners() { if (invalidationListeners != null) { try { lockInvalidationListeners = true; for (InvalidationListener l : invalidationListeners) { try { l.invalidated(source); } catch (Exception e) { Thread.currentThread().getUncaughtExceptionHandler() .uncaughtException(Thread.currentThread(), e); } } } finally { lockInvalidationListeners = false; } } }
Example 7
Source File: CollectionBindings.java From phoenicis with GNU Lesser General Public License v3.0 | 6 votes |
/** * Maps an {@link ObservableValue<I>} object to an {@link ObservableList} by applying the given converter function * and adding the result to the {@link ObservableList}. * In case the input value is empty, i.e. contains <code>null</code>, the returned {@link ObservableList} is also * empty * * @param property The input value * @param converter The converter function * @param <I> The type of the input value * @param <O> The type of the output value * @return A {@link ObservableList} containing the converted list */ public static <I, O> ObservableList<O> mapToList(ObservableValue<I> property, Function<I, ? extends Collection<O>> converter) { final ObservableList<O> result = FXCollections.observableArrayList(); final InvalidationListener listener = (Observable invalidation) -> { final I input = property.getValue(); if (input != null) { result.setAll(converter.apply(input)); } else { result.clear(); } }; // add the listener to the property property.addListener(listener); // ensure that the result list is initialised correctly listener.invalidated(property); return result; }
Example 8
Source File: CollectionBindings.java From phoenicis with GNU Lesser General Public License v3.0 | 6 votes |
/** * Maps an {@link ObservableValue<I>} object to an {@link ObservableMap} by applying the given converter function * and adding the result to the {@link ObservableMap}. * In case the input value is empty, i.e. contains <code>null</code>, the returned {@link ObservableMap} is also * empty * * @param property The input value * @param converter The converter function * @param <I> The type of the input value * @param <O1> The input type of the result map * @param <O2> The output type of the result map * @return A {@link ObservableMap} containing the converted map */ public static <I, O1, O2> ObservableMap<O1, O2> mapToMap(ObservableValue<I> property, Function<I, Map<O1, O2>> converter) { final ObservableMap<O1, O2> result = FXCollections.observableHashMap(); final InvalidationListener listener = (Observable invalidation) -> { final I input = property.getValue(); result.clear(); if (input != null) { result.putAll(converter.apply(input)); } }; // add the listener to the property property.addListener(listener); // ensure that the result map is initialised correctly listener.invalidated(property); return result; }
Example 9
Source File: PeriodicScreenCapture.java From chart-fx with Apache License 2.0 | 4 votes |
protected void executeFireInvalidated() { for (final InvalidationListener listener : new ArrayList<>(listeners)) { listener.invalidated(this); } }
Example 10
Source File: Viewer3DFX.java From paintera with GNU General Public License v2.0 | 4 votes |
public Viewer3DFX(final double width, final double height) { super(); this.root = new Group(); this.sceneGroup = new Group(); this.meshesGroup = new Group(); sceneGroup.getChildren().add(meshesGroup); this.setWidth(width); this.setHeight(height); this.scene = new SubScene(root, width, height, true, SceneAntialiasing.BALANCED); this.scene.fillProperty().bind(backgroundFill); this.camera = new PerspectiveCamera(true); this.camera.setNearClip(0.01); this.camera.setFarClip(10.0); this.camera.setTranslateY(0); this.camera.setTranslateX(0); this.camera.setTranslateZ(0); this.camera.setFieldOfView(90); this.scene.setCamera(this.camera); this.cameraGroup = new Group(); this.getChildren().add(this.scene); this.root.getChildren().addAll(cameraGroup, sceneGroup); this.scene.widthProperty().bind(widthProperty()); this.scene.heightProperty().bind(heightProperty()); lightSpot.setTranslateX(-10); lightSpot.setTranslateY(-10); lightSpot.setTranslateZ(-10); lightFill.setTranslateX(10); this.cameraGroup.getChildren().addAll(camera, lightAmbient, lightSpot, lightFill); this.cameraGroup.getTransforms().add(cameraTransform); this.handler = new Scene3DHandler(this); this.root.visibleProperty().bind(this.meshesEnabled); final AffineTransform3D cameraAffineTransform = Transforms.fromTransformFX(cameraTransform); this.handler.addAffineListener(sceneTransform -> { final AffineTransform3D sceneToWorldTransform = Transforms.fromTransformFX(sceneTransform).inverse(); eyeToWorldTransformProperty.set(sceneToWorldTransform.concatenate(cameraAffineTransform)); }); final InvalidationListener sizeChangedListener = obs -> viewFrustumProperty.set( new ViewFrustum(camera, new double[] {getWidth(), getHeight()}) ); widthProperty().addListener(sizeChangedListener); heightProperty().addListener(sizeChangedListener); // set initial value sizeChangedListener.invalidated(null); }
Example 11
Source File: Arrow.java From fxgraph with Do What The F*ck You Want To Public License | 4 votes |
public Arrow(Line line, Line arrow1, Line arrow2, double arrowLength, double arrowWidth) { super(line, arrow1, arrow2); this.line = line; 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) { // arrow parts of length 0 arrow1.setStartX(ex); arrow1.setStartY(ey); arrow2.setStartX(ex); arrow2.setStartY(ey); } else { double factor = arrowLength / Math.hypot(sx-ex, sy-ey); double factorO = arrowWidth / 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); } }; // add updater to properties startXProperty().addListener(updater); startYProperty().addListener(updater); endXProperty().addListener(updater); endYProperty().addListener(updater); updater.invalidated(null); }