浏览代码

resolved frame layout problem at start

Kolja Strohm 6 年之前
父节点
当前提交
79e8d60d0e
共有 2 个文件被更改,包括 12 次插入17 次删除
  1. 1 5
      src/bk/BlockCalc.java
  2. 11 12
      src/view/MainView.java

+ 1 - 5
src/bk/BlockCalc.java

@@ -3,13 +3,8 @@ package bk;
 import javax.swing.JTree;
 
 import animation.AlgorithmStage;
-import animation.AnimatedAlgorithm;
-import animation.CodeLine;
-import animation.ControlFlow;
-import animation.Memory;
 import animation.PseudoCodeNode;
 import codelines.FunctionDefinition;
-import graph.LayeredGraphNode;
 import lib.TextLayoutHelper;
 
 /**
@@ -23,6 +18,7 @@ public class BlockCalc implements AlgorithmStage {
     public PseudoCodeNode createPseudocodeTree( JTree tree ) {
         String[] vars = { "graph", "L", "v", "r", "neighbors", "layout" };
         PseudoCodeNode root = new PseudoCodeNode( TextLayoutHelper.setupPseudoCode( "calculateBlockGraph( graph, layout )", vars ), tree, new FunctionDefinition( new String[]{ "graph", "layout" } ) );
+        
         return root;
     }
 }

+ 11 - 12
src/view/MainView.java

@@ -450,7 +450,7 @@ public class MainView {
         JScrollPane debugView = new JScrollPane( debugText );
         debugView.setBounds( treeView.getX(), treeView.getY() + 500, treeView.getWidth(), 250 );
         
-        frame.setSize( (int)graph.getWidth( LayoutType.TOP_BOTTOM_LEFT ) * 2 + 575, (int)graph.getHeight( LayoutType.TOP_BOTTOM_LEFT ) * 2 + 200 );
+        frame.setSize( (int)graph.getWidth( LayoutType.TOP_BOTTOM_LEFT ) * 2 + 450, (int)graph.getHeight( LayoutType.TOP_BOTTOM_LEFT ) * 2 + 50 );
         frame.setLocation( 100, 100 );
         frame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
         frame.setVisible( true );
@@ -479,8 +479,6 @@ public class MainView {
         spane.setLeftComponent( layne );
         spane.setResizeWeight(0.5);
         
-        //JPanel onlyCurrentLayout = new JPanel();
-        //onlyCurrentLayout.setLayout( new BorderLayout() );
         JPanel menue = new JPanel();
         menue.setLayout( null );
         menue.setPreferredSize( new Dimension( 410, 500 ) );
@@ -510,7 +508,7 @@ public class MainView {
         menue.add( spane2 );
         
         spane.setRightComponent( menue);
-        spane.setContinuousLayout(true);
+        spane.setContinuousLayout( true );
         spane.setDividerLocation( frame.getWidth() - 430 );
         spane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, new PropertyChangeListener() {
 
@@ -521,9 +519,7 @@ public class MainView {
             
         });
         frame.add( spane );
-        frame.setSize( frame.getWidth() + 1, frame.getHeight() );
-        frame.setSize( frame.getWidth() - 1, frame.getHeight() );
-        frame.validate();
+        frame.revalidate();
         frame.repaint();
 
         frame.addComponentListener(new ComponentAdapter()
@@ -581,6 +577,14 @@ public class MainView {
                 frame.repaint();
             }
         });
+        frame.setSize( frame.getWidth() + 1, frame.getHeight() );
+        frame.setSize( frame.getWidth() - 1, frame.getHeight() );
+        if( frame.getHeight() < (int)graph.getHeight( LayoutType.TOP_BOTTOM_LEFT ) * 2 + 50 )
+        {
+            double factor = (graph.getHeight( LayoutType.TOP_BOTTOM_LEFT ) * 2) / (frame.getHeight()-50);
+            frame.setSize( (int)((frame.getWidth() - 450) / factor) + 450, frame.getHeight() );
+            spane.setDividerLocation( frame.getWidth() - 330 );
+        }
 
         optionsDialog = new OptionsDialog();
         optionsDialog.addActionListener( new ActionListener() {
@@ -637,11 +641,6 @@ public class MainView {
         
         algorithm.start();
     }
-    
-    private void resized()
-    {
-        
-    }
 
     private NodeView createNodeView( LayeredGraphNode gNode, LayoutType lt )
     {