private void initProgressBinding() {
DoubleExpression tmp = constantOf(0);
for (Command command : registeredCommands) {
final ReadOnlyDoubleProperty progressProperty = command.progressProperty();
/**
* When the progress of a command is "undefined", the progress property has a value of -1.
* But in our use case we like to have a value of 0 in this case.
* Therefore we create a custom binding here.
*/
final DoubleBinding normalizedProgress = Bindings
.createDoubleBinding(() -> (progressProperty.get() == -1) ? 0.0 : progressProperty.get(),
progressProperty);
tmp = tmp.add(normalizedProgress);
}
int divisor = registeredCommands.isEmpty() ? 1 : registeredCommands.size();
progress.bind(Bindings.divide(tmp, divisor));
}
java类javafx.beans.property.ReadOnlyDoubleProperty的实例源码
CompositeCommand.java 文件源码
项目:easyMvvmFx
阅读 34
收藏 0
点赞 0
评论 0
CompositeCommand.java 文件源码
项目:javafx-qiniu-tinypng-client
阅读 32
收藏 0
点赞 0
评论 0
private void initProgressBinding() {
DoubleExpression tmp = constantOf(0);
for (Command command : registeredCommands) {
final ReadOnlyDoubleProperty progressProperty = command.progressProperty();
/**
* When the progress of a command is "undefined", the progress property has a value of -1.
* But in our use case we like to have a value of 0 in this case.
* Therefore we create a custom binding here.
*/
final DoubleBinding normalizedProgress = Bindings
.createDoubleBinding(() -> (progressProperty.get() == -1) ? 0.0 : progressProperty.get(),
progressProperty);
tmp = tmp.add(normalizedProgress);
}
int divisor = registeredCommands.isEmpty() ? 1 : registeredCommands.size();
progress.bind(Bindings.divide(tmp, divisor));
}
ImageRetriever.java 文件源码
项目:maps
阅读 43
收藏 0
点赞 0
评论 0
static ReadOnlyDoubleProperty fillImage(ImageView imageView, int zoom, long i, long j) {
Image image = fromFileCache(zoom, i, j);
if (image == null) {
String urlString = host + zoom + "/" + i + "/" + j + ".png";
if (hasFileCache) {
Task<Object> task = new Task() {
@Override
protected Object call() throws Exception {
cacheThread.cacheImage(urlString, zoom, i, j);
return null; // can't return image yet
}
};
Thread t = new Thread(task);
t.start();
}
image = new Image(urlString, true);
}
imageView.setImage(image);
return image.progressProperty();
}
MenuBuilder.java 文件源码
项目:HTMLEditor
阅读 34
收藏 0
点赞 0
评论 0
public MenuBar buildMenuBarWithMenus(HTMLEditor editor, final ReadOnlyDoubleProperty menuWidthProperty, String STYLE_CSS){
MenuBar menuBar = new MenuBar();
menuBar.setStyle(STYLE_CSS);
// Add File menu to menu bar
menuBar.getMenus().add(new FileMenuBuilder().getProduct(editor));
//Add Edit menu to menu bar
menuBar.getMenus().add(new EditMenuBuilder().getProduct(editor)) ;
//Add Insert menu to menu bar
menuBar.getMenus().add(new InsertMenuBuilder().getProduct(editor));
//Add Indent menu to menu bar
menuBar.getMenus().add(new IndentMenuBuilder().getProduct(editor));
// Add View menu to menu bar
menuBar.getMenus().add(new ViewMenuBuilder().getProduct(editor));
// bind width of menu bar to width of associated stage
menuBar.prefWidthProperty().bind(menuWidthProperty);
return menuBar;
}
DraggableItem.java 文件源码
项目:VOOGASalad
阅读 30
收藏 0
点赞 0
评论 0
public DraggableItem(SpriteObject item, ReadOnlyDoubleProperty width, ReadOnlyDoubleProperty height, SimpleDoubleProperty x, SimpleDoubleProperty y){
myItem=item;
myWidth=item.getImage().getFitWidth();
myHeight=item.getImage().getFitHeight();
gridWidth=width.getValue().doubleValue();
gridHeight=height.getValue().doubleValue();
startX=x.getValue().doubleValue();
startY=y.getValue().doubleValue();
addListener(x, (toChange)->changeX(toChange));
addListener(y, (toChange)->changeY(toChange));
addListener(myItem.getObservableWidth(), (toChange)->changeWidth(toChange));
addListener(myItem.getObservableHeight(), (toChange)->changeHeight(toChange));
addListener(width, (toChange)->changeGridWidth(toChange));
addListener(height, (toChange)->changeGridHeight(toChange));
drag();
}
RoundRectangle2dfx.java 文件源码
项目:afc
阅读 40
收藏 0
点赞 0
评论 0
/** Replies the property for the arc width.
*
* @return the arcWidth property.
*/
public DoubleProperty arcWidthProperty() {
if (this.arcWidth == null) {
this.arcWidth = new DependentSimpleDoubleProperty<ReadOnlyDoubleProperty>(
this, MathFXAttributeNames.ARC_WIDTH, widthProperty()) {
@Override
protected void invalidated(ReadOnlyDoubleProperty dependency) {
final double value = get();
if (value < 0.) {
set(0.);
} else {
final double maxArcWidth = dependency.get() / 2.;
if (value > maxArcWidth) {
set(maxArcWidth);
}
}
}
};
}
return this.arcWidth;
}
RoundRectangle2dfx.java 文件源码
项目:afc
阅读 43
收藏 0
点赞 0
评论 0
/** Replies the property for the arc height.
*
* @return the arcHeight property.
*/
public DoubleProperty arcHeightProperty() {
if (this.arcHeight == null) {
this.arcHeight = new DependentSimpleDoubleProperty<ReadOnlyDoubleProperty>(
this, MathFXAttributeNames.ARC_HEIGHT, heightProperty()) {
@Override
protected void invalidated(ReadOnlyDoubleProperty dependency) {
final double value = get();
if (value < 0.) {
set(0.);
} else {
final double maxArcHeight = dependency.get() / 2.;
if (value > maxArcHeight) {
set(maxArcHeight);
}
}
}
};
}
return this.arcHeight;
}
Ellipse2dfxTest.java 文件源码
项目:afc
阅读 36
收藏 0
点赞 0
评论 0
@Test
public void widthProperty() {
assertEpsilonEquals(5, this.shape.getWidth());
ReadOnlyDoubleProperty property = this.shape.widthProperty();
assertNotNull(property);
assertEpsilonEquals(5, property.get());
this.shape.setMinX(7);
assertEpsilonEquals(3, property.get());
this.shape.setMinX(-5);
assertEpsilonEquals(15, property.get());
this.shape.setMaxX(0);
assertEpsilonEquals(5, property.get());
}
Ellipse2dfxTest.java 文件源码
项目:afc
阅读 43
收藏 0
点赞 0
评论 0
@Test
public void heightProperty() {
assertEpsilonEquals(10, this.shape.getHeight());
ReadOnlyDoubleProperty property = this.shape.heightProperty();
assertNotNull(property);
assertEpsilonEquals(10, property.get());
this.shape.setMinY(9);
assertEpsilonEquals(9, property.get());
this.shape.setMinY(-5);
assertEpsilonEquals(23, property.get());
this.shape.setMaxY(0);
assertEpsilonEquals(5, property.get());
}
RoundRectangle2dfxTest.java 文件源码
项目:afc
阅读 27
收藏 0
点赞 0
评论 0
@Test
public void widthProperty() {
assertEpsilonEquals(5, this.shape.getWidth());
ReadOnlyDoubleProperty property = this.shape.widthProperty();
assertNotNull(property);
assertEpsilonEquals(5, property.get());
this.shape.setMinX(7);
assertEpsilonEquals(3, property.get());
this.shape.setMinX(-5);
assertEpsilonEquals(15, property.get());
this.shape.setMaxX(0);
assertEpsilonEquals(5, property.get());
}
RoundRectangle2dfxTest.java 文件源码
项目:afc
阅读 28
收藏 0
点赞 0
评论 0
@Test
public void heightProperty() {
assertEpsilonEquals(10, this.shape.getHeight());
ReadOnlyDoubleProperty property = this.shape.heightProperty();
assertNotNull(property);
assertEpsilonEquals(10, property.get());
this.shape.setMinY(9);
assertEpsilonEquals(9, property.get());
this.shape.setMinY(-5);
assertEpsilonEquals(23, property.get());
this.shape.setMaxY(0);
assertEpsilonEquals(5, property.get());
}
Rectangle2dfxTest.java 文件源码
项目:afc
阅读 34
收藏 0
点赞 0
评论 0
@Test
public void widthProperty() {
assertEpsilonEquals(5, this.shape.getWidth());
ReadOnlyDoubleProperty property = this.shape.widthProperty();
assertNotNull(property);
assertEpsilonEquals(5, property.get());
this.shape.setMinX(7);
assertEpsilonEquals(3, property.get());
this.shape.setMinX(-5);
assertEpsilonEquals(15, property.get());
this.shape.setMaxX(0);
assertEpsilonEquals(5, property.get());
}
Rectangle2dfxTest.java 文件源码
项目:afc
阅读 35
收藏 0
点赞 0
评论 0
@Test
public void heightProperty() {
assertEpsilonEquals(10, this.shape.getHeight());
ReadOnlyDoubleProperty property = this.shape.heightProperty();
assertNotNull(property);
assertEpsilonEquals(10, property.get());
this.shape.setMinY(9);
assertEpsilonEquals(9, property.get());
this.shape.setMinY(-5);
assertEpsilonEquals(23, property.get());
this.shape.setMaxY(0);
assertEpsilonEquals(5, property.get());
}
RectangularPrism3dfxTest.java 文件源码
项目:afc
阅读 25
收藏 0
点赞 0
评论 0
@Test
public void widthProperty() {
assertEpsilonEquals(5, this.shape.getWidth());
ReadOnlyDoubleProperty property = this.shape.widthProperty();
assertNotNull(property);
assertEpsilonEquals(5, property.get());
this.shape.setMinX(7);
assertEpsilonEquals(3, property.get());
this.shape.setMinX(-5);
assertEpsilonEquals(15, property.get());
this.shape.setMaxX(0);
assertEpsilonEquals(5, property.get());
}
RectangularPrism3dfxTest.java 文件源码
项目:afc
阅读 32
收藏 0
点赞 0
评论 0
@Test
public void heightProperty() {
assertEpsilonEquals(10, this.shape.getHeight());
ReadOnlyDoubleProperty property = this.shape.heightProperty();
assertNotNull(property);
assertEpsilonEquals(10, property.get());
this.shape.setMinY(9);
assertEpsilonEquals(9, property.get());
this.shape.setMinY(-5);
assertEpsilonEquals(23, property.get());
this.shape.setMaxY(0);
assertEpsilonEquals(5, property.get());
}
RectangularPrism3dfxTest.java 文件源码
项目:afc
阅读 27
收藏 0
点赞 0
评论 0
@Test
public void depthProperty() {
assertEpsilonEquals(0, this.shape.getDepth());
ReadOnlyDoubleProperty property = this.shape.depthProperty();
assertNotNull(property);
assertEpsilonEquals(0, property.get());
this.shape.setMinZ(9);
assertEpsilonEquals(0, property.get());
this.shape.setMinZ(-5);
assertEpsilonEquals(14, property.get());
this.shape.setMaxZ(0);
assertEpsilonEquals(5, property.get());
}
TraceSectionsDialog.java 文件源码
项目:gemoc-studio-modeldebugging
阅读 43
收藏 0
点赞 0
评论 0
private Pane createTraceWidget(ITraceExtractor<Step<?>, State<?,?>, TracedObject<?>, Dimension<?>, Value<?>> extractor, String label, ReadOnlyDoubleProperty width) {
final Pane pane = new Pane();
pane.setBackground(TRANSPARENT_BACKGROUND);
final Rectangle rectangle = new Rectangle(0, 0, 0, 12);
rectangle.setFill(Color.LIGHTGRAY);
rectangle.widthProperty().bind(width.subtract(10));
rectangle.setArcHeight(12);
rectangle.setArcWidth(12);
Label text = new Label(label);
text.setTextOverrun(OverrunStyle.ELLIPSIS);
text.setAlignment(Pos.CENTER);
text.setMouseTransparent(true);
text.setTextFill(Color.WHITE);
text.setFont(FONT);
text.setMaxWidth(0);
text.maxWidthProperty().bind(rectangle.widthProperty());
StackPane layout = new StackPane();
layout.getChildren().addAll(rectangle, text);
pane.getChildren().add(layout);
layout.setTranslateY(13);
layout.setTranslateX(5);
pane.setPrefHeight(25);
pane.setMinHeight(25);
pane.setMaxHeight(25);
final Shape arrow1 = createCursor();
final Shape arrow2 = createCursor();
arrow1.setTranslateX(5);
arrow1.setTranslateY(4);
arrow2.translateXProperty().bind(rectangle.widthProperty().add(5));
arrow2.setTranslateY(4);
pane.getChildren().add(arrow1);
pane.getChildren().add(arrow2);
return pane;
}
LRInspectorController.java 文件源码
项目:megan-ce
阅读 25
收藏 0
点赞 0
评论 0
/**
* 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;
}
TableItemTask.java 文件源码
项目:megan-ce
阅读 40
收藏 0
点赞 0
评论 0
/**
* constructor
*
* @param doc
* @param cNames
* @param classificationName
* @param tableView
*/
public TableItemTask(Document doc, String[] cNames, String classificationName, Set<Integer> classIds, TableView<TableItem> tableView, FloatProperty maxBitScore, FloatProperty maxNormalizedBitScore, IntegerProperty maxReadLength, ReadOnlyDoubleProperty layoutWidth) {
this.doc = doc;
this.cNames = cNames;
this.classificationName = classificationName;
this.classIds = classIds;
this.tableView = tableView;
this.maxBitScore = maxBitScore;
this.maxNormalizedBitScore = maxNormalizedBitScore;
this.maxReadLength = maxReadLength;
this.layoutWidth = layoutWidth;
}
WCFXPanel.java 文件源码
项目:DriverStation
阅读 36
收藏 0
点赞 0
评论 0
public WCFXPanel(RecordingManager r, ReadOnlyDoubleProperty heightProp, ReadOnlyDoubleProperty widthProp) {
rManager = r;
wcImg = new ImageView();
setCenter(wcImg);
Platform.runLater(new Runnable() {
@Override
public void run() {
initView(heightProp, widthProp);
}
});
}
WCFXPanel.java 文件源码
项目:DriverStation
阅读 27
收藏 0
点赞 0
评论 0
private void initView(ReadOnlyDoubleProperty heightProp, ReadOnlyDoubleProperty widthProp)
{
wcImg.fitWidthProperty().bind(widthProp);
wcImg.fitHeightProperty().bind(heightProp);
wcImg.setPreserveRatio(true);
wcImg.minWidth(0);
wcImg.minHeight(0);
minWidth(0);
minHeight(0);
}
LogView.java 文件源码
项目:LogFX
阅读 39
收藏 0
点赞 0
评论 0
@MustCallOnJavaFXThread
public LogView( BindableValue<Font> fontValue,
ReadOnlyDoubleProperty widthProperty,
HighlightOptions highlightOptions,
FileContentReader fileContentReader,
TaskRunner taskRunner ) {
this.highlightOptions = highlightOptions;
this.fileContentReader = fileContentReader;
this.taskRunner = taskRunner;
this.selectionHandler = new SelectionHandler( this );
this.file = fileContentReader.getFile();
final LogLineColors logLineColors = highlightOptions.logLineColorsFor( "" );
final NumberBinding width = Bindings.max( widthProperty(), widthProperty );
logLineFactory = () -> new LogLine( fontValue, width,
logLineColors.getBackground(), logLineColors.getFill() );
for ( int i = 0; i < MAX_LINES; i++ ) {
getChildren().add( logLineFactory.get() );
}
this.colorChangeListener = ( Observable observable ) -> {
for ( int i = 0; i < MAX_LINES; i++ ) {
updateLine( i );
}
};
highlightOptions.getObservableExpressions().addListener( colorChangeListener );
highlightOptions.getStandardLogColors().addListener( colorChangeListener );
tailingFile.addListener( event -> {
if ( tailingFile.get() ) {
onFileChange();
}
} );
this.fileChangeWatcher = new FileChangeWatcher( file, taskRunner, this::onFileChange );
}
TraceSectionsDialog.java 文件源码
项目:ModelDebugging
阅读 35
收藏 0
点赞 0
评论 0
private Pane createTraceWidget(ITraceExtractor extractor, String label, ReadOnlyDoubleProperty width) {
final Pane pane = new Pane();
pane.setBackground(TRANSPARENT_BACKGROUND);
final Rectangle rectangle = new Rectangle(0, 0, 0, 12);
rectangle.setFill(Color.LIGHTGRAY);
rectangle.widthProperty().bind(width.subtract(10));
rectangle.setArcHeight(12);
rectangle.setArcWidth(12);
Label text = new Label(label);
text.setTextOverrun(OverrunStyle.ELLIPSIS);
text.setAlignment(Pos.CENTER);
text.setMouseTransparent(true);
text.setTextFill(Color.WHITE);
text.setFont(FONT);
text.setMaxWidth(0);
text.maxWidthProperty().bind(rectangle.widthProperty());
StackPane layout = new StackPane();
layout.getChildren().addAll(rectangle, text);
pane.getChildren().add(layout);
layout.setTranslateY(13);
layout.setTranslateX(5);
pane.setPrefHeight(25);
pane.setMinHeight(25);
pane.setMaxHeight(25);
final Group group1 = new Group();
final Label label1 = new Label();
final Shape arrow1 = createCursor();
final Group group2 = new Group();
final Shape arrow2 = createCursor();
arrow1.setTranslateX(5);
arrow1.setTranslateY(4);
arrow2.translateXProperty().bind(rectangle.widthProperty().add(5));
arrow2.setTranslateY(4);
pane.getChildren().add(arrow1);
pane.getChildren().add(arrow2);
return pane;
}
ScrollBarPane.java 文件源码
项目:VOOGASalad
阅读 33
收藏 0
点赞 0
评论 0
public void addDoubleListener(ReadOnlyDoubleProperty prop, DoubleChangeListener listener){
prop.addListener(new ChangeListener<Number>(){
public void changed(ObservableValue<? extends Number> arg0,
Number arg1, Number arg2) {
listener.change(arg2.doubleValue());
}
});
}
DraggableItem.java 文件源码
项目:VOOGASalad
阅读 37
收藏 0
点赞 0
评论 0
private void addListener(ReadOnlyDoubleProperty readOnlyDoubleProperty, DoubleChangeListener doubleChange){
readOnlyDoubleProperty.addListener(new ChangeListener<Number>(){
@Override
public void changed(ObservableValue<? extends Number> arg0,
Number arg1, Number arg2) {
doubleChange.change((arg2.doubleValue()));
}
});
}
RfxVerticalFlingScroller.java 文件源码
项目:Introspect-Framework
阅读 37
收藏 0
点赞 0
评论 0
public RfxVerticalFlingScroller(Node node, ReadOnlyDoubleProperty totalContentHeightProperty) {
this.node = node;
this.totalContentHeightProperty = totalContentHeightProperty;
this.velocityTracker = new VelocityTracker();
node.setOnMousePressed(createOnMousePressedHandler());
node.setOnMouseReleased(createOnMouseReleasedHandler());
node.setOnMouseDragged(createOnMouseDraggerdHandler());
}
RfxVerticalFlingScroller.java 文件源码
项目:Introspect-Framework
阅读 34
收藏 0
点赞 0
评论 0
private static ReadOnlyDoubleProperty createTotalContentHeightProperty(ListView<?> listView) {
return new ReadOnlyDoublePropertyBase() {
@SuppressWarnings({ "rawtypes" })
@Override
public double get() {
VirtualFlow flow = (VirtualFlow) listView.lookup(".virtual-flow");
int nrOfItems = listView.getItems().size();
if (nrOfItems == 0) {
return 0;
}
IndexedCell cell = flow.getCell(0);
// assuming all cells have same size
double cellHeight = cell.getBoundsInLocal().getHeight();
double totalContentHeight = cellHeight * nrOfItems;
return totalContentHeight;
}
@Override
public String getName() {
return null;
}
@Override
public Object getBean() {
return null;
}
};
}
DoubleTest.java 文件源码
项目:assertj-javafx
阅读 45
收藏 0
点赞 0
评论 0
@Test
public void testReadOnlyDoubleProperty(){
ReadOnlyDoubleProperty actual = new SimpleDoubleProperty(30.2);
assertThat(actual).hasValue(30.2);
assertThat(actual).hasSameValue(actual);
}
UnitVectorProperty.java 文件源码
项目:afc
阅读 41
收藏 0
点赞 0
评论 0
/** Replies the x property.
*
* @return the x property.
*/
@Pure
public ReadOnlyDoubleProperty xProperty() {
if (isBound()) {
return super.get().xProperty();
}
return internalXProperty().getReadOnlyProperty();
}
UnitVectorProperty.java 文件源码
项目:afc
阅读 31
收藏 0
点赞 0
评论 0
/** Replies the y property.
*
* @return the y property.
*/
@Pure
public ReadOnlyDoubleProperty yProperty() {
if (isBound()) {
return super.get().yProperty();
}
return internalYProperty().getReadOnlyProperty();
}