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

corrected problem with port process

parent ce29b6c5
/**
* $Id: FCConstants.java,v 1.7 2002-06-13 12:04:50 gchomat Exp $
* $Id: FCConstants.java,v 1.8 2002-06-14 09:26:48 gchomat Exp $
*
* Transmorpher
*
......@@ -33,14 +33,14 @@ import java.util.Hashtable;
public class FCConstants{
public static final String NMERGE = "Merge";
public static final String NGENERATE = "Generate";
public static final String NSERIALIZE = "Serialize";
public static final String NDISPATCH = "Dispatch";
public static final String NAPPLYQUERY = "ApplyQuery";
public static final String NAPPLYPROCESS = "ApplyProcess";
public static final String NAPPLYEXTERNAL= "ApplyExternal";
public static final String NAPPLYRULESET = "ApplyRuleset";
public static final String NMERGE = "M";
public static final String NGENERATE = "G";
public static final String NSERIALIZE = "S";
public static final String NDISPATCH = "D";
public static final String NAPPLYQUERY = "AQ";
public static final String NAPPLYPROCESS = "AP";
public static final String NAPPLYEXTERNAL= "AE";
public static final String NAPPLYRULESET = "AR";
public static final int MERGE =0;
public static final int GENERATE =1;
......
/**
* $Id: FCGraphCell.java,v 1.2 2002-06-13 14:18:50 gchomat Exp $
* $Id: FCGraphCell.java,v 1.3 2002-06-14 09:26:48 gchomat Exp $
*
* Transmorpher
*
......@@ -86,16 +86,17 @@ public class FCGraphCell extends DefaultGraphCell implements Observer{
{
CallImpl call = (CallImpl)userObject;
Port port;
int number = call.inPorts().length();
int number;
if(type == FCConstants.PORTOUTPUT)
{
number = call.outPorts().length();
port= new Port("",call,number,FCConstants.PORTOUTPUT);
call.addOut(port);
}
else
{
number = call.inPorts().length();
port= new Port("",call,number,FCConstants.PORTINPUT);
call.addIn(port);
}
......
/**
* $Id: FCMarqueeHandler.java,v 1.31 2002-06-13 15:28:53 frederic Exp $
* $Id: FCMarqueeHandler.java,v 1.32 2002-06-14 09:26:48 gchomat Exp $
*
* Transmorpher
*
......@@ -61,8 +61,6 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
protected PortView port, firstPort, lastPort;
protected PortView portSource,portTarget;
protected Call currentCall;
public transient JToggleButton marquee = new JToggleButton();
......@@ -106,11 +104,24 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
return current;
}
public Point getStartPoint(){
return start;
}
public PortView getFirstPort(){
return firstPort;
}
public PortView getSecondPort(){
return port;
}
/* Return true if this handler should be preferred over other handlers. */
public boolean isForceMarqueeEvent(MouseEvent e) {
return !marquee.isSelected() || super.isForceMarqueeEvent(e);
}
public void mousePressed(MouseEvent e) {
......@@ -119,7 +130,7 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
if (!e.isConsumed() && !marquee.isSelected()) {
start = currentProcess.snap(e.getPoint());
firstPort = port;
if ((edgeNormal.isSelected())&&(firstPort != null)) {
if ((edgeNormal.isSelected())&&(firstPort != null)) {
double scale = currentProcess.getScale();
start = firstPort.getLocation(null);
start = new Point((int)(start.x*scale),(int)(start.y*scale));
......@@ -127,7 +138,6 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
e.consume();
}
}
super.mousePressed(e);
//System.out.println("MousePressed End...");
......@@ -156,13 +166,11 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
g.setXORMode(fg);
overlay(g);
event.consume();
}
}
else System.out.println("ta mere en slip");
}
super.mouseDragged(event);
// System.out.println("MouseDragged End...");
}
......@@ -227,48 +235,53 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
//dialog = new EditCall((JFrame)(currentProcess.getTopLevelAncestor()),(ProcessGraph)currentProcess,null,start,FCConstants.APPLYQUERY);}
}
else if (edgeNormal.isSelected())
{
if ((firstPort!=null)&&(port!=null)) {
java.util.Iterator itFirst = ((DefaultPort)firstPort.getCell()).edges();
java.util.Iterator it = ((DefaultPort)port.getCell()).edges();
{
if ((firstPort!=null)&&(port!=null)) {
java.util.Iterator itFirst = ((DefaultPort)firstPort.getCell()).edges();
java.util.Iterator it = ((DefaultPort)port.getCell()).edges();
if ((lenght(itFirst)<1)&&(lenght(it)<1)) {
if (((PortCell)firstPort.getCell()).getType()!=((PortCell)port.getCell()).getType()){
DefaultGraphCell c = (DefaultGraphCell)(port.getParentView()).getCell();
Call ca = (Call)(c.getUserObject());
String name = "C"+ca.getId();
channel = new Channel( name, (fr.fluxmedia.transmorpher.Graph.Process)currentTransformation );
((Process)currentTransformation).addChannel(channel);
DefaultGraphCell portOut = (DefaultGraphCell)firstPort.getCell();
DefaultGraphCell c = (DefaultGraphCell)(port.getParentView()).getCell();
String name;
if(c!=null && c.getUserObject() instanceof Call)
{
Call ca = (Call)(c.getUserObject());
name = "C"+ca.getId()+"-"+c.getChildCount();
}
else
{
name = "C"+count;
}
channel = new Channel( name, (fr.fluxmedia.transmorpher.Graph.Process)currentTransformation );
DefaultGraphCell portOut = (DefaultGraphCell)firstPort.getCell();
DefaultGraphCell portIn = (DefaultGraphCell)port.getCell();
channel.setOut((Port)portOut.getUserObject());
channel.setOut((Port)portOut.getUserObject());
channel.setIn((Port)portIn.getUserObject());
((Port)portIn.getUserObject()).setChannel(channel);
((Port)portIn.getUserObject()).setChannel(channel);
((Port)portOut.getUserObject()).setChannel(channel);
//a voir absolument?????????
//((Port)portIn.getUserObject()).setName(name);
//((Port)portOut.getUserObject()).setName(name);
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();
cs.connect(cell, firstPort.getCell(), true);
cs.connect(cell, port.getCell(), false);
currentProcess.getModel().insert(insert, cs, null, viewMap);
}
channel.setName(name);
((Process)currentTransformation).addChannel(channel);
}
}
}
}
event.consume();
}
count++;
marquee.doClick();
firstPort = null;
port = null;
......@@ -430,35 +443,29 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
paintPort(currentProcess.getGraphics());
if (start != null) {
if ((edgeNormal.isSelected()) && current != null)
g.drawLine(start.x, start.y, current.x, current.y);
}
}
protected void paintPort(Graphics g) {
if (port != null) {
if ((firstPort!=null)&&(firstPort!=port)&&((PortCell)firstPort.getCell()).getType()==((PortCell)port.getCell()).getType())
System.out.println("meth: paintPort(Graphics g) --> les deux ports sont de m types");
else {
java.util.Iterator it = ((DefaultPort)port.getCell()).edges();
if ((lenght(it)<1)) {
boolean offset = (GraphConstants.getOffset(port.getAttributes()) != null);
Rectangle r = (offset) ? port.getBounds()
: port.getParentView().getBounds();
r = currentProcess.toScreen(new Rectangle(r));
int s = 3;
r.translate(-s, -s);
r.setSize(r.width+2*s, r.height+2*s);
currentProcess.getUI().paintCell(g, port, r, true);
}
}
}
if (port != null) {
if ((firstPort!=null)&&(firstPort!=port)&&((PortCell)firstPort.getCell()).getType()==((PortCell)port.getCell()).getType())
System.out.println("meth: paintPort(Graphics g) --> les deux ports sont de m types");
else {
java.util.Iterator it = ((DefaultPort)port.getCell()).edges();
if ((lenght(it)<1)) {
boolean offset = (GraphConstants.getOffset(port.getAttributes()) != null);
Rectangle r = (offset) ? port.getBounds(): port.getParentView().getBounds();
r = currentProcess.toScreen(new Rectangle(r));
int s = 3;
r.translate(-s, -s);
r.setSize(r.width+2*s, r.height+2*s);
currentProcess.getUI().paintCell(g, port, r, true);
}
}
}
}
}
......@@ -47,6 +47,8 @@ public class FCPortRenderer extends PortRenderer {
if (offset) {
System.out.println("offset");
g.drawRect(1, 1, d.width-3,d.height-3);
g.setColor(getBackground());
g.drawRect(2, 2, d.width-5, d.height-5);
} else if (!preview)
{
System.out.println("not preview");
......
/**
*
*$Id: FlowComposer.java,v 1.48 2002-06-13 15:28:53 frederic Exp $
*$Id: FlowComposer.java,v 1.49 2002-06-14 09:26:48 gchomat Exp $
*
* Transmorpher
*
......@@ -689,8 +689,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
redoAction.update();
portLeftAction.update();
portRightAction.update();
//ZoomInAction.update();
// ZoomOutAction.update();
}
......@@ -854,8 +853,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
protected UndoAction undoAction = new UndoAction();
protected RedoAction redoAction = new RedoAction();
protected ZoomInAction zoomInAction = new ZoomInAction(this);
protected ZoomOutAction zoomOutAction = new ZoomOutAction(this);
protected PortRightAction portRightAction = new PortRightAction(this);
protected PortLeftAction portLeftAction = new PortLeftAction(this);
......@@ -863,11 +861,11 @@ public class FlowComposer extends JPanel implements GraphModelListener,
undoAction,
redoAction,
portRightAction,
portLeftAction,
portLeftAction,
new LoadAction(this),
zoomInAction,
new ZoomInAction(this),
new ZoomAction(),
zoomOutAction,
new ZoomOutAction(this),
new ImportAction(),
new ExportAction(),
new SaveAction(),
......@@ -1698,7 +1696,8 @@ public class FlowComposer extends JPanel implements GraphModelListener,
DefaultGraphCell cell;
for (int i = 0; i <tmp.length; i++){
cell = (DefaultGraphCell)tmp[i];
if ((cell instanceof DefaultEdge)||(!((cell instanceof DispatchCell)||(cell instanceof ApplyProcessCell)))){
if (cell instanceof DefaultEdge){}
else if (!((cell instanceof DispatchCell)||(cell instanceof ApplyProcessCell))){
accept=false;
}
}
......@@ -1738,9 +1737,10 @@ public class FlowComposer extends JPanel implements GraphModelListener,
DefaultGraphCell cell;
for (int i = 0; i <tmp.length; i++){
cell = (DefaultGraphCell)tmp[i];
if((cell instanceof DefaultEdge)||(!((cell instanceof MergeCell)||(cell instanceof ApplyProcessCell)))){
accept=false;
if (cell instanceof DefaultEdge){}
else if(!((cell instanceof MergeCell)||(cell instanceof ApplyProcessCell))){
accept=false;
break;
}
}
if (accept) setEnabled (true);
......@@ -1767,7 +1767,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
}
}
class ZoomInAction extends AbstractAction {
class ZoomInAction extends AbstractAction {
private FlowComposer flow;
ZoomInAction(FlowComposer flow) {
super("zoomIn"+actionSuffix);
......@@ -1781,13 +1781,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
if ((flow.getGraph()).getSelectionCell() != null)
(flow.getGraph()).scrollCellToVisible((flow.getGraph()).getSelectionCell());
}
protected void update(){
/* if (currentProcess != null) {
double s = (flow.getGraph()).getScale();
if (s==16.0*/
}
}
}
class ZoomOutAction extends AbstractAction {
......@@ -1803,10 +1797,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
if ((flow.getGraph()).getSelectionCell() != null)
(flow.getGraph()).scrollCellToVisible((flow.getGraph()).getSelectionCell());
}
protected void update() {
}
}
......
/**
* $Id: ProcessGraph.java,v 1.32 2002-06-13 15:28:53 frederic Exp $
* $Id: ProcessGraph.java,v 1.33 2002-06-14 09:26:48 gchomat Exp $
*
* Transmorpher
*
......@@ -179,9 +179,9 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
}
protected PortView createPortView(PortCell p, CellMapper cm){
return new FCPortView(p, this, cm);
}
/*protected PortView createPortView(Port p, CellMapper cm){
......@@ -232,8 +232,6 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
/** interface Observer*/
public void update(Observable observable, Object arg){
//System.out.println("obs "+observable +" arg "+arg);
if(observable instanceof Process)
{
if(arg instanceof Call)
......@@ -259,20 +257,70 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
}
else if(arg instanceof Port)
{
Port port = (Port)arg;
Port port = (Port)arg;
if (port.getType()==FCConstants.PORTINPUT)
addVertex("PInput",FCConstants.PORTPROCESS);
addVertex(port,FCConstants.PORTPROCESS);
else
addVertex("POutput",FCConstants.PORTPROCESS);
addVertex(port,FCConstants.PORTPROCESS);
updateCellProcess(port.getType());
}
else if(arg instanceof Channel)
{
}
Point current = null;
Point start = null;
if(marquee instanceof FCMarqueeHandler && ((FCMarqueeHandler)marquee).getCurrentPoint()!= null)
current= new Point(((FCMarqueeHandler)marquee).getCurrentPoint());
if(marquee instanceof FCMarqueeHandler && ((FCMarqueeHandler)marquee).getStartPoint()!= null)
start= new Point(((FCMarqueeHandler)marquee).getStartPoint());
Point p =null;
Point p2 =null;
if(start != null)
p = fromScreen(new Point(start));
if(current!=null)
p2 = 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)arg);
viewMap.put(cell, map);
Object[] insert = new Object[]{cell};
ConnectionSet cs = new ConnectionSet();
PortView firstPort =null;
PortView port =null;
if(marquee instanceof FCMarqueeHandler)
{
firstPort =((FCMarqueeHandler) marquee).getFirstPort();
port =((FCMarqueeHandler) marquee).getSecondPort();
}
/*Object firstport = getPort;
Object secondport
*/
cs.connect(cell, firstPort.getCell(), true);
cs.connect(cell, port.getCell(), false);
getModel().insert(insert, cs, null, viewMap);
}
else
{
System.out.println("update channel " + arg);
}
}
}
......@@ -557,10 +605,16 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
Object[] roots = getAll();
String user;
ArrayList result = new ArrayList();
for (int i = 0; i < roots.length; i++){
if ((((DefaultGraphCell)roots[i]).getUserObject().equals(""))&&((getPorts(roots[i],portLocation)).size()>0))
/*for (int i = 0; i < roots.length; i++){
if ((((DefaultGraphCell)roots[i]).getUserObject().equals())&&((getPorts(roots[i],portLocation)).size()>0))
result.add(roots[i]);
}
}*/
for (int i=0; i < roots.length; i++){
if (roots[i] instanceof PortProcessCell && (((Port)((PortProcessCell)roots[i]).getUserObject()).getType() == portLocation))
result.add(roots[i]);
}
return result;
}
......@@ -750,10 +804,14 @@ addVertex(call, position,FCConstants.MERGE);
break;
case FCConstants.PORTPROCESS :
cell = new PortProcessCell(userObject);
bounds = new Rectangle(position,boundsCube);
bounds = new Rectangle(position,boundsPort);
attributes = commonAttributres(cell,bounds);
addPort(cell,viewMap,FCConstants.PORTOUTPUT);
break;
if(userObject instanceof Port)
addPort(cell,viewMap,((Port)userObject).getType());
else
addPort(cell,viewMap,FCConstants.PORTOUTPUT);
break;
default: System.out.println("pas de vertex correspondant la string : FlowComposerGraph+meth commonAttributres");break;
}
......@@ -761,8 +819,6 @@ addVertex(call, position,FCConstants.MERGE);
getModel().insert(new Object[]{cell}, null, null, viewMap);
FlowComposer.editing=true;
updateCellProcess(FCConstants.PORTINPUT);
updateCellProcess(FCConstants.PORTOUTPUT);
return cell;
}
......@@ -806,15 +862,19 @@ addVertex(call, position,FCConstants.MERGE);
else {
TransformationImpl transformation = (TransformationImpl)userObject;
port = new Port(name,transformation,type);
if (type==FCConstants.PORTINPUT)
int number;
if (type==FCConstants.PORTINPUT)
{
transformation.addIn(port);
number = transformation.inPorts().length();
port= new Port("",transformation,number,type);
transformation.addIn(port);
}
else
{
transformation.addOut(port);
number = transformation.outPorts().length();
port= new Port("",transformation,number,type);
transformation.addOut(port);
}
}
}
......@@ -824,7 +884,7 @@ addVertex(call, position,FCConstants.MERGE);
int u = GraphConstants.PERCENT;
Map map = GraphConstants.createMap();
switch (type) {
/*switch (type) {
case FCConstants.PORTINPUT :
GraphConstants.setOffset(map, new Point(0,(int) (u/2)));
break;
......@@ -833,9 +893,10 @@ addVertex(call, position,FCConstants.MERGE);
break;
default : System.out.println("type de port inconnu : meth addPort");
}
PortCell pc = new PortCell(null,type);
}*/
GraphConstants.setOffset(map, new Point((int)(u/2),(int) (u/2)));
PortCell pc = new PortCell(cell.getUserObject(),type);
viewMap.put(pc, map);
cell.add(pc);
......@@ -844,36 +905,36 @@ addVertex(call, position,FCConstants.MERGE);
/*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 DefaultEdge)&&(!(cell instanceof PortCell))){
cell = (DefaultGraphCell)tmp[i];
if ((portLocation==FCConstants.PORTINPUT)&&((cell instanceof MergeCell)||(cell instanceof ApplyProcessCell)||(cell