javafx.geometry.Side Java Examples

The following examples show how to use javafx.geometry.Side. 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: PreferencesFxView.java    From PreferencesFX with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void layoutParts() {
  // but always add the categoryController
  contentBox.getChildren().addAll(breadCrumbView, categoryController);
  VBox.setVgrow(categoryController, Priority.ALWAYS);

  if (!model.isOneCategoryLayout()) {
    preferencesPane.setDetailSide(Side.LEFT);
    preferencesPane.setDetailNode(navigationView);
    preferencesPane.setMasterNode(contentBox);
    setCenter(preferencesPane);
  } else {
    setCenter(new StackPane(contentBox));
  }
}
 
Example #2
Source File: FlatTab.java    From oim-fx with MIT License 6 votes vote down vote up
private void updateBottomLine() {
	if (Side.TOP == side) {
		borderPane.setTop(hBox);
		hBox.setMinHeight(bottomLineSize);
	} else if (Side.RIGHT == side) {
		borderPane.setRight(hBox);
		hBox.setMinWidth(bottomLineSize);
	} else if (Side.BOTTOM == side) {
		borderPane.setBottom(hBox);
		hBox.setMinHeight(bottomLineSize);
	} else if (Side.LEFT == side) {
		borderPane.setLeft(hBox);
		hBox.setMinWidth(bottomLineSize);
	} else {
		borderPane.setBottom(hBox);
		hBox.setMinHeight(bottomLineSize);
	}
}
 
Example #3
Source File: Tab.java    From oim-fx with MIT License 6 votes vote down vote up
public void setSide(Side side) {
	if (Side.TOP == side) {
		borderPane.setTop(hBox);
		hBox.setMinHeight(2);
	} else if (Side.RIGHT == side) {
		borderPane.setRight(hBox);
		hBox.setMinWidth(2);
	} else if (Side.BOTTOM == side) {
		borderPane.setBottom(hBox);
		hBox.setMinHeight(2);
	} else if (Side.LEFT == side) {
		borderPane.setLeft(hBox);
		hBox.setMinWidth(2);
	} else {
		borderPane.setBottom(hBox);
		hBox.setMinHeight(2);
	}
}
 
Example #4
Source File: WorkbenchTest.java    From WorkbenchFX with Apache License 2.0 6 votes vote down vote up
@Test
void showDrawerInputValidation() {
  robot.interact(() -> {
    // null check
    assertThrows(NullPointerException.class, () -> workbench.showDrawer(drawer, null, 0));
    assertThrows(NullPointerException.class, () -> workbench.showDrawer(null, Side.LEFT, 0));

    // Percentage range
    assertThrows(IllegalArgumentException.class,
        () -> workbench.showDrawer(drawer, Side.LEFT, Integer.MIN_VALUE));
    assertThrows(IllegalArgumentException.class,
        () -> workbench.showDrawer(drawer, Side.LEFT, -2));
    workbench.showDrawer(drawer, Side.LEFT, -1); // valid
    workbench.showDrawer(drawer, Side.LEFT, 0); // valid
    workbench.showDrawer(drawer, Side.LEFT, 1); // valid
    workbench.showDrawer(drawer, Side.LEFT, 100); // valid
    assertThrows(IllegalArgumentException.class,
        () -> workbench.showDrawer(drawer, Side.LEFT, 101));
    assertThrows(IllegalArgumentException.class,
        () -> workbench.showDrawer(drawer, Side.LEFT, Integer.MAX_VALUE));
  });
}
 
Example #5
Source File: LabeledHorizontalBarChart.java    From MyBox with Apache License 2.0 6 votes vote down vote up
public static LabeledHorizontalBarChart create(boolean displayCategoryAxis, ChartCoordinate chartCoordinate) {
    CategoryAxis categoryAxis = new CategoryAxis();
    categoryAxis.setSide(Side.LEFT);
    categoryAxis.setTickLabelsVisible(displayCategoryAxis);
    categoryAxis.setGapStartAndEnd(true);

    NumberAxis numberAxis = new NumberAxis();
    numberAxis.setSide(Side.TOP);
    switch (chartCoordinate) {
        case LogarithmicE:
            numberAxis.setTickLabelFormatter(new LogarithmicECoordinate());
            break;
        case Logarithmic10:
            numberAxis.setTickLabelFormatter(new Logarithmic10Coordinate());
            break;
        case SquareRoot:
            numberAxis.setTickLabelFormatter(new SquareRootCoordinate());
            break;
    }

    return new LabeledHorizontalBarChart(numberAxis, categoryAxis)
            .setChartCoordinate(chartCoordinate);
}
 
Example #6
Source File: WorkbenchTest.java    From WorkbenchFX with Apache License 2.0 6 votes vote down vote up
@Test
void hideDrawerGlassPaneClick() {
  robot.interact(() -> {
    // given
    assertTrue(workbench.getBlockingOverlaysShown().isEmpty());
    assertTrue(workbench.getNonBlockingOverlaysShown().isEmpty());
    assertNull(workbench.getDrawerShown());
    workbench.showDrawer(drawer, Side.LEFT);

    // when:
    simulateGlassPaneClick(drawer);

    // then: drawer is hidden
    assertTrue(workbench.getBlockingOverlaysShown().isEmpty());
    assertTrue(workbench.getNonBlockingOverlaysShown().isEmpty());
    assertNull(workbench.getDrawerShown());
  });
}
 
Example #7
Source File: LabeledBarChart.java    From MyBox with Apache License 2.0 6 votes vote down vote up
public static LabeledBarChart create(boolean displayCategoryAxis, ChartCoordinate chartCoordinate) {
    CategoryAxis categoryAxis = new CategoryAxis();
    categoryAxis.setSide(Side.BOTTOM);
    categoryAxis.setTickLabelsVisible(displayCategoryAxis);
    categoryAxis.setGapStartAndEnd(true);

    NumberAxis numberAxis = new NumberAxis();
    numberAxis.setSide(Side.LEFT);
    switch (chartCoordinate) {
        case LogarithmicE:
            numberAxis.setTickLabelFormatter(new LogarithmicECoordinate());
            break;
        case Logarithmic10:
            numberAxis.setTickLabelFormatter(new Logarithmic10Coordinate());
            break;
        case SquareRoot:
            numberAxis.setTickLabelFormatter(new SquareRootCoordinate());
            break;
    }

    return new LabeledBarChart(categoryAxis, numberAxis)
            .setChartCoordinate(chartCoordinate);
}
 
Example #8
Source File: DemoTabPane.java    From bootstrapfx with MIT License 6 votes vote down vote up
private DemoTab(String title, String sourceFile) throws Exception {
    super(title);
    setClosable(false);

    TabPane content = new TabPane();
    setContent(content);
    content.setSide(Side.BOTTOM);

    Tab widgets = new Tab("Widgets");
    widgets.setClosable(false);
    URL location = getClass().getResource(sourceFile);
    FXMLLoader fxmlLoader = new FXMLLoader(location);
    Node node = fxmlLoader.load();
    widgets.setContent(node);

    Tab source = new Tab("Source");
    source.setClosable(false);
    XMLEditor editor = new XMLEditor();
    editor.setEditable(false);

    String text = IOUtils.toString(getClass().getResourceAsStream(sourceFile));
    editor.setText(text);
    source.setContent(editor);

    content.getTabs().addAll(widgets, source);
}
 
Example #9
Source File: AdvancedScatterChartSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
protected ScatterChart<Number, Number> createChart() {
    final NumberAxis xAxis = new NumberAxis();
    xAxis.setSide(Side.TOP);
    final NumberAxis yAxis = new NumberAxis();
    yAxis.setSide(Side.RIGHT);
    final ScatterChart<Number,Number> sc = new ScatterChart<Number,Number>(xAxis,yAxis);
    // setup chart
    xAxis.setLabel("X Axis");
    yAxis.setLabel("Y Axis");
    // add starting data
    for (int s=0;s<5;s++) {
        XYChart.Series<Number, Number> series = new XYChart.Series<Number, Number>();
        series.setName("Data Series "+s);
        for (int i=0; i<30; i++) series.getData().add(new XYChart.Data<Number, Number>(Math.random()*98, Math.random()*98));
        sc.getData().add(series);
    }
    return sc;
}
 
Example #10
Source File: ContextMenuStage.java    From oim-fx with MIT License 6 votes vote down vote up
private void init() {
	this.setCenter(rootPane);
	this.setTitle("组件测试");
	this.setWidth(380);
	this.setHeight(600);
	this.setRadius(10);
	

	VBox topBox = new VBox();
	topBox.setPrefHeight(50);
	
	HBox hBox=new HBox();
	hBox.getChildren().add(button);
	
	rootPane.setTop(topBox);
	rootPane.setBottom(hBox);
	
	button.setOnAction(a->{
		menu.show(button, Side.TOP, button.getLayoutX(), button.getLayoutY());
	});
}
 
Example #11
Source File: NodeTreeCell.java    From jmonkeybuilder with Apache License 2.0 6 votes vote down vote up
/**
 * Handle a mouse click.
 */
@FxThread
private void processClick(@NotNull final MouseEvent event) {

    final TreeNode<?> item = getItem();
    if (item == null) {
        return;
    }

    final MouseButton button = event.getButton();
    if (button != MouseButton.SECONDARY) {
        return;
    }

    final M nodeTree = getNodeTree();
    final ContextMenu contextMenu = nodeTree.getContextMenu(item);
    if (contextMenu == null) {
        return;
    }

    EXECUTOR_MANAGER.addFxTask(() -> contextMenu.show(this, Side.BOTTOM, 0, 0));
}
 
Example #12
Source File: ChartAdvancedScatter.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected ScatterChart<Number, Number> createChart() {
    final NumberAxis xAxis = new NumberAxis();
    xAxis.setSide(Side.TOP);
    final NumberAxis yAxis = new NumberAxis();
    yAxis.setSide(Side.RIGHT);
    final ScatterChart<Number,Number> sc = new ScatterChart<Number,Number>(xAxis,yAxis);
    // setup chart
    xAxis.setLabel("X Axis");
    yAxis.setLabel("Y Axis");
    // add starting data
    for (int s=0;s<5;s++) {
        XYChart.Series<Number, Number> series = new XYChart.Series<Number, Number>();
        series.setName("Data Series "+s);
        for (int i=0; i<30; i++) series.getData().add(new XYChart.Data<Number, Number>(Math.random()*98, Math.random()*98));
        sc.getData().add(series);
    }
    return sc;
}
 
Example #13
Source File: FlatTabPane.java    From oim-fx with MIT License 6 votes vote down vote up
public void selected(int index) {
	Node node = null;
	if (Side.TOP == side) {
		node = hBox.getChildren().get(index);
	} else if (Side.RIGHT == side) {
		node = vBox.getChildren().get(index);
	} else if (Side.BOTTOM == side) {
		node = hBox.getChildren().get(index);
	} else if (Side.LEFT == side) {
		node = vBox.getChildren().get(index);
	} else {
		node = hBox.getChildren().get(index);
	}
	if (node instanceof FlatTab) {
		FlatTab tabTemp = (FlatTab) node;
		selected(tabTemp);
	}
}
 
Example #14
Source File: DownArrowMenu.java    From arma-dialog-creator with MIT License 6 votes vote down vote up
public DownArrowMenu(@NotNull Image arrowImg, @NotNull MenuItem... items) {
	ImageView img = new ImageView(arrowImg);
	img.setOnMouseEntered(new EventHandler<MouseEvent>() {
		@Override
		public void handle(MouseEvent event) {
			if (popupMenu.isShowing()) {
				return;
			}
			popupMenu.show(DownArrowMenu.this, Side.BOTTOM, 0, 0);
		}
	});
	popupMenu.setAutoHide(true);
	getItems().addAll(items);

	setAlignment(Pos.CENTER_LEFT);
	getChildren().add(img);
}
 
Example #15
Source File: MediaService.java    From gluon-samples with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public MediaService() {
    
    MobileApplication.getInstance().addLayerFactory(POPUP_NAME, () -> {
        imageView = new ImageView();
        imageView.setFitHeight(50);
        imageView.setPreserveRatio(true);
        HBox adsBox = new HBox(imageView);
        adsBox.getStyleClass().add("mediaBox");
        return new SidePopupView(adsBox, Side.BOTTOM, false);
    });
    
    Services.get(LifecycleService.class).ifPresent(service -> {
        service.addListener(LifecycleEvent.PAUSE, this::stopExecutor);
        service.addListener(LifecycleEvent.RESUME, this::startExecutor);
    });
    startExecutor();
}
 
Example #16
Source File: ScriptingAspectEditor.java    From milkman with MIT License 6 votes vote down vote up
@Override
@SneakyThrows
public Tab getRoot(RequestContainer request) {
	val script = request.getAspect(ScriptingAspect.class).get();

	Tab preTab = getTab(script::getPreRequestScript, script::setPreRequestScript, "Before Request");
	Tab postTab = getTab(script::getPostRequestScript, script::setPostRequestScript, "After Request");
	TabPane tabs = new TabPane(preTab, postTab);
	tabs.getSelectionModel().select(1); //default to show after request script

	tabs.setSide(Side.LEFT);
	tabs.getStyleClass().add("options-tabs");
	tabs.tabMinWidthProperty().setValue(20);
	tabs.tabMaxWidthProperty().setValue(20);
	tabs.tabMinHeightProperty().setValue(150);
	tabs.tabMaxHeightProperty().setValue(150);
	tabs.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE);


	return new Tab("Scripting", tabs);
}
 
Example #17
Source File: SwordController.java    From Sword_emulator with GNU General Public License v3.0 6 votes vote down vote up
public void onViewMemory(Event event) {
//        if (memoryStage == null) {
//            memoryStage = FxUtils.newStage(null, "内存查看",
//                    "memory.fxml", "main.css");
//        }
//        memoryStage.show();
//        memoryStage.toFront();
        if (machine.getRomFile() == null) {
            onViewRAM(event);
        } else {
            MenuItem ramViewItem = new MenuItem("查看RAM");
            ramViewItem.setOnAction(event1 -> onViewRAM(event1));
            MenuItem romViewItem = new MenuItem("查看ROM");
            romViewItem.setOnAction(event1 -> onViewROM(event1));
            new ContextMenu(ramViewItem, romViewItem).show(memoryButton, Side.TOP, 0, 0);
        }

    }
 
Example #18
Source File: DefaultConnectorTypes.java    From graph-editor with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Gets the side corresponding to the given connector type.
 * 
 * @param type a non-null connector type
 * @return the {@link Side} the connector type is on
 */
public static Side getSide(final String type) {

    if (isTop(type)) {
        return Side.TOP;
    } else if (isRight(type)) {
        return Side.RIGHT;
    } else if (isBottom(type)) {
        return Side.BOTTOM;
    } else if (isLeft(type)) {
        return Side.LEFT;
    } else {
        return null;
    }
}
 
Example #19
Source File: ParetoChartController.java    From OEE-Designer with MIT License 5 votes vote down vote up
private LineChart<String, Number> createLineChart(String categoryLabel) {
	// X-Axis category (not shown)
	CategoryAxis xAxis = new CategoryAxis();
	xAxis.setLabel(categoryLabel);
	xAxis.setOpacity(0);

	// Y-Axis (%)
	NumberAxis yAxis = new NumberAxis(0, 100, 10);
	yAxis.setLabel(DesignerLocalizer.instance().getLangString("cum.percent"));
	yAxis.setSide(Side.RIGHT);
	yAxis.setAutoRanging(false);
	yAxis.setUpperBound(100.0d);
	yAxis.setLowerBound(0.0d);

	// create the line chart
	LineChart<String, Number> chLineChart = new LineChart<>(xAxis, yAxis);
	chLineChart.setTitle(chartTitle);
	chLineChart.setLegendVisible(false);
	chLineChart.setAnimated(false);
	chLineChart.setCreateSymbols(true);
	chLineChart.getData().add(lineChartSeries);

	// plot the points
	double total = totalCount.doubleValue();
	Float cumulative = new Float(0f);

	for (ParetoItem paretoItem : this.paretoItems) {
		cumulative += new Float(paretoItem.getValue().floatValue() / total * 100.0f);
		XYChart.Data<String, Number> point = new XYChart.Data<>(paretoItem.getCategory(), cumulative);
		lineChartSeries.getData().add(point);
	}

	return chLineChart;
}
 
Example #20
Source File: TabsRepresentation.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
/** Force TabPane refresh */
private void refreshHack()
{
    // Imperfect; works most of the time.
    // See org.csstudio.display.builder.representation.javafx.sandbox.TabDemo
    // for the setSide hack.
    // In addition, if TabPane is the _only_ widget, it will not show
    // unless the background style is initially set to something.
    // OK to then clear the style later, i.e. in here.
    final Runnable twiddle = () ->
    {
        // Called with delay, may happen after disposal
        if (jfx_node == null)
            return;
        jfx_node.setStyle("");
        jfx_node.setSide(Side.BOTTOM);
        if (model_widget.propDirection().getValue() == Direction.HORIZONTAL)
            jfx_node.setSide(Side.TOP);
        else
            jfx_node.setSide(Side.LEFT);

        // Insets computation only possible once TabPane is properly displayed.
        // Until then, content Pane will report position as 0,0.
        toolkit.schedule(this::computeInsets, 500, TimeUnit.MILLISECONDS);
    };
    toolkit.schedule(twiddle, 500, TimeUnit.MILLISECONDS);
}
 
Example #21
Source File: BlurbGroupsPanel.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public BlurbGroupsPanel(GroupType type) {
    DOCK_KEY = new DockKey(type.dockName(), type.dockName(), type.dockDescription(), type.dockIcon(), TabPolicy.Closable,
            Side.LEFT);
    Node text = new Text(type.dockName() + " Available only in MarathonITE");
    StackPane sp = new StackPane(text);
    node = sp;
}
 
Example #22
Source File: ReportsController.java    From HealthPlus with Apache License 2.0 5 votes vote down vote up
@FXML public void fillSupplierChart() {
    
    supplierchart.setVisible(true);
    
    HashMap<String,String> supplierNames = admin.getSupplierNames();
    
    ArrayList<ArrayList<String>> suppliers = admin.getSupplierSummary();
    int noOfSuppliers = suppliers.get(0).size();
    
    ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList();
    for (int i = 0; i < noOfSuppliers; i++)
    {
        String supplierID = suppliers.get(0).get(i);
        int stocks = Integer.parseInt(suppliers.get(1).get(i));
        pieChartData.add(new PieChart.Data(supplierNames.get(supplierID), stocks));
    }
    //piechart.setLabelLineLength(20);
    
    pieChartData.forEach(data ->
            data.nameProperty().bind(
                    Bindings.concat(
                            data.getName(), " (", data.pieValueProperty(), ")"
                    )
            )
    );
    
    
    supplierchart.setLegendSide(Side.BOTTOM); 
    supplierchart.setLabelsVisible(true);
    supplierchart.setData(pieChartData);

}
 
Example #23
Source File: SmoothedChart.java    From OEE-Designer with MIT License 5 votes vote down vote up
public void setXAxisBorderColor(final Paint FILL) {
    if (Side.BOTTOM == getXAxis().getSide()) {
        getXAxis().setBorder(new Border(
            new BorderStroke(FILL, Color.TRANSPARENT, Color.TRANSPARENT, Color.TRANSPARENT, BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID,
                             BorderStrokeStyle.SOLID, CornerRadii.EMPTY, BorderStroke.DEFAULT_WIDTHS, Insets.EMPTY)));
    } else {
        getXAxis().setBorder(new Border(
            new BorderStroke(Color.TRANSPARENT, Color.TRANSPARENT, FILL, Color.TRANSPARENT, BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID,
                             BorderStrokeStyle.SOLID, CornerRadii.EMPTY, BorderStroke.DEFAULT_WIDTHS, Insets.EMPTY)));
    }
}
 
Example #24
Source File: Toast.java    From DevToolBox with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void show(Node anchor, Side side, double offsetX, double offsetY) {
    if (anchor == null) {
        return;
    }
    autoCenter = false;

    HPos hpos = side == Side.LEFT ? HPos.LEFT : side == Side.RIGHT ? HPos.RIGHT : HPos.CENTER;
    VPos vpos = side == Side.TOP ? VPos.TOP : side == Side.BOTTOM ? VPos.BOTTOM : VPos.CENTER;
    // translate from anchor/hpos/vpos/offsetX/offsetY into screenX/screenY
    Point2D point = Utils.pointRelativeTo(anchor, content.prefWidth(-1), content.prefHeight(-1), hpos, vpos, offsetX, offsetY, true);
    this.show(anchor, point.getX(), point.getY());
}
 
Example #25
Source File: LabeledHorizontalBarChart.java    From MyBox with Apache License 2.0 5 votes vote down vote up
private void init() {
        labelType = LabelType.NameAndValue;
//        this.setBarGap(0.0);
//        this.setCategoryGap(2);
        this.setLegendSide(Side.TOP);
        this.setMaxWidth(Double.MAX_VALUE);
        this.setMaxHeight(Double.MAX_VALUE);
        VBox.setVgrow(this, Priority.ALWAYS);
        HBox.setHgrow(this, Priority.ALWAYS);

    }
 
Example #26
Source File: NavigationDrawerSkin.java    From WorkbenchFX with Apache License 2.0 5 votes vote down vote up
private MenuButton buildSubmenu(MenuItem item) {
  Menu menu = (Menu) item;
  MenuButton menuButton = new MenuButton();
  menuButton.setPopupSide(Side.RIGHT);
  menuButton.graphicProperty().bind(menu.graphicProperty());
  menuButton.textProperty().bind(menu.textProperty());
  menuButton.disableProperty().bind(menu.disableProperty());
  menuButton.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
  menuButton.getStyleClass().addAll(item.getStyleClass());
  Bindings.bindContent(menuButton.getItems(), menu.getItems());

  // To determine if a TOUCH_RELEASED event happens.
  // The MOUSE_ENTERED results in an unexpected behaviour on touch events.
  // Event filter triggers before the handler.
  menuButton.addEventFilter(TouchEvent.TOUCH_RELEASED, e -> isTouchUsed = true);

  // Only when ALWAYS or SOMETIMES
  if (!Priority.NEVER.equals(getSkinnable().getMenuHoverBehavior())) {
    menuButton.addEventHandler(MouseEvent.MOUSE_ENTERED, e -> { // Triggers on hovering over Menu
      if (isTouchUsed) {
        isTouchUsed = false;
        return;
      }
      // When ALWAYS, then trigger immediately. Else check if clicked before (case: SOMETIMES)
      if (Priority.ALWAYS.equals(getSkinnable().getMenuHoverBehavior())
          || (hoveredBtn != null && hoveredBtn.isShowing())) {
        menuButton.show(); // Shows the context-menu
        if (hoveredBtn != null && hoveredBtn != menuButton) {
          hoveredBtn.hide(); // Hides the previously hovered Button if not null and not self
        }
      }
      hoveredBtn = menuButton; // Add the button as previously hovered
    });
  }
  return menuButton;
}
 
Example #27
Source File: LRInspectorController.java    From megan-ce with GNU General Public License v3.0 5 votes vote down vote up
/**
 * create a horizontal axis
 *
 * @param maxReadLength
 * @return axis
 */
private static Pane createAxis(final ReadOnlyIntegerProperty maxReadLength, final ReadOnlyDoubleProperty widthProperty) {
    final Pane pane = new Pane();
    pane.prefWidthProperty().bind(widthProperty);

    final NumberAxis axis = new NumberAxis();
    axis.setSide(Side.TOP);
    axis.setAutoRanging(false);
    axis.setLowerBound(0);
    axis.prefHeightProperty().set(20);
    axis.prefWidthProperty().bind(widthProperty.subtract(60));
    axis.setTickLabelFont(Font.font("Arial", 10));

    final ChangeListener<Number> changeListener = (observable, oldValue, newValue) -> {
        int minX = Math.round(maxReadLength.get() / 2000.0f); // at most 2000 major ticks
        for (int x = 10; x < 10000000; x *= 10) {
            if (x >= minX && widthProperty.doubleValue() * x >= 50 * maxReadLength.doubleValue()) {
                axis.setUpperBound(maxReadLength.get());
                axis.setTickUnit(x);
                return;
            }
        }
        axis.setTickUnit(maxReadLength.get());
        axis.setUpperBound(maxReadLength.get());
    };

    maxReadLength.addListener(changeListener);
    widthProperty.addListener(changeListener);

    pane.getChildren().add(axis);
    return pane;
}
 
Example #28
Source File: DefaultSkinController.java    From graph-editor with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Counts the number of connectors the given node currently has of the given type.
 *
 * @param node a {@link GNode} instance
 * @param side the {@link Side} the connector is on
 * @return the number of connectors this node has on the given side
 */
private int countConnectors(final GNode node, final Side side) {

    int count = 0;

    for (final GConnector connector : node.getConnectors()) {
        if (side.equals(DefaultConnectorTypes.getSide(connector.getType()))) {
            count++;
        }
    }

    return count;
}
 
Example #29
Source File: CustomNavigationDrawerSkin.java    From WorkbenchFX with Apache License 2.0 5 votes vote down vote up
private MenuButton buildSubmenu(MenuItem item) {
  Menu menu = (Menu) item;
  MenuButton menuButton = new MenuButton();
  menuButton.setPopupSide(Side.RIGHT);
  menuButton.graphicProperty().bind(menu.graphicProperty());
  menuButton.textProperty().bind(menu.textProperty());
  menuButton.disableProperty().bind(menu.disableProperty());
  menuButton.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
  menuButton.getStyleClass().addAll(item.getStyleClass());
  Bindings.bindContent(menuButton.getItems(), menu.getItems());

  // To determine if a TOUCH_RELEASED event happens.
  // The MOUSE_ENTERED results in an unexpected behaviour on touch events.
  // Event filter triggers before the handler.
  menuButton.addEventFilter(TouchEvent.TOUCH_RELEASED, e -> isTouchUsed = true);

  // Only when ALWAYS or SOMETIMES
  if (!Priority.NEVER.equals(getSkinnable().getMenuHoverBehavior())) {
    menuButton.addEventHandler(MouseEvent.MOUSE_ENTERED, e -> { // Triggers on hovering over Menu
      if (isTouchUsed) {
        isTouchUsed = false;
        return;
      }
      // When ALWAYS, then trigger immediately. Else check if clicked before (case: SOMETIMES)
      if (Priority.ALWAYS.equals(getSkinnable().getMenuHoverBehavior())
          || (hoveredBtn != null && hoveredBtn.isShowing())) {
        menuButton.show(); // Shows the context-menu
        if (hoveredBtn != null && hoveredBtn != menuButton) {
          hoveredBtn.hide(); // Hides the previously hovered Button if not null and not self
        }
      }
      hoveredBtn = menuButton; // Add the button as previously hovered
    });
  }
  return menuButton;
}
 
Example #30
Source File: DrawerTestModule.java    From WorkbenchFX with Apache License 2.0 5 votes vote down vote up
private void setupEventHandlers() {
  // Map
  MapDrawer drawer = new MapDrawer();
  leftBtn.setOnAction(event -> {
    getWorkbench().showDrawer(drawer, Side.LEFT);
  });
  rightBtn.setOnAction(event -> getWorkbench().showDrawer(new MapDrawer(), Side.RIGHT));
  topBtn.setOnAction(event -> getWorkbench().showDrawer(new MapDrawer(), Side.TOP));
  bottomBtn.setOnAction(event -> getWorkbench().showDrawer(new MapDrawer(), Side.BOTTOM));

  leftPercentBtn.setOnAction(event -> getWorkbench().showDrawer(new MapDrawer(), Side.LEFT, 33));
  rightPercentBtn.setOnAction(
      event -> getWorkbench().showDrawer(new MapDrawer(), Side.RIGHT, 33));
  topPercentBtn.setOnAction(event -> getWorkbench().showDrawer(new MapDrawer(), Side.TOP, 33));
  bottomPercentBtn.setOnAction(
      event -> getWorkbench().showDrawer(new MapDrawer(), Side.BOTTOM, 33));

  // Calendar
  calendarLeftBtn.setOnAction(
      event -> getWorkbench().showDrawer(new CalendarDrawer(getWorkbench()), Side.LEFT));
  calendarRightBtn.setOnAction(
      event -> getWorkbench().showDrawer(new CalendarDrawer(getWorkbench()), Side.RIGHT));
  calendarTopBtn.setOnAction(
      event -> getWorkbench().showDrawer(new CalendarDrawer(getWorkbench()), Side.TOP));
  calendarBottomBtn.setOnAction(
      event -> getWorkbench().showDrawer(new CalendarDrawer(getWorkbench()), Side.BOTTOM));

  calendarLeftPercentBtn.setOnAction(
      event -> getWorkbench().showDrawer(new CalendarDrawer(getWorkbench()), Side.LEFT, 33));
  calendarRightPercentBtn.setOnAction(
      event -> getWorkbench().showDrawer(new CalendarDrawer(getWorkbench()), Side.RIGHT, 33));
  calendarTopPercentBtn.setOnAction(
      event -> getWorkbench().showDrawer(new CalendarDrawer(getWorkbench()), Side.TOP, 33));
  calendarBottomPercentBtn.setOnAction(
      event -> getWorkbench().showDrawer(new CalendarDrawer(getWorkbench()), Side.BOTTOM, 33));
}