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


Java Rectangle2D.contains方法代码示例

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


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

示例1: getInsertData

import javafx.geometry.Rectangle2D; //导入方法依赖的package包/类
private InsertData getInsertData(Point2D screenPoint) {
    for(TabPane tabPane : tabPanes) {
        Rectangle2D tabAbsolute = getAbsoluteRect(tabPane);
        if(tabAbsolute.contains(screenPoint)) {
            int tabInsertIndex = 0;
            if(!tabPane.getTabs().isEmpty()) {
                Rectangle2D firstTabRect = getAbsoluteRect(tabPane.getTabs().get(0));
                if(firstTabRect.getMaxY()+60 < screenPoint.getY() || firstTabRect.getMinY() > screenPoint.getY()) {
                    return null;
                }
                Rectangle2D lastTabRect = getAbsoluteRect(tabPane.getTabs().get(tabPane.getTabs().size() - 1));
                if(screenPoint.getX() < (firstTabRect.getMinX() + firstTabRect.getWidth() / 2)) {
                    tabInsertIndex = 0;
                }
                else if(screenPoint.getX() > (lastTabRect.getMaxX() - lastTabRect.getWidth() / 2)) {
                    tabInsertIndex = tabPane.getTabs().size();
                }
                else {
                    for(int i = 0; i < tabPane.getTabs().size() - 1; i++) {
                        Tab leftTab = tabPane.getTabs().get(i);
                        Tab rightTab = tabPane.getTabs().get(i + 1);
                        if(leftTab instanceof DraggableTab && rightTab instanceof DraggableTab) {
                            Rectangle2D leftTabRect = getAbsoluteRect(leftTab);
                            Rectangle2D rightTabRect = getAbsoluteRect(rightTab);
                            if(betweenX(leftTabRect, rightTabRect, screenPoint.getX())) {
                                tabInsertIndex = i + 1;
                                break;
                            }
                        }
                    }
                }
            }
            return new InsertData(tabInsertIndex, tabPane);
        }
    }
    return null;
}
 
开发者ID:ForJ-Latech,项目名称:fwm,代码行数:38,代码来源:DraggableTab.java

示例2: findClickedPiece

import javafx.geometry.Rectangle2D; //导入方法依赖的package包/类
private Piece findClickedPiece(MouseEvent event) {
    for (Piece piece : controller.getPiecesInNormalOrder()) {
        Rectangle2D pieceRect = new Rectangle2D(piece.getXPos(), piece.getYPos(), piece.getWidth(), piece.getHeight());
        if (pieceRect.contains(event.getSceneX(), event.getSceneY())) {
            return piece;
        }
    }
    return null;
}
 
开发者ID:luxmeter,项目名称:puzzlefx,代码行数:10,代码来源:SwapHandler.java

示例3: getInsertData

import javafx.geometry.Rectangle2D; //导入方法依赖的package包/类
private InsertData getInsertData(final Point2D screenPoint)
{
    for (final TabPane tabPane : TabManagement.getInstance().getTabPanes())
    {
        final Rectangle2D tabAbsolute = this.getAbsoluteRect(tabPane);
        if (tabAbsolute.contains(screenPoint))
        {
            int tabInsertIndex = 0;
            if (!tabPane.getTabs().isEmpty())
            {
                final Rectangle2D firstTabRect = this.getAbsoluteRect(tabPane.getTabs().get(0));
                if (firstTabRect.getMaxY() + 60 < screenPoint.getY() || firstTabRect.getMinY() > screenPoint.getY())
                    return null;
                final Rectangle2D lastTabRect = this
                        .getAbsoluteRect(tabPane.getTabs().get(tabPane.getTabs().size() - 1));
                if (screenPoint.getX() < firstTabRect.getMinX() + firstTabRect.getWidth() / 2)
                    tabInsertIndex = 0;
                else if (screenPoint.getX() > lastTabRect.getMaxX() - lastTabRect.getWidth() / 2)
                    tabInsertIndex = tabPane.getTabs().size();
                else
                    for (int i = 0; i < tabPane.getTabs().size() - 1; i++)
                    {
                        final Tab leftTab = tabPane.getTabs().get(i);
                        final Tab rightTab = tabPane.getTabs().get(i + 1);
                        if (leftTab instanceof DraggableTab && rightTab instanceof DraggableTab)
                        {
                            final Rectangle2D leftTabRect = this.getAbsoluteRect(leftTab);
                            final Rectangle2D rightTabRect = this.getAbsoluteRect(rightTab);
                            if (this.betweenX(leftTabRect, rightTabRect, screenPoint.getX()))
                            {
                                tabInsertIndex = i + 1;
                                break;
                            }
                        }
                    }
            }
            return new InsertData(tabInsertIndex, tabPane);
        }
    }
    return null;
}
 
开发者ID:Leviathan-Studio,项目名称:MineIDE,代码行数:42,代码来源:DraggableTab.java


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