Example usage for java.awt Dimension getHeight

List of usage examples for java.awt Dimension getHeight

Introduction

In this page you can find the example usage for java.awt Dimension getHeight.

Prototype

public double getHeight() 

Source Link

Usage

From source file:edu.wustl.xipHost.hostControl.HostConfigurator.java

public static int adjustForResolution() {
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    //logger.debug("Sceen size: Width " + screenSize.getWidth() + ", Height " + screenSize.getHeight());
    int height = (int) screenSize.getHeight();
    int preferredHeight = 600;
    if (height < 768 && height >= 600) {
        preferredHeight = 350;/*from  w w  w .  j a  v a2 s.c  om*/
    } else if (height < 1024 && height >= 768) {
        preferredHeight = 450;
    } else if (height >= 1024 && height < 1200) {
        preferredHeight = 600 - 100;
    } else if (height > 1200 && height <= 1440) {
        preferredHeight = 800;
    }
    return preferredHeight;
}

From source file:org.revager.tools.GUITools.java

/**
 * Sets the location of the given window to cursor position.
 * /*w  w  w .j  ava2s.  c o m*/
 * @param win
 *            the window for which the location is to be set
 */
public static void setLocationToCursorPos(Window win) {
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

    double cursorPosX = MouseInfo.getPointerInfo().getLocation().getX();
    double cursorPosY = MouseInfo.getPointerInfo().getLocation().getY();

    double screenWidth = screenSize.getWidth();
    double screenHeight = screenSize.getHeight() - 40;

    double winWidth = win.getSize().getWidth();
    double winHeight = win.getSize().getHeight();

    int winPosX = (int) cursorPosX;
    int winPosY = (int) cursorPosY;
    // If the window would break the screen size
    if (cursorPosX + winWidth > screenWidth) {
        winPosX = (int) (screenWidth - winWidth);
    }
    if (cursorPosY + winHeight > screenHeight) {
        winPosY = (int) (screenHeight - winHeight);
    }
    win.setLocation(new Point(winPosX, winPosY));
}

From source file:org.jamwiki.parser.image.ImageUtil.java

/**
 * Determine the scaled dimensions, given a max width and height.  For example, if
 * the original dimensions are 800x400 and the max width height are 200, the result
 * is 200x100./*from   w  w  w.j a va 2 s.co m*/
 */
private static Dimension calculateScaledDimensions(Dimension originalDimensions, int maxWidth, int maxHeight) {
    if (maxWidth <= 0 && maxHeight <= 0) {
        return originalDimensions;
    }
    double heightScalingFactor = ((double) maxHeight / (double) originalDimensions.getHeight());
    double widthScalingFactor = ((double) maxWidth / (double) originalDimensions.getWidth());
    // scale by whichever is proportionally smaller
    int width, height;
    if (maxWidth <= 0) {
        width = (int) Math.round(heightScalingFactor * (double) originalDimensions.getWidth());
        height = (int) Math.round(heightScalingFactor * (double) originalDimensions.getHeight());
    } else if (maxHeight <= 0) {
        width = (int) Math.round(widthScalingFactor * (double) originalDimensions.getWidth());
        height = (int) Math.round(widthScalingFactor * (double) originalDimensions.getHeight());
    } else if (heightScalingFactor < widthScalingFactor) {
        width = (int) Math.round(heightScalingFactor * (double) originalDimensions.getWidth());
        height = (int) Math.round(heightScalingFactor * (double) originalDimensions.getHeight());
    } else {
        width = (int) Math.round(widthScalingFactor * (double) originalDimensions.getWidth());
        height = (int) Math.round(widthScalingFactor * (double) originalDimensions.getHeight());
    }
    return new Dimension(width, height);
}

From source file:fr.pasteque.pos.sales.restaurant.Place.java

public void setButtonBounds() {
    Dimension d = m_btn.getPreferredSize();
    d.setSize(d.getWidth() + 30, d.getHeight());
    m_btn.setBounds(m_ix - d.width / 2, m_iy - d.height / 2, d.width, d.height);
}

From source file:org.championship.manager.license.LicenseDialog.java

private void prepareSize() {
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    Dimension screenSize = toolkit.getScreenSize();
    int height = (int) screenSize.getHeight();
    int width = (int) (height / 1.3);

    if (height > 650) {
        height = 600;//ww w.j av  a 2  s  . co m
        width = (int) (height / 1.3);
    }

    setSize(new Dimension(width, height));
}

From source file:com.opendoorlogistics.components.geocode.postcodes.impl.SummaryPanel.java

public SummaryPanel() {
    setLayout(new BorderLayout());
    text.setEditable(false);/*from w  w  w.jav a2s .  com*/
    JScrollPane scrollpane = new JScrollPane(text);
    scrollpane.setViewportView(text);
    add(scrollpane, BorderLayout.CENTER);
    Dimension size = new Dimension(350, 100);
    scrollpane.setMinimumSize(new Dimension(1, (int) size.getHeight()));
    scrollpane.setPreferredSize(size);
    scrollpane.setMaximumSize(new Dimension(2000, (int) size.getHeight()));
    text.setBackground(new Color(220, 220, 220));
    text.setOpaque(true);

}

From source file:JSplash.java

private void center() {
    Dimension scr = Toolkit.getDefaultToolkit().getScreenSize();
    int nX = (int) (scr.getWidth() - getWidth()) / 2;
    int nY = (int) (scr.getHeight() - getHeight()) / 2;

    setLocation(nX, nY);//from  ww w  . j a  v  a2  s .co m
}

From source file:AppPackage.HumidityGraph.java

/**
 *
 *//* w w  w  .  java 2  s  .c o  m*/
public HumidityGraph() {
    try {

        JFrame window = new JFrame();
        window.setSize(1000, 615);
        window.setBackground(Color.blue);

        Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
        int x = (int) ((dimension.getWidth() - window.getWidth()) / 2);
        int y = (int) ((dimension.getHeight() - window.getHeight()) / 2);
        window.setLocation(x, y);

        XYSeries series = new XYSeries("Humidity ");
        XYSeriesCollection dataset = new XYSeriesCollection(series);
        JFreeChart chart = ChartFactory.createXYLineChart("Humidity against Time", "Time(seconds)",
                "Humidity(percentage)", dataset);
        window.add(new ChartPanel(chart), BorderLayout.CENTER);
        window.setVisible(true);

    } catch (Exception e) {
        System.out.print("Chart exception:" + e);
    }
    initComponents();
}

From source file:ShapeMover.java

public void update(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    Dimension dim = getSize();
    int w = (int) dim.getWidth();
    int h = (int) dim.getHeight();
    g2.setStroke(new BasicStroke(8.0f));

    if (isFirstTime) {
        area = new Rectangle(dim);
        rect.setLocation(w / 2 - 50, h / 2 - 25);
        isFirstTime = false;//from  ww w  .  j a va  2 s.  c  o m
    }

    // Clears the rectangle that was previously drawn.
    g2.setPaint(Color.white);
    g2.fillRect(0, 0, w, h);

    g2.setColor(Color.red);
    g2.draw(rect);
    g2.setColor(Color.black);
    g2.fill(rect);
}

From source file:net.chaosserver.timelord.swingui.SwingUtil.java

/**
 * Repair location is designed to detect if a box is partially
 * off-screen and move the box back onto the screen.
 *
 * @param component component to repair/* w  w w  .  ja  va2s .c om*/
 */
public static void repairLocation(Component component) {
    Point locationPoint = component.getLocation();
    Point locationOnScreenPoint = null;
    if (component.isVisible()) {
        locationOnScreenPoint = component.getLocationOnScreen();
    }
    Dimension componentSize = component.getSize();
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

    if (log.isDebugEnabled()) {
        log.debug("Repairing location on [" + component.getClass().getName() + "].  Original location point = ["
                + locationPoint + "] and location on screen point = [" + locationOnScreenPoint
                + "].  The screen size is [" + screenSize + "] and the component size is [" + componentSize
                + "]");
    }

    // Is the dialog to far to the left?  Then fix.
    if (locationPoint.getX() < 0) {
        locationPoint.setLocation(0, locationPoint.getY());
    }
    if (locationPoint.getY() < 0) {
        locationPoint.setLocation(locationPoint.getX(), 0);
    }
    // component.setLocation(locationPoint);

    // Is the dialog too wide?
    if (locationPoint.getX() + componentSize.getWidth() > screenSize.getWidth()) {

        componentSize.width = (int) (screenSize.getWidth() - locationPoint.getX());
    }
    if (locationPoint.getY() + componentSize.getHeight() > screenSize.getHeight()) {

        componentSize.height = (int) (screenSize.getHeight() - locationPoint.getY());
    }

    // component.setSize(componentSize);
}