Java源码示例:javafx.beans.binding.ObjectBinding

示例1
@Test
public void simpleAvgBinding() {
  Property<Double> a = new SimpleObjectProperty<>();
  Property<Double> b = new SimpleObjectProperty<>();
  Property<Double>[] properties = new Property[] {a, b};
  Property<Double> avg = new SimpleObjectProperty<>();

  ObjectBinding<Double> avgBinding = Bindings.createObjectBinding(() -> {
    double sum = 0;
    int n = 0;
    for (Property<Double> p : properties) {
      if (p.getValue() != null) {
        sum += p.getValue().doubleValue();
        n++;
      }
    }
    return n == 0 ? 0 : sum / n;
  }, properties);
  avg.bind(avgBinding);
  logger.info("avg=" + avg.getValue().doubleValue() + "   " + avg.getValue());
  a.setValue(10d);
  logger.info("avg=" + avg.getValue().doubleValue() + "   " + avg.getValue());
  b.setValue(5d);
  logger.info("avg=" + avg.getValue().doubleValue() + "   " + avg.getValue());
}
 
示例2
private void syncOrientationState() {
    // Apply pseudo classes when orientation changes
    labelPosition.addListener((observable, oldValue, newValue) -> {
        if (newValue == HORIZONTAL) {
            pseudoClassStateChanged(VERTICAL_PSEUDOCLASS_STATE, false);
            pseudoClassStateChanged(HORIZONTAL_PSEUDOCLASS_STATE, true);
        } else {
            pseudoClassStateChanged(HORIZONTAL_PSEUDOCLASS_STATE, false);
            pseudoClassStateChanged(VERTICAL_PSEUDOCLASS_STATE, true);
        }
    });

    // Setup listeneres for wrapping
    wrapWidth.addListener(((observable, oldValue, newValue) -> {
        ObjectBinding<Orientation> responsiveOrientation =
                createObjectBinding(() -> getWidth() < newValue ? VERTICAL : HORIZONTAL, widthProperty());

        if (labelPositionProperty().isBound())
            labelPositionProperty().unbind();

        labelPositionProperty().bind(responsiveOrientation);
    }));
}
 
示例3
public void initialise(final Button buttonUnseen, final Button buttonKnown, final Button buttonUnknown, final SessionModel sessionModel,
                        final ObjectBinding<WordState> wordStateProperty, final Runnable nextWordSelector) {
    this.sessionModel = sessionModel;
    this.nextWordSelector = nextWordSelector;

    SimpleBooleanProperty editableProperty = sessionModel.editableProperty();
    BooleanBinding resettableProperty = editableProperty.and(notEqual(WordState.UNSEEN, wordStateProperty));

    buttonUnseen.visibleProperty().bind(resettableProperty);
    buttonKnown.visibleProperty().bind(editableProperty);
    buttonUnknown.visibleProperty().bind(editableProperty);

    buttonUnseen.setOnAction(e -> processResponse(WordState.UNSEEN, false));
    buttonKnown.setOnAction(e -> processResponse(WordState.KNOWN, true));
    buttonUnknown.setOnAction(e -> processResponse(WordState.UNKNOWN, true));
}
 
示例4
public PointingHeroIcon(ObservableEntity oe) {
    super(oe);

    shape = new Polygon(
        0, -200, -120, 200, 120, 200
    );

    shape.fillProperty().bind(getPlayerColor());

    ObjectBinding<Vector> angRotVector = oe.getPropertyBinding(Vector.class, "CBodyComponent.m_angRotation", null);
    DoubleBinding angRot = Bindings.createDoubleBinding(() -> (double) angRotVector.get().getElement(1), angRotVector);

    IntegerBinding angDiff = Bindings.selectInteger(oe.getPropertyBinding(Integer.class, "m_anglediff", 0));

    shape.translateXProperty().bind(getMapX());
    shape.translateYProperty().bind(getMapY());
    shape.rotateProperty().bind(getBaseAngle().add(angRot).add(angDiff));
}
 
示例5
@Override
public ObjectBinding<?> createBinding(BindingsType bind, ModularFeatureListRow row) {
  // get all properties of all features
  @SuppressWarnings("unchecked")
  Property<Range<Double>>[] prop =
      row.streamFeatures().map(f -> f.get(this)).toArray(Property[]::new);
  switch (bind) {
    case RANGE:
      return Bindings.createObjectBinding(() -> {
        Range<Double> result = null;
        for (Property<Range<Double>> p : prop) {
          if (p.getValue() != null) {
            if (result == null)
              result = p.getValue();
            else
              result = result.span(p.getValue());
          }
        }
        return result;
      }, prop);
    case AVERAGE:
    case MIN:
    case MAX:
    case SUM:
    case COUNT:
    default:
      throw new UndefinedRowBindingException(this, bind);
  }
}
 
示例6
@Override
public ObjectBinding<?> createBinding(BindingsType bind, ModularFeatureListRow row) {
  // get all properties of all features
  @SuppressWarnings("unchecked")
  Property<Range<Integer>>[] prop =
      row.streamFeatures().map(f -> f.get(this)).toArray(Property[]::new);
  switch (bind) {
    case RANGE:
      return Bindings.createObjectBinding(() -> {
        Range<Integer> result = null;
        for (Property<Range<Integer>> p : prop) {
          if (p.getValue() != null) {
            if (result == null)
              result = p.getValue();
            else
              result = result.span(p.getValue());
          }
        }
        return result;
      }, prop);
    case AVERAGE:
    case MIN:
    case MAX:
    case SUM:
    case COUNT:
    default:
      throw new UndefinedRowBindingException(this, bind);
  }
}
 
示例7
@Override
public ObjectBinding<?> createBinding(BindingsType bind, ModularFeatureListRow row) {
  // get all properties of all features
  @SuppressWarnings("unchecked")
  Property<Range<Float>>[] prop =
      row.streamFeatures().map(f -> f.get(this)).toArray(Property[]::new);
  switch (bind) {
    case RANGE:
      return Bindings.createObjectBinding(() -> {
        Range<Float> result = null;
        for (Property<Range<Float>> p : prop) {
          if (p.getValue() != null) {
            if (result == null)
              result = p.getValue();
            else
              result = result.span(p.getValue());
          }
        }
        return result;
      }, prop);
    case AVERAGE:
    case MIN:
    case MAX:
    case SUM:
    case COUNT:
    default:
      throw new UndefinedRowBindingException(this, bind);
  }
}
 
示例8
@Test
public void testBinding() {
  ModularFeatureListRow row = flistWithBinding.getRow(0);
  // add bindings first and check after changing values
  Property<Double> mzProperty = row.get(MZType.class);
  Property<Float> areaProperty = row.get(AreaType.class);

  DataType<Property<Float>> type = row.getTypeColumn(AreaType.class);
  if (type instanceof BindingsFactoryType) {
    ObjectBinding<Float> sumBind =
        (ObjectBinding<Float>) ((BindingsFactoryType) type).createBinding(BindingsType.SUM, row);
    areaProperty.bind(sumBind);
  }

  DataType<Property<Double>> typeMZ = row.getTypeColumn(MZType.class);
  if (typeMZ instanceof BindingsFactoryType) {
    ObjectBinding<Double> avgBind = (ObjectBinding<Double>) ((BindingsFactoryType) typeMZ)
        .createBinding(BindingsType.AVERAGE, row);
    mzProperty.bind(avgBind);
  }
  logger.info("avg mz=" + row.getMZ().getValue());
  logger.info("sum area=" + row.getArea().getValue());

  // add values
  for (int i = 0; i < rawsBinding.length; i++) {
    ModularFeature f = row.getFeature(rawsBinding[i]);
    f.set(AreaType.class, area[i]);
    f.set(MZType.class, mz[i]);
    logger.info("after settings values: avg mz=" + row.getMZ().getValue());
    logger.info("after setting values: sum area=" + row.getArea().getValue());
  }
}
 
示例9
private Node initializeNode(
		final Node rootNode,
		final String datasetPromptText,
		final Node browseNode)
{
	final MenuButton datasetDropDown = new MenuButton();
	final StringBinding datasetDropDownText = Bindings.createStringBinding(() -> dataset.get() == null || dataset.get().length() == 0 ? datasetPromptText : datasetPromptText + ": " + dataset.get(), dataset);
	final ObjectBinding<Tooltip> datasetDropDownTooltip = Bindings.createObjectBinding(() -> Optional.ofNullable(dataset.get()).map(Tooltip::new).orElse(null), dataset);
	datasetDropDown.tooltipProperty().bind(datasetDropDownTooltip);
	datasetDropDown.disableProperty().bind(this.isN5Valid.not());
	datasetDropDown.textProperty().bind(datasetDropDownText);
	datasetChoices.addListener((ListChangeListener<String>) change -> {
		final MatchSelection matcher = MatchSelection.fuzzySorted(datasetChoices, s -> {
			dataset.set(s);
			datasetDropDown.hide();
		});
		LOG.debug("Updating dataset dropdown to fuzzy matcher with choices: {}", datasetChoices);
		final CustomMenuItem menuItem = new CustomMenuItem(matcher, false);
		// clear style to avoid weird blue highlight
		menuItem.getStyleClass().clear();
		datasetDropDown.getItems().setAll(menuItem);
		datasetDropDown.setOnAction(e -> {datasetDropDown.show(); matcher.requestFocus();});
	});
	final GridPane grid = new GridPane();
	grid.add(rootNode, 0, 0);
	grid.add(datasetDropDown, 0, 1);
	GridPane.setHgrow(rootNode, Priority.ALWAYS);
	GridPane.setHgrow(datasetDropDown, Priority.ALWAYS);
	grid.add(browseNode, 1, 0);

	return grid;
}
 
示例10
/**
 * Constructs a new {@link DynamicAnchor} for the given anchorage visual
 * using the given {@link IComputationStrategy}. The anchor will also add a
 * default binding for the {@link AnchorageReferenceGeometry} computation
 * parameter, inferring the geometry from the anchorage's shape outline, in
 * case this parameter is required by the given
 * {@link IComputationStrategy}.
 *
 * @param anchorage
 *            The anchorage visual.
 * @param computationStrategy
 *            The {@link IComputationStrategy} to use.
 */
public DynamicAnchor(final Node anchorage,
		IComputationStrategy computationStrategy) {
	super(anchorage);
	anchorageComputationParameters
			.addListener(anchorageComputationParametersChangeListener);
	anchoredComputationParameters
			.addListener(anchoredComputationParametersChangeListener);
	// XXX: Set computation strategy after adding parameter change
	// listeners, because setting the computation strategy does initialize
	// some parameters, for which otherwise no change listeners would be
	// registered.
	setComputationStrategy(computationStrategy);

	// add default binding for the anchorage reference geometry (if required
	// by the given computation strategy)
	if (computationStrategy.getRequiredParameters()
			.contains(AnchorageReferenceGeometry.class)) {
		getComputationParameter(AnchorageReferenceGeometry.class)
				.bind(new ObjectBinding<IGeometry>() {
					{
						bind(anchorage.layoutBoundsProperty());
					}

					@Override
					protected IGeometry computeValue() {
						return NodeUtils.getShapeOutline(anchorage);
					}
				});
	}
}
 
示例11
/**
 * Update's the reference point of the anchor with the given index.
 *
 * @param points
 *            The {@link Connection}'s points (snapshot taken before
 *            parameters are updated, i.e. independent from the parameter
 *            changes).
 * @param index
 *            The index of the connection anchor (and anchor key) for which
 *            the computation parameters are updated.
 * @param anchor
 *            The {@link DynamicAnchor} for which to update the computation
 *            parameters.
 * @param key
 *            The {@link AnchorKey}, corresponding to the index, for which
 *            to update the computation parameters.
 */
protected void updateComputationParameters(List<Point> points, int index,
		DynamicAnchor anchor, AnchorKey key) {
	// only update if necessary (when it changes)
	AnchoredReferencePoint referencePointParameter = anchor
			.getComputationParameter(key, AnchoredReferencePoint.class);
	Point oldRef = referencePointParameter.get();
	Point oldRefInScene = oldRef == null ? null
			: FX2Geometry.toPoint(key.getAnchored()
					.localToScene(Geometry2FX.toFXPoint(oldRef)));

	// if we have a position hint for the anchor, we need to use this as the
	// reference point
	// Point newRef = getAnchoredReferencePoint(points, index);
	Point2D newRefInConnection = Geometry2FX
			.toFXPoint(getAnchoredReferencePoint(points, index));
	Point newRefInScene = FX2Geometry
			.toPoint(getConnection().localToScene(newRefInConnection));
	if (oldRefInScene == null || !newRefInScene.equals(oldRefInScene)) {
		ObjectBinding<Point> refBinding = new ObjectBinding<Point>() {
			{
				bind(key.getAnchored().localToParentTransformProperty());
			}

			@Override
			protected Point computeValue() {
				return FX2Geometry.toPoint(key.getAnchored()
						.parentToLocal(newRefInConnection));
			}
		};
		referencePointParameter.bind(refBinding);
	}
}
 
示例12
/**
 * Initializes the computation parameters for the given
 * {@link DynamicAnchor}.
 *
 * @param anchor
 *            The {@link DynamicAnchor} for which to initialize computation
 *            parameters.
 */
protected void initializeComputationParameters(final DynamicAnchor anchor) {
	anchor.getComputationParameter(AnchorageReferenceGeometry.class)
			.bind(new ObjectBinding<IGeometry>() {
				{
					// XXX: Binding value needs to be recomputed when the
					// anchorage changes or when the layout bounds of the
					// respective anchorage changes.
					anchor.anchorageProperty()
							.addListener(new ChangeListener<Node>() {
								@Override
								public void changed(
										ObservableValue<? extends Node> observable,
										Node oldValue, Node newValue) {
									if (oldValue != null) {
										unbind(oldValue
												.boundsInLocalProperty());
									}
									if (newValue != null) {
										bind(newValue
												.boundsInLocalProperty());
									}
									invalidate();
								}
							});
					bind(anchor.getAnchorage().boundsInLocalProperty());
				}

				@Override
				protected IGeometry computeValue() {
					return computeAnchorageReferenceGeometry(anchor);
				}
			});
}
 
示例13
public MainWordHandler(
    final I18nManager i18nManager, final Label mainWord, final Label useCountLabel, final Pane mainWordPane, final SessionModel sessionModel,
    final ObjectBinding<WordState> wordStateProperty) {
    this.i18nManager = i18nManager;
    this.mainWord = mainWord;
    this.useCountLabel = useCountLabel;
    this.mainWordPane = mainWordPane;
    this.sessionModel = sessionModel;
    this.wordStateProperty = wordStateProperty;
}
 
示例14
/**
 * Constructor
 *
 * @param currentTheme The current theme
 */
public ThemeManager(ObjectProperty<Theme> currentTheme) {
    super();

    this.currentTheme = currentTheme;

    this.defaultCategoryIconsStylesheets = FXCollections.observableArrayList();
    this.defaultLibraryCategoryIconsStylesheets = FXCollections.observableArrayList();
    this.defaultEngineIconsStylesheets = FXCollections.observableArrayList();

    // the base stylesheets
    final ObservableList<String> baseStylesheets = FXCollections
            .observableList(getStylesheets(Themes.STANDARD));
    // the currently selected stylesheets (empty if the the selected theme is the standard theme)
    final ObservableList<String> currentStylesheets = CollectionBindings
            .mapToList(currentTheme, this::getNonStandardStylesheets);

    this.stylesheets = ConcatenatedList.create(
            defaultCategoryIconsStylesheets,
            defaultLibraryCategoryIconsStylesheets,
            defaultEngineIconsStylesheets,
            baseStylesheets,
            currentStylesheets);

    final ObjectBinding<Optional<URI>> currentWebEngineUri = ObjectBindings.map(currentTheme,
            theme -> theme.getResourceUri("description.css"));
    final StringBinding currentWebEngineStylesheet = StringBindings.map(currentWebEngineUri,
            uri -> uri.map(URI::toString).orElse(null));

    this.webEngineStylesheet = Bindings
            .when(Bindings.isNull(currentWebEngineStylesheet))
            .then(Themes.STANDARD.getResourceUri("description.css").map(URI::toString)
                    .orElseThrow(
                            () -> new IllegalStateException("Standard theme contains no \"description.css\" file")))
            .otherwise(currentWebEngineStylesheet);
}
 
示例15
/**
 * Constructor
 *
 * @param control The control belonging to the skin
 */
public ContainerInformationPanelSkin(ContainerInformationPanel control) {
    super(control);

    // initialise the "Overview" tab
    final ObservableList<Tab> overviewTab = FXCollections.singletonObservableList(createContainerOverviewTab());

    // initialise the "Engine settings" tab
    final ObjectBinding<Tab> engineSettingsBinding = Bindings
            .when(Bindings.isNotEmpty(getControl().getEngineSettings()))
            .then(createContainerEngineSettingsTab()).otherwise(new SimpleObjectProperty<>());
    final ObservableList<Tab> engineSettingsTab = CollectionBindings.mapToList(engineSettingsBinding,
            engineSettings -> Optional.ofNullable(engineSettings).map(List::of).orElse(List.of()));

    // initialise the "Verbs" tab
    final Tab verbsTabInstance = createContainerVerbsTab();
    final ObservableList<Tab> verbsTab = CollectionBindings.mapToList(getControl().verbsProperty(),
            verbs -> verbs != null ? List.of(verbsTabInstance) : List.of());

    // initialise the "Engine tools" tab
    final Tab engineToolsTabInstance = createContainerEngineToolsTab();
    final ObservableList<Tab> engineToolsTab = CollectionBindings.mapToList(getControl().engineToolsProperty(),
            engineTools -> engineTools != null ? List.of(engineToolsTabInstance) : List.of());

    // initialise the "Tools" tab
    final ObservableList<Tab> toolsTab = FXCollections.singletonObservableList(createContainerToolsTab());

    this.concatenatedTabs = ConcatenatedList.create(overviewTab, engineSettingsTab, verbsTab, engineToolsTab,
            toolsTab);
}
 
示例16
protected ObjectBinding<Paint> getTeamColor() {
    IntegerBinding teamNum = getTeamNum();
    return Bindings.createObjectBinding(() -> {
        int n = teamNum.get();
        switch (n) {
            case 2:
                return Color.GREEN;
            case 3:
                return Color.RED;
            default:
                return Color.GRAY;
        }
    }, teamNum);
}
 
示例17
protected ObjectBinding<Paint> getPlayerColor() {
    IntegerBinding playerId = getPlayerId();
    return Bindings.createObjectBinding(() -> {
        int n = playerId.get();
        if (n < 0 || n > 9) {
            return Color.WHITE;
        } else {
            return PLAYER_COLORS[n];
        }
    }, playerId);
}
 
示例18
public <T> ObjectBinding<T> getPropertyBinding(Class<T> propertyClass, String property, T defaultValue) {
    FieldPath fp = entity.getDtClass().getFieldPathForName(property);
    if (fp == null) {
        return Bindings.createObjectBinding(() -> defaultValue);
    } else {
        ObjectBinding<T> ob = getPropertyForFieldPath(fp).rawProperty();
        return Bindings.createObjectBinding(() -> ob.get(), ob);
    }
}
 
示例19
void initializeIntervalChartAxes() {
    final NumberAxis xAxis = (NumberAxis) intervalChart.getXAxis();
    xAxis.setForceZeroInRange(false);

    // Bind X Tick label formatter to choice-box
    intervalXTickLabel.getItems().addAll(IntervalTickFormatter.values());
    intervalXTickLabel.getSelectionModel().select(0);
    ObjectBinding<StringConverter<Number>> intervalXLabelConverter = Bindings.createObjectBinding(
            () -> intervalXTickLabel.getSelectionModel().getSelectedItem().getConverter(),
            intervalXTickLabel.getSelectionModel().selectedItemProperty()
    );
    xAxis.tickLabelFormatterProperty().bind(intervalXLabelConverter);

}
 
示例20
public void apply(ModularFeatureListRow row) {
  ObjectBinding<?> binding = featureType.createBinding(bindingType, row);
  row.get(rowType).bind(binding);
}
 
示例21
public <D extends IntegerType<D>, T extends Type<T>, B extends BooleanType<B>> IntersectingSourceState(
		final ThresholdingSourceState<?, ?> thresholded,
		final ConnectomicsLabelState<D, T> labels,
		final Composite<ARGBType, ARGBType> composite,
		final String name,
		final SharedQueue queue,
		final int priority,
		final Group meshesGroup,
		final ObjectProperty<ViewFrustum> viewFrustumProperty,
		final ObjectProperty<AffineTransform3D> eyeToWorldTransformProperty,
		final ObservableBooleanValue viewerEnabled,
		final ExecutorService manager,
		final HashPriorityQueueBasedTaskExecutor<MeshWorkerPriority> workers) {
	// TODO use better converter
	super(
			makeIntersect(thresholded, labels, queue, priority, name),
			new ARGBColorConverter.Imp0<>(0, 1),
			composite,
			name,
			// dependsOn:
			thresholded,
			labels);
	final DataSource<UnsignedByteType, VolatileUnsignedByteType> source = getDataSource();

	final MeshManagerWithAssignmentForSegments segmentMeshManager = labels.getMeshManager();

	this.labelsMeshesEnabledAndMeshesEnabled = Bindings.createBooleanBinding(
			() -> meshesEnabled.get() && segmentMeshManager.getManagedSettings().meshesEnabledProperty().get(),
			meshesEnabled,
			segmentMeshManager.getManagedSettings().meshesEnabledProperty());

	final BiFunction<TLongHashSet, Double, Converter<UnsignedByteType, BoolType>> getMaskGenerator = (l, minLabelRatio) -> (s, t) -> t.set(s.get() > 0);
	final SegmentMeshCacheLoader<UnsignedByteType>[] loaders = new SegmentMeshCacheLoader[getDataSource().getNumMipmapLevels()];
	Arrays.setAll(loaders, d -> new SegmentMeshCacheLoader<>(
			() -> getDataSource().getDataSource(0, d),
			getMaskGenerator,
			getDataSource().getSourceTransformCopy(0, d)));
	final GetMeshFor.FromCache<TLongHashSet> getMeshFor = GetMeshFor.FromCache.fromPairLoaders(loaders);

	this.fragmentsInSelectedSegments = new FragmentsInSelectedSegments(labels.getSelectedSegments());

	this.meshManager = new MeshManagerWithSingleMesh<>(
			source,
			getGetBlockListFor(segmentMeshManager.getLabelBlockLookup()),
			new WrappedGetMeshFromCache(getMeshFor),
			viewFrustumProperty,
			eyeToWorldTransformProperty,
			manager,
			workers,
			new MeshViewUpdateQueue<>());
	this.meshManager.viewerEnabledProperty().bind(viewerEnabled);
	final ObjectBinding<Color> colorProperty = Bindings.createObjectBinding(
			() -> Colors.toColor(this.converter().getColor()),
			this.converter().colorProperty());
	this.meshManager.colorProperty().bind(colorProperty);
	meshesGroup.getChildren().add(this.meshManager.getMeshesGroup());
	this.meshManager.getSettings().bindBidirectionalTo(segmentMeshManager.getSettings());
	this.meshManager.getRendererSettings().meshesEnabledProperty().bind(labelsMeshesEnabledAndMeshesEnabled);
	this.meshManager.getRendererSettings().blockSizeProperty().bind(segmentMeshManager.getRendererSettings().blockSizeProperty());
	this.meshManager.getRendererSettings().setShowBlockBounadries(false);
	this.meshManager.getRendererSettings().frameDelayMsecProperty().bind(segmentMeshManager.getRendererSettings().frameDelayMsecProperty());
	this.meshManager.getRendererSettings().numElementsPerFrameProperty().bind(segmentMeshManager.getRendererSettings().numElementsPerFrameProperty());
	this.meshManager.getRendererSettings().sceneUpdateDelayMsecProperty().bind(segmentMeshManager.getRendererSettings().sceneUpdateDelayMsecProperty());

	thresholded.getThreshold().minValue().addListener((obs, oldv, newv) -> {
		getMeshFor.invalidateAll();
		refreshMeshes(); });
	thresholded.getThreshold().maxValue().addListener((obs, oldv, newv) -> {
		getMeshFor.invalidateAll();
		refreshMeshes(); });

	fragmentsInSelectedSegments.addListener(obs -> refreshMeshes());
}
 
示例22
@Deprecated
public <D extends IntegerType<D>, T extends Type<T>, B extends BooleanType<B>> IntersectingSourceState(
		final ThresholdingSourceState<?, ?> thresholded,
		final LabelSourceState<D, T> labels,
		final Composite<ARGBType, ARGBType> composite,
		final String name,
		final SharedQueue queue,
		final int priority,
		final Group meshesGroup,
		final ObjectProperty<ViewFrustum> viewFrustumProperty,
		final ObjectProperty<AffineTransform3D> eyeToWorldTransformProperty,
		final ObservableBooleanValue viewerEnabled,
		final ExecutorService manager,
		final HashPriorityQueueBasedTaskExecutor<MeshWorkerPriority> workers) {
	// TODO use better converter
	super(
			makeIntersect(thresholded, labels, queue, priority, name),
			new ARGBColorConverter.Imp0<>(0, 1),
			composite,
			name,
			// dependsOn:
			thresholded,
			labels);
	final DataSource<UnsignedByteType, VolatileUnsignedByteType> source = getDataSource();

	final MeshManagerWithAssignmentForSegments segmentMeshManager = labels.meshManager();
	final SelectedIds selectedIds = labels.selectedIds();

	this.labelsMeshesEnabledAndMeshesEnabled = Bindings.createBooleanBinding(
			() -> meshesEnabled.get() && segmentMeshManager.getManagedSettings().meshesEnabledProperty().get(),
			meshesEnabled,
			segmentMeshManager.getManagedSettings().meshesEnabledProperty());


	final BiFunction<TLongHashSet, Double, Converter<UnsignedByteType, BoolType>> getMaskGenerator = (l, minLabelRatio) -> (s, t) -> t.set(s.get() > 0);
	final SegmentMeshCacheLoader<UnsignedByteType>[] loaders = new SegmentMeshCacheLoader[getDataSource().getNumMipmapLevels()];
	Arrays.setAll(loaders, d -> new SegmentMeshCacheLoader<>(
			() -> getDataSource().getDataSource(0, d),
			getMaskGenerator,
			getDataSource().getSourceTransformCopy(0, d)));
	final GetMeshFor.FromCache<TLongHashSet> getMeshFor = GetMeshFor.FromCache.fromPairLoaders(loaders);

	final FragmentSegmentAssignmentState assignment                  = labels.assignment();
	final SelectedSegments               selectedSegments            = new SelectedSegments(selectedIds, assignment);
	this.fragmentsInSelectedSegments = new FragmentsInSelectedSegments(selectedSegments);

	this.meshManager = new MeshManagerWithSingleMesh<>(
			source,
			getGetBlockListFor(segmentMeshManager.getLabelBlockLookup()),
			new WrappedGetMeshFromCache(getMeshFor),
			viewFrustumProperty,
			eyeToWorldTransformProperty,
			manager,
			workers,
			new MeshViewUpdateQueue<>());
	this.meshManager.viewerEnabledProperty().bind(viewerEnabled);
	meshesGroup.getChildren().add(this.meshManager.getMeshesGroup());
	final ObjectBinding<Color> colorProperty = Bindings.createObjectBinding(
			() -> Colors.toColor(this.converter().getColor()),
			this.converter().colorProperty());
	this.meshManager.colorProperty().bind(colorProperty);
	this.meshManager.getSettings().bindBidirectionalTo(segmentMeshManager.getSettings());
	this.meshManager.getRendererSettings().meshesEnabledProperty().bind(labelsMeshesEnabledAndMeshesEnabled);
	this.meshManager.getRendererSettings().blockSizeProperty().bind(segmentMeshManager.getRendererSettings().blockSizeProperty());
	this.meshManager.getRendererSettings().setShowBlockBounadries(false);
	this.meshManager.getRendererSettings().frameDelayMsecProperty().bind(segmentMeshManager.getRendererSettings().frameDelayMsecProperty());
	this.meshManager.getRendererSettings().numElementsPerFrameProperty().bind(segmentMeshManager.getRendererSettings().numElementsPerFrameProperty());
	this.meshManager.getRendererSettings().sceneUpdateDelayMsecProperty().bind(segmentMeshManager.getRendererSettings().sceneUpdateDelayMsecProperty());

	thresholded.getThreshold().minValue().addListener((obs, oldv, newv) -> {
		getMeshFor.invalidateAll();
		refreshMeshes();
	});
	thresholded.getThreshold().maxValue().addListener((obs, oldv, newv) -> {
		getMeshFor.invalidateAll();
		refreshMeshes();
	});

	fragmentsInSelectedSegments.addListener(obs -> refreshMeshes());
}
 
示例23
public <T> ObjectBinding<T> rawProperty() {
    return raw;
}
 
示例24
default ObjectBinding<Color> createLineOrShadColBinding(final boolean isShadow) {
	if(isShadow) {
		return Bindings.createObjectBinding(() -> getArrow().getShape().getShadowCol().toJFX(), getArrow().getShape().shadowColProperty());
	}
	return Bindings.createObjectBinding(() -> getArrow().getShape().getLineColour().toJFX(), getArrow().getShape().lineColourProperty());
}
 
示例25
default ObjectBinding<Color> createFillOrShadColBinding(final boolean isShadow) {
	if(isShadow) {
		return Bindings.createObjectBinding(() -> getArrow().getShape().getShadowCol().toJFX(), getArrow().getShape().shadowColProperty());
	}
	return Bindings.createObjectBinding(() -> getArrow().getShape().getFillingCol().toJFX(), getArrow().getShape().fillingColProperty());
}
 
示例26
/**
 * Maps a {@link ObservableValue<I>} object to a {@link ObjectBinding<O>} by applying the given converter function.
 * In case the input value is empty, i.e. contains <code>null</code>, the given default value is used
 *
 * @param property The input value
 * @param converter The converter function
 * @param defaultValue The default value in case the input value is empty
 * @param <I> The type of the input value
 * @param <O> The type of the output value
 * @return A {@link ObjectBinding} containing the converted value
 */
public static <I, O> ObjectBinding<O> map(ObservableValue<I> property, Function<I, O> converter, O defaultValue) {
    return Bindings.createObjectBinding(
            () -> Optional.ofNullable(property.getValue()).map(converter).orElse(defaultValue), property);
}
 
示例27
/**
 * Maps a {@link ObservableValue<I>} object to a {@link ObjectBinding<O>} by applying the given converter function
 *
 * @param property The input value
 * @param converter The converter function
 * @param <I> The type of the input value
 * @param <O> The type of the output value
 * @return A {@link ObjectBinding} containing the converted value
 */
public static <I, O> ObjectBinding<O> map(ObservableValue<I> property, Function<I, O> converter) {
    return map(property, converter, null);
}
 
示例28
public ObjectBinding<?> createBinding(BindingsType bind, ModularFeatureListRow row);