/** * Renders a copy of the given icon, with a different Wicket ID. * @param icon the icon to render * @param newId the new Wicket ID * @return a copy of the given icon */ public static HippoIcon copy(final HippoIcon icon, final String newId) { if (icon instanceof SpriteIcon) { return new SpriteIcon(newId, (SpriteIcon)icon); } else if (icon instanceof InlineSvgIcon) { return new InlineSvgIcon(newId, (InlineSvgIcon)icon); } else if (icon instanceof ResourceIcon) { return new ResourceIcon(newId, (ResourceIcon)icon); } throw new IllegalStateException("Expected HippoIcon's class to be either SpriteIcon, InlineSvgIcon or ResourceIcon, but got " + icon.getClass()); }
/** * Renders an icon stored in a resource which is referenced by a Wicket model. * When the icon's file extension is '.svg', the icon is rendered as an inline SVG image. * @param id the Wicket id of the icon * @param model the model containing the resource to render * @return the icon component */ public static HippoIcon fromResourceModel(final String id, final IModel<ResourceReference> model) { return new ResourceIcon(id, model, -1, -1); }
/** * Renders an icon stored in a resource, including 'width' and 'height' attributes. * When the icon's file extension is '.svg', the icon is rendered as an inline SVG image. * @param id the Wicket id of the icon * @param reference the resource to render * @param width the width of the icon in pixels * @param height the height of the icon in pixels * @return the icon component */ public static HippoIcon fromResource(final String id, final ResourceReference reference, final int width, final int height) { return new ResourceIcon(id, reference, width, height); }