001/*
002 * (C) Copyright 2006-2016 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Tiago Cardoso <tcardoso@nuxeo.com>
018 */
019package org.nuxeo.ecm.platform.threed.service;
020
021import org.nuxeo.common.xmap.annotation.XNode;
022import org.nuxeo.common.xmap.annotation.XObject;
023
024/**
025 * Object representing a registered render view conversion on the {@link ThreeDService}. An {@code RenderView}
026 * references the spherical coordinates and if it should be a Rendition.
027 *
028 * @since 8.4
029 */
030@XObject("renderView")
031public class RenderView implements Comparable<RenderView> {
032
033    @XNode("@name")
034    protected String name;
035
036    @XNode("@zenith")
037    protected Integer zenith;
038
039    @XNode("@azimuth")
040    protected Integer azimuth;
041
042    @XNode("@width")
043    protected Integer width;
044
045    @XNode("@height")
046    protected Integer height;
047
048    @XNode("@enabled")
049    protected Boolean enabled;
050
051    @XNode("@rendition")
052    protected Boolean rendition;
053
054    @XNode("@renditionVisible")
055    protected Boolean renditionVisible;
056
057    public RenderView(RenderView other) {
058        name = other.name;
059        zenith = other.zenith;
060        azimuth = other.azimuth;
061        width = other.width;
062        height = other.height;
063        enabled = other.enabled;
064        rendition = other.rendition;
065        renditionVisible = other.renditionVisible;
066    }
067
068    public RenderView() {
069        super();
070    }
071
072    public String getName() {
073        return name;
074    }
075
076    public void setName(String name) {
077        this.name = name;
078    }
079
080    public Integer getZenith() {
081        return zenith;
082    }
083
084    public void setZenith(Integer zenith) {
085        this.zenith = zenith;
086    }
087
088    public Integer getAzimuth() {
089        return azimuth;
090    }
091
092    public void setAzimuth(Integer azimuth) {
093        this.azimuth = azimuth;
094    }
095
096    public Integer getWidth() {
097        return width;
098    }
099
100    public void setWidth(Integer width) {
101        this.width = width;
102    }
103
104    public Integer getHeight() {
105        return height;
106    }
107
108    public void setHeight(Integer height) {
109        this.height = height;
110    }
111
112    public boolean isEnabled() {
113        return (enabled == null) || enabled;
114    }
115
116    public void setEnabled(boolean enabled) {
117        this.enabled = enabled;
118    }
119
120    public boolean isRendition() {
121        return (rendition == null) || rendition;
122    }
123
124    public void setRendition(boolean rendition) {
125        this.rendition = rendition;
126    }
127
128    public boolean isRenditionVisible() {
129        return (renditionVisible == null) || renditionVisible;
130    }
131
132    public void setRenditionVisible(boolean renditionVisible) {
133        this.renditionVisible = renditionVisible;
134    }
135
136    public void merge(RenderView src) {
137        if (src.enabled != null) {
138            enabled = src.enabled;
139        }
140        if (src.rendition != null) {
141            rendition = src.rendition;
142        }
143        if (src.renditionVisible != null) {
144            renditionVisible = src.renditionVisible;
145        }
146        if (src.zenith != null) {
147            zenith = src.zenith;
148        }
149        if (src.azimuth != null) {
150            azimuth = src.azimuth;
151        }
152        if (src.width != null) {
153            width = src.width;
154        }
155        if (src.height != null) {
156            height = src.height;
157        }
158    }
159
160    public String getId() {
161        return String.valueOf(name.hashCode() & 0x7fffffff);
162    }
163
164    @Override
165    public int compareTo(RenderView o) {
166        return getId().compareTo(o.getId());
167    }
168}