Java Code Examples for javafx.geometry.Side#TOP

The following examples show how to use javafx.geometry.Side#TOP . 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: HiddenSidesPaneSkin.java    From chart-fx with Apache License 2.0 6 votes vote down vote up
private Side getSide(MouseEvent evt) {
    if (stackPane.getBoundsInLocal().contains(evt.getX(), evt.getY())) {
        final double trigger = getSkinnable().getTriggerDistance();
        // changed to check for trigger only for side-panes with actual content
        if (evt.getX() <= trigger && getSkinnable().getLeft() != null) {
            return Side.LEFT;
        } else if (evt.getX() > getSkinnable().getWidth() - trigger && getSkinnable().getRight() != null) {
            return Side.RIGHT;
        } else if (evt.getY() <= trigger && getSkinnable().getTop() != null) {
            return Side.TOP;
        } else if (evt.getY() > getSkinnable().getHeight() - trigger && getSkinnable().getBottom() != null) {
            return Side.BOTTOM;
        }
    }

    return null;
}
 
Example 2
Source File: FlatTab.java    From oim-fx with MIT License 6 votes vote down vote up
private void updateBottomLine() {
	if (Side.TOP == side) {
		borderPane.setTop(hBox);
		hBox.setMinHeight(bottomLineSize);
	} else if (Side.RIGHT == side) {
		borderPane.setRight(hBox);
		hBox.setMinWidth(bottomLineSize);
	} else if (Side.BOTTOM == side) {
		borderPane.setBottom(hBox);
		hBox.setMinHeight(bottomLineSize);
	} else if (Side.LEFT == side) {
		borderPane.setLeft(hBox);
		hBox.setMinWidth(bottomLineSize);
	} else {
		borderPane.setBottom(hBox);
		hBox.setMinHeight(bottomLineSize);
	}
}
 
Example 3
Source File: FlatTabPane.java    From oim-fx with MIT License 6 votes vote down vote up
private void add(Node tab) {
	if (Side.TOP == side) {
		hBox.getChildren().add(tab);
		HBox.setHgrow(tab, Priority.ALWAYS);
	} else if (Side.RIGHT == side) {
		vBox.getChildren().add(tab);
		VBox.setVgrow(tab, Priority.ALWAYS);
	} else if (Side.BOTTOM == side) {
		hBox.getChildren().add(tab);
		HBox.setHgrow(tab, Priority.ALWAYS);
	} else if (Side.LEFT == side) {
		vBox.getChildren().add(tab);
		VBox.setVgrow(tab, Priority.ALWAYS);
	} else {
		hBox.getChildren().add(tab);
		HBox.setHgrow(tab, Priority.ALWAYS);
	}
}
 
Example 4
Source File: FlatTabPane.java    From oim-fx with MIT License 6 votes vote down vote up
public void selected(int index) {
	Node node = null;
	if (Side.TOP == side) {
		node = hBox.getChildren().get(index);
	} else if (Side.RIGHT == side) {
		node = vBox.getChildren().get(index);
	} else if (Side.BOTTOM == side) {
		node = hBox.getChildren().get(index);
	} else if (Side.LEFT == side) {
		node = vBox.getChildren().get(index);
	} else {
		node = hBox.getChildren().get(index);
	}
	if (node instanceof FlatTab) {
		FlatTab tabTemp = (FlatTab) node;
		selected(tabTemp);
	}
}
 
Example 5
Source File: Tab.java    From oim-fx with MIT License 6 votes vote down vote up
public void setSide(Side side) {
	if (Side.TOP == side) {
		borderPane.setTop(hBox);
		hBox.setMinHeight(2);
	} else if (Side.RIGHT == side) {
		borderPane.setRight(hBox);
		hBox.setMinWidth(2);
	} else if (Side.BOTTOM == side) {
		borderPane.setBottom(hBox);
		hBox.setMinHeight(2);
	} else if (Side.LEFT == side) {
		borderPane.setLeft(hBox);
		hBox.setMinWidth(2);
	} else {
		borderPane.setBottom(hBox);
		hBox.setMinHeight(2);
	}
}
 
Example 6
Source File: PopOver.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
/** @param owner_bounds Bounds of active owner
 *  @return Suggested Side for the popup
 */
private Side determineSide(final Bounds owner_bounds)
{
    // Determine center of active owner
    final double owner_x = owner_bounds.getMinX() + owner_bounds.getWidth()/2;
    final double owner_y = owner_bounds.getMinY() + owner_bounds.getHeight()/2;

    // Locate screen
    Rectangle2D screen_bounds = ScreenUtil.getScreenBounds(owner_x, owner_y);
    if (screen_bounds == null)
        return Side.BOTTOM;

    // left .. right as -0.5 .. +0.5
    double lr = (owner_x - screen_bounds.getMinX())/screen_bounds.getWidth() - 0.5;
    // top..buttom as -0.5 .. +0.5
    double tb = (owner_y - screen_bounds.getMinY())/screen_bounds.getHeight() - 0.5;

    // More left/right from center, or top/bottom from center of screen?
    if (Math.abs(lr) > Math.abs(tb))
        return (lr < 0) ? Side.RIGHT : Side.LEFT;
    else
        return (tb < 0) ? Side.BOTTOM : Side.TOP;
}
 
Example 7
Source File: FlatTabPane.java    From oim-fx with MIT License 5 votes vote down vote up
public void setTabSize(double value) {
	if (Side.TOP == side) {
		hBox.setPrefHeight(value);
	} else if (Side.RIGHT == side) {
		vBox.setPrefWidth(value);
	} else if (Side.BOTTOM == side) {
		hBox.setPrefHeight(value);
	} else if (Side.LEFT == side) {
		vBox.setPrefWidth(value);
	} else {
		hBox.setPrefHeight(value);
	}
}
 
Example 8
Source File: FlatTabPane.java    From oim-fx with MIT License 5 votes vote down vote up
public void setTabPadding(Insets value) {
	if (Side.TOP == side) {
		hBox.setPadding(value);
	} else if (Side.RIGHT == side) {
		vBox.setPadding(value);
	} else if (Side.BOTTOM == side) {
		hBox.setPadding(value);
	} else if (Side.LEFT == side) {
		vBox.setPadding(value);
	} else {
		hBox.setPadding(value);
	}
}
 
Example 9
Source File: Toast.java    From DevToolBox with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void show(Node anchor, Side side, double offsetX, double offsetY) {
    if (anchor == null) {
        return;
    }
    autoCenter = false;

    HPos hpos = side == Side.LEFT ? HPos.LEFT : side == Side.RIGHT ? HPos.RIGHT : HPos.CENTER;
    VPos vpos = side == Side.TOP ? VPos.TOP : side == Side.BOTTOM ? VPos.BOTTOM : VPos.CENTER;
    // translate from anchor/hpos/vpos/offsetX/offsetY into screenX/screenY
    Point2D point = Utils.pointRelativeTo(anchor, content.prefWidth(-1), content.prefHeight(-1), hpos, vpos, offsetX, offsetY, true);
    this.show(anchor, point.getX(), point.getY());
}
 
Example 10
Source File: InfiniteCanvas.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Repaints the tile image that depends on the grid cell size only. The tile
 * image is repeated when repainting the grid.
 */
protected void repaintGrid() {
	Image tile = createGridTile();
	// create a background fill for this node from the tile image
	BackgroundPosition backgroundPosition = new BackgroundPosition(
			Side.LEFT, 0, false, Side.TOP, 0, false);
	BackgroundImage backgroundImage = new BackgroundImage(tile,
			BackgroundRepeat.REPEAT, BackgroundRepeat.REPEAT,
			backgroundPosition, BackgroundSize.DEFAULT);
	Background background = new Background(backgroundImage);
	// apply that background fill
	grid.setBackground(background);
}
 
Example 11
Source File: GraphEditorDemoController.java    From graph-editor with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Gets the side corresponding to the currently selected connector position in the menu.
 *
 * @return the {@link Side} corresponding to the currently selected connector position
 */
private Side getSelectedConnectorPosition() {

    if (leftConnectorPositionButton.isSelected()) {
        return Side.LEFT;
    } else if (rightConnectorPositionButton.isSelected()) {
        return Side.RIGHT;
    } else if (topConnectorPositionButton.isSelected()) {
        return Side.TOP;
    } else {
        return Side.BOTTOM;
    }
}
 
Example 12
Source File: DefaultConnectorTypes.java    From graph-editor with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Gets the side corresponding to the given connector type.
 * 
 * @param type a non-null connector type
 * @return the {@link Side} the connector type is on
 */
public static Side getSide(final String type) {

    if (isTop(type)) {
        return Side.TOP;
    } else if (isRight(type)) {
        return Side.RIGHT;
    } else if (isBottom(type)) {
        return Side.BOTTOM;
    } else if (isLeft(type)) {
        return Side.LEFT;
    } else {
        return null;
    }
}
 
Example 13
Source File: Workbench.java    From WorkbenchFX with Apache License 2.0 4 votes vote down vote up
/**
 * Shows the {@code drawer} on the defined {@code side} in the {@link Workbench}, ensuring the
 * {@code drawer} doesn't cover more than the specified {@code percentage}.
 *
 * @param drawer     to be shown
 * @param side       of the workbench, on which the {@code drawer} should be positioned
 * @param percentage value between 0 and 100, defining how much <b>maximum</b> coverage the drawer
 *                   should have or -1, to have the drawer size according to its computed size
 */
public final void showDrawer(Region drawer, Side side, int percentage) {
  // fail fast
  if (!Range.closed(0, MAX_PERCENT).or(number -> number == -1).test(percentage)) {
    throw new IllegalArgumentException("Percentage needs to be between 0 and 100 or -1");
  }
  Pos position;
  drawer.minWidthProperty().unbind();
  drawer.maxWidthProperty().unbind();
  drawer.minHeightProperty().unbind();
  drawer.maxHeightProperty().unbind();
  switch (side) {
    case TOP:
      // fall through to BOTTOM
    case BOTTOM:
      position = side == Side.TOP ? Pos.TOP_LEFT : Pos.BOTTOM_LEFT;
      drawer.minWidthProperty().bind(widthProperty());
      if (percentage == -1) {
        bindDrawerHeight(drawer);
      } else {
        drawer.maxHeightProperty().bind(
            heightProperty().multiply((double) percentage / MAX_PERCENT));
      }
      break;
    case RIGHT:
      // fall through to LEFT
    default: // LEFT
      position = side == Side.LEFT ? Pos.TOP_LEFT : Pos.TOP_RIGHT;
      drawer.minHeightProperty().bind(heightProperty());
      if (percentage == -1) {
        bindDrawerWidth(drawer);
      } else {
        drawer.maxWidthProperty().bind(
            widthProperty().multiply((double) percentage / MAX_PERCENT));
      }
      break;
  }
  StackPane.setAlignment(drawer, position);
  drawer.getStyleClass().add("drawer");
  setDrawerSideShown(side);
  setDrawerShown(drawer);
}
 
Example 14
Source File: DockKey.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public DockKey(String dockKey, String name) {
    this(dockKey, name, null, null, null, Side.TOP);
}