Crossfire JXClient, Trunk
ResourceUtils.java
Go to the documentation of this file.
1 /*
2  * This file is part of JXClient, the Fullscreen Java Crossfire Client.
3  *
4  * JXClient is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * JXClient is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with JXClient; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  * Copyright (C) 2005-2008 Yann Chachkoff
19  * Copyright (C) 2006-2017,2019-2023 Andreas Kirschbaum
20  * Copyright (C) 2010-2012,2014-2018,2020-2023 Nicolas Weeger
21  */
22 
23 package com.realtime.crossfire.jxclient.util;
24 
25 import java.io.IOException;
26 import java.net.URL;
27 import javax.swing.ImageIcon;
28 import org.jetbrains.annotations.NotNull;
29 
34 public class ResourceUtils {
35 
39  @NotNull
40  public static final String UNKNOWN_PNG = "unknown.png";
41 
45  @NotNull
46  public static final String NEXT_GROUP_FACE = "next_group.png";
47 
51  @NotNull
52  public static final String PREV_GROUP_FACE = "prev_group.png";
53 
57  @NotNull
58  public static final String APPLICATION_ICON = "application_icon.png";
59 
63  @NotNull
64  public static final String ALL_SPELL_SKILLS_ICON = "all_spell_skills_icon.png";
65 
69  private ResourceUtils() {
70  }
71 
78  @NotNull
79  public static ImageIcon loadImage(@NotNull final String name) throws IOException {
80  final URL url = ResourceUtils.class.getClassLoader().getResource("resource/"+name);
81  if (url == null) {
82  throw new IOException("cannot find image '"+name+"'");
83  }
84  final ImageIcon imageIcon = new ImageIcon(url);
85  if (imageIcon.getIconWidth() <= 0 || imageIcon.getIconHeight() <= 0) {
86  throw new IOException("cannot load image '"+name+"'");
87  }
88  return imageIcon;
89  }
90 
91 }
com.realtime.crossfire.jxclient.util.ResourceUtils.PREV_GROUP_FACE
static final String PREV_GROUP_FACE
Definition: ResourceUtils.java:52
com.realtime.crossfire.jxclient.util.ResourceUtils.ALL_SPELL_SKILLS_ICON
static final String ALL_SPELL_SKILLS_ICON
Definition: ResourceUtils.java:64
com.realtime.crossfire.jxclient.util.ResourceUtils.UNKNOWN_PNG
static final String UNKNOWN_PNG
Definition: ResourceUtils.java:40
com.realtime.crossfire.jxclient.util.ResourceUtils.loadImage
static ImageIcon loadImage(@NotNull final String name)
Definition: ResourceUtils.java:79
com.realtime.crossfire.jxclient.util.ResourceUtils.NEXT_GROUP_FACE
static final String NEXT_GROUP_FACE
Definition: ResourceUtils.java:46
com.realtime.crossfire.jxclient.util.ResourceUtils.APPLICATION_ICON
static final String APPLICATION_ICON
Definition: ResourceUtils.java:58
com.realtime.crossfire.jxclient.util.ResourceUtils
Definition: ResourceUtils.java:34
com.realtime.crossfire.jxclient.util.ResourceUtils.ResourceUtils
ResourceUtils()
Definition: ResourceUtils.java:69