[SCM] JAS(2) Plotter branch, master, updated. upstream/2.2.6-23-g1206850
Giovanni Mascellani
gmascellani-guest at alioth.debian.org
Tue Jan 19 15:56:10 UTC 2010
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "JAS(2) Plotter".
The branch, master has been updated
via 120685075233353ce45964899cfa89cbce57277c (commit)
via 075012953cefbda43256db4df1bfd273c2f861e4 (commit)
via d875caf12aff24ca345fe795f4ffd39c61a8b548 (commit)
via d48fe0bf686c14db5e7ca374e1ac548214af073f (commit)
via 220529aae25bffee57f58ec4d50a54cc323e4dca (commit)
via 7a2d06dad2f3a70126adf08ef22c9ea7b7b6149f (commit)
via e5f0335850594d1dae3a1f419fb943dd1c32076e (commit)
from 13f164da8ba5d6a6f95c4edaaf6b2164c94f069d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
-----------------------------------------------------------------------
Summary of changes:
debian/changelog | 2 +-
debian/control | 16 +-
debian/copyright | 2 +-
src/main/java/tablelayout/COPYRIGHT.html | 61 ---
src/main/java/tablelayout/TableCol.java | 264 ------------
src/main/java/tablelayout/TableLayout.java | 597 ----------------------------
src/main/java/tablelayout/TableLoc.java | 321 ---------------
src/main/java/tablelayout/TableLocRec.java | 343 ----------------
src/main/java/tablelayout/TableOpts.java | 205 ----------
src/main/java/tablelayout/TableRow.java | 263 ------------
src/main/java/tablelayout/TableVec.java | 449 ---------------------
src/main/java/tablelayout/TableVecRec.java | 75 ----
12 files changed, 13 insertions(+), 2585 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 28a69fa..84324fd 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,4 +2,4 @@ jas-plotter (2.2.6-1) unstable; urgency=low
* Initial release (Closes: #558344)
- -- Gabriele Giacone <1o5g4r8o at gmail.com> Sat, 12 Dec 2009 18:07:45 +0100
+ -- Giovanni Mascellani <mascellani at poisson.phc.unipi.it> Tue, 19 Jan 2010 16:43:05 +0100
diff --git a/debian/control b/debian/control
index 6859e27..b442a47 100644
--- a/debian/control
+++ b/debian/control
@@ -14,9 +14,15 @@ Homepage: http://java.freehep.org/jas-plotter/
Package: libjas-plotter-java
Architecture: all
-Depends: ${misc:Depends}, ${maven:Depends}
+Depends: ${misc:Depends}, ${maven:Depends}, libtablelayout-java,
+ openjdk-6-jre | java2-runtime
Recommends: ${maven:OptionalDepends}
-Description: JAS(2) Plotter graphic utility
- Basic plot widget, part of the Java Analysis Studio distribution. It is
- designed to be usable by itself in other applications
-
+Description: JAS(2) Plotter graphic library
+ This library, part of the Java Analysis Studio distribution, is able to
+ draw various sorts of plots, such as monodimensional and bidimensinal
+ histograms, scatter plots or function fits. Many aspects of the plots,
+ such as the color or the style of the lines, can also be interactively
+ modified via a Swing interface.
+ .
+ This library is used in FreeHEP, a collection of Java libraries used
+ in High Energy Physics.
diff --git a/debian/copyright b/debian/copyright
index d9c0f0d..2219d98 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -12,7 +12,7 @@ License: LGPL-2.1+
LGPL-2.1 license in '/usr/share/common-licenses/LGPL-2.1'
No license files are included in upstream tarball but copyright holders
list is available at
-<http://java.freehep.org/svn/repos/freehep/show/freehep/trunk/vectorgraphics/LICENSE.txt>
+ <http://java.freehep.org/svn/repos/freehep/show/freehep/trunk/vectorgraphics/LICENSE.txt>
and adopted license at <http://java.freehep.org/license.html>
Files: debian/*
diff --git a/src/main/java/tablelayout/COPYRIGHT.html b/src/main/java/tablelayout/COPYRIGHT.html
deleted file mode 100644
index 5ace29d..0000000
--- a/src/main/java/tablelayout/COPYRIGHT.html
+++ /dev/null
@@ -1,61 +0,0 @@
-<html>
-<!-- $Id: COPYRIGHT.html 11550 2007-06-05 21:44:14Z duns $ -->
-<head>
-<title>TableLayout copyright and disclaimer</Title>
-</head>
-<body>
-<center>
-<h1>TableLayout Copyright and Disclaimer</h1>
-</center>
-
-<p>
-Copyright 1996 by West Consulting BV.<BR>
-Copyright 1997 by Westhawk Ltd.
-(Author: Birgit Arkesteijn, <a href="mailto:birgit at westhawk.nl">birgit at westhawk.nl</a>).<BR>
-Original at: <a
-href="http://www.westhawk.co.uk/software/tablelayout.zip">http://www.westhawk.co.uk/software/tablelayout.zip</a><BR>
-</p>
-
-<p>
-You may download and use the TableLayout applet free of charge for any purpose.
-</p>
-<p>
-You may copy and distribute the TableLayout distribution, provided you
-include all the files that are in the TableLayout distribution. You may
-only charge a fee for the physical act of transferring a copy. You
-may not sublicense or sell any part of the TableLayout distribution for
-a profit. Contact the author if you want to sublicense or sell it.
-</p>
-<p>
-BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-</p>
-<p>
-The TableLayout Manager was initially implemented in C as the XmpTable widget,
-part of the <a href="ftp://ftp.x.org/contrib/devel_tools/Wcl-2.7.tar.Z">Widget
-Creation Library (Wcl)</a>, written by
-<a href="mailto:David.E.Smyth at jpl.nasa.gov">David E. Smyth</a>.
-</p>
-
-<p>
-[The <a href="doc/packages.html">documentation</a>]
-</p>
-
-<hr>
-<!-- $Date: 2007-06-05 23:44:14 +0200 (Tue, 05 Jun 2007) $, $Revision: 11550 $ -->
-<address>
-Birgit Arkesteijn
-<br>
--- <a href="http://www.westhawk.nl/">Westhawk Ltd</a><br>
--- <a href="mailto:birgit at westhawk.nl">birgit at westhawk.nl</a><br>
-</address>
-
-</body>
-</html>
diff --git a/src/main/java/tablelayout/TableCol.java b/src/main/java/tablelayout/TableCol.java
deleted file mode 100644
index a3e722f..0000000
--- a/src/main/java/tablelayout/TableCol.java
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * NAME
- * $RCSfile$ -
- * DESCRIPTION
- * [given below in javadoc format]
- * DELTA
- * $Revision: 11553 $
- * CREATED
- * $Date: 2007-06-06 00:06:23 +0200 (Wed, 06 Jun 2007) $ by birgit
- * COPYRIGHT
- * West Consulting bv
- * TO DO
- *
- */
-
-package tablelayout;
-
-/**
- * Controls the colums of the table
- *
- * @see tablelayout.TableLayout
- * @author Birgit Arkesteijn
- * @version $Revision: 11553 $ $Date: 2007-06-06 00:06:23 +0200 (Wed, 06 Jun 2007) $
- */
-
-public class TableCol extends TableVec
-{
- private static final String version_id =
- "@(#)$Id: TableCol.java 11553 2007-06-05 22:06:23Z duns $ Copyright West Consulting bv";
-
- /**
- * @param tw the corresponding TableLayout manager
- */
-
- public TableCol (TableLayout tw)
- {
- TableLoc loc;
- int index;
-
- parent = tw;
-
- loc = parent.layout;
- if ((TableLoc)null == loc)
- return;
-
- size = loc.numCols();
-
- if (0 == size)
- return;
-
- vec = new TableVecRec [size];
- for (index=0; index < size; index++)
- {
- vec[index] = new TableVecRec();
- }
-
- minimize();
- }
-
-
-// Minimize Column Widths
-//==========================================
-// Change the vector to be its minimum size in the direction indicated.
-// If TBL_VEC_MINIMIZE (i.e., W) then the widget is kept to its
-// original size.
-// TBL_VEC_LOCK (i.e., w) is not checked, because such widgets DO
-// grow to the minimum size of the column.
-//
- /**
- * Changes the column to its minimum size. This method is called every time
- * the layout changes, before the container is laid out
- */
-
- public void minimize()
- {
- int i;
- boolean minimize, dontStretch;
- int first_slot, last_slot, slot;
- int index, loc_sz;
-
- TableLoc loc;
- TableLocRec rec;
-
- // Determine which slots need to be minimized
- loc = parent.layout;
- loc_sz = loc.size();
- for (index=0; index < loc_sz; index++)
- {
- rec = loc.recElementAt(index);
-
- minimize = rec.options.W;
- dontStretch = rec.options.w;
- first_slot = rec.col;
- last_slot = rec.col + rec.col_span;
-
- if (minimize)
- for (slot = first_slot; slot < last_slot; slot++)
- vec[slot].options |= TBL_VEC_MINIMIZE;
-
- if (dontStretch)
- for (slot = first_slot; slot < last_slot; slot++)
- vec[slot].options |= TBL_VEC_LOCK;
- }
-
- // Sort layout (in-place) by the number of columns each component
- // spans so we first compute sizes of individual columns, then
- // compute the spanned columns.
- //
- loc.qsort(0, (loc_sz-1), true);
-
- // Reset all width|heights to zero, then expand to fit
- for (i=0; i < size; i++)
- {
- vec[i].value = 0;
- }
-
- for (index=0; index < loc_sz; index++)
- {
- int pref;
- rec = loc.recElementAt(index);
-
- // Check for simple case (span of 1), where col just becomes
- // large enough for largest component in that col.
-
- if (rec.col_span == 1)
- {
- pref = rec.preferredWidth();
-
- if (pref > vec[rec.col].value)
- vec[rec.col].value = pref;
- }
- else
- {
- // Spans multiple columns. We have already set each
- // column to the individual size requirements, now we can
- // see which spanned columns need to be stretched. The
- // span width includes inter-column spacing.
-
- int to_stretch, span_size, stop_before;
- int can_stretch = 0;
-
- span_size = parent.col_spacing * (rec.col_span-1);
- first_slot = rec.col;
- stop_before = rec.col + rec.col_span;
-
- for (slot = first_slot; slot < stop_before; slot++)
- {
- if (0 == (vec[slot].options & TBL_VEC_LOCK))
- can_stretch++;
- span_size += vec[slot].value;
- }
-
- // If none of the slots can stretch, then we still must force
- // them all to stretch at least to the orig_size of this widget.
-
- if (0 == can_stretch)
- {
- to_stretch = rec.col_span;
- pref = rec.orig_width;
- }
- else
- {
- to_stretch = can_stretch;
- pref = rec.preferredWidth();
- }
-
- if (span_size < pref)
- {
- // Increase size of some or all slots: if nothing
- // can stretch, expand every slot, else expand only
- // those which are not locked small.
-
- int excess = pref - span_size;
- int amt = excess / to_stretch;
- int truncated = excess - amt*to_stretch;
-
- for (slot = first_slot; slot < stop_before; slot++)
- {
- if (0 == can_stretch ||
- 0 == (vec[slot].options & TBL_VEC_LOCK))
- {
- if (truncated!=0)
- {
- vec[slot].value += amt + 1;
- --truncated;
- }
- else
- vec[slot].value += amt;
- }
- }
- }
- }
- }
-
- // The vector is minimized: set pref_value from value
- for (i=0; i < size; i++)
- vec[i].pref_value = vec[i].value;
- }
-
- /**
- * Returns the total (minimum) size of the column
- *
- * @see #layoutSize
- */
-
- public int totalSize()
- {
- return layoutSize(DO_ACTUAL);
- }
-
- /**
- * Returns the preferred size of the column.
- *
- * @see #layoutSize
- */
-
- public int getPreferredSize()
- {
- return layoutSize(DO_PREFERRED);
- }
-
- /**
- * Calculates the size of the layout
- *
- * @param do_actual actual size or the preferred size
- */
- public int layoutSize(boolean do_actual)
- {
- int slot, space;
- int laysize = 0;
-
- space = parent.col_spacing;
- laysize += 2*parent.margin_width;
-
- if (do_actual)
- {
- laysize -= space;
- for (slot = 0; slot < size; slot++)
- laysize += vec[slot].value + space;
- }
- else
- {
- laysize -= space;
- for (slot = 0; slot < size; slot++)
- laysize += vec[slot].pref_value + space;
- }
-
- if (laysize > 0)
- return laysize;
- else
- return 1; // minimum laysize
- }
-
- /**
- * Returns the String representation
- */
-
- public String toString()
- {
- String st = new String (
- "TableCol [" + super.toString() + " ] ");
- return (st);
- }
-}
diff --git a/src/main/java/tablelayout/TableLayout.java b/src/main/java/tablelayout/TableLayout.java
deleted file mode 100644
index b7802e0..0000000
--- a/src/main/java/tablelayout/TableLayout.java
+++ /dev/null
@@ -1,597 +0,0 @@
-/*
- * NAME
- * $RCSfile$ -
- * DESCRIPTION
- * [given below in javadoc format]
- * DELTA
- * $Revision: 11553 $
- * CREATED
- * $Date: 2007-06-06 00:06:23 +0200 (Wed, 06 Jun 2007) $ by birgit
- * COPYRIGHT
- * West Consulting bv
- * TO DO
- *
- */
-
-package tablelayout;
-import java.awt.Component;
-import java.awt.Container;
-import java.awt.Dimension;
-import java.awt.Insets;
-import java.awt.LayoutManager;
-import java.awt.Point;
-import java.util.Vector;
-
-// Edit History
-//
-// 25Oct92 david Geometry management re-work
-// 01Feb92 david Re-Implementation
-
-
-/**
- * TableLayout is a layout manager which allows components to be
- * arranged
- * in a tabular form. The TableLayout component has a layout
- * resource which is used to specify the column and row position of each
- * component. Components can span rows and/or columns. Layout options
- * are available to control the initial sizes, justification, and dynamic
- * resizing
- *
- * @author Birgit Arkesteijn
- * @version $Revision: 11553 $ $Date: 2007-06-06 00:06:23 +0200 (Wed, 06 Jun 2007) $
- */
-
-public class TableLayout extends Object implements LayoutManager
-{
- private static final String version_id =
- "@(#)$Id: TableLayout.java 11553 2007-06-05 22:06:23Z duns $ Copyright West Consulting bv";
-
- boolean force_shrink; // Shrink smaller than pref'd
- int col_spacing; // Space between columns
- int row_spacing; // Space between rows
- TableLoc layout; // Layout spec
-
- // Lists of lists of components whose preferred dimensions
- // should be considered to be the maximum of any individual named on the
- // lists.
-
- // Vector of Vector of Component
- Vector same_width; // kids with same width
- Vector same_height; // kids with same height
- int margin_width;
- int margin_height;
-
- // internally computed members
- TableCol cols; // Widths and opts of each col
- TableRow rows; // Heights and opts of each row
-
- /**
- *
- */
-
- public TableLayout()
- {
- layout = new TableLoc();
-
- force_shrink = true;
- col_spacing = 1;
- row_spacing = 1;
- same_width = new Vector();
- same_height = new Vector();
- margin_width = 0;
- margin_height = 0;
- cols = (TableCol)null;
- rows = (TableRow)null;
- }
-
- /**
- * Adds the specified component with the layout string to the layout
- *
- * @param layout represents the wanted layout of the component
- * @param comp the component to be added
- * @see tablelayout.TableLocRec
- */
-
- public void addLayoutComponent(String name, Component comp)
- {
- try
- {
- TableLocRec rec = new TableLocRec(name);
- layout.addElement(rec, comp);
- }
- catch(Exception e)
- {
- System.out.println("TableLayout: Syntax error in component: "
- + name);
- return;
- }
- }
-
- /**
- * Removes the specified component from the layout
- *
- * @param comp the component to be removed
- */
-
- public void removeLayoutComponent(Component comp)
- {
- layout.removeElement(comp);
- }
-
- /**
- * Calculates the preferred size dimensions for the specified panel,
- * given the components in the specified target container
- *
- * @param target the component to be laid out
- */
-
- public Dimension preferredLayoutSize(Container target)
- {
- int nmembers = target.getComponentCount();
- for (int i=0; i<nmembers; i++)
- {
- Component current = target.getComponent(i);
- if (!current.isVisible()) continue;
-
- TableLocRec rec = layout.element(current);
- if (rec == null) continue;
-
- rec.orig_width = current.getPreferredSize().width;
- rec.orig_height = current.getPreferredSize().height;
- rec.same_width = 0;
- rec.same_height = 0;
-
- }
- considerSameWidth();
- considerSameHeight();
-
- cols = new TableCol(this);
- rows = new TableRow(this);
-
- int width = cols.getPreferredSize();
- int height = rows.getPreferredSize();
-
- // Is it the layout managers job to allow for the insets?
-
- Insets insets = target.getInsets();
- width += insets.left + insets.right;
- height += insets.top + insets.bottom;
-
- return new Dimension (width, height);
- }
-
- /**
- * Calculates the minimum size dimensions for the specified panel,
- * given the components in the specified target container
- *
- * @param target the component to be laid out
- */
-
- public Dimension minimumLayoutSize(Container target)
- {
- int nmembers = target.getComponentCount();
- for (int i=0; i<nmembers; i++)
- {
- Component current = target.getComponent(i);
- if (!current.isVisible()) continue;
-
- TableLocRec rec = layout.element(current);
- if (rec == null) continue;
-
- rec.orig_width = current.getPreferredSize().width;
- rec.orig_height = current.getPreferredSize().height;
- rec.same_width = 0;
- rec.same_height = 0;
- }
- considerSameWidth();
- considerSameHeight();
-
- cols = new TableCol(this);
- rows = new TableRow(this);
-
- int width = cols.totalSize ();
- int height = rows.totalSize ();
-
- return new Dimension (width, height);
- }
-
- /**
- * Lays out the container in the specified panel
- *
- * @param target the component to be laid out
- */
-
- public void layoutContainer(Container target)
- {
- Dimension dim = target.getSize();
- Insets insets = target.getInsets();
-
- int nmembers = target.getComponentCount();
- for (int i=0; i<nmembers; i++)
- {
- Component current = target.getComponent(i);
- if (!current.isVisible()) continue;
-
- TableLocRec rec = layout.element(current);
- if (rec == null) continue;
-
- current.doLayout();
-
- rec.orig_width = current.getPreferredSize().width;
- rec.orig_height = current.getPreferredSize().height;
- rec.same_width = 0;
- rec.same_height = 0;
- }
- considerSameWidth();
- considerSameHeight();
-
- cols = new TableCol(this);
- rows = new TableRow(this);
-
- cols.minimize();
- rows.minimize();
-
- tableMakeColsFitWidth(dim.width - insets.left - insets.right);
- tableMakeRowsFitHeight(dim.height - insets.top - insets.bottom);
-
- tableSetGeometryOfChildren(insets);
- }
-
- /**
- * This resource is used to specify the names of components
- * which will be constrained to remain the same width as
- * the table shrinks and grows
- *
- * @param v the vector of component with the same width
- */
-
- public void sameWidth(Vector v)
- {
- same_width.addElement(v);
- }
-
- /**
- * This resource is used to specify the names of components
- * which will be constrained to remain the same heigth as
- * the table shrinks and grows
- *
- * @param v the vector of component with the same heigth
- */
-
- public void sameHeight(Vector v)
- {
- same_height.addElement(v);
- }
-
- /**
- * The minimum spacing between the left and right edges of the
- * components in the Container
- *
- * @param i the spacing
- */
-
- public void marginWidth(int i)
- {
- margin_width = i;
- }
-
- /**
- * The minimum spacing between the top and bottom edges of the
- * components in the Container
- *
- * @param i the spacing
- */
-
- public void marginHeight(int i)
- {
- margin_height = i;
- }
-
- /**
- * Specifies if components should be made smaller than their "preferred"
- * sizes.
- * The TableLayout component tries to respect the preferred geometries of
- * its components.
- *
- * Components which are locked using options including any of
- * "whWH" will continue to be excluded from
- * stretching, but others will be
- * stretched and then can be shrunk back to their initial preferred sizes
- * from the time they were last managed.
- * When the table is shrunk further, all
- * components are shrunk an equal number of pixels until they are of size 1
- * (the smallest legal size of a Components).
- *
- * By default, this resource is <em>true</em>.
- * @param force boolean to indicate shrink should be forced
- * @see tablelayout.TableOpts
- */
-
- public void forceShrink(boolean force)
- {
- force_shrink = force;
- }
-
- /**
- * Specifies the number of pixels between columns
- *
- * @param sp the spacing between columns
- */
-
- public void columnSpacing(int sp)
- {
- col_spacing = sp;
- }
-
- /**
- * Specifies the number of pixels between rows
- *
- * @param sp the spacing between rows
- */
-
- public void rowSpacing(int sp)
- {
- row_spacing = sp;
- }
-
-
- private void considerSameWidth()
- {
- int nlist = same_width.size();
- for (int ind1=0; ind1<nlist; ind1++)
- {
- Vector compv = (Vector) same_width.elementAt(ind1);
- int max=0;
-
- // find the maximum width
- int ncomp = compv.size();
- for (int ind2=0; ind2<ncomp; ind2++)
- {
- Component comp = (Component) compv.elementAt(ind2);
-
- TableLocRec rec = layout.element(comp);
- if (rec == null)
- break;
-
- if (rec.orig_width > max)
- max = rec.orig_width;
- }
-
- // set the maximum width
- for (int ind2=0; ind2<ncomp; ind2++)
- {
- Component comp = (Component) compv.elementAt(ind2);
-
- TableLocRec rec = layout.element(comp);
- if (rec == null)
- break;
-
- rec.same_width = max;
- }
- }
- }
-
- private void considerSameHeight()
- {
- int nlist = same_height.size();
- for (int ind1=0; ind1<nlist; ind1++)
- {
- Vector compv = (Vector) same_height.elementAt(ind1);
- int max=0;
-
- // find the maximum height
- int ncomp = compv.size();
- for (int ind2=0; ind2<ncomp; ind2++)
- {
- Component comp = (Component) compv.elementAt(ind2);
-
- TableLocRec rec = layout.element(comp);
- if (rec == null)
- break;
-
- if (rec.orig_height > max)
- max = rec.orig_height;
- }
-
- // find the maximum height
- for (int ind2=0; ind2<ncomp; ind2++)
- {
- Component comp = (Component) compv.elementAt(ind2);
-
- TableLocRec rec = layout.element(comp);
- if (rec == null)
- break;
-
- rec.same_height = max;
- }
- }
- }
-
- private void tableMakeColsFitWidth(int width)
- {
- int change, current, prefer;
-
- current = cols.totalSize ();
- prefer = cols.getPreferredSize ();
-
- if (width < prefer && force_shrink == false)
- {
- // Smallest size is preferred size. Excess clipped.
- change = prefer - current;
- }
- else
- {
- change = width - current;
- }
-
- if (change != 0)
- cols.adjust (change);
- }
-
- private void tableMakeRowsFitHeight(int height)
- {
- int change, current, prefer;
-
- current = rows.totalSize ();
- prefer = rows.getPreferredSize ();
-
- if (height < prefer && force_shrink == false)
- {
- // Smallest size is preferred size. Excess clipped.
- change = prefer - current;
- }
- else
- {
- change = height - current;
- }
-
- if (change != 0)
- rows.adjust (change);
- }
-
-
- private void tableSetGeometryOfChildren (Insets insets)
- {
- TableLocRec rec;
- Component comp;
- int sz, index;
-
- if (layout == (TableLoc)null
- || cols == (TableCol)null
- || rows == (TableRow)null)
- return;
-
- cols.computeOffsets(insets.left, col_spacing);
- rows.computeOffsets(insets.top, row_spacing);
-
- sz = layout.size();
- for (index=0; index < sz; index++)
- {
- rec = layout.recElementAt(index);
- comp = layout.compElementAt(index);
-
- TableComputeChildPosition(rec, comp);
- }
- }
-
- private void TableComputeChildPosition(TableLocRec rec, Component comp)
- {
- int cell_w, cell_h;
- int cell_x, x;
- int cell_y, y;
- int width, prefer, height;
- int i, pad;
-
- // cell width may well span cols and spacing
-
- pad = col_spacing;
- cell_w = -pad;
- for (i = 0; i < rec.col_span; i++)
- cell_w += cols.elementAt(rec.col + i).value + pad;
-
- // If size growth is prevented due to (W)
- // then use the lesser of the cell size or the preferred size.
- // Otherwise, use the cell size.
-
- prefer = rec.preferredWidth();
- if (rec.options.W && cell_w > prefer)
- {
- width = prefer;
- }
- else
- {
- width = cell_w;
- }
- // Be certain that the size does not go to zero, or negative!
- if (width <= 0) width = 1;
-
- pad = row_spacing;
- cell_h = -pad;
- for (i = 0; i < rec.row_span; i++)
- cell_h += rows.elementAt(rec.row + i).value + pad;
-
- prefer = rec.preferredHeight();
- if (rec.options.H && cell_h > prefer)
- {
- height = prefer;
- }
- else
- {
- height = cell_h;
- }
- if (height <= 0) height = 1;
-
- cell_x = cols.elementAt(rec.col).offset;
- if (rec.options.l)
- x = cell_x; // left justify in cell
- else if (rec.options.r)
- x = cell_x + cell_w - width; // right justify in cell
- else
- x = cell_x + (cell_w - width)/2; // center in cell
-
- cell_y = rows.elementAt(rec.row).offset;
- if (rec.options.t)
- y = cell_y; // top justify in cell
- else if (rec.options.b)
- y = cell_y + cell_h - height; // bottom justify in cell
- else
- y = cell_y + (cell_h - height)/2; // center in cell
-
-
- comp.setSize(width, height);
- Point p = comp.getLocation();
- if (x != p.x || y != p.y)
- {
- comp.setLocation(x, y);
- }
- }
-
- /**
- * Returns the String representation
- */
-
- public String toString()
- {
- return (
- "TableLayout [" +
- "\nlayout: " + layout.toString() +
- "\ncols: " + cols.toString() +
- "\nrows: " + rows.toString() +
- "\nsame_width: " + same_width.toString() +
- "\nsame_height: " + same_height.toString() +
- "\ncol_spacing: " + col_spacing +
- "\nrow_spacing: " + row_spacing +
- "\nforce_shrink: " + force_shrink +
- "\nmargin_width: " + margin_width +
- "\nmargin_height: " + margin_height +
- " ]");
- }
-
- /**
- * Creates a clone of the object. A new instance is allocated and all
- * the variables of the class are cloned
- */
-
- public Object clone()
- {
- TableLayout elem = new TableLayout();
-
- elem.force_shrink = force_shrink;
- elem.col_spacing = col_spacing;
- elem.row_spacing = row_spacing;
- elem.layout = (TableLoc) layout.clone();
-
- elem.same_width = (Vector) same_width.clone();
- elem.same_height = (Vector) same_height.clone();
- elem.margin_width = margin_width;
- elem.margin_height = margin_height;
-
- elem.considerSameWidth();
- elem.considerSameHeight();
-
- elem.cols = new TableCol(this);
- elem.rows = new TableRow(this);
-
- return ((Object) elem);
- }
-}
diff --git a/src/main/java/tablelayout/TableLoc.java b/src/main/java/tablelayout/TableLoc.java
deleted file mode 100644
index 99e2988..0000000
--- a/src/main/java/tablelayout/TableLoc.java
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- * NAME
- * $RCSfile$ -
- * DESCRIPTION
- * [given below in javadoc format]
- * DELTA
- * $Revision: 11553 $
- * CREATED
- * $Date: 2007-06-06 00:06:23 +0200 (Wed, 06 Jun 2007) $ by birgit
- * COPYRIGHT
- * West Consulting bv
- * TO DO
- *
- */
-
-package tablelayout;
-import java.awt.Component;
-import java.util.Vector;
-
-
-// TableLoc methods
-//====================
-// The TableLayout Manager keeps its layout as a TableLoc, which are
-// vectors of TableLocRecs.
-//
-// Each TableLocRec defines the component's location information (the
-// row, col, spans, and layout options like justification and sizing controls).
-// The layout describes where components may be placed if and when they
-// become layout-ed.
-//
-// The layout is created from a string by the TableLocRec constructor.
-
-// Allocate, Grow, and Free Arrays of TableLocRec's
-//====================================================
-//
-
-/**
- * The TableLayout Manager keeps its layout
- * description as a TableLoc, which contains
- * a vector of TableLocRec and of the
- * components.
- *
- * Each TableLocRec defines the component's location information (the
- * row, col, spans, and layout options like justification and sizing
- * controls).
- * The layout describes where components may be placed if and when they
- * become layout-ed.
- *
- * The layout is created from a string by the TableLocRec constructor.
- *
- * @see tablelayout.TableLayout
- * @see tablelayout.TableLocRec
- * @author Birgit Arkesteijn
- * @version $Revision: 11553 $ $Date: 2007-06-06 00:06:23 +0200 (Wed, 06 Jun 2007) $
- */
-
-public class TableLoc extends Object
-{
- private static final String version_id =
- "@(#)$Id: TableLoc.java 11553 2007-06-05 22:06:23Z duns $ Copyright West Consulting bv";
-
- Vector compinfo;
- Vector recinfo;
-
- static final String CHAR_SEMI = ";";
- static final String CHAR_BLANC = " ";
- static final String CHAR_ALL = CHAR_SEMI + CHAR_BLANC;
-
- static final String COMPONENT_REC = "rec";
- static final String COMPONENT_NEXT = "next";
- static final String COMPONENT_PREV = "prev";
-
- /**
- *
- */
-
- public TableLoc()
- {
- compinfo = new Vector();
- recinfo = new Vector();
- }
-
- /**
- * Adds a component with its layout
- *
- * @param rec the layout information of the component
- * @param comp the component
- */
-
- public void addElement (TableLocRec rec, Component comp)
- {
- compinfo.addElement((Object)comp);
- recinfo.addElement((Object)rec);
- }
-
- /**
- * Adds a TableLoc vector
- *
- * @param loc the TableLoc vector to add
- */
-
- public void addElement (TableLoc loc)
- {
- int index, sz;
-
- sz = loc.size();
- for (index=0; index<sz; index++)
- {
- compinfo.addElement(loc.compinfo.elementAt(index));
- recinfo.addElement(loc.recinfo.elementAt(index));
- }
- }
-
- /**
- * Removes the information about a component
- *
- * @param comp the component
- */
-
- public void removeElement(Component comp)
- {
- int index;
-
- if ((index = compinfo.indexOf(comp)) > -1)
- {
- compinfo.removeElementAt(index);
- recinfo.removeElementAt(index);
- }
- }
-
- /**
- * Returns the number of components in the layout
- */
-
- public int size()
- {
- return compinfo.size();
- }
-
-
-// Find things in TableLocs
-//============================
-// Linear search of TableLoc array looking for various parameters
-//
-
- /**
- * Returns the TableLocRec layout information on a given position
- *
- * @param index the index of the information
- */
-
- public TableLocRec recElementAt(int index)
- {
- return ((TableLocRec)recinfo.elementAt(index));
- }
-
- /**
- * Returns the component on a given position
- *
- * @param index the index of the information
- */
-
- public Component compElementAt(int index)
- {
- return ((Component)compinfo.elementAt(index));
- }
-
- /**
- * Returns the TableLocRec layout information of a given component
- *
- * @param w the component
- */
-
- public TableLocRec element(Component w)
- {
- int index;
-
- if ((index = compinfo.indexOf(w)) > -1)
- {
- return ((TableLocRec)recinfo.elementAt(index));
- }
- return ((TableLocRec)null);
- }
-
- /**
- * Returns the number of columns of the layout
- */
-
- public int numCols()
- {
- int index, sz;
- TableLocRec rec = null;
- int cols = 0;
-
- index = 0;
- sz = compinfo.size();
- while (index < sz)
- {
- rec = (TableLocRec)recinfo.elementAt(index);
- if (cols < (rec.col + rec.col_span))
- cols = rec.col + rec.col_span;
- index ++;
- }
- return cols;
- }
-
- /**
- * Returns the number of rows of the layout
- */
-
- public int numRows()
- {
- int index, sz;
- TableLocRec rec = null;
- int rows = 0;
-
- index = 0;
- sz = compinfo.size();
- while (index < sz)
- {
- rec = (TableLocRec)recinfo.elementAt(index);
- if (rows < (rec.row + rec.row_span))
- rows = rec.row + rec.row_span;
- index ++;
- }
- return rows;
- }
-
-
- // Definitly ported from "C". Java does not allow function pointers to pass
-
- /**
- * Sorts the colums of row to their position
- *
- * @param left left element
- * @param right right element
- * @param do_col are these columns?
- */
- public void qsort(int left, int right, boolean do_col)
- {
- int i, last;
-
- if (left >= right)
- return;
- swap (left, (left+right)/2);
- last = left;
-
- for (i=left+1; i<=right; i++)
- {
- if (do_col)
- {
- if (TableLocRec.compareColSpan((TableLocRec)recinfo.elementAt(i),
- (TableLocRec)recinfo.elementAt(left)) < 0)
- swap (last, i);
- }
- else
- {
- if (TableLocRec.compareRowSpan((TableLocRec)recinfo.elementAt(i),
- (TableLocRec)recinfo.elementAt(left)) < 0)
- swap (last, i);
- }
- last++;
- }
- swap(left, last);
- qsort(left, last-1, do_col);
- qsort(last+1, right, do_col);
- }
-
- /**
- * Swap two cells
- *
- * @param one cell no. 1
- * @param two cell no. 2
- */
-
- public void swap(int one, int two)
- {
- TableLocRec trec = (TableLocRec)recinfo.elementAt(one);
- TableLocRec rec1 = (TableLocRec)recinfo.elementAt(one);
- TableLocRec rec2 = (TableLocRec)recinfo.elementAt(two);
-
- trec = rec2;
- rec2 = rec1;
- rec1 = trec;
-
- Component tcom = (Component)compinfo.elementAt(one);
- Component com1 = (Component)compinfo.elementAt(one);
- Component com2 = (Component)compinfo.elementAt(two);
-
- tcom = com2;
- com2 = com1;
- com1 = tcom;
- }
-
- /**
- * Creates a clone of the object. A new instance is allocated and all
- * the variables of the class are cloned
- */
-
- public Object clone()
- {
- TableLoc elem = new TableLoc();
- elem.compinfo = (Vector) compinfo.clone();
- elem.recinfo = (Vector) recinfo.clone();
- return ((Object) elem);
- }
-
- /**
- * Returns the String representation
- */
-
- public String toString()
- {
- return (
- "TableLoc [" +
- "\ncompinfo " + compinfo.toString() +
- "\nrecinfo " + recinfo.toString() +
- "]");
- }
-
-}
diff --git a/src/main/java/tablelayout/TableLocRec.java b/src/main/java/tablelayout/TableLocRec.java
deleted file mode 100644
index 3e939c0..0000000
--- a/src/main/java/tablelayout/TableLocRec.java
+++ /dev/null
@@ -1,343 +0,0 @@
-/*
- * NAME
- * $RCSfile$ -
- * DESCRIPTION
- * [given below in javadoc format]
- * DELTA
- * $Revision: 11553 $
- * CREATED
- * $Date: 2007-06-06 00:06:23 +0200 (Wed, 06 Jun 2007) $ by birgit
- * COPYRIGHT
- * West Consulting bv
- * TO DO
- *
- */
-
-package tablelayout;
-import java.util.StringTokenizer;
-
-
-// Parse Layout String
-//=======================
-// Parse a layout string, allocating and setting the values.
-//
-// A layout is a string of a location specification.
-// Each location specification has the form:
-//
-// column row col_span row_span opt_list
-//
-// where the meaning of each field is:
-//
-// column Integer >= 0 descibing column in array
-// row Row >= 0 describing row in array
-//
-// optional:
-// col_span Integer >= 1 describing horizontal widget span
-// row_span Integer >= 1 describing vertical widget span
-// opt_list Series of characters each representing an option:
-// l: TBL_LEFT
-// r: TBL_RIGHT
-// t: TBL_TOP
-// b: TBL_BOTTOM
-// w: TBL_LK_WIDTH
-// h: TBL_LK_HEIGHT
-// W: TBL_SM_WIDTH
-// H: TBL_SM_HEIGHT
-//
-// The options are interpreted in the TableOpts() method.
-//
-
-
-/**
- * This class parses the string which specifies the layout for a component.
- *
- * The layout string specifies the column, row, column span, row span,
- * and options for each component. The options field is optional.
- * The options are parsed by the TableOpts
- * class.
- *
- * Components which are not named in the layout specification are
- * positioned
- * in column 0, row 0, with colum and row spans of 1, all the options will
- * be
- * <em>false</em>. If the layout is
- * changed after the TableLocRec is created, then a complete
- * re-layout is performed.
- *
- * Each layout specification is of the form:
- * <pre>
- * name col row [opts]
- * </pre>
- *
- * @see tablelayout.TableLayout
- * @see tablelayout.TableOpts
- * @author Birgit Arkesteijn
- * @version $Revision: 11553 $ $Date: 2007-06-06 00:06:23 +0200 (Wed, 06 Jun 2007) $
- */
-
-public class TableLocRec extends Object
-{
- private static final String version_id =
- "@(#)$Id: TableLocRec.java 11553 2007-06-05 22:06:23Z duns $ Copyright West Consulting bv";
-
- /**
- * Position of column in table (>=0)
- */
- public int col;
-
- /**
- * Position of row in table (>=0)
- */
- public int row;
-
- /**
- * Horizontal widget span (>=1)
- */
- public int col_span;
-
- /**
- * Vertical widget span (>=1)
- */
- public int row_span;
-
- /**
- * Original width of the cell
- */
- public int orig_width;
-
- /**
- * Original heigth of the cell
- */
- public int orig_height;
-
- /**
- * The width of the cell, changed because of sameWidth constraint
- */
- public int same_width;
-
- /**
- * The height of the cell, changed because of sameHeight constraint
- */
- public int same_height;
-
- /**
- * Justify, grow and shrink constraint options
- *
- * @see tablelayout.TableOpts
- */
- public TableOpts options;
-
- static final String CHAR_BLANC = " ";
-
- /**
- *
- */
-
- public TableLocRec()
- {
- col = 0;
- row = 0;
- col_span = 1;
- row_span = 1;
- orig_width = 0;
- orig_height = 0;
- same_width = 0;
- same_height = 0;
- options = new TableOpts();
- }
-
- /**
- * @param layout the string that specifies the layout
- */
-
- public TableLocRec(String layout)
- {
- String next;
- orig_width = 0;
- orig_height = 0;
- same_width = 0;
- same_height = 0;
-
- StringTokenizer st = new StringTokenizer(layout, CHAR_BLANC, false);
-
- next = st.nextToken();
- col = Integer.valueOf(next).intValue();
-
- next = st.nextToken();
- row = Integer.valueOf(next).intValue();
-
- // is there a next token?
- try
- {
- next = st.nextToken();
- }
- catch (Exception e)
- {
- // No next token
- col_span = 1;
- row_span = 1;
- options = new TableOpts ();
- return;
- }
-
- // is the token a number (col_span) or not (option)
- try
- {
- col_span = Integer.valueOf(next).intValue();
- if (col_span < 1) col_span = 1;
- }
- catch (NumberFormatException e)
- {
- col_span = 1;
- row_span = 1;
- options = new TableOpts (next);
- return;
- }
-
- // is there a next token?
- try
- {
- next = st.nextToken();
- }
- catch (Exception e)
- {
- // No next token
- row_span = 1;
- options = new TableOpts ();
- return;
- }
-
- // is the token a number (row_span) or not (option)
- try
- {
- row_span = Integer.valueOf(next).intValue();
- if (row_span < 1) row_span = 1;
- }
- catch (NumberFormatException e)
- {
- row_span = 1;
- options = new TableOpts (next);
- return;
- }
-
- try
- {
- next = st.nextToken();
- options = new TableOpts (next);
- }
- catch (Exception e)
- {
- options = new TableOpts ();
- }
- }
-
- /**
- * Creates a clone of the object. A new instance is allocated and all
- * the variables of the class are cloned
- */
-
- public Object clone()
- {
- TableLocRec elem = new TableLocRec();
- elem.options = options;
- elem.col = col;
- elem.row = row;
- elem.col_span = col_span;
- elem.row_span = row_span;
- elem.orig_width = orig_width;
- elem.orig_height = orig_height;
- elem.same_width = same_width;
- elem.same_height = same_height;
- return ((Object) elem);
- }
-
- /**
- * Returns the String representation
- */
-
- public String toString()
- {
- return (
- "TableLocRec [" +
- "\n\tcol " + col +
- " row " + row +
- " col_span " + col_span +
- " row_span " + row_span +
- "\n\torig_width " + orig_width +
- " orig_height " + orig_height +
- " same_width " + same_width +
- " same_height " + same_height +
- "\n\toptions " + options.toString() +
- "]");
- }
-
-
- // Used by qsort when the layout table is sorted by span
- // before doing distribution of space to rows or columns.
- //
- /**
- * Compaires the span width of two columns, returns the difference in
- * span width
- *
- * @param loc1 the first column
- * @param loc2 the second column
- */
-
- public static int compareColSpan(TableLocRec loc1, TableLocRec loc2)
- {
- if (loc1.col_span == loc2.col_span)
- return loc1.col - loc2.col;
-
- return loc1.col_span - loc2.col_span;
- }
-
- /**
- * Compaires the span height of two rows, returns the difference in
- * span height
- *
- * @param loc1 the first row
- * @param loc2 the second row
- */
-
- public static int compareRowSpan (TableLocRec loc1, TableLocRec loc2)
- {
- if (loc1.row_span == loc2.row_span)
- return loc1.row - loc2.row;
-
- return loc1.row_span - loc2.row_span;
- }
-
- /**
- * Returns the preferred width of the layout component
- */
-
- public int preferredWidth ()
- {
- // First take care of situations where SameSize resources apply
- if (same_width != 0)
- {
- return same_width;
- }
- else
- {
- return orig_width;
- }
- }
-
- /**
- * Returns the preferred heigth of the layout component
- */
-
- public int preferredHeight ()
- {
- if (same_height != 0)
- {
- return same_height;
- }
- else
- {
- return orig_height;
- }
- }
-
-}
diff --git a/src/main/java/tablelayout/TableOpts.java b/src/main/java/tablelayout/TableOpts.java
deleted file mode 100644
index b64847e..0000000
--- a/src/main/java/tablelayout/TableOpts.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * NAME
- * $RCSfile$ -
- * DESCRIPTION
- * [given below in javadoc format]
- * DELTA
- * $Revision: 11550 $
- * CREATED
- * $Date: 2007-06-05 23:44:14 +0200 (Tue, 05 Jun 2007) $ by birgit
- * COPYRIGHT
- * West Consulting bv
- * TO DO
- *
- */
-
-package tablelayout;
-
-// Parse Layout String
-//=======================
-// opt_list: Series of characters each representing an option:
-// l: left justify component in table cell
-// r: right justify component in table cell
-// t: top justify component in table cell
-// b: bottom justify component in table cell
-// w: do not stretch width of column in which component is
-// positioned during resizing. Column width will remain wide enough to
-// contain the widest component in the column
-// h: do not stretch height of row in which component is positioned
-// during resizing. Row height will emain high enough to contain the
-// tallest component in the row
-// W: do not stretch width of component during resizing. The width
-// of the column may grow (unless constrained by w), and the
-// component will be justified according to its layout options
-// H: do not stretch height of component during resizing. The height
-// of the row may grow (unless constrained by h), and the
-// component will be justified according to its layout options
-//
-// The options are interpreted in the constructor.
-//
-
-
-/**
- * This class parses the options string which specifies the layout options
- * for an component.
- *
- * The layout options allow a component to be justified within the table
- * cell, and allow the initial size and dynamic resizing of components to
- * be
- * constrained. Combinations of options can be used: <b>tr</b> means top
- * and right, or north-east justification.
- *
- * Note that the justification does not do anything special with the labels
- * of a
- * Label components: it simply sets the positioning
- * of the entire component within the cell of the <b>TableLayout</b>.
- *
- * If no options are specified for a component, all options will be
- * <em>false</em>.
- *
- *
- * @see tablelayout.TableLayout
- * @author Birgit Arkesteijn
- * @version $Revision: 11550 $ $Date: 2007-06-05 23:44:14 +0200 (Tue, 05 Jun 2007) $
- */
-
-public class TableOpts extends Object
-{
- private static final String version_id =
- "@(#)$Id: TableOpts.java 11550 2007-06-05 21:44:14Z duns $ Copyright West Consulting bv";
-
- /**
- * left justify component in table cell.
- */
- public boolean l;
-
- /**
- * right justify component in table cell.
- */
- public boolean r;
-
- /**
- * top justify component in table cell.
- */
- public boolean t;
-
- /**
- * bottom justify component in table cell.
- */
- public boolean b;
-
- /**
- * do not stretch width of column in which component is
- * positioned during resizing. Column width will remain wide enough to
- * contain the widest component in the column.
- */
- public boolean w;
-
- /**
- * do not stretch height of row in which component is
- * positioned
- * during resizing. Row height will emain high enough to contain the
- * tallest component in the row.
- */
- public boolean h;
-
- /**
- * do not stretch width of component during resizing. The
- * width
- * of the column may grow (unless constrained by <em>w</em>), and the
- * component
- * will be justified according to its layout options.
- */
- public boolean W;
-
- /**
- * do not stretch height of component during resizing. The
- * height
- * of the row may grow (unless constrained by <em>h</em>), and the
- * component
- * will be justified according to its layout options.
- *
- */
- public boolean H;
-
-
- /**
- *
- */
-
- public TableOpts()
- {
- l = false;
- r = false;
- t = false;
- b = false;
- w = false;
- h = false;
- W = false;
- H = false;
- }
-
- /**
- * @param layout the string that specifies the options
- */
-
- public TableOpts(String layout)
- {
- if (layout.indexOf ('l') > -1) l = true;
- else l = false;
- if (layout.indexOf ('r') > -1) r = true;
- else r = false;
- if (layout.indexOf ('t') > -1) t = true;
- else t = false;
- if (layout.indexOf ('b') > -1) b = true;
- else b = false;
- if (layout.indexOf ('w') > -1) w = true;
- else w = false;
- if (layout.indexOf ('h') > -1) h = true;
- else h = false;
- if (layout.indexOf ('W') > -1) W = true;
- else W = false;
- if (layout.indexOf ('H') > -1) H = true;
- else H = false;
- }
-
- /**
- * Creates a clone of the object. A new instance is allocated and all
- * the variables of the class are cloned
- */
-
- public Object clone()
- {
- TableOpts elem = new TableOpts();
- elem.r = r;
- elem.l = l;
- elem.b = b;
- elem.t = t;
- elem.w = w;
- elem.h = h;
- elem.W = W;
- elem.H = H;
- return ((Object) elem);
- }
-
-
- /**
- * Returns the String representation
- */
-
- public String toString()
- {
- return (
- "TableOpts [" +
- " r " + r +
- " l " + l +
- " b " + b +
- " t " + t +
- " w " + w +
- " h " + h +
- " W " + W +
- " H " + H +
- "]");
- }
-
-}
diff --git a/src/main/java/tablelayout/TableRow.java b/src/main/java/tablelayout/TableRow.java
deleted file mode 100644
index 87c5033..0000000
--- a/src/main/java/tablelayout/TableRow.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * NAME
- * $RCSfile$ -
- * DESCRIPTION
- * [given below in javadoc format]
- * DELTA
- * $Revision: 11553 $
- * CREATED
- * $Date: 2007-06-06 00:06:23 +0200 (Wed, 06 Jun 2007) $ by birgit
- * COPYRIGHT
- * West Consulting bv
- * TO DO
- *
- */
-
-package tablelayout;
-
-/**
- * Controls the rows of the table
- *
- * @see tablelayout.TableLayout
- * @author Birgit Arkesteijn
- * @version $Revision: 11553 $ $Date: 2007-06-06 00:06:23 +0200 (Wed, 06 Jun 2007) $
- */
-
-public class TableRow extends TableVec
-{
- private static final String version_id =
- "@(#)$Id: TableRow.java 11553 2007-06-05 22:06:23Z duns $ Copyright West Consulting bv";
-
- /**
- * @param tw the corresponding TableLayout manager
- */
-
- public TableRow (TableLayout tw)
- {
- TableLoc loc;
- int index;
-
- parent = tw;
- loc = parent.layout;
- if ((TableLoc)null == loc)
- return;
-
- size = loc.numRows();
-
- if (0 == size)
- return;
-
- vec = new TableVecRec [size];
- for (index=0; index < size; index++)
- {
- vec[index] = new TableVecRec();
- }
-
- minimize();
- }
-
-
-// Minimize Row Heights
-//==========================================
-// Change the vector to be its minimum size in the direction indicated.
-// If TBL_VEC_MINIMIZE (i.e., H) then the widget is kept to its
-// original size.
-// TBL_VEC_LOCK (i.e., h) is not checked, because such widgets DO
-// grow to the minimum size of the row.
-//
- /**
- * Changes the row to its minimum size. This method is called every time
- * the layout changes, before the container is laid out
- */
-
- public void minimize()
- {
- int i;
- boolean minimize, dontStretch;
- int first_slot, last_slot, slot;
- int index, loc_sz;
-
- TableLoc loc;
- TableLocRec rec;
-
- // Determine which slots need to be minimized
- loc = parent.layout;
- loc_sz = loc.size();
- for (index=0; index < loc_sz; index++)
- {
- rec = loc.recElementAt(index);
-
- minimize = rec.options.H;
- dontStretch = rec.options.h;
- first_slot = rec.row;
- last_slot = rec.row + rec.row_span;
-
- if (minimize)
- for (slot = first_slot; slot < last_slot; slot++)
- vec[slot].options |= TBL_VEC_MINIMIZE;
-
- if (dontStretch)
- for (slot = first_slot; slot < last_slot; slot++)
- vec[slot].options |= TBL_VEC_LOCK;
- }
-
- // Sort layout (in-place) by the number of rows each component
- // spans so we first compute sizes of individual rows, then
- // compute the spanned rows.
- //
- loc.qsort(0, (loc_sz-1), false);
-
- // Reset all width|heights to zero, then expand to fit
- for (i=0; i < size; i++)
- {
- vec[i].value = 0;
- }
-
- for (index=0; index < loc_sz; index++)
- {
- int pref;
- rec = loc.recElementAt(index);
-
- // Check for simple case (span of 1), where row just becomes
- // large enough for largest component in that row.
-
- if (rec.row_span == 1)
- {
- pref = rec.preferredHeight();
-
- if (pref > vec[rec.row].value)
- vec[rec.row].value = pref;
- }
- else
- {
- // Spans multiple rows. We have already set each
- // row to the individual size requirements, now we can
- // see which spanned rows need to be stretched. The
- // span width includes inter-row spacing.
-
- int to_stretch, span_size, stop_before;
- int can_stretch = 0;
-
- span_size = parent.row_spacing * (rec.row_span-1);
- first_slot = rec.row;
- stop_before = rec.row + rec.row_span;
-
- for (slot = first_slot; slot < stop_before; slot++)
- {
- if (0 == (vec[slot].options & TBL_VEC_LOCK))
- can_stretch++;
- span_size += vec[slot].value;
- }
-
- // If none of the slots can stretch, then we still must force
- // them all to stretch at least to the orig_size of this widget.
-
- if (0 == can_stretch)
- {
- to_stretch = rec.row_span;
- pref = rec.orig_height;
- }
- else
- {
- to_stretch = can_stretch;
- pref = rec.preferredHeight();
- }
-
- if (span_size < pref)
- {
- // Increase size of some or all slots: if nothing
- // can stretch, expand every slot, else expand only
- // those which are not locked small.
-
- int excess = pref - span_size;
- int amt = excess / to_stretch;
- int truncated = excess - amt*to_stretch;
-
- for (slot = first_slot; slot < stop_before; slot++)
- {
- if (0 == can_stretch ||
- 0 == (vec[slot].options & TBL_VEC_LOCK))
- {
- if (truncated!=0)
- {
- vec[slot].value += amt + 1;
- --truncated;
- }
- else
- vec[slot].value += amt;
- }
- }
- }
- }
- }
-
- // The vector is minimized: set pref_value from value
- for (i=0; i < size; i++)
- vec[i].pref_value = vec[i].value;
- }
-
- /**
- * Returns the total (minimum) size of the row
- *
- * @see #layoutSize
- */
-
- public int totalSize()
- {
- return layoutSize(DO_ACTUAL);
- }
-
- /**
- * Returns the preferred size of the row.
- *
- * @see #layoutSize
- */
-
- public int getPreferredSize()
- {
- return layoutSize(DO_PREFERRED);
- }
-
- /**
- * Calculates the size of the layout
- *
- * @param do_actual actual size or the preferred size
- */
- public int layoutSize(boolean do_actual)
- {
- int slot, space;
- int laysize = 0;
-
- space = parent.row_spacing;
- laysize += 2*parent.margin_height;
-
- if (do_actual)
- {
- laysize -= space;
- for (slot = 0; slot < size; slot++)
- laysize += vec[slot].value + space;
- }
- else
- {
- laysize -= space;
- for (slot = 0; slot < size; slot++)
- laysize += vec[slot].pref_value + space;
- }
-
- if (laysize > 0)
- return laysize;
- else
- return 1; // minimum laysize
- }
-
- /**
- * Returns the String representation
- */
-
- public String toString()
- {
- String st = new String (
- "TableRow [" + super.toString() + " ] ");
- return (st);
- }
-}
diff --git a/src/main/java/tablelayout/TableVec.java b/src/main/java/tablelayout/TableVec.java
deleted file mode 100644
index 7219c65..0000000
--- a/src/main/java/tablelayout/TableVec.java
+++ /dev/null
@@ -1,449 +0,0 @@
-/*
- * NAME
- * $RCSfile$ -
- * DESCRIPTION
- * [given below in javadoc format]
- * DELTA
- * $Revision: 11553 $
- * CREATED
- * $Date: 2007-06-06 00:06:23 +0200 (Wed, 06 Jun 2007) $ by birgit
- * COPYRIGHT
- * West Consulting bv
- * TO DO
- *
- */
-
-package tablelayout;
-
-
-// TableVector Methods
-//=======================
-// Each TableLayout Manager has two TableVectors:
-// one describes the columns, and the other describes the rows.
-//
-// The TableVector is an abstract class. For the column use TableCol, for the
-// row use TableRow.
-//
-// The table vectors are created based on information in the layout
-// of the Manager, hence they must be created after the layout, and they
-// must be updated when the layout changes. The layout data upon
-// which the vectors depend is: number of cols, number of rows, options (only
-// W and H).
-//
-// This class used to be abstract, but since MSIE could not handle it
-// I removed the "abstract" notation.
-
-/**
- * Each TableLayout Manager has two
- * TableVectors:
- * one describes the columns, and the other describes the rows.
- *
- * The <b>TableVector</b> is an abstract class. For the column use
- * <b>TableCol</b>, for the row use <b>TableRow</b>.
- *
- * The table vector is created, based on information of the
- * layout
- * of the TableLayout Manager, hence they must be created after the
- * layout, and they must be updated when the layout changes.
- *
- * The TableVec is an array of TableVecRec, which
- * contains the size information of each component in a row of column.
- *
- * @see tablelayout.TableVecRec
- * @see tablelayout.TableLoc
- * @see tablelayout.TableCol
- * @see tablelayout.TableRow
- *
- * @see tablelayout.TableLayout
- * @author Birgit Arkesteijn
- * @version $Revision: 11553 $ $Date: 2007-06-06 00:06:23 +0200 (Wed, 06 Jun 2007) $
- */
-
-abstract public class TableVec extends Object
-{
- private static final String version_id =
- "@(#)$Id: TableVec.java 11553 2007-06-05 22:06:23Z duns $ Copyright West Consulting bv";
-
-
-// Table Vector Structs
-//========================
-// A table has two of these vectors: one for columns, and one for rows.
-//
- static final int TBL_VEC_MINIMIZE = 0x01;
- static final int TBL_VEC_LOCK = 0x02;
- static final int TBL_VEC_NOGROW = (TBL_VEC_MINIMIZE | TBL_VEC_LOCK);
-
- static final boolean DO_ACTUAL = true;
- static final boolean DO_PREFERRED = false;
-
- /**
- * Vector with the sizes of the elements (columns or rows)
- */
- public TableVecRec vec[];
-
- /**
- * The layout parent
- */
- public TableLayout parent;
-
- /**
- * Number of elements (columns or rows)
- */
- public int size;
-
- /**
- * Changes the cells to its minimum size.
- */
- abstract public void minimize();
-
- /**
- * Returns the total (minimum) size
- */
- abstract public int totalSize();
-
- /**
- * Returns the preferred size
- */
- abstract public int getPreferredSize();
-
-
- /**
- * Calculates the size of the layout
- */
- abstract public int layoutSize(boolean do_actual);
-
-
- /**
- * Returns the TableVecRec size information on a given position
- *
- * @exception java.lang.ArrayIndexOutOfBoundsException if the index if out of
- * bound
- * @param index the index of the information
- * @see tablelayout.TableVecRec
- */
- public TableVecRec elementAt(int index)
- {
- if (index < 0 || index > size-1)
- {
- throw new ArrayIndexOutOfBoundsException(index);
- }
- else
- return (TableVecRec) vec[index];
- }
-
-
-// Adjust rows or columns
-//==========================
-// When a parent re-sizes a Table, it can make it larger or smaller. The
-// adjustment is distributed as a ratio of the preferred sizes of the
-// col/row, so small ones change slower than larger ones.
-//
-// Nowhere in the logic below is there any mechanism which prevents things
-// from shrinking smaller than the preferred size.
-// There is, however, mechanisms to prevent any col or row from becoming
-// smaller than 1.
-//
-// If resize makes the Table larger than before: First, all col/row
-// smaller that preferred size are stretched up until their preferred
-// size. The rest of the change is distributed evenly to un-locked col/row,
-// but if all are locked, then all are stretched.
-//
-// If the table is being made smaller, then the inverse is applied: all
-// unlocked (or all if all are locked) are made smaller down to their
-// preferred sizes, then all are made smaller by the same amount.
-//
-// Adjustments to the vectors are made on a relative basis. Big slots
-// change more than small slots. Therefore, the adjustment delta is
-// computed for each slot which might change.
-//
-// While adjusting the vectors, there are too things to watch out for: lots of
-// slots to change, yet not much change, integer truncation then leaves the
-// delta zero. In this case we make the delta 1, which means the change gets
-// used up before all the slots are seen. We use the same algorithm for
-// growing and shrinking, so there should be no perceivable problems. The
-// second problem is when the delta would consume too much change, again due
-// to integer truncation. In this case, we must simply make the delta equal
-// to the remaining change.
-//
-// Notice that there are two resize algorithms used: one applies when
-// everything is smaller than preferred, and another applies when everything
-// is bigger.
-// When smaller, everything gets changed relatively. When larger, change
-// is influenced by the table slot being locked (TBL_VEC_LOCK). Slots which
-// are locked are not adjusted unless ALL slots are locked, then all are
-// adjusted relatively.
-//
-
- /**
- * Adjust the row or column after a resize
- *
- * @param change the number of pixel the row or column should grow or
- * shrink
- */
- public void adjust(int change)
- {
- int vec_inx, remaining, amt;
- int total_pref;
- int can_change, can_change_pref;
- int too_small;
- int too_big, too_big_pref;
-
- if (0 == change)
- return;
-
- total_pref = can_change = can_change_pref = 0;
- too_small = too_big = too_big_pref = 0;
-
- for (vec_inx=0; vec_inx < size; vec_inx++)
- {
- // NOTE: total_pref can be zero if all pref_value are 0!
- total_pref += vec[vec_inx].pref_value;
- if (change > 0)
- {
- if (0 == (vec[vec_inx].options & TBL_VEC_LOCK))
- {
- // NOTE: can_change_pref can be zero if all pref_value are 0!
- can_change++;
- can_change_pref += vec[vec_inx].pref_value;
- }
- if (vec[vec_inx].value < vec[vec_inx].pref_value)
- {
- too_small++;
- }
- }
- else
- {
- if (vec[vec_inx].value > vec[vec_inx].pref_value)
- {
- // NOTE: too_big_pref can be zero if all pref_value are 0!
- too_big++;
- too_big_pref += vec[vec_inx].pref_value;
- }
- }
- }
-
- if (change > 0)
- {
- //================= Make columns wider or rows taller ===============
- int still_too_small;
- remaining = change;
- still_too_small = 1;
- while (still_too_small != 0)
- {
- // Expand everything smaller than preferred up to preferred
- still_too_small = 0;
-
- for (vec_inx=0; vec_inx < size; vec_inx++)
- {
- if (vec[vec_inx].value < vec[vec_inx].pref_value)
- {
- // Make this one bigger, up to preferred size
- if (0 == total_pref)
- amt = change / (too_small!=0?too_small:size);
- else
- amt = change * vec[vec_inx].pref_value / total_pref;
- if (0 == amt)
- amt = 1;
- else if (remaining < amt)
- amt = remaining;
-
- if (vec[vec_inx].value + amt < vec[vec_inx].pref_value)
- {
- vec[vec_inx].value += amt;
- ++still_too_small;
- }
- else
- {
- amt = vec[vec_inx].pref_value - vec[vec_inx].value;
- vec[vec_inx].value = vec[vec_inx].pref_value;
- }
- remaining -= amt;
-
- if (remaining <= 0)
- return; // used up all change
- }
- }
-
- change = remaining;
- }
-
- // All are at least preferred size, and there is change remaining.
- // If none of the vector slots can stretch, then we still must
- // force them all to stretch.
-
- if (0 == can_change)
- can_change_pref = total_pref; // maintain relative sizes
-
- while (true) // until remaining goes to zero or negative above
- {
- for (vec_inx = 0; vec_inx < size; vec_inx++)
- {
- if (0 == can_change ||
- 0 == (vec[vec_inx].options & TBL_VEC_LOCK))
- {
- // Add relative amount to all which can change.
- if (0 == can_change_pref)
- amt = change / (can_change!=0?can_change:size);
- else
- amt = change * vec[vec_inx].pref_value/can_change_pref;
- if (0 == amt)
- amt = 1;
- else if (remaining < amt)
- amt = remaining;
-
- vec[vec_inx].value += amt;
- remaining -= amt;
-
- if (remaining <= 0)
- return; // used up all change
- }
- }
-
- // We have gone thru vector, adding space, but due to truncation
- // there may still be more change to distribute.
-
- change = remaining;
- }
- }
- else // (change < 0)
- {
- //================= Make columns narrower or rows shorter ==============
- int still_too_big, num_larger_than_1;
-
- // For conceptual clarity, switch the sign on change
- change = -change;
- remaining = change;
-
- still_too_big = too_big;
- while (still_too_big !=0)
- {
- // Shrink all which are larger than preferred
- still_too_big = 0;
- for (vec_inx = 0; vec_inx < size; vec_inx++)
- {
- if (vec[vec_inx].value > vec[vec_inx].pref_value)
- {
- if (0 == too_big_pref)
- amt = change / (too_big !=0?too_big:size);
- else
- amt = change * vec[vec_inx].pref_value / too_big_pref;
- if (0 == amt)
- amt = 1;
- else if (remaining < amt)
- amt = remaining;
-
- if (vec[vec_inx].value - amt < vec[vec_inx].pref_value)
- {
- amt = vec[vec_inx].value - vec[vec_inx].pref_value;
- vec[vec_inx].value = vec[vec_inx].pref_value;
- }
- else
- {
- vec[vec_inx].value -= amt;
- still_too_big++;
- }
-
- remaining -= amt;
-
- if (remaining <= 0)
- return; // used up all change
- }
- }
-
- // We have made a pass through all slots
- change = remaining;
- }
-
- // Now all stretchable are preferred sizes, or all were already smaller
- // than preferred sizes, yet more change is remaining to be absorbed.
- //
- // Shrink evenly, but since none can become smaller than 1, we may need
- // to make multiple passes over vector until total change is absorbed,
- // or all are of size 1.
-
- num_larger_than_1 = 1;
- while (num_larger_than_1 != 0)
- {
- num_larger_than_1 = 0;
-
- for (vec_inx = 0; vec_inx < size; vec_inx++)
- {
- if (0 == total_pref)
- amt = change / size;
- else
- amt = change * vec[vec_inx].pref_value / total_pref;
- if (0 == amt)
- amt = 1;
- else if (remaining < amt)
- amt = remaining;
-
- if (amt < vec[vec_inx].value)
- {
- vec[vec_inx].value -= amt;
- ++num_larger_than_1;
- }
- else
- {
- amt = vec[vec_inx].value - 1;
- vec[vec_inx].value = 1;
- }
- remaining -= amt;
- if (remaining <= 0)
- return; // used up all change
- }
-
- // We have made a pass through all slots
- change = remaining;
- }
- return; // all are shrunk to absolute minimum size (1)
- }
- } // end of adjust()
-
-
-// Set Upper Left Corner Coordinates of Each Cell
-//==================================================
-// Note that it is not worth doing this until the actual correct size of
-// the rows and columns have been computed.
-//
-
- /**
- * Sets the upper left corner coordinate of each component within the
- * container
- *
- * @param margin the margin of the container
- * @param gap the gap between each component in the container
- */
-
- public void computeOffsets(int margin, int gap)
- {
- int i;
- int offset = margin;
-
- for (i = 0; i < size; i++)
- {
- vec[i].offset = offset;
- offset = offset + vec[i].value + gap;
- }
- }
-
- /**
- * Returns the String representation
- */
- public String toString()
- {
- String st = new String (
- "TableVec [" +
- " size " + size);
-
- for (int i=0; i<size; i++)
- {
- st = st + "\n" + vec[i].toString();
- }
- st = st + " ]";
-
- return (st);
- }
-
-}
-
-
diff --git a/src/main/java/tablelayout/TableVecRec.java b/src/main/java/tablelayout/TableVecRec.java
deleted file mode 100644
index 095acaf..0000000
--- a/src/main/java/tablelayout/TableVecRec.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * NAME
- * $RCSfile$ -
- * DESCRIPTION
- * [given below in javadoc format]
- * DELTA
- * $Revision: 11550 $
- * CREATED
- * $Date: 2007-06-05 23:44:14 +0200 (Tue, 05 Jun 2007) $ by birgit
- * COPYRIGHT
- * West Consulting bv
- * TO DO
- *
- */
-
-package tablelayout;
-
-/**
- * Contains information of the size of one table cell
- *
- * @see tablelayout.TableLayout
- * @author Birgit Arkesteijn
- * @version $Revision: 11550 $ $Date: 2007-06-05 23:44:14 +0200 (Tue, 05 Jun 2007) $
- */
-public class TableVecRec extends Object
-{
- private static final String version_id =
- "@(#)$Id: TableVecRec.java 11550 2007-06-05 21:44:14Z duns $ Copyright West Consulting bv";
-
- /**
- * the preferred value of the cell
- */
- public int pref_value;
-
- /**
- * the upper left corner of the cell
- */
- public int offset;
-
- /**
- * the options that should be applied to the entire column or row
- */
- public int options;
-
- /**
- * the width of column, or the height of the row
- */
- public int value;
-
- /**
- *
- */
-
- public TableVecRec ()
- {
- pref_value = 0;
- offset = 0;
- options = 0;
- value = 0;
- }
-
- /**
- * Returns the String representation
- */
- public String toString()
- {
- return (
- "TableVecRec [" +
- "options " + options +
- " value " + value +
- " pref_value " + pref_value +
- " offset " + offset +
- "]");
- }
-}
hooks/post-receive
--
JAS(2) Plotter
More information about the pkg-java-commits
mailing list