@Override public ReadOnlyIntegerProperty preloadMapTiles(double minLatitude, double maxLatitude, double minLongitude, double maxLongitude) { ReadOnlyIntegerWrapper remainingCount = new ReadOnlyIntegerWrapper(); int minX = getTileX(minLongitude, ZOOM); int maxX = getTileX(maxLongitude, ZOOM); int minY = getTileY(minLatitude, ZOOM); int maxY = getTileY(maxLatitude, ZOOM); int totalCount = (maxX-minX+1)*(maxY-minY+1); if (totalCount > MAX_TILES) { throw new IllegalArgumentException("The number of tiles required ("+totalCount+") is greater than the maximum allowed ("+MAX_TILES+")"); } int remaining = 0; for (int x = minX; x <= maxX; x++) { for (int y = minY; y <= maxY; y++) { File f = getCacheFile(ZOOM, x, y); if (!f.exists()) { remaining++; fetchAndStoreTile(remainingCount, ZOOM, x, y); } } } remainingCount.set(remaining); return remainingCount; }
@SuppressWarnings("unchecked") @Override public void set(Consumer<Object> dispatcher, Object node, String name, VProperty vProperty) { if(! (node instanceof TabPane)) { throw new IllegalStateException("Trying to set selectionModel of node " + node); } final TabPane tabPane = (TabPane) node; final ReadOnlyIntegerProperty selectedIndexProperty = tabPane.getSelectionModel().selectedIndexProperty(); clearListeners(node, selectedIndexProperty); if (vProperty.isValueDefined()) { tabPane.getSelectionModel().select((int) vProperty.getValue()); } if(vProperty.getChangeListener().isDefined()) { setChangeListener(dispatcher, node, selectedIndexProperty, vProperty.getChangeListener().get()); } if(vProperty.getInvalidationListener().isDefined()) { setInvalidationListener(dispatcher, node, selectedIndexProperty, vProperty.getInvalidationListener().get()); } }
private void bindPossibleScoringButtons() { ReadOnlyIntegerProperty selectedIndex = this.tablePossibleScores .getSelectionModel().selectedIndexProperty(); ReadOnlyObjectProperty<PossibleScoring> selectedItem = this.tablePossibleScores .getSelectionModel().selectedItemProperty(); // only enable move-up button if an item other than the topmost is // selected this.buttonMoveScoreUp.disableProperty().bind( selectedIndex.isEqualTo(0).or(selectedItem.isNull())); // only enable move-down button if an item other than the last one is // selected // index < size - 1 && selected != null this.buttonMoveScoreDown.disableProperty().bind( selectedIndex.greaterThanOrEqualTo( Bindings.size(this.tablePossibleScores.getItems()) .subtract(1)).or(selectedItem.isNull())); // only enable remove button if an item is selected this.buttonRemoveScore.disableProperty().bind(selectedItem.isNull()); // only enable edit button if an item is selected this.buttonEditScore.disableProperty().bind(selectedItem.isNull()); }
@Test public void widthProperty() { assertEpsilonEquals(10, this.shape.getWidth()); ReadOnlyIntegerProperty property = this.shape.widthProperty(); assertNotNull(property); assertEpsilonEquals(10, property.get()); this.shape.setMinX(7); assertEpsilonEquals(8, property.get()); this.shape.setMinX(-5); assertEpsilonEquals(20, property.get()); this.shape.setMaxX(0); assertEpsilonEquals(5, property.get()); }
@Test public void heightProperty() { assertEpsilonEquals(5, this.shape.getHeight()); ReadOnlyIntegerProperty property = this.shape.heightProperty(); assertNotNull(property); assertEpsilonEquals(5, property.get()); this.shape.setMinY(9); assertEpsilonEquals(4, property.get()); this.shape.setMinY(-5); assertEpsilonEquals(18, property.get()); this.shape.setMaxY(0); assertEpsilonEquals(5, property.get()); }
public boolean validate() { boolean isValid = true; String emptyError = "Ce champ ne peut pas être vide"; clearErrors(); if(languageName.getText().isEmpty()){ isValid = false; languageNameError.setText(emptyError); } if(Double.isNaN(robustness.getValue())) { isValid = false; robustnessError.setText(emptyError); } if(Double.isNaN(facility.getValue())) { isValid = false; facilityError.setText(emptyError); } ReadOnlyIntegerProperty platformIndex = platforms.getSelectionModel().selectedIndexProperty(); if(platformIndex.get() == -1) { isValid = false; platformsError.setText(emptyError); } ReadOnlyIntegerProperty paradygmIndex = paradygmChoice.getSelectionModel().selectedIndexProperty(); if(paradygmIndex.get() == -1){ isValid = false; paraDygmeChoiceError.setText(emptyError); } return isValid; }
/** * create a horizontal axis * * @param maxReadLength * @return axis */ public static Pane createAxis(final ReadOnlyIntegerProperty maxReadLength, final ReadOnlyDoubleProperty widthProperty) { final Pane pane = new Pane(); pane.prefWidthProperty().bind(widthProperty); final NumberAxis axis = new NumberAxis(); axis.setSide(Side.TOP); axis.setAutoRanging(false); axis.setLowerBound(0); axis.prefHeightProperty().set(20); axis.prefWidthProperty().bind(widthProperty.subtract(60)); final ChangeListener<Number> changeListener = new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { int minX = Math.round(maxReadLength.get() / 2000.0f); // at most 2000 major ticks for (int x = 10; x < 10000000; x *= 10) { if (x >= minX && widthProperty.doubleValue() * x >= 50 * maxReadLength.doubleValue()) { axis.setUpperBound(maxReadLength.get()); axis.setTickUnit(x); return; } } axis.setTickUnit(maxReadLength.get()); axis.setUpperBound(maxReadLength.get()); } }; maxReadLength.addListener(changeListener); widthProperty.addListener(changeListener); pane.getChildren().add(axis); return pane; }
public ReadOnlyIntegerProperty createReadOnlyIntegerProperty(Object bean, String name) { Objects.requireNonNull(bean, BEAN_MUST_NOT_BE_NULL); Objects.requireNonNull(name, NAME_MUST_NOT_BE_NULL); final Publisher<IntegerChangedCommand> propertyPublisher = getIntegerChangedCommandFlowable().filter(command -> name.equals(command.getPropertyName())); return new ReduxFXReadOnlyIntegerProperty(bean, name, propertyPublisher); }
/** * Adds listeners to the selection property of the tournament phase table to * dis-/enable table buttons accordingly */ private void bindTournamentPhaseTableButtons() { ReadOnlyIntegerProperty selectedIndex = this.tableTournamentPhases .getSelectionModel().selectedIndexProperty(); ReadOnlyObjectProperty<GamePhase> selectedItem = this.tableTournamentPhases .getSelectionModel().selectedItemProperty(); // only enable move-up button if an item other than the topmost is // selected this.buttonMoveTournamentPhaseUp.disableProperty().bind( selectedIndex.isEqualTo(0).or(selectedItem.isNull())); // only enable move-down button if an item other than the last // one is selected // index < size - 1 && selected != null this.buttonMoveTournamentPhaseDown.disableProperty().bind( selectedIndex.greaterThanOrEqualTo( Bindings.size(this.tableTournamentPhases.getItems()) .subtract(1)).or(selectedItem.isNull())); // only enable remove button if an item is selected this.buttonRemoveTournamentPhase.disableProperty().bind( selectedItem.isNull()); // only enable edit button if an item is selected this.buttonEditTournamentPhase.disableProperty().bind( selectedItem.isNull()); }
/** * Adds listeners to the selection property of the possible scores table to * dis-/enable table buttons accordingly */ private void bindPossibleScoresTableButtons() { ReadOnlyIntegerProperty selectedIndex = this.tablePossibleScores .getSelectionModel().selectedIndexProperty(); ReadOnlyObjectProperty<PossibleScoring> selectedItem = this.tablePossibleScores .getSelectionModel().selectedItemProperty(); // only enable move-up button if an item other than the topmost is // selected this.buttonMovePossibleScoreUp.disableProperty().bind( selectedIndex.isEqualTo(0).or(selectedItem.isNull())); // only enable move-down button if an item other than the last one is // selected // index < size - 1 && selected != null this.buttonMovePossibleScoreDown.disableProperty().bind( selectedIndex.greaterThanOrEqualTo( Bindings.size(this.tablePossibleScores.getItems()) .subtract(1)).or(selectedItem.isNull())); // only enable remove button if an item is selected and there is more // than one possible score this.buttonRemovePossibleScore.disableProperty().bind( selectedItem.isNull()); // only enable edit button if an item is selected this.buttonEditPossibleScore.disableProperty().bind( selectedItem.isNull()); }
private void bindTournamentPhaseButtons() { ReadOnlyIntegerProperty selectedPhaseIndex = this.tableTournamentPhases .getSelectionModel().selectedIndexProperty(); ReadOnlyObjectProperty<GamePhase> selectedPhase = this.tableTournamentPhases .getSelectionModel().selectedItemProperty(); // only enable move-up button if an item other than the topmost is // selected this.buttonMovePhaseUp.disableProperty().bind( selectedPhaseIndex.isEqualTo(0).or(selectedPhase.isNull())); // only enable move-down button if an item other than the last one is // selected // index < size - 1 && selected != null this.buttonMovePhaseDown.disableProperty().bind( selectedPhaseIndex.greaterThanOrEqualTo( Bindings.size(this.tableTournamentPhases.getItems()) .subtract(1)).or(selectedPhase.isNull())); // only enable remove button if an item is selected this.buttonRemovePhase.disableProperty().bind(selectedPhase.isNull()); // only enable edit button if an item is selected this.buttonEditPhase.disableProperty().bind(selectedPhase.isNull()); // TODO: add bindings for the possible score table's buttons (see // TournamentDialog#loadTournament()) }
@Test public void testReadOnlyIntegerProperty(){ ReadOnlyIntegerProperty actual = new SimpleIntegerProperty(30); assertThat(actual).hasValue(30); assertThat(actual).hasSameValue(actual); }
Item(String id, String initText) { this.id = id; this.setText(initText); final ObservableList<ReadOnlyIntegerProperty> numbersOfAllSubItems = EasyBind.map(openSubItems, Item::recursiveNumberOfOpenSubItems); final ObservableValue<Number> sum = EasyBind.combine(numbersOfAllSubItems, stream -> stream.reduce( (a, b) -> a.intValue() + b.intValue()).orElse(0)); recursiveNumberOfOpenSubItems.bind(Bindings.size(openSubItems).add(asDouble(sum))); subItems.addListener((ListChangeListener<Item>) change -> { while (change.next()) { if (change.wasAdded()) { change.getAddedSubList().forEach(item -> { item.getParent().ifPresent(oldParent -> oldParent.removeSubItem(item)); item.setParent(Item.this); }); } if (change.wasRemoved()) { change.getRemoved().forEach(item -> item.setParent(null)); } } }); this.title.bind(Bindings.createStringBinding(() -> { final String text = getText() == null ? "" : getText(); final String[] lines = text.split("\\r?\\n"); if(lines.length > 0) { return lines[0]; } return ""; }, this.text)); }
public final ReadOnlyIntegerProperty unitsToPrintProperty() { return unitsToPrint.getReadOnlyProperty(); }
public final ReadOnlyIntegerProperty pageNumberProperty() { return pageNumber.getReadOnlyProperty(); }
public final ReadOnlyIntegerProperty totalPagesProperty() { return totalPages.getReadOnlyProperty(); }
public ReadOnlyIntegerProperty vulnerabilityProperty() { return vulnerability; }
public static ReadOnlyIntegerProperty getWeight() { return WEIGHT.getReadOnlyProperty(); }
@Override public ReadOnlyIntegerProperty availableHelpsProperty() { return IntegerProperty.readOnlyIntegerProperty(this.availableHelps); }
@Override public ReadOnlyIntegerProperty scoreProperty() { return IntegerProperty.readOnlyIntegerProperty(this.score); }
public ReadOnlyIntegerProperty selectionIndexProperty() { return selectionIndex.getReadOnlyProperty(); }
public ReadOnlyIntegerProperty anInt() { return anInt; }
public ReadOnlyIntegerProperty idProperty () { return idProperty.getReadOnlyProperty(); }
public ReadOnlyIntegerProperty idProperty() { return idProperty.getReadOnlyProperty(); }
public ReadOnlyIntegerProperty taskCountProperty() { return taskCountProperty.getReadOnlyProperty(); }
public ReadOnlyIntegerProperty secondsProperty() { return seconds.getReadOnlyProperty(); }
public ReadOnlyIntegerProperty hoursProperty() { return hours.getReadOnlyProperty(); }
public ReadOnlyIntegerProperty minutesProperty() { return minutes.getReadOnlyProperty(); }
public ReadOnlyIntegerProperty createReadOnlyIntegerProperty(Object bean, String name) { return componentDriver.createReadOnlyIntegerProperty(bean, name); }
public ReadOnlyIntegerProperty numberOfItemsLeft() { return numberOfItemsLeft.getReadOnlyProperty(); }
public ReadOnlyIntegerProperty counter() { return counter.getReadOnlyProperty(); }
public ReadOnlyIntegerProperty initElementsNumberProperty() { return initElementsNumber.getReadOnlyProperty(); }
public ReadOnlyIntegerProperty allElementsNumberProperty() { return allElementsNumber.getReadOnlyProperty(); }