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 <[email protected]> 018 */ 019package org.nuxeo.ecm.platform.threed; 020 021import org.nuxeo.ecm.core.api.Blob; 022 023import java.io.Serializable; 024import java.util.HashMap; 025import java.util.Map; 026 027/** 028 * Object wraping a 3D render view {@code Blob}, spherical coordinates and title. 029 * 030 * @since 8.4 031 */ 032public class ThreeDRenderView { 033 034 public static final String TITLE = "title"; 035 036 public static final String CONTENT = "content"; 037 038 public static final String THUMBNAIL = "thumbnail"; 039 040 public static final String AZIMUTH = "azimuth"; 041 042 public static final String ZENITH = "zenith"; 043 044 protected final Blob content; 045 046 protected final Blob thumbnail; 047 048 protected final String title; 049 050 protected final int azimuth; 051 052 protected final int zenith; 053 054 public ThreeDRenderView(String title, Blob content, Blob thumbnail, int azimuth, int zenith) { 055 this.title = title; 056 this.content = content; 057 this.thumbnail = thumbnail; 058 this.azimuth = azimuth; 059 this.zenith = zenith; 060 } 061 062 public ThreeDRenderView(Map<String, Serializable> map) { 063 title = (String) map.get(TITLE); 064 content = (Blob) map.get(CONTENT); 065 thumbnail = (Blob) map.get(THUMBNAIL); 066 Long azimuthLong = (Long) map.get(AZIMUTH); 067 azimuth = (azimuthLong != null) ? azimuthLong.intValue() : 0; 068 Long zenithLong = (Long) map.get(ZENITH); 069 zenith = (zenithLong != null) ? zenithLong.intValue() : 0; 070 } 071 072 public Blob getContent() { 073 return content; 074 } 075 076 public Blob getThumbnail() { 077 return thumbnail; 078 } 079 080 public String getTitle() { 081 return title; 082 } 083 084 public int getAzimuth() { 085 return azimuth; 086 } 087 088 public int getZenith() { 089 return zenith; 090 } 091 092 public Map<String, Serializable> toMap() { 093 Map<String, Serializable> map = new HashMap<String, Serializable>(); 094 map.put(TITLE, title); 095 map.put(CONTENT, (Serializable) content); 096 map.put(THUMBNAIL, (Serializable) thumbnail); 097 map.put(AZIMUTH, azimuth); 098 map.put(ZENITH, zenith); 099 return map; 100 } 101}