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++;
}
}
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);
}
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);
}
}
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);
}
}
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;
}
Aggregations