svn commit: r17161 - trunk/src/argouml-app/src/org/argouml/uml/ui/LabelledLayout.java
Bob Tarling <[email protected]>
| Newsgroups | gmane.comp.lang.uml.argouml.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: bobtarling
Date: 2009-06-28 08:26:17-0700
New Revision: 17161
Modified:
trunk/src/argouml-app/src/org/argouml/uml/ui/LabelledLayout.java
Log:
Tidy up the layout
Modified: trunk/src/argouml-app/src/org/argouml/uml/ui/LabelledLayout.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/ui/LabelledLayout.java?view=diff&pathrev=17161&r1=17160&r2=17161
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/ui/LabelledLayout.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/ui/LabelledLayout.java 2009-06-28 08:26:17-0700
@@ -33,6 +33,7 @@
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
+import javax.swing.JToolBar;
import javax.swing.UIManager;
/**
@@ -320,10 +321,13 @@
// Build up an array list of the heights of each label/component pair.
// Heights of zero indicate a proportional height.
+ Component previousComp = null;
for (int i = 0; i < componentCount; ++i) {
final Component childComp = (Component) components.get(i);
final int childHeight;
- if (childComp instanceof JLabel) {
+ if (childComp instanceof JToolBar && previousComp instanceof ScrollList) {
+ // Ignore toolbars belonging to ScrollList
+ } else if (childComp instanceof JLabel) {
final JLabel jlabel = (JLabel) childComp;
final Component labelledComp = jlabel.getLabelFor();
@@ -338,6 +342,9 @@
} else {
childHeight = getPreferredHeight(jlabel);
}
+
+ totalHeight += childHeight + this.vgap;
+ rowHeights.add(new Integer(childHeight));
} else {
// to manage the case there are no label/component
// pairs but just one component
@@ -345,10 +352,12 @@
if (childHeight == 0) {
++unknownHeightCount;
}
+
+ totalHeight += childHeight + this.vgap;
+ rowHeights.add(new Integer(childHeight));
}
- totalHeight += childHeight + this.vgap;
- rowHeights.add(new Integer(childHeight));
+ previousComp = childComp;
}
totalHeight -= this.vgap;
@@ -362,56 +371,62 @@
// consecutively.
int y = insets.top;
int row = 0;
+ previousComp = null;
for (int i = 0; i < componentCount; ++i) {
Component childComp = (Component) components.get(i);
if (childComp.isVisible()) {
- int rowHeight;
- int componentWidth = sectionWidth;
- int componentX = sectionX;
- // If the component is a JLabel which has another
- // component assigned then position/size the label and
- // calculate the size of the registered component
- if (childComp instanceof JLabel
- && ((JLabel) childComp).getLabelFor() != null) {
- i++; // Assumes the next child is the labelled component
- final JLabel jlabel = (JLabel) childComp;
- childComp = jlabel.getLabelFor();
- jlabel.setBounds(sectionX, y, labelWidth,
- getPreferredHeight(jlabel));
- componentWidth = sectionWidth - (labelWidth);
- componentX = sectionX + labelWidth;
- }
- rowHeight = rowHeights.get(row).intValue();
- if (rowHeight == 0) {
- try {
- rowHeight = calculateHeight(
- parentHeight,
- totalHeight,
- unknownHeightCount--,
- childComp);
- } catch (ArithmeticException e) {
- String lookAndFeel =
- UIManager.getLookAndFeel().getClass().getName();
- throw new IllegalStateException(
- "Division by zero laying out "
- + childComp.getClass().getName()
- + " on " + parent.getClass().getName()
- + " in section " + sectionNo
- + " using "
- + lookAndFeel,
- e);
+ if (childComp instanceof JToolBar && previousComp instanceof ScrollList) {
+ childComp.setLocation(previousComp.getY(), previousComp.getX() - childComp.getWidth());
+ } else {
+ int rowHeight;
+ int componentWidth = sectionWidth;
+ int componentX = sectionX;
+ // If the component is a JLabel which has another
+ // component assigned then position/size the label and
+ // calculate the size of the registered component
+ if (childComp instanceof JLabel
+ && ((JLabel) childComp).getLabelFor() != null) {
+ i++; // Assumes the next child is the labelled component
+ final JLabel jlabel = (JLabel) childComp;
+ childComp = jlabel.getLabelFor();
+ jlabel.setBounds(sectionX, y, labelWidth,
+ getPreferredHeight(jlabel));
+ componentWidth = sectionWidth - (labelWidth);
+ componentX = sectionX + labelWidth;
}
- totalHeight += rowHeight;
- }
- // Make sure the component width isn't any greater
- // than its maximum allowed width
- if (childComp.getMaximumSize() != null
- && getMaximumWidth(childComp) < componentWidth) {
- componentWidth = getMaximumWidth(childComp);
+ rowHeight = rowHeights.get(row).intValue();
+ if (rowHeight == 0) {
+ try {
+ rowHeight = calculateHeight(
+ parentHeight,
+ totalHeight,
+ unknownHeightCount--,
+ childComp);
+ } catch (ArithmeticException e) {
+ String lookAndFeel =
+ UIManager.getLookAndFeel().getClass().getName();
+ throw new IllegalStateException(
+ "Division by zero laying out "
+ + childComp.getClass().getName()
+ + " on " + parent.getClass().getName()
+ + " in section " + sectionNo
+ + " using "
+ + lookAndFeel,
+ e);
+ }
+ totalHeight += rowHeight;
+ }
+ // Make sure the component width isn't any greater
+ // than its maximum allowed width
+ if (childComp.getMaximumSize() != null
+ && getMaximumWidth(childComp) < componentWidth) {
+ componentWidth = getMaximumWidth(childComp);
+ }
+ childComp.setBounds(componentX, y, componentWidth, rowHeight);
+ y += rowHeight + this.vgap;
+ ++row;
+ previousComp = childComp;
}
- childComp.setBounds(componentX, y, componentWidth, rowHeight);
- y += rowHeight + this.vgap;
- ++row;
}
}
}
------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2366109
To unsubscribe from this discussion, e-mail: [[email protected]].