| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| Borders |
|
| 1.0;1 |
| 1 | package org.jtheque.core.utils.ui; | |
| 2 | ||
| 3 | import org.jtheque.core.managers.Managers; | |
| 4 | import org.jtheque.core.managers.language.ILanguageManager; | |
| 5 | ||
| 6 | import javax.swing.BorderFactory; | |
| 7 | import javax.swing.border.Border; | |
| 8 | import javax.swing.border.TitledBorder; | |
| 9 | ||
| 10 | /* | |
| 11 | * This file is part of JTheque. | |
| 12 | * | |
| 13 | * JTheque is free software: you can redistribute it and/or modify | |
| 14 | * it under the terms of the GNU General Public License as published by | |
| 15 | * the Free Software Foundation, either version 3 of the License. | |
| 16 | * | |
| 17 | * JTheque is distributed in the hope that it will be useful, | |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 20 | * GNU General Public License for more details. | |
| 21 | * | |
| 22 | * You should have received a copy of the GNU General Public License | |
| 23 | * along with JTheque. If not, see <http://www.gnu.org/licenses/>. | |
| 24 | */ | |
| 25 | ||
| 26 | /** | |
| 27 | * An utility class to create and get borders. | |
| 28 | * | |
| 29 | * @author Baptiste Wicht | |
| 30 | */ | |
| 31 | public final class Borders { | |
| 32 | 0 | public static final Border DIALOG_BORDER = BorderFactory.createEmptyBorder(10, 10, 10, 10); |
| 33 | 0 | public static final Border EMPTY_BORDER = BorderFactory.createEmptyBorder(); |
| 34 | ||
| 35 | /** | |
| 36 | * This is an utility class, not instanciable. | |
| 37 | */ | |
| 38 | private Borders() { | |
| 39 | 0 | super(); |
| 40 | 0 | } |
| 41 | ||
| 42 | /** | |
| 43 | * Create a titled border. | |
| 44 | * | |
| 45 | * @param key The internationalization key. | |
| 46 | * @return The border. | |
| 47 | */ | |
| 48 | public static Border createTitledBorder(String key) { | |
| 49 | 0 | TitledBorder border = BorderFactory.createTitledBorder(Managers.getManager(ILanguageManager.class).getMessage(key)); |
| 50 | ||
| 51 | 0 | Managers.getManager(ILanguageManager.class).addInternationalizable(new BorderUpdater(border, key)); |
| 52 | ||
| 53 | 0 | return border; |
| 54 | } | |
| 55 | ||
| 56 | /** | |
| 57 | * Create empty borders with a size of i on all side. | |
| 58 | * | |
| 59 | * @param i The size of borders. | |
| 60 | * @return the <code>Border</code> object | |
| 61 | */ | |
| 62 | public static Border createEmptyBorder(int i) { | |
| 63 | 0 | return BorderFactory.createEmptyBorder(i, i, i, i); |
| 64 | } | |
| 65 | ||
| 66 | /** | |
| 67 | * Creates an empty border that takes up space but which does | |
| 68 | * no drawing, specifying the width of the top, left, bottom, and | |
| 69 | * right sides. | |
| 70 | * | |
| 71 | * @param top an integer specifying the width of the top, in pixels | |
| 72 | * @param left an integer specifying the width of the left side, in pixels | |
| 73 | * @param bottom an integer specifying the width of the bottom, in pixels | |
| 74 | * @param right an integer specifying the width of the right side, in pixels | |
| 75 | * @return the <code>Border</code> object | |
| 76 | */ | |
| 77 | public static Border createEmptyBorder(int top, int left, int bottom, int right) { | |
| 78 | 0 | return BorderFactory.createEmptyBorder(top, left, bottom, right); |
| 79 | } | |
| 80 | } |