Search in sources :

Example 46 with ScrollPane

use of javafx.scene.control.ScrollPane in project org.csstudio.display.builder by kasemir.

the class JFXRepresentation method createModelRoot.

/**
 * Create scrollpane etc. for hosting the model
 *
 *  @return ScrollPane
 *  @throws IllegalStateException if had already been called
 */
public final ScrollPane createModelRoot() {
    if (model_root != null)
        throw new IllegalStateException("Already created model root");
    widget_parent = new Pane();
    scroll_body = new Group(widget_parent);
    if (isEditMode()) {
        horiz_bound = new Line();
        horiz_bound.getStyleClass().add("display_model_bounds");
        horiz_bound.setStartX(0);
        vert_bound = new Line();
        vert_bound.getStyleClass().add("display_model_bounds");
        vert_bound.setStartY(0);
        scroll_body.getChildren().addAll(vert_bound, horiz_bound);
    }
    model_root = new ScrollPane(scroll_body);
    final InvalidationListener resized = prop -> handleViewportChanges();
    model_root.widthProperty().addListener(resized);
    model_root.heightProperty().addListener(resized);
    // Middle Button (Wheel press) drag panning started
    final EventHandler<MouseEvent> onMousePressedHandler = evt -> {
        if (evt.isMiddleButtonDown()) {
            lastMouseCoordinates.set(new Point2D(evt.getX(), evt.getY()));
            scroll_body.setCursor(Cursor.CLOSED_HAND);
            evt.consume();
        }
    };
    if (isEditMode())
        scroll_body.addEventFilter(MouseEvent.MOUSE_PRESSED, onMousePressedHandler);
    else
        scroll_body.setOnMousePressed(onMousePressedHandler);
    // Middle Button (Wheel press) drag panning function
    final EventHandler<MouseEvent> onMouseDraggedHandler = evt -> {
        if (evt.isMiddleButtonDown()) {
            double deltaX = evt.getX() - lastMouseCoordinates.get().getX();
            double extraWidth = scroll_body.getLayoutBounds().getWidth() - model_root.getViewportBounds().getWidth();
            double deltaH = deltaX * (model_root.getHmax() - model_root.getHmin()) / extraWidth;
            double desiredH = model_root.getHvalue() - deltaH;
            model_root.setHvalue(Math.max(0, Math.min(model_root.getHmax(), desiredH)));
            double deltaY = evt.getY() - lastMouseCoordinates.get().getY();
            double extraHeight = scroll_body.getLayoutBounds().getHeight() - model_root.getViewportBounds().getHeight();
            double deltaV = deltaY * (model_root.getHmax() - model_root.getHmin()) / extraHeight;
            double desiredV = model_root.getVvalue() - deltaV;
            model_root.setVvalue(Math.max(0, Math.min(model_root.getVmax(), desiredV)));
            evt.consume();
        }
    };
    if (isEditMode())
        scroll_body.addEventFilter(MouseEvent.MOUSE_DRAGGED, onMouseDraggedHandler);
    else
        scroll_body.setOnMouseDragged(onMouseDraggedHandler);
    // Middle Button (Wheel press) drag panning finished
    final EventHandler<MouseEvent> onMouseReleasedHandler = evt -> {
        if (scroll_body.getCursor() == Cursor.CLOSED_HAND) {
            scroll_body.setCursor(Cursor.DEFAULT);
            evt.consume();
        }
    };
    if (isEditMode())
        scroll_body.addEventFilter(MouseEvent.MOUSE_RELEASED, onMouseReleasedHandler);
    else
        scroll_body.setOnMouseReleased(onMouseReleasedHandler);
    // also handle the wheel
    if (isEditMode())
        model_root.addEventFilter(ScrollEvent.ANY, evt -> {
            if (evt.isControlDown()) {
                evt.consume();
                doWheelZoom(evt.getDeltaY(), evt.getX(), evt.getY());
            }
        });
    else
        widget_parent.addEventHandler(ScrollEvent.ANY, evt -> {
            if (evt.isControlDown()) {
                evt.consume();
                ScrollEvent gevt = evt.copyFor(model_root, scroll_body);
                doWheelZoom(evt.getDeltaY(), gevt.getX(), gevt.getY());
            }
        });
    return model_root;
}
Also used : Line(javafx.scene.shape.Line) Color(java.awt.Color) PredefinedColorMaps(org.csstudio.display.builder.model.properties.PredefinedColorMaps) GaugeWidget(org.csstudio.display.builder.model.widgets.GaugeWidget) PictureWidget(org.csstudio.display.builder.model.widgets.PictureWidget) RegistryFactory(org.eclipse.core.runtime.RegistryFactory) EllipseWidget(org.csstudio.display.builder.model.widgets.EllipseWidget) TextEntryRepresentation(org.csstudio.display.builder.representation.javafx.widgets.TextEntryRepresentation) TextUpdateWidget(org.csstudio.display.builder.model.widgets.TextUpdateWidget) ScrollBarRepresentation(org.csstudio.display.builder.representation.javafx.widgets.ScrollBarRepresentation) Line(javafx.scene.shape.Line) Future(java.util.concurrent.Future) TankWidget(org.csstudio.display.builder.model.widgets.TankWidget) XYPlotWidget(org.csstudio.display.builder.model.widgets.plots.XYPlotWidget) ScrollPane(javafx.scene.control.ScrollPane) XYPlotRepresentation(org.csstudio.display.builder.representation.javafx.widgets.plots.XYPlotRepresentation) Map(java.util.Map) MultiStateLEDWidget(org.csstudio.display.builder.model.widgets.MultiStateLEDWidget) Point2D(javafx.geometry.Point2D) WidgetRepresentation(org.csstudio.display.builder.representation.WidgetRepresentation) Transform(javafx.scene.transform.Transform) ThermometerWidget(org.csstudio.display.builder.model.widgets.ThermometerWidget) NamedColorMappings(org.csstudio.javafx.rtplot.NamedColorMappings) LinearMeterWidget(org.csstudio.display.builder.model.widgets.LinearMeterWidget) PolygonWidget(org.csstudio.display.builder.model.widgets.PolygonWidget) TabsWidget(org.csstudio.display.builder.model.widgets.TabsWidget) ScaledSliderRepresentation(org.csstudio.display.builder.representation.javafx.widgets.ScaledSliderRepresentation) BoolButtonWidget(org.csstudio.display.builder.model.widgets.BoolButtonWidget) ArcRepresentation(org.csstudio.display.builder.representation.javafx.widgets.ArcRepresentation) Group(javafx.scene.Group) Platform(javafx.application.Platform) CountDownLatch(java.util.concurrent.CountDownLatch) LEDRepresentation(org.csstudio.display.builder.representation.javafx.widgets.LEDRepresentation) RadioRepresentation(org.csstudio.display.builder.representation.javafx.widgets.RadioRepresentation) TabsRepresentation(org.csstudio.display.builder.representation.javafx.widgets.TabsRepresentation) ColorMappingFunction(org.csstudio.javafx.rtplot.ColorMappingFunction) BasicStroke(java.awt.BasicStroke) ObservableList(javafx.collections.ObservableList) CheckBoxWidget(org.csstudio.display.builder.model.widgets.CheckBoxWidget) TableWidget(org.csstudio.display.builder.model.widgets.TableWidget) Bounds(javafx.geometry.Bounds) ClockRepresentation(org.csstudio.display.builder.representation.javafx.widgets.ClockRepresentation) ArcWidget(org.csstudio.display.builder.model.widgets.ArcWidget) JFXBaseRepresentation(org.csstudio.display.builder.representation.javafx.widgets.JFXBaseRepresentation) EmbeddedDisplayRepresentation(org.csstudio.display.builder.representation.javafx.widgets.EmbeddedDisplayRepresentation) KnobWidget(org.csstudio.display.builder.model.widgets.KnobWidget) GroupRepresentation(org.csstudio.display.builder.representation.javafx.widgets.GroupRepresentation) ThumbWheelWidget(org.csstudio.display.builder.model.widgets.ThumbWheelWidget) ImageWidget(org.csstudio.display.builder.model.widgets.plots.ImageWidget) TextSymbolWidget(org.csstudio.display.builder.model.widgets.TextSymbolWidget) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) RectangleRepresentation(org.csstudio.display.builder.representation.javafx.widgets.RectangleRepresentation) LabelWidget(org.csstudio.display.builder.model.widgets.LabelWidget) TextEntryWidget(org.csstudio.display.builder.model.widgets.TextEntryWidget) EllipseRepresentation(org.csstudio.display.builder.representation.javafx.widgets.EllipseRepresentation) MeterWidget(org.csstudio.display.builder.model.widgets.MeterWidget) Node(javafx.scene.Node) ImagePattern(javafx.scene.paint.ImagePattern) TableRepresentation(org.csstudio.display.builder.representation.javafx.widgets.TableRepresentation) Background(javafx.scene.layout.Background) File(java.io.File) ImageRepresentation(org.csstudio.display.builder.representation.javafx.widgets.plots.ImageRepresentation) ExecutionException(java.util.concurrent.ExecutionException) ArrayWidget(org.csstudio.display.builder.model.widgets.ArrayWidget) Cursor(javafx.scene.Cursor) FileChooser(javafx.stage.FileChooser) ComboWidget(org.csstudio.display.builder.model.widgets.ComboWidget) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) GaugeRepresentation(org.csstudio.display.builder.representation.javafx.widgets.GaugeRepresentation) Widget(org.csstudio.display.builder.model.Widget) NamedColorMapping(org.csstudio.javafx.rtplot.NamedColorMapping) EventHandler(javafx.event.EventHandler) ToolkitRepresentation(org.csstudio.display.builder.representation.ToolkitRepresentation) ComboRepresentation(org.csstudio.display.builder.representation.javafx.widgets.ComboRepresentation) LinearMeterRepresentation(org.csstudio.display.builder.representation.javafx.widgets.LinearMeterRepresentation) WebBrowserRepresentation(org.csstudio.display.builder.representation.javafx.widgets.WebBrowserRepresentation) TimeoutException(java.util.concurrent.TimeoutException) RenderingHints(java.awt.RenderingHints) ChoiceDialog(javafx.scene.control.ChoiceDialog) ClockWidget(org.csstudio.display.builder.model.widgets.ClockWidget) ProgressBarWidget(org.csstudio.display.builder.model.widgets.ProgressBarWidget) InvalidationListener(javafx.beans.InvalidationListener) PictureRepresentation(org.csstudio.display.builder.representation.javafx.widgets.PictureRepresentation) Parent(javafx.scene.Parent) RectangleWidget(org.csstudio.display.builder.model.widgets.RectangleWidget) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry) ActionButtonRepresentation(org.csstudio.display.builder.representation.javafx.widgets.ActionButtonRepresentation) SpinnerRepresentation(org.csstudio.display.builder.representation.javafx.widgets.SpinnerRepresentation) WidgetRepresentationFactory(org.csstudio.display.builder.representation.WidgetRepresentationFactory) Status(javafx.scene.media.MediaPlayer.Status) Pane(javafx.scene.layout.Pane) Alert(javafx.scene.control.Alert) MeterRepresentation(org.csstudio.display.builder.representation.javafx.widgets.MeterRepresentation) BufferedImage(java.awt.image.BufferedImage) ArrayRepresentation(org.csstudio.display.builder.representation.javafx.widgets.ArrayRepresentation) PolylineWidget(org.csstudio.display.builder.model.widgets.PolylineWidget) ThermometerRepresentation(org.csstudio.display.builder.representation.javafx.widgets.ThermometerRepresentation) List(java.util.List) ByteMonitorWidget(org.csstudio.display.builder.model.widgets.ByteMonitorWidget) RadioWidget(org.csstudio.display.builder.model.widgets.RadioWidget) LabelRepresentation(org.csstudio.display.builder.representation.javafx.widgets.LabelRepresentation) GroupWidget(org.csstudio.display.builder.model.widgets.GroupWidget) Scale(javafx.scene.transform.Scale) Optional(java.util.Optional) ThumbWheelRepresentation(org.csstudio.display.builder.representation.javafx.widgets.ThumbWheelRepresentation) Media(javafx.scene.media.Media) NavigationTabsWidget(org.csstudio.display.builder.model.widgets.NavigationTabsWidget) ProgressBarRepresentation(org.csstudio.display.builder.representation.javafx.widgets.ProgressBarRepresentation) NavigationTabsRepresentation(org.csstudio.display.builder.representation.javafx.widgets.NavigationTabsRepresentation) CornerRadii(javafx.scene.layout.CornerRadii) Scene(javafx.scene.Scene) DisplayModel(org.csstudio.display.builder.model.DisplayModel) LEDWidget(org.csstudio.display.builder.model.widgets.LEDWidget) ButtonType(javafx.scene.control.ButtonType) MouseEvent(javafx.scene.input.MouseEvent) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) Level(java.util.logging.Level) Insets(javafx.geometry.Insets) Graphics2D(java.awt.Graphics2D) ScrollBarWidget(org.csstudio.display.builder.model.widgets.ScrollBarWidget) WidgetColor(org.csstudio.display.builder.model.properties.WidgetColor) TextUpdateRepresentation(org.csstudio.display.builder.representation.javafx.widgets.TextUpdateRepresentation) BackgroundFill(javafx.scene.layout.BackgroundFill) TankRepresentation(org.csstudio.display.builder.representation.javafx.widgets.TankRepresentation) DigitalClockRepresentation(org.csstudio.display.builder.representation.javafx.widgets.DigitalClockRepresentation) WebBrowserWidget(org.csstudio.display.builder.model.widgets.WebBrowserWidget) DigitalClockWidget(org.csstudio.display.builder.model.widgets.DigitalClockWidget) TextSymbolRepresentation(org.csstudio.display.builder.representation.javafx.widgets.TextSymbolRepresentation) MediaPlayer(javafx.scene.media.MediaPlayer) ByteMonitorRepresentation(org.csstudio.display.builder.representation.javafx.widgets.ByteMonitorRepresentation) PolylineRepresentation(org.csstudio.display.builder.representation.javafx.widgets.PolylineRepresentation) ObjectProperty(javafx.beans.property.ObjectProperty) CheckBoxRepresentation(org.csstudio.display.builder.representation.javafx.widgets.CheckBoxRepresentation) SymbolRepresentation(org.csstudio.display.builder.representation.javafx.widgets.SymbolRepresentation) WritableImage(javafx.scene.image.WritableImage) EmbeddedDisplayWidget(org.csstudio.display.builder.model.widgets.EmbeddedDisplayWidget) SpinnerWidget(org.csstudio.display.builder.model.widgets.SpinnerWidget) SymbolWidget(org.csstudio.display.builder.model.widgets.SymbolWidget) ScrollEvent(javafx.scene.input.ScrollEvent) Styles(org.csstudio.javafx.Styles) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) ScaledSliderWidget(org.csstudio.display.builder.model.widgets.ScaledSliderWidget) BoolButtonRepresentation(org.csstudio.display.builder.representation.javafx.widgets.BoolButtonRepresentation) PolygonRepresentation(org.csstudio.display.builder.representation.javafx.widgets.PolygonRepresentation) ActionButtonWidget(org.csstudio.display.builder.model.widgets.ActionButtonWidget) KnobRepresentation(org.csstudio.display.builder.representation.javafx.widgets.KnobRepresentation) UntypedWidgetPropertyListener(org.csstudio.display.builder.model.UntypedWidgetPropertyListener) WidgetPropertyListener(org.csstudio.display.builder.model.WidgetPropertyListener) SwingFXUtils(javafx.embed.swing.SwingFXUtils) Window(javafx.stage.Window) DialogHelper(org.csstudio.javafx.DialogHelper) MultiStateLEDRepresentation(org.csstudio.display.builder.representation.javafx.widgets.MultiStateLEDRepresentation) Group(javafx.scene.Group) MouseEvent(javafx.scene.input.MouseEvent) Point2D(javafx.geometry.Point2D) ScrollEvent(javafx.scene.input.ScrollEvent) ScrollPane(javafx.scene.control.ScrollPane) InvalidationListener(javafx.beans.InvalidationListener) ScrollPane(javafx.scene.control.ScrollPane) Pane(javafx.scene.layout.Pane)

Example 47 with ScrollPane

use of javafx.scene.control.ScrollPane in project org.csstudio.display.builder by kasemir.

the class ZoomPan method createScene.

public static Scene createScene() {
    // Stuff to show as 'widgets'
    final Node[] stuff = new Node[3];
    for (int i = 0; i < stuff.length; ++i) {
        final Rectangle rect = new Rectangle(50 + i * 100, 100, 10 + i * 50, 20 + i * 40);
        rect.setFill(Color.BLUE);
        stuff[i] = rect;
    }
    // With 'Group', stuff would start in top-left (0, 0) corner,
    // not at (50, 100) based on its coordinates
    final Pane widgets = new Pane(stuff);
    widgets.setStyle("-fx-background-color: coral;");
    final ScrollPane scroll;
    if (true) {
        // Additional Group to help ScrollPane get correct bounds
        final Group scroll_content = new Group(widgets);
        scroll = new ScrollPane(scroll_content);
    } else
        scroll = new ScrollPane(widgets);
    final InvalidationListener resized = prop -> handleViewportChanges(scroll);
    scroll.widthProperty().addListener(resized);
    scroll.heightProperty().addListener(resized);
    System.out.println("Press 'space' to change zoom");
    final Scene scene = new Scene(scroll);
    scene.addEventFilter(KeyEvent.KEY_PRESSED, (KeyEvent event) -> {
        if (event.getCode() == KeyCode.SPACE) {
            zoom_in = !zoom_in;
            if (zoom_in)
                widgets.getTransforms().setAll(new Scale(2.5, 2.5));
            else
                widgets.getTransforms().setAll(new Scale(0.5, 0.5));
        }
    });
    return scene;
}
Also used : Scene(javafx.scene.Scene) KeyCode(javafx.scene.input.KeyCode) Color(javafx.scene.paint.Color) Node(javafx.scene.Node) Rectangle(javafx.scene.shape.Rectangle) KeyEvent(javafx.scene.input.KeyEvent) Group(javafx.scene.Group) InvalidationListener(javafx.beans.InvalidationListener) Application(javafx.application.Application) ScrollPane(javafx.scene.control.ScrollPane) Stage(javafx.stage.Stage) Scale(javafx.scene.transform.Scale) Pane(javafx.scene.layout.Pane) KeyEvent(javafx.scene.input.KeyEvent) Group(javafx.scene.Group) ScrollPane(javafx.scene.control.ScrollPane) Node(javafx.scene.Node) Rectangle(javafx.scene.shape.Rectangle) InvalidationListener(javafx.beans.InvalidationListener) Scale(javafx.scene.transform.Scale) Scene(javafx.scene.Scene) ScrollPane(javafx.scene.control.ScrollPane) Pane(javafx.scene.layout.Pane)

Example 48 with ScrollPane

use of javafx.scene.control.ScrollPane in project narchy by automenta.

the class RDPCV method createScrollPane.

/**
 * @return a ScrollPane which scrolls the layout.
 */
private ScrollPane createScrollPane(Pane layout) {
    ScrollPane scroll = new ScrollPane();
    scroll.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    scroll.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    scroll.setPannable(true);
    scroll.setPrefSize(800, 600);
    scroll.setContent(layout);
    return scroll;
}
Also used : ScrollPane(javafx.scene.control.ScrollPane)

Example 49 with ScrollPane

use of javafx.scene.control.ScrollPane in project S4T1TM2 by CSUS-CSC-131-Spring2018.

the class YaamDemo method constructInnerContent.

private void constructInnerContent() {
    innerContent = new ScrollPane();
    innerContent.setId("innerContent");
    innerContent.layoutXProperty().bind(sidebar.widthProperty());
    innerContent.layoutYProperty().bind(brandName.heightProperty());
    innerContent.prefWidthProperty().bind(content.widthProperty().subtract(brandName.widthProperty()));
    innerContent.prefHeightProperty().bind(content.heightProperty().subtract(brandName.heightProperty()));
    content.getChildren().add(innerContent);
}
Also used : ScrollPane(javafx.scene.control.ScrollPane)

Example 50 with ScrollPane

use of javafx.scene.control.ScrollPane in project bisq-desktop by bisq-network.

the class TakeOfferView method addScrollPane.

// /////////////////////////////////////////////////////////////////////////////////////////
// Build UI elements
// /////////////////////////////////////////////////////////////////////////////////////////
private void addScrollPane() {
    scrollPane = new ScrollPane();
    scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
    scrollPane.setFitToWidth(true);
    scrollPane.setFitToHeight(true);
    scrollPane.setOnScroll(e -> InputTextField.hideErrorMessageDisplay());
    AnchorPane.setLeftAnchor(scrollPane, 0d);
    AnchorPane.setTopAnchor(scrollPane, 0d);
    AnchorPane.setRightAnchor(scrollPane, 0d);
    AnchorPane.setBottomAnchor(scrollPane, 0d);
    root.getChildren().add(scrollPane);
}
Also used : ScrollPane(javafx.scene.control.ScrollPane)

Aggregations

ScrollPane (javafx.scene.control.ScrollPane)71 VBox (javafx.scene.layout.VBox)18 Text (javafx.scene.text.Text)15 Scene (javafx.scene.Scene)14 Label (javafx.scene.control.Label)13 Insets (javafx.geometry.Insets)11 Button (javafx.scene.control.Button)11 BorderPane (javafx.scene.layout.BorderPane)11 HBox (javafx.scene.layout.HBox)10 GridPane (javafx.scene.layout.GridPane)9 TextFlow (javafx.scene.text.TextFlow)8 FXCollections (javafx.collections.FXCollections)7 Node (javafx.scene.Node)7 TextArea (javafx.scene.control.TextArea)7 javafx.scene.layout (javafx.scene.layout)7 Pane (javafx.scene.layout.Pane)7 InvalidationListener (javafx.beans.InvalidationListener)6 Observable (javafx.beans.Observable)6 ObservableList (javafx.collections.ObservableList)6 Alert (javafx.scene.control.Alert)6