Commit 91473b08 authored by Guillaume Chomat's avatar Guillaume Chomat
Browse files

start of link with transmorpher

parent 2d4d807a
......@@ -322,9 +322,16 @@
</section>
<section><title>Channels</title>
<para></para>
<para>Les channels seront représentées par des simples traits entre ports.</para>
</section>
<section><title>Process</title>
<para>Les ports des process seront représentés....</para>
</section>
</section>
......
/**
* $Id: ApplyExternalRenderer.java,v 1.5 2002-04-15 06:42:04 serge Exp $
* $Id: ApplyExternalRenderer.java,v 1.6 2002-05-22 16:49:53 gchomat Exp $
*
* Transmorpher
*
......@@ -27,20 +27,28 @@
* User: gchomat
* Date: Apr 8, 2002
* Time: 11:04:07 AM
* To change template for new class use
* To change template for new class use
* Code Style | Class Templates options (Tools | IDE Options).
*/
package fr.fluxmedia.flowcomposer;
import com.jgraph.graph.VertexRenderer;
import com.jgraph.graph.GraphConstants;
import com.jgraph.graph.CellView;
import com.jgraph.graph.VertexView;
import com.jgraph.JGraph;
import java.awt.*;
public class ApplyExternalRenderer extends VertexRenderer {
public void paint(Graphics g) {
int b = borderWidth;
public ApplyExternalRenderer(){
super();
}
public void paint(Graphics g) {
int b = borderWidth;
Graphics2D g2 = (Graphics2D) g;
Dimension d = getSize();
boolean tmp = selected;
......@@ -52,7 +60,7 @@ public class ApplyExternalRenderer extends VertexRenderer {
setBorder(null);
setOpaque(false);
selected = false;
super.paint(g);
super.paint(g);
} finally {
selected = tmp;
}
......@@ -62,11 +70,41 @@ public class ApplyExternalRenderer extends VertexRenderer {
g.drawRect(b-1, b-1, d.width-b, d.height-b);
g.setColor((Color)(GraphConstants.getBackground(view.getAttributes())));
g.fillRect(b-1, b-1, d.width-b, d.height-b);
}
}
if (selected) {
g2.setStroke(GraphConstants.SELECTION_STROKE);
g.setColor(graph.getHighlightColor());
g.drawRect(b-1, b-1, d.width-b, d.height-b);
}
}
public Component getRendererComponent(JGraph graph,
CellView view, boolean sel,
boolean focus, boolean preview)
{
if (view instanceof VertexView) {
this.view = (VertexView) view;
setComponentOrientation(graph.getComponentOrientation());
if (graph.getEditingCell() != view.getCell()) {
Object label = graph.convertValueToString(view.getCell());
if (label != null)
setText(label.toString());
else
setText(null);
} else
setText(null);
this.graph = graph;
this.hasFocus = focus;
this.selected = sel;
this.preview = preview;
if (this.view.isLeaf())
installAttributes(view);
else {
setBorder(null);
setOpaque(false);
}
return this;
}
return null;
}
}
/**
* $Id: ApplyExternalView.java,v 1.6 2002-04-15 10:14:11 gchomat Exp $
* $Id: ApplyExternalView.java,v 1.7 2002-05-22 16:49:53 gchomat Exp $
*
* Transmorpher
*
......@@ -51,7 +51,8 @@ public class ApplyExternalView extends VertexView {
public ApplyExternalView(Object cell, JGraph graph, CellMapper cm) {
super(cell, graph, cm);
changeColor(Color.lightGray);
//setBackgroundColor(Color.lightGray);
//setForegroundColor(Color.white);
}
/**
......@@ -73,11 +74,18 @@ public class ApplyExternalView extends VertexView {
return renderer;
}
public void changeColor(Color c){
public void setBackgroundColor(Color c){
Map map = GraphConstants.createMap();
GraphConstants.setBackground(map,c);
GraphConstants.applyMap(map,attributes);
}
public void setForegroundColor(Color c){
Map map = GraphConstants.createMap();
GraphConstants.setForeground(map,c);
GraphConstants.applyMap(map,attributes);
}
}
/**
* $Id: FCMarqueeHandler.java,v 1.6 2002-05-21 09:44:32 frederic Exp $
* $Id: FCMarqueeHandler.java,v 1.7 2002-05-22 16:49:53 gchomat Exp $
*
* Transmorpher
*
......@@ -29,6 +29,9 @@
package fr.fluxmedia.flowcomposer;
import fr.fluxmedia.transmorpher.Graph.Process;
import fr.fluxmedia.transmorpher.Graph.Port;
import fr.fluxmedia.transmorpher.Graph.*;
import javax.swing.*;
import com.jgraph.JGraph;
......@@ -45,9 +48,17 @@ import java.io.*;
*/
public class FCMarqueeHandler extends BasicMarqueeHandler {
protected JGraph currentProcess;
protected Process currentTransformation;
public JGraph currentProcess;
// temporary
protected int count=0;
protected Call currentCall;
public transient JToggleButton marquee = new JToggleButton();
public transient JToggleButton generate = new JToggleButton();
public transient JToggleButton serialize = new JToggleButton();
......@@ -65,11 +76,21 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
protected Point start, current;
protected Object beginCell, endCell;
public FCMarqueeHandler(){
}
public void setCurrentProcess(Object process){
//if(process instanceof ProcessGraph)
//{
currentProcess = (ProcessGraph)process;
//}
if(process instanceof ProcessGraph)
{
currentProcess = (ProcessGraph)process;
if(((ProcessGraph)currentProcess).getUserObject()!=null && ((ProcessGraph)currentProcess).getUserObject() instanceof Process){
currentTransformation = (Process)(((ProcessGraph)currentProcess).getUserObject());
}
System.out.println("currentTransformation "+currentTransformation);
}
}
public JGraph getCurrentProcess(){
......@@ -123,31 +144,75 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
}
public void mouseReleased(MouseEvent event) {
count++;
if(currentProcess != null)
{
endCell= currentProcess.getFirstCellForLocation(event.getX(), event.getY());
if (event != null && !event.isConsumed() && !marquee.isSelected()) {
if (merge.isSelected())
((ProcessGraph)currentProcess).addVertex("",start,ProcessGraph.MERGE);
{
currentCall = new Merge("merge"+count,"concat",currentTransformation);
if(((ProcessGraph)currentProcess).getUserObject() instanceof Process)
((Process)(((ProcessGraph)currentProcess).getUserObject())).addCall(currentCall);
((ProcessGraph)currentProcess).addVertex(currentCall,start,ProcessGraph.MERGE);
}
else if (generate.isSelected())
((ProcessGraph)currentProcess).addVertex("",start,ProcessGraph.GENERATE);
{
currentCall = new Generate("generate"+count,"readfile",currentTransformation,1,"/local_home/gchomat/transmorpher/samples/biblio/input/bibexmo.xml");
if(((ProcessGraph)currentProcess).getUserObject() instanceof Process)
((Process)(((ProcessGraph)currentProcess).getUserObject())).addCall(currentCall);
((ProcessGraph)currentProcess).addVertex(currentCall,start,ProcessGraph.GENERATE);
}
else if (serialize.isSelected())
((ProcessGraph)currentProcess).addVertex("",start,ProcessGraph.SERIALYSE);
{
currentCall = new Serialize("serialize"+count,"writefile",currentTransformation,1,"test.xml");
if(((ProcessGraph)currentProcess).getUserObject() instanceof Process)
((Process)(((ProcessGraph)currentProcess).getUserObject())).addCall(currentCall);
((ProcessGraph)currentProcess).addVertex(currentCall,start,ProcessGraph.SERIALYSE);
}
else if (dispatch.isSelected())
((ProcessGraph)currentProcess).addVertex("",start,ProcessGraph.DISPATCH);
{
currentCall = new Dispatch("dispatch"+count,"broadcast",currentTransformation);
if(((ProcessGraph)currentProcess).getUserObject() instanceof Process)
((Process)(((ProcessGraph)currentProcess).getUserObject())).addCall(currentCall);
((ProcessGraph)currentProcess).addVertex(currentCall,start,ProcessGraph.DISPATCH);
}
else if (applyExternal.isSelected())
((ProcessGraph)currentProcess).addVertex("",start,ProcessGraph.APPLYEXTERNAL);
{
currentCall = new ApplyExternal("applyExternal"+count,"xslt","/local_home/gchomat/transmorpher/samples/biblio/xslt/sort-ty.xsl",currentTransformation);
if(((ProcessGraph)currentProcess).getUserObject() instanceof Process)
((Process)(((ProcessGraph)currentProcess).getUserObject())).addCall(currentCall);
((ProcessGraph)currentProcess).addVertex(currentCall,start,ProcessGraph.APPLYEXTERNAL);
}
else if (applyProcess.isSelected())
((ProcessGraph)currentProcess).addVertex("",start,ProcessGraph.APPLYPROCESS);
{
currentCall = new ApplyProcess("applyProcess"+count,"no",currentTransformation);
if(((ProcessGraph)currentProcess).getUserObject() instanceof Process)
((Process)(((ProcessGraph)currentProcess).getUserObject())).addCall(currentCall);
((ProcessGraph)currentProcess).addVertex(currentCall,start,ProcessGraph.APPLYPROCESS);
}
else if (applyRuleset.isSelected())
((ProcessGraph)currentProcess).addVertex("",start,ProcessGraph.APPLYRULESET);
{
currentCall = new ApplyRuleset("applyRuleset"+count,"no",currentTransformation);
if(((ProcessGraph)currentProcess).getUserObject() instanceof Process)
((Process)(((ProcessGraph)currentProcess).getUserObject())).addCall(currentCall);
((ProcessGraph)currentProcess).addVertex(currentCall,start,ProcessGraph.APPLYRULESET);
}
else if (applyQuery.isSelected())
((ProcessGraph)currentProcess).addVertex("",start,ProcessGraph.APPLYQUERY);
{
currentCall = new ApplyQuery("applyQuery"+count,"tmq",currentTransformation);
if(((ProcessGraph)currentProcess).getUserObject() instanceof Process)
((Process)(((ProcessGraph)currentProcess).getUserObject())).addCall(currentCall);
((ProcessGraph)currentProcess).addVertex(currentCall,start,ProcessGraph.APPLYQUERY);
}
else if (edgeNormal.isSelected()) {
if (beginCell!=null&&endCell!=null) {
doConnectionSet(beginCell,endCell);
}
}
event.consume();
......@@ -178,13 +243,18 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
Point p,p2 = null;
Rectangle rect,rect2;
rect=currentProcess.getCellBounds(cell);
Call tCallOut;
Call tCallIn;
rect=currentProcess.getCellBounds(cell);
rect2=currentProcess.getCellBounds(cell2);
int port = (((ProcessGraph)currentProcess).getPorts(cell,"output")).size();
int port = (((ProcessGraph)currentProcess).getPorts(cell,"output")).size();
int port2 = (((ProcessGraph)currentProcess).getPorts(cell2,"input")).size();
System.out.println(port+"premier");
System.out.println(port2+"deuxieme");
if ((cell instanceof SerializeCell)||(cell2 instanceof GenerateCell))
//System.out.println(port+"premier");
//System.out.println(port2+"deuxieme");
if ((cell instanceof SerializeCell)||(cell2 instanceof GenerateCell))
System.out.println("pas de port en entre (resp. sortie)");
else if ((port==1)&&((cell instanceof MergeCell)||(cell instanceof ApplyRulesetCell)
||(cell instanceof ApplyQueryCell)||(cell instanceof GenerateCell)))
......@@ -194,12 +264,30 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
System.out.println("1 seul port de sortie pour la connection");
else {
((ProcessGraph)currentProcess).addPort("output",(DefaultGraphCell)cell);
((ProcessGraph)currentProcess).addPort("input",(DefaultGraphCell)cell2);
p= new Point(rect.x+rect.width/2,rect.y+rect.height/2);
p2= new Point(rect2.x+rect2.width/2,rect2.y+rect2.height/2);
tCallOut = (Call)(((DefaultGraphCell)cell).getUserObject());
tCallIn = (Call)(((DefaultGraphCell)cell2).getUserObject());
//System.out.println("tCallIn "+tCallIn);
//System.out.println("tCallOut "+tCallOut);
int indexIn = (tCallIn.inPorts().length()==0)?0:tCallIn.inPorts().length()-1;
int indexOut = (tCallOut.outPorts().length()==0)?0:tCallOut.outPorts().length()-1;
tCallIn.inPorts().addPort(new Port("C"+tCallIn.getId(),tCallIn,indexIn));
tCallOut.outPorts().addPort(new Port("C"+tCallIn.getId(),tCallOut,indexOut));
/* c = new Channel( name, (fr.fluxmedia.transmorpher.Graph.Process)currentTransformation );
((fr.fluxmedia.transmorpher.Graph.Process)currentTransformation).addChannel( c );
c.setOut( p );
p.setChannel( c );*/
((ProcessGraph)currentProcess).addPort("output",(DefaultGraphCell)cell);
((ProcessGraph)currentProcess).addPort("input",(DefaultGraphCell)cell2);
p= new Point(rect.x+rect.width/2,rect.y+rect.height/2);
p2= new Point(rect2.x+rect2.width/2,rect2.y+rect2.height/2);
Point p3 = currentProcess.fromScreen(new Point(p));
Point p4 = currentProcess.fromScreen(new Point(p2));
ArrayList list = new ArrayList();
......@@ -211,15 +299,15 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
NormalEdge edge = new NormalEdge();
viewMap.put(edge, map);
Object[] insert = new Object[]{edge};
ConnectionSet cs = new ConnectionSet();
System.out.println("point p "+p);
System.out.println("point p2 "+p2);
ConnectionSet cs = new ConnectionSet();
//System.out.println("point p "+p);
//System.out.println("point p2 "+p2);
cs.connect(edge,currentProcess.getPortForLocation(p.x,p.y), true);
cs.connect(edge,currentProcess.getPortForLocation(p2.x,p2.y), false);
currentProcess.getModel().insert(insert, cs, null, viewMap);
((ProcessGraph)currentProcess).layoutPorts(cell,"output");
((ProcessGraph)currentProcess).layoutPorts(cell,"output");
((ProcessGraph)currentProcess).layoutPorts(cell2,"input");
}
......
/**
* $Id: FCProcessFactory.java,v 1.2 2002-05-16 14:14:53 gchomat Exp $
* $Id: FCProcessFactory.java,v 1.3 2002-05-22 16:49:53 gchomat Exp $
*
* Transmorpher
*
......@@ -45,7 +45,6 @@ public class FCProcessFactory implements ProcessFactory{
// The list of all process create with this factory
protected Hashtable listProcess ;
public FCProcessFactory(){
listProcess = new Hashtable();
......@@ -59,7 +58,7 @@ public class FCProcessFactory implements ProcessFactory{
GraphModel model = new ProcessGraphModel();
JGraph process = new ProcessGraph(model,null,userObject);
listProcess.put(userObject,process);
listProcess.put(((fr.fluxmedia.transmorpher.Graph.Process)userObject).getName(),process);
return process;
}
else return null;
......
/**
*
* $Id: FlowComposer.java,v 1.17 2002-05-16 14:14:53 gchomat Exp $
* $Id: FlowComposer.java,v 1.18 2002-05-22 16:49:53 gchomat Exp $
*
* Transmorpher
*
......@@ -41,6 +41,7 @@ import com.jgraph.event.*;
//import Transmorpher
import fr.fluxmedia.transmorpher.Graph.*;
import fr.fluxmedia.transmorpher.Utils.Parameters;
import java.awt.*;
import java.beans.*;
......@@ -122,6 +123,12 @@ public class FlowComposer extends JPanel implements GraphModelListener,
/**Default height of the app*/
public static final int PREFERRED_HEIGHT = 400;
public static final int MAIN = 1;
public static final int SERVLET = 2;
public static final int TRANSFORMER = 3;
public static final int PROCESS = 4;
/**
* Suffix applied to the key used in resource file
* lookups for a label.
......@@ -248,7 +255,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
//Init the main process
addProcess(new String("main process"));
addProcess(new String("main"),MAIN);
// Add the Graph as Center Component
panel.add(tabProcess, BorderLayout.CENTER);
......@@ -323,29 +330,40 @@ public class FlowComposer extends JPanel implements GraphModelListener,
return new FlowComposer(filename, model);
}
public void addProcess(Object userObject){
public void addProcess(String name, int type){
UndoHandler undoHandler;
JScrollPane sp ;
Transformation process = null;
Transformation process;
switch(type)
{
case MAIN :
process = new fr.fluxmedia.transmorpher.Graph.Main(name,transmorpher);
if ( transmorpher.getMain() == null) {
transmorpher.setMain((MainProcess)process);
}
break;
case PROCESS:
process = new fr.fluxmedia.transmorpher.Graph.Process(name,transmorpher);
transmorpher.addTransformation(name,process);
break;
}
if(tabProcess != null )
{
currentProcess = processFactory.createProcess(userObject);
currentProcess = processFactory.createProcess(process);
((ProcessGraph)currentProcess).setMarqueeHandler(marqueeHandler);
marqueeHandler.setCurrentProcess(currentProcess);
//marqueeHandler.setCurrentProcess(currentProcess);
undoHandler = new UndoHandler();
registerListeners(currentProcess);
currentProcess.getModel().addUndoableEditListener(undoHandler);
sp = new JScrollPane(currentProcess);
sp = (JScrollPane)(tabProcess.add((String)userObject,sp));
sp = (JScrollPane)(tabProcess.add(process.getName(),sp));
tabProcess.setSelectedComponent(sp);
currentProcess = (ProcessGraph)(sp.getViewport().getView());
marqueeHandler.setCurrentProcess(currentProcess);
//marqueeHandler.setCurrentProcess(currentProcess);
undoHandler.setProcess(currentProcess);
}
else
......@@ -927,8 +945,9 @@ public class FlowComposer extends JPanel implements GraphModelListener,
try {
if(currentProcess!= null & ((ProcessGraph)currentProcess).getUndoManager()!=null)
((ProcessGraph)currentProcess).getUndoManager().redo(getView());
{
((ProcessGraph)currentProcess).getUndoManager().redo(getView());
}
} catch (CannotRedoException ex) {
ex.printStackTrace();
......@@ -1004,7 +1023,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
}
public void actionPerformed(ActionEvent e) {
transmorpher.generateXML();
}
}
......@@ -1071,8 +1090,14 @@ public class FlowComposer extends JPanel implements GraphModelListener,
}
public void actionPerformed(ActionEvent e) {
}
/* try{
String reloc = "";
transmorpher.generateExec(reloc);
Parameters p = generateParameters();
transmorpher.exec(p);
}
catch(Exception ex){ex.printStackTrace();}*/
}
}
class CompileAction extends AbstractAction {
......@@ -1137,7 +1162,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
Alert.show(null,resource.getString("UNIQUE_NAME_PROCESS"),resource.getString("WARNING"),JOptionPane.WARNING_MESSAGE);
else
{
addProcess(name);
addProcess(name,PROCESS);
}
}
}
......
/**
* $Id: GenerateCell.java,v 1.3 2002-05-02 12:24:03 frederic Exp $
* $Id: GenerateCell.java,v 1.4 2002-05-22 16:49:53 gchomat Exp $
*
* Transmorpher
*
......@@ -41,7 +41,6 @@ public class GenerateCell extends DefaultGraphCell {
}
public GenerateCell(Object userObject) {
super(userObject);
super(userObject);
}
}
/**
* $Id: MergeCell.java,v 1.3 2002-04-30 13:12:29 gchomat Exp $
* $Id: MergeCell.java,v 1.4 2002-05-22 16:49:53 gchomat Exp $
*
* Transmorpher
*
......@@ -26,6 +26,10 @@ package fr.fluxmedia.flowcomposer;
import com.jgraph.graph.DefaultGraphCell;
import fr.fluxmedia.transmorpher.Graph.*;
public class MergeCell extends DefaultGraphCell {
public MergeCell() {
......@@ -35,5 +39,20 @@ public class MergeCell extends DefaultGraphCell {
public MergeCell(Object userObject) {
super(userObject);
}
/*public String toString(){
if(userObject instanceof Call)
{
System.out.println("id "+((Call)userObject).toString());
return ((Call)userObject).toString();
}
else
{
return "";
}
}*/
}
/**
* $Id: MergeRenderer.java,v 1.4 2002-05-02 12:24:03 frederic Exp $
* $Id: MergeRenderer.java,v 1.5 2002-05-22 16:49:53 gchomat Exp $