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

lyout frame

parent 730c8b6b
/**
*
*$Id: FlowComposer.java,v 1.57 2002-06-28 15:29:31 frederic Exp $
*$Id: FlowComposer.java,v 1.58 2002-07-01 13:09:45 frederic Exp $
*
* Transmorpher
*
......@@ -58,6 +58,7 @@ import java.net.URLConnection;
import java.util.Map;
import java.util.Hashtable;
import java.util.ArrayList;
import java.util.List;
import javax.swing.undo.*;
import javax.swing.tree.*;
import javax.swing.event.*;
......@@ -110,6 +111,9 @@ public class FlowComposer extends JPanel implements GraphModelListener,
protected Layout touchLayout;
private Rectangle viewPortRect = null;
//private JPanel editor;
protected JToolBar toolbar;
protected JMenuBar menubar;
......@@ -483,47 +487,51 @@ public class FlowComposer extends JPanel implements GraphModelListener,
public void createProcess(Object process){
UndoHandler undoHandler;
currentProcess = (ProcessGraph)process;
if(tabProcess != null ) {
if(marqueeHandler == null)
marqueeHandler = new FCMarqueeHandler(this);
currentProcess.setMarqueeHandler(marqueeHandler);
undoHandler = new UndoHandler();
registerListeners(currentProcess);
currentProcess.getModel().addUndoableEditListener(undoHandler);
pane = new JPanel();
Border loweredbevel = BorderFactory.createLoweredBevelBorder();
flow = new FlowLayout(FlowLayout.LEFT,0,0);
pane.setLayout(flow);
pane.add(currentProcess);
sp = new JScrollPane(pane,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
sp = (JScrollPane)(tabProcess.add(currentProcess.getName(),sp));
tabProcess.setSelectedComponent(sp);
//componentResized(null);
currentProcess.setPreferredSize(new Dimension(PREFERRED_WIDTH,PREFERRED_HEIGHT));
currentProcess.setBorder(loweredbevel);
currentProcess.setBackground(Color.WHITE);
undoHandler.setProcess(currentProcess);
JButton buttonView = new JButton("VG");
sp.setCorner(JScrollPane.LOWER_RIGHT_CORNER,buttonView);
ActionListener buttonListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("ca passe ici");
JDialog overviewDlg = new JDialog(getFrame(),"GeneralView", false);
Container fContentPane = overviewDlg.getContentPane();
fContentPane.setLayout(new BorderLayout());
FCOverviewPanel overviewPanel = new FCOverviewPanel(currentProcess);
fContentPane.add(overviewPanel);
overviewDlg.setSize(new Dimension(180,180));
overviewDlg.setLocationRelativeTo(getFrame());
overviewDlg.show();
}
};
buttonView.addActionListener(buttonListener);
if(marqueeHandler == null)
marqueeHandler = new FCMarqueeHandler(this);
currentProcess.setMarqueeHandler(marqueeHandler);
undoHandler = new UndoHandler();
registerListeners(currentProcess);
currentProcess.getModel().addUndoableEditListener(undoHandler);
pane = new JPanel();
Border loweredbevel = BorderFactory.createLoweredBevelBorder();
if (viewPortRect != null) {
int height = viewPortRect.height-PREFERRED_HEIGHT;
int width = viewPortRect.width-PREFERRED_WIDTH;
if ((width<0)&&(height<0)) flow = new FlowLayout(FlowLayout.LEFT,0,0);
else if (width<0) flow = new FlowLayout(FlowLayout.LEFT,0,height/2);
else if (height<0) flow = new FlowLayout(FlowLayout.LEFT,width/2,0);
else flow = new FlowLayout(FlowLayout.LEFT,width/2,height/2);
}
else { flow = new FlowLayout(FlowLayout.LEFT,0,0);}
pane.setLayout(flow);
pane.add(currentProcess);
sp = new JScrollPane(pane,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
sp = (JScrollPane)(tabProcess.add(currentProcess.getName(),sp));
tabProcess.setSelectedComponent(sp);
//componentResized(null);
currentProcess.setPreferredSize(new Dimension(PREFERRED_WIDTH,PREFERRED_HEIGHT));
currentProcess.setBorder(loweredbevel);
currentProcess.setBackground(Color.WHITE);
undoHandler.setProcess(currentProcess);
JButton buttonView = new JButton("VG");
sp.setCorner(JScrollPane.LOWER_RIGHT_CORNER,buttonView);
ActionListener buttonListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("ca passe ici");
JDialog overviewDlg = new JDialog(getFrame(),"GeneralView", false);
Container fContentPane = overviewDlg.getContentPane();
fContentPane.setLayout(new BorderLayout());
FCOverviewPanel overviewPanel = new FCOverviewPanel(currentProcess);
fContentPane.add(overviewPanel);
overviewDlg.setSize(new Dimension(180,180));
overviewDlg.setLocationRelativeTo(getFrame());
overviewDlg.show();
}
};
buttonView.addActionListener(buttonListener);
}
......@@ -1047,12 +1055,33 @@ public class FlowComposer extends JPanel implements GraphModelListener,
public void componentMoved(ComponentEvent e) { }
public void componentResized(ComponentEvent e) {
//System.out.println(e);
Rectangle r = pane.getBounds();
System.out.println(r);
//System.out.println(r);
viewPortRect = sp.getViewport().getBounds();
List processList = processFactory.getAllProcess();
java.util.Iterator it = processList.iterator();
while (it.hasNext()) {
ProcessGraph process = (ProcessGraph)it.next();
Rectangle processRect = process.getBounds();
FlowLayout layout = ((FlowLayout)((Container)process.getParent()).getLayout());
int height = viewPortRect.height-processRect.height;
int width = viewPortRect.width-processRect.width;
if (processRect.height<viewPortRect.height) {
layout.setVgap(height/2);
((JComponent)process.getParent()).revalidate();
}
if (processRect.width<viewPortRect.width) {
layout.setHgap(width/2);
((JComponent)process.getParent()).revalidate();
}
if (height<0) {
layout.setVgap(0);
((JComponent)process.getParent()).revalidate();
}
if (width<0) {
layout.setHgap(0);
((JComponent)process.getParent()).revalidate();
}
}
}
public void componentShown(ComponentEvent e) {
......@@ -1763,11 +1792,18 @@ public class FlowComposer extends JPanel implements GraphModelListener,
}
public void actionPerformed(ActionEvent e) {
(flow.getGraph()).setScale(1.0);
}
}
double s = (flow.getGraph()).getScale();
(flow.getGraph()).setScale(1.0);
Rectangle r = currentProcess.getBounds();
if (s<2.0) {
int scale = (int)((s-1.0)*100);
System.out.println(scale);
currentProcess.setPreferredSize(new Dimension((int)(r.width-((r.width*scale)/100)),(int)(r.height-((r.height*scale)/100))));
}
}
}
class ZoomInAction extends AbstractAction {
class ZoomInAction extends AbstractAction {
private FlowComposer flow;
ZoomInAction(FlowComposer flow) {
super("zoomIn"+actionSuffix);
......@@ -1777,8 +1813,12 @@ public class FlowComposer extends JPanel implements GraphModelListener,
public void actionPerformed(ActionEvent e) {
double s = (flow.getGraph()).getScale();
if (s<2.0) (flow.getGraph()).setScale((flow.getGraph()).getScale()+0.25);
else (flow.getGraph()).setScale((flow.getGraph()).getScale()*2.0);
Rectangle r = currentProcess.getBounds();
if (s<2.0) {
(flow.getGraph()).setScale((flow.getGraph()).getScale()+0.25);
currentProcess.setPreferredSize(new Dimension((int)(r.width+((r.width*25)/100)),(int)(r.height+((r.height*25)/100))));
}
else { (flow.getGraph()).setScale((flow.getGraph()).getScale()*2.0);}
//(flow.getGraph()).setScale((flow.getGraph()).getScale()+0.5);
if ((flow.getGraph()).getSelectionCell() != null)
(flow.getGraph()).scrollCellToVisible((flow.getGraph()).getSelectionCell());
......
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