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

add fichier+images

parent 419b16e8
/**
*
*$Id: FlowComposer.java,v 1.26 2002-05-29 16:20:21 frederic Exp $
*$Id: FlowComposer.java,v 1.27 2002-05-30 08:57:55 frederic Exp $
*
* Transmorpher
*
......@@ -91,30 +91,30 @@ public class FlowComposer extends JPanel implements GraphModelListener,
//Array of all Flowcomposer instance
protected static ArrayList instances = new ArrayList();
//The current Process of our Transmorpher.Warning!!! This reference must be sync whith marqueeHandler.currentProcess.
protected JGraph currentProcess;
//Version
protected static String version = "v0.1";
protected static String version = "v0.1";
//Application Title
protected static String title = "FlowComposer";
//private JPanel editor;
protected JToolBar toolbar;
protected JMenuBar menubar;
// for represent the process notion we dacide to use a tabbed Pane
protected JTabbedPane tabProcess;
// External resource
protected static ResourceBundle resource;
//The window listener.
protected static FCWindowListener windowListener;
// The current file name
protected static FCWindowListener windowListener;
// The current file name
protected String filename;
// Application Icon. From resource file.
......@@ -251,7 +251,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
JPanel tool = new JPanel();
//tool.setLayout(new GridLayout(2,0));
tool.add(createToolBar("toolbar1"));
tool.add(createToolBar("toolbar2"));
//tool.add(createToolBar("toolbar2"));
panel.add(tool,BorderLayout.NORTH);
//Add a JTabbedPane for represnting the process notion.
tabProcess= new JTabbedPane();
......@@ -270,16 +270,16 @@ public class FlowComposer extends JPanel implements GraphModelListener,
marqueeHandler.setCurrentProcess(currentProcess);
update();
}
}
}
}
}
}
}
);
//Init the main process
addProcess(new String("main"),MAIN);
// Add the Graph as Center Component
panel.add(tabProcess, BorderLayout.CENTER);
this.add(createMenubar(),BorderLayout.NORTH);
......@@ -312,7 +312,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
JFrame frame = new JFrame();
frame.addWindowListener(windowListener);
FlowComposer flowComposer = createInstance(filename,null);
......@@ -320,13 +320,13 @@ public class FlowComposer extends JPanel implements GraphModelListener,
frame.setTitle(title +" "+ version + " -- " + flowComposer.getFileName());
frame.pack();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
frame.setLocation(
screenSize.width/2 - frame.getSize().width/2 + instances.size()*10,
screenSize.height/2 - frame.getSize().height/2+ instances.size()*10);
frame.show();
instances.add(flowComposer);
return flowComposer;
......@@ -357,13 +357,13 @@ public class FlowComposer extends JPanel implements GraphModelListener,
}
public void addProcess(String name, int type){
UndoHandler undoHandler;
JScrollPane sp ;
Transformation process = null;
switch(type)
{
{
case MAIN :
process = new fr.fluxmedia.transmorpher.Graph.Main(name,transmorpher);
if ( transmorpher.getMain() == null) {
......@@ -375,16 +375,16 @@ public class FlowComposer extends JPanel implements GraphModelListener,
transmorpher.addTransformation(name,process);
break;
}
if(tabProcess != null )
{
{
currentProcess = processFactory.createProcess(process);
((ProcessGraph)currentProcess).setMarqueeHandler(marqueeHandler);
//marqueeHandler.setCurrentProcess(currentProcess);
undoHandler = new UndoHandler();
registerListeners(currentProcess);
currentProcess.getModel().addUndoableEditListener(undoHandler);
sp = new JScrollPane(currentProcess);
JViewport port = sp.getViewport();
colrule = new Rule(Rule.HORIZONTAL,isMetric,currentProcess);
......@@ -413,7 +413,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
}
}
/**
* Create the menubar for the app. By default this pulls the
* definition of the menu from the associated resource file.
......@@ -464,11 +464,11 @@ public class FlowComposer extends JPanel implements GraphModelListener,
* of lookups.
*/
protected JMenuItem createMenuItem(String cmd) {
//System.out.println("cmd " +cmd);
String subMenu = getResourceString(cmd + menuSuffix);
if (subMenu != null) {
String[] itemKeys = tokenize(subMenu);
......@@ -541,7 +541,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
* resource file for the definition of the toolbar.
*/
public Component createToolBar(String st) {
toolbar = new JToolBar();
toolbar.putClientProperty("JToolBar.isRollover", Boolean.TRUE);
......@@ -568,19 +568,19 @@ public class FlowComposer extends JPanel implements GraphModelListener,
public Component createToolButton(String key) {
Object button;
Object button;
AbstractButton b = null;
URL url;
url = getResource(key + imageSuffix);
System.out.println(url + " " + key);
button= buttons.get(key);
if (button instanceof AbstractButton) {
b = (AbstractButton) button;
b.setIcon(new ImageIcon(url));
......@@ -616,8 +616,8 @@ public class FlowComposer extends JPanel implements GraphModelListener,
return b;
}
/* Invoked after the selection or the model has changed. */
public void update() {
undoAction.update();
......@@ -731,7 +731,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
cmd = new String[v.size()];
for (int i = 0; i < cmd.length; i++)
cmd[i] = (String) v.elementAt(i);
return cmd;
}
......@@ -804,13 +804,13 @@ public class FlowComposer extends JPanel implements GraphModelListener,
//
// Listeners
//
// PropertyChangeListener
public void propertyChange(PropertyChangeEvent evt) {
//System.out.println("PropertyChange " + evt);
update();
}
// GraphSelectionListener
public void valueChanged(GraphSelectionEvent e) {
//System.out.println("GraphSelection" + e);
......@@ -822,7 +822,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
//System.out.println("View " + obs + " " + arg);
update();
}
// GraphModelListener
public void graphChanged(GraphModelEvent e) {
//System.out.println("GraphModel" + e);
......@@ -831,41 +831,41 @@ public class FlowComposer extends JPanel implements GraphModelListener,
currentProcess.setSelectionCells(inserted);
update();
}
/* This will change the source of the actionevent to graph. */
protected class EventRedirector implements ActionListener {
protected Action action;
public EventRedirector(Action a) {
this.action = a;
}
public void actionPerformed(ActionEvent e) {
e = new ActionEvent(currentProcess,
e.getID(),
e = new ActionEvent(currentProcess,
e.getID(),
e.getActionCommand(),
e.getModifiers());
action.actionPerformed(e);
}
}
// Yarked from JMenu, ideally this would be public.
protected PropertyChangeListener createActionChangeListener(AbstractButton b) {
return new ActionChangedListener(b);
}
// Yarked from JMenu, ideally this would be public.
protected class ActionChangedListener implements PropertyChangeListener {
AbstractButton button;
ActionChangedListener(AbstractButton b) {
super();
button = b;
}
public void propertyChange(PropertyChangeEvent e) {
String propertyName = e.getPropertyName();
if (e.getPropertyName().equals(Action.NAME) &&
button instanceof JMenuItem) {
......@@ -877,12 +877,12 @@ public class FlowComposer extends JPanel implements GraphModelListener,
}
}
}
//
// Custom Model
//
class UndoHandler implements UndoableEditListener {
JGraph process;
......@@ -905,20 +905,20 @@ public class FlowComposer extends JPanel implements GraphModelListener,
redoAction.update();
}
public void setProcess(JGraph process){
this.process = process;
}
public JGraph getProcess(){
return process;
}
}
protected Hashtable createButtons() {
Hashtable buttons = new Hashtable();
if (marqueeHandler instanceof FCMarqueeHandler) {
ButtonGroup group = new ButtonGroup();
FCMarqueeHandler mh = marqueeHandler;
......@@ -937,22 +937,22 @@ public class FlowComposer extends JPanel implements GraphModelListener,
//group.add(mh.EdgeNull); buttons.put("EdgeNull", mh.EdgeNull);
mh.marquee.doClick();
}
return buttons;
}
/**
* Ask to user to enter the name of the new process.
*
*/
public String getNameProcess(){
String name = JOptionPane.showInternalInputDialog(this,resource.getString("EnterNameMessage"),resource.getString("EnterName"),JOptionPane.QUESTION_MESSAGE);
return name;
}
// Status Bar
......@@ -989,11 +989,11 @@ public class FlowComposer extends JPanel implements GraphModelListener,
//System.out.println("win "+instances.indexOf(e.getWindow()));
}
}
class UndoAction extends AbstractAction {
public UndoAction() {
super("undo"+actionSuffix);
setEnabled(false);
......@@ -1014,21 +1014,21 @@ public class FlowComposer extends JPanel implements GraphModelListener,
protected void update() {
//System.out.println("test "+((ProcessGraph)currentProcess).getUndoManager().canUndo(getView()));
if(currentProcess!= null & ((ProcessGraph)currentProcess).getUndoManager()!=null){
if(((ProcessGraph)currentProcess).getUndoManager().canUndo(getView())) {
setEnabled(true);
putValue(Action.NAME, ((ProcessGraph)currentProcess).getUndoManager().getUndoPresentationName());
}
else {
setEnabled(false);
putValue(Action.NAME, "Undo");
}
}
}
}
class RedoAction extends AbstractAction {
public RedoAction() {
super("redo"+actionSuffix);
......@@ -1038,12 +1038,12 @@ public class FlowComposer extends JPanel implements GraphModelListener,
public void actionPerformed(ActionEvent e) {
try {
if(currentProcess!= null & ((ProcessGraph)currentProcess).getUndoManager()!=null)
{
{
((ProcessGraph)currentProcess).getUndoManager().redo(getView());
}
} catch (CannotRedoException ex) {
ex.printStackTrace();
}
......@@ -1054,7 +1054,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
protected void update() {
//System.out.println("test "+((ProcessGraph)currentProcess).getUndoManager().canUndo(getView()));
if(currentProcess!= null & ((ProcessGraph)currentProcess).getUndoManager()!=null){
if(((ProcessGraph)currentProcess).getUndoManager().canRedo(getView())) {
setEnabled(true);
......@@ -1067,7 +1067,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
}
}
}
class LoadAction extends AbstractAction {
private FlowComposer flow;
LoadAction(FlowComposer flow) {
......@@ -1259,7 +1259,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
}
public void actionPerformed(ActionEvent e) {
newEditor();
newEditor();
}
}
......@@ -1284,18 +1284,18 @@ public class FlowComposer extends JPanel implements GraphModelListener,
}
}
class CompileAction extends AbstractAction {
CompileAction() {
super("compile"+actionSuffix);
}
public void actionPerformed(ActionEvent e) {
}
}
class DebugAction extends AbstractAction {
DebugAction() {
......@@ -1311,7 +1311,7 @@ public class FlowComposer extends JPanel implements GraphModelListener,
ExpandTAction() {
super("expandT"+actionSuffix);
}
public void actionPerformed(ActionEvent e) {
......
/*
* Created by IntelliJ IDEA.
* User: administrateur
* Date: 29 mai 2002
* Time: 10:28:15
* To change template for new class use
* Code Style | Class Templates options (Tools | IDE Options).
*/
package fr.fluxmedia.flowcomposer;
import com.jgraph.graph.DefaultGraphCell;
public class PortProcessCell extends DefaultGraphCell {
public PortProcessCell() {
this(null);
}
public PortProcessCell(Object userObject) {
super(userObject);
}
}
/*
* Created by IntelliJ IDEA.
* User: administrateur
* Date: 29 mai 2002
* Time: 10:34:05
* To change template for new class use
* Code Style | Class Templates options (Tools | IDE Options).
*/
package fr.fluxmedia.flowcomposer;
import com.jgraph.graph.VertexRenderer;
import com.jgraph.graph.GraphConstants;
import java.awt.*;
public class PortProcessRenderer extends VertexRenderer {
/**
* paint the PortProcessCell.
*
*/
public void paint(Graphics g) {
int b = borderWidth;
Graphics2D g2 = (Graphics2D) g;
Dimension d = getSize();
boolean tmp = selected;
if (super.isOpaque()) {
g.setColor(super.getBackground());
g.fillRect(b-1, b-1, d.width-b, d.height-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));
drawApplyProcess(g,d,b);
}
if (selected) {
g2.setStroke(GraphConstants.SELECTION_STROKE);
g.setColor(graph.getHighlightColor());
drawApplyProcess(g,d,b);
}
}
private void drawApplyProcess(Graphics g,Dimension d , int b ) {
g.drawRect(b-1, b-1,d.width-b, d.height-b);
}
}
/*
* Created by IntelliJ IDEA.
* User: administrateur
* Date: 29 mai 2002
* Time: 10:37:34
* To change template for new class use
* Code Style | Class Templates options (Tools | IDE Options).
*/
package fr.fluxmedia.flowcomposer;
import com.jgraph.graph.VertexView;
import com.jgraph.graph.CellMapper;
import com.jgraph.graph.CellViewRenderer;
import com.jgraph.JGraph;
import java.awt.*;
public class PortProcessView extends VertexView{
public static PortProcessRenderer renderer = new PortProcessRenderer();
public PortProcessView(Object cell, JGraph graph, CellMapper cm) {
super(cell, graph, cm);
}
/**
* Returns the intersection of the bounding rectangle and the
* straight line between the source and the specified point p.
* The specified point is expected not to intersect the bounds.
*/
public Point getPerimeterPoint(Point source, Point p) {
// Compute relative bounds
// Compute Perimeter Point
int xout = 0;
int yout = 0;
// Return perimeter point
return new Point (xout, yout);
}
public CellViewRenderer getRenderer() {
return renderer;
}
}
/*
* Created by IntelliJ IDEA.
* User: administrateur
* Date: 29 mai 2002
* Time: 17:44:28