Example usage for com.intellij.openapi.ui.popup Balloon setBounds

List of usage examples for com.intellij.openapi.ui.popup Balloon setBounds

Introduction

In this page you can find the example usage for com.intellij.openapi.ui.popup Balloon setBounds.

Prototype

void setBounds(Rectangle bounds);

Source Link

Usage

From source file:com.intellij.ui.BalloonLayoutImpl.java

License:Apache License

private void relayout() {
    final Dimension size = myLayeredPane.getSize();

    JBInsets.removeFrom(size, myInsets);

    final Rectangle layoutRec = new Rectangle(new Point(myInsets.left, myInsets.top), size);

    List<ArrayList<Balloon>> columns = createColumns(layoutRec);
    while (columns.size() > 1) {
        myBalloons.remove(0);/*w  ww.  j  a va2  s . c  o  m*/
        columns = createColumns(layoutRec);
    }
    List<Integer> columnWidths = computeWidths(columns);

    ToolWindowsPane pane = UIUtil.findComponentOfType(myParent, ToolWindowsPane.class);
    JComponent component = pane != null ? pane : myParent;
    int paneOnScreen = component.isShowing() ? component.getLocationOnScreen().y : 0;
    int layerOnScreen = myLayeredPane.isShowing() ? myLayeredPane.getLocationOnScreen().y : 0;
    int toolbarsOffset = paneOnScreen - layerOnScreen;

    JComponent layeredPane = pane != null ? pane.getMyLayeredPane() : null;
    int eachColumnX = (layeredPane == null ? myLayeredPane.getWidth()
            : layeredPane.getX() + layeredPane.getWidth()) - 4;

    for (int i = 0; i < columns.size(); i++) {
        final ArrayList<Balloon> eachColumn = columns.get(i);
        final Integer eachWidth = columnWidths.get(i);
        eachColumnX -= eachWidth.intValue();
        int eachY = toolbarsOffset + 2;
        for (Balloon eachBalloon : eachColumn) {
            final Rectangle eachRec = new Rectangle();
            final Dimension eachPrefSize = eachBalloon.getPreferredSize();
            eachRec.setSize(eachPrefSize);
            if (((BalloonImpl) eachBalloon).hasShadow()) {
                final int shadowSize = ((BalloonImpl) eachBalloon).getShadowBorderSize();
                eachRec.width += 2 * shadowSize;
                eachRec.height += 2 * shadowSize;
            }
            eachY += 2; //space between two notifications
            eachRec.setLocation(eachColumnX + eachWidth.intValue() - eachRec.width, eachY);
            eachBalloon.setBounds(eachRec);
            eachY += eachRec.height;
        }
    }
}