| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| NoteImageManager |
|
| 2.5;2.5 |
| 1 | package org.jtheque.core.utils.db; | |
| 2 | ||
| 3 | import org.jtheque.core.managers.Managers; | |
| 4 | import org.jtheque.core.managers.core.ICore; | |
| 5 | import org.jtheque.core.managers.resource.IResourceManager; | |
| 6 | import org.jtheque.core.managers.resource.ImageType; | |
| 7 | ||
| 8 | import java.awt.Image; | |
| 9 | import java.awt.image.BufferedImage; | |
| 10 | ||
| 11 | /* | |
| 12 | * This file is part of JTheque. | |
| 13 | * | |
| 14 | * JTheque is free software: you can redistribute it and/or modify | |
| 15 | * it under the terms of the GNU General Public License as published by | |
| 16 | * the Free Software Foundation, either version 3 of the License. | |
| 17 | * | |
| 18 | * JTheque is distributed in the hope that it will be useful, | |
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 21 | * GNU General Public License for more details. | |
| 22 | * | |
| 23 | * You should have received a copy of the GNU General Public License | |
| 24 | * along with JTheque. If not, see <http://www.gnu.org/licenses/>. | |
| 25 | */ | |
| 26 | ||
| 27 | /** | |
| 28 | * A manager for the images of the notes. | |
| 29 | * | |
| 30 | * @author Baptiste Wicht | |
| 31 | */ | |
| 32 | public final class NoteImageManager { | |
| 33 | private static final BufferedImage[] STARS; | |
| 34 | ||
| 35 | /** | |
| 36 | * Utility class, not instanciable. | |
| 37 | */ | |
| 38 | private NoteImageManager() { | |
| 39 | 0 | super(); |
| 40 | 0 | } |
| 41 | ||
| 42 | static { | |
| 43 | 0 | STARS = new BufferedImage[7]; |
| 44 | ||
| 45 | 0 | for (int i = 0; i < 7; ++i) { |
| 46 | 0 | STARS[i] = Managers.getManager(IResourceManager.class).getImage(ICore.IMAGES_BASE_NAME, "Star" + (i + 1), ImageType.PNG); |
| 47 | } | |
| 48 | 0 | } |
| 49 | ||
| 50 | /** | |
| 51 | * Return the image of the specified note. | |
| 52 | * | |
| 53 | * @param note The image of the note. | |
| 54 | * @return The <code>BufferedImage</code>. | |
| 55 | */ | |
| 56 | public static Image getImage(Note note) { | |
| 57 | 0 | if (note == null) { |
| 58 | 0 | return STARS[6]; |
| 59 | } | |
| 60 | ||
| 61 | 0 | return note.getValue() == DaoNotes.NoteType.ERROR ? STARS[DaoNotes.NoteType.UNDEFINED.intValue() - 1] : STARS[note.getValue().intValue() - 1]; |
| 62 | } | |
| 63 | } |