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

implemented observer observable on call

parent 233fe258
/**
* $Id: GenerateRenderer.java,v 1.5 2002-04-30 13:12:29 gchomat Exp $
* $Id: GenerateRenderer.java,v 1.6 2002-06-11 09:38:57 gchomat Exp $
*
* Transmorpher
*
......@@ -33,38 +33,38 @@ public class GenerateRenderer extends VertexRenderer {
public void paint(Graphics g) {
int b = borderWidth;
Graphics2D g2 = (Graphics2D) g;
Dimension d = getSize();
boolean tmp = selected;
if (super.isOpaque()) {
Graphics2D g2 = (Graphics2D) g;
Dimension d = getSize();
boolean tmp = selected;
if (super.isOpaque()) {
g.setColor(super.getBackground());
// For the moment the opaque state is not implemented
drawGenerate(g,d,b);
}
try {
setBorder(null);
setOpaque(false);
selected = false;
super.paint(g);
} finally {
selected = tmp;
}
if (bordercolor != null) {
g.setColor(bordercolor);
g2.setStroke(new BasicStroke(b));
drawGenerate(g,d,b);
}
if (selected) {
g2.setStroke(GraphConstants.SELECTION_STROKE);
g.setColor(graph.getHighlightColor());
drawGenerate(g,d,b);
}
}
try {
setBorder(null);
setOpaque(false);
selected = false;
super.paint(g);
} finally {
selected = tmp;
}
if (bordercolor != null) {
g.setColor(bordercolor);
g2.setStroke(new BasicStroke(b));
drawGenerate(g,d,b);
}
if (selected) {
g2.setStroke(GraphConstants.SELECTION_STROKE);
g.setColor(graph.getHighlightColor());
drawGenerate(g,d,b);
}
}
private void drawGenerate(Graphics g,Dimension d , int b ) {
g.drawPolygon(new int[]{b-1,2*d.width/3-1,d.width-1,2*d.width/3-1,b-1},
new int[]{b-1,b-1,d.height/2,d.height-1,d.height-1},
5);
g.drawPolygon(new int[]{b-1,2*d.width/3-1,d.width-1,2*d.width/3-1,b-1},
new int[]{b-1,b-1,d.height/2,d.height-1,d.height-1},
5);
}
}
/**
* $Id: GenerateView.java,v 1.3 2002-06-05 14:46:41 frederic Exp $
* $Id: GenerateView.java,v 1.4 2002-06-11 09:38:57 gchomat Exp $
*
* Transmorpher
*
......@@ -43,6 +43,8 @@ public class GenerateView extends VertexView{
public static GenerateRenderer renderer = new GenerateRenderer();
protected static int size = 100;
public GenerateView(Object cell, JGraph graph, CellMapper cm) {
super(cell, graph, cm);
}
......@@ -61,6 +63,8 @@ public class GenerateView extends VertexView{
return new Point (xout, yout);
}
protected static int size = 100;
public CellViewRenderer getRenderer() {
return renderer;
}
}
/**
* $Id: MergeCell.java,v 1.5 2002-06-03 17:19:30 gchomat Exp $
* $Id: MergeCell.java,v 1.6 2002-06-11 09:38:57 gchomat Exp $
*
* Transmorpher
*
......@@ -42,6 +42,15 @@ public class MergeCell extends DefaultGraphCell implements Observer{
public void update(Observable o, Object arg){
if(o instanceof Call)
{
if(arg instanceof Port)
{
}
}
}
/*public String toString(){
......
/**
* $Id: ProcessGraph.java,v 1.24 2002-06-10 13:53:00 frederic Exp $
* $Id: ProcessGraph.java,v 1.25 2002-06-11 09:38:57 gchomat Exp $
*
* Transmorpher
*
......@@ -190,7 +190,7 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
{
if(arg instanceof Call)
{
if(arg instanceof Dispatch)
addVertex(arg,FCConstants.DISPATCH);
else if(arg instanceof Merge)
......@@ -207,7 +207,7 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
addVertex(arg,FCConstants.APPLYQUERY);
else if(arg instanceof ApplyRuleset)
addVertex(arg,FCConstants.APPLYRULESET);
}
}
}
......@@ -621,89 +621,87 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
DefaultGraphCell cell = null;
Map viewMap = new Hashtable();
Map attributes = null;
// Create Vertex
switch (type) {
case FCConstants.MERGE :
cell = new MergeCell(userObject);
bounds = new Rectangle(position,boundsCube);
addCell(cell,viewMap,bounds);
attributes = commonAttributres(cell,bounds);
addPort(cell,viewMap,FCConstants.PORTOUTPUT);
// updatePorts(FCConstants.PORTOUTPUT,cell);
break;
case FCConstants.GENERATE :
cell = new GenerateCell(userObject);
bounds = new Rectangle(position,boundsRect);
addCell(cell,viewMap,bounds);
attributes = commonAttributres(cell,bounds);
addPort(cell,viewMap,FCConstants.PORTOUTPUT);
//updatePorts(FCConstants.PORTOUTPUT,cell);
break;
case FCConstants.SERIALIZE :
cell = new SerializeCell(userObject);
bounds = new Rectangle(position,boundsRect);
addCell(cell,viewMap,bounds);
attributes = commonAttributres(cell,bounds);
addPort(cell,viewMap,FCConstants.PORTINPUT);
break;
case FCConstants.DISPATCH :
cell = new DispatchCell(userObject);
bounds = new Rectangle(position,boundsCube);
addCell(cell,viewMap,bounds);
attributes = commonAttributres(cell,bounds);
addPort(cell,viewMap,FCConstants.PORTINPUT);
break;
case FCConstants.APPLYEXTERNAL :
cell = new ApplyExternalCell(userObject);
bounds = new Rectangle(position,boundsRect);
addCell(cell,viewMap,bounds);
Call call = (Call)userObject;
attributes = commonAttributres(cell,bounds);
Call call = (Call)userObject;
if(call.getType().equals("xslt")){
addPort(cell,viewMap,FCConstants.PORTINPUT);
addPort(cell,viewMap,FCConstants.PORTOUTPUT);
}
/*Map map = GraphConstants.createMap();
GraphConstants.setBounds(map, bounds);
GraphConstants.setOpaque(map, false);
GraphConstants.setBorderColor(map, Color.black);
GraphConstants.setForeground(map, Color.white);
GraphConstants.setBackground(map, Color.lightGray);
viewMap.put(cell, map);*/
GraphConstants.setForeground(attributes, Color.white);
GraphConstants.setBackground(attributes, Color.lightGray);
break;
case FCConstants.APPLYPROCESS :
case FCConstants.APPLYPROCESS :
cell = new ApplyProcessCell(userObject);
bounds = new Rectangle(position,boundsRect);
addCell(cell,viewMap,bounds);
attributes = commonAttributres(cell,bounds);
break;
case FCConstants.APPLYRULESET :
cell = new ApplyRulesetCell(userObject);
bounds = new Rectangle(position,boundsRect);
addCell(cell,viewMap,bounds);
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);
addCell(cell,viewMap,bounds);
attributes = commonAttributres(cell,bounds);
addPort(cell,viewMap,FCConstants.PORTINPUT);
addPort(cell,viewMap,FCConstants.PORTOUTPUT);
break;
case FCConstants.PORTPROCESS :
cell = new PortProcessCell(userObject);
bounds = new Rectangle(new Point(50,50),boundsPort);
addCell(cell,viewMap,bounds);
break;
default: System.out.println("pas de vertex correspondant la string : FlowComposerGraph+meth addCell");break;
bounds = new Rectangle(position,boundsCube);
attributes = commonAttributres(cell,bounds);
addPort(cell,viewMap,FCConstants.PORTOUTPUT);
break;
default: System.out.println("pas de vertex correspondant la string : FlowComposerGraph+meth commonAttributres");break;
}
viewMap.put(cell,attributes);
getModel().insert(new Object[]{cell}, null, null, viewMap);
FlowComposer.editing=true;
return cell;
}
public void addCell(DefaultGraphCell cell,Map viewMap, Rectangle bounds) {
public Map commonAttributres(DefaultGraphCell cell, Rectangle bounds) {
Map map = GraphConstants.createMap();
if(cell instanceof PortProcessCell){
......@@ -715,8 +713,7 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
GraphConstants.setBounds(map, bounds);
GraphConstants.setOpaque(map, false);
GraphConstants.setBorderColor(map, Color.black);
viewMap.put(cell, map);
return map;
}
public void createPort(int type)
......@@ -750,9 +747,9 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
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);
......@@ -765,7 +762,7 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
cell.add(pc);
}
public void actionRL(int type,int portLocation){
Object[] tmp = getSelectionCells();
......@@ -890,13 +887,13 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
}
/*
public void updatePorts(int type,DefaultGraphCell cell){
>>>>>>> 1.23
>>>>>>> 1.23
GraphView v = getView();
ArrayList children = getPorts(cell,type);
......@@ -925,6 +922,7 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
/** add a Port to the Cell
*
*/
/*
public void addPort(Object userObject,DefaultGraphCell cell) {
......@@ -950,6 +948,7 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
return (int)(u*(nb+1))/(nb+2);
}
*/
public void generateRDF(ReadWrite file) {
Object[] cells = getAll();
file.Writeln(4,"<rdf:Description about=\""+((Process)userObject).getName()+"\">");
......@@ -995,13 +994,9 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
}
/* Show a dialog with the given error message. */
/* Show a dialog with the given error message.*/
public void error(String message) {
JOptionPane.showMessageDialog(this, message,"FlowComposer", JOptionPane.ERROR_MESSAGE);
}
}
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