[Japi-cvs] SF.net SVN: japi: [287] libs
Status: Beta
Brought to you by:
christianhujer
|
From: <chr...@us...> - 2007-01-10 19:13:13
|
Revision: 287
http://svn.sourceforge.net/japi/?rev=287&view=rev
Author: christianhujer
Date: 2007-01-10 11:13:11 -0800 (Wed, 10 Jan 2007)
Log Message:
-----------
Renamed ColumnLayout to VerticalFlowLayout. Added ColumnLayout. Changed AbstractPrefs to use ColumnLayout instead of VerticalFlowLayout (formerly ColumnLayout).
Modified Paths:
--------------
libs/swing-prefs/trunk/src/net/sf/japi/swing/prefs/AbstractPrefs.java
Added Paths:
-----------
libs/swing-extlib/trunk/src/net/sf/japi/swing/RowLayout.java
libs/swing-extlib/trunk/src/net/sf/japi/swing/VerticalFlowLayout.java
Removed Paths:
-------------
libs/swing-extlib/trunk/src/net/sf/japi/swing/ColumnLayout.java
Deleted: libs/swing-extlib/trunk/src/net/sf/japi/swing/ColumnLayout.java
===================================================================
--- libs/swing-extlib/trunk/src/net/sf/japi/swing/ColumnLayout.java 2007-01-07 18:53:39 UTC (rev 286)
+++ libs/swing-extlib/trunk/src/net/sf/japi/swing/ColumnLayout.java 2007-01-10 19:13:11 UTC (rev 287)
@@ -1,149 +0,0 @@
-package net.sf.japi.swing;
-
-import java.awt.LayoutManager;
-import java.awt.Component;
-import java.awt.Dimension;
-import java.awt.Container;
-import java.awt.Insets;
-import org.jetbrains.annotations.Nullable;
-import org.jetbrains.annotations.NotNull;
-
-/** Layout similar to FlowLayout, but using columns (vertical layout) instead of rows (horizontal layout).
- * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
- */
-@SuppressWarnings({"NonPrivateFieldAccessedInSynchronizedContext", "FieldAccessedSynchronizedAndUnsynchronized"})
-public class ColumnLayout implements LayoutManager {
-
- /** Horizontal Gap. */
- private int hgap = 4;
-
- /** Vertical Gap. */
- private int vgap = 4;
-
- /** Create a ColumnLayout with default gaps (4, 4). */
- public ColumnLayout() {
- }
-
- /** Create a ColumnLayout with defined gaps.
- * @param hgap horizontal gap
- * @param vgap vertical gap
- */
- public ColumnLayout(final int hgap, final int vgap) {
- this.hgap = hgap;
- this.vgap = vgap;
- }
-
- /** Returns horizontal Gap.
- * @return horizontal Gap.
- */
- public int getHgap() {
- return hgap;
- }
-
- /** Sets horizontal Gap.
- * @param hgap horizontal Gap.
- */
- public void setHgap(final int hgap) {
- this.hgap = hgap;
- }
-
- /** Returns vertical Gap.
- * @return vertical Gap.
- */
- public int getVgap() {
- return vgap;
- }
-
- /** Sets vertical Gap.
- * @param vgap vertical Gap.
- */
- public void setVgap(final int vgap) {
- this.vgap = vgap;
- }
-
- /** {@inheritDoc} */
- public void addLayoutComponent(@Nullable final String name, @Nullable final Component comp) {
- // Superfluous
- }
-
- /** {@inheritDoc} */
- public void removeLayoutComponent(@Nullable final Component comp) {
- // Superfluous
- }
-
- /** {@inheritDoc} */
- @NotNull
- public Dimension preferredLayoutSize(@NotNull final Container parent) {
- synchronized (parent.getTreeLock()) {
- final Dimension preferredLayoutSize = new Dimension();
- final int nmembers = parent.getComponentCount();
- for (int i = 0; i < nmembers; i++) {
- final Component comp = parent.getComponent(i);
- if (comp.isVisible()) {
- final Dimension dim = comp.getPreferredSize();
- preferredLayoutSize.width = Math.max(preferredLayoutSize.width, dim.width);
- if (i > 0) {
- preferredLayoutSize.height += vgap;
- }
- preferredLayoutSize.height += dim.height;
- }
- }
- final Insets insets = parent.getInsets();
- preferredLayoutSize.width += insets.left + insets.right + (hgap << 1);
- preferredLayoutSize.height += insets.top + insets.bottom + (vgap << 1);
- return preferredLayoutSize;
- }
- }
-
- /** {@inheritDoc} */
- @NotNull public Dimension minimumLayoutSize(@NotNull final Container parent) {
- synchronized (parent.getTreeLock()) {
- final Dimension minimumLayoutSize = new Dimension();
- final int nmembers = parent.getComponentCount();
- for (int i = 0; i < nmembers; i++) {
- final Component comp = parent.getComponent(i);
- if (comp.isVisible()) {
- final Dimension dim = comp.getMinimumSize();
- minimumLayoutSize.width = Math.max(minimumLayoutSize.width, dim.width);
- if (i > 0) {
- minimumLayoutSize.height += vgap;
- }
- minimumLayoutSize.height += dim.height;
- }
- }
- final Insets insets = parent.getInsets();
- minimumLayoutSize.width += insets.left + insets.right + (hgap << 1);
- minimumLayoutSize.height += insets.top + insets.bottom + (vgap << 1);
- return minimumLayoutSize;
- }
- }
-
- /** {@inheritDoc} */
- public void layoutContainer(@NotNull final Container parent) {
- synchronized (parent.getTreeLock()) {
- final Insets insets = parent.getInsets();
- final int nmembers = parent.getComponentCount();
- final int maxheight = parent.getHeight() - (insets.left + insets.right + (vgap << 1));
- int maxwidth = 0;
- int y = 0;
- int x = insets.left + hgap;
- for (int i = 0; i < nmembers; i++) {
- final Component comp = parent.getComponent(i);
- if (comp.isVisible()) {
- final Dimension dim = comp.getPreferredSize();
- comp.setSize(dim);
- if (y + vgap + comp.getHeight() > maxheight) {
- y = 0;
- x += maxwidth + hgap;
- maxwidth = 0;
- }
- maxwidth = comp.getWidth() > maxwidth ? comp.getWidth() : maxwidth;
- y += vgap;
- comp.setLocation(x, y);
- y += comp.getHeight();
- }
- }
- }
- }
-
-} // class ColumnLayout
Added: libs/swing-extlib/trunk/src/net/sf/japi/swing/RowLayout.java
===================================================================
--- libs/swing-extlib/trunk/src/net/sf/japi/swing/RowLayout.java (rev 0)
+++ libs/swing-extlib/trunk/src/net/sf/japi/swing/RowLayout.java 2007-01-10 19:13:11 UTC (rev 287)
@@ -0,0 +1,108 @@
+package net.sf.japi.swing;
+
+import java.awt.LayoutManager;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Container;
+import java.awt.Insets;
+
+/**
+ * RowLayout is a layout that layouts its container's components vertically below each other.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public class RowLayout implements LayoutManager {
+
+ /** Vertical Gap. */
+ private int vgap = 4;
+
+ /** Create a RowLayout with default gaps (4, 4). */
+ public RowLayout() {
+ }
+
+ /** Create a RowLayout with defined gaps.
+ * @param hgap horizontal gap
+ * @param vgap vertical gap
+ */
+ public RowLayout(final int hgap, final int vgap) {
+ this.vgap = vgap;
+ }
+
+ /** {@inheritDoc} */
+ public void addLayoutComponent(String name, Component comp) {
+ // nothing to do
+ }
+
+ /** {@inheritDoc} */
+ public void removeLayoutComponent(Component comp) {
+ // nothing to do
+ }
+
+ /** {@inheritDoc} */
+ public Dimension preferredLayoutSize(Container parent) {
+ synchronized (parent.getTreeLock()) {
+ final Dimension preferredLayoutSize = new Dimension();
+ final int nmembers = parent.getComponentCount();
+ for (int i = 0; i < nmembers; i++) {
+ final Component comp = parent.getComponent(i);
+ if (comp.isVisible()) {
+ final Dimension dim = comp.getPreferredSize();
+ preferredLayoutSize.width = Math.max(preferredLayoutSize.width, dim.width);
+ if (i > 0) {
+ preferredLayoutSize.height += vgap;
+ }
+ preferredLayoutSize.height += dim.height;
+ }
+ }
+ final Insets insets = parent.getInsets();
+ preferredLayoutSize.height += insets.top + insets.bottom + (vgap << 1);
+ return preferredLayoutSize;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public Dimension minimumLayoutSize(Container parent) {
+ synchronized (parent.getTreeLock()) {
+ final Dimension minimumLayoutSize = new Dimension();
+ final int nmembers = parent.getComponentCount();
+ for (int i = 0; i < nmembers; i++) {
+ final Component comp = parent.getComponent(i);
+ if (comp.isVisible()) {
+ final Dimension dim = comp.getMinimumSize();
+ minimumLayoutSize.width = Math.max(minimumLayoutSize.width, dim.width);
+ if (i > 0) {
+ minimumLayoutSize.height += vgap;
+ }
+ minimumLayoutSize.height += dim.height;
+ }
+ }
+ final Insets insets = parent.getInsets();
+ minimumLayoutSize.width += insets.left + insets.right;
+ minimumLayoutSize.height += insets.top + insets.bottom + (vgap << 1);
+ return minimumLayoutSize;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void layoutContainer(Container parent) {
+ synchronized (parent.getTreeLock()) {
+ final Insets insets = parent.getInsets();
+ final int nmembers = parent.getComponentCount();
+ final int maxheight = parent.getHeight() - (insets.left + insets.right + (vgap << 1));
+ final int width = parent.getWidth();
+ int y = 0;
+ final int x = insets.left;
+ for (int i = 0; i < nmembers; i++) {
+ final Component comp = parent.getComponent(i);
+ if (comp.isVisible()) {
+ final Dimension dim = comp.getPreferredSize();
+ dim.setSize(dim.getWidth(), dim.getHeight());
+ comp.setSize(dim);
+ y += vgap;
+ comp.setLocation(x, y);
+ y += comp.getHeight();
+ }
+ }
+ }
+ }
+
+} // class RowLayout
Property changes on: libs/swing-extlib/trunk/src/net/sf/japi/swing/RowLayout.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
Copied: libs/swing-extlib/trunk/src/net/sf/japi/swing/VerticalFlowLayout.java (from rev 286, libs/swing-extlib/trunk/src/net/sf/japi/swing/ColumnLayout.java)
===================================================================
--- libs/swing-extlib/trunk/src/net/sf/japi/swing/VerticalFlowLayout.java (rev 0)
+++ libs/swing-extlib/trunk/src/net/sf/japi/swing/VerticalFlowLayout.java 2007-01-10 19:13:11 UTC (rev 287)
@@ -0,0 +1,149 @@
+package net.sf.japi.swing;
+
+import java.awt.LayoutManager;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Container;
+import java.awt.Insets;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.NotNull;
+
+/** Layout similar to FlowLayout, but using columns (vertical layout) instead of rows (horizontal layout).
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+@SuppressWarnings({"NonPrivateFieldAccessedInSynchronizedContext", "FieldAccessedSynchronizedAndUnsynchronized"})
+public class VerticalFlowLayout implements LayoutManager {
+
+ /** Horizontal Gap. */
+ private int hgap = 4;
+
+ /** Vertical Gap. */
+ private int vgap = 4;
+
+ /** Create a VerticalFlowLayout with default gaps (4, 4). */
+ public VerticalFlowLayout() {
+ }
+
+ /** Create a VerticalFlowLayout with defined gaps.
+ * @param hgap horizontal gap
+ * @param vgap vertical gap
+ */
+ public VerticalFlowLayout(final int hgap, final int vgap) {
+ this.hgap = hgap;
+ this.vgap = vgap;
+ }
+
+ /** Returns horizontal Gap.
+ * @return horizontal Gap.
+ */
+ public int getHgap() {
+ return hgap;
+ }
+
+ /** Sets horizontal Gap.
+ * @param hgap horizontal Gap.
+ */
+ public void setHgap(final int hgap) {
+ this.hgap = hgap;
+ }
+
+ /** Returns vertical Gap.
+ * @return vertical Gap.
+ */
+ public int getVgap() {
+ return vgap;
+ }
+
+ /** Sets vertical Gap.
+ * @param vgap vertical Gap.
+ */
+ public void setVgap(final int vgap) {
+ this.vgap = vgap;
+ }
+
+ /** {@inheritDoc} */
+ public void addLayoutComponent(@Nullable final String name, @Nullable final Component comp) {
+ // Superfluous
+ }
+
+ /** {@inheritDoc} */
+ public void removeLayoutComponent(@Nullable final Component comp) {
+ // Superfluous
+ }
+
+ /** {@inheritDoc} */
+ @NotNull
+ public Dimension preferredLayoutSize(@NotNull final Container parent) {
+ synchronized (parent.getTreeLock()) {
+ final Dimension preferredLayoutSize = new Dimension();
+ final int nmembers = parent.getComponentCount();
+ for (int i = 0; i < nmembers; i++) {
+ final Component comp = parent.getComponent(i);
+ if (comp.isVisible()) {
+ final Dimension dim = comp.getPreferredSize();
+ preferredLayoutSize.width = Math.max(preferredLayoutSize.width, dim.width);
+ if (i > 0) {
+ preferredLayoutSize.height += vgap;
+ }
+ preferredLayoutSize.height += dim.height;
+ }
+ }
+ final Insets insets = parent.getInsets();
+ preferredLayoutSize.width += insets.left + insets.right + (hgap << 1);
+ preferredLayoutSize.height += insets.top + insets.bottom + (vgap << 1);
+ return preferredLayoutSize;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @NotNull public Dimension minimumLayoutSize(@NotNull final Container parent) {
+ synchronized (parent.getTreeLock()) {
+ final Dimension minimumLayoutSize = new Dimension();
+ final int nmembers = parent.getComponentCount();
+ for (int i = 0; i < nmembers; i++) {
+ final Component comp = parent.getComponent(i);
+ if (comp.isVisible()) {
+ final Dimension dim = comp.getMinimumSize();
+ minimumLayoutSize.width = Math.max(minimumLayoutSize.width, dim.width);
+ if (i > 0) {
+ minimumLayoutSize.height += vgap;
+ }
+ minimumLayoutSize.height += dim.height;
+ }
+ }
+ final Insets insets = parent.getInsets();
+ minimumLayoutSize.width += insets.left + insets.right + (hgap << 1);
+ minimumLayoutSize.height += insets.top + insets.bottom + (vgap << 1);
+ return minimumLayoutSize;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void layoutContainer(@NotNull final Container parent) {
+ synchronized (parent.getTreeLock()) {
+ final Insets insets = parent.getInsets();
+ final int nmembers = parent.getComponentCount();
+ final int maxheight = parent.getHeight() - (insets.left + insets.right + (vgap << 1));
+ int maxwidth = 0;
+ int y = 0;
+ int x = insets.left + hgap;
+ for (int i = 0; i < nmembers; i++) {
+ final Component comp = parent.getComponent(i);
+ if (comp.isVisible()) {
+ final Dimension dim = comp.getPreferredSize();
+ comp.setSize(dim);
+ if (y + vgap + comp.getHeight() > maxheight) {
+ y = 0;
+ x += maxwidth + hgap;
+ maxwidth = 0;
+ }
+ maxwidth = comp.getWidth() > maxwidth ? comp.getWidth() : maxwidth;
+ y += vgap;
+ comp.setLocation(x, y);
+ y += comp.getHeight();
+ }
+ }
+ }
+ }
+
+} // class VerticalFlowLayout
Property changes on: libs/swing-extlib/trunk/src/net/sf/japi/swing/VerticalFlowLayout.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
Modified: libs/swing-prefs/trunk/src/net/sf/japi/swing/prefs/AbstractPrefs.java
===================================================================
--- libs/swing-prefs/trunk/src/net/sf/japi/swing/prefs/AbstractPrefs.java 2007-01-07 18:53:39 UTC (rev 286)
+++ libs/swing-prefs/trunk/src/net/sf/japi/swing/prefs/AbstractPrefs.java 2007-01-10 19:13:11 UTC (rev 287)
@@ -20,13 +20,13 @@
package net.sf.japi.swing.prefs;
+import java.awt.LayoutManager;
import java.net.URL;
-import java.awt.LayoutManager;
+import javax.swing.BoxLayout;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JPanel;
-import javax.swing.BoxLayout;
-import net.sf.japi.swing.ColumnLayout;
+import net.sf.japi.swing.RowLayout;
/** Abstract preferences implementation.
* Subclass this.
@@ -66,7 +66,7 @@
/** Constructor. */
protected AbstractPrefs() {
- super(new ColumnLayout());
+ super(new RowLayout());
// setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|