/[classpath]/classpath/javax/swing/SizeRequirements.java
ViewVC logotype

Diff of /classpath/javax/swing/SizeRequirements.java

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

revision 1.6 by rabbit78, Thu May 19 13:33:15 2005 UTC revision 1.7 by rabbit78, Thu May 19 15:19:23 2005 UTC
# Line 87  public class SizeRequirements implements Line 87  public class SizeRequirements implements
87     */     */
88    public SizeRequirements()    public SizeRequirements()
89    {    {
90      // TODO      this (0, 0, 0, 0.5F);
91    }    }
92    
93    /**    /**
# Line 101  public class SizeRequirements implements Line 101  public class SizeRequirements implements
101     */     */
102    public SizeRequirements(int min, int pref, int max, float align)    public SizeRequirements(int min, int pref, int max, float align)
103    {    {
104      // TODO      minimum = min;
105        preferred = pref;
106        maximum = max;
107        alignment = align;
108    }    }
109    
110    /**    /**
# Line 129  public class SizeRequirements implements Line 132  public class SizeRequirements implements
132    public static SizeRequirements    public static SizeRequirements
133    getTiledSizeRequirements(SizeRequirements[] children)    getTiledSizeRequirements(SizeRequirements[] children)
134    {    {
135      return null; // TODO      SizeRequirements result = new SizeRequirements();
136        for (int i = 0; i < children.length; i++)
137          {
138            result.minimum += children[i].minimum;
139            result.preferred += children[i].preferred;
140            result.maximum += children[i].maximum;
141          }
142        return result;
143    }    }
144    
145    /**    /**
# Line 162  public class SizeRequirements implements Line 172  public class SizeRequirements implements
172     * The calculated offset and span values for each component are then     * The calculated offset and span values for each component are then
173     * stored in the arrays <code>offsets</code> and <code>spans</code>.     * stored in the arrays <code>offsets</code> and <code>spans</code>.
174     *     *
175       * The components are placed in the forward direction, beginning with
176       * an offset of 0.
177       *
178     * @param allocated the amount of allocated space     * @param allocated the amount of allocated space
179     * @param total the total size requirements of the components     * @param total the total size requirements of the components
180     * @param children the size requirement of each component     * @param children the size requirement of each component
# Line 171  public class SizeRequirements implements Line 184  public class SizeRequirements implements
184    public static void calculateTiledPositions(int allocated,    public static void calculateTiledPositions(int allocated,
185                                               SizeRequirements total,                                               SizeRequirements total,
186                                               SizeRequirements[] children,                                               SizeRequirements[] children,
187                                               int[] offset, int[] spans)                                               int[] offsets, int[] spans)
188    {    {
189      // TODO      calculateTiledPositions(allocated, total, children, offsets, spans, true);
190    }    }
191    
192    /**    /**
# Line 189  public class SizeRequirements implements Line 202  public class SizeRequirements implements
202     * The calculated offset and span values for each component are then     * The calculated offset and span values for each component are then
203     * stored in the arrays <code>offsets</code> and <code>spans</code>.     * stored in the arrays <code>offsets</code> and <code>spans</code>.
204     *     *
205       * Depending on the value of <code>forward</code> the components are
206       * placed in the forward direction (left-right or top-bottom), where
207       * the offsets begin with 0, or in the reverse direction
208       * (right-left or bottom-top).
209       *
210       * @param allocated the amount of allocated space
211       * @param total the total size requirements of the components
212       * @param children the size requirement of each component
213       * @param offsets will hold the offset values for each component
214       * @param spans will hold the span values for each component
215       * @param forward whether the components should be placed in the forward
216       *     direction (left-right or top-bottom) or reverse direction
217       *     (right-left or bottom-top)
218       */
219      public static void calculateTiledPositions(int allocated,
220                                                 SizeRequirements total,
221                                                 SizeRequirements[] children,
222                                                 int[] offsets, int[] spans,
223                                                 boolean forward)
224      {
225        if (forward)
226          {
227            int offset = 0;
228            for (int i = 0; i < children.length; i++)
229              {
230                offsets[i] = offset;
231                spans[i] = children[i].preferred;
232                offset += children[i].preferred;
233              }
234          }
235        else
236          {
237            int offset = allocated;
238            for (int i = 0; i < children.length; i++)
239              {
240                offset -= children[i].preferred;
241                offsets[i] = offset;
242                spans[i] = children[i].preferred;
243              }
244          }
245      }
246    
247      /**
248       * Calculate the offsets and spans of the components, when they should
249       * be placed end-to-end.
250       *
251       * You must specify the amount of allocated space in
252       * <code>allocated</code>, the total size requirements of the set of
253       * components in <code>total</code> (this can be calculated using
254       * {@link #getTiledSizeRequirements} and the size requirements of the
255       * components in <code>children</code>.
256       *
257       * The calculated offset and span values for each component are then
258       * stored in the arrays <code>offsets</code> and <code>spans</code>.
259       *
260       * The components are tiled in the forward direction, beginning with
261       * an offset of 0.
262       *
263       * @param allocated the amount of allocated space
264       * @param total the total size requirements of the components
265       * @param children the size requirement of each component
266       * @param offsets will hold the offset values for each component
267       * @param spans will hold the span values for each component
268       */
269      public static void calculateAlignedPositions(int allocated,
270                                                   SizeRequirements total,
271                                                   SizeRequirements[] children,
272                                                   int[] offsets, int[] spans)
273      {
274        calculateTiledPositions(allocated, total, children, offsets, spans, true);
275      }
276    
277      /**
278       * Calculate the offsets and spans of the components, when they should
279       * be placed end-to-end.
280       *
281       * You must specify the amount of allocated space in
282       * <code>allocated</code>, the total size requirements of the set of
283       * components in <code>total</code> (this can be calculated using
284       * {@link #getTiledSizeRequirements} and the size requirements of the
285       * components in <code>children</code>.
286       *
287       * The calculated offset and span values for each component are then
288       * stored in the arrays <code>offsets</code> and <code>spans</code>.
289       *
290       * Depending on the value of <code>forward</code> the components are
291       * placed in the forward direction (left-right or top-bottom), where
292       * the offsets begin with 0, or in the reverse direction
293       * (right-left or bottom-top).
294       *
295     * @param allocated the amount of allocated space     * @param allocated the amount of allocated space
296     * @param total the total size requirements of the components     * @param total the total size requirements of the components
297     * @param children the size requirement of each component     * @param children the size requirement of each component
298     * @param offsets will hold the offset values for each component     * @param offsets will hold the offset values for each component
299     * @param spans will hold the span values for each component     * @param spans will hold the span values for each component
300       * @param forward whether the components should be placed in the forward
301       *     direction (left-right or top-bottom) or reverse direction
302       *     (right-left or bottom-top)
303     */     */
304    public static void calculateAlignedPositions(int allocated,    public static void calculateAlignedPositions(int allocated,
305                                                 SizeRequirements total,                                                 SizeRequirements total,
306                                                 SizeRequirements[] children,                                                 SizeRequirements[] children,
307                                                 int[] offset, int[] spans)                                                 int[] offset, int[] spans,
308                                                   boolean forward)
309    {    {
310      // TODO      // TODO
311    }    }

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

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