Commit 53fa7920 authored by Guillaume Chomat's avatar Guillaume Chomat
Browse files

observer/observable minor modification

parent d9ffd89e
......@@ -26,7 +26,7 @@ menubar=file edit transmorpher process component channel layout help
file=load download upload - save saveAs - quit
fileLabel=File
loadLabel=Load
loadLabel=Load
loadImage=resources/load.gif
downloadLabel=Import
downloadImage=resources/import.gif
......@@ -149,38 +149,38 @@ aboutImage=resources/help.gif
# toolbar definition
#
toolbar1=Load Save SaveAs - undo redo - Cut Copy Paste - ZoomIn zoomButton ZoomOut
LoadAction=load
LoadToolTip=Load
LoadImage=resources/load.gif
SaveAction=save
SaveToolTip=Save
SaveImage=resources/save.gif
SaveAsAction=saveAs
SaveAsToolTip=SaveAs
SaveAsImage=resources/saveas.gif
undoAction=undo
undoToolTip=Undo
undoImage=resources/Undo.gif
redoAction=redo
redoToolTip=Redo
redoImage=resources/Redo.gif
CutAction=cut
CutToolTip=Cut
CutImage=resources/cut.gif
CopyAction=copy
CopyToolTip=Copy
CopyImage=resources/copy.gif
PasteAction=paste
PasteToolTip=Paste
PasteImage=resources/paste.gif
ZoomInAction=zoomIn
ZoomInToolTip=ZoomIn
ZoomInImage=resources/zoomin.gif
ZoomOutAction=zoomOut
ZoomOutToolTip=ZoomOut
ZoomOutImage=resources/zoomout.gif
toolbar2=Marquee Generate Serialize Merge Dispatch ApplyExternal ApplyProcess ApplyRuleset ApplyQuery - EdgeNormal PortRight PortLeft
LoadAction=load
LoadToolTip=Load
LoadImage=resources/load.gif
SaveAction=save
SaveToolTip=Save
SaveImage=resources/save.gif
SaveAsAction=saveAs
SaveAsToolTip=SaveAs
SaveAsImage=resources/saveas.gif
undoAction=undo
undoToolTip=Undo
undoImage=resources/Undo.gif
redoAction=redo
redoToolTip=Redo
redoImage=resources/Redo.gif
CutAction=cut
CutToolTip=Cut
CutImage=resources/cut.gif
CopyAction=copy
CopyToolTip=Copy
CopyImage=resources/copy.gif
PasteAction=paste
PasteToolTip=Paste
PasteImage=resources/paste.gif
ZoomInAction=zoomIn
ZoomInToolTip=ZoomIn
ZoomInImage=resources/zoomin.gif
ZoomOutAction=zoomOut
ZoomOutToolTip=ZoomOut
ZoomOutImage=resources/zoomout.gif
toolbar2=Marquee Generate Serialize Merge Dispatch ApplyExternal ApplyProcess ApplyRuleset ApplyQuery - EdgeNormal PortLeft PortRight
#- In Out
#- EdgeTest EdgeIterator EdgeNull
toolboxLabel=Outils
......@@ -204,12 +204,12 @@ ApplyQueryTooltip=ApplyQuery
ApplyQueryImage=resources/applyQuery.gif
EdgeNormalTooltip=EdgeNormal
EdgeNormalImage=resources/edge.gif
PortRightTooltip=PortRight
PortRightAction=portright
PortRightImage=resources/PortRight.gif
PortLeftTooltip=PortLeft
PortLeftImage=resources/PortLeft.gif
PortLeftAction=portleft
PortRightTooltip=PortRight
PortRightAction=portright
PortRightImage=resources/PortLeft.gif
PortLeftTooltip=PortLeft
PortLeftImage=resources/PortRight.gif
PortLeftAction=portleft
#EdgeTestTooltip=EdgeTest
#EdgeTestImage=resources/EdgeTest.gif
#EdgeIteratorTooltip=EdgeIterator
......
/**
* $Id: ApplyProcessCell.java,v 1.4 2002-06-13 12:04:50 gchomat Exp $
* $Id: ApplyProcessCell.java,v 1.5 2002-06-13 14:18:50 gchomat Exp $
*
* Transmorpher
*
......@@ -49,7 +49,7 @@ public class ApplyProcessCell extends FCGraphCell{
}
public void update(Observable o, Object arg){
super.update(o,arg);
}
}
/**
* $Id: FCGraphCell.java,v 1.1 2002-06-13 12:10:25 gchomat Exp $
* $Id: FCGraphCell.java,v 1.2 2002-06-13 14:18:50 gchomat Exp $
*
* Transmorpher
*
......@@ -87,7 +87,7 @@ public class FCGraphCell extends DefaultGraphCell implements Observer{
CallImpl call = (CallImpl)userObject;
Port port;
int number = call.inPorts().length();
if(type == FCConstants.PORTOUTPUT)
{
......@@ -113,6 +113,8 @@ public class FCGraphCell extends DefaultGraphCell implements Observer{
if(process != null)
{
System.out.println("obs "+obs);
PortCell pc = new PortCell((Port)arg,((Port)arg).getType());
Map map = GraphConstants.createMap();
......@@ -122,14 +124,15 @@ public class FCGraphCell extends DefaultGraphCell implements Observer{
ParentMap parent = new ParentMap();
parent.addEntry(pc,this);
System.out.println("cell "+ this);
//System.out.println("cell "+ this);
Map viewMap = new Hashtable();
viewMap.put(pc,map);
process.getModel().insert(new Object[]{pc},null,parent,viewMap);
System.out.println("type "+((Port)arg).getType());
process.updatePort(this,((Port)arg).getType());
}
}
......
/**
* $Id: FCMarqueeHandler.java,v 1.29 2002-06-13 14:05:26 frederic Exp $
* $Id: FCMarqueeHandler.java,v 1.30 2002-06-13 14:18:50 gchomat Exp $
*
* Transmorpher
*
......@@ -119,11 +119,11 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
start = currentProcess.snap(e.getPoint());
firstPort = port;
if ((edgeNormal.isSelected())&&(firstPort != null)) {
double scale = currentProcess.getScale();
start = firstPort.getLocation(null);
start = new Point((int)(start.x*scale),(int)(start.y*scale));
}
e.consume();
double scale = currentProcess.getScale();
start = firstPort.getLocation(null);
start = new Point((int)(start.x*scale),(int)(start.y*scale));
}
e.consume();
}
......@@ -142,14 +142,14 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
g.setColor(fg);
g.setXORMode(bg);
overlay(g);
current = currentProcess.snap(event.getPoint());
current = currentProcess.snap(event.getPoint());
if (edgeNormal.isSelected()){
double scale = currentProcess.getScale();
port = currentProcess.getPortViewAt((int)(event.getX()/scale),(int)(event.getY()/scale));
if ( port != null ) {
current = port.getLocation(null);
current = new Point((int)(current.x*scale),(int)(current.y*scale));
}
double scale = currentProcess.getScale();
port = currentProcess.getPortViewAt((int)(event.getX()/scale),(int)(event.getY()/scale));
if ( port != null ) {
current = port.getLocation(null);
current = new Point((int)(current.x*scale),(int)(current.y*scale));
}
}
g.setColor(bg);
g.setXORMode(fg);
......@@ -224,44 +224,44 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
currentTransformation.addCall(call);
//dialog = new EditCall((JFrame)(currentProcess.getTopLevelAncestor()),(ProcessGraph)currentProcess,null,start,FCConstants.APPLYQUERY);}
}
else if (edgeNormal.isSelected())
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 ((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 portIn = (DefaultGraphCell)port.getCell();
channel.setOut((Port)portOut.getUserObject());
channel.setIn((Port)portIn.getUserObject());
((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);
}
}
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 portIn = (DefaultGraphCell)port.getCell();
channel.setOut((Port)portOut.getUserObject());
channel.setIn((Port)portIn.getUserObject());
((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);
}
}
}
}
event.consume();
......@@ -290,8 +290,8 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
if (edgeNormal.isSelected()) {
PortView oldPort = port;
double scale=currentProcess.getScale();
PortView newPort = currentProcess.getPortViewAt((int)(event.getX()/scale),(int)(event.getY()/scale));
double scale=currentProcess.getScale();
PortView newPort = currentProcess.getPortViewAt((int)(event.getX()/scale),(int)(event.getY()/scale));
if (oldPort != newPort) {
Graphics g = currentProcess.getGraphics();
Color bg = currentProcess.getBackground();
......@@ -316,16 +316,16 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
currentProcess.getModel().insert(null,null,null,null);
}
public int lenght(java.util.Iterator it) {
int compteur = 0;
while (it.hasNext()){
it.next();
compteur++;
}
return compteur;
}
public int lenght(java.util.Iterator it) {
int compteur = 0;
while (it.hasNext()){
it.next();
compteur++;
}
return compteur;
}
/*
public void doConnectionSet(Object cell,Object cell2) {
......@@ -435,12 +435,12 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
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)) {
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();
......@@ -449,8 +449,8 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
r.translate(-s, -s);
r.setSize(r.width+2*s, r.height+2*s);
currentProcess.getUI().paintCell(g, port, r, true);
}
}
}
}
}
}
......
......@@ -35,6 +35,7 @@ public class FCPortRenderer extends PortRenderer {
g.setColor(graph.getBackground());
//g.setXORMode(graph.getBackground());
if (preview) {
System.out.println("preview");
g.setColor(getBackground());
//g.setColor(Color.red);
g.drawRect(1, 1, d.width-3, d.height-3);
......@@ -44,9 +45,11 @@ public class FCPortRenderer extends PortRenderer {
g.setColor(getForeground());
if (offset) {
System.out.println("offset");
g.drawRect(1, 1, d.width-3,d.height-3);
} else if (!preview)
{
System.out.println("not preview");
// g.setColor(Color.red);
g.drawRect(2, 2, d.width-3, d.height-3);
......
/**
*
*$Id: FlowComposer.java,v 1.46 2002-06-13 14:05:26 frederic Exp $
*$Id: FlowComposer.java,v 1.47 2002-06-13 14:18:50 gchomat Exp $
*
* Transmorpher
*
......@@ -1680,12 +1680,9 @@ public class FlowComposer extends JPanel implements GraphModelListener,
}
public void actionPerformed(ActionEvent e) {
((ProcessGraph)currentProcess).newPort(FCConstants.PORTINPUT);
}
if(currentProcess!=null)
((ProcessGraph)currentProcess).newPort(FCConstants.PORTOUTPUT);
}
protected void update(){
if (currentProcess != null) {
......@@ -1700,7 +1697,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
for (int i = 0; i <tmp.length; i++){
cell = (DefaultGraphCell)tmp[i];
if (cell instanceof DefaultEdge){}
else if (!((cell instanceof MergeCell)||(cell instanceof ApplyProcessCell))){
else if (!((cell instanceof DispatchCell)||(cell instanceof ApplyProcessCell))){
accept=false;
}
}
......@@ -1724,8 +1721,8 @@ public class FlowComposer extends JPanel implements GraphModelListener,
}
public void actionPerformed(ActionEvent e) {
((ProcessGraph)currentProcess).newPort(FCConstants.PORTOUTPUT);
if(currentProcess!=null)
((ProcessGraph)currentProcess).newPort(FCConstants.PORTINPUT);
}
protected void update(){
......@@ -1741,8 +1738,9 @@ public class FlowComposer extends JPanel implements GraphModelListener,
for (int i = 0; i <tmp.length; i++){
cell = (DefaultGraphCell)tmp[i];
if (cell instanceof DefaultEdge){}
else if (!((cell instanceof DispatchCell)||(cell instanceof ApplyProcessCell))){
accept=false;
else if(!((cell instanceof MergeCell)||(cell instanceof ApplyProcessCell))){
accept=false;
break;
}
}
if (accept) setEnabled (true);
......
/**
* $Id: ProcessGraph.java,v 1.30 2002-06-13 14:05:26 frederic Exp $
* $Id: ProcessGraph.java,v 1.31 2002-06-13 14:18:50 gchomat Exp $
*
* Transmorpher
*
......@@ -162,31 +162,24 @@ public class ProcessGraph extends JGraph implements Comparator, Observer{
* @param cell reference to the object in the model
*/
public CellView createView(Object cell, CellMapper map) {
CellView view = null;
if (cell instanceof PortCell)
view = createPortView((PortCell) cell, map);
else if (cell instanceof Edge)
view = createEdgeView((Edge) cell, map);
else
view = createVertexView(cell, map);
if (cell instanceof Port )
System.out.println("true");
map.putMapping(cell, view);
view.refresh(true); // Create Dependent Views
view.update();
return view;
CellView view = null;
if (cell instanceof PortCell)
{
view = createPortView((PortCell) cell, map);
//System.out.println("view "+view);
}
else if (cell instanceof Edge)
view = createEdgeView((Edge) cell, map);
else
view = createVertexView(cell, map);
map.putMapping(cell, view);
view.refresh(true); // Create Dependent Views
view.update();
return view;
}
protected PortView createPortView(PortCell p, CellMapper cm){
//System.out.println("object port "+p);
return new FCPortView(p, this, cm);
return new FCPortView(p, this, cm);
}
/*protected PortView createPortView(Port p, CellMapper cm){
......@@ -760,7 +753,7 @@ addVertex(call, position,FCConstants.MERGE);
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);
......@@ -792,31 +785,26 @@ addVertex(call, position,FCConstants.MERGE);
public void newPort(int type){
Object[] tmp = getSelectionCells();
DefaultGraphCell cell;
String name ="";
Port port ;
if (tmp.length != 0) {
for (int i = 0; i <tmp.length; i++){
cell = (DefaultGraphCell)tmp[i];
if (cell instanceof FCGraphCell && cell.getUserObject() instanceof CallImpl){
port = new Port(name,(Call)cell.getUserObject(),type);
if(type == FCConstants.PORTOUTPUT)
((CallImpl)cell.getUserObject()).addOut(port);
else
((CallImpl)cell.getUserObject()).addIn(port);
}
}
}
else {
TransformationImpl transformation = (TransformationImpl)userObject;
port = new Port(name,transformation,type);
Object[] tmp = getSelectionCells();
DefaultGraphCell cell;
String name ="";
Port port ;
if (tmp.length != 0) {
for (int i = 0; i <tmp.length; i++){
cell = (DefaultGraphCell)tmp[i];
if (cell instanceof FCGraphCell){
//System.out.println("new port for cell "+cell);
((FCGraphCell)cell).newPort(type);
}
}
}
else {
TransformationImpl transformation = (TransformationImpl)userObject;
port = new Port(name,transformation,type);
if (type==FCConstants.PORTINPUT)
{
......
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