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

connections:wq

:wq
parent 28e7ac0a
/**
* $Id: FCMarqueeHandler.java,v 1.5 2002-05-16 14:14:53 gchomat Exp $
* $Id: FCMarqueeHandler.java,v 1.6 2002-05-21 09:44:32 frederic Exp $
*
* Transmorpher
*
......@@ -30,7 +30,7 @@
package fr.fluxmedia.flowcomposer;
import javax.swing.*;
import javax.swing.*;
import com.jgraph.JGraph;
import com.jgraph.graph.*;
import com.jgraph.plaf.GraphUI;
......@@ -47,7 +47,7 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
public JGraph currentProcess;
public transient JToggleButton marquee = new JToggleButton();
public transient JToggleButton generate = new JToggleButton();
public transient JToggleButton serialize = new JToggleButton();
......@@ -63,16 +63,15 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
public transient JToggleButton edgeNull = new JToggleButton();
protected Point start, current;
protected Object beginCell, endCell;
public void setCurrentProcess(Object process){
//if(process instanceof ProcessGraph)
//{
currentProcess = (ProcessGraph)process;
//}
}
public JGraph getCurrentProcess(){
return currentProcess;
}
......@@ -82,7 +81,7 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
public boolean isForceMarqueeEvent(MouseEvent e) {
return !marquee.isSelected() || super.isForceMarqueeEvent(e);
}
public void mousePressed(MouseEvent e) {
//System.out.println("MousePressed Start...");
if(currentProcess != null)
......@@ -90,15 +89,15 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
if (!e.isConsumed() && !marquee.isSelected()) {
start = currentProcess.snap(e.getPoint());
beginCell = currentProcess.getFirstCellForLocation(e.getX(), e.getY());
e.consume();
}
}
super.mousePressed(e);
//System.out.println("MousePressed End...");
}
public void mouseDragged(MouseEvent event) {
//System.out.println("MouseDragged Start...");
if(currentProcess != null)
......@@ -118,13 +117,13 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
event.consume();
}
}
super.mouseDragged(event);
// System.out.println("MouseDragged End...");
}
public void mouseReleased(MouseEvent event) {
if(currentProcess != null)
{
endCell= currentProcess.getFirstCellForLocation(event.getX(), event.getY());
......@@ -148,13 +147,13 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
else if (edgeNormal.isSelected()) {
if (beginCell!=null&&endCell!=null) {
doConnectionSet(beginCell,endCell);
}
}
event.consume();
}
marquee.doClick();
start = null;
current = null;
}
......@@ -171,7 +170,7 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
event.consume();
}
}
super.mouseMoved(event);
}
......@@ -198,8 +197,8 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
((ProcessGraph)currentProcess).addPort("output",(DefaultGraphCell)cell);
((ProcessGraph)currentProcess).addPort("input",(DefaultGraphCell)cell2);
p= new Point(rect.x+rect.width,rect.y+((rect.height*(port+1))/(port+2)));
p2= new Point(rect2.x,rect2.y+((rect2.height*(port2+1))/(port2+2)));
p= new Point(rect.x+rect.width/2,rect.y+rect.height/2);
p2= new Point(rect2.x+rect2.width/2,rect2.y+rect2.height/2);
Point p3 = currentProcess.fromScreen(new Point(p));
Point p4 = currentProcess.fromScreen(new Point(p2));
......@@ -213,6 +212,10 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
viewMap.put(edge, map);
Object[] insert = new Object[]{edge};
ConnectionSet cs = new ConnectionSet();
System.out.println("point p "+p);
System.out.println("point p2 "+p2);
cs.connect(edge,currentProcess.getPortForLocation(p.x,p.y), true);
cs.connect(edge,currentProcess.getPortForLocation(p2.x,p2.y), false);
currentProcess.getModel().insert(insert, cs, null, viewMap);
......@@ -221,14 +224,14 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
}
}
public void overlay(Graphics g) {
super.overlay(g);
if (start != null) {
if ((edgeNormal.isSelected()) && current != null)
g.drawLine(start.x, start.y, current.x, current.y);
}
}
}
/**
* $Id: ProcessGraph.java,v 1.5 2002-05-16 14:14:53 gchomat Exp $
* $Id: ProcessGraph.java,v 1.6 2002-05-21 09:44:32 frederic Exp $
*
* Transmorpher
*
......@@ -67,7 +67,7 @@ public class ProcessGraph extends JGraph implements Comparator{
static final int APPLYPROCESS =5;
static final int APPLYRULESET =6;
static final int APPLYQUERY =7;
ArrayList tmp =null;
public ProcessGraph() {
......@@ -379,6 +379,7 @@ public class ProcessGraph extends JGraph implements Comparator{
public void layoutPorts(Object vertex1,Object userObject) {
GraphView v = getView();
ArrayList result = new ArrayList();
Map port = new Hashtable();
Set edges = DefaultGraphModel.getEdges(graphModel, new Object[]{vertex1});
Iterator it = edges.iterator();
......@@ -387,15 +388,20 @@ public class ProcessGraph extends JGraph implements Comparator{
if ((userObject.equals("output"))&&(getSourceVertex(edge)==vertex1)){
result.add(graphModel.getTarget(edge));
port.put(graphModel.getTarget(edge),edge);}
else if (getTargetVertex(edge)==vertex1){
else if ((userObject.equals("input"))&&(getTargetVertex(edge)==vertex1)){
result.add(graphModel.getSource(edge));
port.put(graphModel.getSource(edge),edge);}
}
Collections.sort(result,this);
for (int i=0;i<result.size();i++) {
Rectangle rect = getCellBounds((Object)result.get(i));
System.out.println(rect.y);
}
if(tmp!=null){
if(i<tmp.size())
System.out.println("ordre "+i+" "+tmp.get(i).equals(result.get(i)));
}
Rectangle rect = getCellBounds((Object)result.get(i));
//System.out.println(rect.y+" object port "+((Object)result.get(i)).toString());
}
for (int i=0;i<result.size();i++) {
Map map = GraphConstants.createMap();
......@@ -403,18 +409,24 @@ public class ProcessGraph extends JGraph implements Comparator{
int u = GraphConstants.PERCENT;
Object edge = port.get(result.get(i));
if (userObject.equals("input")){
GraphConstants.setOffset(map,new Point(0,(u*(i+1))/(result.size()+1)));
CellView cellView = v.getMapping(graphModel.getTarget(edge),false);
//System.out.println( "y input" +(int)(u*(i+1))/(result.size()+1));
GraphConstants.setOffset(map,new Point(0,(int)(u*(i+1))/(result.size()+1)));
// System.out.println("offset input" +map.get(GraphConstants.OFFSET));
CellView cellView = v.getMapping(graphModel.getTarget(edge),false);
attributes.put(cellView,map);
}
else {
GraphConstants.setOffset(map,new Point(u,(u*(i+1))/(result.size()+1)));
//System.out.println( "y output" +(int)(u*(i+1))/(result.size()+1));
GraphConstants.setOffset(map,new Point(u,(int)(u*(i+1))/(result.size()+1)));
// System.out.println("offset output" +map.get(GraphConstants.OFFSET));
CellView cellView = v.getMapping(graphModel.getSource(edge),false);
//System.out.println("port view "+cellView.getClass());
attributes.put(cellView,map);
}
v.edit(attributes);
//getModel().edit(null,attributes,null,null);
}
tmp=result;
}
......@@ -496,9 +508,10 @@ public class ProcessGraph extends JGraph implements Comparator{
Map map = GraphConstants.createMap();
int u = GraphConstants.PERCENT;
if (userObject.equals("input"))
GraphConstants.setOffset(map,new Point(0,getFactor(nb)));
GraphConstants.setOffset(map,new Point(u/2,u/2));
else
GraphConstants.setOffset(map,new Point(u,getFactor(nb)));
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);
......
/**
* $Id: ProcessGraphModel.java,v 1.1 2002-05-13 12:43:31 gchomat Exp $
* $Id: ProcessGraphModel.java,v 1.2 2002-05-21 09:44:32 frederic Exp $
*
* Transmorpher
*
......@@ -37,17 +37,17 @@ import java.util.*;
public class ProcessGraphModel extends DefaultGraphModel{
// Constructors
public ProcessGraphModel(){
super();
}
public ProcessGraphModel(boolean attributeStore){
super(attributeStore);
}
/**
* Inserts the <code>cells</code> and connections into the model,
* and passes <code>attributeMap</code> to the views. If the
......@@ -61,5 +61,49 @@ public class ProcessGraphModel extends DefaultGraphModel{
super.insert(roots,cs,pm,attributeMap);
}
public boolean acceptsSource(Object edge,Object port) {
return (((Edge)edge).getTarget()!=port);
}
public boolean acceptsTarget(Object edge,Object port) {
return (((Edge)edge).getSource()!=port);
}
}
procedure DFS( NbSommets: integer );
{ Algorithme de parcours en profondeur d'un graphe non-orient
avec reprsentation par liste de connectivit.
Version modifie pour dtecter les cycles. }
var CmptrVisite,
IndexSommet : 0..MaxNbSommets;
NumeroDOrdre: array[1..MaxNbSommets] of integer;
procedure Visite (IndexSommet,
Precedent : integer);
var Voisin : Ref;
begin
CmptrVisite := CmptrVisite + 1;
NumeroDOrdre[IndexSommet]:=CmptrVisite;
Voisin := PremierVoisin[IndexSommet];
while Voisin <> nil do
with Voisin^ do begin
if NumeroDOrdre[IndexVoisin]=0 then
Visite(IndexVoisin,IndexSommet)
else if IndexVoisin<>Precedent then (* cycle dtect *);
Voisin := Suivant;
end; { whith }
end; { Visite }
begin { DFS }
CmptrVisite := 0;
for IndexSommet:= 1 to NbSommets do
NumeroDOrdre[IndexSommet]:=0;
for IndexSommet := 1 to NbSommets do
if NumeroDOrdre[IndexSommet] = 0 then
Visite (IndexSommet,0)
end; { DFS }
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