当前位置: 首页>>代码示例>>Java>>正文


Java Bounds.getWidth方法代码示例

本文整理汇总了Java中javafx.geometry.Bounds.getWidth方法的典型用法代码示例。如果您正苦于以下问题:Java Bounds.getWidth方法的具体用法?Java Bounds.getWidth怎么用?Java Bounds.getWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.geometry.Bounds的用法示例。


在下文中一共展示了Bounds.getWidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ensureVisible

import javafx.geometry.Bounds; //导入方法依赖的package包/类
private static void ensureVisible(ScrollPane pane, Node node) {
    Bounds viewport = pane.getViewportBounds();
    double contentHeight = pane.getContent().getBoundsInLocal().getHeight();
    double contentWidth = pane.getContent().getBoundsInLocal().getWidth();
    double nodeMinY = node.getBoundsInParent().getMinY();
    double nodeMaxY = node.getBoundsInParent().getMaxY();
    double nodeMinX = node.getBoundsInParent().getMinX();
    double nodeMaxX = node.getBoundsInParent().getMaxX();
    double viewportMinY = (contentHeight - viewport.getHeight()) * pane.getVvalue();
    double viewportMaxY = viewportMinY + viewport.getHeight();
    double viewportMinX = (contentWidth - viewport.getWidth()) * pane.getHvalue();
    double viewportMaxX = viewportMinX + viewport.getWidth();
    if (nodeMinY < viewportMinY) {
        pane.setVvalue(nodeMinY / (contentHeight - viewport.getHeight()));
    } else if (nodeMaxY > viewportMaxY) {
        pane.setVvalue((nodeMaxY - viewport.getHeight()) / (contentHeight - viewport.getHeight()));
    }
    if (nodeMinX < viewportMinX) {
        pane.setHvalue(nodeMinX / (contentWidth - viewport.getWidth()));
    } else if (nodeMaxX > viewportMaxX) {
        pane.setHvalue((nodeMaxX - viewport.getWidth()) / (contentWidth - viewport.getWidth()));
    }

}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:25,代码来源:ImagePanel.java

示例2: ensureVisible

import javafx.geometry.Bounds; //导入方法依赖的package包/类
protected void ensureVisible(Node target) {
    ScrollPane scrollPane = getParentScrollPane(target);
    if (scrollPane == null) {
        return;
    }
    Node content = scrollPane.getContent();
    Bounds contentBounds = content.localToScene(content.getBoundsInLocal());
    Bounds viewportBounds = scrollPane.getViewportBounds();
    Bounds nodeBounds = target.localToScene(target.getBoundsInLocal());
    if (scrollPane.contains(nodeBounds.getMinX() - contentBounds.getMinX(), nodeBounds.getMinY() - contentBounds.getMinY())) {
        return;
    }
    double toVScroll = (nodeBounds.getMinY() - contentBounds.getMinY())
            * ((scrollPane.getVmax() - scrollPane.getVmin()) / (contentBounds.getHeight() - viewportBounds.getHeight()));
    scrollPane.setVvalue(toVScroll);
    double toHScroll = (nodeBounds.getMinX() - contentBounds.getMinX())
            * ((scrollPane.getHmax() - scrollPane.getHmin()) / (contentBounds.getWidth() - viewportBounds.getWidth()));
    scrollPane.setHvalue(toHScroll);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:20,代码来源:FXEventQueueDevice.java

示例3: scrollTo

import javafx.geometry.Bounds; //导入方法依赖的package包/类
private void scrollTo(Node target) {
	ScrollPane scrollPane = getParentScrollPane(target);
	if (scrollPane == null)
		return;
	Node content = scrollPane.getContent();
	Bounds contentBounds = content.localToScene(content.getBoundsInLocal());
	Bounds viewportBounds = scrollPane.getViewportBounds();
	Bounds nodeBounds = target.localToScene(target.getBoundsInLocal());
	double toVScroll = (nodeBounds.getMinY() - contentBounds.getMinY())
			* ((scrollPane.getVmax() - scrollPane.getVmin())
					/ (contentBounds.getHeight() - viewportBounds.getHeight()));
	if (toVScroll >= scrollPane.getVmin() && toVScroll < scrollPane.getVmax())
		scrollPane.setVvalue(toVScroll);
	double toHScroll = (nodeBounds.getMinX() - contentBounds.getMinX())
			* ((scrollPane.getHmax() - scrollPane.getHmin())
					/ (contentBounds.getWidth() - viewportBounds.getWidth()));
	if (toHScroll >= scrollPane.getHmin() && toHScroll < scrollPane.getHmax())
		scrollPane.setHvalue(toHScroll);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:20,代码来源:ScrollPaneSample2.java

示例4: centerContent

import javafx.geometry.Bounds; //导入方法依赖的package包/类
void centerContent() {
    Bounds contentLayoutBounds = view.getContent().getLayoutBounds();
    double contentWidth = contentLayoutBounds.getWidth();
    double contentHeight = contentLayoutBounds.getHeight();
    double rootWidth = view.getRoot().getLayoutBounds().getWidth();
    double rootHeight = view.getRoot().getLayoutBounds().getHeight();
    double contentStartX = Math.round((rootWidth - contentWidth) / 2);
    double contentStartY = Math.round((rootHeight - contentHeight) / 2);
    view.getContent().setLayoutX(contentStartX - contentLayoutBounds.getMinX());
    view.getContent().setLayoutY(contentStartY - contentLayoutBounds.getMinY());
}
 
开发者ID:rmfisher,项目名称:fx-animation-editor,代码行数:12,代码来源:PanningPresenter.java

示例5: _getMidpoint

import javafx.geometry.Bounds; //导入方法依赖的package包/类
@Override public Point2D _getMidpoint() {
    Node cell = getPseudoComponent();
    Bounds boundsInParent = cell.getBoundsInParent();
    double x = boundsInParent.getWidth() / 2;
    double y = boundsInParent.getHeight() / 2;
    return cell.getParent().localToParent(cell.localToParent(x, y));
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:8,代码来源:JavaFXTableCellElement.java

示例6: _getMidpoint

import javafx.geometry.Bounds; //导入方法依赖的package包/类
@Override public Point2D _getMidpoint() {
    TreeView<?> treeView = (TreeView<?>) getComponent();
    Node cell = getCellAt(treeView, getPath(treeView, path));
    Bounds boundsInParent = cell.getBoundsInParent();
    double x = boundsInParent.getWidth() / 2;
    double y = boundsInParent.getHeight() / 2;
    return cell.localToParent(x, y);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:9,代码来源:JavaFXTreeViewNodeElement.java

示例7: _getMidpoint

import javafx.geometry.Bounds; //导入方法依赖的package包/类
@Override public Point2D _getMidpoint() {
    Node cell = getPseudoComponent();
    Bounds boundsInParent = cell.getBoundsInParent();
    double x = boundsInParent.getWidth() / 2;
    double y = boundsInParent.getHeight() / 2;
    return cell.localToParent(x, y);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:8,代码来源:JavaFXListViewItemElement.java

示例8: _getMidpoint

import javafx.geometry.Bounds; //导入方法依赖的package包/类
@Override public Point2D _getMidpoint() {
    StackPane tabRegion = getTabRegion();
    Bounds boundsInParent = tabRegion.getBoundsInParent();
    double x = boundsInParent.getWidth() / 2;
    double y = boundsInParent.getHeight() / 2;
    return tabRegion.localToParent(x, y);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:8,代码来源:JavaFXTabPaneTabJavaElement.java

示例9: doOnMouseMoved

import javafx.geometry.Bounds; //导入方法依赖的package包/类
private void doOnMouseMoved(final MouseEvent e) {
	final int mouseMovedDeltaX = this.mouseMovedDeltaX.get();
	final int mouseMovedDeltaY = this.mouseMovedDeltaY.get();
	
	this.mouseMovementTime.set(System.currentTimeMillis());
	
	if(mouseMovedDeltaX != 0 || mouseMovedDeltaY != 0) {
		this.mouseMovedX.addAndGet(this.mouseMovedDeltaX.get() - (int)(e.getScreenX()));
		this.mouseMovedY.addAndGet(this.mouseMovedDeltaY.get() - (int)(e.getScreenY()));
	}
	
	this.mouseX.set((int)(e.getX()));
	this.mouseY.set((int)(e.getY()));
	
	onMouseMoved(this.mouseMovedX.getAndSet(0), this.mouseMovedY.getAndSet(0));
	
	if(isMouseRecentering()) {
		final Bounds bounds = this.canvas.localToScreen(this.canvas.getBoundsInLocal());
		
		final int minX = (int)(bounds.getMinX());
		final int minY = (int)(bounds.getMinY());
		final int width = (int)(bounds.getWidth());
		final int height = (int)(bounds.getHeight());
		final int x = minX + width / 2;
		final int y = minY + height / 2;
		
		this.robot.mouseMove(x, y);
		
		this.mouseMovedDeltaX.set(x);
		this.mouseMovedDeltaY.set(y);
	} else {
		this.mouseMovedDeltaX.set((int)(e.getScreenX()));
		this.mouseMovedDeltaY.set((int)(e.getScreenY()));
	}
}
 
开发者ID:macroing,项目名称:Dayflower-Path-Tracer,代码行数:36,代码来源:AbstractApplication.java

示例10: setPosition

import javafx.geometry.Bounds; //导入方法依赖的package包/类
void setPosition(Point2D topLeft) {
	if (topLeft == null) {
		setDefaultPosition();
		return;
	}
	Bounds bounds = getLayoutBounds();
	Rectangle2D rect = new Rectangle2D(topLeft.getX(), topLeft.getY(),
			bounds.getWidth(), bounds.getHeight());
	for (Screen screen : Screen.getScreens()) {
		rect = snapRect(rect, screen.getBounds());
		rect = snapRect(rect, screen.getVisualBounds());
	}
	relocate(rect.getMinX(), rect.getMinY());
}
 
开发者ID:DeskChan,项目名称:DeskChan,代码行数:15,代码来源:MovablePane.java

示例11: moveTo

import javafx.geometry.Bounds; //导入方法依赖的package包/类
@Override
public RNode<T> moveTo(Duration d, Pos referencePoint, double _x, double _y) {
	double x;
	double y;
	
	Bounds bounds = node.localToScreen(node.getBoundsInLocal());
	switch (referencePoint.getHpos()) {
	case CENTER:
		x = bounds.getMinX() + bounds.getWidth()/2;
		break;
	case RIGHT:
		x = bounds.getMaxX();
		break;
	default:
		x = bounds.getMinX();
		break;
	}
	
	switch (referencePoint.getVpos()) {
	case BOTTOM:
	case BASELINE:
		y = bounds.getMaxY();
		break;
	case CENTER:
		y = bounds.getMinY() + bounds.getHeight()/2;
		break;
	default:
		y = bounds.getMinY();
		break;
	}
	
	controller.run(Move.to(d, x+_x, y+_y));
	return this;
}
 
开发者ID:BestSolution-at,项目名称:FX-Test,代码行数:35,代码来源:RNodeImpl.java

示例12: location

import javafx.geometry.Bounds; //导入方法依赖的package包/类
@Override
public Point2D location(Pos position) {
	double x;
	double y;
	
	Bounds bounds = node.localToScreen(node.getBoundsInLocal());
	switch (position.getHpos()) {
	case CENTER:
		x = bounds.getMinX() + bounds.getWidth()/2;
		break;
	case RIGHT:
		x = bounds.getMaxX();
		break;
	default:
		x = bounds.getMinX();
		break;
	}
	
	switch (position.getVpos()) {
	case BOTTOM:
	case BASELINE:
		y = bounds.getMaxY();
		break;
	case CENTER:
		y = bounds.getMinY() + bounds.getHeight()/2;
		break;
	default:
		y = bounds.getMinY();
		break;
	}
	return new Point2D(x, y);
}
 
开发者ID:BestSolution-at,项目名称:FX-Test,代码行数:33,代码来源:RNodeImpl.java

示例13: rotatorMouseDragged

import javafx.geometry.Bounds; //导入方法依赖的package包/类
@FXML void rotatorMouseDragged(MouseEvent e) {
    final Parent p = rotator_dial.getParent();
    final Bounds b = rotator_dial.getLayoutBounds();
    final Double centerX = b.getMinX() + (b.getWidth() / 2);
    final Double centerY = b.getMinY() + (b.getHeight() / 2);
    final Point2D center = p.localToParent(centerX, centerY);
    final Point2D mouse = p.localToParent(e.getX(), e.getY());
    final Double deltaX = mouse.getX() - center.getX();
    final Double deltaY = mouse.getY() - center.getY();
    final Double radians = Math.atan2(deltaY, deltaX);
    rotate(Math.toDegrees(radians));
}
 
开发者ID:EricCanull,项目名称:fxexperience2,代码行数:13,代码来源:RotatorControl.java

示例14: applyLayout

import javafx.geometry.Bounds; //导入方法依赖的package包/类
/**
 * Applies the layout values set up using the setBounds methods.
 */
protected void applyLayout() {
    rectangle.setX(rect.getX() + padding);
    rectangle.setY(rect.getY() + padding);
    rectangle.setWidth(rect.getWidth() - 2.0 * padding);
    rectangle.setHeight(rect.getHeight() - 2.0 * padding);
    //
    label.setRotate(0);
    Bounds textBounds = label.getLayoutBounds();
    boolean verticalText;
    double textHeight;
    double textWidth;
    if (textBounds != null) {
        textHeight = textBounds.getHeight();
        textWidth = textBounds.getWidth();
    } else {
        textHeight = DEFAULT_TEXT_HEIGHT;
        textWidth = DEFAULT_TEXT_WIDTH;
    }
    verticalText = textBounds != null ? textBounds.getWidth() > rectangle.getWidth() - 2 * TEXT_PADDING : false;
    //
    if (!verticalText) {
        label.setTranslateX(rectangle.getX() + TEXT_PADDING);
        label.setTranslateY(rectangle.getY() + TEXT_PADDING);
        label.setRotate(0);
        label.setTextAlignment(TextAlignment.LEFT);
        label.setMaxWidth(rectangle.getWidth() - 2 * TEXT_PADDING);
    } else {
        label.setTranslateX(rectangle.getX() + TEXT_PADDING - textHeight);
        label.setTranslateY(rectangle.getY() + rectangle.getHeight() - textWidth);
        label.setRotate(-90);
        label.setTextAlignment(TextAlignment.LEFT);
        label.setMaxWidth(rectangle.getHeight() - 2 * TEXT_PADDING);
    }
}
 
开发者ID:PtitNoony,项目名称:FxTreeMap,代码行数:38,代码来源:FxMapItem.java

示例15: openEditor

import javafx.geometry.Bounds; //导入方法依赖的package包/类
private void openEditor() {

        final PopOver popOver = new PopOver();
        final TextField textEditor = new TextField(targetText.getText());
        BorderPane editorPane = new BorderPane(textEditor);

        BorderPane.setMargin(textEditor, new Insets(12));
        textEditor.setOnKeyReleased(e -> {
            if ( KeyCode.ESCAPE.equals(e.getCode()) ) {
                popOver.hide();
            }
        });
        textEditor.setOnAction(e -> {
            try {
                setTargetValue(Double.parseDouble(textEditor.getText()));
                fireTargeValueSet();
            } catch ( NumberFormatException nfex ) {
                Toolkit.getDefaultToolkit().beep();
            } finally {
                popOver.hide();
            }
        });

        popOver.setContentNode(editorPane);
        popOver.setDetachable(false);
        popOver.setDetached(false);
        popOver.setArrowLocation(PopOver.ArrowLocation.TOP_CENTER);
        popOver.setHeaderAlwaysVisible(true);
        popOver.setHideOnEscape(true);
        popOver.setTitle("Set Target Value");
        popOver.setAnimated(true);
        popOver.setAutoHide(true);
        popOver.setCloseButtonEnabled(true);

        text.getScene().getStylesheets().stream().forEach(s -> popOver.getRoot().getStylesheets().add(s));

        Bounds bounds = getBoundsInLocal();
        Bounds screenBounds = localToScreen(bounds);
        int x = (int) screenBounds.getMinX();
        int y = (int) screenBounds.getMinY();
        int w = (int) screenBounds.getWidth();
        int h = (int) screenBounds.getHeight();

        popOver.show(this, x + w / 2, y + h / 2);
        
    }
 
开发者ID:ESSICS,项目名称:KNOBS,代码行数:47,代码来源:Knob.java


注:本文中的javafx.geometry.Bounds.getWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。