@Override protected ObservableList<Wordnet> call() throws Exception { // using executorService to ensure that database upload is a background // progress, so that all the parsing and comparing is done, while // database upload is probably still running. only supposed to run one // uploading process at a time, the // rest is in queue. ExecutorService executor = new ThreadPoolExecutor( 1, 1, 10, TimeUnit.HOURS, new ArrayBlockingQueue<Runnable>(inList.size(), true)); for (int i = 0; i < inList.size(); i++) { WordnetParser rspParser = chosenParser.getClass().newInstance(); rspParser.setSourcePath(inList.get(i).getAbsolutePath()); Wordnet wordnet = rspParser.callCall(); // System.out.println(getProgress() + (1.0 / (double) // inList.size()) + " / " + "1" + "\n"); // updateProgress(1/i, 1); //TODO reimplement progressbar // Platform.runLater(new Runnable() { // // @Override // public void run() { partialResults.get().add(wordnet); if (exportXml) Output.outToFileXmlFile( wordnet.getSynsetList(), wordnet.getLang(), "D:\\Programmierung\\git repo\\wdntxml\\out"); if (outData) { // add database-upload-process to executorService executor.submit( new Runnable() { @Override public void run() { try { Output.outToDB( wordnet, dbUrl, dbUser, dbPassword, dbPort, sshUser, sshPassword, sshPort); progress++; updateProgress(((double) progress) / ((double) maxProgress), 1); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); } } return getPartialResults(); }
// wyœwietla wszystkie albumy private void drawAlbums() { for (int i = 0; i < albumList.size(); i++) { VBox vBox = new VBox(5); // ok³adka albumu Song tempSong = new Song(albumList.get(i).albumSongList.get(0)); ImageView albumCover = new ImageView(tempSong.getAlbumCover()); albumCover.setFitWidth(130); albumCover.setPreserveRatio(true); albumCover.setSmooth(true); albumCover.imageProperty().bind(tempSong.albumCoverProperty()); // tytu³ albumu Text albumTitle = new Text(albumList.get(i).getAlbumTitle()); albumTitle.getStyleClass().add("text"); vBox.getChildren().addAll(albumCover, albumTitle); vBox.setAlignment(Pos.CENTER); // dodaje do ka¿dego albumu listener którym otwiera listê z piosenkami vBox.setOnMouseClicked( e -> { Text tempText = (Text) vBox.getChildren().get(1); for (int j = 0; j < albumList.size(); j++) { if (albumList.get(j).getAlbumTitle().equals(tempText.getText())) { showCurrentAlbum(albumList.get(j)); break; } } }); flowPane.getChildren().add(vBox); } }
private final void defineStretching() { //////////// give resizing hints ObservableList<RowConstraints> rows = getRowConstraints(); logger.info("original row constraints size" + rows.size()); RowConstraints rc; rc = new RowConstraints(); // rc.setPercentHeight( 0 ); rc.setVgrow(Priority.NEVER); rc.setMinHeight(StaticConst.GU); rows.add(rc); rc = new RowConstraints(); // rc.setPercentHeight( 100 ); rc.setVgrow(Priority.ALWAYS); rows.add(rc); rc = new RowConstraints(); // rc.setPercentHeight( 0 ); rc.setVgrow(Priority.NEVER); rows.add(rc); ObservableList<ColumnConstraints> ccs = getColumnConstraints(); logger.info("original column constraints size" + ccs.size()); ColumnConstraints cc; cc = new ColumnConstraints(); cc.setHgrow(Priority.ALWAYS); ccs.add(cc); }
private void setupStageLocation(Stage stage) { ObservableList<Screen> screens = Screen.getScreens(); Screen screen = screens.size() <= screenNumber ? Screen.getPrimary() : screens.get(screenNumber); Rectangle2D bounds = screen.getBounds(); boolean primary = screen.equals( Screen.getPrimary()); // WORKAROUND: this doesn't work nice in combination with full // screen, so this hack is used to prevent going fullscreen when // screen is not primary if (primary) { stage.setX(bounds.getMinX()); stage.setY(bounds.getMinY()); stage.setWidth(bounds.getWidth()); stage.setHeight(bounds.getHeight()); stage.setFullScreen(true); } else { stage.setX(bounds.getMinX()); stage.setY(bounds.getMinY()); stage.setWidth(bounds.getWidth()); stage.setHeight(bounds.getHeight()); stage.toFront(); } }
public static boolean writeFile(ObservableList<XYChart.Data> list, String path) throws FileNotFoundException { try { boolean newFile = false; File file = new File(path); System.out.println(file.exists()); newFile = file.createNewFile(); System.out.println(newFile); System.out.println(file.exists()); PrintWriter printWriter; try { printWriter = new PrintWriter(new FileOutputStream(file)); for (int i = 0; i < list.size(); i++) { String x = list.get(i).getXValue().toString(); String y = list.get(i).getYValue().toString(); String line = x + "\t" + y; printWriter.println(line); } printWriter.close(); } catch (Exception ex) { return false; } } catch (IOException ex) { return false; } return true; }
/** Sanity? Removing last child throws IOOB if selected */ @Test public void testSelectedRemoveLast() { int lastIndex = rawItems.size() - 1; TreeItem lastChild = (TreeItem) getRootChildren().get(lastIndex); getSelectionModel().select(lastChild); getRootChildren().remove(lastChild); }
@FXML public void ok() { ObservableList<UITableColumnVO> items = columnListView.getItems(); if (items != null && items.size() > 0) { List<IgnoredColumn> ignoredColumns = new ArrayList<>(); List<ColumnOverride> columnOverrides = new ArrayList<>(); items .stream() .forEach( item -> { if (!item.getChecked()) { IgnoredColumn ignoredColumn = new IgnoredColumn(item.getColumnName()); ignoredColumns.add(ignoredColumn); } else if (item.getTypeHandle() != null || item.getJavaType() != null || item.getPropertyName() != null) { // unchecked and have typeHandler value ColumnOverride columnOverride = new ColumnOverride(item.getColumnName()); columnOverride.setTypeHandler(item.getTypeHandle()); columnOverride.setJavaProperty(item.getPropertyName()); columnOverride.setJavaType(item.getJavaType()); columnOverrides.add(columnOverride); } }); mainUIController.setIgnoredColumns(ignoredColumns); mainUIController.setColumnOverrides(columnOverrides); } getDialogStage().close(); }
// wyœwietla wszystkie playlisty private void drawPlaylists() { for (int i = 0; i < playlistList.size(); i++) { VBox vBox = new VBox(5); ImageView playlistCover = new ImageView(new Image(new File("temp_cover.png").toURI().toString())); playlistCover.setFitWidth(130); playlistCover.setPreserveRatio(true); playlistCover.setSmooth(true); int ext = playlistList.get(i).getName().lastIndexOf('.'); Text playlistTitle = new Text(playlistList.get(i).getName().substring(0, ext)); playlistTitle.getStyleClass().add("text"); vBox.getChildren().addAll(playlistCover, playlistTitle); vBox.setAlignment(Pos.CENTER); vBox.setOnMouseClicked( e -> { Text tempText = (Text) vBox.getChildren().get(1); showCurrentPlaylist(new File("Playlists/" + tempText.getText() + ".fpl")); }); flowPane.getChildren().add(vBox); } }
@Override public Music getMusic(int nr) { if (nr < 0 || nr >= music.size()) { return null; } return music.get(nr); }
// ******************** Misc ********************************************** private static void calcNoOfNodes(Node node) { if (node instanceof Parent) { if (((Parent) node).getChildrenUnmodifiable().size() != 0) { ObservableList<Node> tempChildren = ((Parent) node).getChildrenUnmodifiable(); noOfNodes += tempChildren.size(); tempChildren.forEach(n -> calcNoOfNodes(n)); } } }
@Test public void getNext3() throws Exception { ObservableList<Appointment> appointments = AppointmentHelper.getNextAppointments(3); assertEquals(3, appointments.size()); assertEquals(a0.getId(), appointments.get(0).getId()); }
private void detectScreen() { Screen screen = Screen.getPrimary(); ObservableList<Screen> screens = Screen.getScreens(); Integer screenId = main.getConfig().get(PainelConfig.KEY_MONITOR_ID, Integer.class).getValue(); if (screenId > 0 && screens.size() > screenId) { screen = screens.get(screenId); } display = new Display(screen); }
private int getIndexOfComponentInParent(Node component) { Parent parent = component.getParent(); if (parent == null) return -1; ObservableList<Node> components = parent.getChildrenUnmodifiable(); for (int i = 0; i < components.size(); i++) { if (components.get(i) == component) return i; } return -1; }
private void cleanUpRepeatingFramesAndValues() { ObservableList<KeyFrame> timelineKeyFrames = timeline.getKeyFrames().sorted(new KeyFrameComparator()); // Timeline timeline; int kfTotal = timelineKeyFrames.size(), kfRemoved = 0; int kvTotal = 0, kvRemoved = 0; Map<Duration, KeyFrame> kfUnique = new HashMap<>(); Map<WritableValue, KeyValue> kvUnique = new HashMap<>(); MapOfLists<KeyFrame, KeyFrame> duplicates = new MapOfLists<>(); Iterator<KeyFrame> iterator = timelineKeyFrames.iterator(); while (iterator.hasNext()) { KeyFrame duplicate = iterator.next(); KeyFrame original = kfUnique.put(duplicate.getTime(), duplicate); if (original != null) { kfRemoved++; iterator.remove(); // removing duplicate keyFrame duplicates.add(original, duplicate); kfUnique.put(duplicate.getTime(), original); } kvUnique.clear(); for (KeyValue kvDup : duplicate.getValues()) { kvTotal++; KeyValue kvOrig = kvUnique.put(kvDup.getTarget(), kvDup); if (kvOrig != null) { kvRemoved++; if (!kvOrig.getEndValue().equals(kvDup.getEndValue()) && kvOrig.getTarget() == kvDup.getTarget()) { System.err.println( "KeyValues set different values for KeyFrame " + duplicate.getTime() + ":" + "\n kvOrig = " + kvOrig + ", \nkvDup = " + kvDup); } } } } for (KeyFrame orig : duplicates.keySet()) { List<KeyValue> keyValues = new ArrayList<>(); for (KeyFrame dup : duplicates.get(orig)) { keyValues.addAll(dup.getValues()); } timelineKeyFrames.set( timelineKeyFrames.indexOf(orig), new KeyFrame(orig.getTime(), keyValues.toArray(new KeyValue[keyValues.size()]))); } System.out.printf( "Removed %d (%.2f%%) duplicate KeyFrames out of total %d.\n", kfRemoved, 100d * kfRemoved / kfTotal, kfTotal); System.out.printf( "Identified %d (%.2f%%) duplicate KeyValues out of total %d.\n", kvRemoved, 100d * kvRemoved / kvTotal, kvTotal); }
public void deleteMarker(Waypoint point) { int listSize = waypointList.size(); for (int index = 0; index < listSize; index++) { Waypoint current = waypointList.get(index); if (current.getPointNo() == point.getPointNo()) { waypointList.remove(index); break; } } }
/** * Creates a translation part of word card, it corresponds to one meaning. * * @return true if there are any translations in this translation block. */ public boolean create(Connect conn, TTranslation _ttranslation, TLang _lang) { meaning_summary = _ttranslation.getMeaningSummary(); TTranslationEntry[] trans_entries = TTranslationEntry.getByTranslation(conn, _ttranslation); // System.out.println("WCTranslation.create() _lang=" + _lang.getLanguage().toString() + "; // trans_entries.length=" + trans_entries); List<TranslationEntryItem> data_trans = new ArrayList(); // listview_trans.items length =" + trans_entries.length); trans_entry_items_size = trans_entries.length; // trans_entry_items = new TranslationEntryItem[trans_entries.length]; for (int i = 0; i < trans_entries.length; i++) { TTranslationEntry e = trans_entries[i]; LanguageType l = e.getLang().getLanguage(); String lang_name_value = l.getName(); String lang_code_value = l.getCode(); String translation_text = e.getWikiText().getText(); TranslationEntryItem item = new TranslationEntryItem(); item.create(lang_name_value, lang_code_value, translation_text); data_trans.add(item); } // TranslationEntryItem[] trans_entry_items = data_trans.toArray(); // insert trans_entry_items into listview_trans.items; ObservableList<TranslationEntryItem> data = FXCollections.observableArrayList(data_trans); listview_trans.setCellFactory( new Callback< ListView<wiwordik.word_card.TranslationEntryItem>, ListCell<wiwordik.word_card.TranslationEntryItem>>() { @Override public ListCell<wiwordik.word_card.TranslationEntryItem> call( ListView<wiwordik.word_card.TranslationEntryItem> list) { return new wiwordik.word_card.TranslationCell(); } }); listview_trans.setItems(data); setMinMaxTranslationBoxHeight(listview_trans, data.size()); // GUI right - indent for translation list words // top right bottom left group.setPadding(new Insets(0, 20, 0, 0)); Text t_meaning_summary = new Text(); t_meaning_summary.setText(meaning_summary); group.getChildren().addAll(t_meaning_summary); group.getChildren().addAll(listview_trans); return trans_entries.length > 0; }
// Сохранение в базу данных public static void setList(ObservableList<ContructorViewer> list) { if (list.size() == contructorsDB.size()) { for (int i = 0; i < list.size(); i++) { contructorsDB.get(i).setName(list.get(i).getName()); } contructorsDB.forEach(contructor -> contrImpl.update(contructor)); } else { List<Contructor> contructorsDBNEW = new ArrayList<Contructor>(); list.forEach( new Consumer<ContructorViewer>() { @Override public void accept(ContructorViewer contr) { // TODO Auto-generated method stub contructorsDBNEW.add(new Contructor(contr.getName())); } }); contructorsDB.forEach(contructor -> contrImpl.delete(contructor)); contructorsDBNEW.forEach(contructor -> contrImpl.create(contructor)); } }
/** * Test notification on setAll if there are already set indices. Changed implementation due to * RT-39776, test assumption incorrect. */ @Test public void testSetAllNotificationIfHasSet() { int[] indices = new int[] {3, 5, 1}; indicesList.addIndices(indices); report.clear(); indicesList.setAllIndices(); // report.prettyPrint(); assertEquals(items.size(), indicesList.size()); assertEquals(1, report.getEventCount()); Change c = report.getLastChange(); assertEquals(4, getChangeCount(c, ChangeType.ADDED)); }
public void addTab(Tab tab, boolean closable) { // new RuntimeException().printStackTrace(); Platform.runLater( () -> { final ObservableList<Tab> tabs = getTabs(); tab.setClosable(closable); int index = tabs.size() - 1; // new RuntimeException().printStackTrace(); tabs.add(index, tab); setSelectedTab(tab); }); }
/** * Regression testing: SelectedItems contains null after removing unselected grandParent of * selectedItem https://javafx-jira.kenai.com/browse/RT-38334 * * <p>This is the exact replication of the bug report: grandParent is last */ @Test public void testSelectedItemsOnRemoveGrandParentOfSelectedItemIfLast_38334() { TreeItem grandParent = createBranch("grandParent", true); TreeItem childWithSelection = createBranch("selected", true); grandParent.getChildren().add(childWithSelection); TreeItem selected = (TreeItem) childWithSelection.getChildren().get(0); int lastIndex = rawItems.size() - 1; TreeItem oldFirst = (TreeItem) getRootChildren().get(lastIndex); getRootChildren().add(grandParent); getSelectionModel().select(selected); getRootChildren().remove(grandParent); assertEquals("sibling of removed selected", oldFirst, getSelectedItem()); assertEquals("selectedItems contain sibling", oldFirst, getSelectedItems().get(0)); }
private void onListChanged() { Log.traceCall(); list.clear(); list.addAll( tradeManager .getTrades() .stream() .map(PendingTradesListItem::new) .collect(Collectors.toList())); // we sort by date, earliest first list.sort((o1, o2) -> o2.getTrade().getDate().compareTo(o1.getTrade().getDate())); // TODO improve selectedItem handling // selectedItem does not get set to null if we dont have the view visible // So if the item gets removed form the list, and a new item is added we need to check if the // old // selectedItem is in the new list, if not we know it is an invalid one if (list.size() == 1) onSelectTrade(list.get(0)); else if (list.size() > 1 && (selectedItem == null || !list.contains(selectedItem))) onSelectTrade(list.get(0)); else if (list.size() == 0) onSelectTrade(null); }
// Adding functionality to the forward button public String goForward() { final WebHistory history = browser.getEngine().getHistory(); ObservableList<WebHistory.Entry> entryList = history.getEntries(); int currentIndex = history.getCurrentIndex(); Platform.runLater(() -> history.go(1)); if (currentIndex < entryList.size() - 2) { entryList.get(currentIndex + 1); forwardButton.setDisable(false); } else { entryList.get(history.getCurrentIndex()); forwardButton.setDisable(true); backButton.setDisable(false); } return entryList.get(currentIndex).getUrl(); }
@Test public void testSelectedOnExpandedGrandBranchCollapsed() { TreeItem childBranch = createBranch("expandedChild", true); TreeItem grandChildBranch = createBranch("expandedGrandChild", true); childBranch.getChildren().add(0, grandChildBranch); TreeItem selected = (TreeItem) grandChildBranch.getChildren().get(rawItems.size() - 1); getRootChildren().add(0, childBranch); getSelectionModel().select(selected); TreeItem selectedItem = getSelectedItems().get(0); assertEquals(selectedItem, getSelectedItems().get(0)); assertEquals(selectedItem, getSelectedItem()); grandChildBranch.setExpanded(false); assertEquals("selected items size", 1, getSelectedItems().size()); assertEquals(grandChildBranch, getSelectedItem()); // assertEquals(index, getSelectionModel().getSelectedIndex()); // assertEquals(index, getSelectionModel().getSelectedIndices().get(0).intValue()); }
/** Mètode que canvia la llista que es mostra per pantalla */ public void setData(String city, int units) { data.remove(1, data.size()); File inputFile = new File(city + units + ".xml"); try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(inputFile); // És important normalitzar doc.getDocumentElement().normalize(); NodeList nl = doc.getElementsByTagName("time"); temp = new Temps(); TempUnitari tempU = null; for (int i = 0; i < nl.getLength(); i++) { tempU = new TempUnitari(); Element temps = (Element) nl.item(i); String[] horari = temps.getAttribute("day").split("-"); String diaVista = horari[2] + "/" + horari[1]; String descripcio = temps.getFirstChild().getAttributes().getNamedItem("name").getTextContent(); String icon = temps.getFirstChild().getAttributes().getNamedItem("var").getTextContent() + "#"; Element temperatura = (Element) temps.getChildNodes().item(4); String tempMin = temperatura.getAttribute("min"); String tempMax = temperatura.getAttribute("max"); Element humitat = (Element) temps.getChildNodes().item(6); String humidity = humitat.getAttribute("value"); Element presio = (Element) temps.getChildNodes().item(5); String pressure = presio.getAttribute("value"); tempU.setTempsMin(Double.parseDouble(tempMin)); tempU.setTempsMax(Double.parseDouble(tempMax)); tempU.setHumidity(Integer.parseInt(humidity)); tempU.setPressure(Double.parseDouble(pressure)); temp.add(tempU); // afegir el String al observableList per a que el mostri el listView data.add(icon + diaVista + "\t-\t" + descripcio + "\t-\t" + tempMin + "/" + tempMax); } } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
protected String supportedFreq(ObservableList<? extends String> list) { final StringBuilder sb = new StringBuilder(); if (list != null) { for (int i = 0, max = list.size(); i < max; i++) { sb.append(list.get(i)); if (i < max - 1) { sb.append(","); } } } final String str = sb.toString(); return str; }
protected List<IJavaFXElement> found(List<IJavaFXElement> pElements, IJavaFXAgent driver) { List<IJavaFXElement> r = new ArrayList<IJavaFXElement>(); for (IJavaFXElement je : pElements) { Node component = je.getComponent(); if (!(component instanceof Parent)) continue; int index = getIndexOfComponentInParent(component); if (index < 0) continue; Parent parent = component.getParent(); JFXWindow topContainer = driver.switchTo().getTopContainer(); ObservableList<Node> children = parent.getChildrenUnmodifiable(); for (int i = index + 1; i < children.size(); i++) { Node c = children.get(i); IJavaFXElement je2 = JavaFXElementFactory.createElement(c, driver, driver.switchTo().getTopContainer()); if (sibling.matchesSelector(je2).size() > 0) { IJavaFXElement e = topContainer.addElement(JavaFXElementFactory.createElement(c, driver, topContainer)); if (!r.contains(e)) r.add(e); } } } return r; }
@Override public void initialize(URL url, ResourceBundle rb) { Sql.loadSql(); total.setText("$" + expenseTotal); name.setCellValueFactory(new PropertyValueFactory<Expense, String>("name")); name.setCellFactory(TextFieldTableCell.<String>forTableColumn()); vendor.setCellValueFactory(new PropertyValueFactory<Expense, String>("vendor")); vendor.setCellFactory(TextFieldTableCell.<String>forTableColumn()); date.setCellValueFactory(new PropertyValueFactory<Expense, String>("date")); date.setCellFactory(TextFieldTableCell.<String>forTableColumn()); cost.setCellValueFactory(new PropertyValueFactory<Expense, Double>("cost")); cost.setCellFactory( TextFieldTableCell.forTableColumn( new StringConverter<Double>() { @Override public String toString(Double object) { return object.toString(); } @Override public Double fromString(String string) { return Double.parseDouble(string); } })); add.setOnAction(e -> Action.addExpense()); delete.setOnAction(e -> Action.deleteExpense()); if (tableList.size() > 0) emptyLabel.setText(""); table.setItems(tableList); pieChart.setData(pieChartList); }
public static DefaultBoxAndWhiskerCategoryDataset getDatasetForBoxAndWhiskers( ObservableList<EvaluationHelper> allEvaluationHelper, ArrayList<Bereich> bereiche) { int categoryCount = bereiche.size(); int entityCount = allEvaluationHelper.size(); final DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); for (int j = 0; j < categoryCount; j++) { final List<Double> list = new ArrayList<Double>(); for (int k = 0; k < entityCount; k++) { int valCount = 0; double avValue = 0; for (Item item : allEvaluationHelper.get(k).getItems()) { if (bereiche.get(j).equals(item.getBereich())) { if (!allEvaluationHelper.get(k).getItemWertung().get(valCount).isEmpty()) { avValue += Double.parseDouble(allEvaluationHelper.get(k).getItemWertung().get(valCount)); } valCount++; } } if (valCount != 0) { avValue /= valCount; } list.add(new Double(avValue)); } dataset.add( list, SeCatResourceBundle.getInstance().getString("scene.chart.all.averagevalues"), bereiche.get(j).getName()); } return dataset; }
public ReadInTask2( ObservableList<File> inList, String dbUrl, String dbUser, String dbPassword, WordnetParser chosenParser, boolean exportXml, int dbPort, String sshUser, String sshPassword, int sshPort) { this(inList, chosenParser, exportXml); this.dbUrl = dbUrl; this.dbUser = dbUser; this.dbPassword = dbPassword; this.outData = true; this.dbPort = dbPort; this.sshUser = sshUser; this.sshPassword = sshPassword; this.sshPort = sshPort; maxProgress = inList.size(); }
public void handleMoveSegmentTo(ActionEvent actionEvent) { try { FXMLLoader loader = new FXMLLoader(getClass().getResource("/com/view/moveSegmentPopup.fxml")); AnchorPane pane = (AnchorPane) loader.load(); Stage dialogStage = new Stage(); dialogStage.setTitle("Move selected segment to track"); dialogStage.initModality(Modality.WINDOW_MODAL); dialogStage.initOwner(Main.primaryStage); Scene scene = new Scene(pane); dialogStage.setScene(scene); MoveSegmentPopupController controller = loader.getController(); controller.setDialogStage(dialogStage); dialogStage.showAndWait(); if (controller.isOkClicked()) { int beat = controller.getBeat(); String trackName = controller.getTrack(); ObservableList<Node> tracksList = Controller.getComposeAreaVBox().getChildren(); for (int i = 0; i < tracksList.size(); i++) { TrackController track = (TrackController) tracksList.get(i); if (track.nameProperty().getValue().equals(trackName)) { Rectangle rectangle = (Rectangle) track.getTrackBeats().getChildren().get(beat - 1); MusicSegmentController newSegment = new MusicSegmentController(this.name, this.length, this.width, this.audioPath); newSegment.setLayoutX(rectangle.getLayoutX()); newSegment.setLayoutY(i * 55 + 6); Controller.anchorPaneComposition.getChildren().add(newSegment); } } } } catch (IOException ex) { ex.printStackTrace(); } }