Search in sources :

Example 1 with LocalizedImageResource

use of org.apache.wicket.markup.html.image.resource.LocalizedImageResource in project wicket by apache.

the class Image method buildSrcSetAttribute.

/**
 * Builds the srcset attribute if multiple localizedImageResources are found as varargs
 *
 * @param tag
 *            the component tag
 */
protected void buildSrcSetAttribute(final ComponentTag tag) {
    int srcSetPosition = 0;
    for (LocalizedImageResource localizedImageResource : localizedImageResources) {
        localizedImageResource.setSrcAttribute(tag);
        if (shouldAddAntiCacheParameter()) {
            addAntiCacheParameter(tag);
        }
        String srcset = tag.getAttribute("srcset");
        String xValue = "";
        // If there are xValues set process them in the applied order to the srcset attribute.
        if (xValues != null) {
            xValue = xValues.size() > srcSetPosition && xValues.get(srcSetPosition) != null ? " " + xValues.get(srcSetPosition) : "";
        }
        tag.put("srcset", (srcset != null ? srcset + ", " : "") + tag.getAttribute("src") + xValue);
        srcSetPosition++;
    }
}
Also used : LocalizedImageResource(org.apache.wicket.markup.html.image.resource.LocalizedImageResource)

Example 2 with LocalizedImageResource

use of org.apache.wicket.markup.html.image.resource.LocalizedImageResource in project wicket by apache.

the class Image method setDefaultModel.

/**
 * @see org.apache.wicket.Component#setDefaultModel(org.apache.wicket.model.IModel)
 */
@Override
public Component setDefaultModel(IModel<?> model) {
    // stuck with the old model.
    for (LocalizedImageResource localizedImageResource : localizedImageResources) {
        localizedImageResource.setResourceReference(null);
        localizedImageResource.setResource(null);
    }
    localizedImageResource.setResourceReference(null);
    localizedImageResource.setResource(null);
    return super.setDefaultModel(model);
}
Also used : LocalizedImageResource(org.apache.wicket.markup.html.image.resource.LocalizedImageResource)

Example 3 with LocalizedImageResource

use of org.apache.wicket.markup.html.image.resource.LocalizedImageResource in project wicket by apache.

the class Image method setImageResourceReferences.

/**
 * @param parameters
 *            Set the resource parameters for the resource.
 * @param resourceReferences
 *            The resource references to set.
 */
public void setImageResourceReferences(final PageParameters parameters, final ResourceReference... resourceReferences) {
    localizedImageResources.clear();
    for (ResourceReference resourceReference : resourceReferences) {
        LocalizedImageResource localizedImageResource = new LocalizedImageResource(this);
        if (parameters != null) {
            localizedImageResource.setResourceReference(resourceReference, parameters);
        } else {
            localizedImageResource.setResourceReference(resourceReference);
        }
        localizedImageResources.add(localizedImageResource);
    }
}
Also used : LocalizedImageResource(org.apache.wicket.markup.html.image.resource.LocalizedImageResource) ResourceReference(org.apache.wicket.request.resource.ResourceReference)

Example 4 with LocalizedImageResource

use of org.apache.wicket.markup.html.image.resource.LocalizedImageResource in project wicket by apache.

the class Image method setImageResources.

/**
 * @param imageResources
 *            the new ImageResource to set.
 */
public void setImageResources(final IResource... imageResources) {
    localizedImageResources.clear();
    for (IResource imageResource : imageResources) {
        LocalizedImageResource localizedImageResource = new LocalizedImageResource(this);
        localizedImageResource.setResource(imageResource);
        localizedImageResources.add(localizedImageResource);
    }
}
Also used : LocalizedImageResource(org.apache.wicket.markup.html.image.resource.LocalizedImageResource) IResource(org.apache.wicket.request.resource.IResource)

Example 5 with LocalizedImageResource

use of org.apache.wicket.markup.html.image.resource.LocalizedImageResource in project wicket by apache.

the class Image method getStatelessHint.

/**
 * @see org.apache.wicket.Component#getStatelessHint()
 */
@Override
protected boolean getStatelessHint() {
    boolean stateless = (getImageResource() == null || getImageResource() == localizedImageResource.getResource()) && localizedImageResource.isStateless();
    boolean statelessList = false;
    for (LocalizedImageResource localizedImageResource : localizedImageResources) {
        if (localizedImageResource.isStateless()) {
            statelessList = true;
        }
    }
    return stateless || statelessList;
}
Also used : LocalizedImageResource(org.apache.wicket.markup.html.image.resource.LocalizedImageResource)

Aggregations

LocalizedImageResource (org.apache.wicket.markup.html.image.resource.LocalizedImageResource)5 IResource (org.apache.wicket.request.resource.IResource)1 ResourceReference (org.apache.wicket.request.resource.ResourceReference)1