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; }
public TabSample() { BorderPane borderPane = new BorderPane(); final TabPane tabPane = new TabPane(); tabPane.setPrefSize(400, 400); tabPane.setSide(Side.TOP); tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE); final Tab tab1 = new Tab(); tab1.setText("Tab 1"); final Tab tab2 = new Tab(); tab2.setText("Tab 2"); final Tab tab3 = new Tab(); tab3.setText("Tab 3"); final Tab tab4 = new Tab(); tab4.setText("Tab 4"); tabPane.getTabs().addAll(tab1, tab2, tab3, tab4); borderPane.setCenter(tabPane); getChildren().add(borderPane); }
public MonitoringPane() { super(); super.setPrefHeight(AppTabPane.CONTENT_HEIGHT); super.setPrefWidth(AppTabPane.CONTENT_WIDTH); super.setSide(Side.BOTTOM); Tab[] tabs = new Tab[3]; tabs[0] = new Tab("Core Usage"); tabs[0].setContent(new CoreUsageMonitorPane()); tabs[1] = new Tab("Memory Usage"); tabs[1].setContent(new MemoryUsageMonitorPane()); tabs[2] = new Tab("Temperature"); tabs[2].setContent(new TempMonitorPane()); for(int i = 0; i < tabs.length; i++) tabs[i].setClosable(false); super.getTabs().addAll(tabs); }
@Override public final Node getPanel(Stage stage) { DateControl dateControl = createControl(); control = dateControl; requireNonNull(control, "missing date control"); DeveloperConsole console = new DeveloperConsole(); console.setDateControl(dateControl); if (isSupportingDeveloperConsole()) { MasterDetailPane masterDetailPane = new MasterDetailPane(); masterDetailPane.setMasterNode(wrap(dateControl)); masterDetailPane.setDetailSide(Side.BOTTOM); masterDetailPane.setDetailNode(console); masterDetailPane.setShowDetailNode(true); return masterDetailPane; } return wrap(dateControl); }
/** * Handle mouse clicked events. * * @param event the mouse clicked event. */ @FXThread private void handleMouseClickedEvent(@NotNull final MouseEvent event) { final ResourceElement item = getItem(); if (item == null) return; final boolean isFolder = item instanceof FolderResourceElement; final ResourceTree treeView = (ResourceTree) getTreeView(); if (event.getButton() == MouseButton.SECONDARY) { final ContextMenu contextMenu = treeView.getContextMenu(item); if (contextMenu == null) return; contextMenu.show(this, Side.BOTTOM, 0, 0); } else if ((treeView.isOnlyFolders() || !isFolder) && event.getButton() == MouseButton.PRIMARY && event.getClickCount() > 1) { final Consumer<ResourceElement> openFunction = treeView.getOpenFunction(); if (openFunction != null) openFunction.accept(item); } }
private void setTitleSideBase(String side){ side = side == null ? "":side; side = side.trim().toLowerCase(); switch (side){ case "bottom": body.setTitleSide(Side.BOTTOM); break; case "left": body.setTitleSide(Side.LEFT); break; case "right": body.setTitleSide(Side.RIGHT); break; default: body.setTitleSide(Side.TOP); break; } }
private void setLegendSideBase(String side){ side = side == null ? "":side; side = side.trim().toLowerCase(); switch (side){ case "top": body.setLegendSide(Side.TOP); break; case "left": body.setLegendSide(Side.LEFT); break; case "right": body.setLegendSide(Side.RIGHT); break; default: body.setLegendSide(Side.BOTTOM); break; } }
private void populatePopup(LinkedList<String> results) { List<CustomMenuItem> menuItems = results.stream() .map(Label::new) .map(label -> { CustomMenuItem menuItem = new CustomMenuItem(label, true); menuItem.setOnAction(action -> { select(label.getText()); popup.hide(); }); return menuItem; }) .collect(Collectors.toCollection(LinkedList::new)); popup.getItems().setAll(menuItems); if (!popup.isShowing()) { popup.show(this, Side.BOTTOM, 0, 0); } }
public DemoPanel(final Willow chrome) { // create a canvas demos button. final Button canvasButton = new IconButton( getString("demo-panel.canvas-demos"), "canvas.jpg", getString("demo-panel.canvas-demos.tooltip"), null ); canvasButton.setOnAction(actionEvent -> canvasMenu.show(canvasButton, Side.BOTTOM, 0, 0) ); for (String[] bookmark : canvasBookmarks) { BookmarkHandler.installBookmark(chrome, canvasMenu, bookmark[0], bookmark[1]); } // create a box for demos. VBox demoBox = new VBox(); // todo generalize this title stuff creation for sidebar items. demoBox.setSpacing(5); demoBox.setStyle("-fx-padding: 5"); demoBox.getChildren().addAll(canvasButton); setText(getString("demo-panel.title")); setContent(demoBox); getStyleClass().add("sidebar-panel"); setExpanded(false); }
public final ObjectProperty<Side> pageInformationAlignmentProperty() { if (pageInformationAlignment == null) { pageInformationAlignment = new StyleableObjectProperty<Side>(Side.BOTTOM) { @Override protected void invalidated() { getSkinnable().requestLayout(); } @Override public CssMetaData<Pagination, Side> getCssMetaData() { return StyleableProperties.PAGE_INFORMATION_ALIGNMENT; } @Override public Object getBean() { return CPagenationSkin.this; } @Override public String getName() { return "pageInformationAlignment"; } }; } return pageInformationAlignment; }
private Layer createFloatingActionButtons() { callActionButton = Util.createFAB(MaterialDesignIcon.CALL, e -> { Dialog confirmCallDialog = new Dialog(OTNBundle.getString("OTN.VENUE.CALLDIALOG.TITLE"), OTNBundle.getString("OTN.VENUE.CALLDIALOG.CONTENT", getVenue().getName(), getVenue().getPhoneNumber())) { { rootNode.setPrefWidth(MobileApplication.getInstance().getView().getScene().getWidth() * 0.9); } }; Button cancel = new Button(OTNBundle.getString("OTN.VENUE.CALLDIALOG.NO")); Button ok = new Button(OTNBundle.getString("OTN.VENUE.CALLDIALOG.YES")); cancel.setOnAction(event -> confirmCallDialog.hide()); ok.setOnAction(event -> { Services.get(DialerService.class).ifPresent(d -> d.call(getVenue().getPhoneNumber())); confirmCallDialog.hide(); }); confirmCallDialog.getButtons().addAll(cancel, ok); confirmCallDialog.showAndWait(); }); webActionButton = Util.createWebLaunchFAB(() -> getVenue().getUrl()); webActionButton.getStyleClass().add("secondary"); webActionButton.attachTo(callActionButton, Side.TOP); return callActionButton.getLayer(); }
public CommandPane (SessionTable sessionTable, ProcessInstruction processInstruction) { setSide (Side.TOP); setTabClosingPolicy (TabClosingPolicy.UNAVAILABLE); final Tab tabCommand = getTab ("Command", commandTextArea); final Tab tabReply = getTab ("Reply", replyTextArea); final Tab tabScreen = getTab ("Screen", screenTextArea); final Tab tabFields = getTab ("Fields", fieldsTextArea); final Tab tabBuffer = getTab ("Buffer", bufferTextArea); final Tab tabReplyBuffer = getTab ("Reply Buffer", replyBufferTextArea); this.processInstruction = processInstruction; getTabs ().addAll (tabCommand, tabBuffer, tabFields, tabScreen, tabReply, tabReplyBuffer); sessionTable.getSelectionModel ().selectedItemProperty () .addListener ( (observable, oldValue, newValue) -> replay (newValue)); }
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); }
@Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { if (textInputControl.getText().length() == 0) { entriesPopup.hide(); } else { LinkedList<String> searchResult = new LinkedList<>(); // todo make sense to add list of items, text get last word searchResult.addAll(entries.subSet(textInputControl.getText(), textInputControl.getText() + Character.MAX_VALUE)); if (entries.size() > 0) { populatePopup(searchResult); if (!entriesPopup.isShowing()) { // textInputControl. entriesPopup.show(textInputControl, Side.BOTTOM, 2 * textInputControl.getFont().getSize(), -1 * textInputControl.getHeight() + 2 * textInputControl.getFont().getSize()); } } else { entriesPopup.hide(); } } }
@Override public Point2D getConnectorPosition(final GConnectorSkin connectorSkin) { final Node connectorRoot = connectorSkin.getRoot(); final Side side = DefaultConnectorTypes.getSide(connectorSkin.getConnector().getType()); // The following logic is required because the connectors are offset slightly from the node edges. final double x, y; if (side.equals(Side.LEFT)) { x = 0; y = connectorRoot.getLayoutY() + connectorSkin.getHeight() / 2; } else if (side.equals(Side.RIGHT)) { x = getRoot().getWidth(); y = connectorRoot.getLayoutY() + connectorSkin.getHeight() / 2; } else if (side.equals(Side.TOP)) { x = connectorRoot.getLayoutX() + connectorSkin.getWidth() / 2; y = 0; } else { x = connectorRoot.getLayoutX() + connectorSkin.getWidth() / 2; y = getRoot().getHeight(); } return new Point2D(x, y); }
protected void reset() { tabPane.getTabs().clear(); eventList.getItems().clear(); for (int i = 0; i < TABS_NUM; i++) { Tab tab = new NamedTab("Tab " + i); tab.setTooltip(new Tooltip("Tab " + i)); ContextMenu menu = new ContextMenu(); for (int j = 0; j < 3; j++) { menu.getItems().add(new MenuItem("Tab " + i + " menu item " + j)); } tab.setContextMenu(menu); if (tab.getContextMenu() != menu) { error.setText("tab.setContextMenu() fails"); } tabPane.getTabs().add(tab); } tabPane.setSide(Side.TOP); error.setText(""); }
@Test(timeout = 300000) @ScreenshotCheck public void screenshot1Test() throws Throwable { setPropertyByToggleClick(SettingType.UNIDIRECTIONAL, ChartProperties.animated, true); setPropertyByChoiceBox(SettingType.UNIDIRECTIONAL, Side.BOTTOM, ChartProperties.titleSide); setPropertyByChoiceBox(SettingType.UNIDIRECTIONAL, Side.LEFT, ChartProperties.legendSide); setPropertyBySlider(SettingType.UNIDIRECTIONAL, ChartProperties.prefWidth, 300); setPropertyBySlider(SettingType.UNIDIRECTIONAL, ChartProperties.prefHeight, 500); setPropertyBySlider(SettingType.UNIDIRECTIONAL, PieChartProperties.startAngle, -100); addDataItem("Added dynamicly", 100.0, 1); setPropertyByToggleClick(SettingType.UNIDIRECTIONAL, PieChartProperties.clockWise, true); setPropertyByToggleClick(SettingType.UNIDIRECTIONAL, PieChartProperties.labelsVisible, true); setPropertyBySlider(SettingType.UNIDIRECTIONAL, PieChartProperties.labelLineLength, 10); setPropertyByTextField(SettingType.UNIDIRECTIONAL, ChartProperties.title, "Changed title"); checkScreenshot("PieChart-multiple1", testedControl); throwScreenshotError(); }
@Test(timeout = 300000) @ScreenshotCheck public void screenshot2Test() throws Throwable { setPropertyByToggleClick(SettingType.UNIDIRECTIONAL, ChartProperties.animated, false); setPropertyByChoiceBox(SettingType.UNIDIRECTIONAL, Side.RIGHT, ChartProperties.titleSide); setPropertyByChoiceBox(SettingType.UNIDIRECTIONAL, Side.TOP, ChartProperties.legendSide); setPropertyBySlider(SettingType.UNIDIRECTIONAL, ChartProperties.prefWidth, 500); setPropertyBySlider(SettingType.UNIDIRECTIONAL, ChartProperties.prefHeight, 300); setPropertyBySlider(SettingType.UNIDIRECTIONAL, PieChartProperties.startAngle, 100); removeDataItem(1); setPropertyByToggleClick(SettingType.UNIDIRECTIONAL, PieChartProperties.clockWise, false); setPropertyByToggleClick(SettingType.UNIDIRECTIONAL, PieChartProperties.labelsVisible, false); setPropertyBySlider(SettingType.UNIDIRECTIONAL, PieChartProperties.labelLineLength, -10); setPropertyByTextField(SettingType.UNIDIRECTIONAL, ChartProperties.title, "Changed title"); checkScreenshot("PieChart-multiple2", testedControl); throwScreenshotError(); }
@Test(timeout = 3000000)//RT-27768 public void chartPropertiesMultipleChangingAndCorrectness3Test() throws Throwable { setSize(500, 500); for (Boolean animated : new Boolean[]{Boolean.TRUE, Boolean.FALSE}) { setPropertyByToggleClick(SettingType.UNIDIRECTIONAL, ChartProperties.animated, animated); for (Side titleSide : Side.values()) { setPropertyByChoiceBox(SettingType.UNIDIRECTIONAL, titleSide, ChartProperties.titleSide); try { pieChartPropertiesTest(); } catch (Throwable ex) { System.out.println("Exception occured in state : "); System.out.println("animated : " + animated); System.out.println("titleSide : " + titleSide); throw ex; } } } }
@Test(timeout = 3000000)//RT-27768 public void chartPropertiesMultipleChangingAndCorrectness4Test() throws Throwable { setSize(500, 500); for (Boolean animated : new Boolean[]{Boolean.TRUE, Boolean.FALSE}) { setPropertyByToggleClick(SettingType.UNIDIRECTIONAL, ChartProperties.animated, animated); for (Side legendSide : Side.values()) { setPropertyByChoiceBox(SettingType.UNIDIRECTIONAL, legendSide, ChartProperties.legendSide); try { pieChartPropertiesTest(); } catch (Throwable ex) { System.out.println("Exception occured in state : "); System.out.println("animated : " + animated); System.out.println("legendSide : " + legendSide); throw ex; } } } }
@Test(timeout = 300000) public void titleSidePropertyTest() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, Throwable { assertEquals(getNewChartInstance().getTitleSide(), Side.TOP); //Switch off legend visibility to check, that title is centered to chart content. setPropertyByToggleClick(SettingType.SETTER, ChartProperties.legendVisible, Boolean.FALSE); setPropertyByTextField(SettingType.BIDIRECTIONAL, ChartProperties.title, "New Title"); titleSideCommonTest(Side.TOP); setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, Side.BOTTOM, ChartProperties.titleSide); titleSideCommonTest(Side.BOTTOM); setPropertyByChoiceBox(SettingType.SETTER, Side.LEFT, ChartProperties.titleSide); titleSideCommonTest(Side.LEFT); setPropertyByChoiceBox(SettingType.UNIDIRECTIONAL, Side.RIGHT, ChartProperties.titleSide); titleSideCommonTest(Side.RIGHT); }
@Test(timeout = 300000) public void legendSidePropertyTest() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, Throwable { assertEquals(getNewChartInstance().getLegendSide(), Side.BOTTOM); setSize(450, 450); setPropertyByTextField(SettingType.BIDIRECTIONAL, ChartProperties.title, "New Title"); legendSideTestCommon(Side.BOTTOM); setPropertyByChoiceBox(SettingType.BIDIRECTIONAL, Side.TOP, ChartProperties.legendSide); legendSideTestCommon(Side.TOP); setPropertyByChoiceBox(SettingType.SETTER, Side.LEFT, ChartProperties.legendSide); legendSideTestCommon(Side.LEFT); setPropertyByChoiceBox(SettingType.UNIDIRECTIONAL, Side.RIGHT, ChartProperties.legendSide); legendSideTestCommon(Side.RIGHT); }
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(); }
@Smoke @Test(timeout = 300000) public void keyboardDropTest() throws Throwable { focus(); expandByKeyboard(activationBtn); if (secondaryActivationBtn != null) { expandByKeyboard(secondaryActivationBtn); } Map<Side, KeyboardButtons> sideMap = new HashMap<Side, KeyboardButtons>() { { put(Side.BOTTOM, KeyboardButtons.DOWN); put(Side.LEFT, KeyboardButtons.LEFT); put(Side.RIGHT, KeyboardButtons.RIGHT); put(Side.TOP, KeyboardButtons.UP); } }; for (Entry<Side, KeyboardButtons> entry : sideMap.entrySet()) { sideCB.as(Selectable.class).selector().select(entry.getKey()); expandByKeyboard(entry.getValue()); } }
public SettingsTabPane(Dictionary dictionary) { this.setSide(Side.LEFT); this.getTabs().addAll( new GeneralSettingsTab(dictionary), new EditorSettingsTab(dictionary), new ViewSettingsTab(dictionary) ); }
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; }
public DockKey(String dockKey, String name, String tooltip, Node icon, TabPolicy policy, Side side) { this.key = dockKey; this.policy = policy; this.name = new SimpleStringProperty(name); this.tooltip = tooltip; this.icon = icon; this.side = side; }
/** * @param selectedChart * @param type * @return return charts for the purchase category */ private ChartView purchaseChart(@NamedArg("selectedChart") int selectedChart, @NamedArg("type") ChartType type) { GenericDAO<Product, Integer> dao = new GenericDAO<>(Product.class); ArrayList<Product> products = (ArrayList<Product>) dao.findAll(); ArrayList<String> objects = new ArrayList<>(); ArrayList<Float> comparative = new ArrayList<>(); String title = null; switch (selectedChart) { case 0: // produit le plus vendu products.sort((p1, p2) -> p2.getSumPurchases() - p1.getSumPurchases()); comparative.sort((o1, o2) -> (int) (o2 - o1)); title = "Produits les plus achetés"; break; case 1: // produits les moins vendus products.sort(Comparator.comparingInt(Product::getSumPurchases)); comparative.sort((o1, o2) -> (int) (o1 - o2)); title = "Produits les moins achetés"; break; default: break; } for (Product c : products) { int sum = c.getSumPurchases(); objects.add(c.getName()); comparative.add((float) sum); } ChartView chartView = new ChartView(ChartType.PIE, objects, comparative, title, "Nom", "Nombre de ventes"); chartView.setLegendSide(Side.BOTTOM); return chartView; }
/** * @param selectedChart * @param type * @return return charts for the others category */ private ChartView otherChart(@NamedArg("selectedChart") int selectedChart, @NamedArg("type") ChartType type) { GenericDAO<Employee, Integer> dao = new GenericDAO<>(Employee.class); ArrayList<Employee> employees = (ArrayList<Employee>) dao.findAll(); ArrayList<String> objects = new ArrayList<>(); ArrayList<Float> comparative = new ArrayList<>(); ChartView chartView = null; switch (selectedChart) { case 0: employees.sort((o1, o2) -> o2.getLogs().size() - o1.getLogs().size()); for (Employee e : employees) { objects.add(e.getFirstName() + " " + e.getLastName()); comparative.add((float) e.getLogs().size()); } comparative.sort((o1, o2) -> (int) (o2 - o1)); chartView = new ChartView(ChartType.PIE, objects, comparative,"Employés se connectant le plus", "Nom", "Nombre de connections"); chartView.setLegendSide(Side.BOTTOM); break; default: break; } return chartView; }
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))); } }
public void setYAxisBorderColor(final Paint FILL) { if (Side.LEFT == getYAxis().getSide()) { getYAxis().setBorder(new Border( new BorderStroke(Color.TRANSPARENT, FILL, Color.TRANSPARENT, Color.TRANSPARENT, BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, BorderStroke.DEFAULT_WIDTHS, Insets.EMPTY))); } else { getYAxis().setBorder(new Border( new BorderStroke(Color.TRANSPARENT, Color.TRANSPARENT, Color.TRANSPARENT, FILL, BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, BorderStroke.DEFAULT_WIDTHS, Insets.EMPTY))); } }
/** * Constructor for all SkinBase instances. * * @param control The control for which this Skin should attach to. */ public LogPaneSkin(LogPane control, TableView<LogItem> table) { super(control); TextArea textArea = new TextArea(); textArea.addEventFilter(KeyEvent.ANY, Event::consume); BorderPane tablePane = new BorderPane(); tablePane.setTop(createToolBar()); tablePane.setCenter(table); MasterDetailPane container = new MasterDetailPane(); container.setMasterNode(tablePane); container.setDetailNode(textArea); container.setDetailSide(Side.RIGHT); container.setDividerPosition(0.65); container.setShowDetailNode(false); control.getSelectedItems().addListener((Observable obs) -> { List<LogItem> item = control.getSelectedItems(); if (item == null || item.isEmpty() || item.size() > 1 || item.get(0).getException() == null) { textArea.setText(null); container.setShowDetailNode(false); } else { StringWriter stackTraceWriter = new StringWriter(); item.get(0).getException().printStackTrace(new PrintWriter(stackTraceWriter)); textArea.setText(stackTraceWriter.toString()); container.setShowDetailNode(true); } }); getChildren().add(container); }
private TabPane createDescriptionPane() { final TabPane descriptionPane = new TabPane(); descriptionPane.getTabs().add(createSnapshots2Tab()); descriptionPane.getTabs().add(createDescriptionTab()); descriptionPane.setSide(Side.LEFT); return descriptionPane; }
private void rebuildContextMenu(Collection<String> values, boolean isPartial) { context.getItems().clear(); values.forEach(value -> { MenuItem item = new MenuItem(value); context.getItems().add(item); item.setOnAction(event -> { String text = getText(); String[] words = text.split(" "); if (isPartial) { words[words.length - 1] = value; } else { words = ArrayUtils.add(words, value); } String newText = StringUtils.join(words, " "); if (!newText.endsWith(" ")) { newText += " "; } setText(newText); positionCaret(newText.length()); }); }); FontLoader fontLoader = Toolkit.getToolkit().getFontLoader(); float width = fontLoader.computeStringWidth(getText(), getFont()); context.show(this, Side.BOTTOM, width, 0); }
@Override public void start(Stage primaryStage) { try { // Image setting = new Image(getClass().getResourceAsStream("setting.png"j)); Image logoimg = new Image(getClass().getResourceAsStream("logo.png")); // Button settingbtn = new Button("",new ImageView(setting)); // settingLabel.setStyle("-fx-background-color:#1d1d1d"); JFXButton logobtn = new JFXButton("",new ImageView(logoimg)); Label title = new Label(" Energy Saving System"); title.setFont(new Font(30)); title.setPrefSize(650, 60); title.setStyle("-fx-background-color:#1d1d1d; \n -fx-text-fill:white ;"); HBox hbox = new HBox(); hbox.setStyle("-fx-background-color:#1d1d1d"); hbox.setSpacing(10); hbox.setPadding(new Insets(10,10,10,10)); hbox.getChildren().addAll(logobtn,title); BorderPane root = new BorderPane(); root.setTop(hbox); JFXTabPane pane = new JFXTabPane(); pane.setSide(Side.RIGHT); Tab tab1 = new Tab(); Tab tab2 = new Tab(); Tab tab3 = new Tab(); tab3.setText("Settings"); tab2.setText("Tweaks"); tab2.setContent(new Tweaks().getPane()); tab1.setText("Statistics"); tab1.setContent(new ChartControls().getPane()); pane.getTabs().addAll(tab1,tab2,tab3); root.setCenter(pane); Scene scene = new Scene(root,910,550); scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm()); primaryStage.setScene(scene); primaryStage.show(); } catch(Exception e) { e.printStackTrace(); } }
/** * Generates an integer timing diagram. * * @param concreteSpec the concrete specification which should be used to extract the needed * information * @param specIoVar the variable for which a diagram should be generated * @param globalXAxis global x axis used for all diagrams * @param selection selection that should be updated when hovering with mouse * @param activated only update selection if true * @return A {@link Pair} which holds a {@link TimingDiagramController} and a {@link NumberAxis} */ public static Pair<TimingDiagramController, Axis> createIntegerTimingDiagram( ConcreteSpecification concreteSpec, ValidIoVariable specIoVar, NumberAxis globalXAxis, Selection selection, BooleanProperty activated) { NumberAxis yaxis = new NumberAxis(0, 10, 1); yaxis.setPrefWidth(30); yaxis.setSide(Side.LEFT); yaxis.setTickLabelFormatter(new IntegerTickLabelConverter()); yaxis.setMinorTickVisible(false); TimingDiagramController timingDiagramController = new TimingDiagramController(globalXAxis, yaxis, concreteSpec, specIoVar, selection, activated); return new ImmutablePair<>(timingDiagramController, yaxis); }
/** * Generates a boolean timing diagram. * * @param concreteSpec the concrete specification which should be used to extract the needed * information * @param specIoVar the variable for which a diagram should be generated * @param globalXAxis global x axis used for all diagrams * @param selection selection that should be updated when hovering with mouse * @param activated only update selection if true * @return A {@link Pair} which holds a {@link TimingDiagramController} and a {@link CategoryAxis} */ public static Pair<TimingDiagramController, Axis> createBoolTimingDiagram( ConcreteSpecification concreteSpec, ValidIoVariable specIoVar, NumberAxis globalXAxis, Selection selection, BooleanProperty activated) { ObservableList<String> categories = FXCollections.observableArrayList(); categories.addAll("FALSE", "TRUE"); CategoryAxis boolCategoryAxis = new CategoryAxis(categories); boolCategoryAxis.setPrefWidth(30); boolCategoryAxis.setSide(Side.LEFT); boolCategoryAxis.setAutoRanging(true); TimingDiagramController timingDiagramController = new TimingDiagramController(globalXAxis, boolCategoryAxis, concreteSpec, specIoVar, selection, activated); return new ImmutablePair<>(timingDiagramController, boolCategoryAxis); }