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

update

parent 6417ac50
......@@ -19,6 +19,19 @@ TRANSMORPHER_VERSION = 1.0
menubar=file edit transmorpher process component channel layout help
#dialog definition
dialogTitle=Properties
idLabel=id :
fileLab=file :
refLabel=ref :
strategyLabel=strategy :
typeLabel=type :
okTitle=OK
cancelTitle=CANCEL
# file Menu definition
#
# Each of the strings that follow form a key to be
......
......@@ -66,6 +66,10 @@ public class FCGraphTools {
return cells;
}
//
// Sorting With CostFunction
//
......
/**
*
*$Id: FCGraphUI.java,v 1.5 2002-06-25 08:23:39 gchomat Exp $
*$Id: FCGraphUI.java,v 1.6 2002-06-25 09:50:38 frederic Exp $
*
* Transmorpher
*
......@@ -118,7 +118,7 @@ public class FCGraphUI extends BasicGraphUI{
for (int i = 0; i < views.length; i++) {
//System.out.println(views[i].getClass()+"class");
Rectangle bounds = views[i].getBounds();
if (bounds != null && real != null && bounds.intersects(real))
paintCell(g, views[i], bounds, false);
......@@ -128,8 +128,9 @@ public class FCGraphUI extends BasicGraphUI{
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
g2.setTransform(at);
// Paint Foreground (Typically Ports)
paintForeground(g);
/* change with JGRAPH as port have views: draw ports two once
// Paint Foreground (Typically Ports)
// paintForeground(g);
// Paint Handle
if (handle != null)
......@@ -137,59 +138,10 @@ public class FCGraphUI extends BasicGraphUI{
// Empty out the renderer pane, allowing renderers to be gc'ed.
if (rendererPane != null)
rendererPane.removeAll();
rendererPane.removeAll(); */
}
/** Get the preferred Size for a cell view.*/
public Dimension getPreferredSize(JGraph graph, CellView view) {
// Either label or icon
boolean label = graph.convertValueToString(view.getCell()).length() > 0;
boolean icon = GraphConstants.getIcon(view.getAttributes()) != null;
if (view != null && (label || icon)) {
boolean focus = (getFocusedCell() == view.getCell()) && graph.hasFocus();
// Only ever removed when UI changes, this is OK!
Component component = view.getRendererComponent(graph, focus, false,false);
if (component != null) {
graph.add(component);
component.validate();
System.out.println("preferredSize() "+ component.getPreferredSize());
return component.getPreferredSize();
}
}
System.out.println("preferredSize() "+ view.getBounds().getSize());
return view.getBounds().getSize();
}
/**
* Paints the renderer of <code>view</code> to <code>g</code>
* at <code>bounds</code>. Recursive implementation that
* paints the children first.<p>
* The reciever should NOT modify <code>clipBounds</code>, or
* <code>insets</code>. The <code>preview</code> flag is passed to
* the renderer, and is not used here.
*/
public void paintCell(Graphics g, CellView view, Rectangle bounds,
boolean preview)
{
//System.out.println("view = " + view + " " + view.isLeaf());
if (!view.isLeaf()) {
CellView[] children = view.getChildViews();
for (int i = 0; i < children.length; i++){
//System.out.println("child " + children[i]);
paintCell(g, children[i], children[i].getBounds(), preview);
}
}
boolean focus = graph.getSelectionModel().isChildrenSelected(view.getCell());
boolean sel = graph.isCellSelected(view.getCell());
Component component = view.getRendererComponent(graph, sel, focus, preview);
rendererPane.paintComponent(g, component, graph, bounds.x, bounds.y,
bounds.width, bounds.height, true);
}
/**
* TreeMouseListener is responsible for updating the selection
......@@ -202,14 +154,20 @@ public class FCGraphUI extends BasicGraphUI{
* Invoked when a mouse button has been pressed on a component.
*/
public void mousePressed(MouseEvent e) {
System.out.println("e "+e.getButton());
if(e.isPopupTrigger())
{
if (marquee!= null)
{
if (marquee!= null)
marquee.mousePressed(e);
super.mousePressed(e);
}
else
else if(e.getButton() == MouseEvent.BUTTON3 ){
System.out.println("marquee "+marquee);
if (marquee!= null)
marquee.mousePressed(e);
super.mousePressed(e);
}
else
super.mousePressed(e);
}
......
/**
* $Id: FCMarqueeHandler.java,v 1.37 2002-06-25 08:23:39 gchomat Exp $
* $Id: FCMarqueeHandler.java,v 1.38 2002-06-25 09:50:38 frederic Exp $
*
* Transmorpher
......@@ -84,6 +84,7 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
int count = 0;
public FCMarqueeHandler(FlowComposer flowcomposer){
this.flowcomposer = flowcomposer;
gt = new FCGraphTools();
......@@ -98,6 +99,13 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
}
}
public void update() {
if (currentProcess.canConnect())
edgeNormal.setEnabled(true);
else edgeNormal.setEnabled(false);
}
public JGraph getCurrentProcess(){
return currentProcess;
}
......@@ -135,7 +143,14 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
return;
}
}
}
else if(e.getButton() == MouseEvent.BUTTON3)
{
current = currentProcess.snap(e.getPoint());
flowcomposer.showPopup(e);
return;
}
else{
if(currentProcess != null){
if (!e.isConsumed() && !marquee.isSelected()) {
......@@ -182,7 +197,7 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
overlay(g);
event.consume();
}
else {}
}
......@@ -267,7 +282,7 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
if ((firstPort!=null)&&(port!=null)&&(firstPort!=port)) {
java.util.Iterator itFirst = ((DefaultPort)firstPort.getCell()).edges();
java.util.Iterator it = ((DefaultPort)port.getCell()).edges();
if ((lenght(itFirst)<1)&&(lenght(it)<1)) {
if ((Utils.lenght(itFirst)<1)&&(Utils.lenght(it)<1)) {
DefaultGraphCell firstCell = (DefaultGraphCell)(firstPort.getParentView()).getCell();
DefaultGraphCell cell = (DefaultGraphCell)(port.getParentView()).getCell();
int firstType = ((PortCell)firstPort.getCell()).getType();
......@@ -347,7 +362,7 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
name = "C"+ca.getId()+"-"+count;
}
else{ name = "C"+count;}
count++;
count++;
channel = new Channel( name, (fr.fluxmedia.transmorpher.Graph.Process)currentTransformation );
DefaultGraphCell portOut = (DefaultGraphCell)firstPort.getCell();
DefaultGraphCell portIn = (DefaultGraphCell)port.getCell();
......@@ -369,14 +384,7 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
public int lenght(java.util.Iterator it) {
int compteur = 0;
while (it.hasNext()){
it.next();
compteur++;
}
return compteur;
}
public void overlay(Graphics g) {
......@@ -392,7 +400,7 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
if (port != null) {
java.util.Iterator it = ((DefaultPort)port.getCell()).edges();
if ((firstPort!=null)&&(firstPort!=port)){
if ((lenght(it)<1)) {
if ((Utils.lenght(it)<1)) {
DefaultGraphCell firstCell = (DefaultGraphCell)(firstPort.getParentView()).getCell();
DefaultGraphCell cell = (DefaultGraphCell)(port.getParentView()).getCell();
int firstType = ((PortCell)firstPort.getCell()).getType();
......@@ -410,7 +418,7 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
}
}
else {
if ((lenght(it)<1)) {
if ((Utils.lenght(it)<1)) {
paintPort(g);
}
}
......
......@@ -44,10 +44,12 @@ public class FCPortRenderer extends PortRenderer {
Map attr = view.getAttributes();
int offset = ( GraphConstants.getOffset(attr) != null ) ? 0 : 1;
g.setXORMode(graph.getBackground());
g.setColor(getBackground());
g.drawRect(0, 0, d.width - offset, d.height - offset);
g.setColor(Color.GREEN);
//g.setColor(getBackground());
//System.out.println("je suis passe la");
g.drawRect(0, 0, d.width - offset, d.height - offset);
g.drawRect(1, 1, d.width - 2 - offset, d.height - 2 - offset);
g.drawRect(2, 2, d.width - 4 - offset, d.height - 4 - offset);
......@@ -55,11 +57,12 @@ public class FCPortRenderer extends PortRenderer {
protected void paintPort ( Graphics g, Dimension d )
{
Map attr = view.getAttributes();
Map attr = view.getAttributes();
Color backCol = GraphConstants.getBackground(attr);
Color foreCol = GraphConstants.getForeground(attr);
//System.out.println(backCol+"back");
//System.out.println(foreCol+"fore");
g.setPaintMode();
if ( foreCol != null )
......
/**
*
*$Id: FCPortView.java,v 1.4 2002-06-13 12:04:50 gchomat Exp $
*$Id: FCPortView.java,v 1.5 2002-06-25 09:50:38 frederic Exp $
*
* Transmorpher
*
......@@ -45,8 +45,8 @@ public class FCPortView extends PortView{
/** Renderer for the class. */
public static FCPortRenderer renderer = new FCPortRenderer();
protected static int size = 15;
protected int size = 10;
/**
......@@ -61,7 +61,14 @@ public class FCPortView extends PortView{
super(cell, graph, mapper);
}
/**
public void setSize(int size) {
this.size=size;
}
public int getSize() {
return size;
}
/**
* Returns the bounds for the port view.
*/
public Rectangle getBounds() {
......
/**
*
*$Id: FlowComposer.java,v 1.52 2002-06-25 08:23:39 gchomat Exp $
*$Id: FlowComposer.java,v 1.53 2002-06-25 09:50:38 frederic Exp $
*
* Transmorpher
*
......@@ -102,6 +102,8 @@ public class FlowComposer extends JPanel implements GraphModelListener,
//Application Title
protected static String title = "FlowComposer";
protected Layout touchLayout;
//private JPanel editor;
protected JToolBar toolbar;
protected JMenuBar menubar;
......@@ -240,14 +242,12 @@ public class FlowComposer extends JPanel implements GraphModelListener,
// init the GUI.
initGUI();
//init the Main Process.
if(init_main)
initMainProcess();
touchLayout = new Layout(currentProcess);
parser = new ParserRDF();
}
public static void init() {
......@@ -256,7 +256,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
protected void initTransmorpher(){
processFactory = new FCProcessFactory(this);
processFactory = new FCProcessFactory(this);
if(filename != null)
{
......@@ -271,7 +271,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
transmorpher = new Transmorpher(filename,resource.getString("TRANSMORPHER_VERSION"),0,false);
//proccess Factory listen transmorpher modification.
transmorpher.addObserver(processFactory);
}
}
}
protected void initGUI(){
......@@ -286,6 +286,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
JPanel panel = new JPanel();
panel.setPreferredSize(new Dimension(PREFERRED_WIDTH,PREFERRED_HEIGHT));
// Use Border Layout
panel.setLayout(new BorderLayout());
......@@ -329,6 +330,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
else
{
marqueeHandler.setCurrentProcess(currentProcess);
touchLayout = new Layout(currentProcess);
update();
}
}
......@@ -342,7 +344,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
// Add the Graph as Center Component
center.add(tabProcess, BorderLayout.CENTER);
panel.add(center,BorderLayout.CENTER);
this.add(createMenubar(),BorderLayout.NORTH);
this.add(createMenubar(),BorderLayout.NORTH);
this.add(panel,BorderLayout.CENTER);
this.add(status,BorderLayout.SOUTH);
......@@ -725,11 +727,10 @@ public class FlowComposer extends JPanel implements GraphModelListener,
redoAction.update();
portLeftAction.update();
portRightAction.update();
propertiesCAction.update();
zoomInAction.update();
propertiesCAction.update();
zoomInAction.update();
zoomOutAction.update();
marqueeHandler.update();
}
/* Add this documents listeners to the specified graph. */
......@@ -980,13 +981,17 @@ public class FlowComposer extends JPanel implements GraphModelListener,
// GraphSelectionListener
public void valueChanged(GraphSelectionEvent e) {
//System.out.println("GraphSelection" + e);
if (!currentProcess.isSelectionEmpty()) {
System.out.println("ca passe la aussi");
touchLayout.setDamper(0);}
update();
}
// View Observer
public void update(Observable obs, Object arg) {
//System.out.println("View " + obs + " " + arg);
update();
touchLayout.resetDamper();
update();
}
......@@ -997,7 +1002,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
if (inserted != null && inserted.length > 0)
currentProcess.setSelectionCells(inserted);
touchLayout.resetDamper();
update();
}
......@@ -1161,202 +1166,147 @@ public class FlowComposer extends JPanel implements GraphModelListener,
protected JFileChooser fileChooser;
protected JButton ok,cancel,fileChooserButton;
protected JLabel idJLabel, fileJLabel, refJLabel, strategyJLabel, typeJLabel, alertJLabel;
final static String idLabel ="id :";
final static String fileLabel ="file :";
final static String refLabel ="ref :";
final static String strategyLabel ="strategy :";
final static String typeLabel ="type :";
final static String okTitle = "OK";
final static String cancelTitle = "Cancel";
final static int HORIZONTAL_GAP = 5;
final static int VERTICAL_GAP = 5;
protected Call call;
protected int type;
protected BoxLayout layout;
protected boolean editMode;
protected Point location;
protected Container contentPane;
public EditCall(Call call, Point location,int type){
super((JFrame)getTopLevelAncestor(),"",true);
this.call = call;
this.type=type;
this.call = call;
this.type=type;
this.location = location;
editMode = (call != null);
this.setResizable(false);
buildDialog();
editMode = (call != null);
this.setResizable(false);
contentPane = getContentPane();
contentPane.setLayout(new GridLayout(0,1));
buildDialog();
}
protected void makeComponent(Object[] component) {
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout(FlowLayout.LEFT,5,5));
for (int i=0;i<component.length;i++) {
panel.add((Container)component[i]);
}
contentPane.add(panel);
}
/**
build the dialog depends on type and call
*/
public void buildDialog(){
// Dimension space = new Dimension(10,10);
getContentPane().setLayout(new BoxLayout(getContentPane(),BoxLayout.Y_AXIS));
JPanel propertiesPane;
JPanel labelPane;
JPanel fieldPane;
JPanel chooserPane;
//GridBagLayout****
Object attributes = null;
Parameters parameters = null;
if(editMode)
{
if(editMode){
attributes = call.getAttributes();
parameters = call.getParameters();
}
else
{
parameters = call.getParameters();}
else{
attributes = FCConstants.defaultAttributes(type);
parameters = new Parameters();
}
propertiesPane = new JPanel();
propertiesPane.setLayout( new BoxLayout(propertiesPane,BoxLayout.X_AXIS));
labelPane = new JPanel();
labelPane.setLayout( new BoxLayout(labelPane,BoxLayout.Y_AXIS));
fieldPane = new JPanel();
fieldPane.setLayout(new BoxLayout(fieldPane,BoxLayout.Y_AXIS));
idJLabel = new JLabel(idLabel);
labelPane.add(idJLabel);
parameters = new Parameters();}
//id
// id construction
idJLabel = new JLabel(resource.getString("idLabel"));
idJLabel.setPreferredSize(new Dimension(30,20));
if(editMode){
// id
idText= new JTextField(call.getId(),20);
}
idText= new JTextField(call.getId());}
else{
// id
idText= new JTextField(((Hashtable)attributes).get("id")+""+location.x,20);
}
fieldPane.add(idText);
idText= new JTextField(((Hashtable)attributes).get("id")+""+location.x);}
idText.setPreferredSize(new Dimension(150,20));
Object[] compId = new Object[]{idJLabel,idText};
makeComponent(compId);
//list of type. if null no type must be defined for this call.
Object[] list = FCConstants.getListType(type);
if(list != null)
{
typeJLabel = new JLabel(typeLabel);
//labelPane.add(Box.createVerticalGlue());
labelPane.add(typeJLabel);
// type construction
if(list != null){
typeJLabel = new JLabel(resource.getString("typeLabel"));
typeJLabel.setPreferredSize(new Dimension(30,20));
typeChooser = new JComboBox(list);
//fieldPane.add(Box.createVerticalGlue());
fieldPane.add(typeChooser);
typeChooser.setPreferredSize(new Dimension(150,20));
if(editMode){
Object value = ((Parameters)attributes).getParameter("type");
typeChooser.setSelectedItem(value);
}
Object[] compType = new Object[]{typeJLabel,typeChooser};
makeComponent(compType);
}
Object file = (parameters instanceof Parameters)?((Parameters)parameters).getParameter("file"):((Hashtable)attributes).get("file");
if(file != null )
{
//label
fileJLabel = new JLabel(fileLabel);
labelPane.add(Box.createVerticalGlue());
labelPane.add(fileJLabel);
//textField
fileText = new JTextField((String)file,15);
Object file = (parameters instanceof Parameters)?((Parameters)parameters).getParameter("file"):((Hashtable)attributes).get("file");