本文整理汇总了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;
}
示例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;
}
示例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;
}