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

update

parent a644294d
/**
*
*$Id: FlowComposer.java,v 1.35 2002-06-04 09:20:29 frederic Exp $
*$Id: FlowComposer.java,v 1.36 2002-06-04 15:22:30 frederic Exp $
*
* Transmorpher
*
......@@ -259,7 +259,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
processFactory = new FCProcessFactory();
buttons = createButtons();
createSpecialButtons();
// Add a ToolBar
JPanel center = new JPanel();
......@@ -597,16 +597,17 @@ public class FlowComposer extends JPanel implements GraphModelListener,
public Component createToolButton(String key) {
Object button;
AbstractButton b = null;
URL url;
url = getResource(key + imageSuffix);
button= buttons.get(key);
if (button instanceof AbstractButton) {
Object button;
AbstractButton b = null;
URL url;
url = getResource(key + imageSuffix);
button= buttons.get(key);
//System.out.println(url);
//System.out.println(button);
if (button instanceof JComponent &&
!(button instanceof AbstractButton)&&!(button==null))
return (JComponent) button;
else if (button instanceof AbstractButton) {
b = (AbstractButton) button;
b.setIcon(new ImageIcon(url));
} else {
......
/**
* $Id: ProcessGraph.java,v 1.14 2002-06-03 17:19:30 gchomat Exp $
* $Id: ProcessGraph.java,v 1.15 2002-06-04 15:22:30 frederic Exp $
*
* Transmorpher
*
......@@ -84,7 +84,7 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
undo = new GraphUndoManager();
setPortsVisible(false);
setPortsVisible(true);
setSizeable(false);
//setEditable(false);
setAntiAliased(true);
......@@ -111,13 +111,13 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
}
public String toString(){
if(userObject instanceof Process){
return ((Process)userObject).getName();
}
return super.toString();
if(userObject instanceof Process){
return ((Process)userObject).getName();
}
return super.toString();
}
/**
* Creates and returns the corresponding <code>GraphView</code> of the v object.
......@@ -290,8 +290,8 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
*
*/
public Object[] getAll() {
// return DefaultGraphModel.getDescendants(getModel(), getRoots()).toArray();
return getRoots();
// return DefaultGraphModel.getDescendants(getModel(), getRoots()).toArray();
return getRoots();
}
......@@ -385,30 +385,30 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
public boolean isSingleId(String name){
Object[] roots = getAll();
DefaultGraphCell cell;
Object userObject;
Call call;
for (int i = 0; i < roots.length; i++){
Object[] roots = getAll();
DefaultGraphCell cell;
Object userObject;
Call call;
for (int i = 0; i < roots.length; i++){
if (!(roots[i] instanceof Edge))
{
cell = (DefaultGraphCell)(roots[i]);
userObject = cell.getUserObject();
call = ((userObject instanceof Call)? (Call)userObject : null );
if(call != null)
{
if(call.getId().equals(name))
return false;
}
}
}
return true;
}
{
cell = (DefaultGraphCell)(roots[i]);
userObject = cell.getUserObject();
call = ((userObject instanceof Call)? (Call)userObject : null );
if(call != null)
{
if(call.getId().equals(name))
return false;
}
}
}
return true;
}
/**
......@@ -430,7 +430,7 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
return result;
}
/*
public void layoutPorts(Object vertex1,Object userObject) {
GraphView v = getView();
ArrayList result = new ArrayList();
......@@ -488,40 +488,41 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
tmp=result;
}
*/
/** add a Cell to the Graph
*
*/
public void addVertex(Object userObject,Point point,int number) {
int u = GraphConstants.PERCENT;
Rectangle bounds;
DefaultGraphCell cell = null;
Map viewMap = new Hashtable();
// Create Vertex
switch (number) {
case FCConstants.MERGE :
// cell = new MergeCell(userObject);
cell = new MergeCell(userObject);
bounds = new Rectangle(point,boundsCube);
addCell(cell,viewMap,bounds);
addPort(cell,viewMap,FCConstants.PORTOUTPUT);
break;
case FCConstants.GENERATE :
cell = new GenerateCell(userObject);
bounds = new Rectangle(point,boundsRect);
addCell(cell,viewMap,bounds);
addPort(cell,viewMap,FCConstants.PORTOUTPUT);
break;
case FCConstants.SERIALIZE :
cell = new SerializeCell(userObject);
bounds = new Rectangle(point,boundsRect);
addCell(cell,viewMap,bounds);
addPort(cell,viewMap,FCConstants.PORTINPUT);
break;
case FCConstants.DISPATCH :
cell = new DispatchCell(userObject);
bounds = new Rectangle(point,boundsCube);
addCell(cell,viewMap,bounds);
addPort(cell,viewMap,FCConstants.PORTINPUT);
break;
case FCConstants.APPLYEXTERNAL :
cell = new ApplyExternalCell(userObject);
......@@ -545,11 +546,15 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
cell = new ApplyRulesetCell(userObject);
bounds = new Rectangle(point,boundsRect);
addCell(cell,viewMap,bounds);
addPort(cell,viewMap,FCConstants.PORTINPUT);
addPort(cell,viewMap,FCConstants.PORTOUTPUT);
break;
case FCConstants.APPLYQUERY :
cell = new ApplyQueryCell(userObject);
bounds = new Rectangle(point,boundsCube);
addCell(cell,viewMap,bounds);
addPort(cell,viewMap,FCConstants.PORTINPUT);
addPort(cell,viewMap,FCConstants.PORTOUTPUT);
break;
case FCConstants.PORTPROCESS :
cell = new PortProcessCell(userObject);
......@@ -573,58 +578,76 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
viewMap.put(cell, map);
}
public void updatePorts(Object userObject,DefaultGraphCell cell){
GraphView v = getView();
ArrayList children = getPorts(cell,userObject);
for (int i=0;i<children.size();i++) {
Map map = GraphConstants.createMap();
int u = GraphConstants.PERCENT;
Map attributes = new Hashtable();
if (userObject.equals("input")){
GraphConstants.setOffset(map,new Point(0,(int)(u*(i+1))/(children.size()+1)));
CellView cellView = v.getMapping(children.get(i),false);
attributes.put(cellView,map);
}
else {
GraphConstants.setOffset(map,new Point(u,(int)(u*(i+1))/(children.size()+1)));
CellView cellView = v.getMapping(children.get(i),false);
attributes.put(cellView,map);
}
v.edit(attributes);
public void addPort(DefaultGraphCell cell,Map viewMap,int type) {
int u = GraphConstants.PERCENT;
Map map = GraphConstants.createMap();
/*Call call = (Call)cell.getUserObject();
int indexIn = (call.inPorts().length()==0)?0:call.inPorts().length()-1;
String name = "C"+call.getId();
fr.fluxmedia.transmorpher.Graph.Port tPort = new fr.fluxmedia.transmorpher.Graph.Port(name,call,indexIn);*/
if (type==FCConstants.PORTOUTPUT){
//call.outPorts().addPort(tPort);
GraphConstants.setOffset(map, new Point(0,(int) (u/2)));}
else {
//call.inPorts().addPort(tPort);
GraphConstants.setOffset(map, new Point(u,(int) (u/2)));
}
PortCell port = new PortCell("");
cell.add(port);
viewMap.put(port, map);
}
/* public void updatePorts(Object userObject,DefaultGraphCell cell){
GraphView v = getView();
ArrayList children = getPorts(cell,userObject);
for (int i=0;i<children.size();i++) {
Map map = GraphConstants.createMap();
int u = GraphConstants.PERCENT;
Map attributes = new Hashtable();
if (userObject.equals("input")){
GraphConstants.setOffset(map,new Point(0,(int)(u*(i+1))/(children.size()+1)));
CellView cellView = v.getMapping(children.get(i),false);
attributes.put(cellView,map);
}
else {
GraphConstants.setOffset(map,new Point(u,(int)(u*(i+1))/(children.size()+1)));
CellView cellView = v.getMapping(children.get(i),false);
attributes.put(cellView,map);
}
v.edit(attributes);
}
} */
/** add a Port to the Cell
*
*/
/*
public void addPort(Object userObject,DefaultGraphCell cell) {
int nb = (getPorts(cell,userObject)).size();
Map map = GraphConstants.createMap();
int u = GraphConstants.PERCENT;
if (userObject.equals("input"))
GraphConstants.setOffset(map,new Point(u/2,u/2));
else
GraphConstants.setOffset(map,new Point(u/2,u/2));
//System.out.println("offset "+userObject+" " +map.get(GraphConstants.OFFSET));
DefaultPort port = new DefaultPort(userObject);
ParentMap parent = new ParentMap();
parent.addEntry(port,cell);
Map viewMap = new Hashtable();
viewMap.put(port,map);
getModel().insert(new Object[]{port},null,parent,viewMap);
}
int nb = (getPorts(cell,userObject)).size();
Map map = GraphConstants.createMap();
int u = GraphConstants.PERCENT;
if (userObject.equals("input"))
GraphConstants.setOffset(map,new Point(u/2,u/2));
else
GraphConstants.setOffset(map,new Point(u/2,u/2));
//System.out.println("offset "+userObject+" " +map.get(GraphConstants.OFFSET));
DefaultPort port = new DefaultPort(userObject);
ParentMap parent = new ParentMap();
parent.addEntry(port,cell);
Map viewMap = new Hashtable();
viewMap.put(port,map);
getModel().insert(new Object[]{port},null,parent,viewMap);
}
*/ /*
public int getFactor(int nb) {
int u = GraphConstants.PERCENT;
// System.out.println(nb);
return (int)(u*(nb+1))/(nb+2);
int u = GraphConstants.PERCENT;
// System.out.println(nb);
return (int)(u*(nb+1))/(nb+2);
}
*/
public void generateRDF(ReadWrite file) {
Object[] cells = getAll();
file.Writeln(4,"<rdf:Description about=\""+((Process)userObject).getName()+"\">");
......
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