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

update

parent 474c31ef
/**
* $Id: ApplyQueryRenderer.java,v 1.5 2002-06-26 12:25:09 frederic Exp $
* $Id: ApplyQueryRenderer.java,v 1.6 2002-06-28 15:29:31 frederic Exp $
*
* Transmorpher
*
......@@ -65,7 +65,7 @@ public class ApplyQueryRenderer extends VertexRenderer {
if (selected) {
g2.setStroke(GraphConstants.SELECTION_STROKE);
g.setColor(graph.getHighlightColor());
System.out.println(graph.getHighlightColor());
drawApplyQuery(g,d,b);
}
}
......
/**
* $Id: DispatchRenderer.java,v 1.5 2002-04-30 13:12:29 gchomat Exp $
* $Id: DispatchRenderer.java,v 1.6 2002-06-28 15:29:31 frederic Exp $
*
* Transmorpher
*
......@@ -54,6 +54,7 @@ public class DispatchRenderer extends VertexRenderer {
drawDispatch(g,d,b);
}
if (selected) {
g2.setStroke(GraphConstants.SELECTION_STROKE);
g.setColor(graph.getHighlightColor());
drawDispatch(g,d,b);
......
/**
* $Id: FCGraphCell.java,v 1.5 2002-06-25 08:23:39 gchomat Exp $
* $Id: FCGraphCell.java,v 1.6 2002-06-28 15:29:31 frederic Exp $
*
* Transmorpher
*
......@@ -116,7 +116,7 @@ public class FCGraphCell extends DefaultGraphCell implements Observer{
public void update(Observable obs, Object arg)
{
System.out.println("modify a call + arg "+ arg);
if(obs instanceof Call)
{
......
/**
*
*$Id: FCGraphUI.java,v 1.6 2002-06-25 09:50:38 frederic Exp $
*$Id: FCGraphUI.java,v 1.7 2002-06-28 15:29:31 frederic Exp $
*
* Transmorpher
*
......@@ -69,13 +69,13 @@ import com.jgraph.plaf.basic.BasicGraphUI;
public class FCGraphUI extends BasicGraphUI{
// FCGraphUI constructors
public static ComponentUI createUI(JComponent x) {
return new FCGraphUI();
return new FCGraphUI();
}
public FCGraphUI(){
super();
super();
}
/**
......@@ -85,170 +85,190 @@ public class FCGraphUI extends BasicGraphUI{
protected MouseListener createMouseListener() {
return new FCMouseHandler();
}
/**
* Main painting routine.
*/
public void paint(Graphics g, JComponent c) {
if (graph != c)
throw new InternalError("BasicGraphUI cannot paint "+c.toString()+
"; "+graph+" was expected.");
Graphics2D g2 = (Graphics2D) g;
Rectangle paintBounds = new Rectangle(g.getClipBounds());
Rectangle real = graph.fromScreen(new Rectangle(paintBounds));
// Paint Background (Typically Grid)
paintBackground(g);
// Remember current affine transform
AffineTransform at = g2.getTransform();
// Use anti aliasing
if (graph.isAntiAliased())
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
// Use Swing's scaling
double scale = graph.getScale();
g2.scale(scale, scale);
// Paint cells
CellView[] views = graphView.getRoots();
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);
}
// Reset affine transform and antialias
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
g2.setTransform(at);
/* change with JGRAPH as port have views: draw ports two once
// Paint Foreground (Typically Ports)
// paintForeground(g);
// Paint Handle
if (handle != null)
handle.paint(g);
// Empty out the renderer pane, allowing renderers to be gc'ed.
if (rendererPane != null)
if (graph != c)
throw new InternalError("BasicGraphUI cannot paint "+c.toString()+
"; "+graph+" was expected.");
Graphics2D g2 = (Graphics2D) g;
//System.out.println(g.getClipBounds()+"g.getClipBounds()");
Rectangle paintBounds = new Rectangle(g.getClipBounds());
Rectangle real = graph.fromScreen(new Rectangle(paintBounds));
//System.out.println(real+"real");
// Paint Background (Typically Grid)
paintBackground(g);
// Remember current affine transform
AffineTransform at = g2.getTransform();
// Use anti aliasing
if (graph.isAntiAliased())
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
// Use Swing's scaling
double scale = graph.getScale();
g2.scale(scale, scale);
// Paint cells
CellView[] views = graphView.getRoots();
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);
}
// Reset affine transform and antialias
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
g2.setTransform(at);
/* change with JGRAPH as port have views: draw ports two once
// Paint Foreground (Typically Ports)
// paintForeground(g);
// Paint Handle
if (handle != null)
handle.paint(g);
// Empty out the renderer pane, allowing renderers to be gc'ed.
if (rendererPane != null)
rendererPane.removeAll(); */
}
public void paintCell(Graphics g, CellView view, Rectangle bounds,
boolean preview)
{
if (!view.isLeaf()) {
CellView[] children = view.getChildViews();
for (int i = 0; i < children.length; i++)
paintCell(g, children[i], children[i].getBounds(), preview);
}
boolean focus = graph.getSelectionModel().isChildrenSelected(view.getCell());
boolean sel = graph.isCellSelected(view.getCell());
//System.out.println(sel+"booleen de selection");
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
* based on mouse events.
*/
public class FCMouseHandler extends BasicGraphUI.MouseHandler
{
/**
* 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)
marquee.mousePressed(e);
super.mousePressed(e);
}
else if(e.getButton() == MouseEvent.BUTTON3 ){
System.out.println("marquee "+marquee);
if (marquee!= null)
marquee.mousePressed(e);
super.mousePressed(e);
}
else
super.mousePressed(e);
}
/**
* Invoked when a mouse button has been pressed on a component.
*/
public void mousePressed(MouseEvent e) {
if(e.isPopupTrigger())
{
if (marquee!= null)
marquee.mousePressed(e);
super.mousePressed(e);
}
else if(e.getButton() == MouseEvent.BUTTON3 ){
if (marquee!= null)
marquee.mousePressed(e);
super.mousePressed(e);
}
else
super.mousePressed(e);
}
public void mouseDragged(MouseEvent e) {
try {
autoscroll(graph, e.getPoint());
if (handler == marquee)
marquee.mouseDragged(e);
else if (handler == null && !isEditing(graph) && focus != null) {
if (!graph.isCellSelected(focus.getCell())) {
selectCellForEvent(focus.getCell(), e);
cell = null;
}
if (handle != null)
handle.mousePressed(e);
handler = handle;
}
if (handle != null && handler == handle)
handle.mouseDragged(e);
} finally {
//cell = null;
}
}
try {
autoscroll(graph, e.getPoint());
if (handler == marquee)
marquee.mouseDragged(e);
else if (handler == null && !isEditing(graph) && focus != null) {
if (!graph.isCellSelected(focus.getCell())) {
selectCellForEvent(focus.getCell(), e);
cell = null;
}
if (handle != null)
handle.mousePressed(e);
handler = handle;
}
if (handle != null && handler == handle)
handle.mouseDragged(e);
} finally {
//cell = null;
}
}
/**
* Invoked when the mouse pointer has been moved on a component
* (with no buttons down).
*/
* Invoked when the mouse pointer has been moved on a component
* (with no buttons down).
*/
public void mouseMoved(MouseEvent e) {
if (graph != null && graph.isEnabled()) {
if (marquee != null)
marquee.mouseMoved(e);
if (handle != null)
handle.mouseMoved(e);
if (!e.isConsumed())
graph.setCursor(Cursor.getDefaultCursor());
}
}
if (graph != null && graph.isEnabled()) {
if (marquee != null)
marquee.mouseMoved(e);
if (handle != null)
handle.mouseMoved(e);
if (!e.isConsumed())
graph.setCursor(Cursor.getDefaultCursor());
}
}
public void mouseReleased(MouseEvent e) {
try {
if (!e.isConsumed()) {
if (handler == marquee)
marquee.mouseReleased(e);
else if (handler == handle && handle != null)
handle.mouseReleased(e);
if (isDescendant(cell, focus) && e.getModifiers() != 0) {
// Do not switch to parent if Special Selection
cell = focus;
}
if (!e.isConsumed() && cell != null) {
Object tmp = cell.getCell();
boolean wasSelected = graph.isCellSelected(tmp);
selectCellForEvent(tmp, e);
focus = cell;
if (wasSelected && graph.isCellSelected(tmp))
{
Object root = ((DefaultMutableTreeNode) tmp).getRoot();
selectCellForEvent(root, e);
focus = graphView.getMapping(root, false);
}
}
}
} finally {
insertionLocation = null;
handler = null;
cell = null;
}
try {
if (!e.isConsumed()) {
if (handler == marquee)
marquee.mouseReleased(e);
else if (handler == handle && handle != null)
handle.mouseReleased(e);
if (isDescendant(cell, focus) && e.getModifiers() != 0) {
// Do not switch to parent if Special Selection
cell = focus;
}
if (!e.isConsumed() && cell != null) {
Object tmp = cell.getCell();
boolean wasSelected = graph.isCellSelected(tmp);
selectCellForEvent(tmp, e);
focus = cell;
if (wasSelected && graph.isCellSelected(tmp))
{
Object root = ((DefaultMutableTreeNode) tmp).getRoot();
selectCellForEvent(root, e);
focus = graphView.getMapping(root, false);
}
}
}
} finally {
insertionLocation = null;
handler = null;
cell = null;
}
}
protected boolean isDescendant(CellView parent, CellView child) {
if (parent != null && parent.getCell() instanceof DefaultMutableTreeNode &&
child != null && child.getCell() instanceof DefaultMutableTreeNode)
{
DefaultMutableTreeNode p = (DefaultMutableTreeNode) parent.getCell();
DefaultMutableTreeNode c = (DefaultMutableTreeNode) child.getCell();
return p.isNodeDescendant(c);
}
return false;
}
protected boolean isDescendant(CellView parent, CellView child) {
if (parent != null && parent.getCell() instanceof DefaultMutableTreeNode &&
child != null && child.getCell() instanceof DefaultMutableTreeNode)
{
DefaultMutableTreeNode p = (DefaultMutableTreeNode) parent.getCell();
DefaultMutableTreeNode c = (DefaultMutableTreeNode) child.getCell();
return p.isNodeDescendant(c);
}
return false;
}
} // End of BasicGraphUI.MouseHandler
......
/**
* $Id: FCMarqueeHandler.java,v 1.38 2002-06-25 09:50:38 frederic Exp $
* $Id: FCMarqueeHandler.java,v 1.39 2002-06-28 15:29:31 frederic Exp $
*
* Transmorpher
......@@ -399,8 +399,10 @@ public class FCMarqueeHandler extends BasicMarqueeHandler {
protected void previewPort(Graphics g) {
if (port != null) {
java.util.Iterator it = ((DefaultPort)port.getCell()).edges();
if ((firstPort!=null)&&(firstPort!=port)){
if ((Utils.lenght(it)<1)) {
java.util.Iterator it2 = ((DefaultPort)firstPort.getCell()).edges();
if ((Utils.lenght(it)<1)&&(Utils.lenght(it2)<1)) {
DefaultGraphCell firstCell = (DefaultGraphCell)(firstPort.getParentView()).getCell();
DefaultGraphCell cell = (DefaultGraphCell)(port.getParentView()).getCell();
int firstType = ((PortCell)firstPort.getCell()).getType();
......
/*
* Created by IntelliJ IDEA.
* User: Administrateur
* Date: 28 juin 2002
* Time: 13:25:49
* To change template for new class use
* Code Style | Class Templates options (Tools | IDE Options).
*/
package fr.fluxmedia.flowcomposer;
import javax.swing.*;
import com.jgraph.JGraph;
import com.jgraph.graph.*;
import com.jgraph.event.*;
import java.awt.event.ComponentListener;
import java.awt.event.ComponentEvent;
import java.util.Observer;
import java.util.Observable;
import javax.swing.JPanel;
import javax.swing.BorderFactory;
import java.awt.*;
public class FCOverviewPanel extends JPanel implements ComponentListener,
GraphModelListener,
Observer
{
protected ProcessGraph graph;
public FCOverviewPanel(JGraph g) {
GraphView view = new ViewRedirector(g, g.getView());
graph = new ProcessGraph(g.getModel(), view);
graph.setAntiAliased(true);
setBorder(BorderFactory.createEtchedBorder());
graph.getModel().addGraphModelListener(this);
graph.setEnabled(false);
g.addComponentListener(this);
g.getView().addObserver(this);
setLayout(new BorderLayout());
add(graph, BorderLayout.CENTER);
}
//
// Observer
//
public void update(Observable o, Object arg) {
componentResized(null);
}
//
// GraphModelListener
//
public void graphChanged(GraphModelEvent e) {
componentResized(null);
}
//
// Component Listener
//
public void componentResized(ComponentEvent e) {
Rectangle r = AbstractCellView.getBounds(graph.getView().getRoots());
double scale = 0.5;
if (r != null) {
Dimension d = new Dimension(r.x+r.width, r.y+r.height);
Dimension s = getSize();
double sx = s.getWidth()*0.95/d.getWidth();
double sy = s.getHeight()*0.95/d.getHeight();
scale = Math.min(Math.max(Math.min(sx, sy), 0.05), 0.5);
}
graph.setScale(scale);
repaint();
}
public void componentShown(ComponentEvent e) {
componentResized(e);
}
public void componentHidden(ComponentEvent e) { }
public void componentMoved(ComponentEvent e) { }
//
// View Redirector
//
public class ViewRedirector extends GraphView {
protected GraphView realView;
public ViewRedirector(JGraph graph, GraphView realView) {
super(null, graph);
this.realView = realView;
setModel(graph.getModel());
}
public CellView[] getRoots() {
return realView.getRoots();
}
public CellView getMapping(Object cell, boolean create) {
if (realView != null)
return realView.getMapping(cell, create);
return null;
}
public void putMapping(Object cell, CellView view) {
if (realView != null)
realView.putMapping(cell, view);
}
}
}
......@@ -21,13 +21,14 @@ import com.jgraph.graph.*;
public class FCPortRenderer extends PortRenderer {
public FCPortRenderer(){
super();
}
public void paint ( Graphics g )
{
Dimension d = getSize();
g.setClip(0, 0, d.width + 1, d.height + 1);
......@@ -36,7 +37,7 @@ public class FCPortRenderer extends PortRenderer {
paintPreview(g, d);
else
paintPort(g, d);
}
protected void paintPreview(Graphics g, Dimension d )
......@@ -48,7 +49,7 @@ public class FCPortRenderer extends PortRenderer {
g.setXORMode(graph.getBackground());
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);
......@@ -61,8 +62,7 @@ public class FCPortRenderer extends PortRenderer {
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 !=