org.icepdf.ri.images.DefaultIconPack Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of icepdf-viewer Show documentation
Show all versions of icepdf-viewer Show documentation
ICEpdf Java Swing/AWT reference implementation.
The newest version!
package org.icepdf.ri.images;
import javax.swing.*;
import java.net.URL;
/**
* Icon pack definition for the default colour icons shipping with ICEpdf
*
* This icon pack supports all icon variants. Typical icon sizes are:
*
* - {@code HUGE}: 57×48 px
* - {@code LARGE}: 32×32 px
* - {@code SMALL}: 24×24 px
* - {@code MINI}: 20×20 px
* - {@code TINY}: 16×16 px
*
* All icons in this pack are returned as {@link ImageIcon}s created from PNG files
*
* @author Alexander Leithner
*/
public class DefaultIconPack extends IconPack {
@Override
public VariantPool getProvidedVariants() {
return new VariantPool(Variant.DISABLED, Variant.ROLLOVER, Variant.PRESSED, Variant.SELECTED);
}
@Override
public Icon getIcon(String name, Variant variant, Images.IconSize size) throws RuntimeException {
String iconSize;
switch (size) {
case HUGE:
iconSize = "_lg";
break;
case LARGE:
iconSize = "_32";
break;
case SMALL:
iconSize = "_24";
break;
case MINI:
iconSize = "_20";
break;
default:
iconSize = "_16";
break;
}
String iconVariant;
switch (variant) {
case NORMAL:
iconVariant = "_a";
break;
case PRESSED:
case DISABLED:
iconVariant = "_i";
break;
case ROLLOVER:
iconVariant = "_r";
break;
case SELECTED:
iconVariant = "_selected_a";
break;
case NONE:
default:
iconVariant = "";
break;
}
URL url = Images.class.getResource(name + iconVariant + iconSize + ".png");
if (url == null) {
throw new NullPointerException("Icon " + name + " not found with variant " + variant + ", size " + size + " on classpath; NULL URL returned");
}
return new ImageIcon(url);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy