当前位置: 首页>>代码示例>>Java>>正文


Java Screen.getScreens方法代码示例

本文整理汇总了Java中javafx.stage.Screen.getScreens方法的典型用法代码示例。如果您正苦于以下问题:Java Screen.getScreens方法的具体用法?Java Screen.getScreens怎么用?Java Screen.getScreens使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.stage.Screen的用法示例。


在下文中一共展示了Screen.getScreens方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: launch

import javafx.stage.Screen; //导入方法依赖的package包/类
public static SecondScreen launch() {

        ObservableList<Screen> screens = Screen.getScreens();

        if (screens.size() < 2)
            return null;

        Screen screen1 = screens.get(0);
        Screen screen2 = screens.get(1);
        log.info("screen1.getBounds() = " + screen1.getBounds());
        log.info("screen2.getBounds() = " + screen2.getBounds());
        Stage stage2 = new Stage();
        stage2.setScene(new Scene(new Label("primary")));
        stage2.setX(screen2.getVisualBounds().getMinX());
        stage2.setY(screen2.getVisualBounds().getMinY());
        stage2.setWidth(screen1.getBounds().getWidth());
        stage2.setHeight(screen1.getBounds().getHeight());
        Group root = new Group();
        Scene scene = new Scene(root, screen1.getBounds().getWidth(), screen1.getBounds().getHeight(), Color.BLACK);

        makeLighting(root, screen2.getBounds());

        stage2.setScene(scene);

        stage2.show();

        SecondScreen sc = new SecondScreen();

        Configuration config = ConfigurationBuilder.createFromPropertiesResource().build();

        /*
         * if (config.eyetracker.equals("tobii")) Tobii.execProg(sc); else
         */
        if (config.isGazeMode())
            gazeListener = new EyeTribeGazeListener(sc);
        else
            gazeListener = new FuzzyGazeListener(sc);

        return sc;
    }
 
开发者ID:schwabdidier,项目名称:GazePlay,代码行数:41,代码来源:SecondScreen.java

示例2: getDesktopSize

import javafx.stage.Screen; //导入方法依赖的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);
}
 
开发者ID:DeskChan,项目名称:DeskChan,代码行数:22,代码来源:OverlayStage.java

示例3: getResolutionOfTheSelectedScreen

import javafx.stage.Screen; //导入方法依赖的package包/类
private void getResolutionOfTheSelectedScreen() {

        // Get list of active screens.
//        GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
//        GraphicsDevice[] graphicsDevices = graphicsEnvironment.getScreenDevices();

        // Get index of selected screen in comboBoxScreen.
//        int selectedScreenIndex = comboBoxScreen.getSelectionModel().getSelectedIndex();

        // Get resolution of the selected screen.
//        GraphicsDevice selectedScreen = graphicsDevices[selectedScreenIndex];
//        int x = selectedScreen.getDisplayMode().getWidth();
//        int y = selectedScreen.getDisplayMode().getHeight();

        java.util.List<Screen> screens = Screen.getScreens();
        Screen activeScreen = screens.get(comboBoxScreen.getSelectionModel().getSelectedIndex());
        Rectangle2D activeScreenVisualBounds = activeScreen.getVisualBounds();

        // Set text for text fields.
        textFieldScreenResolutionX.setText(String.valueOf((int) activeScreenVisualBounds.getWidth()));
        textFieldScreenResolutionY.setText(String.valueOf((int) activeScreenVisualBounds.getHeight()));
    }
 
开发者ID:piotrdzwiniel,项目名称:Specvis,代码行数:23,代码来源:ViewScreenAndLumScaleController.java

示例4: findSmallestScreen

import javafx.stage.Screen; //导入方法依赖的package包/类
private Optional<Screen> findSmallestScreen() {
	Screen smallest = null;

	// Find screen with the smallest area
	for (final Screen screen : Screen.getScreens()) {
		if (smallest == null) {
			smallest = screen;
		} else {
			if (screen.getBounds().getHeight() * screen.getBounds().getWidth() < smallest.getBounds().getHeight()
					* smallest.getBounds().getWidth()) {
				smallest = screen;
			}
		}
	}

	return Optional.ofNullable(smallest);
}
 
开发者ID:phrack,项目名称:ShootOFF,代码行数:18,代码来源:ProjectorArenaPane.java

示例5: getDockSide

import javafx.stage.Screen; //导入方法依赖的package包/类
/**
 * Based on mouse position returns dock side
 *
 * @param mouseEvent
 * @return DOCK_LEFT,DOCK_RIGHT,DOCK_TOP
 */
int getDockSide(MouseEvent mouseEvent) {
    double minX = Double.POSITIVE_INFINITY;
    double minY = Double.POSITIVE_INFINITY;
    double maxX = 0;
    double maxY = 0;

    // Get "big" screen bounds
    ObservableList<Screen> screens = Screen.getScreens();
    for (Screen screen : screens) {
        Rectangle2D visualBounds = screen.getVisualBounds();
        minX = Math.min(minX, visualBounds.getMinX());
        minY = Math.min(minY, visualBounds.getMinY());
        maxX = Math.max(maxX, visualBounds.getMaxX());
        maxY = Math.max(maxY, visualBounds.getMaxY());
    }
    // Dock Left
    if (mouseEvent.getScreenX() == minX) {
        return DOCK_LEFT;
    } else if (mouseEvent.getScreenX() >= maxX - 1) { // MaxX returns the width? Not width -1 ?!
        return DOCK_RIGHT;
    } else if (mouseEvent.getScreenY() <= minY) {   // Mac menu bar
        return DOCK_TOP;
    }
    return 0;
}
 
开发者ID:SnakeDoc,项目名称:superD,代码行数:32,代码来源:UndecoratorController.java

示例6: setPosition

import javafx.stage.Screen; //导入方法依赖的package包/类
void setPosition(Point2D topLeft) {
	if (topLeft == null) {
		setDefaultPosition();
		return;
	}
	Bounds bounds = getLayoutBounds();
	Rectangle2D rect = new Rectangle2D(topLeft.getX(), topLeft.getY(),
			bounds.getWidth(), bounds.getHeight());
	for (Screen screen : Screen.getScreens()) {
		rect = snapRect(rect, screen.getBounds());
		rect = snapRect(rect, screen.getVisualBounds());
	}
	relocate(rect.getMinX(), rect.getMinY());
}
 
开发者ID:DeskChan,项目名称:DeskChan,代码行数:15,代码来源:MovablePane.java

示例7: isValidCoordinates

import javafx.stage.Screen; //导入方法依赖的package包/类
/** returns true if the coordinates belong to one of the Screens */
public static boolean isValidCoordinates(double x, double y)
{
	for(Screen screen: Screen.getScreens())
	{
		Rectangle2D r = screen.getVisualBounds();
		if(r.contains(x, y))
		{
			return true;
		}
	}
	return false;
}
 
开发者ID:andy-goryachev,项目名称:FxEditor,代码行数:14,代码来源:FX.java

示例8: getMaxScreenHeight

import javafx.stage.Screen; //导入方法依赖的package包/类
/**
 * Get maximum height of all monitors.
 * @return maximum height
 */
private double getMaxScreenHeight(){
    double result = 0;

    for(Screen screen : Screen.getScreens()){
        if(screen.getBounds().getHeight() > result){
            result = screen.getBounds().getHeight();
        }
    }

    return result;
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:16,代码来源:FSTestApp.java

示例9: getMaxScreenWidth

import javafx.stage.Screen; //导入方法依赖的package包/类
/**
 * Get maximum width of all monitors.
 * @return maximum width
 */
private double getMaxScreenWidth(){
    double result = 0;

    for(Screen screen : Screen.getScreens()){
        if(screen.getBounds().getWidth() > result){
            result = screen.getBounds().getWidth();
        }
    }

    return result;
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:16,代码来源:FSTestApp.java

示例10: StartUpLocation

import javafx.stage.Screen; //导入方法依赖的package包/类
/**
 * Get Top Left X and Y Positions for a Window to centre it on the
 * currently active screen at application startup
 * @param windowWidth - Window Width
 * @param windowHeight - Window Height
 */
public StartUpLocation(double windowWidth, double windowHeight) {
 
 //System.out.println("(" + windowWidth + ", " + windowHeight + ")");
    // Get X Y of start-up location on Active Screen
    // simple_JavaFX_App
    try {
        // Get current mouse location, could return null if mouse is moving Super-Man fast
        Point p = MouseInfo.getPointerInfo().getLocation();
        // Get list of available screens
        List<Screen> screens = Screen.getScreens();
        if (p != null && screens != null && screens.size() > 1) {
     	   // in order for xPos != 0 and yPos != 0 in startUpLocation, there has to be more than 1 screen
            // Screen bounds as rectangle
            Rectangle2D screenBounds;
            // Go through each screen to see if the mouse is currently on that screen
            for (Screen screen : screens) {
                screenBounds = screen.getVisualBounds();
                // Trying to compute Left Top X-Y position for the Applcation Window
                // If the Point p is in the Bounds
                if (screenBounds.contains(p.x, p.y)) {
                    // Fixed Size Window Width and Height
                    xPos = screenBounds.getMinX() + ((screenBounds.getMaxX() - screenBounds.getMinX() - windowWidth) / 2);
                    yPos = screenBounds.getMinY() + ((screenBounds.getMaxY() - screenBounds.getMinY() - windowHeight) / 2);
                    return;
                }
            }
        }
    } catch (HeadlessException headlessException) {
        // Catch and report exceptions
        headlessException.printStackTrace();
    }
    
}
 
开发者ID:mars-sim,项目名称:mars-sim,代码行数:40,代码来源:StartUpLocation.java

示例11: determineSide

import javafx.stage.Screen; //导入方法依赖的package包/类
/** @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 = null;
    for (Screen screen : Screen.getScreens())
    {
        final Rectangle2D check = screen.getVisualBounds();
        if (check.contains(owner_x, owner_y))
        {
            screen_bounds = check;
            break;
        }
    }
    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;
}
 
开发者ID:kasemir,项目名称:org.csstudio.display.builder,代码行数:35,代码来源:PopOver.java

示例12: calculateMaxRenderScale

import javafx.stage.Screen; //导入方法依赖的package包/类
public float calculateMaxRenderScale() {
	float maxRenderScale = 0;
	ScreenHelper.ScreenAccessor accessor = ScreenHelper.getScreenAccessor();
	for (Screen screen : Screen.getScreens()) {
		maxRenderScale = Math.max(maxRenderScale, accessor.getRenderScale(screen));
	}
	return maxRenderScale;
}
 
开发者ID:codecentric,项目名称:javafxsvg,代码行数:9,代码来源:SvgImageLoader.java

示例13: checkScreenEdges

import javafx.stage.Screen; //导入方法依赖的package包/类
/**
 * checks if the primary move node is off screen and if so, resets the
 * window so it is visible again.
 */
public void checkScreenEdges() {
	if (primaryMoveNode == null) {
		return;
	}

	double minX = Double.MAX_VALUE;
	double maxX = Double.MIN_VALUE;
	double minY = Double.MAX_VALUE;
	double maxY = Double.MIN_VALUE;

	for (Screen screen : Screen.getScreens()) {
		minX = Math.min(minX, screen.getVisualBounds().getMinX());
		minY = Math.min(minY, screen.getVisualBounds().getMinY());

		maxX = Math.max(maxX, screen.getVisualBounds().getMaxX());
		maxY = Math.max(maxY, screen.getVisualBounds().getMaxY());
	}

	Rectangle2D bounds = getScreenBounds(primaryMoveNode);
	Rectangle2D valid = bounds;
	if (!isValidBounds(bounds)) {
		if (bounds.getMinY() < minY || bounds.getMaxY() > maxY) {
			int dir = 1;
			if (bounds.getMaxY() > maxY) {
				dir = -1;
			}
			for (double y = minX; y <= maxY && y >= minY; y += dir) {
				Rectangle2D test = cloneRect(bounds, null, y, null, null);
				if (isValidBounds(test)) {
					valid = test;
				}
			}
		}
	}
	// TODO handle when new bounds were found
}
 
开发者ID:narrowtux,项目名称:FxDecorate,代码行数:41,代码来源:FxDecorateController.java

示例14: ViewStimuliDistribution

import javafx.stage.Screen; //导入方法依赖的package包/类
/**
 * Constructor.
 * @param fixationMonitorTechnique
 * @param fixationPointLocationX
 * @param fixationPointLocationY
 * @param blindspotDistanceFromFixPointX
 * @param blindspotDistanceFromFixPointY
 * @param previewLocationOfMsgAfterLossOfFixation
 * @param previewLocationOfMsgAfterLossOfFixationWithText
 */
public ViewStimuliDistribution(String fixationMonitorTechnique, double fixationPointLocationX, double fixationPointLocationY, double blindspotDistanceFromFixPointX, double blindspotDistanceFromFixPointY, boolean previewLocationOfMsgAfterLossOfFixation, boolean previewLocationOfMsgAfterLossOfFixationWithText) {

    // Get Functions.
    functions = StartApplication.getFunctions();

    // Init fields.
    int chosenScreenIndex = StartApplication.getSpecvisData().getUiSettingsScreenAndLuminanceScale().getChosenScreenIndex();
    this.screenResolutionX = StartApplication.getSpecvisData().getUiSettingsScreenAndLuminanceScale().getScreenResolutionX();
    this.screenResolutionY = StartApplication.getSpecvisData().getUiSettingsScreenAndLuminanceScale().getScreenResolutionY();
    double involvedVisualFieldX = StartApplication.getSpecvisData().getUiSettingsScreenAndLuminanceScale().getInvolvedVisualFieldX();
    double involvedVisualFieldY = StartApplication.getSpecvisData().getUiSettingsScreenAndLuminanceScale().getInvolvedVisualFieldY();
    this.correctionForSphericityOfTheFieldOfView = StartApplication.getSpecvisData().getUiSettingsStimulusAndBackground().isCorrectionForSphericityCheckBoxChecked();
    this.distanceBetweenStimuliInDegreesX = StartApplication.getSpecvisData().getUiSettingsStimulusAndBackground().getDistanceBetweenStimuliInDegreesX();
    this.distanceBetweenStimuliInDegreesY = StartApplication.getSpecvisData().getUiSettingsStimulusAndBackground().getDistanceBetweenStimuliInDegreesY();
    this.fixationMonitorTechnique = fixationMonitorTechnique;
    this.fixationPointLocationX = fixationPointLocationX;
    this.fixationPointLocationY = fixationPointLocationY;
    this.blindspotDistanceFromFixPointX = blindspotDistanceFromFixPointX;
    this.blindspotDistanceFromFixPointY = blindspotDistanceFromFixPointY;
    this.previewLocationOfMsgAfterLossOfFixation = previewLocationOfMsgAfterLossOfFixation;
    this.previewLocationOfMsgAfterLossOfFixationWithText = previewLocationOfMsgAfterLossOfFixationWithText;

    // Init other fields.
    screenWidthInMM = StartApplication.getSpecvisData().getUiSettingsScreenAndLuminanceScale().getScreenWidth();
    screenHeightInMM = StartApplication.getSpecvisData().getUiSettingsScreenAndLuminanceScale().getScreenHeight();

    pixelsForOneDegreeX = screenResolutionX / involvedVisualFieldX;
    pixelsForOneDegreeY = screenResolutionY / involvedVisualFieldY;

    // Set scene.
    this.setScene(new Scene(createContent()));

    // Set size and position of the window.
    List<Screen> displays = Screen.getScreens();
    Screen activeDisplay = displays.get(chosenScreenIndex);
    Rectangle2D activeDisplayBounds = activeDisplay.getVisualBounds();

    this.setX(activeDisplayBounds.getMinX());
    this.setY(activeDisplayBounds.getMinY());
    this.setWidth(activeDisplayBounds.getWidth());
    this.setHeight(activeDisplayBounds.getHeight());
    this.initStyle(StageStyle.UNDECORATED);

    // Set close action for ESCAPE key.
    this.getScene().addEventFilter(KeyEvent.KEY_PRESSED, ke -> {
        if (ke.getCode() == KeyCode.ESCAPE) {
            close();
        }
    });
}
 
开发者ID:piotrdzwiniel,项目名称:Specvis,代码行数:61,代码来源:ViewStimuliDistribution.java

示例15: positionWindowBasedOnConfigCoordinates

import javafx.stage.Screen; //导入方法依赖的package包/类
/**
 * Position window based on coordinates from config.
 * 
 * @param windowName
 *            The name of window in config.
 * @param window
 *            The window to position.
 */
@SuppressWarnings("unchecked")
public static void positionWindowBasedOnConfigCoordinates(String windowName, Window window) {
	String subKey = windowName + "Coordinates";
	String defaultCoordsString = CuteConfig.getStringDefault(CuteConfig.UTILGUI, subKey);
	ArrayList<Double> defaultCoords;
	try {
		defaultCoords = (ArrayList<Double>) StuffSerializator
				.deserializeFromString(defaultCoordsString, ArrayList.class);
	} catch (IOException e1) {
		throw new RuntimeException("The default " + subKey + "in config is not deserializable");
	}
	String coordsString = CuteConfig.getString(CuteConfig.UTILGUI, subKey);
	boolean usingDefaultCoords = false;
	ArrayList<Double> coords;
	try {
		coords = (ArrayList<Double>) StuffSerializator.deserializeFromString(coordsString,
				ArrayList.class);
	} catch (IOException e) {
		// If there's a problem deserializing values, let's use default coordinates.
		logger.error("Can't deserialize " + subKey + " from current config,"
				+ " using coordinates from fallback config.");
		coords = defaultCoords;
		usingDefaultCoords = true;
	}
	// Let's check if coordinates are actual numbers.
	for (Object coord : coords) {
		if (!(coord instanceof Double) || ((Double) coord).isNaN()) {
			if (usingDefaultCoords) {
				throw new RuntimeException(
						"The default " + subKey + " in config contain NaN values");
			} else {
				logger.error(subKey + " from current config contain NaN values,"
						+ " using coordinates from fallback config.");
				coords = defaultCoords;
			}
			break;
		}
	}
	double prefX = coords.get(0);
	double prefY = coords.get(1);
	double prefWidth = coords.get(2);
	double prefHeight = coords.get(3);
	Rectangle2D prefWindow = new Rectangle2D(prefX, prefY, prefWidth, prefHeight);
	// If window is hardly accessible, we need to reset it's position.
	// Let's find out if it's accessible.
	boolean prefWindowWillBeAccessible = false;
	ObservableList<Screen> screens = Screen.getScreens();
	for (Screen screen: screens) {
		if (prefWindow.intersects(screen.getVisualBounds())) {
			prefWindowWillBeAccessible = true;
			break;
		}
	}
	if (prefWindowWillBeAccessible) {
		// Everything is alright, showing window in the specified position.
		window.setWidth(prefWidth);
		window.setHeight(prefHeight);
		window.setX(prefX);
		window.setY(prefY);
	} else {
		// Resetting position.
		logger.error("The window " + windowName
				+ " doesn't fit in screen bounds. Resetting position.");
		logger.error(prefWindow.toString());
		window.setWidth(defaultCoords.get(2));
		window.setHeight(defaultCoords.get(3));
		window.centerOnScreen();
	}
}
 
开发者ID:ubershy,项目名称:StreamSis,代码行数:78,代码来源:GUIUtil.java


注:本文中的javafx.stage.Screen.getScreens方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。