EmulatorImpl.java 2.26 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.day.cq.wcm.api.components.Component
 *  org.apache.sling.api.resource.Resource
 *  org.apache.sling.api.resource.ResourceResolver
 *  org.apache.sling.api.resource.ResourceUtil
 *  org.apache.sling.api.resource.ValueMap
 */
package com.day.cq.wcm.emulator.impl;

import com.day.cq.wcm.api.components.Component;
import com.day.cq.wcm.emulator.Emulator;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ResourceUtil;
import org.apache.sling.api.resource.ValueMap;

public class EmulatorImpl
implements Emulator {
    private final Resource resource;
    private final Component component;
    private final ValueMap properties;
    private final ValueMap config;
    private String contentCssPath;

    public EmulatorImpl(Resource resource) {
        this.resource = resource;
        this.properties = ResourceUtil.getValueMap((Resource)resource);
        this.component = (Component)resource.adaptTo(Component.class);
        this.config = ResourceUtil.getValueMap((Resource)resource.getResourceResolver().getResource(resource, "cq:emulatorConfig"));
    }

    public String getContentCssPath() {
        return this.contentCssPath;
    }

    public String getDescription() {
        return (String)this.properties.get("jcr:description", String.class);
    }

    public String getName() {
        return this.component.getName();
    }

    public String getPath() {
        return this.resource.getPath();
    }

    public String getTitle() {
        return this.component.getTitle();
    }

    public boolean canRotate() {
        return (Boolean)this.config.get("canRotate", (Object)false);
    }

    public boolean hasTouchScrolling() {
        return (Boolean)this.config.get("touchScrolling", (Object)false);
    }

    public int getWidth() {
        return (Integer)this.config.get("width", (Object)-1);
    }

    public int getHeight() {
        return (Integer)this.config.get("height", (Object)-1);
    }

    public double getPixelRatio() {
        return (Double)this.config.get("device-pixel-ratio", (Object)1.0);
    }

    public void setContentCssPath(String cssPath) {
        this.contentCssPath = cssPath;
    }
}