List of usage examples for com.intellij.openapi.ui.popup Balloon getPreferredSize
Dimension getPreferredSize();
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);/*from w w w .ja v a 2s.co 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; } } }
From source file:com.intellij.ui.BalloonLayoutImpl.java
License:Apache License
private static List<Integer> computeWidths(List<ArrayList<Balloon>> columns) { List<Integer> columnWidths = new ArrayList<Integer>(); for (ArrayList<Balloon> eachColumn : columns) { int maxWidth = 0; for (Balloon each : eachColumn) { maxWidth = Math.max(each.getPreferredSize().width, maxWidth); }/*w w w.j a va 2 s . c o m*/ columnWidths.add(maxWidth); } return columnWidths; }
From source file:com.intellij.ui.BalloonLayoutImpl.java
License:Apache License
private List<ArrayList<Balloon>> createColumns(Rectangle layoutRec) { List<ArrayList<Balloon>> columns = new ArrayList<ArrayList<Balloon>>(); ArrayList<Balloon> eachColumn = new ArrayList<Balloon>(); columns.add(eachColumn);// w w w. j a va 2s . c o m int eachColumnHeight = 0; for (Balloon each : myBalloons) { final Dimension eachSize = each.getPreferredSize(); if (eachColumnHeight + eachSize.height > layoutRec.getHeight()) { eachColumn = new ArrayList<Balloon>(); columns.add(eachColumn); eachColumnHeight = 0; } eachColumn.add(each); eachColumnHeight += eachSize.height; } return columns; }