001/*
002 * (C) Copyright 2006-2007 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Nuxeo - initial API and implementation
016 *
017 * $Id: JOOoConvertPluginImpl.java 18651 2007-05-13 20:28:53Z sfermigier $
018 */
019
020package org.nuxeo.ecm.platform.picture.api;
021
022import java.io.Serializable;
023import java.util.HashMap;
024import java.util.Map;
025
026import org.nuxeo.ecm.core.api.Blob;
027
028public class PictureViewImpl implements PictureView {
029
030    int width;
031
032    int height;
033
034    String title;
035
036    String description;
037
038    String tag;
039
040    String filename;
041
042    Blob content;
043
044    Blob blob;
045
046    ImageInfo imageInfo;
047
048    /**
049     * @since 5.7
050     */
051    public PictureViewImpl() {
052    }
053
054    /**
055     * @since 5.7
056     */
057    public PictureViewImpl(Map<String, Serializable> m) {
058        title = (String) m.get(PictureView.FIELD_TITLE);
059        description = (String) m.get(PictureView.FIELD_DESCRIPTION);
060        tag = (String) m.get(PictureView.FIELD_TAG);
061        filename = (String) m.get(PictureView.FIELD_FILENAME);
062        blob = (Blob) m.get(PictureView.FIELD_CONTENT);
063        imageInfo = (ImageInfo) m.get(PictureView.FIELD_INFO);
064
065        Integer w = (Integer) m.get(PictureView.FIELD_WIDTH);
066        if (w != null) {
067            width = w;
068        }
069        Integer h = (Integer) m.get(PictureView.FIELD_HEIGHT);
070        if (h != null) {
071            height = h;
072        }
073
074    }
075
076    @Override
077    public int getWidth() {
078        return width;
079    }
080
081    @Override
082    public void setWidth(int width) {
083        this.width = width;
084    }
085
086    @Override
087    public String getTitle() {
088        return title;
089    }
090
091    @Override
092    public void setTitle(String title) {
093        this.title = title;
094    }
095
096    @Override
097    public String getDescription() {
098        return description;
099    }
100
101    @Override
102    public void setDescription(String description) {
103        this.description = description;
104    }
105
106    @Override
107    public String getTag() {
108        return tag;
109    }
110
111    @Override
112    public void setTag(String tag) {
113        this.tag = tag;
114    }
115
116    @Override
117    public String getFilename() {
118        return filename;
119    }
120
121    @Override
122    public void setFilename(String filename) {
123        this.filename = filename;
124    }
125
126    @Override
127    public Blob getContent() {
128        return blob;
129    }
130
131    @Override
132    public int getHeight() {
133        return height;
134    }
135
136    @Override
137    public void setHeight(int height) {
138        this.height = height;
139    }
140
141    @Override
142    public Blob getBlob() {
143        return blob;
144    }
145
146    @Override
147    public void setBlob(Blob blob) {
148        this.blob = blob;
149    }
150
151    @Override
152    public ImageInfo getImageInfo() {
153        return imageInfo;
154    }
155
156    @Override
157    public void setImageInfo(ImageInfo info) {
158        this.imageInfo = info;
159    }
160
161    @Override
162    public Map<String, Serializable> asMap() {
163        Map<String, Serializable> m = new HashMap<String, Serializable>();
164        m.put(PictureView.FIELD_TITLE, getTitle());
165        m.put(PictureView.FIELD_DESCRIPTION, getDescription());
166        m.put(PictureView.FIELD_TAG, getTag());
167        m.put(PictureView.FIELD_HEIGHT, getHeight());
168        m.put(PictureView.FIELD_WIDTH, getWidth());
169        m.put(PictureView.FIELD_FILENAME, getFilename());
170        m.put(PictureView.FIELD_CONTENT, (Serializable) blob);
171        m.put(PictureView.FIELD_INFO, (Serializable) imageInfo.toMap());
172        return m;
173    }
174}