本文整理匯總了Java中javafx.geometry.Rectangle2D類的典型用法代碼示例。如果您正苦於以下問題:Java Rectangle2D類的具體用法?Java Rectangle2D怎麽用?Java Rectangle2D使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Rectangle2D類屬於javafx.geometry包,在下文中一共展示了Rectangle2D類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: start
import javafx.geometry.Rectangle2D; //導入依賴的package包/類
@Override
public void start(Stage stage) {
this.stage = stage;
stage.initStyle(StageStyle.TRANSPARENT);
VBox box = new VBox(20);
box.setMaxWidth(Region.USE_PREF_SIZE);
box.setMaxHeight(Region.USE_PREF_SIZE);
box.setBackground(Background.EMPTY);
String style = "-fx-background-color: rgba(255, 255, 255, 0.5);";
box.setStyle(style);
box.setPadding(new Insets(50));
BorderPane root = new BorderPane(box);
root.setStyle(style);
root.setBackground(Background.EMPTY);
Scene scene = new Scene(root);
scene.setFill(Color.TRANSPARENT);
stage.setScene(scene);
ImageView splashView = new ImageView(splashImage);
box.getChildren().addAll(splashView, new Label("ST Verification Studio is loading.."));
stage.show();
Rectangle2D primScreenBounds = Screen.getPrimary().getVisualBounds();
stage.setX((primScreenBounds.getWidth() - stage.getWidth()) / 2);
stage.setY((primScreenBounds.getHeight() - stage.getHeight()) / 2);
}
示例2: start
import javafx.geometry.Rectangle2D; //導入依賴的package包/類
@Override
public void start(Stage primaryStage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("menuSample.fxml"));
primaryStage.setTitle("Hello World");
Screen screen = Screen.getPrimary();
Rectangle2D bounds = screen.getVisualBounds();
primaryStage.setX(bounds.getMinX());
primaryStage.setY(bounds.getMinY());
primaryStage.setWidth(bounds.getWidth());
primaryStage.setHeight(bounds.getHeight());
primaryStage.setMaximized(true);
Scene menuScene = new Scene(root, 1080, 720);
//primaryStage.setFullScreen(true);
primaryStage.setScene(menuScene);
//primaryStage.setFullScreen(true);
primaryStage.show();
}
示例3: Exe
import javafx.geometry.Rectangle2D; //導入依賴的package包/類
void Exe(int i) {
if(i==1) {
warnmesse="プレイ開始から5分経過しました\n混雑している場合は次の人に\n交代してください";
fontsize=25;
}else if(i==2) {
warnmesse="プレイ開始から10分経過しました\n混雑している場合は次の人に\n交代してください";
fontsize=25;
}else if(i==-1) {
warnmesse="user timer is reset";
fontsize=35;
}
final Stage primaryStage = new Stage(StageStyle.TRANSPARENT);
primaryStage.initModality(Modality.NONE);
final StackPane root = new StackPane();
final Scene scene = new Scene(root, 350, 140);
scene.setFill(null);
final Label label = new Label(warnmesse);
label.setFont(new Font("Arial", fontsize));
BorderPane borderPane = new BorderPane();
borderPane.setCenter(label);
borderPane.setStyle("-fx-background-radius: 10;-fx-background-color: rgba(0,0,0,0.3);");
root.getChildren().add(borderPane);
final Rectangle2D d = Screen.getPrimary().getVisualBounds();
primaryStage.setScene(scene);
primaryStage.setAlwaysOnTop(true);
primaryStage.setX(d.getWidth()-350);
primaryStage.setY(d.getHeight()-300);
primaryStage.show();
final Timeline timer = new Timeline(new KeyFrame(Duration.seconds(CLOSE_SECONDS), (ActionEvent event) -> primaryStage.close()));
timer.setCycleCount(Timeline.INDEFINITE);
timer.play();
}
示例4: start
import javafx.geometry.Rectangle2D; //導入依賴的package包/類
@Override
public void start(final Stage primaryStage) throws Exception
{
this.preloaderStage = primaryStage;
final ImageView splash = new ImageView(new Image(Constant.IMG_DIR + "banner.png"));
this.loadProgressPhase = new JFXProgressBar();
this.loadProgressPhase.setPrefWidth(Constant.SPLASH_WIDTH);
this.splashLayout = new VBox();
this.splashLayout.getChildren().addAll(splash, this.loadProgressPhase);
this.splashLayout.setStyle("-fx-padding: 5; " + "-fx-background-color: gainsboro; " + "-fx-border-width:2; "
+ "-fx-border-color: " + "linear-gradient(" + "to bottom, " + "MediumSeaGreen, "
+ "derive(MediumSeaGreen, 50%)" + ");");
this.splashLayout.setEffect(new DropShadow());
final Scene splashScene = new Scene(this.splashLayout, Color.TRANSPARENT);
final Rectangle2D bounds = Screen.getPrimary().getBounds();
primaryStage.setScene(splashScene);
primaryStage.setX(bounds.getMinX() + bounds.getWidth() / 2 - Constant.SPLASH_WIDTH / 2);
primaryStage.setY(bounds.getMinY() + bounds.getHeight() / 2 - Constant.SPLASH_HEIGHT / 2);
primaryStage.getIcons().add(new Image(Constant.IMG_DIR + "icon.png"));
primaryStage.setTitle(Constant.APP_NAME);
primaryStage.initStyle(StageStyle.UNDECORATED);
primaryStage.setAlwaysOnTop(true);
primaryStage.show();
}
示例5: InferenceRuleView
import javafx.geometry.Rectangle2D; //導入依賴的package包/類
/**
* Adds the content for showing the inference rules to the TabPane in the proof
* @param tabPane
*
*/
public InferenceRuleView(TabPane tabPane) {
//load the image
Image image = new Image("inferenceRules.png");
ImageView iv1 = new ImageView();
iv1.setImage(image);
iv1.setSmooth(true);
iv1.setPreserveRatio(true);
//putting the image on a scrollpane
ScrollPane sp=new ScrollPane();
sp.getStyleClass().add("rulesView");
tab = new ViewTab("Inference Rules",this);
sp.setContent(iv1);
tabPane.getTabs().add(tab);
tab.setContent(sp);
tabPane.getSelectionModel().select(tab);
//used for getting screensize
Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
//Avoids scaling too much
double w=primaryScreenBounds.getWidth()/2;
iv1.setFitWidth(w);
}
示例6: ParseInfoView
import javafx.geometry.Rectangle2D; //導入依賴的package包/類
/**
* Adds the content for showing the parser info to the TabPane
* @param tabPane
*
*/
public ParseInfoView(TabPane tabPane) {
Label label = new Label(loadInstructions());
label.getStyleClass().add("infoText");
//putting the image on a scrollpane
ScrollPane sp = new ScrollPane();
sp.getStyleClass().add("rulesView");
tab = new ViewTab("Input format",this);
sp.setContent(label);
tabPane.getTabs().add(tab);
tab.setContent(sp);
tabPane.getSelectionModel().select(tab);
//used for getting screensize
Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
//Avoids scaling too much
double w=primaryScreenBounds.getWidth();
label.setPrefWidth(w);
}
示例7: 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();
}
示例8: SpriteAnimation
import javafx.geometry.Rectangle2D; //導入依賴的package包/類
/**
* Creates an animation that will run for indefinite time.
* Use setCycleCount(1) to run animation only once. Remember to remove the imageView afterwards.
*
* @param imageView - the imageview of the sprite
* @param duration - How long should one animation cycle take
* @param count - Number of frames
* @param columns - Number of colums the sprite has
* @param offsetX - Offset x
* @param offsetY - Offset y
* @param width - Width of each frame
* @param height - Height of each frame
*/
public SpriteAnimation(
ImageView imageView,
Duration duration,
int count, int columns,
int offsetX, int offsetY,
int width, int height
) {
this.imageView = imageView;
this.count = count;
this.columns = columns;
this.offsetX = offsetX;
this.offsetY = offsetY;
this.width = width;
this.height = height;
setCycleDuration(duration);
setCycleCount(Animation.INDEFINITE);
setInterpolator(Interpolator.LINEAR);
this.imageView.setViewport(new Rectangle2D(offsetX, offsetY, width, height));
}
示例9: start
import javafx.geometry.Rectangle2D; //導入依賴的package包/類
@Override
public void start(Stage primaryStage) throws Exception{
FXMLLoader fxmlLoader = new FXMLLoader();
fxmlLoader.setLocation(getClass().getResource("sample.fxml"));
Parent root = fxmlLoader.load();
Screen screen = Screen.getPrimary ();
// 界麵初始化
Controller controller = fxmlLoader.getController();
controller.init(primaryStage);
Rectangle2D bounds = screen.getVisualBounds ();
double minX = bounds.getMinX ();
double minY = bounds.getMinY ();
double maxX = bounds.getMaxX ();
double maxY = bounds.getMaxY ();
screenWidth = maxX - minX;
screenHeight = maxY - minY;
Scene scene = new Scene(root, (maxX - minX) * 0.6, (maxY - minY) * 0.6);
primaryStage.setTitle ("Higher Cloud Compute Platform");
primaryStage.setScene (scene);
primaryStage.setFullScreen(true);
primaryStage.show ();
}
示例10: getDesktopSize
import javafx.geometry.Rectangle2D; //導入依賴的package包/類
static Rectangle2D getDesktopSize() {
Rectangle2D rect = Screen.getPrimary().getBounds();
double minX = rect.getMinX(), minY = rect.getMinY();
double maxX = rect.getMaxX(), maxY = rect.getMaxY();
for (Screen screen : Screen.getScreens()) {
Rectangle2D screenRect = screen.getBounds();
if (minX > screenRect.getMinX()) {
minX = screenRect.getMinX();
}
if (minY > screenRect.getMinY()) {
minY = screenRect.getMinY();
}
if (maxX < screenRect.getMaxX()) {
maxX = screenRect.getMaxX();
}
if (maxY < screenRect.getMaxY()) {
maxY = screenRect.getMaxY();
}
}
return new Rectangle2D(minX, minY, maxX - minX, maxY - minY);
}
示例11: 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());
}
示例12: getCurrentPositionStorageKey
import javafx.geometry.Rectangle2D; //導入依賴的package包/類
private String getCurrentPositionStorageKey() {
if (positionStorageID == null) {
return null;
}
final StringBuilder key = new StringBuilder();
final Rectangle2D desktopSize = OverlayStage.getDesktopSize();
key.append(positionStorageID);
if (positionRelativeToDesktopSize) {
key.append('.');
key.append(desktopSize.getMinX());
key.append('_');
key.append(desktopSize.getMinY());
key.append('_');
key.append(desktopSize.getWidth());
key.append('_');
key.append(desktopSize.getHeight());
}
return key.toString();
}
示例13: 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();
}
示例14: 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;
}
示例15: changeSize
import javafx.geometry.Rectangle2D; //導入依賴的package包/類
public void changeSize(int newSize) {
this.size = newSize;
width = size * 12 + 45;
double rightWidth = RIGHT.getWidth() - Config.SHADOW_WIDTH;
double centerWidth = width - LEFT.getWidth() - rightWidth;
centerImageView.setViewport(new Rectangle2D(
(CENTER.getWidth() - centerWidth) / 2, 0, centerWidth, CENTER.getHeight()));
rightImageView.setTranslateX(width - rightWidth);
}