/[classpath]/classpath/java/awt/GridBagLayout.java
ViewVC logotype

Diff of /classpath/java/awt/GridBagLayout.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.15 by mark, Thu Jul 22 19:45:38 2004 UTC revision 1.15.2.1 by gnu_andrew, Mon Jan 10 18:25:46 2005 UTC
# Line 1  Line 1 
1  /* GridBagLayout - Layout manager for components according to GridBagConstraints  /* GridBagLayout - Layout manager for components according to GridBagConstraints
2     Copyright (C) 2002, 2003 Free Software Foundation, Inc.     Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
3    
4  This file is part of GNU Classpath.  This file is part of GNU Classpath.
5    
# Line 46  import java.util.HashMap; Line 46  import java.util.HashMap;
46  /**  /**
47   * @author Michael Koch <konqueror@gmx.de>   * @author Michael Koch <konqueror@gmx.de>
48   * @author Jeroen Frijters <jeroen@frijters.net>   * @author Jeroen Frijters <jeroen@frijters.net>
49     * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
50   */   */
51  public class GridBagLayout  public class GridBagLayout
52      implements Serializable, LayoutManager2      implements Serializable, LayoutManager2
# Line 62  public class GridBagLayout Line 63  public class GridBagLayout
63      // REMAINDER constraints.      // REMAINDER constraints.
64      // Constraints kept in comptable are never modified, and constraints      // Constraints kept in comptable are never modified, and constraints
65      // kept in internalcomptable can be modified internally only.      // kept in internalcomptable can be modified internally only.
66      protected Hashtable comptable;      protected Hashtable<Component,GridBagConstraints> comptable;
67      private Hashtable internalcomptable;      private Hashtable<Component,GridBagConstraints> internalcomptable;
68      protected GridBagLayoutInfo layoutInfo;      protected GridBagLayoutInfo layoutInfo;
69      protected GridBagConstraints defaultConstraints;      protected GridBagConstraints defaultConstraints;
70    
# Line 74  public class GridBagLayout Line 75  public class GridBagLayout
75    
76      public GridBagLayout ()      public GridBagLayout ()
77      {      {
78          this.comptable = new Hashtable();          this.comptable = new Hashtable<Component,GridBagConstraints>();
79          this.internalcomptable = new Hashtable();          this.internalcomptable = new Hashtable<Component,GridBagConstraints>();
80          this.defaultConstraints= new GridBagConstraints();          this.defaultConstraints= new GridBagConstraints();
81      }      }
82    
# Line 466  public class GridBagLayout Line 467  public class GridBagLayout
467    
468        // Guaranteed to contain the last component added to the given row        // Guaranteed to contain the last component added to the given row
469        // or column, whose gridwidth/height is not REMAINDER.        // or column, whose gridwidth/height is not REMAINDER.
470        HashMap lastInRow = new HashMap();        HashMap<Integer,Component> lastInRow = new HashMap<Integer,Component>();
471        HashMap lastInCol = new HashMap();        HashMap<Integer,Component> lastInCol = new HashMap<Integer,Component>();
472    
473        Component[] components = parent.getComponents();        Component[] components = parent.getComponents();
474    
475        // Components sorted by gridwidths/heights,        // Components sorted by gridwidths/heights,
476        // smallest to largest, with REMAINDER and RELATIVE at the end.        // smallest to largest, with REMAINDER and RELATIVE at the end.
477        // These are useful when determining sizes and weights.        // These are useful when determining sizes and weights.
478        ArrayList sortedByWidth = new ArrayList(components.length);        ArrayList<Component> sortedByWidth =
479        ArrayList sortedByHeight = new ArrayList(components.length);          new ArrayList<Component>(components.length);
480          ArrayList<Component> sortedByHeight =
481            new ArrayList<Component>(components.length);
482    
483        // STEP 1: first we figure out how many rows/columns        // STEP 1: first we figure out how many rows/columns
484        for (int i = 0; i < components.length; i++)        for (int i = 0; i < components.length; i++)
# Line 737  public class GridBagLayout Line 740  public class GridBagLayout
740        // STEP 3: Determine sizes and weights for columns.        // STEP 3: Determine sizes and weights for columns.
741        for (int i = 0; i < sortedByWidth.size(); i++)        for (int i = 0; i < sortedByWidth.size(); i++)
742          {          {
743            Component component = (Component) sortedByWidth.get(i);            Component component = sortedByWidth.get(i);
744                                                    
745            // If component is not visible we dont have to care about it.            // If component is not visible we dont have to care about it.
746            if (!component.isVisible())            if (!component.isVisible())
# Line 851  public class GridBagLayout Line 854  public class GridBagLayout
854       *                    width. Otherwise, sort by height.       *                    width. Otherwise, sort by height.
855       * FIXME: Use a better sorting algorithm.       * FIXME: Use a better sorting algorithm.
856       */       */
857      private void sortBySpan (Component component, int span, ArrayList list, boolean sortByWidth)      private void sortBySpan (Component component, int span,
858                                 ArrayList<Component> list, boolean sortByWidth)
859      {      {
860        if (span == GridBagConstraints.REMAINDER        if (span == GridBagConstraints.REMAINDER
861            || span == GridBagConstraints.RELATIVE)            || span == GridBagConstraints.RELATIVE)

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.15.2.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26