Java Code Examples for javafx.scene.Node#resizeRelocate()

The following examples show how to use javafx.scene.Node#resizeRelocate() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlowSafeVBox.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Override protected void layoutChildren() {
    double top = getPadding().getTop();
    double left = getPadding().getLeft();
    double right = getPadding().getRight();
    double w = getWidth() - left - right;
    double y = top;
    for(Node child:getChildren()) {
        double prefH = child.prefHeight(w);
        child.resizeRelocate(
            snapPosition(left),
            snapPosition(y),
            snapSize(w),
            snapSize(prefH)
        );
        y += vgap + prefH;
    }
}
 
Example 2
Source File: FlowSafeVBox.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Override protected void layoutChildren() {
    double top = getPadding().getTop();
    double left = getPadding().getLeft();
    double right = getPadding().getRight();
    double w = getWidth() - left - right;
    double y = top;
    for(Node child:getChildren()) {
        double prefH = child.prefHeight(w);
        child.resizeRelocate(
            snapPosition(left),
            snapPosition(y),
            snapSize(w),
            snapSize(prefH)
        );
        y += vgap + prefH;
    }
}
 
Example 3
Source File: MultiSelectSkin.java    From tornadofx-controls with Apache License 2.0 6 votes vote down vote up
protected void layoutChildren(double contentX, double contentY, double contentWidth, double contentHeight) {
	double usedLineWidth = 0;
	double hgap = getSkinnable().getHgap().doubleValue();
	double vgap = getSkinnable().getVgap().doubleValue();
	double prefHeight = getPrefRowHeight();

	for (Node node : getChildren()) {
		double prefWidth = node.prefWidth(prefHeight);
		if (usedLineWidth + prefWidth > contentWidth && usedLineWidth > 0) {
			usedLineWidth = 0;
			contentY += prefHeight + vgap;
		}
		double x = usedLineWidth + contentX;
		node.resizeRelocate(x, contentY, prefWidth, prefHeight);
		usedLineWidth += prefWidth + hgap;
	}
}
 
Example 4
Source File: ListMenuSkin.java    From tornadofx-controls with Apache License 2.0 5 votes vote down vote up
protected void layoutChildren(double x, double y, double w, double h) {
	for (Node node : getChildren()) {
		if (getSkinnable().getOrientation() == Orientation.VERTICAL) {
			double prefHeight = node.prefHeight(-1);
			node.resizeRelocate(x, y, w, prefHeight);
			y += prefHeight;
		} else {
			double prefWidth = node.prefWidth(-1);
			node.resizeRelocate(x, y, prefWidth, h);
			x += prefWidth;
		}
	}
}
 
Example 5
Source File: MosaicPane.java    From Mosaic with Apache License 2.0 4 votes vote down vote up
public SurfaceListener<T> getSurfaceObserver() {
	SurfaceListener<T> l = new SurfaceListener<T>() {
		public void changed(ChangeType changeType, Node n, String id, Rectangle2D r1, Rectangle2D r2) {
			switch(changeType) {
		    	case REMOVE_DISCARD: {
		    		content.getChildren().remove(n);
		    		requestLayout();
		    		break;
		    	}
		    	case RESIZE_RELOCATE: {
		    		n.resizeRelocate(r2.getX(), r2.getY(), r2.getWidth(), r2.getHeight());
					requestLayout();
			        
			        break;
		    	}
		    	case ADD_COMMIT: {
		    		content.getChildren().add(n);
		    		n.resizeRelocate(r2.getX(), r2.getY(), r2.getWidth(), r2.getHeight());
					requestLayout();
			        break;
		    	}
		    	case MOVE_BEGIN: {
		    		DropShadow shadow = new DropShadow();
		    		shadow.setOffsetX(10);
		    		shadow.setOffsetY(10);
		    		shadow.setRadius(5);
		    		shadow.setColor(Color.GRAY);
		    		n.setEffect(shadow);
		    		n.toFront();
		    		n.setOpacity(.5);
		    		break;
		    	}
		    	case RELOCATE_DRAG_TARGET: {
		    		n.resizeRelocate(r2.getX(), r2.getY(), r2.getWidth(), r2.getHeight());
					requestLayout();
		    		break;
		    	}
		    	case RESIZE_DRAG_TARGET: {
		    		n.resizeRelocate(r2.getX(), r2.getY(), r2.getWidth(), r2.getHeight());
					requestLayout();
			        break;
		    	}
		    	case MOVE_END: {
		    		n.setOpacity(1);
		    		n.setEffect(null);
		    		break;
		    	}
		    	case ANIMATE_RESIZE_RELOCATE: {
		    		n.resizeRelocate(r2.getX(), r2.getY(), r2.getWidth(), r2.getHeight());
					requestLayout();
			        break;
		    	}
		    	default: break;
	    	}
		}
	};
	return l;
}
 
Example 6
Source File: OrientationHelper.java    From Flowless with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void resizeRelocate(
        Node node, double b0, double l0, double breadth, double length) {
    node.resizeRelocate(l0, b0, length, breadth);
}
 
Example 7
Source File: OrientationHelper.java    From Flowless with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void resizeRelocate(
        Node node, double b0, double l0, double breadth, double length) {
    node.resizeRelocate(b0, l0, breadth, length);
}