20 package net.sf.gridarta.textedit.textarea;
22 import java.awt.Component;
23 import java.awt.Container;
24 import java.awt.Dimension;
25 import java.awt.Insets;
26 import java.awt.LayoutManager;
27 import java.util.ArrayList;
28 import java.util.Collection;
29 import org.jetbrains.annotations.NotNull;
30 import org.jetbrains.annotations.Nullable;
34 public static final String
CENTER =
"center";
36 public static final String
RIGHT =
"right";
38 public static final String
BOTTOM =
"bottom";
67 if (name.equals(CENTER)) {
69 }
else if (name.equals(RIGHT)) {
71 }
else if (name.equals(BOTTOM)) {
73 }
else if (name.equals(LEFT_OF_SCROLL_BAR)) {
74 leftOfScrollBar.add(comp);
91 leftOfScrollBar.remove(comp);
98 final Dimension dim =
new Dimension();
99 final Insets insets = textArea.getInsets();
100 dim.width = insets.left + insets.right;
101 dim.height = insets.top + insets.bottom;
103 if (center != null) {
104 final Dimension centerPref = center.getPreferredSize();
105 dim.width += centerPref.width;
106 dim.height += centerPref.height;
109 final Dimension rightPref = right.getPreferredSize();
110 dim.width += rightPref.width;
112 if (bottom != null) {
113 final Dimension bottomPref = bottom.getPreferredSize();
114 dim.height += bottomPref.height;
123 final Dimension dim =
new Dimension();
124 final Insets insets = textArea.getInsets();
125 dim.width = insets.left + insets.right;
126 dim.height = insets.top + insets.bottom;
128 if (center != null) {
129 final Dimension centerPref = center.getMinimumSize();
130 dim.width += centerPref.width;
131 dim.height += centerPref.height;
134 final Dimension rightPref = right.getMinimumSize();
135 dim.width += rightPref.width;
137 if (bottom != null) {
138 final Dimension bottomPref = bottom.getMinimumSize();
139 dim.height += bottomPref.height;
147 final Dimension size = parent.getSize();
148 final Insets insets = parent.getInsets();
149 final int insetsTop = insets.top;
150 int insetsLeft = insets.left;
151 final int insetsBottom = insets.bottom;
152 final int insetsRight = insets.right;
154 final int rightWidth = right != null ? right.getPreferredSize().width : 0;
155 final int bottomHeight = bottom != null ? bottom.getPreferredSize().height : 0;
156 final int centerWidth = size.width - rightWidth - insetsLeft - insetsRight;
157 final int centerHeight = size.height - bottomHeight - insetsTop - insetsBottom;
159 if (center != null) {
160 center.setBounds(insetsLeft, insetsTop, centerWidth, centerHeight);
164 right.setBounds(insetsLeft + centerWidth, insetsTop, rightWidth, centerHeight);
168 for (
final Component comp : leftOfScrollBar) {
169 final Dimension dim = comp.getPreferredSize();
170 comp.setBounds(insetsLeft, insetsTop + centerHeight, dim.width, bottomHeight);
171 insetsLeft += dim.width;
174 if (bottom != null) {
175 bottom.setBounds(insetsLeft, insetsTop + centerHeight, size.width - rightWidth - insetsLeft - insetsRight, bottomHeight);
void removeLayoutComponent(@NotNull final Component comp)
static final String BOTTOM
final Collection< Component > leftOfScrollBar
Dimension preferredLayoutSize(@NotNull final Container parent)
static final String LEFT_OF_SCROLL_BAR
Adding components with this name to the text area will place them left of the horizontal scroll bar...
ScrollLayout(@NotNull final Container textArea)
Dimension minimumLayoutSize(@NotNull final Container parent)
void addLayoutComponent(@NotNull final String name, @NotNull final Component comp)
static final String CENTER
void layoutContainer(@NotNull final Container parent)
static final String RIGHT