001: /*
002: * Apollo - Motion capture and animation system
003: * Copyright (c) 2005 Apollo
004: *
005: * This program is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU General Public License
007: * as published by the Free Software Foundation; either version 2
008: * of the License, or (at your option) any later version.
009: *
010: * This program is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
013: * GNU General Public License for more details.
014: *
015: * You should have received a copy of the GNU General Public License
016: * along with this program; if not, write to the Free Software
017: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
018: *
019: * http://www.gnu.org/copyleft/gpl.html
020: *
021: * @author Giovane.Kuhn - brain@netuno.com.br
022: *
023: */
024: package org.apollo.datamodel;
025:
026: import java.io.Serializable;
027: import java.util.Collections;
028: import java.util.HashSet;
029: import java.util.Observable;
030: import java.util.Set;
031:
032: import org.apollo.ApolloUtil;
033:
034: /**
035: * Class represents an apollo project.
036: * @author Giovane.Kuhn on 03/05/2005
037: */
038: public final class Project extends Observable implements Serializable {
039:
040: private static final long serialVersionUID = 1L;
041:
042: /** File to persist the apollo project */
043: private transient String projectFile;
044:
045: /** Model used by the video */
046: private String modelName;
047:
048: /** Collection of videos of the project */
049: private Set<Video> videos;
050:
051: public String getModelName() {
052: return modelName;
053: }
054:
055: public void setModelName(String modelName) {
056: this .modelName = modelName;
057: }
058:
059: public Model Model() {
060: return Model.REGISTERED.get(modelName);
061: }
062:
063: public String getProjectFile() {
064: return projectFile;
065: }
066:
067: public void setProjectFile(String projectFile) {
068: this .projectFile = projectFile;
069: }
070:
071: public String getProjectName() {
072: return ApolloUtil.getFileName(projectFile, false);
073: }
074:
075: public Set<Video> getVideos() {
076: if (videos == null) {
077: return Collections.emptySet();
078: }
079: return videos;
080: }
081:
082: public void setVideos(Set<Video> videos) {
083: this .videos = videos;
084: if (videos != null) {
085: for (Video video : videos) {
086: video.setProject(this );
087: }
088: }
089: }
090:
091: public boolean addVideo(Video video) {
092: if (videos == null) {
093: videos = new HashSet<Video>();
094: }
095: boolean ret = videos.add(video);
096: video.setProject(this );
097: setChanged(Project.class);
098: return ret;
099: }
100:
101: public boolean removeVideo(Video video) {
102: if (video == null) {
103: return false;
104: }
105: boolean ret = videos.remove(video);
106: video.setProject(null);
107: setChanged(Project.class);
108: return ret;
109: }
110:
111: void setChanged(Object arg) {
112: setChanged();
113: notifyObservers(arg);
114: }
115: }
|