Search in sources :

Example 21 with ActionEvent

use of javafx.event.ActionEvent in project Gargoyle by callakrsos.

the class DockTabPaneSkin method removeTabs.

private void removeTabs(List<? extends DockTab> removedList) {
    for (final DockTab tab : removedList) {
        stopCurrentAnimation(tab);
        // Animate the tab removal
        final TabHeaderSkin tabRegion = tabHeaderArea.getTabHeaderSkin(tab);
        if (tabRegion != null) {
            tabRegion.isClosing = true;
            tabRegion.removeListeners(tab);
            removeTabContent(tab);
            // remove the menu item from the popup menu
            ContextMenu popupMenu = tabHeaderArea.controlButtons.popup;
            TabMenuItem tabItem = null;
            if (popupMenu != null) {
                for (MenuItem item : popupMenu.getItems()) {
                    tabItem = (TabMenuItem) item;
                    if (tab == tabItem.getTab()) {
                        break;
                    }
                    tabItem = null;
                }
            }
            if (tabItem != null) {
                tabItem.dispose();
                popupMenu.getItems().remove(tabItem);
            }
            // end of removing menu item
            EventHandler<ActionEvent> cleanup = ae -> {
                tabRegion.animationState = TabAnimationState.NONE;
                tabHeaderArea.removeTab(tab);
                tabHeaderArea.requestLayout();
                if (getSkinnable().getTabs().isEmpty()) {
                    tabHeaderArea.setVisible(false);
                }
            };
            if (closeTabAnimation.get() == TabAnimation.GROW) {
                tabRegion.animationState = TabAnimationState.HIDING;
                Timeline closedTabTimeline = tabRegion.currentAnimation = createTimeline(tabRegion, Duration.millis(ANIMATION_SPEED), 0.0F, cleanup);
                closedTabTimeline.play();
            } else {
                cleanup.handle(null);
            }
        }
    }
}
Also used : EventHandler(javafx.event.EventHandler) Button(javafx.scene.control.Button) HPos(javafx.geometry.HPos) Pos(javafx.geometry.Pos) PseudoClass(javafx.css.PseudoClass) Rotate(javafx.scene.transform.Rotate) EnumConverter(com.sun.javafx.css.converters.EnumConverter) LoggerFactory(org.slf4j.LoggerFactory) StackPane(javafx.scene.layout.StackPane) Side(javafx.geometry.Side) InvalidationListener(javafx.beans.InvalidationListener) TabPane(javafx.scene.control.TabPane) ListChangeListener(javafx.collections.ListChangeListener) ContextMenu(javafx.scene.control.ContextMenu) BehaviorSkinBase(com.sun.javafx.scene.control.skin.BehaviorSkinBase) ControlResources.getString(com.sun.javafx.scene.control.skin.resources.ControlResources.getString) DockPos(com.kyj.fx.voeditor.visual.component.dock.pane.DockPos) DockPane(com.kyj.fx.voeditor.visual.component.dock.pane.DockPane) Point2D(javafx.geometry.Point2D) Pane(javafx.scene.layout.Pane) MultiplePropertyChangeListenerHandler(com.sun.javafx.scene.control.MultiplePropertyChangeListenerHandler) MenuItem(javafx.scene.control.MenuItem) AccessibleAttribute(javafx.scene.AccessibleAttribute) SingleSelectionModel(javafx.scene.control.SingleSelectionModel) DockEvent(com.kyj.fx.voeditor.visual.component.dock.pane.DockEvent) CssMetaData(javafx.css.CssMetaData) Timeline(javafx.animation.Timeline) Rectangle(javafx.scene.shape.Rectangle) TraversalEngine(com.sun.javafx.scene.traversal.TraversalEngine) Observable(javafx.beans.Observable) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) WeakInvalidationListener(javafx.beans.WeakInvalidationListener) List(java.util.List) Duration(javafx.util.Duration) Region(javafx.scene.layout.Region) Interpolator(javafx.animation.Interpolator) WeakListChangeListener(javafx.collections.WeakListChangeListener) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) ObservableList(javafx.collections.ObservableList) AccessibleRole(javafx.scene.AccessibleRole) Styleable(javafx.css.Styleable) Bounds(javafx.geometry.Bounds) SkinBase(javafx.scene.control.SkinBase) RadioMenuItem(javafx.scene.control.RadioMenuItem) MouseButton(javafx.scene.input.MouseButton) MouseEvent(javafx.scene.input.MouseEvent) FXCollections(javafx.collections.FXCollections) DoubleProperty(javafx.beans.property.DoubleProperty) DockNode(com.kyj.fx.voeditor.visual.component.dock.pane.DockNode) SwipeEvent(javafx.scene.input.SwipeEvent) ArrayList(java.util.ArrayList) TabClosingPolicy(javafx.scene.control.TabPane.TabClosingPolicy) VPos(javafx.geometry.VPos) AccessibleAction(javafx.scene.AccessibleAction) Direction(com.sun.javafx.scene.traversal.Direction) StyleableProperty(javafx.css.StyleableProperty) KeyValue(javafx.animation.KeyValue) Animation(javafx.animation.Animation) Tooltip(javafx.scene.control.Tooltip) Color(javafx.scene.paint.Color) KeyFrame(javafx.animation.KeyFrame) ObjectProperty(javafx.beans.property.ObjectProperty) Logger(org.slf4j.Logger) Label(javafx.scene.control.Label) Iterator(java.util.Iterator) Node(javafx.scene.Node) ScrollEvent(javafx.scene.input.ScrollEvent) DropShadow(javafx.scene.effect.DropShadow) ContextMenuEvent(javafx.scene.input.ContextMenuEvent) Popup(javafx.stage.Popup) ActionEvent(javafx.event.ActionEvent) ToggleGroup(javafx.scene.control.ToggleGroup) StyleableObjectProperty(javafx.css.StyleableObjectProperty) Utils(com.sun.javafx.util.Utils) ImageView(javafx.scene.image.ImageView) WritableValue(javafx.beans.value.WritableValue) Collections(java.util.Collections) SharedMemory(com.kyj.fx.voeditor.visual.momory.SharedMemory) Timeline(javafx.animation.Timeline) ActionEvent(javafx.event.ActionEvent) ContextMenu(javafx.scene.control.ContextMenu) MenuItem(javafx.scene.control.MenuItem) RadioMenuItem(javafx.scene.control.RadioMenuItem)

Example 22 with ActionEvent

use of javafx.event.ActionEvent in project jgnash by ccavanaugh.

the class ConsoleDialogController method initialize.

@FXML
void initialize() {
    oldErrStream = System.err;
    oldOutStream = System.out;
    // Force a monospaced font
    consoleArea.setFont(Font.font("Monospaced", consoleArea.getFont().getSize()));
    Engine.getLogger().addHandler(logHandler);
    try {
        outStream = new PrintStream(new OutputStream() {

            @Override
            public void write(int b) {
                oldOutStream.write(b);
                JavaFXUtils.runLater(() -> consoleArea.appendText(String.valueOf((char) b)));
            }
        }, false, Charset.defaultCharset().name());
    } catch (final UnsupportedEncodingException ex) {
        Logger.getLogger(ConsoleDialogController.class.getName()).log(Level.SEVERE, null, ex);
    }
    try {
        errStream = new PrintStream(new OutputStream() {

            @Override
            public void write(int b) {
                oldErrStream.write(b);
                JavaFXUtils.runLater(() -> consoleArea.appendText(String.valueOf((char) b)));
            }
        }, false, Charset.defaultCharset().name());
    } catch (final UnsupportedEncodingException ex) {
        Logger.getLogger(ConsoleDialogController.class.getName()).log(Level.SEVERE, null, ex);
    }
    // Plug in the new streams
    System.setOut(outStream);
    System.setErr(errStream);
    timeline = new Timeline(new KeyFrame(Duration.millis(REFRESH_PERIOD), new EventHandler<ActionEvent>() {

        private long total;

        private long used;

        private long oldUsed;

        private static final int diff = 1;

        @Override
        public void handle(ActionEvent event) {
            total = runtime.totalMemory() / BYTES_PER_MB;
            used = total - runtime.freeMemory() / BYTES_PER_MB;
            if (used < oldUsed - diff || used > oldUsed + diff) {
                JavaFXUtils.runLater(() -> {
                    memoryUsageProgressBar.setProgress((double) used / (double) total);
                    memoryUsageText.setText(used + "/" + total + " MB");
                });
                oldUsed = used;
            }
        }
    }));
    timeline.setCycleCount(Animation.INDEFINITE);
    timeline.play();
    // Close with the main application
    MainView.getPrimaryStage().addEventHandler(WindowEvent.WINDOW_CLOSE_REQUEST, event -> handleCloseAction());
}
Also used : PrintStream(java.io.PrintStream) Timeline(javafx.animation.Timeline) ActionEvent(javafx.event.ActionEvent) OutputStream(java.io.OutputStream) UnsupportedEncodingException(java.io.UnsupportedEncodingException) KeyFrame(javafx.animation.KeyFrame) InjectFXML(jgnash.uifx.util.InjectFXML) FXML(javafx.fxml.FXML)

Example 23 with ActionEvent

use of javafx.event.ActionEvent in project fxexperience2 by EricCanull.

the class RotatorControl method initialize.

/**
     * Private
     */
private void initialize(String text) {
    final FXMLLoader loader = new FXMLLoader();
    //NOI18N
    loader.setLocation(RotatorControl.class.getResource("/fxml/FXMLRotatorControl.fxml"));
    loader.setController(this);
    loader.setRoot(this);
    try {
        loader.load();
    } catch (IOException ex) {
        Logger.getLogger(GradientPicker.class.getName()).log(Level.SEVERE, null, ex);
    }
    assert rotator_label != null;
    rotator_label.setText(text);
    rotator_dial.setOnAction((ActionEvent event) -> {
        event.consume();
    });
    rotator_handle.setOnAction((ActionEvent event) -> {
        event.consume();
    });
}
Also used : GradientPicker(com.fxexperience.javafx.scene.control.gradientpicker.GradientPicker) ActionEvent(javafx.event.ActionEvent) IOException(java.io.IOException) FXMLLoader(javafx.fxml.FXMLLoader)

Example 24 with ActionEvent

use of javafx.event.ActionEvent in project fxexperience2 by EricCanull.

the class GradientPickerStop method initialize.

private void initialize() {
    final FXMLLoader loader = new FXMLLoader();
    //NOI18N
    loader.setLocation(GradientPickerStop.class.getResource("/fxml/FXMLGradientPickerStop.fxml"));
    loader.setController(this);
    loader.setRoot(this);
    try {
        loader.load();
    } catch (IOException ex) {
        Logger.getLogger(GradientPicker.class.getName()).log(Level.SEVERE, null, ex);
    }
    assert offset_textfield != null;
    assert chip_rect != null;
    //NOI18N
    offset_textfield.setText("" + offset);
    chip_rect.setFill(color);
    gradientPicker.setSelectedStop(this);
    stop_button.setOnAction((ActionEvent event) -> {
        event.consume();
    });
    // when we detect a width change, we know node layout is resolved so we position stop in track
    widthProperty().addListener((ov, oldValue, newValue) -> {
        if (newValue.doubleValue() > 0) {
            thumbWidth = newValue.doubleValue();
            valueToPixels();
        }
    });
}
Also used : ActionEvent(javafx.event.ActionEvent) IOException(java.io.IOException) FXMLLoader(javafx.fxml.FXMLLoader)

Example 25 with ActionEvent

use of javafx.event.ActionEvent in project fxexperience2 by EricCanull.

the class DemoController method bringBackAfter.

private void bringBackAfter() {
    PauseTransition pauseTransition = new PauseTransition();
    pauseTransition.setDuration(Duration.seconds(1.5));
    pauseTransition.play();
    pauseTransition.setOnFinished((ActionEvent t) -> {
        btn.setOpacity(1);
        btn.autosize();
    });
}
Also used : ActionEvent(javafx.event.ActionEvent) PauseTransition(javafx.animation.PauseTransition)

Aggregations

ActionEvent (javafx.event.ActionEvent)37 List (java.util.List)11 Label (javafx.scene.control.Label)11 ObservableList (javafx.collections.ObservableList)10 FxUtil (com.kyj.fx.voeditor.visual.util.FxUtil)9 ArrayList (java.util.ArrayList)9 Optional (java.util.Optional)9 Button (javafx.scene.control.Button)9 MenuItem (javafx.scene.control.MenuItem)9 Stage (javafx.stage.Stage)9 ResourceLoader (com.kyj.fx.voeditor.visual.momory.ResourceLoader)8 DialogUtil (com.kyj.fx.voeditor.visual.util.DialogUtil)8 ValueUtil (com.kyj.fx.voeditor.visual.util.ValueUtil)8 File (java.io.File)8 MouseEvent (javafx.scene.input.MouseEvent)8 Pair (javafx.util.Pair)8 Logger (org.slf4j.Logger)8 ConfigResourceLoader (com.kyj.fx.voeditor.visual.momory.ConfigResourceLoader)7 Iterator (java.util.Iterator)7 FXCollections (javafx.collections.FXCollections)7