001: /**
002: * LibreSource
003: * Copyright (C) 2004-2008 Artenum SARL / INRIA
004: * http://www.libresource.org - contact@artenum.com
005: *
006: * This file is part of the LibreSource software,
007: * which can be used and distributed under license conditions.
008: * The license conditions are provided in the LICENSE.TXT file
009: * at the root path of the packaging that enclose this file.
010: * More information can be found at
011: * - http://dev.libresource.org/home/license
012: *
013: * Initial authors :
014: *
015: * Guillaume Bort / INRIA
016: * Francois Charoy / Universite Nancy 2
017: * Julien Forest / Artenum
018: * Claude Godart / Universite Henry Poincare
019: * Florent Jouille / INRIA
020: * Sebastien Jourdain / INRIA / Artenum
021: * Yves Lerumeur / Artenum
022: * Pascal Molli / Universite Henry Poincare
023: * Gerald Oster / INRIA
024: * Mariarosa Penzi / Artenum
025: * Gerard Sookahet / Artenum
026: * Raphael Tani / INRIA
027: *
028: * Contributors :
029: *
030: * Stephane Bagnier / Artenum
031: * Amadou Dia / Artenum-IUP Blois
032: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
033: */package com.artenum.so6.dataflow.graph;
034:
035: import com.artenum.graph.impl.DefaultGraphModel;
036:
037: import java.util.ArrayList;
038: import java.util.Iterator;
039: import java.util.Properties;
040:
041: /**
042: * @author seb
043: */
044: public class So6SimpleGraphModel extends DefaultGraphModel {
045: private ArrayList pathNodeList = null;
046: private So6Node currentNode;
047: private So6Node root;
048:
049: public So6SimpleGraphModel() {
050: super ();
051: pathNodeList = new ArrayList();
052: }
053:
054: public So6Node getRoot() {
055: return root;
056: }
057:
058: private void commonManagingNode() {
059: pathNodeList.add(currentNode);
060:
061: if (root == null) {
062: root = currentNode;
063: } else {
064: So6Node node = (So6Node) pathNodeList.get(pathNodeList
065: .size() - 2);
066: node.connectTo(currentNode);
067: }
068:
069: insertCell(currentNode);
070: }
071:
072: public void clear() {
073: super .clear();
074: pathNodeList.clear();
075: root = null;
076: }
077:
078: public void createSynchronizer(Properties attributes) {
079: currentNode = new SynchronizerNode(attributes);
080: commonManagingNode();
081: }
082:
083: public void createConnection(Properties attributes) {
084: currentNode = new ConnectionNode(attributes);
085: commonManagingNode();
086: }
087:
088: public void createWorkspace(Properties attributes) {
089: currentNode = new WorkspaceNode(attributes);
090: commonManagingNode();
091: }
092:
093: public void endElement() {
094: pathNodeList.remove(pathNodeList.size() - 1);
095: }
096:
097: public void updateNodes() {
098: for (Iterator i = getCellList().iterator(); i.hasNext();) {
099: ((So6Node) i.next()).updateNode();
100: }
101: }
102: }
|