Java Code Examples for javafx.scene.layout.Region#USE_COMPUTED_SIZE
The following examples show how to use
javafx.scene.layout.Region#USE_COMPUTED_SIZE .
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: JFXListViewSkin.java From JFoenix with Apache License 2.0 | 6 votes |
@Override protected double computePrefHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) { final int itemsCount = getSkinnable().getItems().size(); if (getSkinnable().maxHeightProperty().isBound() || itemsCount <= 0) { return super.computePrefHeight(width, topInset, rightInset, bottomInset, leftInset); } final double fixedCellSize = getSkinnable().getFixedCellSize(); double computedHeight = fixedCellSize != Region.USE_COMPUTED_SIZE ? fixedCellSize * itemsCount + snapVerticalInsets() : estimateHeight(); double height = super.computePrefHeight(width, topInset, rightInset, bottomInset, leftInset); if (height > computedHeight) { height = computedHeight; } if (getSkinnable().getMaxHeight() > 0 && computedHeight > getSkinnable().getMaxHeight()) { return getSkinnable().getMaxHeight(); } return height; }
Example 2
Source File: ConnectorUtils.java From scenic-view with GNU General Public License v3.0 | 5 votes |
public static String formatSize(final double size) { if (size == Region.USE_COMPUTED_SIZE) { return "USE_COMPUTED_SIZE"; } else if (size == Region.USE_PREF_SIZE) { return "USE_PREF_SIZE"; } return DFMT.format(size); }
Example 3
Source File: JFXTextArea.java From tuxguitar with GNU Lesser General Public License v2.1 | 5 votes |
public void computePackedSize(Float fixedWidth, Float fixedHeight) { if( this.getControl().getPrefWidth() == Region.USE_COMPUTED_SIZE ) { this.getControl().setPrefWidth(DEFAULT_WIDTH); } if( this.getControl().getPrefHeight() == Region.USE_COMPUTED_SIZE ) { this.getControl().setPrefHeight(DEFAULT_HEIGHT); } super.computePackedSize(fixedWidth, fixedHeight); }
Example 4
Source File: JFXNode.java From tuxguitar with GNU Lesser General Public License v2.1 | 5 votes |
public void computePackedSize(Float fixedWidth, Float fixedHeight) { double wHint = (fixedWidth != null ? fixedWidth : Region.USE_COMPUTED_SIZE); double hHint = (fixedHeight != null ? fixedHeight : Region.USE_COMPUTED_SIZE); this.packedSize.setWidth(fixedWidth != null ? fixedWidth : (float) this.getControl().prefWidth(hHint)); this.packedSize.setHeight(fixedHeight != null ? fixedHeight : (float) this.getControl().prefHeight(wHint)); }
Example 5
Source File: JFXReadOnlyTextBox.java From tuxguitar with GNU Lesser General Public License v2.1 | 5 votes |
public void computePackedSize(Float fixedWidth, Float fixedHeight) { if( this.getControl().getPrefWidth() == Region.USE_COMPUTED_SIZE ) { this.getControl().setPrefWidth(DEFAULT_WIDTH); } if( this.getControl().getPrefHeight() == Region.USE_COMPUTED_SIZE ) { this.getControl().setPrefHeight(DEFAULT_HEIGHT); } super.computePackedSize(fixedWidth, fixedHeight); }
Example 6
Source File: JFXSpinnerSkin.java From JFoenix with Apache License 2.0 | 5 votes |
@Override protected double computeMaxHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) { if (Region.USE_COMPUTED_SIZE == control.getRadius()) { return super.computeMaxHeight(width, topInset, rightInset, bottomInset, leftInset); } else { return control.getRadius() * 2 + arc.getStrokeWidth() * 2; } }
Example 7
Source File: JFXSpinnerSkin.java From JFoenix with Apache License 2.0 | 5 votes |
@Override protected double computeMaxWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) { if (Region.USE_COMPUTED_SIZE == control.getRadius()) { return super.computeMaxHeight(height, topInset, rightInset, bottomInset, leftInset); } else { return control.getRadius() * 2 + arc.getStrokeWidth() * 2; } }
Example 8
Source File: JFXUtil.java From jfxutils with Apache License 2.0 | 5 votes |
/** * Creates a "Scale Pane", which is a pane that scales as it resizes, instead of reflowing layout * like a normal pane. It can be used to create an effect like a presentation slide. There is no * attempt to preserve the aspect ratio. * <p> * If the region has an explicitly set preferred width and height, those are used unless * override is set true. * <p> * If the region already has a parent, the returned pane will replace it via the * {@link #replaceComponent(Node, Node)} method. The Region's parent must be a Pane in this case. * * @param region non-null Region * @param w default width, used if the region's width is calculated * @param h default height, used if the region's height is calculated * @param override if true, w,h is the region's "100%" size even if the region has an explicit * preferred width and height set. * * @return the created StackPane, with preferred width and height set based on size determined by * w, h, and override parameters. */ public static StackPane createScalePane( Region region, double w, double h, boolean override ) { //If the Region containing the GUI does not already have a preferred width and height, set it. //But, if it does, we can use that setting as the "standard" resolution. if ( override || region.getPrefWidth() == Region.USE_COMPUTED_SIZE ) region.setPrefWidth( w ); else w = region.getPrefWidth(); if ( override || region.getPrefHeight() == Region.USE_COMPUTED_SIZE ) region.setPrefHeight( h ); else h = region.getPrefHeight(); StackPane ret = new StackPane(); ret.setPrefWidth( w ); ret.setPrefHeight( h ); if ( region.getParent() != null ) replaceComponent( region, ret ); //Wrap the resizable content in a non-resizable container (Group) Group group = new Group( region ); //Place the Group in a StackPane, which will keep it centered ret.getChildren().add( group ); //Bind the scene's width and height to the scaling parameters on the group group.scaleXProperty().bind( ret.widthProperty().divide( w ) ); group.scaleYProperty().bind( ret.heightProperty().divide( h ) ); return ret; }
Example 9
Source File: SpectralMatchPanelFX.java From mzmine3 with GNU General Public License v2.0 | 4 votes |
public SpectralMatchPanelFX(SpectralDBPeakIdentity hit) { super(); this.hit = hit; setMinSize(950, 500); theme = MZmineCore.getConfiguration().getDefaultChartTheme(); SimpleColorPalette palette = MZmineCore.getConfiguration().getDefaultColorPalette(); MAX_COS_COLOR = palette.getPositiveColor(); MIN_COS_COLOR = palette.getNegativeColor(); pnTitle = createTitlePane(); metaDataScroll = createMetaDataPane(); mirrorChart = MirrorChartFactory.createMirrorPlotFromSpectralDBPeakIdentity(hit); MZmineCore.getConfiguration().getDefaultChartTheme().apply(mirrorChart.getChart()); mirrorChartWrapper = new BorderPane(); mirrorChartWrapper.setCenter(mirrorChart); coupleZoomYListener(); // put into main ColumnConstraints ccSpectrum = new ColumnConstraints(400, -1, Region.USE_COMPUTED_SIZE, Priority.ALWAYS, HPos.CENTER, true); ColumnConstraints ccMetadata = new ColumnConstraints(META_WIDTH + 30, META_WIDTH + 30, Region.USE_COMPUTED_SIZE, Priority.NEVER, HPos.LEFT, false); add(pnTitle, 0, 0, 2, 1); add(mirrorChartWrapper, 0, 1); add(metaDataScroll, 1, 1); getColumnConstraints().add(0, ccSpectrum); getColumnConstraints().add(1, ccMetadata); setBorder(new Border(new BorderStroke(Color.BLACK, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, BorderWidths.DEFAULT))); }
Example 10
Source File: NodePart.java From gef with Eclipse Public License 2.0 | 4 votes |
@Override protected void doRefreshVisual(Group visual) { org.eclipse.gef.graph.Node node = getContent(); if (node == null) { throw new IllegalStateException(); } // set CSS class Map<String, Object> attrs = node.attributesProperty(); List<String> cssClasses = new ArrayList<>(); cssClasses.add(CSS_CLASS); if (attrs.containsKey(ZestProperties.CSS_CLASS__NE)) { cssClasses.add(ZestProperties.getCssClass(node)); } if (!visual.getStyleClass().equals(cssClasses)) { visual.getStyleClass().setAll(cssClasses); } // set CSS id String id = null; if (attrs.containsKey(ZestProperties.CSS_ID__NE)) { id = ZestProperties.getCssId(node); } if (visual.getId() != id || id != null && !id.equals(visual.getId())) { visual.setId(id); } refreshShape(); // set CSS style if (attrs.containsKey(ZestProperties.SHAPE_CSS_STYLE__N)) { if (getShape() != null) { if (!getShape().getStyle().equals(ZestProperties.getShapeCssStyle(node))) { getShape().setStyle(ZestProperties.getShapeCssStyle(node)); } } } if (attrs.containsKey(ZestProperties.LABEL_CSS_STYLE__NE)) { if (getLabelText() != null) { if (!getLabelText().getStyle().equals(ZestProperties.getLabelCssStyle(node))) { getLabelText().setStyle(ZestProperties.getLabelCssStyle(node)); } } } if (vbox != null) { if (getShape() != null && DEFAULT_SHAPE_ROLE.equals(getShape().getUserData()) || isNesting()) { vbox.setPadding(new Insets(DEFAULT_SHAPE_PADDING)); } else { vbox.setPadding(Insets.EMPTY); } if (isNesting()) { if (!vbox.getChildren().contains(nestedContentAnchorPane)) { vbox.getChildren().add(nestedContentAnchorPane); if (vbox.getPrefWidth() == Region.USE_COMPUTED_SIZE && vbox.getPrefHeight() == Region.USE_COMPUTED_SIZE) { vbox.setPrefSize(DEFAULT_OUTER_LAYOUT_CONTAINER_WIDTH_NESTING, DEFAULT_OUTER_LAYOUT_CONTAINER_HEIGHT_NESTING); vbox.autosize(); } } // show a nested graph icon dependent on the zoom level if (!getChildrenUnmodifiable().isEmpty()) { hideNestedGraphIcon(); } else { // show an icon as a replacement when the zoom threshold is // not reached showNestedGraphIcon(); } } else { if (vbox.getChildren().contains(nestedContentAnchorPane)) { vbox.getChildren().remove(nestedContentAnchorPane); vbox.setPrefSize(Region.USE_COMPUTED_SIZE, Region.USE_COMPUTED_SIZE); vbox.autosize(); } } } refreshLabel(); refreshIcon(); refreshTooltip(); Point position = ZestProperties.getPosition(node); if (position != null) { Affine newTransform = new Affine(new Translate(position.x, position.y)); if (!NodeUtils.equals(getVisualTransform(), newTransform)) { setVisualTransform(newTransform); } } Dimension size = ZestProperties.getSize(node); if (size != null) { // XXX: Resize is needed even though the visual size is already // up-to-date, because otherwise a nesting node might be resized to // 0, 0 (unknown reason, need debug). getVisual().resize(size.width, size.height); } else { getVisual().autosize(); } }
Example 11
Source File: JFXRippler.java From JFoenix with Apache License 2.0 | 4 votes |
private Ripple(double centerX, double centerY) { super(centerX, centerY, ripplerRadius.get().doubleValue() == Region.USE_COMPUTED_SIZE ? computeRippleRadius() : ripplerRadius.get().doubleValue(), null); setCache(true); setCacheHint(CacheHint.SPEED); setCacheShape(true); setManaged(false); setSmooth(true); KeyValue[] inKeyValues = new KeyValue[isRipplerRecenter() ? 4 : 2]; outKeyValues = new KeyValue[isRipplerRecenter() ? 5 : 3]; inKeyValues[0] = new KeyValue(scaleXProperty(), 0.9, rippleInterpolator); inKeyValues[1] = new KeyValue(scaleYProperty(), 0.9, rippleInterpolator); outKeyValues[0] = new KeyValue(this.scaleXProperty(), 1, rippleInterpolator); outKeyValues[1] = new KeyValue(this.scaleYProperty(), 1, rippleInterpolator); outKeyValues[2] = new KeyValue(this.opacityProperty(), 0, rippleInterpolator); if (isRipplerRecenter()) { double dx = (control.getLayoutBounds().getWidth() / 2 - centerX) / 1.55; double dy = (control.getLayoutBounds().getHeight() / 2 - centerY) / 1.55; inKeyValues[2] = outKeyValues[3] = new KeyValue(translateXProperty(), Math.signum(dx) * Math.min(Math.abs(dx), this.getRadius() / 2), rippleInterpolator); inKeyValues[3] = outKeyValues[4] = new KeyValue(translateYProperty(), Math.signum(dy) * Math.min(Math.abs(dy), this.getRadius() / 2), rippleInterpolator); } inAnimation = new Timeline(new KeyFrame(Duration.ZERO, new KeyValue(scaleXProperty(), 0, rippleInterpolator), new KeyValue(scaleYProperty(), 0, rippleInterpolator), new KeyValue(translateXProperty(), 0, rippleInterpolator), new KeyValue(translateYProperty(), 0, rippleInterpolator), new KeyValue(opacityProperty(), 1, rippleInterpolator) ), new KeyFrame(Duration.millis(900), inKeyValues)); setScaleX(0); setScaleY(0); if (ripplerFill.get() instanceof Color) { Color circleColor = new Color(((Color) ripplerFill.get()).getRed(), ((Color) ripplerFill.get()).getGreen(), ((Color) ripplerFill.get()).getBlue(), 0.3); setStroke(circleColor); setFill(circleColor); } else { setStroke(ripplerFill.get()); setFill(ripplerFill.get()); } }
Example 12
Source File: JFXRippler.java From JFoenix with Apache License 2.0 | 4 votes |
public Number getRipplerRadius() { return ripplerRadius == null ? Region.USE_COMPUTED_SIZE : ripplerRadius.get(); }