本文整理匯總了Java中javafx.geometry.Rectangle2D.getWidth方法的典型用法代碼示例。如果您正苦於以下問題:Java Rectangle2D.getWidth方法的具體用法?Java Rectangle2D.getWidth怎麽用?Java Rectangle2D.getWidth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.geometry.Rectangle2D
的用法示例。
在下文中一共展示了Rectangle2D.getWidth方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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);
}
示例2: ShortcutsView
import javafx.geometry.Rectangle2D; //導入方法依賴的package包/類
/**
* Adds the content for showing the shortcuts to the TabPane in the proof
* @param tabPane
*
*/
public ShortcutsView(TabPane tabPane) {
Label label = new Label(loadInstructions());
label.getStyleClass().add("infoText");
//putting the image on a scrollpane
ScrollPane sp = new ScrollPane();
sp.getStyleClass().add("shortcutsView");
tab = new ViewTab("Shortcuts",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);
}
示例3: 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);
}
示例4: 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();
}
示例5: 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());
}
示例6: 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();
}
示例7: 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;
}
示例8: 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;
}
示例9: 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;
}
示例10: 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]);
}
}
示例11: 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);
}
示例12: 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;
}
示例13: betweenX
import javafx.geometry.Rectangle2D; //導入方法依賴的package包/類
private boolean betweenX(Rectangle2D r1, Rectangle2D r2, double xPoint) {
double lowerBound = r1.getMinX() + r1.getWidth() / 2;
double upperBound = r2.getMaxX() - r2.getWidth() / 2;
return xPoint >= lowerBound && xPoint <= upperBound;
}
示例14: getTreeViewWidth
import javafx.geometry.Rectangle2D; //導入方法依賴的package包/類
/**
* get width by total screen size
*
* @return intended treeview width
*/
private int getTreeViewWidth() {
Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
int totalWidth = (int)primaryScreenBounds.getWidth();
return totalWidth / maxColumns;
}
示例15: 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;
}