javafx.scene.control.ScrollPane.ScrollBarPolicy Java Examples

The following examples show how to use javafx.scene.control.ScrollPane.ScrollBarPolicy. 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: NewsPanel.java    From pdfsam with GNU Affero General Public License v3.0 6 votes vote down vote up
public NewsPanel() {
    getStyleClass().add("news-panel");
    getStyleClass().addAll(Style.CONTAINER.css());
    Button closeButton = FontAwesomeIconFactory.get().createIconButton(FontAwesomeIcon.TIMES);
    closeButton.getStyleClass().addAll("close-button");
    closeButton.setOnAction(e -> eventStudio().broadcast(HideNewsPanelRequest.INSTANCE));
    Label titleLabel = new Label(DefaultI18nContext.getInstance().i18n("What's new"));
    titleLabel.setPrefWidth(Integer.MAX_VALUE);
    titleLabel.getStyleClass().add("news-panel-title");

    StackPane top = new StackPane(titleLabel, closeButton);
    top.setAlignment(Pos.TOP_RIGHT);

    scroll.getStyleClass().add("scrollable-news");
    scroll.setHbarPolicy(ScrollBarPolicy.NEVER);
    scroll.setFitToHeight(true);
    scroll.setFitToWidth(true);
    getChildren().addAll(top, scroll);

    eventStudio().addAnnotatedListeners(this);
}
 
Example #2
Source File: WorkArea.java    From pdfsam with GNU Affero General Public License v3.0 6 votes vote down vote up
@Inject
public WorkArea(List<Module> modules, QuickbarModuleButtonsPane modulesButtons) {
    getStyleClass().addAll(Style.CONTAINER.css());
    setId("work-area");
    for (Module module : modules) {
        this.modules.put(module.id(), module);
    }
    fade.setFromValue(0);
    fade.setToValue(1);
    center.setHbarPolicy(ScrollBarPolicy.NEVER);
    center.setFitToWidth(true);
    center.setFitToHeight(true);
    setCenter(center);
    setLeft(new QuickbarPane(modulesButtons));
    eventStudio().addAnnotatedListeners(this);
}
 
Example #3
Source File: ContentEditor.java    From milkman with MIT License 6 votes vote down vote up
public ContentEditor() {
	getStyleClass().add("contentEditor");

	setupHeader();
	setupCodeArea();
	setupSearch();

	StackPane.setAlignment(search, Pos.TOP_RIGHT);
	// bug: scrollPane has some issue if it is rendered within a tab that
	// is not yet shown with content that needs a scrollbar
	// this leads to e.g. tabs not being updated, if triggered programmatically
	// switching to ALWAYS for scrollbars fixes this issue
	scrollPane = new VirtualizedScrollPane(codeArea, ScrollBarPolicy.ALWAYS,
			ScrollBarPolicy.ALWAYS);

	StackPane contentPane = new StackPane(scrollPane, search);
	VBox.setVgrow(contentPane, Priority.ALWAYS);

	getChildren().add(contentPane);
}
 
Example #4
Source File: CommentBoxVBoxer.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
private Node createTextArea(boolean selectable, boolean editable) {
    textArea = new TextArea();
    textArea.setPrefRowCount(4);
    textArea.setEditable(editable);
    textArea.textProperty().addListener((observable, oldValue, newValue) -> {
        item.setText(textArea.getText());
    });
    textArea.setText(item.getText());
    ScrollPane scrollPane = new ScrollPane(textArea);
    scrollPane.setFitToWidth(true);
    scrollPane.setFitToHeight(true);
    scrollPane.setHbarPolicy(ScrollBarPolicy.NEVER);
    scrollPane.setVbarPolicy(ScrollBarPolicy.ALWAYS);
    HBox.setHgrow(scrollPane, Priority.ALWAYS);
    return scrollPane;
}
 
Example #5
Source File: SessionViewerController.java    From ShootOFF with GNU General Public License v3.0 6 votes vote down vote up
private void updateCameraTabs() {
	cameraTabPane.getTabs().clear();
	cameraGroups.clear();
	eventSelectionsPerTab.clear();

	for (final String cameraName : currentSession.getEvents().keySet()) {
		final Group canvas = new Group();
		final ScrollPane scrollPane = new ScrollPane(canvas);
		scrollPane.setPrefSize(cameraTabPane.getPrefWidth(), cameraTabPane.getPrefHeight());
		scrollPane.setHbarPolicy(ScrollBarPolicy.AS_NEEDED);
		scrollPane.setVbarPolicy(ScrollBarPolicy.AS_NEEDED);
		cameraGroups.put(cameraName, new SessionCanvasManager(canvas, config));

		final Tab cameraTab = new Tab(cameraName);
		cameraTab.setContent(scrollPane);
		cameraTabPane.getTabs().add(cameraTab);
	}
}
 
Example #6
Source File: DashboardItemPane.java    From pdfsam with GNU Affero General Public License v3.0 5 votes vote down vote up
DashboardItemPane(DashboardItem item) {
    requireNotNullArg(item, "Dashboard item cannot be null");
    this.item = item;
    this.item.pane().getStyleClass().addAll(Style.DEAULT_CONTAINER.css());
    this.item.pane().getStyleClass().addAll(Style.CONTAINER.css());
    ScrollPane scroll = new ScrollPane(this.item.pane());
    scroll.getStyleClass().addAll(Style.DEAULT_CONTAINER.css());
    scroll.setFitToWidth(true);
    scroll.setHbarPolicy(ScrollBarPolicy.NEVER);
    scroll.setVbarPolicy(ScrollBarPolicy.AS_NEEDED);
    setCenter(scroll);
    eventStudio().add(SetActiveModuleRequest.class, enableFooterListener, Integer.MAX_VALUE,
            ReferenceStrength.STRONG);
}
 
Example #7
Source File: OnlyScrollPaneSkin.java    From oim-fx with MIT License 5 votes vote down vote up
/**
 * Computes the size that should be reserved for horizontal scrollbar in
 * size hints (min/pref height)
 */
private double computeHsbSizeHint(ScrollPane sp) {
	return ((sp.getHbarPolicy() == ScrollBarPolicy.ALWAYS) ||
			(sp.getHbarPolicy() == ScrollBarPolicy.AS_NEEDED && (sp.getPrefViewportHeight() > 0 || sp.getMinViewportHeight() > 0)))
					? hsb.prefHeight(ScrollBar.USE_COMPUTED_SIZE)
					: 0;
}
 
Example #8
Source File: OnlyScrollPaneSkin.java    From oim-fx with MIT License 5 votes vote down vote up
/**
 * Computes the size that should be reserved for vertical scrollbar in size
 * hints (min/pref width)
 */
private double computeVsbSizeHint(ScrollPane sp) {
	return ((sp.getVbarPolicy() == ScrollBarPolicy.ALWAYS) ||
			(sp.getVbarPolicy() == ScrollBarPolicy.AS_NEEDED && (sp.getPrefViewportWidth() > 0
					|| sp.getMinViewportWidth() > 0)))
							? vsb.prefWidth(ScrollBar.USE_COMPUTED_SIZE)
							: 0;
}
 
Example #9
Source File: OnlyScrollPaneSkin.java    From oim-fx with MIT License 5 votes vote down vote up
private boolean determineHorizontalSBVisible() {
	final ScrollPane sp = getSkinnable();

	if (IS_TOUCH_SUPPORTED) {
		return (tempVisibility && (nodeWidth > contentWidth));
	} else {
		// RT-17395: ScrollBarPolicy might be null. If so, treat it as
		// "AS_NEEDED", which is the default
		ScrollBarPolicy hbarPolicy = sp.getHbarPolicy();
		return (ScrollBarPolicy.NEVER == hbarPolicy) ? false
				: ((ScrollBarPolicy.ALWAYS == hbarPolicy) ? true : ((sp.isFitToWidth() && scrollNode != null ? scrollNode.isResizable() : false) ? (nodeWidth > contentWidth && scrollNode.minWidth(-1) > contentWidth) : (nodeWidth > contentWidth)));
	}
}
 
Example #10
Source File: OnlyScrollPaneSkin.java    From oim-fx with MIT License 5 votes vote down vote up
private boolean determineVerticalSBVisible() {
	final ScrollPane sp = getSkinnable();

	if (IS_TOUCH_SUPPORTED) {
		return (tempVisibility && (nodeHeight > contentHeight));
	} else {
		// RT-17395: ScrollBarPolicy might be null. If so, treat it as
		// "AS_NEEDED", which is the default
		ScrollBarPolicy vbarPolicy = sp.getVbarPolicy();
		return (ScrollBarPolicy.NEVER == vbarPolicy) ? false
				: ((ScrollBarPolicy.ALWAYS == vbarPolicy) ? true : ((sp.isFitToHeight() && scrollNode != null ? scrollNode.isResizable() : false) ? (nodeHeight > contentHeight && scrollNode.minHeight(-1) > contentHeight) : (nodeHeight > contentHeight)));
	}
}
 
Example #11
Source File: FunctionStage.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private void initComponents() {
    mainSplitPane.setDividerPositions(0.35);
    mainSplitPane.getItems().addAll(createTree(), functionSplitPane);

    expandAllBtn.setOnAction((e) -> expandAll());
    collapseAllBtn.setOnAction((e) -> collapseAll());
    refreshButton.setOnAction((e) -> refresh());
    topButtonBar.setId("topButtonBar");
    topButtonBar.setButtonMinWidth(Region.USE_PREF_SIZE);
    topButtonBar.getButtons().addAll(expandAllBtn, collapseAllBtn, refreshButton);

    functionSplitPane.setDividerPositions(0.4);
    functionSplitPane.setOrientation(Orientation.VERTICAL);
    documentArea = functionInfo.getEditorProvider().get(false, 0, IEditorProvider.EditorType.OTHER, false);
    Platform.runLater(() -> {
        documentArea.setEditable(false);
        documentArea.setMode("ruby");
    });

    argumentPane = new VBox();
    ScrollPane scrollPane = new ScrollPane(argumentPane);
    scrollPane.setHbarPolicy(ScrollBarPolicy.AS_NEEDED);
    scrollPane.setVbarPolicy(ScrollBarPolicy.AS_NEEDED);
    functionSplitPane.getItems().addAll(documentArea.getNode(), scrollPane);

    okButton.setOnAction(new OkHandler());
    okButton.setDisable(true);
    cancelButton.setOnAction((e) -> dispose());
    buttonBar.getButtons().addAll(okButton, cancelButton);
    buttonBar.setButtonMinWidth(Region.USE_PREF_SIZE);
}
 
Example #12
Source File: FailureNoteVBoxer.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private Node createTextArea(boolean selectable, boolean editable) {
    textArea.setPrefRowCount(4);
    textArea.setEditable(editable);
    textArea.textProperty().addListener((observable, oldValue, newValue) -> {
        item.setText(textArea.getText());
    });
    textArea.setText(item.getText());
    ScrollPane scrollPane = new ScrollPane(textArea);
    scrollPane.setFitToWidth(true);
    scrollPane.setHbarPolicy(ScrollBarPolicy.NEVER);
    scrollPane.setVbarPolicy(ScrollBarPolicy.ALWAYS);
    HBox.setHgrow(scrollPane, Priority.ALWAYS);
    return scrollPane;
}
 
Example #13
Source File: UI.java    From HubTurbo with GNU Lesser General Public License v3.0 5 votes vote down vote up
private Parent createRootNode() {

        VBox top = new VBox();

        panelsScrollPane = new ScrollPane(panels);
        panelsScrollPane.getStyleClass().add("transparent-bg");
        panelsScrollPane.setFitToHeight(true);
        panelsScrollPane.setVbarPolicy(ScrollBarPolicy.NEVER);
        HBox.setHgrow(panelsScrollPane, Priority.ALWAYS);
        menuBar = new MenuControl(this, panels, panelsScrollPane, prefs, mainStage);
        menuBar.setUseSystemMenuBar(true);

        HBox detailsBar = new HBox();
        detailsBar.setAlignment(Pos.CENTER_LEFT);
        apiBox.getStyleClass().add("text-grey");
        apiBox.setTooltip(new Tooltip("Remaining calls / Minutes to next refresh"));
        detailsBar.getChildren().add(apiBox);

        top.getChildren().addAll(menuBar, detailsBar);

        BorderPane root = new BorderPane();
        root.setTop(top);
        root.setCenter(panelsScrollPane);
        root.setBottom((HTStatusBar) status);

        notificationPane = new NotificationPane(root);

        return notificationPane;
    }
 
Example #14
Source File: BreakingNewsDemo.java    From htm.java-examples with GNU Affero General Public License v3.0 5 votes vote down vote up
public void configureView() {
    view = new BreakingNewsDemoView();
    view.autoModeProperty().addListener((v, o, n) -> { this.mode = n; });
    this.mode = view.autoModeProperty().get();
    view.startActionProperty().addListener((v, o, n) -> {
        if(n) {
            if(mode == Mode.AUTO) cursor++;
            start();
        }else{
            stop();
        }
    });
    view.runOneProperty().addListener((v, o, n) -> {
        this.cursor += n.intValue();
        runOne(jsonList.get(cursor), cursor);
    });
    view.flipStateProperty().addListener((v, o, n) -> {
        view.flipPaneProperty().get().flip();
    });

    view.setPrefSize(1370, 1160);
    view.setMinSize(1370, 1160);

    mainViewScroll  = new ScrollPane();
    mainViewScroll.setViewportBounds(new BoundingBox(0, 0, 1370, 1160));

    mainViewScroll.setHbarPolicy(ScrollBarPolicy.NEVER);
    mainViewScroll.setVbarPolicy(ScrollBarPolicy.AS_NEEDED);
    mainViewScroll.setContent(view);
    mainViewScroll.viewportBoundsProperty().addListener((v, o, n) -> {
        view.setPrefSize(Math.max(1370, n.getMaxX()), Math.max(1160, n.getMaxY()));//1370, 1160);
    });

    createDataStream();
    createAlgorithm();
}
 
Example #15
Source File: InfiniteCanvas.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void changed(
		ObservableValue<? extends ScrollBarPolicy> observable,
		ScrollBarPolicy oldValue, ScrollBarPolicy newValue) {
	updateScrollBars();
}
 
Example #16
Source File: InfiniteCanvas.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Updates the {@link ScrollBar}s' visibilities, value ranges and value
 * increments based on the {@link #computeContentBoundsInLocal() content
 * bounds} and the {@link #computeScrollableBoundsInLocal() scrollable
 * bounds}. The update is not done if any of the {@link ScrollBar}s is
 * currently in use.
 */
protected void updateScrollBars() {
	// do not update while a scrollbar is pressed, so that the scrollable
	// area does not change while using a scrollbar
	if (horizontalScrollBar.isPressed() || verticalScrollBar.isPressed()) {
		return;
	}

	// determine current content bounds
	double[] oldContentBounds = Arrays.copyOf(contentBounds,
			contentBounds.length);
	contentBounds = computeContentBoundsInLocal();
	if (!Arrays.equals(oldContentBounds, contentBounds)) {
		contentBoundsBinding.invalidate();
	}

	// show/hide horizontal scrollbar
	ScrollBarPolicy hbarPolicy = horizontalScrollBarPolicyProperty.get();
	boolean hbarIsNeeded = contentBounds[0] < -0.01
			|| contentBounds[2] > getWidth() + 0.01;
	if (hbarPolicy.equals(ScrollBarPolicy.ALWAYS)
			|| hbarPolicy.equals(ScrollBarPolicy.AS_NEEDED)
					&& hbarIsNeeded) {
		horizontalScrollBar.setVisible(true);
	} else {
		horizontalScrollBar.setVisible(false);
	}

	// show/hide vertical scrollbar
	ScrollBarPolicy vbarPolicy = verticalScrollBarPolicyProperty.get();
	boolean vbarIsNeeded = contentBounds[1] < -0.01
			|| contentBounds[3] > getHeight() + 0.01;
	if (vbarPolicy.equals(ScrollBarPolicy.ALWAYS)
			|| vbarPolicy.equals(ScrollBarPolicy.AS_NEEDED)
					&& vbarIsNeeded) {
		verticalScrollBar.setVisible(true);
	} else {
		verticalScrollBar.setVisible(false);
	}

	// determine current scrollable bounds
	double[] oldScrollableBounds = Arrays.copyOf(scrollableBounds,
			scrollableBounds.length);
	scrollableBounds = computeScrollableBoundsInLocal();
	if (!Arrays.equals(oldScrollableBounds, scrollableBounds)) {
		scrollableBoundsBinding.invalidate();
	}

	// update scrollbar ranges
	horizontalScrollBar.setMin(scrollableBounds[0]);
	horizontalScrollBar.setMax(scrollableBounds[2]);
	horizontalScrollBar.setVisibleAmount(getWidth());
	horizontalScrollBar.setBlockIncrement(getWidth() / 2);
	horizontalScrollBar.setUnitIncrement(getWidth() / 10);
	verticalScrollBar.setMin(scrollableBounds[1]);
	verticalScrollBar.setMax(scrollableBounds[3]);
	verticalScrollBar.setVisibleAmount(getHeight());
	verticalScrollBar.setBlockIncrement(getHeight() / 2);
	verticalScrollBar.setUnitIncrement(getHeight() / 10);

	// compute scrollbar values from canvas translation (in case the
	// scrollbar values are incorrect)
	// XXX: Remove scroll bar value listeners when adapting the values to
	// prevent infinite recursion.
	horizontalScrollBar.valueProperty()
			.removeListener(horizontalScrollBarValueChangeListener);
	verticalScrollBar.valueProperty()
			.removeListener(verticalScrollBarValueChangeListener);

	horizontalScrollBar
			.setValue(computeHv(getScrolledPane().getTranslateX()));
	verticalScrollBar
			.setValue(computeVv(getScrolledPane().getTranslateY()));

	horizontalScrollBar.valueProperty()
			.addListener(horizontalScrollBarValueChangeListener);
	verticalScrollBar.valueProperty()
			.addListener(verticalScrollBarValueChangeListener);
}
 
Example #17
Source File: Palette.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
/** Create UI elements
 *  @return Top-level Node of the UI
 */
@SuppressWarnings("unchecked")
public Node create()
{
    final VBox palette = new VBox();

    final Map<WidgetCategory, Pane> palette_groups = createWidgetCategoryPanes(palette);
    groups = palette_groups.values();
    createWidgetEntries(palette_groups);

    final ScrollPane palette_scroll = new ScrollPane(palette);
    palette_scroll.setHbarPolicy(ScrollBarPolicy.NEVER);
    palette_scroll.setFitToWidth(true);

    // TODO Determine the correct size for the main node
    // Using 2*PREFERRED_WIDTH was determined by trial and error
    palette_scroll.setMinWidth(PREFERRED_WIDTH + 12);
    palette_scroll.setPrefWidth(PREFERRED_WIDTH);

    // Copy the widgets, i.e. the children of each palette_group,
    // to the userData.
    // Actual children are now updated based on search by widget name
    palette_groups.values().forEach(group -> group.setUserData(new ArrayList<Node>(group.getChildren())));

    final TextField searchField = new ClearingTextField();
    searchField.setPromptText(Messages.SearchTextField);
    searchField.setTooltip(new Tooltip(Messages.WidgetFilterTT));
    searchField.setPrefColumnCount(9);
    searchField.textProperty().addListener( ( observable, oldValue, search_text ) ->
    {
        final String search = search_text.toLowerCase().trim();
        palette_groups.values().stream().forEach(group ->
        {
            group.getChildren().clear();
            final List<Node> all_widgets = (List<Node>)group.getUserData();
            if (search.isEmpty())
                group.getChildren().setAll(all_widgets);
            else
                group.getChildren().setAll(all_widgets.stream()
                                                      .filter(node ->
                                                      {
                                                         final String text = ((ToggleButton) node).getText().toLowerCase();
                                                         return text.contains(search);
                                                      })
                                                     .collect(Collectors.toList()));
        });
    });
    HBox.setHgrow(searchField, Priority.NEVER);

    final HBox toolsPane = new HBox(6);
    toolsPane.setAlignment(Pos.CENTER_RIGHT);
    toolsPane.setPadding(new Insets(6));
    toolsPane.getChildren().add(searchField);

    BorderPane paletteContainer = new BorderPane();
    paletteContainer.setTop(toolsPane);
    paletteContainer.setCenter(palette_scroll);

    return paletteContainer;
}
 
Example #18
Source File: EmbeddedDisplayRepresentation.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void updateChanges()
{
    // Late update after disposal?
    if (inner == null)
        return;
    super.updateChanges();
    if (dirty_sizes.checkAndClear())
    {
        final Integer width = model_widget.propWidth().getValue();
        final Integer height = model_widget.propHeight().getValue();
        scroll.setPrefSize(width, height);

        final Resize resize = model_widget.propResize().getValue();
        if (resize == Resize.None)
        {
            zoom.setX(1.0);
            zoom.setY(1.0);
            scroll.setHbarPolicy(ScrollBarPolicy.AS_NEEDED);
            scroll.setVbarPolicy(ScrollBarPolicy.AS_NEEDED);
        }
        else if (resize == Resize.Crop)
        {
            zoom.setX(1.0);
            zoom.setY(1.0);
            scroll.setHbarPolicy(ScrollBarPolicy.NEVER);
            scroll.setVbarPolicy(ScrollBarPolicy.NEVER);
        }
        else if (resize == Resize.ResizeContent  ||  resize == Resize.StretchContent )
        {
            zoom.setX(zoom_factor_x);
            zoom.setY(zoom_factor_y);
            scroll.setHbarPolicy(ScrollBarPolicy.NEVER);
            scroll.setVbarPolicy(ScrollBarPolicy.NEVER);
        }
        else // SizeToContent
        {
            zoom.setX(1.0);
            zoom.setY(1.0);
            scroll.setHbarPolicy(ScrollBarPolicy.NEVER);
            scroll.setVbarPolicy(ScrollBarPolicy.NEVER);
        }
    }
    if (dirty_background.checkAndClear())
        inner.setBackground(inner_background);
}
 
Example #19
Source File: SpectraIdentificationResultsWindowFX.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
public SpectraIdentificationResultsWindowFX() {
  super();

  pnMain = new BorderPane();
  this.setScene(new Scene(pnMain));
  getScene().getStylesheets()
      .addAll(MZmineCore.getDesktop().getMainWindow().getScene().getStylesheets());

  pnMain.setPrefSize(1000, 600);
  pnMain.setMinSize(700, 500);
  setMinWidth(700);
  setMinHeight(500);

  setTitle("Processing...");

  pnGrid = new GridPane();
  // any number of rows

  noMatchesFound = new Label("I'm working on it");
  noMatchesFound.setFont(headerFont);
  // yellow
  noMatchesFound.setTextFill(Color.web("0xFFCC00"));
  pnGrid.add(noMatchesFound, 0, 0);
  pnGrid.setVgap(5);

  // Add the Windows menu
  MenuBar menuBar = new MenuBar();
  // menuBar.add(new WindowsMenu());

  Menu menu = new Menu("Menu");

  // set font size of chart
  MenuItem btnSetup = new MenuItem("Setup dialog");
  btnSetup.setOnAction(e -> {
    Platform.runLater(() -> {
      if (MZmineCore.getConfiguration()
          .getModuleParameters(SpectraIdentificationResultsModule.class)
          .showSetupDialog(true) == ExitCode.OK) {
        showExportButtonsChanged();
      }
    });
  });

  menu.getItems().add(btnSetup);

  CheckMenuItem cbCoupleZoomY = new CheckMenuItem("Couple y-zoom");
  cbCoupleZoomY.setSelected(true);
  cbCoupleZoomY.setOnAction(e -> setCoupleZoomY(cbCoupleZoomY.isSelected()));
  menu.getItems().add(cbCoupleZoomY);

  menuBar.getMenus().add(menu);
  pnMain.setTop(menuBar);

  scrollPane = new ScrollPane(pnGrid);
  pnMain.setCenter(scrollPane);
  scrollPane.setHbarPolicy(ScrollBarPolicy.AS_NEEDED);
  scrollPane.setVbarPolicy(ScrollBarPolicy.AS_NEEDED);

  totalMatches = new ArrayList<>();
  matchPanels = new HashMap<>();
  setCoupleZoomY(true);

  show();
}
 
Example #20
Source File: JavaFxTopComponent.java    From constellation with Apache License 2.0 4 votes vote down vote up
@Override
protected final void initContent() {
    this.setLayout(new BorderLayout());
    this.setPreferredSize(new Dimension(500, 500));
    Platform.setImplicitExit(false);
    Platform.runLater(() -> {
        this.content = createContent();

        this.scrollPane = new ScrollPane(content);

        this.scene = new Scene(scrollPane);
        scene.getStylesheets().add(JavafxStyleManager.getMainStyleSheet());
        if (createStyle() != null) {
            scene.getStylesheets().add(getClass().getResource(createStyle()).toExternalForm());
        }

        scrollPane.setHbarPolicy(getHorizontalScrollPolicy());
        if (getHorizontalScrollPolicy() == ScrollBarPolicy.NEVER) {
            scrollPane.setFitToWidth(true);
        } else {
            scrollPane.viewportBoundsProperty().addListener((observable, oldValue, newValue) -> {
                // TODO: fix a bug where the width of the scroll can grow infinitely
                scrollPane.setFitToWidth(content.prefWidth(-1) <= newValue.getWidth());
            });
        }
        scrollPane.setVbarPolicy(getVerticalScrollPolicy());
        if (getVerticalScrollPolicy() == ScrollBarPolicy.NEVER) {
            scrollPane.setFitToHeight(true);
        } else {
            scrollPane.viewportBoundsProperty().addListener((observable, oldValue, newValue) -> {
                scrollPane.setFitToHeight(content.prefHeight(-1) <= newValue.getHeight());
            });
        }

        // set the font on initialise
        updateFont();

        jfxContainer.setScene(scene);
        jfxContainer.setBackground(Color.red);
        SwingUtilities.invokeLater(() -> {
            add(jfxContainer, BorderLayout.CENTER);
            validate();
        });
    });
}
 
Example #21
Source File: InfiniteCanvas.java    From gef with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Returns the {@link ScrollBarPolicy} that is currently used to decide when
 * to show a vertical scrollbar.
 *
 * @return The {@link ScrollBarPolicy} that is currently used to decide when
 *         to show a vertical scrollbar.
 */
public ScrollBarPolicy getVerticalScrollBarPolicy() {
	return verticalScrollBarPolicyProperty.get();
}
 
Example #22
Source File: InfiniteCanvas.java    From gef with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Returns the {@link ObjectProperty} that controls the
 * {@link ScrollBarPolicy} that decides when to show a horizontal scrollbar.
 *
 * @return The {@link ObjectProperty} that controls the
 *         {@link ScrollBarPolicy} that decides when to show a horizontal
 *         scrollbar.
 */
public ObjectProperty<ScrollBarPolicy> horizontalScrollBarPolicyProperty() {
	return horizontalScrollBarPolicyProperty;
}
 
Example #23
Source File: InfiniteCanvas.java    From gef with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Sets the value of the {@link #horizontalScrollBarPolicyProperty()} to the
 * given {@link ScrollBarPolicy}.
 *
 * @param horizontalScrollBarPolicy
 *            The new {@link ScrollBarPolicy} for the horizontal scrollbar.
 */
public void setHorizontalScrollBarPolicy(
		ScrollBarPolicy horizontalScrollBarPolicy) {
	horizontalScrollBarPolicyProperty.set(horizontalScrollBarPolicy);
}
 
Example #24
Source File: InfiniteCanvas.java    From gef with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Sets the value of the {@link #verticalScrollBarPolicyProperty()} to the
 * given {@link ScrollBarPolicy}.
 *
 * @param verticalScrollBarPolicy
 *            The new {@link ScrollBarPolicy} for the vertical scrollbar.
 */
public void setVerticalScrollBarPolicy(
		ScrollBarPolicy verticalScrollBarPolicy) {
	verticalScrollBarPolicyProperty.set(verticalScrollBarPolicy);
}
 
Example #25
Source File: InfiniteCanvas.java    From gef with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Returns the {@link ScrollBarPolicy} that is currently used to decide when
 * to show a horizontal scrollbar.
 *
 * @return The {@link ScrollBarPolicy} that is currently used to decide when
 *         to show a horizontal scrollbar.
 */
public ScrollBarPolicy getHorizontalScrollBarPolicy() {
	return horizontalScrollBarPolicyProperty.get();
}
 
Example #26
Source File: InfiniteCanvas.java    From gef with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Returns the {@link ObjectProperty} that controls the
 * {@link ScrollBarPolicy} that decides when to show a vertical scrollbar.
 *
 * @return The {@link ObjectProperty} that controls the
 *         {@link ScrollBarPolicy} that decides when to show a vertical
 *         scrollbar.
 */
public ObjectProperty<ScrollBarPolicy> verticalScrollBarPolicyProperty() {
	return verticalScrollBarPolicyProperty;
}
 
Example #27
Source File: JavaFxTopComponent.java    From constellation with Apache License 2.0 2 votes vote down vote up
/**
 * A JavaFxTopComponent will have a ScrollPane by default, as it cannot know
 * the expected layout of the given pane. If you wish to remove the
 * horizontal scroll bar, you can override this method to return
 * ScrollBarPolicy.NEVER.
 *
 * @return a {@link ScrollBarPolicy} representing the desired horizontal
 * scroll bar policy.
 */
protected ScrollBarPolicy getHorizontalScrollPolicy() {
    return ScrollBarPolicy.NEVER;
}
 
Example #28
Source File: JavaFxTopComponent.java    From constellation with Apache License 2.0 2 votes vote down vote up
/**
 * A JavaFxTopComponent will have a ScrollPane by default, as it cannot know
 * the expected layout of the given pane. If you wish to remove the vertical
 * scroll bar, you can override this method to return ScrollBarPolicy.NEVER.
 *
 * @return a {@link ScrollBarPolicy} representing the desired vertical
 * scroll bar policy.
 */
protected ScrollBarPolicy getVerticalScrollPolicy() {
    return ScrollBarPolicy.NEVER;
}