Commit 82650467 authored by Guillaume Chomat's avatar Guillaume Chomat
Browse files

begin implemented observer/observable for port

parent 9bfa4bb7
/**
*
*$Id: FlowComposer.java,v 1.42 2002-06-11 09:42:51 frederic Exp $
*$Id: FlowComposer.java,v 1.43 2002-06-11 13:28:08 gchomat Exp $
*
* Transmorpher
*
......@@ -472,10 +472,11 @@ public class FlowComposer extends JPanel implements GraphModelListener,
sp = (JScrollPane)(tabProcess.add(currentProcess.getName(),sp));
tabProcess.setSelectedComponent(sp);
currentProcess = (ProcessGraph)(sp.getViewport().getView());
undoHandler.setProcess(currentProcess);
undoHandler.setProcess(currentProcess);
}
else
{
......@@ -1554,14 +1555,14 @@ public class FlowComposer extends JPanel implements GraphModelListener,
}
protected static class FCWindowListener extends WindowAdapter{
public FCWindowListener() {
}
public void windowClosing(WindowEvent e){
e.getWindow().dispose();
......@@ -1688,11 +1689,11 @@ public class FlowComposer extends JPanel implements GraphModelListener,
}
public void actionPerformed(ActionEvent e) {
((ProcessGraph)currentProcess).actionRL(FCConstants.PORTPROCESS,FCConstants.PORTINPUT);
// ((ProcessGraph)currentProcess).actionRL(FCConstants.PORTPROCESS,FCConstants.PORTINPUT);
((ProcessGraph)currentProcess).newPort(FCConstants.PORTOUTPUT);
//((ProcessGraph)currentProcess).addOut();
}
protected void update(){
......@@ -1717,13 +1718,12 @@ public class FlowComposer extends JPanel implements GraphModelListener,
this.flow=flow;
}
public void actionPerformed(ActionEvent e) {
((ProcessGraph)currentProcess).actionRL(FCConstants.PORTPROCESS,FCConstants.PORTOUTPUT);
((ProcessGraph)currentProcess).newPort(FCConstants.PORTINPUT);
//((ProcessGraph)currentProcess).addIn();
//((ProcessGraph)currentProcess).actionRL(FCConstants.PORTPROCESS,FCConstants.PORTOUTPUT);
}
protected void update(){
if(currentProcess == null || (currentProcess).getUserObject() instanceof MainProcess)
{
......@@ -1736,7 +1736,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
}
}
class ZoomAction extends AbstractAction {
......
/**
* $Id: MergeCell.java,v 1.6 2002-06-11 09:38:57 gchomat Exp $
* $Id: MergeCell.java,v 1.7 2002-06-11 13:28:08 gchomat Exp $
*
* Transmorpher
*
......@@ -53,6 +53,27 @@ public class MergeCell extends DefaultGraphCell implements Observer{
}
public void newPort(int type){
if(userObject != null && userObject instanceof Merge)
{
Merge merge = (Merge)userObject;
Port port;
if(type == FCConstants.PORTOUTPUT)
{
port= new Port("",merge,FCConstants.PORTOUTPUT);
merge.addOut(port);
}
else
{
port= new Port("",merge,FCConstants.PORTINPUT);
merge.addIn(port);
}
}
}
/*public String toString(){
if(userObject instanceof Call)
......
/**
* $Id: ProcessGraph.java,v 1.26 2002-06-11 09:42:51 frederic Exp $
* $Id: ProcessGraph.java,v 1.27 2002-06-11 13:28:08 gchomat Exp $
*
* Transmorpher
*
......@@ -51,6 +51,9 @@ import fr.fluxmedia.transmorpher.Graph.ApplyProcess;
import fr.fluxmedia.transmorpher.Graph.ApplyRuleset;
import fr.fluxmedia.transmorpher.Graph.ApplyExternal;
import fr.fluxmedia.transmorpher.Graph.ApplyQuery;
import fr.fluxmedia.transmorpher.Graph.CallImpl;
import fr.fluxmedia.transmorpher.Graph.Port;
import fr.fluxmedia.transmorpher.Graph.TransformationImpl;
import fr.fluxmedia.transmorpher.Files.*;
......@@ -209,6 +212,17 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
addVertex(arg,FCConstants.APPLYRULESET);
}
else if(arg instanceof Port)
{
Port port = (Port)arg;
if (port.getType()==FCConstants.PORTINPUT)
addVertex("PInput",FCConstants.PORTPROCESS);
else
addVertex("POutput",FCConstants.PORTPROCESS);
updateCellProcess(port.getType());
}
}
}
......@@ -621,13 +635,21 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
switch (type) {
case FCConstants.MERGE :
cell = new MergeCell(userObject);
if(userObject instanceof CallImpl)
((CallImpl)userObject).addObserver((MergeCell)cell);
bounds = new Rectangle(position,boundsCube);
attributes = commonAttributres(cell,bounds);
addPort(cell,viewMap,FCConstants.PORTOUTPUT);
// updatePorts(FCConstants.PORTOUTPUT,cell);
((MergeCell)cell).newPort(FCConstants.PORTOUTPUT);
// addPort(cell,viewMap,FCConstants.PORTOUTPUT);
// updatePorts(FCConstants.PORTOUTPUT,cell);
break;
case FCConstants.GENERATE :
cell = new GenerateCell(userObject);
if(userObject instanceof CallImpl)
((CallImpl)userObject).addObserver((GenerateCell)cell);
bounds = new Rectangle(position,boundsRect);
attributes = commonAttributres(cell,bounds);
addPort(cell,viewMap,FCConstants.PORTOUTPUT);
......@@ -635,18 +657,27 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
break;
case FCConstants.SERIALIZE :
cell = new SerializeCell(userObject);
bounds = new Rectangle(position,boundsRect);
if(userObject instanceof CallImpl)
((CallImpl)userObject).addObserver((SerializeCell)cell);
bounds = new Rectangle(position,boundsRect);
attributes = commonAttributres(cell,bounds);
addPort(cell,viewMap,FCConstants.PORTINPUT);
break;
case FCConstants.DISPATCH :
cell = new DispatchCell(userObject);
if(userObject instanceof CallImpl)
((CallImpl)userObject).addObserver((DispatchCell)cell);
bounds = new Rectangle(position,boundsCube);
attributes = commonAttributres(cell,bounds);
addPort(cell,viewMap,FCConstants.PORTINPUT);
break;
case FCConstants.APPLYEXTERNAL :
cell = new ApplyExternalCell(userObject);
if(userObject instanceof CallImpl)
((CallImpl)userObject).addObserver((ApplyExternalCell)cell);
bounds = new Rectangle(position,boundsRect);
attributes = commonAttributres(cell,bounds);
......@@ -661,24 +692,38 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
break;
case FCConstants.APPLYPROCESS :
cell = new ApplyProcessCell(userObject);
bounds = new Rectangle(position,boundsRect);
if(userObject instanceof CallImpl)
((CallImpl)userObject).addObserver((ApplyProcessCell)cell);
bounds = new Rectangle(position,boundsRect);
attributes = commonAttributres(cell,bounds);
break;
case FCConstants.APPLYRULESET :
cell = new ApplyRulesetCell(userObject);
bounds = new Rectangle(position,boundsRect);
if(userObject instanceof CallImpl)
((CallImpl)userObject).addObserver((ApplyRulesetCell)cell);
bounds = new Rectangle(position,boundsRect);
attributes = commonAttributres(cell,bounds);
addPort(cell,viewMap,FCConstants.PORTINPUT);
addPort(cell,viewMap,FCConstants.PORTOUTPUT);
break;
case FCConstants.APPLYQUERY :
cell = new ApplyQueryCell(userObject);
bounds = new Rectangle(position,boundsCube);
if(userObject instanceof CallImpl)
((CallImpl)userObject).addObserver((ApplyQueryCell)cell);
bounds = new Rectangle(position,boundsCube);
attributes = commonAttributres(cell,bounds);
addPort(cell,viewMap,FCConstants.PORTINPUT);
addPort(cell,viewMap,FCConstants.PORTOUTPUT);
break;
case FCConstants.PORTPROCESS :
cell = new PortProcessCell(userObject);
/* if(userObject instanceof CallImpl)
((CallImpl)userObject).addObserver((PortProcessCell)cell);
*/
bounds = new Rectangle(position,boundsCube);
attributes = commonAttributres(cell,bounds);
addPort(cell,viewMap,FCConstants.PORTOUTPUT);
......@@ -708,47 +753,57 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
GraphConstants.setOpaque(map, false);
GraphConstants.setBorderColor(map, Color.black);
return map;
}
public void createPort(int type)
{
if(getSelectionCount()==0)
{
//addVertex(null,new Point(0,100),FCConstants.PORTPROCESS);
}
else
{
Map map = GraphConstants.createMap();
public void newPort(int type){
Object[] tmp = getSelectionCells();
DefaultGraphCell cell;
String name ="";
Port port ;
if (tmp.length != 0) {
for (int i = 0; i <tmp.length; i++){
cell = (DefaultGraphCell)tmp[i];
if (cell instanceof MergeCell && cell.getUserObject() instanceof Call){
Merge merge =(Merge)cell.getUserObject();
port = new Port(name,(Call)cell.getUserObject(),type);
merge.addIn(port);
}
}
}
else {
TransformationImpl transformation = (TransformationImpl)userObject;
port = new Port(name,transformation,type);
if (type==FCConstants.PORTINPUT)
{
transformation.addIn(port);
}
else
{
transformation.addOut(port);
}
}
}
public void addPort(DefaultGraphCell cell,Map viewMap, int type) {
int index;
fr.fluxmedia.transmorpher.Graph.Port port=null;
int u = GraphConstants.PERCENT;
Map map = GraphConstants.createMap();
Call call = (Call)cell.getUserObject();
switch (type) {
case FCConstants.PORTINPUT :
GraphConstants.setOffset(map, new Point(0,(int) (u/2)));
if(call!=null){
index = (call.inPorts().length()==0)?0:call.inPorts().length()-1;
port = new fr.fluxmedia.transmorpher.Graph.Port(null,call,index);
call.inPorts().addPort(port);
}
break;
case FCConstants.PORTOUTPUT :
GraphConstants.setOffset(map, new Point(u,(int) (u/2)));
if(call!=null){
index = (call.outPorts().length()==0)?0:call.outPorts().length()-1;
port = new fr.fluxmedia.transmorpher.Graph.Port(null,call,index);
call.outPorts().addPort(port);
}
break;
default : System.out.println("type de port inconnu : meth addPort");
}
......@@ -759,17 +814,18 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
}
public void actionRL(int type,int portLocation){
/*public void actionRL(int type,int portLocation){
Object[] tmp = getSelectionCells();
DefaultGraphCell cell;
if (tmp.length!=0) {
for (int i = 0; i <tmp.length; i++){
cell = (DefaultGraphCell)tmp[i];
if (!(cell instanceof NormalEdge)){
cell = (DefaultGraphCell)tmp[i];
addPortRL(cell,portLocation);
updatePort(cell,portLocation);
if (cell instanceof MergeCell)){
addPortRL(cell,portLocation);
updatePort(cell,portLocation);
}
}
}
......@@ -780,7 +836,7 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
addPortRL(cell,portLocation);
updateCellProcess(portLocation);
}
}
}*/
public void addPortRL(DefaultGraphCell cell,int type){
int index;
......
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