本文整理匯總了Java中javafx.geometry.Rectangle2D.getHeight方法的典型用法代碼示例。如果您正苦於以下問題:Java Rectangle2D.getHeight方法的具體用法?Java Rectangle2D.getHeight怎麽用?Java Rectangle2D.getHeight使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.geometry.Rectangle2D
的用法示例。
在下文中一共展示了Rectangle2D.getHeight方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: start
import javafx.geometry.Rectangle2D; //導入方法依賴的package包/類
@Override
public void start(Stage stage) throws Exception {
Flow flow = new Flow(MainController.class);
DefaultFlowContainer container = new DefaultFlowContainer();
flowContext = new ViewFlowContext();
flowContext.register("Stage", stage);
flow.createHandler(flowContext).start(container);
JFXDecorator decorator = new JFXDecorator(stage, container.getView());
decorator.setCustomMaximize(true);
double width = 700;
double height = 200;
try {
Rectangle2D bounds = Screen.getScreens().get(0).getBounds();
width = bounds.getWidth() / 2.5;
height = bounds.getHeight() / 1.35;
} catch (Exception e) {
}
Scene scene = new Scene(decorator, width, height);
final ObservableList<String> stylesheets = scene.getStylesheets();
stylesheets.addAll(Main.class.getResource("/css/jfoenix-fonts.css").toExternalForm(),
Main.class.getResource("/css/jfoenix-design.css").toExternalForm(),
Main.class.getResource("/css/jhosts-main.css").toExternalForm());
stage.setScene(scene);
stage.show();
}
示例2: snapRect
import javafx.geometry.Rectangle2D; //導入方法依賴的package包/類
private static Rectangle2D snapRect(Rectangle2D bounds, Rectangle2D screenBounds) {
double x1 = bounds.getMinX(), y1 = bounds.getMinY();
double x2 = bounds.getMaxX(), y2 = bounds.getMaxY();
if (Math.abs(x1 - screenBounds.getMinX()) < SNAP_DISTANCE) {
x1 = screenBounds.getMinX();
}
if (Math.abs(y1 - screenBounds.getMinY()) < SNAP_DISTANCE) {
y1 = screenBounds.getMinY();
}
if (Math.abs(x2 - screenBounds.getMaxX()) < SNAP_DISTANCE) {
x1 = screenBounds.getMaxX() - bounds.getWidth();
}
if (Math.abs(y2 - screenBounds.getMaxY()) < SNAP_DISTANCE) {
y1 = screenBounds.getMaxY() - bounds.getHeight();
}
return new Rectangle2D(x1, y1, bounds.getWidth(), bounds.getHeight());
}
示例3: loadPositionFromStorage
import javafx.geometry.Rectangle2D; //導入方法依賴的package包/類
protected void loadPositionFromStorage() {
try {
final String key = getCurrentPositionStorageKey();
if (key != null) {
final String value = Main.getProperties().getString(key);
if (value != null) {
String[] coords = value.split(";");
if (coords.length == 2) {
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
Rectangle2D desktop = OverlayStage.getDesktopSize();
if(desktop.getWidth() == 0 || desktop.getHeight() == 0) return;
if (x + getHeight() > desktop.getMaxX() || x < -getHeight())
x = desktop.getMaxX() - getHeight();
if (y + getWidth() > desktop.getMaxY() || y < -getWidth()) y = desktop.getMaxY() - getWidth();
setPosition(new Point2D(x, y));
return;
}
}
}
} catch (Exception e){ Main.log(e); }
setDefaultPosition();
}
示例4: findPopOverArrowLocation
import javafx.geometry.Rectangle2D; //導入方法依賴的package包/類
public static ArrowLocation findPopOverArrowLocation(Node view) {
Bounds localBounds = view.getBoundsInLocal();
Bounds entryBounds = view.localToScreen(localBounds);
ObservableList<Screen> screens = Screen.getScreensForRectangle(
entryBounds.getMinX(), entryBounds.getMinY(),
entryBounds.getWidth(), entryBounds.getHeight());
Rectangle2D screenBounds = screens.get(0).getVisualBounds();
double spaceLeft = entryBounds.getMinX();
double spaceRight = screenBounds.getWidth() - entryBounds.getMaxX();
double spaceTop = entryBounds.getMinY();
double spaceBottom = screenBounds.getHeight() - entryBounds.getMaxY();
if (spaceLeft > spaceRight) {
if (spaceTop > spaceBottom) {
return ArrowLocation.RIGHT_BOTTOM;
}
return ArrowLocation.RIGHT_TOP;
}
if (spaceTop > spaceBottom) {
return ArrowLocation.LEFT_BOTTOM;
}
return ArrowLocation.LEFT_TOP;
}
示例5: computeGameSizing
import javafx.geometry.Rectangle2D; //導入方法依賴的package包/類
public GameSizing computeGameSizing(Rectangle2D bounds) {
double sceneWidth = bounds.getWidth();
double sceneHeight = bounds.getHeight();
if (sceneWidth == 0 || sceneHeight == 0) {
throw new IllegalStateException("Invalid gaming area size : bounds = " + bounds);
}
final double width;
final double height;
final double shift;
log.info("16/9 or 16/10 screen ? = " + ((sceneWidth / sceneHeight) - (16.0 / 9.0)));
if (fourThree && ((sceneWidth / sceneHeight) - (16.0 / 9.0)) < 0.1) {
width = 4 * sceneHeight / 3;
height = sceneHeight;
shift = (sceneWidth - width) / 2;
} else {
width = sceneWidth;
height = sceneHeight;
shift = 0;
}
GameSizing gameSizing = new GameSizing(width / nbColumns, height / nbLines, shift);
log.info("gameSizing = {}", gameSizing);
return gameSizing;
}
示例6: makeLighting
import javafx.geometry.Rectangle2D; //導入方法依賴的package包/類
private static void makeLighting(Group root, Rectangle2D RScreen) {
int width = (int) RScreen.getWidth();
int height = (int) RScreen.getHeight();
T = new Lighting[width / pixelWidth][height / pixelWidth];
for (int i = 0; i < T.length; i++)
for (int j = 0; j < T[i].length; j++) {
T[i][j] = new Lighting(i * pixelWidth, j * pixelWidth, pixelWidth, lightingLength, lightingColor);
root.getChildren().add(T[i][j]);
}
}
示例7: CustomStage
import javafx.geometry.Rectangle2D; //導入方法依賴的package包/類
public CustomStage(AnchorPane ap, StageStyle style) {
initStyle(style);
setSize(ap.getPrefWidth(), ap.getPrefHeight());
Rectangle2D screenBounds = Screen.getPrimary().getVisualBounds();
double x = screenBounds.getMinX() + screenBounds.getWidth() - ap.getPrefWidth() - 2;
double y = screenBounds.getMinY() + screenBounds.getHeight() - ap.getPrefHeight() - 2;
bottomRight = Location.at(x, y);
}
示例8: computeActualScale
import javafx.geometry.Rectangle2D; //導入方法依賴的package包/類
/**
* Computes the actual scaling of an Image in an ImageView. If the preserveRatio
* property on the ImageView is false the scaling has no meaning so NaN is
* returned.
*
* @return The scale factor of the image in relation to display coordinates
*/
public double computeActualScale() {
if (!imageView.isPreserveRatio()) {
actualScale = Double.NaN;
}
else if (doScaleRecompute) {
Image localImage = imageView.getImage();
Rectangle2D localViewport = imageView.getViewport();
double w = 0;
double h = 0;
if (localViewport != null && localViewport.getWidth() > 0 && localViewport.getHeight() > 0) {
w = localViewport.getWidth();
h = localViewport.getHeight();
} else if (localImage != null) {
w = localImage.getWidth();
h = localImage.getHeight();
}
double localFitWidth = imageView.getFitWidth();
double localFitHeight = imageView.getFitHeight();
if (w > 0 && h > 0 && (localFitWidth > 0 || localFitHeight > 0)) {
if (localFitWidth <= 0 || (localFitHeight > 0 && localFitWidth * h > localFitHeight * w)) {
w = w * localFitHeight / h;
} else {
w = localFitWidth;
}
actualScale = w / localImage.getWidth();
}
doScaleRecompute = false;
}
return actualScale;
}
示例9: getTreeViewHeight
import javafx.geometry.Rectangle2D; //導入方法依賴的package包/類
/**
* get height by total screen size
*
* @return intended treeview height
*/
private int getTreeViewHeight() {
Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
int totalHeight = (int)primaryScreenBounds.getHeight();
return totalHeight / (numberOfDays / maxColumns);
}
示例10: init
import javafx.geometry.Rectangle2D; //導入方法依賴的package包/類
@Override
public void init() throws Exception {
//Load the image files for all of the
TextProc.loadImages();
txtField = new TextField();
pane = new BorderPane();
Rectangle2D screenBounds = Screen.getPrimary().getVisualBounds();
// Initialize a canvas that is half the size of the screen
canvas = new Canvas(screenBounds.getWidth() / 2,screenBounds.getHeight() / 2);
GraphicsContext gc = canvas.getGraphicsContext2D();
pane.setCenter(canvas);
pane.setBottom(txtField);
// Event handler for the text field. The action is triggered whenever ENTER key is pressed
txtField.setOnKeyReleased(event -> drawStrokes(txtField.getText(), gc));
}
示例11: initWindowDimensions
import javafx.geometry.Rectangle2D; //導入方法依賴的package包/類
private void initWindowDimensions() {
Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
width = primaryScreenBounds.getHeight() / 3;
height = primaryScreenBounds.getWidth() / 3;
}