List of usage examples for javafx.scene.control ComboBox getSelectionModel
public final SingleSelectionModel<T> getSelectionModel()
From source file:gov.va.isaac.gui.refexViews.refexEdit.AddRefexPopup.java
private void buildDataFields(boolean assemblageValid, RefexDynamicDataBI[] currentValues) { if (assemblageValid) { for (ReadOnlyStringProperty ssp : currentDataFieldWarnings_) { allValid_.removeBinding(ssp); }//from www . j ava 2 s . c om currentDataFieldWarnings_.clear(); for (RefexDataTypeNodeDetails nd : currentDataFields_) { nd.cleanupListener(); } currentDataFields_.clear(); GridPane gp = new GridPane(); gp.setHgap(10.0); gp.setVgap(10.0); gp.setStyle("-fx-padding: 5;"); int row = 0; boolean extraInfoColumnIsRequired = false; for (RefexDynamicColumnInfo ci : assemblageInfo_.getColumnInfo()) { SimpleStringProperty valueIsRequired = (ci.isColumnRequired() ? new SimpleStringProperty("") : null); SimpleStringProperty defaultValueTooltip = ((ci.getDefaultColumnValue() == null && ci.getValidator() == null) ? null : new SimpleStringProperty()); ComboBox<RefexDynamicDataType> polymorphicType = null; Label l = new Label(ci.getColumnName()); l.getStyleClass().add("boldLabel"); l.setMinWidth(FxUtils.calculateNecessaryWidthOfBoldLabel(l)); Tooltip.install(l, new Tooltip(ci.getColumnDescription())); int col = 0; gp.add(l, col++, row); if (ci.getColumnDataType() == RefexDynamicDataType.POLYMORPHIC) { polymorphicType = new ComboBox<>(); polymorphicType.setEditable(false); polymorphicType.setConverter(new StringConverter<RefexDynamicDataType>() { @Override public String toString(RefexDynamicDataType object) { return object.getDisplayName(); } @Override public RefexDynamicDataType fromString(String string) { throw new RuntimeException("unecessary"); } }); for (RefexDynamicDataType type : RefexDynamicDataType.values()) { if (type == RefexDynamicDataType.POLYMORPHIC || type == RefexDynamicDataType.UNKNOWN) { continue; } else { polymorphicType.getItems().add(type); } } polymorphicType.getSelectionModel() .select((currentValues == null ? RefexDynamicDataType.STRING : (currentValues[row] == null ? RefexDynamicDataType.STRING : currentValues[row].getRefexDataType()))); } RefexDataTypeNodeDetails nd = RefexDataTypeFXNodeBuilder.buildNodeForType(ci.getColumnDataType(), ci.getDefaultColumnValue(), (currentValues == null ? null : currentValues[row]), valueIsRequired, defaultValueTooltip, (polymorphicType == null ? null : polymorphicType.getSelectionModel().selectedItemProperty()), allValid_, new SimpleObjectProperty<>(ci.getValidator()), new SimpleObjectProperty<>(ci.getValidatorData())); currentDataFieldWarnings_.addAll(nd.getBoundToAllValid()); if (ci.getColumnDataType() == RefexDynamicDataType.POLYMORPHIC) { nd.addUpdateParentListListener(currentDataFieldWarnings_); } currentDataFields_.add(nd); gp.add(nd.getNodeForDisplay(), col++, row); Label colType = new Label(ci.getColumnDataType().getDisplayName()); colType.setMinWidth(FxUtils.calculateNecessaryWidthOfLabel(colType)); gp.add((polymorphicType == null ? colType : polymorphicType), col++, row); if (ci.isColumnRequired() || ci.getDefaultColumnValue() != null || ci.getValidator() != null) { extraInfoColumnIsRequired = true; StackPane stackPane = new StackPane(); stackPane.setMaxWidth(Double.MAX_VALUE); if (ci.getDefaultColumnValue() != null || ci.getValidator() != null) { ImageView information = Images.INFORMATION.createImageView(); Tooltip tooltip = new Tooltip(); tooltip.textProperty().bind(defaultValueTooltip); Tooltip.install(information, tooltip); tooltip.setAutoHide(true); information.setOnMouseClicked( event -> tooltip.show(information, event.getScreenX(), event.getScreenY())); stackPane.getChildren().add(information); } if (ci.isColumnRequired()) { ImageView exclamation = Images.EXCLAMATION.createImageView(); final BooleanProperty showExclamation = new SimpleBooleanProperty( StringUtils.isNotBlank(valueIsRequired.get())); valueIsRequired.addListener((ChangeListener<String>) (observable, oldValue, newValue) -> showExclamation.set(StringUtils.isNotBlank(newValue))); exclamation.visibleProperty().bind(showExclamation); Tooltip tooltip = new Tooltip(); tooltip.textProperty().bind(valueIsRequired); Tooltip.install(exclamation, tooltip); tooltip.setAutoHide(true); exclamation.setOnMouseClicked( event -> tooltip.show(exclamation, event.getScreenX(), event.getScreenY())); stackPane.getChildren().add(exclamation); } gp.add(stackPane, col++, row); } row++; } ColumnConstraints cc = new ColumnConstraints(); cc.setHgrow(Priority.NEVER); gp.getColumnConstraints().add(cc); cc = new ColumnConstraints(); cc.setHgrow(Priority.ALWAYS); gp.getColumnConstraints().add(cc); cc = new ColumnConstraints(); cc.setHgrow(Priority.NEVER); gp.getColumnConstraints().add(cc); if (extraInfoColumnIsRequired) { cc = new ColumnConstraints(); cc.setHgrow(Priority.NEVER); gp.getColumnConstraints().add(cc); } if (row == 0) { sp_.setContent(new Label("This assemblage does not allow data fields")); } else { sp_.setContent(gp); } allValid_.invalidate(); } else { sp_.setContent(null); } }
From source file:gov.va.isaac.gui.refexViews.refexEdit.AddSememePopup.java
private void buildDataFields(boolean assemblageValid, DynamicSememeDataBI[] currentValues) { if (assemblageValid) { for (ReadOnlyStringProperty ssp : currentDataFieldWarnings_) { allValid_.removeBinding(ssp); }//w ww. j av a 2s. c o m currentDataFieldWarnings_.clear(); for (SememeGUIDataTypeNodeDetails nd : currentDataFields_) { nd.cleanupListener(); } currentDataFields_.clear(); GridPane gp = new GridPane(); gp.setHgap(10.0); gp.setVgap(10.0); gp.setStyle("-fx-padding: 5;"); int row = 0; boolean extraInfoColumnIsRequired = false; for (DynamicSememeColumnInfo ci : assemblageInfo_.getColumnInfo()) { SimpleStringProperty valueIsRequired = (ci.isColumnRequired() ? new SimpleStringProperty("") : null); SimpleStringProperty defaultValueTooltip = ((ci.getDefaultColumnValue() == null && ci.getValidator() == null) ? null : new SimpleStringProperty()); ComboBox<DynamicSememeDataType> polymorphicType = null; Label l = new Label(ci.getColumnName()); l.getStyleClass().add("boldLabel"); l.setMinWidth(FxUtils.calculateNecessaryWidthOfBoldLabel(l)); Tooltip.install(l, new Tooltip(ci.getColumnDescription())); int col = 0; gp.add(l, col++, row); if (ci.getColumnDataType() == DynamicSememeDataType.POLYMORPHIC) { polymorphicType = new ComboBox<>(); polymorphicType.setEditable(false); polymorphicType.setConverter(new StringConverter<DynamicSememeDataType>() { @Override public String toString(DynamicSememeDataType object) { return object.getDisplayName(); } @Override public DynamicSememeDataType fromString(String string) { throw new RuntimeException("unecessary"); } }); for (DynamicSememeDataType type : DynamicSememeDataType.values()) { if (type == DynamicSememeDataType.POLYMORPHIC || type == DynamicSememeDataType.UNKNOWN) { continue; } else { polymorphicType.getItems().add(type); } } polymorphicType.getSelectionModel() .select((currentValues == null ? DynamicSememeDataType.STRING : (currentValues[row] == null ? DynamicSememeDataType.STRING : currentValues[row].getDynamicSememeDataType()))); } SememeGUIDataTypeNodeDetails nd = SememeGUIDataTypeFXNodeBuilder.buildNodeForType( ci.getColumnDataType(), ci.getDefaultColumnValue(), (currentValues == null ? null : currentValues[row]), valueIsRequired, defaultValueTooltip, (polymorphicType == null ? null : polymorphicType.getSelectionModel().selectedItemProperty()), allValid_, ci.getValidator(), ci.getValidatorData()); currentDataFieldWarnings_.addAll(nd.getBoundToAllValid()); if (ci.getColumnDataType() == DynamicSememeDataType.POLYMORPHIC) { nd.addUpdateParentListListener(currentDataFieldWarnings_); } currentDataFields_.add(nd); gp.add(nd.getNodeForDisplay(), col++, row); Label colType = new Label(ci.getColumnDataType().getDisplayName()); colType.setMinWidth(FxUtils.calculateNecessaryWidthOfLabel(colType)); gp.add((polymorphicType == null ? colType : polymorphicType), col++, row); if (ci.isColumnRequired() || ci.getDefaultColumnValue() != null || ci.getValidator() != null) { extraInfoColumnIsRequired = true; StackPane stackPane = new StackPane(); stackPane.setMaxWidth(Double.MAX_VALUE); if (ci.getDefaultColumnValue() != null || ci.getValidator() != null) { ImageView information = Images.INFORMATION.createImageView(); Tooltip tooltip = new Tooltip(); tooltip.textProperty().bind(defaultValueTooltip); Tooltip.install(information, tooltip); tooltip.setAutoHide(true); information.setOnMouseClicked( event -> tooltip.show(information, event.getScreenX(), event.getScreenY())); stackPane.getChildren().add(information); } if (ci.isColumnRequired()) { ImageView exclamation = Images.EXCLAMATION.createImageView(); final BooleanProperty showExclamation = new SimpleBooleanProperty( StringUtils.isNotBlank(valueIsRequired.get())); valueIsRequired.addListener((ChangeListener<String>) (observable, oldValue, newValue) -> showExclamation.set(StringUtils.isNotBlank(newValue))); exclamation.visibleProperty().bind(showExclamation); Tooltip tooltip = new Tooltip(); tooltip.textProperty().bind(valueIsRequired); Tooltip.install(exclamation, tooltip); tooltip.setAutoHide(true); exclamation.setOnMouseClicked( event -> tooltip.show(exclamation, event.getScreenX(), event.getScreenY())); stackPane.getChildren().add(exclamation); } gp.add(stackPane, col++, row); } row++; } ColumnConstraints cc = new ColumnConstraints(); cc.setHgrow(Priority.NEVER); gp.getColumnConstraints().add(cc); cc = new ColumnConstraints(); cc.setHgrow(Priority.ALWAYS); gp.getColumnConstraints().add(cc); cc = new ColumnConstraints(); cc.setHgrow(Priority.NEVER); gp.getColumnConstraints().add(cc); if (extraInfoColumnIsRequired) { cc = new ColumnConstraints(); cc.setHgrow(Priority.NEVER); gp.getColumnConstraints().add(cc); } if (row == 0) { sp_.setContent(new Label("This assemblage does not allow data fields")); } else { sp_.setContent(gp); } allValid_.invalidate(); } else { sp_.setContent(null); } }
From source file:de.bayern.gdi.gui.Controller.java
private void loadWfsSimple() { ObservableList<Node> children = simpleWFSContainer.getChildren(); Map<String, String> parameters = downloadConfig.getParams(); for (Node node : children) { if (node instanceof HBox) { HBox hb = (HBox) node;//from w w w .j a va 2 s . c o m Node n1 = hb.getChildren().get(0); Node n2 = hb.getChildren().get(1); if (n1 instanceof Label && n2 instanceof TextField) { Label paramLabel = (Label) n1; TextField paramBox = (TextField) n2; String targetValue = parameters.get(paramLabel.getText()); if (targetValue != null) { paramBox.setText(targetValue); } } if (n2 instanceof ComboBox) { ComboBox<OutputFormatModel> cb = (ComboBox<OutputFormatModel>) n2; cb.setCellFactory(new Callback<ListView<OutputFormatModel>, ListCell<OutputFormatModel>>() { @Override public ListCell<OutputFormatModel> call(ListView<OutputFormatModel> list) { return new CellTypes.StringCell(); } }); cb.setOnAction(event -> { if (cb.getValue().isAvailable()) { cb.setStyle(FX_BORDER_COLOR_NULL); } else { cb.setStyle(FX_BORDER_COLOR_RED); } }); boolean formatAvailable = false; for (OutputFormatModel i : cb.getItems()) { if (i.getItem().equals(downloadConfig.getOutputFormat())) { cb.getSelectionModel().select(i); formatAvailable = true; } } if (!formatAvailable) { String format = downloadConfig.getOutputFormat(); OutputFormatModel m = new OutputFormatModel(); m.setItem(format); m.setAvailable(false); cb.getItems().add(m); cb.getSelectionModel().select(m); } if (cb.getValue().isAvailable()) { cb.setStyle(FX_BORDER_COLOR_NULL); } else { cb.setStyle(FX_BORDER_COLOR_RED); } } } } }
From source file:de.bayern.gdi.gui.Controller.java
private void extractStoredQuery() { ItemModel data = this.dataBean.getDatatype(); if (data instanceof StoredQueryModel) { this.dataBean.setAttributes(new ArrayList<DataBean.Attribute>()); ObservableList<Node> children = this.simpleWFSContainer.getChildren(); for (Node n : children) { if (n.getClass() == HBox.class) { HBox hbox = (HBox) n;//w w w . ja va 2 s.c o m ObservableList<Node> hboxChildren = hbox.getChildren(); String value = ""; String name = ""; String type = ""; Label l1 = null; Label l2 = null; TextField tf = null; ComboBox cb = null; for (Node hn : hboxChildren) { if (hn.getClass() == ComboBox.class) { cb = (ComboBox) hn; } if (hn.getClass() == TextField.class) { tf = (TextField) hn; } if (hn.getClass() == Label.class) { if (l1 == null) { l1 = (Label) hn; } if (l1 != (Label) hn) { l2 = (Label) hn; } } if (tf != null && (l1 != null || l2 != null)) { name = tf.getUserData().toString(); value = tf.getText(); if (l2 != null && l1.getText().equals(name)) { type = l2.getText(); } else { type = l1.getText(); } } if (cb != null && (l1 != null || l2 != null) && cb.getId().equals(UIFactory.getDataFormatID())) { name = OUTPUTFORMAT; if (cb.getSelectionModel() != null && cb.getSelectionModel().getSelectedItem() != null) { value = cb.getSelectionModel().getSelectedItem().toString(); type = ""; } else { Platform.runLater(() -> setStatusTextUI(I18n.getMsg(GUI_FORMAT_NOT_SELECTED))); } } if (!name.isEmpty() && !value.isEmpty()) { this.dataBean.addAttribute(name, value, type); } } } } } }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param lstPano/*from w ww . ja v a 2 s. c o m*/ * @param numPano * @return */ public Pane affichageHS(String lstPano, int numPano) { Pane panneauHotSpots = new Pane(); panneauHotSpots.setTranslateY(10); panneauHotSpots.setTranslateX(30); VBox vb1 = new VBox(5); panneauHotSpots.getChildren().add(vb1); Label lblPoint; Label sep = new Label(" "); Label sep1 = new Label(" "); int o; for (o = 0; o < panoramiquesProjet[numPano].getNombreHotspots(); o++) { VBox vbPanneauHS = new VBox(); double deplacement = 20; vbPanneauHS.setLayoutX(deplacement); Pane pannneauHS = new Pane(vbPanneauHS); pannneauHS.setStyle("-fx-border-color : #777777;-fx-border-width : 1px;-fx-border-radius : 3;"); panneauHotSpots.setId("HS" + o); lblPoint = new Label("Point n" + (o + 1)); lblPoint.setPadding(new Insets(5, 10, 5, 5)); lblPoint.setTranslateX(-deplacement); lblPoint.setStyle("-fx-background-color : #333;"); lblPoint.setTextFill(Color.WHITE); Separator sp = new Separator(Orientation.HORIZONTAL); sp.setTranslateX(-deplacement); sp.setPrefWidth(300); pannneauHS.setPrefWidth(300); pannneauHS.setTranslateX(5); vbPanneauHS.getChildren().addAll(lblPoint, sp); if (lstPano != null) { Label lblLien = new Label("Panoramique de destination"); ComboBox cbDestPano = new ComboBox(); String[] liste = lstPano.split(";"); cbDestPano.getItems().addAll(Arrays.asList(liste)); cbDestPano.valueProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue ov, String t, String t1) { valideHS(); } }); cbDestPano.setTranslateX(60); cbDestPano.setId("cbpano" + o); String f1XML = panoramiquesProjet[numPano].getHotspot(o).getFichierXML(); if (f1XML != null) { cbDestPano.setValue(f1XML.split("\\.")[0]); } int num = cbDestPano.getSelectionModel().getSelectedIndex(); vbPanneauHS.getChildren().addAll(lblLien, cbDestPano, sep); } Label lblTexteHS = new Label("Texte du Hotspot"); TextArea txtTexteHS = new TextArea(); if (panoramiquesProjet[numPano].getHotspot(o).getInfo() != null) { txtTexteHS.setText(panoramiquesProjet[numPano].getHotspot(o).getInfo()); } txtTexteHS.textProperty().addListener((final ObservableValue<? extends String> observable, final String oldValue, final String newValue) -> { valideHS(); }); txtTexteHS.setId("txtHS" + o); txtTexteHS.setPrefSize(200, 25); txtTexteHS.setMaxSize(200, 20); txtTexteHS.setTranslateX(60); CheckBox cbAnime = new CheckBox("HostSpot Anim"); cbAnime.setId("anime" + o); cbAnime.selectedProperty().addListener((final ObservableValue<? extends Boolean> observable, final Boolean oldValue, final Boolean newValue) -> { valideHS(); }); if (panoramiquesProjet[numPano].getHotspot(o).isAnime()) { cbAnime.setSelected(true); } cbAnime.setPadding(new Insets(5)); cbAnime.setTranslateX(60); vbPanneauHS.getChildren().addAll(lblTexteHS, txtTexteHS, cbAnime, sep1); vb1.getChildren().addAll(pannneauHS, sep); } int nbHS = o; for (o = 0; o < panoramiquesProjet[numPano].getNombreHotspotImage(); o++) { VBox vbPanneauHS = new VBox(); Pane pannneauHS = new Pane(vbPanneauHS); pannneauHS.setStyle("-fx-border-color : #777777;-fx-border-width : 1px;-fx-border-radius : 3;"); panneauHotSpots.setId("HSImg" + o); lblPoint = new Label("Image n" + (o + 1)); lblPoint.setPadding(new Insets(5, 10, 5, 5)); lblPoint.setStyle("-fx-background-color : #666;"); lblPoint.setTextFill(Color.WHITE); Separator sp = new Separator(Orientation.HORIZONTAL); sp.setPrefWidth(300); pannneauHS.setPrefWidth(300); pannneauHS.setTranslateX(5); vbPanneauHS.getChildren().addAll(lblPoint, sp); Label lblLien = new Label("Image choisie :"); String f1XML = panoramiquesProjet[numPano].getHotspotImage(o).getLienImg(); ImageView IMChoisie = new ImageView( new Image("file:" + repertTemp + File.separator + "images" + File.separator + f1XML, 100, -1, true, true)); IMChoisie.setTranslateX(100); vbPanneauHS.getChildren().addAll(lblLien, IMChoisie, sep); Label lblTexteHS = new Label("Texte du Hotspot"); TextArea txtTexteHS = new TextArea(); if (panoramiquesProjet[numPano].getHotspotImage(o).getInfo() != null) { txtTexteHS.setText(panoramiquesProjet[numPano].getHotspotImage(o).getInfo()); } txtTexteHS.textProperty().addListener((final ObservableValue<? extends String> observable, final String oldValue, final String newValue) -> { valideHS(); }); txtTexteHS.setId("txtHSImage" + o); txtTexteHS.setPrefSize(200, 25); txtTexteHS.setMaxSize(200, 20); txtTexteHS.setTranslateX(60); CheckBox cbAnime = new CheckBox("HostSpot Anim"); cbAnime.setId("animeImage" + o); cbAnime.selectedProperty().addListener((final ObservableValue<? extends Boolean> observable, final Boolean oldValue, final Boolean newValue) -> { valideHS(); }); if (panoramiquesProjet[numPano].getHotspotImage(o).isAnime()) { cbAnime.setSelected(true); } cbAnime.setPadding(new Insets(5)); cbAnime.setTranslateX(60); vbPanneauHS.getChildren().addAll(lblTexteHS, txtTexteHS, cbAnime, sep1); vb1.getChildren().addAll(pannneauHS, sep); } valideHS(); nbHS += o; // if (nbHS == 0) { // } else { // btnValider.setVisible(true); // } return panneauHotSpots; }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param iNumHS/*from www .ja v a 2 s . c om*/ * @return */ private static AnchorPane apAfficherListePanosVignettes(int iNumHS) { NavigateurPanoramique navigateurPano2; AnchorPane apVisuPanoHS; iNumeroPanoChoisitHS = -1; if (!getPanoramiquesProjet()[getiPanoActuel()].getHotspot(iNumHS).getStrFichierXML().equals("")) { for (int ii1 = 0; ii1 < getiNombrePanoramiques(); ii1++) { String strFichPano = getPanoramiquesProjet()[ii1].getStrNomFichier(); String strNomXMLFile = strFichPano .substring(strFichPano.lastIndexOf(File.separator) + 1, strFichPano.length()) .split("\\.")[0] + ".xml"; if (strNomXMLFile .equals(getPanoramiquesProjet()[getiPanoActuel()].getHotspot(iNumHS).getStrFichierXML())) { iNumeroPanoChoisitHS = ii1; strNomPanoChoisitHS = getPanoramiquesProjet()[ii1].getStrNomFichier(); } } navigateurPano2 = new NavigateurPanoramique( getPanoramiquesProjet()[iNumeroPanoChoisitHS].getImgVisuPanoramique(), 0, 0, 400, 200, true); if (getPanoramiquesProjet()[getiPanoActuel()].getHotspot(iNumHS).getRegardX() != -1000) { navigateurPano2.setChoixLongitude( getPanoramiquesProjet()[getiPanoActuel()].getHotspot(iNumHS).getRegardX()); } else { navigateurPano2.setChoixLongitude(0); } navigateurPano2.setLongitude(navigateurPano2.getChoixLongitude()); if (getPanoramiquesProjet()[getiPanoActuel()].getHotspot(iNumHS).getRegardY() != -1000) { navigateurPano2.setChoixLatitude( getPanoramiquesProjet()[getiPanoActuel()].getHotspot(iNumHS).getRegardY()); } else { navigateurPano2.setChoixLatitude(0); } navigateurPano2.setLatitude(navigateurPano2.getChoixLatitude()); if (getPanoramiquesProjet()[getiPanoActuel()].getHotspot(iNumHS).getChampVisuel() != 0) { navigateurPano2 .setChoixFov(getPanoramiquesProjet()[getiPanoActuel()].getHotspot(iNumHS).getChampVisuel()); } else { navigateurPano2.setChoixFov(50); } navigateurPano2.setFov(navigateurPano2.getChoixFov()); apVisuPanoHS = navigateurPano2.affichePano(); apVisuPanoHS.setDisable(false); } else { navigateurPano2 = new NavigateurPanoramique( getPanoramiquesProjet()[getiPanoActuel()].getImgVisuPanoramique(), 0, 0, 400, 200, true); apVisuPanoHS = navigateurPano2.affichePano(); apVisuPanoHS.setDisable(true); } AnchorPane aplistePano = new AnchorPane(); aplistePano.setOpacity(1); Pane paneFond = new Pane(); paneFond.setOnMouseClicked((mouseEvent) -> { mouseEvent.consume(); }); paneFond.setStyle("-fx-background-color : #bbb;"); paneFond.setPrefWidth(540); paneFond.setPrefHeight(((getiNombrePanoramiques() - 2) / 4 + 1) * 65 + 10 + 320); paneFond.setMinWidth(540); paneFond.setMinHeight(70); aplistePano.getChildren().add(paneFond); aplistePano.setStyle("-fx-backgroung-color : #bbb;"); int ij = 0; ImageView[] ivPano; ivPano = new ImageView[getiNombrePanoramiques()]; double xPos; double yPos; int iRow = 0; Button btnValide = new Button("Ok"); btnValide.setPrefWidth(80); btnValide.setLayoutX(paneFond.getPrefWidth() - 100); btnValide.setLayoutY(paneFond.getPrefHeight() - 30); paneFond.getChildren().add(btnValide); btnValide.setOnMouseClicked((mouseEvent) -> { if (iNumeroPanoChoisitHS != -1) { panePanoramique.setCursor(Cursor.CROSSHAIR); panePanoramique.setOnMouseClicked((me1) -> { gereSourisPanoramique(me1); }); setStrPanoListeVignette(strNomPanoChoisitHS); if (getPanoramiquesProjet()[iNumeroPanoChoisitHS].getStrTitrePanoramique() != null) { String strTexteHS = getPanoramiquesProjet()[iNumeroPanoChoisitHS].getStrTitrePanoramique(); TextField tfTxtHS = (TextField) vbOutils.lookup("#txtHS" + iNumHS); tfTxtHS.setText(strTexteHS); } double latitude = Math.round(navigateurPano2.getChoixLatitude() * 10) / 10.d; double longitude = Math.round(navigateurPano2.getChoixLongitude() * 10) / 10.d - 180; double fov = Math.round(navigateurPano2.getChoixFov() * 10) / 10.d; longitude = longitude % 360; longitude = longitude < 0 ? longitude + 360 : longitude; longitude = longitude > 180 ? longitude - 360 : longitude; getPanoramiquesProjet()[getiPanoActuel()].getHotspot(iNumHS).setNumeroPano(iNumeroPanoChoisitHS); getPanoramiquesProjet()[getiPanoActuel()].getHotspot(iNumHS).setRegardX(longitude - 180); getPanoramiquesProjet()[getiPanoActuel()].getHotspot(iNumHS).setRegardY(latitude); getPanoramiquesProjet()[getiPanoActuel()].getHotspot(iNumHS).setChampVisuel(fov); getPanoramiquesProjet()[getiPanoActuel()].getHotspot(iNumHS) .setImgVueHs(navigateurPano2.getImgVignetteHS()); ComboBox cbPanos = (ComboBox) vbOutils.lookup("#cbpano" + iNumHS); cbPanos.getSelectionModel().select(iNumeroPanoChoisitHS); aplistePano.setVisible(false); } mouseEvent.consume(); }); for (int i = 0; i < getiNombrePanoramiques(); i++) { int iNumeroPano1 = i; String strNomPano = getPanoramiquesProjet()[i].getStrNomFichier(); ivPano[ij] = new ImageView(getPanoramiquesProjet()[i].getImgVignettePanoramique()); ivPano[ij].setFitWidth(120); ivPano[ij].setFitHeight(60); ivPano[ij].setSmooth(true); int iCol = ij % 4; iRow = ij / 4; xPos = iCol * 130 + 25; yPos = iRow * 65 + 15; ivPano[ij].setLayoutX(xPos); ivPano[ij].setLayoutY(yPos); ivPano[ij].setCursor(Cursor.HAND); ivPano[ij].setStyle("-fx-background-color : #ccc;"); Tooltip tltpPano = new Tooltip( strNomPano.substring(strNomPano.lastIndexOf(File.separator) + 1, strNomPano.lastIndexOf("."))); tltpPano.setStyle(getStrTooltipStyle()); Tooltip.install(ivPano[ij], tltpPano); ivPano[ij].setOnMouseClicked((mouseEvent) -> { iNumeroPanoChoisitHS = iNumeroPano1; strNomPanoChoisitHS = getPanoramiquesProjet()[iNumeroPanoChoisitHS].getStrNomFichier(); navigateurPano2.setImagePanoramique( getPanoramiquesProjet()[iNumeroPanoChoisitHS].getStrNomFichier(), getPanoramiquesProjet()[iNumeroPanoChoisitHS].getImgVisuPanoramique()); navigateurPano2.setLongitude(getPanoramiquesProjet()[iNumeroPanoChoisitHS].getRegardX() - 180); navigateurPano2.setLatitude(getPanoramiquesProjet()[iNumeroPanoChoisitHS].getRegardY()); navigateurPano2.setFov(getPanoramiquesProjet()[iNumeroPanoChoisitHS].getChampVisuel()); navigateurPano2.affiche(); apVisuPanoHS.setDisable(false); }); aplistePano.getChildren().add(ivPano[ij]); ij++; } int iTaille = (iRow + 1) * 65 + 5; apVisuPanoHS.setLayoutY(iTaille + 10); iTaille += 320; apVisuPanoHS.setLayoutX((540 - apVisuPanoHS.getPrefWidth()) / 2.d); aplistePano.setPrefWidth(540); aplistePano.setPrefHeight(iTaille); aplistePano.setMinWidth(540); aplistePano.setMinHeight(iTaille); aplistePano.getChildren().add(apVisuPanoHS); ImageView ivClose = new ImageView( new Image("file:" + getStrRepertAppli() + File.separator + "images/ferme.png", 20, 20, true, true)); ivClose.setLayoutX(2); ivClose.setLayoutY(5); ivClose.setCursor(Cursor.HAND); aplistePano.getChildren().add(ivClose); ivClose.setOnMouseClicked((mouseEvent) -> { panePanoramique.setCursor(Cursor.CROSSHAIR); panePanoramique.setOnMouseClicked((mouseEvent1) -> { gereSourisPanoramique(mouseEvent1); }); setStrPanoListeVignette(""); aplistePano.setVisible(false); mouseEvent.consume(); }); return aplistePano; }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * *///from w ww . j a va 2 s . co m private static void valideHS() { for (int i = 0; i < getPanoramiquesProjet()[getiPanoActuel()].getNombreHotspots(); i++) { ComboBox cbPanos = (ComboBox) vbOutils.lookup("#cbpano" + i); TextField tfTexteHS = (TextField) vbOutils.lookup("#txtHS" + i); if (tfTexteHS != null) { getPanoramiquesProjet()[getiPanoActuel()].getHotspot(i).setStrInfo(tfTexteHS.getText()); } if (cbPanos != null) { getPanoramiquesProjet()[getiPanoActuel()].getHotspot(i) .setStrFichierXML(cbPanos.getValue() + ".xml"); getPanoramiquesProjet()[getiPanoActuel()].getHotspot(i) .setNumeroPano(cbPanos.getSelectionModel().getSelectedIndex()); } CheckBox cbAnime = (CheckBox) vbOutils.lookup("#anime" + i); if (cbAnime != null) { getPanoramiquesProjet()[getiPanoActuel()].getHotspot(i).setAnime(cbAnime.isSelected()); } } for (int i = 0; i < getPanoramiquesProjet()[getiPanoActuel()].getNombreHotspotImage(); i++) { TextField tfTexteHS = (TextField) vbOutils.lookup("#txtHSImage" + i); if (tfTexteHS != null) { getPanoramiquesProjet()[getiPanoActuel()].getHotspotImage(i).setStrInfo(tfTexteHS.getText()); } CheckBox cbAnime = (CheckBox) vbOutils.lookup("#animeImage" + i); if (cbAnime != null) { getPanoramiquesProjet()[getiPanoActuel()].getHotspotImage(i).setAnime(cbAnime.isSelected()); } } for (int i = 0; i < getPanoramiquesProjet()[getiPanoActuel()].getNombreHotspotHTML(); i++) { TextField tfTexteHS = (TextField) vbOutils.lookup("#txtHSHTML" + i); if (tfTexteHS != null) { getPanoramiquesProjet()[getiPanoActuel()].getHotspotHTML(i).setStrInfo(tfTexteHS.getText()); } CheckBox cbAnime = (CheckBox) vbOutils.lookup("#animeHTML" + i); if (cbAnime != null) { getPanoramiquesProjet()[getiPanoActuel()].getHotspotHTML(i).setAnime(cbAnime.isSelected()); } } for (int i = 0; i < getPanoramiquesProjet()[getiPanoActuel()].getiNombreHotspotDiapo(); i++) { TextField tfTexteHS = (TextField) vbOutils.lookup("#txtDIA" + i); if (tfTexteHS != null) { getPanoramiquesProjet()[getiPanoActuel()].getHotspotDiapo(i).setStrInfo(tfTexteHS.getText()); } CheckBox cbAnime = (CheckBox) vbOutils.lookup("#animeDIA" + i); if (cbAnime != null) { getPanoramiquesProjet()[getiPanoActuel()].getHotspotDiapo(i).setbAnime(cbAnime.isSelected()); } } }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param strLstPano//from w w w . java 2s .c om * @param iNumPano * @return */ public static Pane paneAffichageHS(String strLstPano, int iNumPano) { Pane paneHotSpots = new Pane(); paneHotSpots.setTranslateY(10); paneHotSpots.setTranslateX(10); VBox vbHotspots = new VBox(5); paneHotSpots.getChildren().add(vbHotspots); Label lblPoint; int io; for (io = 0; io < getPanoramiquesProjet()[iNumPano].getNombreHotspots(); io++) { Label lblSep = new Label(" "); Label lblSep1 = new Label(" "); VBox vbPanneauHS = new VBox(); double deplacement = 0; vbPanneauHS.setLayoutX(deplacement); Pane paneHsPanoramique = new Pane(vbPanneauHS); paneHsPanoramique.setPrefHeight(300); paneHsPanoramique.setMinHeight(300); paneHsPanoramique.setMaxHeight(300); int iNum1 = io; Timeline timBouge = new Timeline(new KeyFrame(Duration.millis(500), (ActionEvent event) -> { Circle c1 = (Circle) panePanoramique.lookup("#point" + iNum1); if (c1 != null) { if (c1.getFill() == Color.RED) { c1.setFill(Color.YELLOW); c1.setStroke(Color.RED); } else { c1.setFill(Color.RED); c1.setStroke(Color.YELLOW); } } })); timBouge.setCycleCount(Timeline.INDEFINITE); timBouge.pause(); paneHsPanoramique.setOnMouseEntered((e) -> { timBouge.play(); }); paneHsPanoramique.setOnMouseExited((e) -> { timBouge.pause(); Circle c1 = (Circle) panePanoramique.lookup("#point" + iNum1); if (c1 != null) { c1.setFill(Color.YELLOW); c1.setStroke(Color.RED); } }); paneHsPanoramique .setStyle("-fx-border-color : #777777;-fx-border-width : 1px;-fx-border-radius : 3px;"); paneHsPanoramique.setId("HS" + io); lblPoint = new Label("Point #" + (io + 1)); lblPoint.setPadding(new Insets(5, 10, 5, 5)); lblPoint.setTranslateX(-deplacement); lblPoint.getStyleClass().add("titreOutil"); Separator sepHotspots = new Separator(Orientation.HORIZONTAL); sepHotspots.setTranslateX(-deplacement); sepHotspots.setPrefWidth(321); sepHotspots.setTranslateX(2); paneHsPanoramique.setPrefWidth(325); vbPanneauHS.getChildren().addAll(lblPoint, sepHotspots); if (strLstPano != null) { Label lblLien = new Label(rbLocalisation.getString("main.panoramiqueDestination")); lblLien.setTranslateX(10); ComboBox cbDestPano = new ComboBox(); String[] strListe = strLstPano.split(";"); cbDestPano.getItems().addAll(Arrays.asList(strListe)); int iNum11 = getPanoramiquesProjet()[iNumPano].getHotspot(io).getNumeroPano(); cbDestPano.setTranslateX(10); cbDestPano.setId("cbpano" + io); cbDestPano.getSelectionModel().select(iNum11); cbDestPano.getSelectionModel().selectedIndexProperty().addListener((ov, t, t1) -> { valideHS(); if (dejaCharge) { dejaCharge = false; retireAffichageHotSpots(); Pane affHS1 = paneAffichageHS(strListePano(), iNumPano); affHS1.setId("labels"); vbVisuHotspots.getChildren().add(affHS1); } }); if (iNum11 != -1) { int iNumPan = iNum11; ImageView ivAfficheVignettePano = new ImageView( getPanoramiquesProjet()[iNum11].getImgPanoRect()); ivAfficheVignettePano.setPreserveRatio(true); ivAfficheVignettePano.setFitWidth(300); ivAfficheVignettePano.setLayoutY(10); ivAfficheVignettePano.setCursor(Cursor.HAND); ivAfficheVignettePano.setOnMouseClicked((e) -> { affichePanoChoisit(iNumPan); }); AnchorPane apVisuVignettePano = new AnchorPane(ivAfficheVignettePano); apVisuVignettePano.setPrefHeight(170); apVisuVignettePano.setTranslateX(10); vbPanneauHS.getChildren().addAll(lblLien, cbDestPano, apVisuVignettePano, lblSep); } else { vbPanneauHS.getChildren().addAll(lblLien, cbDestPano, lblSep); } } Label lblTexteHS = new Label(rbLocalisation.getString("main.texteHotspot")); lblTexteHS.setTranslateX(10); TextField tfTexteHS = new TextField(); if (getPanoramiquesProjet()[iNumPano].getHotspot(io).getStrInfo() != null) { tfTexteHS.setText(getPanoramiquesProjet()[iNumPano].getHotspot(io).getStrInfo()); } tfTexteHS.textProperty().addListener((final ObservableValue<? extends String> observable, final String oldValue, final String newValue) -> { valideHS(); }); tfTexteHS.setId("txtHS" + io); tfTexteHS.setPrefSize(200, 25); tfTexteHS.setMaxSize(200, 20); tfTexteHS.setTranslateX(60); vbPanneauHS.getChildren().addAll(lblTexteHS, tfTexteHS, lblSep1); vbHotspots.getChildren().addAll(paneHsPanoramique, lblSep); } int iNbHS = io; int iTaillePane = io * 325; for (io = 0; io < getPanoramiquesProjet()[iNumPano].getNombreHotspotImage(); io++) { Label lblSep = new Label(" "); Label lblSep1 = new Label(" "); VBox vbPanneauHsImage = new VBox(); Pane paneHsImage = new Pane(vbPanneauHsImage); int iNum = io; Timeline timBouge = new Timeline(new KeyFrame(Duration.millis(500), (ActionEvent event) -> { Circle c1 = (Circle) panePanoramique.lookup("#img" + iNum); if (c1 != null) { if (c1.getFill() == Color.BLUE) { c1.setFill(Color.YELLOW); c1.setStroke(Color.BLUE); } else { c1.setFill(Color.BLUE); c1.setStroke(Color.YELLOW); } } })); timBouge.setCycleCount(Timeline.INDEFINITE); timBouge.pause(); paneHsImage.setOnMouseEntered((e) -> { timBouge.play(); }); paneHsImage.setOnMouseExited((e) -> { Circle c1 = (Circle) panePanoramique.lookup("#img" + iNum); if (c1 != null) { c1.setFill(Color.BLUE); c1.setStroke(Color.YELLOW); } timBouge.pause(); }); paneHsImage.setStyle("-fx-border-color : #777777;-fx-border-width : 1px;-fx-border-radius : 3px;"); paneHsImage.setId("HSImg" + io); lblPoint = new Label("Image #" + (io + 1)); lblPoint.setPadding(new Insets(5, 10, 5, 5)); lblPoint.getStyleClass().add("titreOutil"); Separator sepHS = new Separator(Orientation.HORIZONTAL); sepHS.setPrefWidth(321); sepHS.setTranslateX(2); paneHsImage.setPrefWidth(325); vbPanneauHsImage.getChildren().addAll(lblPoint, sepHS); Label lblLien = new Label(rbLocalisation.getString("main.imageChoisie")); lblLien.setTranslateX(10); String strF1XML = getPanoramiquesProjet()[iNumPano].getHotspotImage(io).getStrLienImg(); Image imgChoisie = new Image( "file:" + getStrRepertTemp() + File.separator + "images" + File.separator + strF1XML); ImageView ivChoisie = new ImageView(imgChoisie); ivChoisie.setTranslateX(100); ivChoisie.setFitWidth(100); ivChoisie.setFitHeight(imgChoisie.getHeight() / imgChoisie.getWidth() * 100); vbPanneauHsImage.getChildren().addAll(lblLien, ivChoisie, lblSep); Label lblTexteHS = new Label(rbLocalisation.getString("main.texteHotspot")); lblTexteHS.setTranslateX(10); TextField tfTexteHS = new TextField(); if (getPanoramiquesProjet()[iNumPano].getHotspotImage(io).getStrInfo() != null) { tfTexteHS.setText(getPanoramiquesProjet()[iNumPano].getHotspotImage(io).getStrInfo()); } tfTexteHS.textProperty().addListener((final ObservableValue<? extends String> observable, final String oldValue, final String newValue) -> { valideHS(); }); tfTexteHS.setId("txtHSImage" + io); tfTexteHS.setPrefSize(200, 25); tfTexteHS.setMaxSize(200, 20); tfTexteHS.setTranslateX(60); vbPanneauHsImage.getChildren().addAll(lblTexteHS, tfTexteHS, lblSep1); Label lblCoulFond = new Label(rbLocalisation.getString("diapo.couleurFond")); lblCoulFond.setTranslateX(10); Label lblOpacite = new Label(rbLocalisation.getString("diapo.opacite")); lblOpacite.setTranslateX(10); if (getPanoramiquesProjet()[iNumPano].getHotspotImage(io).getStrCouleurFond().equals("")) { getPanoramiquesProjet()[iNumPano].getHotspotImage(io).setStrCouleurFond( "#" + getGestionnaireInterface().getCouleurFondTheme().toString().substring(2, 8)); } ColorPicker cpCouleurFond = new ColorPicker( Color.valueOf(getPanoramiquesProjet()[iNumPano].getHotspotImage(io).getStrCouleurFond())); if (getPanoramiquesProjet()[iNumPano].getHotspotImage(io).getOpacite() == -1) { getPanoramiquesProjet()[iNumPano].getHotspotImage(io) .setOpacite(getGestionnaireInterface().getOpaciteTheme()); } cpCouleurFond.setTranslateX(100); int i = io; cpCouleurFond.valueProperty().addListener((ov, av, nv) -> { if (getiNombrePanoramiques() != 0) { setbDejaSauve(false); getStPrincipal().setTitle(getStPrincipal().getTitle().replace(" *", "") + " *"); } getPanoramiquesProjet()[iNumPano].getHotspotImage(i) .setStrCouleurFond("#" + cpCouleurFond.getValue().toString().substring(2, 8)); }); Slider slOpacite = new Slider(0, 1, getPanoramiquesProjet()[iNumPano].getHotspotImage(io).getOpacite()); slOpacite.valueProperty().addListener((ov, av, nv) -> { if (getiNombrePanoramiques() != 0) { setbDejaSauve(false); getStPrincipal().setTitle(getStPrincipal().getTitle().replace(" *", "") + " *"); } getPanoramiquesProjet()[iNumPano].getHotspotImage(i).setOpacite(slOpacite.getValue()); }); slOpacite.setTranslateX(100); slOpacite.setPrefWidth(130); slOpacite.setMinWidth(130); slOpacite.setMaxWidth(130); vbPanneauHsImage.getChildren().addAll(lblCoulFond, cpCouleurFond, lblOpacite, slOpacite); vbHotspots.getChildren().addAll(paneHsImage, lblSep); iTaillePane += 225 + ivChoisie.getFitHeight(); paneHsImage.setPrefHeight(200 + ivChoisie.getFitHeight()); paneHsImage.setMinHeight(200 + ivChoisie.getFitHeight()); paneHsImage.setMaxHeight(200 + ivChoisie.getFitHeight()); } iNbHS += io; for (io = 0; io < getPanoramiquesProjet()[iNumPano].getNombreHotspotHTML(); io++) { Label lblSep = new Label(" "); int iNum = io; VBox vbPanneauHS = new VBox(); Pane paneHsHtml = new Pane(vbPanneauHS); Timeline timBouge = new Timeline(new KeyFrame(Duration.millis(500), (ActionEvent event) -> { Circle c1 = (Circle) panePanoramique.lookup("#html" + iNum); if (c1 != null) { if (c1.getFill() == Color.DARKGREEN) { c1.setFill(Color.YELLOWGREEN); c1.setStroke(Color.DARKGREEN); } else { c1.setFill(Color.DARKGREEN); c1.setStroke(Color.YELLOWGREEN); } } })); timBouge.setCycleCount(Timeline.INDEFINITE); timBouge.pause(); paneHsHtml.setOnMouseEntered((e) -> { timBouge.play(); }); paneHsHtml.setOnMouseExited((e) -> { timBouge.pause(); Circle c1 = (Circle) panePanoramique.lookup("#html" + iNum); if (c1 != null) { c1.setFill(Color.DARKGREEN); c1.setStroke(Color.YELLOWGREEN); } }); paneHsHtml.setStyle("-fx-border-color : #777777;-fx-border-width : 1px;-fx-border-radius : 3px;"); paneHsHtml.setId("HSHTML" + io); lblPoint = new Label("Hotspot HTML #" + (io + 1)); lblPoint.setPadding(new Insets(5, 10, 5, 5)); lblPoint.getStyleClass().add("titreOutil"); Separator sepHS = new Separator(Orientation.HORIZONTAL); sepHS.setPrefWidth(321); sepHS.setTranslateX(2); paneHsHtml.setPrefWidth(325); Label lblTexteHS = new Label(rbLocalisation.getString("main.texteHotspot")); lblTexteHS.setTranslateX(10); TextField tfTexteHS = new TextField(); if (getPanoramiquesProjet()[iNumPano].getHotspotHTML(io).getStrInfo() != null) { tfTexteHS.setText(getPanoramiquesProjet()[iNumPano].getHotspotHTML(io).getStrInfo()); } tfTexteHS.textProperty().addListener((final ObservableValue<? extends String> observable, final String oldValue, final String newValue) -> { valideHS(); }); tfTexteHS.setId("txtHSHTML" + io); tfTexteHS.setPrefSize(200, 25); tfTexteHS.setMaxSize(200, 20); tfTexteHS.setTranslateX(60); vbPanneauHS.getChildren().addAll(lblPoint, sepHS, lblTexteHS, tfTexteHS); Button btnEditeHSHTML = new Button(rbLocalisation.getString("main.editeHTML")); btnEditeHSHTML.setPrefWidth(80); btnEditeHSHTML.setTranslateX(paneHsHtml.getPrefWidth() - btnEditeHSHTML.getPrefWidth() - 10); vbPanneauHS.getChildren().addAll(btnEditeHSHTML); btnEditeHSHTML.setOnAction((e) -> { EditeurHTML editHTML = new EditeurHTML(); HotspotHTML HS = getPanoramiquesProjet()[iNumPano].getHotspotHTML(iNum); editHTML.setHsHTML(HS); Rectangle2D tailleEcran = Screen.getPrimary().getBounds(); int iHauteur = (int) tailleEcran.getHeight() - 100; int iLargeur = (int) tailleEcran.getWidth() - 100; editHTML.affiche(iLargeur, iHauteur); editHTML.addPropertyChangeListener("bValide", (ev) -> { if (ev.getNewValue().toString().equals("true")) { getPanoramiquesProjet()[iNumPano].setHotspotHTML(editHTML.getHsHTML(), iNum); dejaCharge = false; retireAffichageHotSpots(); Pane affHS1 = paneAffichageHS(strListePano(), iNumPano); affHS1.setId("labels"); vbVisuHotspots.getChildren().add(affHS1); } }); }); vbHotspots.getChildren().addAll(paneHsHtml, lblSep); paneHsHtml.setPrefHeight(120); paneHsHtml.setMinHeight(120); paneHsHtml.setMaxHeight(120); iTaillePane += 145; } iNbHS += io; for (io = 0; io < getPanoramiquesProjet()[iNumPano].getiNombreHotspotDiapo(); io++) { Label lblSep = new Label(" "); int iNum = io; VBox vbPanneauHS = new VBox(); Pane paneHsDiapo = new Pane(vbPanneauHS); Timeline timBouge = new Timeline(new KeyFrame(Duration.millis(500), (ActionEvent event) -> { Circle c1 = (Circle) panePanoramique.lookup("#dia" + iNum); if (c1 != null) { if (c1.getFill() == Color.TURQUOISE) { c1.setFill(Color.ORANGE); c1.setStroke(Color.TURQUOISE); } else { c1.setFill(Color.TURQUOISE); c1.setStroke(Color.ORANGE); } } })); timBouge.setCycleCount(Timeline.INDEFINITE); timBouge.pause(); paneHsDiapo.setOnMouseEntered((e) -> { timBouge.play(); }); paneHsDiapo.setOnMouseExited((e) -> { timBouge.pause(); Circle c1 = (Circle) panePanoramique.lookup("#html" + iNum); if (c1 != null) { c1.setFill(Color.TURQUOISE); c1.setStroke(Color.ORANGE); } }); paneHsDiapo.setStyle("-fx-border-color : #777777;-fx-border-width : 1px;-fx-border-radius : 3px;"); paneHsDiapo.setId("DIAPO" + io); lblPoint = new Label("Hotspot Diaporama #" + (io + 1)); lblPoint.setPadding(new Insets(5, 10, 5, 5)); lblPoint.getStyleClass().add("titreOutil"); Separator sepHS = new Separator(Orientation.HORIZONTAL); sepHS.setPrefWidth(321); sepHS.setTranslateX(2); paneHsDiapo.setPrefWidth(325); Label lblTexteHS = new Label(rbLocalisation.getString("main.texteHotspot")); lblTexteHS.setTranslateX(10); TextField tfTexteHS = new TextField(); if (getPanoramiquesProjet()[iNumPano].getHotspotDiapo(io).getStrInfo() != null) { tfTexteHS.setText(getPanoramiquesProjet()[iNumPano].getHotspotDiapo(io).getStrInfo()); } tfTexteHS.textProperty().addListener((final ObservableValue<? extends String> observable, final String oldValue, final String newValue) -> { valideHS(); }); tfTexteHS.setId("txtDIA" + io); tfTexteHS.setPrefSize(200, 25); tfTexteHS.setMaxSize(200, 20); tfTexteHS.setTranslateX(60); vbPanneauHS.getChildren().addAll(lblPoint, sepHS, lblTexteHS, tfTexteHS); ComboBox cbListeDiapo = new ComboBox(); for (int i = 0; i < getiNombreDiapo(); i++) { cbListeDiapo.getItems().add(diaporamas[i].getStrNomDiaporama()); } cbListeDiapo.getSelectionModel() .select(getPanoramiquesProjet()[iNumPano].getHotspotDiapo(io).getiNumDiapo()); int iii = io; cbListeDiapo.getSelectionModel().selectedIndexProperty().addListener((ov, av, nv) -> { getPanoramiquesProjet()[iNumPano].getHotspotDiapo(iii).setiNumDiapo((int) nv); }); cbListeDiapo.setTranslateX(60); vbPanneauHS.getChildren().addAll(cbListeDiapo); //Ajouter Liste Diaporamas vbHotspots.getChildren().addAll(paneHsDiapo, lblSep); paneHsDiapo.setPrefHeight(120); paneHsDiapo.setMinHeight(120); paneHsDiapo.setMaxHeight(120); iTaillePane += 145; } valideHS(); iNbHS += io; dejaCharge = true; paneHotSpots.setPrefHeight(iTaillePane); paneHotSpots.setMinHeight(iTaillePane); paneHotSpots.setMaxHeight(iTaillePane); paneHotSpots.setId("labels"); apVisuHS.setPrefHeight(paneHotSpots.getPrefHeight()); apVisuHS.setMinHeight(paneHotSpots.getPrefHeight()); apVisuHS.setMaxHeight(paneHotSpots.getPrefHeight()); vbVisuHotspots.setPrefHeight(paneHotSpots.getPrefHeight()); vbVisuHotspots.setMinHeight(paneHotSpots.getPrefHeight()); vbVisuHotspots.setMaxHeight(paneHotSpots.getPrefHeight()); return paneHotSpots; }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param iLargeur/*from ww w . j a v a 2s. co m*/ * @param iHauteur * @param bMasqueZones * @param strIdZone * @param mouseEvent */ private static void choixZone(int iLargeur, int iHauteur, boolean bMasqueZones, String strIdZone, MouseEvent mouseEvent) { ComboBox cbTouchesBarre = new ComboBox(); cbTouchesBarre.getItems().clear(); for (int i = 0; i < strTouchesBarre.length; i++) { cbTouchesBarre.getItems().add(i, strTouchesBarre[i]); } cbTouchesBarre.setLayoutX(200); cbTouchesBarre.setLayoutX(40); final int iNumeroZone = Integer.parseInt(strIdZone.split("-")[1]); if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) { if (mouseEvent.getClickCount() == 2) { for (int ij = iNumeroZone; ij < iNombreZones - 1; ij++) { zones[ij] = zones[ij + 1]; } iNombreZones--; afficheBarrePersonnalisee(iLargeur, iHauteur, bMasqueZones); } else { afficheBarrePersonnalisee(iLargeur, iHauteur, bMasqueZones); apZoneBarrePersonnalisee.getChildren().clear(); apZoneBarrePersonnalisee.getChildren().add(cbTouchesBarre); ZoneTelecommande zone = zones[iNumeroZone]; int index = -1; for (int ij = 0; ij < strCodeBarre.length; ij++) { if (strCodeBarre[ij].equals(zone.getStrIdZone())) { index = ij; } } if (index != -1) { cbTouchesBarre.getSelectionModel().select(index); } cbTouchesBarre.valueProperty().addListener((ov, ancienneValeur, nouvelleValeur) -> { if (nouvelleValeur != null) { String strId = strCodeBarre[cbTouchesBarre.getSelectionModel().getSelectedIndex()]; zones[iNumeroZone].setStrIdZone(strId); } }); Label lblTypeBarre = new Label(zone.getStrTypeZone()); lblTypeBarre.setLayoutX(20); lblTypeBarre.setLayoutY(40); Label lblCoordsBarre = new Label(zone.getStrCoordonneesZone()); lblCoordsBarre.setLayoutX(20); lblCoordsBarre.setLayoutY(70); lblCoordsBarre.setPrefWidth(260); lblCoordsBarre.setMaxWidth(260); lblCoordsBarre.setWrapText(true); apZoneBarrePersonnalisee.getChildren().addAll(lblTypeBarre, lblCoordsBarre); switch (zone.getStrTypeZone()) { case "poly": Polygon poly = (Polygon) apImgBarrePersonnalisee.lookup("#" + strIdZone); poly.setFill(Color.rgb(255, 0, 0, 0.5)); poly.setStroke(Color.YELLOW); apImgBarrePersonnalisee.getChildren() .addAll(olCreeAncresPourPolygone(iNumeroZone, poly.getPoints())); break; case "rect": Rectangle rect = (Rectangle) apImgBarrePersonnalisee.lookup("#" + strIdZone); rect.setFill(Color.rgb(255, 0, 0, 0.5)); rect.setStroke(Color.YELLOW); apImgBarrePersonnalisee.getChildren().addAll(olCreeAncresPourRectangle(iNumeroZone, rect)); break; case "circle": Circle cercle = (Circle) apImgBarrePersonnalisee.lookup("#" + strIdZone); cercle.setFill(Color.rgb(255, 0, 0, 0.5)); cercle.setStroke(Color.YELLOW); apImgBarrePersonnalisee.getChildren().addAll(olCreeAncresPourCercle(iNumeroZone, cercle)); break; } } } }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param iLargeur// w w w . j a v a2 s.com * @param iHauteur * @param bMasqueZones */ private static void ajouterZone(int iLargeur, int iHauteur, boolean bMasqueZones) { if (iNombreZones == -1) { iNombreZones = 0; } final ZoneTelecommande zone = new ZoneTelecommande(); strTypeZone = "poly"; zone.setStrTypeZone(strTypeZone); iNombrePointsZone = 0; bRecommenceZone = false; apZoneBarrePersonnalisee.getChildren().clear(); Button btnAnnuler = new Button(rbLocalisation.getString("main.annuler"), new ImageView(new Image("file:" + getStrRepertAppli() + "/images/annule.png"))); Button btnValider = new Button(rbLocalisation.getString("main.valider"), new ImageView(new Image("file:" + getStrRepertAppli() + "/images/valide.png"))); btnValider.setLayoutX(180); btnValider.setLayoutY(170); btnAnnuler.setLayoutX(80); btnAnnuler.setLayoutY(170); ToggleGroup tgTypeZone = new ToggleGroup(); Label lblTypeZone = new Label(rbLocalisation.getString("main.typeZone")); lblTypeZone.setLayoutX(20); lblTypeZone.setLayoutY(10); RadioButton rbCercleZone = new RadioButton(rbLocalisation.getString("main.cercle")); rbCercleZone.setLayoutX(20); rbCercleZone.setLayoutY(40); rbCercleZone.setUserData("circle"); rbCercleZone.setToggleGroup(tgTypeZone); RadioButton rbRectZone = new RadioButton(rbLocalisation.getString("main.rectangle")); rbRectZone.setLayoutX(120); rbRectZone.setLayoutY(40); rbRectZone.setUserData("rect"); rbRectZone.setToggleGroup(tgTypeZone); RadioButton rbPolyZone = new RadioButton(rbLocalisation.getString("main.polygone")); rbPolyZone.setLayoutX(220); rbPolyZone.setLayoutY(40); rbPolyZone.setUserData("poly"); rbPolyZone.setToggleGroup(tgTypeZone); rbPolyZone.setSelected(true); ComboBox cbTouchesBarre = new ComboBox(); cbTouchesBarre.getItems().clear(); for (int i = 0; i < strTouchesBarre.length; i++) { cbTouchesBarre.getItems().add(i, strTouchesBarre[i]); } cbTouchesBarre.setLayoutX(50); cbTouchesBarre.setLayoutY(110); afficheBarrePersonnalisee(iLargeur, iHauteur, bMasqueZones); AnchorPane apCreeZone = new AnchorPane(); apCreeZone.setStyle("-fx-background-color : rgba(0,0,0,0.1)"); apCreeZone.setPrefWidth(imgBarrePersonnalisee.getWidth()); apCreeZone.setPrefHeight(imgBarrePersonnalisee.getHeight()); apCreeZone.setCursor(Cursor.CROSSHAIR); apImgBarrePersonnalisee.getChildren().add(apCreeZone); apZoneBarrePersonnalisee.getChildren().addAll(lblTypeZone, rbCercleZone, rbRectZone, rbPolyZone, cbTouchesBarre, btnAnnuler, btnValider); apCreeZone.setOnMouseClicked((t) -> { rbCercleZone.setDisable(true); rbRectZone.setDisable(true); rbPolyZone.setDisable(true); iNombrePointsZone++; switch (strTypeZone) { case "rect": if (iNombrePointsZone == 1) { apCreeZone.getChildren().clear(); x1Zone = t.getX(); y1Zone = t.getY(); Circle cercle = new Circle(t.getX(), t.getY(), 4); cercle.setFill(Color.rgb(255, 0, 0, 0.5)); cercle.setStroke(Color.YELLOW); apCreeZone.getChildren().add(cercle); } if (iNombrePointsZone == 2) { apCreeZone.getChildren().clear(); Rectangle rect = new Rectangle(x1Zone, y1Zone, t.getX() - x1Zone, t.getY() - y1Zone); rect.setFill(Color.rgb(255, 0, 0, 0.5)); rect.setStroke(Color.YELLOW); apCreeZone.getChildren().add(rect); String chaine = Math.round(x1Zone * 10) / 10 + "," + Math.round(y1Zone * 10) / 10 + "," + Math.round(t.getX() * 10) / 10 + "," + Math.round(t.getY() * 10) / 10; zone.setStrCoordonneesZone(chaine); iNombrePointsZone = 0; } break; case "circle": if (iNombrePointsZone == 1) { apCreeZone.getChildren().clear(); x1Zone = t.getX(); y1Zone = t.getY(); Circle cercle = new Circle(t.getX(), t.getY(), 4); cercle.setFill(Color.rgb(255, 0, 0, 0.5)); cercle.setStroke(Color.YELLOW); apCreeZone.getChildren().add(cercle); } if (iNombrePointsZone == 2) { apCreeZone.getChildren().clear(); double rayon = Math.sqrt(Math.pow(x1Zone - t.getX(), 2.d) + Math.pow(y1Zone - t.getY(), 2.d)); Circle cercle = new Circle(x1Zone, y1Zone, rayon); cercle.setFill(Color.rgb(255, 0, 0, 0.5)); cercle.setStroke(Color.YELLOW); apCreeZone.getChildren().add(cercle); String chaine = Math.round(x1Zone * 10) / 10 + "," + Math.round(y1Zone * 10) / 10 + "," + Math.round(rayon * 10) / 10; zone.setStrCoordonneesZone(chaine); iNombrePointsZone = 0; } break; case "poly": if (bRecommenceZone) { bRecommenceZone = false; iNombrePointsZone = 1; } if (iNombrePointsZone == 1) { apCreeZone.getChildren().clear(); x1Zone = t.getX(); y1Zone = t.getY(); Circle cercle = new Circle(t.getX(), t.getY(), 4); cercle.setFill(Color.rgb(255, 0, 0, 0.5)); cercle.setStroke(Color.YELLOW); apCreeZone.getChildren().add(cercle); pointsPolyZone[(iNombrePointsZone - 1) * 2] = t.getX(); pointsPolyZone[(iNombrePointsZone - 1) * 2 + 1] = t.getY(); } if (iNombrePointsZone == 2) { apCreeZone.getChildren().clear(); Line ligne = new Line(x1Zone, y1Zone, t.getX(), t.getY()); ligne.setStroke(Color.YELLOW); apCreeZone.getChildren().add(ligne); pointsPolyZone[(iNombrePointsZone - 1) * 2] = t.getX(); pointsPolyZone[(iNombrePointsZone - 1) * 2 + 1] = t.getY(); } if (iNombrePointsZone > 2) { pointsPolyZone[(iNombrePointsZone - 1) * 2] = t.getX(); pointsPolyZone[(iNombrePointsZone - 1) * 2 + 1] = t.getY(); apCreeZone.getChildren().clear(); Polygon poly = new Polygon(); for (int i = 0; i < iNombrePointsZone; i++) { poly.getPoints().addAll(pointsPolyZone[i * 2], pointsPolyZone[i * 2 + 1]); } poly.setFill(Color.rgb(255, 0, 0, 0.5)); poly.setStroke(Color.YELLOW); apCreeZone.getChildren().add(poly); } if (t.getClickCount() == 2) { String chaine = ""; for (int i = 0; i < iNombrePointsZone; i++) { if (i != 0) { chaine += ","; } chaine += Math.round(pointsPolyZone[i * 2] * 10) / 10 + "," + Math.round(pointsPolyZone[i * 2 + 1] * 10) / 10; } zone.setStrCoordonneesZone(chaine); bRecommenceZone = true; } break; } }); apCreeZone.setOnMouseMoved((t) -> { switch (strTypeZone) { case "rect": if (iNombrePointsZone == 1) { apCreeZone.getChildren().clear(); Rectangle rect = new Rectangle(x1Zone, y1Zone, t.getX() - x1Zone, t.getY() - y1Zone); rect.setFill(Color.rgb(255, 0, 0, 0.5)); rect.setStroke(Color.YELLOW); apCreeZone.getChildren().add(rect); } break; case "circle": if (iNombrePointsZone == 1) { apCreeZone.getChildren().clear(); double rayon = Math.sqrt(Math.pow(x1Zone - t.getX(), 2.d) + Math.pow(y1Zone - t.getY(), 2.d)); Circle cercle = new Circle(x1Zone, y1Zone, rayon); cercle.setFill(Color.rgb(255, 0, 0, 0.5)); cercle.setStroke(Color.YELLOW); apCreeZone.getChildren().add(cercle); } break; case "poly": if (!bRecommenceZone) { if (iNombrePointsZone == 1) { apCreeZone.getChildren().clear(); Line ligne = new Line(x1Zone, y1Zone, t.getX(), t.getY()); ligne.setStroke(Color.YELLOW); apCreeZone.getChildren().add(ligne); } if (iNombrePointsZone > 1) { apCreeZone.getChildren().clear(); Polygon poly = new Polygon(); for (int i = 0; i < iNombrePointsZone; i++) { poly.getPoints().addAll(pointsPolyZone[i * 2], pointsPolyZone[i * 2 + 1]); } poly.getPoints().addAll(t.getX(), t.getY()); poly.setFill(Color.rgb(255, 0, 0, 0.5)); poly.setStroke(Color.YELLOW); apCreeZone.getChildren().add(poly); } } break; } }); btnValider.setOnMouseClicked((t) -> { if (strTypeZone.equals("poly")) { String strChaine = ""; for (int i = 0; i < iNombrePointsZone; i++) { if (i != 0) { strChaine += ","; } strChaine += Math.round(pointsPolyZone[i * 2] * 10) / 10 + "," + Math.round(pointsPolyZone[i * 2 + 1] * 10) / 10; } zone.setStrCoordonneesZone(strChaine); } zones[iNombreZones] = zone; iNombreZones++; afficheBarrePersonnalisee(iLargeur, iHauteur, bMasqueZones); btnAjouteZone.setDisable(false); }); btnAnnuler.setOnMouseClicked((t) -> { afficheBarrePersonnalisee(iLargeur, iHauteur, bMasqueZones); btnAjouteZone.setDisable(false); }); cbTouchesBarre.valueProperty().addListener((ov, strAncienneValeur, strNouvelleValeur) -> { if (strNouvelleValeur != null) { String strId = strCodeBarre[cbTouchesBarre.getSelectionModel().getSelectedIndex()]; zone.setStrIdZone(strId); } }); tgTypeZone.selectedToggleProperty() .addListener((ObservableValue<? extends Toggle> ov, Toggle old_toggle, Toggle new_toggle) -> { if (tgTypeZone.getSelectedToggle() != null) { strTypeZone = tgTypeZone.getSelectedToggle().getUserData().toString(); zone.setStrTypeZone(strTypeZone); } }); }