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

update transmo

parent bce61388
/**
* $Id: FCMarqueeHandler.java,v 1.21 2002-06-06 08:43:39 gchomat Exp $
* $Id: FCMarqueeHandler.java,v 1.22 2002-06-06 09:49:55 frederic Exp $
*
* Transmorpher
*
......@@ -191,59 +191,53 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
{dialog = new EditCall((JFrame)(currentProcess.getTopLevelAncestor()),(ProcessGraph)currentProcess,null,start,FCConstants.APPLYRULESET);}
else if (applyQuery.isSelected())
{dialog = new EditCall((JFrame)(currentProcess.getTopLevelAncestor()),(ProcessGraph)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();
}
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);
//System.out.println("MouseReleased End...");
}
}
public void mouseMoved(MouseEvent event) {
......
/**
*
*$Id: FlowComposer.java,v 1.38 2002-06-06 08:43:39 gchomat Exp $
*$Id: FlowComposer.java,v 1.39 2002-06-06 09:49:55 frederic Exp $
*
* Transmorpher
*
......@@ -258,7 +258,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
marqueeHandler = new FCMarqueeHandler(this);
processFactory = new FCProcessFactory();
buttons = createButtons();
createSpecialButtons();
// Add a ToolBar
......@@ -270,11 +270,12 @@ public class FlowComposer extends JPanel implements GraphModelListener,
Border etched = BorderFactory.createRaisedBevelBorder();
center.setBorder(etched);
//Add a JTabbedPane for represnting the process notion.
tabProcess= new JTabbedPane();
tabProcess.getModel().addChangeListener(
new ChangeListener() {
tabProcess.getModel().addChangeListener(
new ChangeListener() {
public void stateChanged(ChangeEvent e) {
SingleSelectionModel model = (SingleSelectionModel) e.getSource();
if(model.getSelectedIndex() != -1) {
......@@ -297,12 +298,13 @@ public class FlowComposer extends JPanel implements GraphModelListener,
//Init the main process
addProcess(new String("main"),MAIN);
// Add the Graph as Center Component
center.add(tabProcess, BorderLayout.CENTER);
panel.add(center,BorderLayout.CENTER);
this.add(createMenubar(),BorderLayout.NORTH);
this.add(panel,BorderLayout.CENTER);
// Add the Graph as Center Component
center.add(tabProcess, BorderLayout.CENTER);
panel.add(center,BorderLayout.CENTER);
this.add(createMenubar(),BorderLayout.NORTH);
this.add(panel,BorderLayout.CENTER);
this.add(status,BorderLayout.SOUTH);
}
......@@ -377,17 +379,15 @@ public class FlowComposer extends JPanel implements GraphModelListener,
public Point getGraphLocationOnscreen(){
Point result = null;
if(tabProcess!=null)
result = tabProcess.getLocationOnScreen();
return result;
}
public void addProcess(String name, int type){
UndoHandler undoHandler;
......@@ -422,19 +422,23 @@ public class FlowComposer extends JPanel implements GraphModelListener,
{
return;
}
((ProcessGraph)currentProcess).setMarqueeHandler(marqueeHandler);
undoHandler = new UndoHandler();
registerListeners(currentProcess);
currentProcess.getModel().addUndoableEditListener(undoHandler);
sp = new JScrollPane(currentProcess);
sp = new JScrollPane(currentProcess,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
sp = (JScrollPane)(tabProcess.add(process.getName(),sp));
tabProcess.setSelectedComponent(sp);
currentProcess = (ProcessGraph)(sp.getViewport().getView());
undoHandler.setProcess(currentProcess);
}
((ProcessGraph)currentProcess).addVertex("",null,FCConstants.PORTPROCESS);
}
else
{
System.out.println("The process is not added. Mode multi fentre not yet implemented");
......@@ -687,7 +691,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
currentLookAndFeel = laf;
try {
UIManager.setLookAndFeel(currentLookAndFeel);
}
catch (Exception ex) {
System.out.println("Failed loading L&F: " + currentLookAndFeel);
......@@ -695,8 +699,8 @@ public class FlowComposer extends JPanel implements GraphModelListener,
}
}
}
public void setScale(double scale) {
scale = Math.max(Math.min(scale, 1024), .01);
setScale(scale);
......@@ -1086,6 +1090,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
try {
if(currentProcess!= null & ((ProcessGraph)currentProcess).getUndoManager()!=null)
{
((ProcessGraph)currentProcess).getUndoManager().undo(getView());
......@@ -1096,7 +1101,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
}
update();
redoAction.update();
}
protected void update() {
......@@ -1129,7 +1134,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
((ProcessGraph)currentProcess).getUndoManager().redo(getView());
}
} catch (CannotRedoException ex) {
ex.printStackTrace();
}
......@@ -1186,6 +1191,12 @@ public class FlowComposer extends JPanel implements GraphModelListener,
}
public void actionPerformed(ActionEvent e) {
Rectangle r = currentProcess.getBounds();
System.out.println(r.x+"xxx");
System.out.println(r.y+"yyy");
System.out.println(r.width+"width");
System.out.println(r.height+"height");
((ProcessGraph)currentProcess).addVertex("",new Point(0,r.height/2),FCConstants.PORTPROCESS);
//(flow.getGraph()).
}
}
......@@ -1365,7 +1376,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
public void actionPerformed(ActionEvent e) {
try{
SystemResources tResources = new SystemResources();
String reloc = "";
transmorpher.generateExec(reloc);
......@@ -1430,7 +1441,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
}
public void actionPerformed(ActionEvent e) {
//String name = getNameProcess();
String name = new String("Process"+processFactory.getAllProcess().size());
......@@ -1439,7 +1450,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
if(processFactory.getProcess(name) != null)
{
Alert.show(null,resource.getString("UNIQUE_NAME_PROCESS"),resource.getString("WARNING"),JOptionPane.WARNING_MESSAGE);
}
}
else
{
addProcess(name,PROCESS);
......
/**
* $Id: ProcessGraph.java,v 1.18 2002-06-05 14:46:41 frederic Exp $
* $Id: ProcessGraph.java,v 1.19 2002-06-06 09:49:55 frederic Exp $
*
* Transmorpher
*
......@@ -51,6 +51,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
*/
......@@ -85,12 +86,12 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
undo = new GraphUndoManager();
setPortsVisible(true);
setSizeable(false);
setSizeable(true);
//setEditable(false);
setAntiAliased(true);
this.userObject = userObject;
}
}
public void setUndoManager(GraphUndoManager undo){
......@@ -494,13 +495,26 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
}
*/
public void updateProcess() {
if (pCell!=null) {
GraphView v = getView();
Rectangle r = getBounds();
Map map = GraphConstants.createMap();
Map attributes = new Hashtable();
GraphConstants.setBounds(map,r);
CellView cellView = v.getMapping(pCell,true);
attributes.put(cellView,map);
v.edit(attributes);}
}
/** add a Cell to the Graph
*
*/
public void addVertex(Object userObject,Point point,int number) {
int u = GraphConstants.PERCENT;
Rectangle bounds;
Rectangle boundsPort_ = new Rectangle(point,boundsPort);
DefaultGraphCell cell = null;
Map viewMap = new Hashtable();
......@@ -565,8 +579,10 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
addPort(cell,viewMap,FCConstants.PORTOUTPUT);
break;
case FCConstants.PORTPROCESS :
Rectangle r = getBounds();
cell = new PortProcessCell(userObject);
bounds = new Rectangle(point,boundsPort);
pCell=cell;
bounds = new Rectangle(new Point(0,0),new Dimension(70,70));
addCell(cell,viewMap,bounds);
break;
default: System.out.println("pas de vertex correspondant la string : FlowComposerGraph+meth addCell");break;
......@@ -575,6 +591,7 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
getModel().insert(new Object[]{cell}, null, null, viewMap);
FlowComposer.editing=true;
updateProcess();
}
......@@ -593,23 +610,23 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
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)));
index = (call.inPorts().length()==0)?0:call.inPorts().length()-1;
port = new fr.fluxmedia.transmorpher.Graph.Port(null,call,index);
call.inPorts().addPort(port);
// 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)));
index = (call.outPorts().length()==0)?0:call.outPorts().length()-1;
port = new fr.fluxmedia.transmorpher.Graph.Port(null,call,index);
call.outPorts().addPort(port);
// 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);
PortCell pc = new PortCell("",type);
viewMap.put(pc, map);
cell.add(pc);
......
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