Java Screen Center getPercentageOnScreen(Point location, Dimension size, Rectangle screen)

Here you can find the source of getPercentageOnScreen(Point location, Dimension size, Rectangle screen)

Description

get Percentage On Screen

License

Apache License

Declaration

private static float getPercentageOnScreen(Point location, Dimension size, Rectangle screen) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.awt.Dimension;

import java.awt.Point;
import java.awt.Rectangle;

import java.awt.geom.Rectangle2D;

public class Main {
    private static float getPercentageOnScreen(Point location, Dimension size, Rectangle screen) {
        Rectangle frameBounds = new Rectangle(location, size);
        Rectangle2D intersection = frameBounds.createIntersection(screen);
        int frameArea = size.width * size.height;
        int intersectionArea = (int) (intersection.getWidth() * intersection.getHeight());
        float percentage = (float) intersectionArea / frameArea;
        return percentage < 0 ? 0 : percentage;
    }//from  w w w.  j av  a 2  s  .c o m
}

Related

  1. getCenterPositionForComponent(int width, int heigth)
  2. getDimensionFromPercent(int percentWidth, int percentHeight)
  3. getFrameCenteredLocation(final java.awt.Component centerThis, final Component parent)
  4. getFrameOnCenterLocationPoint(Window window)
  5. getLocationToCenterOnScreen(Component comp)
  6. locateOnScreenCenter(Component component)
  7. moveToCenter(Component componentToMove, Component componentToCenterOver)
  8. moveToScreenCenter(Window w)
  9. packAndCenter(Window wind)