View Javadoc
1   package fr.ifremer.dali.ui.swing.util;
2   
3   /*-
4    * #%L
5    * Dali :: UI
6    * %%
7    * Copyright (C) 2014 - 2017 Ifremer
8    * %%
9    * This program is free software: you can redistribute it and/or modify
10   * it under the terms of the GNU Affero General Public License as published by
11   * the Free Software Foundation, either version 3 of the License, or
12   * (at your option) any later version.
13   * 
14   * This program is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   * GNU General Public License for more details.
18   * 
19   * You should have received a copy of the GNU Affero General Public License
20   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21   * #L%
22   */
23  
24  import fr.ifremer.quadrige3.ui.swing.ApplicationUIUtil;
25  
26  import java.awt.Component;
27  import java.awt.Dimension;
28  
29  /**
30   * @author peck7 on 04/07/2017.
31   */
32  public class DaliUIs extends ApplicationUIUtil {
33  
34      /**
35       * La largeur des combobox.
36       */
37      public static final int DALI_COMPONENT_WIDTH = 200;
38  
39      /**
40       * La hauteur des combobox.
41       */
42      public static final int DALI_COMPONENT_HEIGHT = 30;
43  
44      /**
45       * Size of a Dali double list
46       */
47      public static final int DALI_DOUBLE_LIST_SIZE = 260;
48  
49      /**
50       * Size of a Dali checkbox column
51       */
52      public static final int DALI_CHECKBOX_WIDTH = 80;
53  
54      /**
55       * Size of a Dali image thumbnail
56       */
57      public static final int DALI_IMAGE_WIDTH = 200;
58  
59      /**
60       * Affecte une largeur et une hauteur a un composant.
61       *
62       * @param component La combobox
63       */
64      public static void forceComponentSize(Component component) {
65          forceComponentSize(component, DALI_COMPONENT_WIDTH);
66      }
67  
68      /**
69       * Affecte une largeur et une hauteur a une combobox.
70       *
71       * @param component La combobox
72       * @param width     La largeur
73       */
74      public static void forceComponentSize(Component component, int width) {
75          forceComponentSize(component, width, DALI_COMPONENT_HEIGHT);
76      }
77  
78      public static void forceComponentSize(Component component, int width, int height) {
79          forceComponentSize(component, new Dimension(width, height));
80      }
81  
82      public static void forceComponentSize(Component component, Dimension dimension) {
83          component.setPreferredSize(dimension);
84          component.setSize(component.getPreferredSize());
85          component.setMaximumSize(component.getPreferredSize());
86          component.setMinimumSize(component.getPreferredSize());
87      }
88  }