KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > viewers > ColumnWeightData


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jface.viewers;
12
13 import org.eclipse.core.runtime.Assert;
14
15 /**
16  * Describes the width of a table column in terms of a weight,
17  * a minimum width, and whether the column is resizable.
18  * <p>
19  * This class may be instantiated; it is not intended to be subclassed.
20  * </p>
21  */

22 public class ColumnWeightData extends ColumnLayoutData {
23
24     /**
25      * Default width of a column (in pixels).
26      */

27     public static final int MINIMUM_WIDTH = 20;
28
29     /**
30      * The column's minimum width in pixels.
31      */

32     public int minimumWidth;
33
34     /**
35      * The column's weight.
36      */

37     public int weight;
38
39     /**
40      * Creates a resizable column width with the given weight and a default
41      * minimum width.
42      *
43      * @param weight the weight of the column
44      */

45     public ColumnWeightData(int weight) {
46         this(weight, true);
47     }
48
49     /**
50      * Creates a resizable column width with the given weight and minimum width.
51      *
52      * @param weight the weight of the column
53      * @param minimumWidth the minimum width of the column in pixels
54      */

55     public ColumnWeightData(int weight, int minimumWidth) {
56         this(weight, minimumWidth, true);
57     }
58
59     /**
60      * Creates a column width with the given weight and minimum width.
61      *
62      * @param weight the weight of the column
63      * @param minimumWidth the minimum width of the column in pixels
64      * @param resizable <code>true</code> if the column is resizable,
65      * and <code>false</code> if size of the column is fixed
66      */

67     public ColumnWeightData(int weight, int minimumWidth, boolean resizable) {
68         super(resizable);
69         Assert.isTrue(weight >= 0);
70         Assert.isTrue(minimumWidth >= 0);
71         this.weight = weight;
72         this.minimumWidth = minimumWidth;
73     }
74
75     /**
76      * Creates a column width with the given weight and a default
77      * minimum width.
78      *
79      * @param weight the weight of the column
80      * @param resizable <code>true</code> if the column is resizable,
81      * and <code>false</code> if size of the column is fixed
82      */

83     public ColumnWeightData(int weight, boolean resizable) {
84         this(weight, MINIMUM_WIDTH, resizable);
85     }
86 }
87
Popular Tags