Search in sources :

Example 1 with ImageSection

use of uk.nhs.digital.ps.beans.ImageSection in project hippo by NHS-digital-website.

the class PageSectionGrouper method groupSections.

public List<Object> groupSections(List<? extends HippoBean> sections) {
    // convert the section into a grouped list so we can
    // show multiple images next to each other in a section
    List<Object> groupedSections = new ArrayList<>();
    for (HippoBean section : sections) {
        if (isHalfImage(section)) {
            // if the last entry was a Image Pair with a space then we are the second one
            ImageSection imageSection = (ImageSection) section;
            Object last = groupedSections.size() > 0 ? groupedSections.get(groupedSections.size() - 1) : null;
            if (isImagePairWithSpace(last)) {
                ((ImagePairSection) last).setSecond(imageSection);
            } else {
                groupedSections.add(new ImagePairSection(imageSection));
            }
        } else {
            // just add it, no grouping required
            groupedSections.add(section);
        }
    }
    return groupedSections;
}
Also used : HippoBean(org.hippoecm.hst.content.beans.standard.HippoBean) ArrayList(java.util.ArrayList) ImageSection(uk.nhs.digital.ps.beans.ImageSection)

Example 2 with ImageSection

use of uk.nhs.digital.ps.beans.ImageSection in project hippo by NHS-digital-website.

the class PageSectionGrouperTest method mockImage.

private static ImageSection mockImage(ImageSection.Size size) {
    ImageSection imageSection = mock(ImageSection.class);
    given(imageSection.getSize()).willReturn(size);
    return imageSection;
}
Also used : ImageSection(uk.nhs.digital.ps.beans.ImageSection)

Aggregations

ImageSection (uk.nhs.digital.ps.beans.ImageSection)2 ArrayList (java.util.ArrayList)1 HippoBean (org.hippoecm.hst.content.beans.standard.HippoBean)1