Commit 5424787c authored by SAINT-MARCEL Frederic's avatar SAINT-MARCEL Frederic
Browse files

suppr 2 fichiers + RDF fini

parent 90e2a60d
/**
* $Id: FCProcessFactory.java,v 1.4 2002-05-23 15:38:54 frederic Exp $
* $Id: FCProcessFactory.java,v 1.5 2002-05-27 14:53:55 frederic Exp $
*
* Transmorpher
*
......@@ -36,7 +36,7 @@ import java.util.Hashtable;
import java.util.*;
import com.jgraph.JGraph;
import com.jgraph.graph.*;
import fr.fluxmedia.transmorpher.Files.*;
......@@ -44,20 +44,20 @@ public class FCProcessFactory implements ProcessFactory{
// The list of all process create with this factory
protected Hashtable listProcess ;
public FCProcessFactory(){
listProcess = new Hashtable();
}
public JGraph createProcess(Object userObject){
if(userObject != null)
{
GraphModel model = new ProcessGraphModel();
JGraph process = new ProcessGraph(model,null,userObject);
listProcess.put(((fr.fluxmedia.transmorpher.Graph.Process)userObject).getName(),process);
return process;
}
......@@ -70,7 +70,7 @@ public class FCProcessFactory implements ProcessFactory{
}
public JGraph getProcess(Object index){
if(listProcess.containsKey(index))
return (JGraph)(listProcess.get(index));
else
......@@ -80,12 +80,12 @@ public class FCProcessFactory implements ProcessFactory{
public Map getAllProcess(){
return listProcess;
}
public void generateFileRDF(ReadWrite file) {
file.Writeln("<?xml version=\"1.0\"?>");
file.Writeln("<rdf:RDF>");
file.Writeln(4,"xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"");
file.Writeln(4,"xmlns:s=\"http://description.org/schema/\">");
file.Writeln("<?xml version=\"1.0\" standalone=\"yes\"?>");
file.Writeln("<rdf:RDF");
file.Writeln(4,"xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns\"");
file.Writeln(4,"xmlns:s=\"http://www.w3.org/2000/01/rdf-schema\">");
Iterator it = ((getAllProcess()).values()).iterator();
while (it.hasNext()) {
Object process = it.next();
......
/**
*
* $Id: FlowComposer.java,v 1.20 2002-05-23 15:38:54 frederic Exp $
* $Id: FlowComposer.java,v 1.21 2002-05-27 14:53:55 frederic Exp $
*
* Transmorpher
*
......@@ -42,7 +42,7 @@ import com.jgraph.event.*;
//import Transmorpher
import fr.fluxmedia.transmorpher.Graph.*;
import fr.fluxmedia.transmorpher.Utils.*;
import fr.fluxmedia.transmorpher.Files.*;
import java.awt.*;
import java.beans.*;
......@@ -76,6 +76,8 @@ public class FlowComposer extends JPanel implements GraphModelListener,
//Used only if FlowComposer is an applet
//private boolean inAnApplet = true;
protected ParserRDF parser;
//Process Factory allow to create new Process
protected ProcessFactory processFactory;
......@@ -208,7 +210,9 @@ public class FlowComposer extends JPanel implements GraphModelListener,
transmorpher = new Transmorpher(filename,resource.getString("TRANSMORPHER_VERSION"),0,false);
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
parser = new ParserRDF();
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
this.setLayout(new BorderLayout());
......@@ -1032,6 +1036,8 @@ public class FlowComposer extends JPanel implements GraphModelListener,
ReadWrite file = new ReadWrite("fichier.rdf",ReadWrite.WRITE);
((FCProcessFactory)processFactory).generateFileRDF(file);
file.Close();
parser.newParse(file.getName());
parser.print();
}
}
......
/*
* Created by IntelliJ IDEA.
* User: administrateur
* Date: 22 mai 2002
* Time: 15:49:04
* To change template for new class use
* Code Style | Class Templates options (Tools | IDE Options).
*/
package fr.fluxmedia.flowcomposer;
// Imported SAX Classes
import org.xml.sax.Attributes;
import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.SAXException ;
import org.xml.sax.SAXParseException;
import org.xml.sax.helpers.XMLFilterImpl;
//Imported JAVA Classes
import java.io.*;
import java.util.Stack ;
public class Parser extends DefaultHandler {
/** The XML Parser class */
private static final String
DEFAULT_PARSER_NAME = "org.apache.xerces.parsers.SAXParser";
/** XML Parser */
javax.xml.parsers.SAXParser iParser = null;
/*------------------------------------------ CONSTRUCTOR -----------------------------*/
/** The constructor, build the XML Parser but not parse the document */
public Parser() {
try {
javax.xml.parsers.SAXParserFactory iParserFactory = javax.xml.parsers.SAXParserFactory.newInstance();
iParserFactory.setValidating(true);
iParserFactory.setNamespaceAware(true);
iParser = iParserFactory.newSAXParser();
} catch (javax.xml.parsers.ParserConfigurationException CNFE) {
System.out.println("FMParser :Error [" + CNFE +"]");
} catch (org.xml.sax.SAXException SaxE) {
System.out.println("FMParser :Error [" + SaxE +"]");
}
}
/*------------------------------------------- END CONSTRUCTOR ------------------------*/
/** Parse the document given in parameter */
public void newParse(String uri) {
try {
iParser.parse(uri,this);
} catch (SAXException SE) {
System.err.println("[FMParser]Erreur SAX(" + SE+")");
System.err.println("[FMParser]Erreur SAX(" + SE.getMessage()+")");
System.err.println("[FMParser]Erreur SAX(" + SE.getException()+")");
SE.printStackTrace();
} catch (java.io.IOException IOE) {
System.err.println("[FMParser]Erreur IO(" + IOE+")");
}
}
public void warning(SAXParseException exception)
throws SAXException
{
System.err.println("warning");
}
public void error(SAXParseException ex)
{
System.err.print("Error!! ");
System.err.println(ex);
}
public void fatalError(SAXParseException ex) throws SAXException
{
System.err.print("Fatal Error!! ");
System.err.println(ex);
}
}
/**
* $Id: ProcessGraph.java,v 1.8 2002-05-23 15:38:54 frederic Exp $
* $Id: ProcessGraph.java,v 1.9 2002-05-27 14:53:55 frederic Exp $
*
* Transmorpher
*
......@@ -42,6 +42,7 @@ import javax.swing.undo.UndoManager;
import fr.fluxmedia.transmorpher.Graph.Process;
import fr.fluxmedia.transmorpher.Graph.Call;
import fr.fluxmedia.transmorpher.Files.*;
public class ProcessGraph extends JGraph implements Comparator{
......@@ -587,7 +588,7 @@ public class ProcessGraph extends JGraph implements Comparator{
public void generateRDF(ReadWrite file) {
Object[] cells = getAll();
file.Writeln(4,"<rdf:Description about=\"#"+((Process)userObject).getName()+"\">");
file.Writeln(4,"<rdf:Description about=\""+((Process)userObject).getName()+"\">");
for (int i = 0; i < cells.length; i++){
if (cells[i] instanceof NormalEdge)
ChannelRDF(cells[i],file);
......@@ -606,10 +607,10 @@ public class ProcessGraph extends JGraph implements Comparator{
CellView cellview = v.getMapping(cell,false);
Map map = cellview.getAttributes();
Color color = GraphConstants.getBorderColor(map);
System.out.println(color);
file.Writeln(8,"<hasComponent>");
file.Writeln(11,"<rdf:Description about=\"#"+call.toString()+"\">");
file.Writeln(11,"<rdf:Description about=\""+call.toString()+"\">");
file.Writeln(14,"<s:color>"+color.toString()+"</s:color>");
file.Writeln(14,"<s:x>"+x+"</s:x>");
file.Writeln(14,"<s:y>"+y+"</s:y>");
......@@ -621,8 +622,8 @@ public class ProcessGraph extends JGraph implements Comparator{
file.Writeln(8,"<hasChannel>");
//file.Writeln(11,"<rdf:Description about=\"#"+((Call)((DefaultGraphCell)cell).getUserObject()).getId()+"\">");
// file.Writeln(14,"<s:color>"+color.toString()+"</s:color>");
file.Writeln(11,"</rdf:Description>");
//file.Writeln(14,"<s:color>"+color.toString()+"</s:color>");
//file.Writeln(11,"</rdf:Description>");
file.Writeln(8,"</hasChannel>");
}
......
/*
* Created by IntelliJ IDEA.
* User: administrateur
* Date: 22 mai 2002
* Time: 17:08:31
* To change template for new class use
* Code Style | Class Templates options (Tools | IDE Options).
*/
package fr.fluxmedia.flowcomposer;
import java.io.File;
import java.io.FileWriter;
import java.io.FileReader;
public class ReadWrite {
public static final int READ = 0 ;
public static final int WRITE = 1 ;
FileWriter vFileW = null;
FileReader vFileR = null;
String vFileName = null ;
int vMode = 0 ;
public ReadWrite(String pName,int pMode) {
vFileName = pName ;
vMode = pMode ;
try {
if (pMode == WRITE ) {
vFileW = new FileWriter(pName);
} else {
vFileR = new FileReader (pName);
}
} catch (java.io.IOException pE) {
if (pMode == WRITE ) {
System.err.println("[Save] " + pE );
} else {
System.err.println("[Load] " + pE );
}
}
}
public String getName() {
return vFileName ;
}
public void Write(String pString) {
try {
//System.err.print("[" +vFileName +"] : " +pString);
vFileW.write(pString);
} catch (java.io.IOException pE) {
System.err.println("[Save] " + pE );
}
}
public void Write(int Decalage,String pString) {
String vParam ="";
for (int i=0;i<Decalage;i++) {
vParam+=" ";
}
Write(vParam+pString);
}
public void Writeln(int Decalage,String pString) {
String vParam ="";
for (int i=0;i<Decalage;i++) {
vParam+=" ";
}
Writeln(vParam+pString);
}
public void Writeln(String pString) {
try {
//System.err.println("[" +vFileName +"] : " +pString+"\n");
vFileW.write(pString +"\n");
} catch (java.io.IOException pE) {
System.err.println("[Save] " + pE );
}
}
public void Writeln() {
try {
vFileW.write("\n");
} catch (java.io.IOException pE) {
System.err.println("[Save] " + pE );
}
}
public char [] Read() {
char[] chaine = null ;
try {
int Taillefichier = (int) (new File(vFileName).length());
chaine = new char[Taillefichier];
int longueur = vFileR.read(chaine);
} catch (java.io.IOException pE) {
System.err.println("[Load] " + pE );
}
return chaine ;
}
public void Close() {
try {
if (vMode == READ ) vFileR.close();
else vFileW.close();
} catch (java.io.IOException pE) {
System.err.println("[Save] " + pE );
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment