BrightSide Workbench Full Report + Source Code
Images.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2012 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.elephant.util;
20 
21 import org.turro.elephant.context.ElephantContext;
22 import org.turro.elephant.impl.util.Files;
23 
28 public class Images {
29 
30  public static final String
31  PATH_TO_IMAGES = "/_zul/images/",
32  PATH_TO_12IMAGES = "/_zul/images/12/",
33  PATH_TO_64IMAGES = "/_zul/images/64/",
34  IMAGE_EXTENSION = ".png";
35 
36  public static String getImage(String image) {
37  return PATH_TO_IMAGES + image + IMAGE_EXTENSION;
38  }
39 
40  public static String get12Image(String image) {
41  return PATH_TO_12IMAGES + image + IMAGE_EXTENSION;
42  }
43 
44  public static String get64Image(String image) {
45  return PATH_TO_64IMAGES + image + IMAGE_EXTENSION;
46  }
47 
48  public static String getBlankImage() {
49  return PATH_TO_IMAGES + "no_img" + IMAGE_EXTENSION;
50  }
51 
52  public static String getImageOrDefault(String image) {
53  return getImageOrDefault(image, "/_zul/images/bg/default.png");
54  }
55 
56  public static String getImageOrDefault(String image, String defaultImage) {
57  return Files.exists(image) ? image : defaultImage;
58  }
59 
60  public static String getImageOrNull(String image) {
61  return Files.exists(image) ? image : null;
62  }
63 
64  public static String removeAppContext(String path) {
65  if(path.startsWith(ElephantContext.getRootWebPath())) {
66  path = path.substring(ElephantContext.getRootWebPath().length());
67  }
68  return path;
69  }
70 
71  private Images() {
72  }
73 
74 }
static boolean exists(String path)
Definition: Files.java:80
static final String PATH_TO_IMAGES
Definition: Images.java:31
static String get64Image(String image)
Definition: Images.java:44
static String getImageOrDefault(String image, String defaultImage)
Definition: Images.java:56
static String getImageOrNull(String image)
Definition: Images.java:60
static String get12Image(String image)
Definition: Images.java:40
static String getImage(String image)
Definition: Images.java:36
static String getImageOrDefault(String image)
Definition: Images.java:52
static String getBlankImage()
Definition: Images.java:48
static String removeAppContext(String path)
Definition: Images.java:64