You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2009/11/09 21:46:37 UTC
svn commit: r834223 - in /incubator/pivot/trunk:
tutorials/src/org/apache/pivot/tutorials/layout/
wtk/src/org/apache/pivot/wtk/effects/ wtk/src/org/apache/pivot/wtk/skin/
Author: gbrown
Date: Mon Nov 9 20:46:36 2009
New Revision: 834223
URL: http://svn.apache.org/viewvc?rev=834223&view=rev
Log:
Update FlowPane preferred size calculations to account for baseline alignment; fix some minor memory leaks in various decorators; add a BaselineDecorator class to assist in debugging baseline code (the previous approach, which used a drawBaselineDebug() method in ComponentSkin, did not work for container skins, whose children are painted over their contents).
Added:
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/BaselineDecorator.java
Modified:
incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/layout/flow_panes.wtkx
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/BlurDecorator.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/GrayscaleDecorator.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/OverlayDecorator.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/ReflectionDecorator.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/SaturationDecorator.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/ShadeDecorator.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/TagDecorator.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/WatermarkDecorator.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FlowPaneSkin.java
Modified: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/layout/flow_panes.wtkx
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/layout/flow_panes.wtkx?rev=834223&r1=834222&r2=834223&view=diff
==============================================================================
--- incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/layout/flow_panes.wtkx (original)
+++ incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/layout/flow_panes.wtkx Mon Nov 9 20:46:36 2009
@@ -18,22 +18,33 @@
<Window title="Flow Panes" maximized="true"
xmlns:wtkx="http://pivot.apache.org/wtkx"
+ xmlns:effects="org.apache.pivot.wtk.effects"
xmlns="org.apache.pivot.wtk">
<content>
<SplitPane splitRatio="0.75">
<left>
- <Border>
+ <Border styles="{padding:4}">
<content>
- <FlowPane wtkx:id="flowPane" styles="{padding:2}">
- <PushButton buttonData="0" styles="{minimumAspectRatio:1.5}"/>
- <PushButton buttonData="1" styles="{minimumAspectRatio:1.5}"/>
- <PushButton buttonData="2" styles="{minimumAspectRatio:1.5}"/>
- <PushButton buttonData="3" preferredWidth="20" preferredHeight="20"/>
- <PushButton buttonData="4" preferredWidth="30" preferredHeight="30"/>
- <PushButton buttonData="5" preferredWidth="40" preferredHeight="40"/>
- <PushButton buttonData="6" styles="{minimumAspectRatio:1.5}"/>
- <PushButton buttonData="7" styles="{minimumAspectRatio:1.5}"/>
- </FlowPane>
+ <BoxPane orientation="vertical" styles="{verticalAlignment:'center', fill:true}">
+ <Border>
+ <content>
+ <FlowPane wtkx:id="flowPane" styles="{padding:2}">
+ <decorators>
+ <effects:BaselineDecorator/>
+ </decorators>
+
+ <PushButton buttonData="0" styles="{minimumAspectRatio:1.5}"/>
+ <PushButton buttonData="1" styles="{minimumAspectRatio:1.5}"/>
+ <PushButton buttonData="2" styles="{minimumAspectRatio:1.5}"/>
+ <PushButton buttonData="3" preferredWidth="20" preferredHeight="20"/>
+ <PushButton buttonData="4" preferredWidth="30" preferredHeight="30"/>
+ <PushButton buttonData="5" preferredWidth="40" preferredHeight="40"/>
+ <PushButton buttonData="6" styles="{minimumAspectRatio:1.5}"/>
+ <PushButton buttonData="7" styles="{minimumAspectRatio:1.5}"/>
+ </FlowPane>
+ </content>
+ </Border>
+ </BoxPane>
</content>
</Border>
</left>
Added: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/BaselineDecorator.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/BaselineDecorator.java?rev=834223&view=auto
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/BaselineDecorator.java (added)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/BaselineDecorator.java Mon Nov 9 20:46:36 2009
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pivot.wtk.effects;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.geom.AffineTransform;
+
+import org.apache.pivot.wtk.Bounds;
+import org.apache.pivot.wtk.Component;
+import org.apache.pivot.wtk.GraphicsUtilities;
+import org.apache.pivot.wtk.Orientation;
+
+/**
+ * Displays a component's baseline.
+ */
+public class BaselineDecorator implements Decorator {
+ private Component component = null;
+ private Graphics2D graphics = null;
+
+ @Override
+ public Graphics2D prepare(Component component, Graphics2D graphics) {
+ this.component = component;
+ this.graphics = graphics;
+
+ return graphics;
+ }
+
+ @Override
+ public void update() {
+ int width = component.getWidth();
+ int baseline = component.getBaseline(width, component.getHeight());
+
+ if (baseline != -1) {
+ graphics.setPaint(Color.RED);
+ GraphicsUtilities.drawLine(graphics, 0, baseline, width, Orientation.HORIZONTAL);
+ }
+
+ component = null;
+ graphics = null;
+ }
+
+ @Override
+ public Bounds getBounds(Component component) {
+ return new Bounds(0, 0, component.getWidth(), component.getHeight());
+ }
+
+ @Override
+ public AffineTransform getTransform(Component component) {
+ return new AffineTransform();
+ }
+}
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/BlurDecorator.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/BlurDecorator.java?rev=834223&r1=834222&r2=834223&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/BlurDecorator.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/BlurDecorator.java Mon Nov 9 20:46:36 2009
@@ -94,6 +94,8 @@
@Override
public void update() {
bufferedImageGraphics.dispose();
+ bufferedImageGraphics = null;
+
bufferedImage.flush();
float[] kernel = new float[blurMagnitude * blurMagnitude];
@@ -105,7 +107,10 @@
kernel), ConvolveOp.EDGE_NO_OP, null);
bufferedImage = blur.filter(bufferedImage, null);
- this.graphics.drawImage(bufferedImage, 0, 0, null);
+ graphics.drawImage(bufferedImage, 0, 0, null);
+
+ bufferedImage = null;
+ graphics = null;
}
@Override
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/GrayscaleDecorator.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/GrayscaleDecorator.java?rev=834223&r1=834222&r2=834223&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/GrayscaleDecorator.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/GrayscaleDecorator.java Mon Nov 9 20:46:36 2009
@@ -55,9 +55,14 @@
@Override
public void update() {
bufferedImageGraphics.dispose();
+ bufferedImageGraphics = null;
+
bufferedImage.flush();
graphics.drawImage(bufferedImage, 0, 0, null);
+
+ bufferedImage = null;
+ graphics = null;
}
@Override
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/OverlayDecorator.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/OverlayDecorator.java?rev=834223&r1=834222&r2=834223&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/OverlayDecorator.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/OverlayDecorator.java Mon Nov 9 20:46:36 2009
@@ -59,6 +59,8 @@
@Override
public void update() {
overlay.paint(graphics);
+
+ graphics = null;
}
@Override
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/ReflectionDecorator.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/ReflectionDecorator.java?rev=834223&r1=834222&r2=834223&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/ReflectionDecorator.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/ReflectionDecorator.java Mon Nov 9 20:46:36 2009
@@ -33,16 +33,16 @@
* TODO Make gradient properties configurable.
*/
public class ReflectionDecorator implements Decorator {
- private Graphics2D graphics = null;
private Component component = null;
+ private Graphics2D graphics = null;
private BufferedImage componentImage = null;
private Graphics2D componentImageGraphics = null;
@Override
public Graphics2D prepare(Component component, Graphics2D graphics) {
- this.graphics = graphics;
this.component = component;
+ this.graphics = graphics;
int width = component.getWidth();
int height = component.getHeight();
@@ -76,11 +76,17 @@
componentImageGraphics.fillRect(0, 0, width, height);
componentImageGraphics.dispose();
+ componentImageGraphics = null;
+
componentImage.flush();
graphics.transform(getTransform(component));
graphics.drawImage(componentImage, 0, 0, null);
+
+ componentImage = null;
+ component = null;
+ graphics = null;
}
@Override
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/SaturationDecorator.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/SaturationDecorator.java?rev=834223&r1=834222&r2=834223&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/SaturationDecorator.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/SaturationDecorator.java Mon Nov 9 20:46:36 2009
@@ -135,7 +135,12 @@
}
componentGraphics.dispose();
+ componentGraphics = null;
+
graphics.drawImage(componentImage, x, y, null);
+
+ componentImage = null;
+ graphics = null;
}
@Override
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/ShadeDecorator.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/ShadeDecorator.java?rev=834223&r1=834222&r2=834223&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/ShadeDecorator.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/ShadeDecorator.java Mon Nov 9 20:46:36 2009
@@ -34,8 +34,8 @@
private float opacity;
private Color color;
- private Graphics2D graphics;
private Component component;
+ private Graphics2D graphics;
/**
* Creates a new <tt>ShadeDecorator</tt> with the default opacity and
@@ -56,7 +56,8 @@
* The color of the shade.
*/
public ShadeDecorator(float opacity, Color color) {
- if (opacity <= 0 || opacity >= 1) {
+ if (opacity <= 0
+ || opacity >= 1) {
throw new IllegalArgumentException("opacity must be between 0 and 1, exclusive.");
}
@@ -108,8 +109,8 @@
@Override
public Graphics2D prepare(Component component, Graphics2D graphics) {
- this.graphics = graphics;
this.component = component;
+ this.graphics = graphics;
return graphics;
}
@@ -119,6 +120,9 @@
graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacity));
graphics.setColor(color);
graphics.fillRect(0, 0, component.getWidth(), component.getHeight());
+
+ component = null;
+ graphics = null;
}
@Override
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/TagDecorator.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/TagDecorator.java?rev=834223&r1=834222&r2=834223&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/TagDecorator.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/TagDecorator.java Mon Nov 9 20:46:36 2009
@@ -145,6 +145,8 @@
graphics.translate(bounds.x, bounds.y);
tag.paint(graphics);
}
+
+ graphics = null;
}
@Override
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/WatermarkDecorator.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/WatermarkDecorator.java?rev=834223&r1=834222&r2=834223&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/WatermarkDecorator.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/WatermarkDecorator.java Mon Nov 9 20:46:36 2009
@@ -328,6 +328,9 @@
}
watermarkGraphics.dispose();
+
+ component = null;
+ graphics = null;
}
@Override
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java?rev=834223&r1=834222&r2=834223&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/ComponentSkin.java Mon Nov 9 20:46:36 2009
@@ -16,9 +16,7 @@
*/
package org.apache.pivot.wtk.skin;
-import java.awt.Color;
import java.awt.Font;
-import java.awt.Graphics2D;
import org.apache.pivot.serialization.JSONSerializer;
import org.apache.pivot.serialization.SerializationException;
@@ -38,11 +36,9 @@
import org.apache.pivot.wtk.Display;
import org.apache.pivot.wtk.DragSource;
import org.apache.pivot.wtk.DropTarget;
-import org.apache.pivot.wtk.GraphicsUtilities;
import org.apache.pivot.wtk.Keyboard;
import org.apache.pivot.wtk.MenuHandler;
import org.apache.pivot.wtk.Mouse;
-import org.apache.pivot.wtk.Orientation;
import org.apache.pivot.wtk.Point;
import org.apache.pivot.wtk.Skin;
import org.apache.pivot.wtk.Theme;
@@ -364,16 +360,6 @@
}
}
- protected void drawBaselineDebug(Graphics2D graphics) {
- int width = getWidth();
- int baseline = getBaseline(width, getHeight());
-
- if (baseline != -1) {
- graphics.setPaint(Color.RED);
- GraphicsUtilities.drawLine(graphics, 0, baseline, width, Orientation.HORIZONTAL);
- }
- }
-
public static Font decodeFont(String value) {
Font font;
if (value.startsWith("{")) {
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FlowPaneSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FlowPaneSkin.java?rev=834223&r1=834222&r2=834223&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FlowPaneSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/FlowPaneSkin.java Mon Nov 9 20:46:36 2009
@@ -28,11 +28,19 @@
* Flow pane skin.
*/
public class FlowPaneSkin extends ContainerSkin {
- private HorizontalAlignment alignment = HorizontalAlignment.LEFT;
- private Insets padding = Insets.NONE;
- private int horizontalSpacing = 2;
- private int verticalSpacing = 2;
- private boolean alignToBaseline = false;
+ private HorizontalAlignment alignment;
+ private Insets padding;
+ private int horizontalSpacing;
+ private int verticalSpacing;
+ private boolean alignToBaseline;
+
+ public FlowPaneSkin() {
+ alignment = HorizontalAlignment.LEFT;
+ padding = Insets.NONE;
+ horizontalSpacing = 2;
+ verticalSpacing = 2;
+ alignToBaseline = true;
+ }
@Override
public int getPreferredWidth(int height) {
@@ -65,55 +73,73 @@
@Override
public int getPreferredHeight(int width) {
- // TODO Account for baseline in these calculations
-
FlowPane flowPane = (FlowPane)getComponent();
- int preferredHeight = 0;
+ int preferredHeight;
if (width == -1) {
- // Preferred height is the maximum preferred height of all components
- for (int i = 0, n = flowPane.getLength(); i < n; i++) {
- Component component = flowPane.get(i);
+ if (alignToBaseline) {
+ // Delegate to preferred size calculations
+ Dimensions preferredSize = getPreferredSize();
+ preferredHeight = preferredSize.height;
+ } else {
+ // Preferred height is the maximum preferred height of all components
+ preferredHeight = 0;
- if (component.isVisible()) {
- preferredHeight = Math.max(preferredHeight,
- component.getPreferredHeight());
+ for (int i = 0, n = flowPane.getLength(); i < n; i++) {
+ Component component = flowPane.get(i);
+
+ if (component.isVisible()) {
+ preferredHeight = Math.max(preferredHeight, component.getPreferredHeight());
+ }
}
}
} else {
+ // Break the components into multiple rows
+ preferredHeight = 0;
+
int contentWidth = Math.max(width - (padding.left + padding.right), 0);
- // Break the components into multiple rows
int rowCount = 0;
int rowWidth = 0;
- int rowHeight = 0;
+ int rowAscent = 0;
+ int rowDescent = 0;
+
for (int i = 0, n = flowPane.getLength(); i < n; i++) {
Component component = flowPane.get(i);
if (component.isVisible()) {
- Dimensions componentSize = component.getPreferredSize();
+ Dimensions size = component.getPreferredSize();
- if (rowWidth + componentSize.width > contentWidth
+ if (rowWidth + size.width > contentWidth
&& rowWidth > 0) {
// The component is too big to fit in the remaining space,
// and it is not the only component in this row; wrap
- preferredHeight += rowHeight;
+ preferredHeight += rowAscent + rowDescent;
rowCount++;
rowWidth = 0;
- rowHeight = 0;
+ rowAscent = 0;
+ rowDescent = 0;
}
- rowWidth += componentSize.width + horizontalSpacing;
- rowHeight = Math.max(rowHeight, componentSize.height);
+ rowWidth += size.width + horizontalSpacing;
+
+ if (alignToBaseline) {
+ int baseline = component.getBaseline(size.width, size.height);
+ rowAscent = Math.max(rowAscent, baseline);
+ rowDescent = Math.max(rowDescent, size.height - baseline);
+ } else {
+ rowAscent = Math.max(rowAscent, size.height);
+ }
}
}
// Add the last row
- if (rowHeight > 0) {
- preferredHeight += rowHeight;
+ int lastRowHeight = rowAscent + rowDescent;
+ if (lastRowHeight > 0) {
+ preferredHeight += lastRowHeight;
rowCount++;
}
@@ -131,21 +157,29 @@
@Override
public Dimensions getPreferredSize() {
- // TODO Account for baseline in these calculations
-
FlowPane flowPane = (FlowPane)getComponent();
int preferredWidth = 0;
- int preferredHeight = 0;
+
+ int ascent = 0;
+ int descent = 0;
int j = 0;
for (int i = 0, n = flowPane.getLength(); i < n; i++) {
Component component = flowPane.get(i);
if (component.isVisible()) {
- Dimensions componentSize = component.getPreferredSize();
- preferredWidth += componentSize.width;
- preferredHeight = Math.max(preferredHeight, componentSize.height);
+ Dimensions size = component.getPreferredSize();
+ preferredWidth += size.width;
+
+ if (alignToBaseline) {
+ int baseline = component.getBaseline(size.width, size.height);
+ ascent = Math.max(ascent, baseline);
+ descent = Math.max(descent, size.height - baseline);
+ } else {
+ ascent = Math.max(ascent, size.height);
+ }
+
j++;
}
}
@@ -157,9 +191,9 @@
// Include padding
preferredWidth += padding.left + padding.right;
- preferredHeight += padding.top + padding.bottom;
- return new Dimensions(preferredWidth, preferredHeight);
+ return new Dimensions(preferredWidth, ascent + descent
+ + padding.top + padding.bottom);
}
@Override
@@ -168,32 +202,31 @@
int baseline = -1;
- int contentWidth = Math.max(width - (padding.left + padding.right), 0);
+ if (alignToBaseline) {
+ int contentWidth = Math.max(width - (padding.left + padding.right), 0);
- // Break the components into multiple rows, and calculate the baseline of the
- // first row
- int rowWidth = 0;
- for (int i = 0, n = flowPane.getLength(); i < n; i++) {
- Component component = flowPane.get(i);
+ // Break the components into multiple rows, and calculate the baseline of the
+ // first row
+ int rowWidth = 0;
+ for (int i = 0, n = flowPane.getLength(); i < n; i++) {
+ Component component = flowPane.get(i);
- if (component.isVisible()) {
- Dimensions componentSize = component.getPreferredSize();
+ if (component.isVisible()) {
+ Dimensions size = component.getPreferredSize();
- if (rowWidth + componentSize.width > contentWidth
- && rowWidth > 0) {
- // The component is too big to fit in the remaining space,
- // and it is not the only component in this row; wrap
- break;
- }
+ if (rowWidth + size.width > contentWidth
+ && rowWidth > 0) {
+ // The component is too big to fit in the remaining space,
+ // and it is not the only component in this row; wrap
+ break;
+ }
- baseline = Math.max(baseline, component.getBaseline(componentSize.width,
- componentSize.height));
- rowWidth += componentSize.width + horizontalSpacing;
+ baseline = Math.max(baseline, component.getBaseline(size.width, size.height));
+ rowWidth += size.width + horizontalSpacing;
+ }
}
- }
- // Include top padding value
- if (baseline != -1) {
+ // Include top padding value
baseline += padding.top;
}
@@ -276,7 +309,8 @@
for (Component component : row) {
int y;
- if (alignToBaseline && baseline != -1) {
+ if (alignToBaseline
+ && baseline != -1) {
// Align to baseline
y = baseline - component.getBaseline(component.getWidth(),
component.getHeight());