Package com.psddev.dari.util

Examples of com.psddev.dari.util.StorageItem


    }

    @Override
    protected void doService(final ToolPageContext page) throws IOException, ServletException {
        Object object = Query.fromAll().where("_id = ?", page.param(UUID.class, "id")).first();
        StorageItem image = (StorageItem) State.getInstance(object).get(page.param(String.class, "field"));

        page.writeHeader();
            page.writeStart("div", "class", "widget");
                page.writeStart("h1", "class", "icon icon-crop");
                    page.writeHtml("Resized Images");
View Full Code Here


         */
        public String toHtml() {
            String html = convertAttributesToHtml(tagName, toAttributes());

            if (isOverlay()) {
                StorageItem item = null;
                Map<String, ImageCrop> crops = null;

                if (this.state != null) {
                    State objectState = this.state;
                    String field = this.field;
View Full Code Here

            ResizeOption resizeOption = this.resizeOption;

            String srcAttr = this.srcAttribute;
            boolean hideDimensions = this.hideDimensions;

            StorageItem item = null;
            Integer originalWidth = null;
            Integer originalHeight = null;
            Map<String, ImageCrop> crops = null;

            if (this.state != null) { // backwards compatibility path
                State objectState = this.state;
                String field = this.field;

                if (ObjectUtils.isBlank(field)) {
                    field = findStorageItemField(objectState);
                }

                item = findStorageItem(objectState, field);

                if (item != null) {
                    originalWidth = findDimension(objectState, field, "width");
                    originalHeight = findDimension(objectState, field, "height");
                    crops = findImageCrops(objectState, field);
                }

            } else { // new code path
                item = this.item;

                if (item != null) {
                    originalWidth = findDimension(item, "width");
                    originalHeight = findDimension(item, "height");
                    crops = findImageCrops(item);
                }
            }

            // null out all dimensions that are less than or equal to zero
            originalWidth = originalWidth != null && originalWidth <= 0 ? null : originalWidth;
            originalHeight = originalHeight != null && originalHeight <= 0 ? null : originalHeight;
            width = width != null && width <= 0 ? null : width;
            height = height != null && height <= 0 ? null : height;

            if (item != null) {
                Map<String, Object> options = new LinkedHashMap<String, Object>();

                Integer cropX = null, cropY = null, cropWidth = null, cropHeight = null;

                // set fields from this standard size if they haven't already been set
                if (standardImageSize != null) {

                    Integer standardWidth = standardImageSize.getWidth();
                    Integer standardHeight = standardImageSize.getHeight();
                    if (standardWidth <= 0) { standardWidth = null; }
                    if (standardHeight <= 0) { standardHeight = null; }

                    Double standardAspectRatio = null;
                    if (standardWidth != null && standardHeight != null) {
                        standardAspectRatio = (double) standardWidth / (double) standardHeight;
                    }

                    // if only one of either width or height is set then calculate
                    // the other dimension based on the standardImageSize aspect
                    // ratio rather than blindly taking the other standardImageSize
                    // dimension.
                    if (standardAspectRatio != null && (width != null || height != null)) {

                        if (width != null && height == null) {
                            height = (int) (width / standardAspectRatio);

                        } else if (width == null && height != null) {
                            width = (int) (height * standardAspectRatio);
                        }

                    } else {
                        // get the standard image dimensions
                        if (width == null) {
                            width = standardWidth;
                        }
                        if (height == null) {
                            height = standardHeight;
                        }
                    }

                    // get the crop and resize options
                    if (cropOption == null) {
                        cropOption = standardImageSize.getCropOption();
                    }
                    if (resizeOption == null) {
                        resizeOption = standardImageSize.getResizeOption();
                    }

                    // get a potentially smaller image from the StorageItem. This improves
                    // resize performance on large images.
                    StorageItem alternateItem = findStorageItemForSize(item, width, height);
                    if (alternateItem != item) {
                        item = alternateItem;
                        originalWidth = findDimension(item, "width");
                        originalHeight = findDimension(item, "height");
                    }
View Full Code Here

TOP

Related Classes of com.psddev.dari.util.StorageItem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.