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

updatE

parent 43613ffa
/**
* $Id: FCMarqueeHandler.java,v 1.23 2002-06-10 09:47:41 gchomat Exp $
* $Id: FCMarqueeHandler.java,v 1.24 2002-06-10 10:58:40 frederic Exp $
*
* Transmorpher
*
......@@ -146,7 +146,8 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
}
public void mouseReleased(MouseEvent event) {
EditCall dialog;
Channel channel;
//count++;
if(currentProcess != null){
......@@ -183,62 +184,58 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
//dialog = new EditCall((JFrame)(currentProcess.getTopLevelAncestor()),currentProcess,null,start,FCConstants.APPLYRULESET);
}
else if (applyQuery.isSelected())
{
//dialog = new EditCall((JFrame)(currentProcess.getTopLevelAncestor()),currentProcess,null,start,FCConstants.APPLYQUERY);
}
else if (edgeNormal.isSelected()){
//currentProcess.getModel().insert(null,null,null,null);
if(port != null && firstPort != null)
{
DefaultGraphCell c = (DefaultGraphCell)(port.getParentView()).getCell();
Call call = (Call)(c.getUserObject());
String name = "C"+call.getId();
channel = new Channel( name, (fr.fluxmedia.transmorpher.Graph.Process)currentTransformation );
((Process)currentTransformation).addChannel(channel);
DefaultGraphCell portOut = (DefaultGraphCell)firstPort.getCell();
DefaultGraphCell portIn = (DefaultGraphCell)port.getCell();
channel.setOut((Port)portOut.getUserObject());
channel.setIn((Port)portIn.getUserObject());
((Port)portIn.getUserObject()).setChannel(channel);
((Port)portOut.getUserObject()).setChannel(channel);
//if ((beginCell!=null)&&(endCell!=null)&&(!beginCell.equals(endCell))) {
//doConnectionSet(beginCell,endCell);}
Point p = currentProcess.fromScreen(new Point(start));
Point p2 = currentProcess.toScreen(new Point(current));
ArrayList list = new ArrayList();
list.add(p);
list.add(p2);
Map map = GraphConstants.createMap();
GraphConstants.setPoints(map, list);
Map viewMap = new Hashtable();
DefaultEdge cell = new DefaultEdge(channel);
viewMap.put(cell, map);
Object[] insert = new Object[]{cell};
ConnectionSet cs = new ConnectionSet();
if (firstPort != null)
cs.connect(cell, firstPort.getCell(), true);
if (port != null)
cs.connect(cell, port.getCell(), false);
currentProcess.getModel().insert(insert, cs, null, viewMap);
}
}
event.consume();
}
marquee.doClick();
firstPort = null;
port = null;
start = null;
current = null;
super.mouseReleased(event);
//System.out.println("MouseReleased End...");
updateGraphics();
}
{//dialog = new EditCall((JFrame)(currentProcess.getTopLevelAncestor()),(ProcessGraph)currentProcess,null,start,FCConstants.APPLYQUERY);}
}
else if (edgeNormal.isSelected()){
//currentProcess.getModel().insert(null,null,null,null);
DefaultGraphCell c = (DefaultGraphCell)(port.getParentView()).getCell();
Call call = (Call)(c.getUserObject());
String name = "C"+call.getId();
channel = new Channel( name, (fr.fluxmedia.transmorpher.Graph.Process)currentTransformation );
((Process)currentTransformation).addChannel(channel);
DefaultGraphCell portOut = (DefaultGraphCell)firstPort.getCell();
DefaultGraphCell portIn = (DefaultGraphCell)port.getCell();
channel.setOut((Port)portOut.getUserObject());
channel.setIn((Port)portIn.getUserObject());
((Port)portIn.getUserObject()).setChannel(channel);
((Port)portOut.getUserObject()).setChannel(channel);
//((Port)portIn.getUserObject()).setName(name);
//((Port)portOut.getUserObject()).setName(name);
//if ((beginCell!=null)&&(endCell!=null)&&(!beginCell.equals(endCell))) {
//doConnectionSet(beginCell,endCell);}
Point p = currentProcess.fromScreen(new Point(start));
Point p2 = currentProcess.toScreen(new Point(current));
ArrayList list = new ArrayList();
list.add(p);
list.add(p2);
Map map = GraphConstants.createMap();
GraphConstants.setPoints(map, list);
Map viewMap = new Hashtable();
DefaultEdge cell = new DefaultEdge(channel);
viewMap.put(cell, map);
Object[] insert = new Object[]{cell};
ConnectionSet cs = new ConnectionSet();
if (firstPort != null)
cs.connect(cell, firstPort.getCell(), true);
if (port != null)
cs.connect(cell, port.getCell(), false);
currentProcess.getModel().insert(insert, cs, null, viewMap);
}
event.consume();
}
marquee.doClick();
firstPort = null;
port = null;
start = null;
current = null;
super.mouseReleased(event);
updateGraphics();
//System.out.println("MouseReleased End...");
}
}
public void mouseMoved(MouseEvent event) {
......
/**
*
*$Id: FlowComposer.java,v 1.40 2002-06-10 09:47:42 gchomat Exp $
*$Id: FlowComposer.java,v 1.41 2002-06-10 10:58:40 frederic Exp $
*
* Transmorpher
*
......@@ -472,9 +472,10 @@ 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
{
......@@ -956,14 +957,12 @@ public class FlowComposer extends JPanel implements GraphModelListener,
public void graphChanged(GraphModelEvent e) {
//System.out.println("GraphModel" + e);
Object[] inserted = e.getChange().getInserted();
if (inserted != null && inserted.length > 0)
currentProcess.setSelectionCells(inserted);
if (inserted != null && inserted.length > 0)
{
DefaultGraphCell cell = (DefaultGraphCell)inserted[0];
System.out.println(cell.getUserObject());
}
currentProcess.setSelectionCells(inserted);
update();
}
......@@ -1555,13 +1554,22 @@ public class FlowComposer extends JPanel implements GraphModelListener,
}
protected static class FCWindowListener extends WindowAdapter{
public FCWindowListener() {
}
public void windowClosing(WindowEvent e){
//if(instances.size()==1)
//System.exit(0);
e.getWindow().dispose();
//System.out.println("win "+instances.indexOf(e.getWindow()));
}
// public void windowStateChanged(WindowEvent e) {((ProcessGraph)flow.currentProcess).updateCell(FCConstants.PORTINPUT); }
}
......@@ -1680,7 +1688,11 @@ public class FlowComposer extends JPanel implements GraphModelListener,
}
public void actionPerformed(ActionEvent e) {
((ProcessGraph)currentProcess).actionRL(FCConstants.PORTPROCESS,FCConstants.PORTOUTPUT);
}
protected void update(){
......@@ -1705,12 +1717,14 @@ public class FlowComposer extends JPanel implements GraphModelListener,
this.flow=flow;
}
public void actionPerformed(ActionEvent e) {
//sure that currentProcess != null
(currentProcess).createPort(FCConstants.PORTINPUT);
}
protected void update(){
public void actionPerformed(ActionEvent e) {
((ProcessGraph)currentProcess).actionRL(FCConstants.PORTPROCESS,FCConstants.PORTINPUT);
}
protected void update(){
if(currentProcess == null || (currentProcess).getUserObject() instanceof MainProcess)
{
setEnabled(false);
......@@ -1722,6 +1736,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
}
}
class ZoomAction extends AbstractAction {
......
/**
* $Id: ProcessGraph.java,v 1.20 2002-06-10 09:47:42 gchomat Exp $
* $Id: ProcessGraph.java,v 1.21 2002-06-10 10:58:40 frederic Exp $
*
* Transmorpher
*
......@@ -52,7 +52,7 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
// Undo Manager
protected GraphUndoManager undo;
protected DefaultGraphCell pCell = null;
/** boundsCube define the dimension of a squared form composant such as ApplyQuery, Merge and Dispatch.
* ie: this composant are included in square boxe
*/
......@@ -335,6 +335,7 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
return null;
}
/**
* Return the cell Neighboor of the vertex
* @param edge The edge between the vertex and his neighboor
......@@ -386,6 +387,18 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
return getView().getMapping(target, false);
}
public Object[] getSelectionCells() {
Object[] tmp = getSelectionModel().getSelectionCells();
ArrayList list = new ArrayList();
for (int i = 0; i <tmp.length; i++){
DefaultGraphCell cell = (DefaultGraphCell)tmp[i];
if ((!(cell instanceof PortProcessCell))&&(!(cell instanceof PortCell)))
list.add(tmp[i]);
}
return list.toArray();
}
/**
* Return all edges between two vertices.
*
......@@ -407,12 +420,11 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
public boolean isSingleId(String name){
Object[] roots = getAll();
//Observable
DefaultGraphCell cell;
Object userObject;
Call call;
for (int i = 0; i < roots.length; i++){
if (!(roots[i] instanceof Edge))
{
......@@ -423,10 +435,8 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
{
if(call.getId().equals(name))
return false;
}
}
}
}
return true;
}
......@@ -452,6 +462,22 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
return result;
}
public ArrayList getCellProcess(int portLocation) {
Object[] roots = getAll();
String user;
if (portLocation==FCConstants.PORTINPUT)
user="PInput";
else user="POutput";
ArrayList result = new ArrayList();
for (int i = 0; i < roots.length; i++){
if (((DefaultGraphCell)roots[i]).getUserObject().equals(user))
result.add(roots[i]);
}
return result;
}
/*
public void layoutPorts(Object vertex1,Object userObject) {
GraphView v = getView();
......@@ -512,6 +538,7 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
}
*/
/**
create a channel in the graph.
*/
......@@ -565,11 +592,12 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
v.edit(attributes);}
}
*/
/** add a Cell to the Graph
*
*/
public void addVertex(Object userObject,Point point,int number) {
public DefaultGraphCell addVertex(Object userObject,Point point,int type) {
int u = GraphConstants.PERCENT;
Rectangle bounds;
......@@ -577,7 +605,7 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
Map viewMap = new Hashtable();
// Create Vertex
switch (number) {
switch (type) {
case FCConstants.MERGE :
cell = new MergeCell(userObject);
bounds = new Rectangle(point,boundsCube);
......@@ -643,9 +671,10 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
addPort(cell,viewMap,FCConstants.PORTOUTPUT);
break;
case FCConstants.PORTPROCESS :
bounds = new Rectangle(point,boundsCube);
cell = new PortProcessCell(userObject);
bounds = new Rectangle(new Point(50,50),boundsPort);
addCell(cell,viewMap,bounds);
addPort(cell,viewMap,FCConstants.PORTOUTPUT);
break;
default: System.out.println("pas de vertex correspondant la string : FlowComposerGraph+meth addCell");break;
......@@ -653,20 +682,26 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
getModel().insert(new Object[]{cell}, null, null, viewMap);
FlowComposer.editing=true;
// updateProcess();
return cell;
}
public void addCell(DefaultGraphCell cell,Map viewMap, Rectangle bounds) {
Map map = GraphConstants.createMap();
if(cell instanceof PortProcessCell){
GraphConstants.setMoveable(map, false);
GraphConstants.setSizeable(map, false);
}
GraphConstants.setBounds(map, bounds);
Map map = GraphConstants.createMap();
if(cell instanceof PortProcessCell)
{
GraphConstants.setEditable(map,false);
GraphConstants.setMoveable(map, false);
GraphConstants.setSizeable(map, false);
}
GraphConstants.setBounds(map, bounds);
GraphConstants.setOpaque(map, false);
GraphConstants.setBorderColor(map, Color.black);
......@@ -690,38 +725,134 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
fr.fluxmedia.transmorpher.Graph.Port port=null;
int u = GraphConstants.PERCENT;
Map map = GraphConstants.createMap();
Call call = (Call)cell.getUserObject();
Call call = (Call)cell.getUserObject();
switch (type) {
case FCConstants.PORTINPUT :
GraphConstants.setOffset(map, new Point(0,(int) (u/2)));
if(call!=null){
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");
}
PortCell pc = new PortCell("",type);
PortCell pc = new PortCell(port,type);
viewMap.put(pc, map);
cell.add(pc);
}
/*
public void updatePorts(int type,DefaultGraphCell cell){
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);
}
}
}
else {
if (portLocation==FCConstants.PORTINPUT)
cell= addVertex("PInput",null,type);
else cell= addVertex("POutput",null,type);
addPortRL(cell,portLocation);
updateCell(portLocation);
}
}
public void updateCell(int portLocation){
GraphView v = getView();
ArrayList children = getPorts(cell,type);
Rectangle rect = getBounds();
System.out.println(rect);
ArrayList cell = getCellProcess(portLocation);
for (int i=0;i<cell.size();i++) {
Map map = GraphConstants.createMap();
Map attributes = new Hashtable();
if (portLocation==FCConstants.PORTINPUT)
GraphConstants.setBounds(map,new Rectangle(new Point(rect.width-15,(int)(rect.height*(i+1))/(cell.size()+1)),boundsPort));
else GraphConstants.setBounds(map,new Rectangle(new Point(0,(int)(rect.height*(i+1))/(cell.size()+1)),boundsPort));
CellView cellView = v.getMapping(cell.get(i),true);
attributes.put(cellView,map);
v.edit(attributes);
}
}
public void addPortRL(DefaultGraphCell cell,int type){
int index;
Call call = null;
fr.fluxmedia.transmorpher.Graph.Port port=null;
GraphView v = getView();
Map map = GraphConstants.createMap();
int u = GraphConstants.PERCENT;
GraphConstants.setOffset(map, new Point((int)(u/2),(int)(u/2)));
switch (type) {
case FCConstants.PORTINPUT :
if (cell.getUserObject().equals("PInput")) {
index = (((Process)userObject).inPorts().length()==0)?0:((Process)userObject).inPorts().length()-1;
port = new fr.fluxmedia.transmorpher.Graph.Port(null,((Process)userObject),index);
((Process)userObject).addIn(index,port);
}
else {
call = (Call)cell.getUserObject();
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 :
if (cell.getUserObject().equals("POutput")) {
index = (((Process)userObject).outPorts().length()==0)?0:((Process)userObject).outPorts().length()-1;
port = new fr.fluxmedia.transmorpher.Graph.Port(null,((Process)userObject),index);
((Process)userObject).addOut(index,port);
}
else {
call = (Call)cell.getUserObject();
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");
}
PortCell pc = new PortCell(port,type);
ParentMap parent = new ParentMap();
parent.addEntry(pc,cell);
Map viewMap = new Hashtable();
viewMap.put(pc,map);
getModel().insert(new Object[]{pc},null,parent,viewMap);
}
public void updatePort(DefaultGraphCell cell,int type){
GraphView v = getView();
ArrayList children = getPorts(cell,type);
for (int i=0;i<children.size();i++) {
Map map = GraphConstants.createMap();
int u = GraphConstants.PERCENT;
......@@ -730,7 +861,6 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
GraphConstants.setOffset(map,new Point(0,(int)(u*(i+1))/(children.size()+1)));
System.out.println(children.get(i));
CellView cellView = v.getMapping(children.get(i),true);
attributes.put(cellView,map);
}
else {
......@@ -742,7 +872,12 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
}
v.edit(attributes);
}
} */
}
/** add a Port to the Cell
*
......
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