Преглед изворни кода

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/bk/ConflictDetection.java
Eren Yilmaz пре 7 година
родитељ
комит
9d2bfcb197
4 измењених фајлова са 39 додато и 9 уклоњено
  1. 10 2
      src/bk/Combine.java
  2. 3 1
      src/bk/ConflictDetection.java
  3. 24 6
      src/view/MainView.java
  4. 2 0
      src/view/NodeView.java

+ 10 - 2
src/bk/Combine.java

@@ -1,7 +1,10 @@
 package bk;
 
+import java.awt.Color;
+
 import animation.AlgorithmStage;
 import graph.LayeredGraphNode;
+import view.MainView;
 
 /**
  * The stage of the combination of the four extremal layouts.
@@ -10,14 +13,19 @@ import graph.LayeredGraphNode;
  */
 public class Combine implements AlgorithmStage {
 
+	LayeredGraphNode graph;
+	
 	public Combine( LayeredGraphNode graph )
 	{
-		
+		this.graph = graph;
 	}
 	
 	@Override
 	public StageStatus forwardStep() {
-		// TODO Auto-generated method stub
+		MainView.frame.setSize( MainView.frame.getWidth() + 1, MainView.frame.getHeight() );
+		MainView.frame.setSize( MainView.frame.getWidth() - 1, MainView.frame.getHeight() );
+		
+		graph.setColor( Color.BLACK, null );
 		return null;
 	}
 

+ 3 - 1
src/bk/ConflictDetection.java

@@ -27,7 +27,9 @@ public class ConflictDetection implements AlgorithmStage {
     public StageStatus forwardStep() {
     	int oldI = i;
     	int oldL1 = l1;
-    	LayeredGraphNode curr = graph.getContainedLayers().get( i + 1 ).get( l1 ); // TODO: fix IndexOutOfBoundsException
+    	if( i + 1 >= graph.getContainedLayers().size() - 1 )
+    		return StageStatus.FINISHED;
+    	LayeredGraphNode curr = graph.getContainedLayers().get( i + 1 ).get( l1 );
     	curr.setSelected( null );
     	ArrayList< LayeredGraphEdge > edges = curr.getIncomingEdges();
     	LayeredGraphEdge dummyEdge = null;

+ 24 - 6
src/view/MainView.java

@@ -134,13 +134,18 @@ public class MainView {
 		
 		JLayeredPane layne = new JLayeredPane();
 		JPanel pl = new JPanel();
-		pl.setLayout(new GridLayout( 2, 2, 500, 500 ) );
+		GridLayout grout = new GridLayout( 2, 2, 10, 10 );
+		pl.setLayout( grout );
 		pl.setLocation( 0, 0 );
 		pl.setSize( frame.getSize() );
-		pl.add(createNodeView( graph, LayoutType.TOP_BOTTOM_LEFT ));
-		pl.add(createNodeView( graph, LayoutType.TOP_BOTTOM_RIGHT ));
-		pl.add(createNodeView( graph, LayoutType.BOTTOM_TOP_LEFT ));
-		pl.add(createNodeView( graph, LayoutType.BOTTOM_TOP_RIGHT ));
+		NodeView topLeft = createNodeView( graph, LayoutType.TOP_BOTTOM_LEFT );
+		NodeView topRight = createNodeView( graph, LayoutType.TOP_BOTTOM_RIGHT );
+		NodeView bottomLeft = createNodeView( graph, LayoutType.BOTTOM_TOP_LEFT );
+		NodeView bottomRight = createNodeView( graph, LayoutType.BOTTOM_TOP_RIGHT );
+		pl.add( topLeft );
+		pl.add( topRight );
+		pl.add( bottomLeft );
+		pl.add( bottomRight );
 		layne.add( pl, 1 );
 		NodeView combined = createNodeView( graph, LayoutType.COMBINED );
 		combined.setSize( 500, 500 );
@@ -153,7 +158,20 @@ public class MainView {
 		{  
 	        public void componentResized(ComponentEvent evt) {
 	    		pl.setSize( layne.getSize() );
-	    		combined.setLocation( layne.getWidth() / 2 - combined.getWidth() / 2, layne.getHeight() / 2 - combined.getHeight() / 2 );
+	    		if( graph.getColor( LayoutType.COMBINED ) == null )
+	    		{
+		    		grout.setHgap( 10 );
+		    		grout.setVgap( 10 );
+	    		}
+	    		else
+	    		{
+	    			grout.setHgap( layne.getWidth() / 3 );
+	    			grout.setVgap( layne.getHeight() / 3 );
+	    		}
+	    		combined.setSize( layne.getWidth() / 3, layne.getHeight() / 3 );
+	    		combined.setLocation( layne.getWidth() / 3, layne.getHeight() / 3 );
+	    		frame.validate();
+	    		frame.repaint();
 	        }
 		});
 		new BKNodePlacement( controller, graph ).start();

+ 2 - 0
src/view/NodeView.java

@@ -45,6 +45,8 @@ public class NodeView extends JPanel {
     @Override
     public void paint( Graphics g )
     {
+    	if( layout == LayoutType.COMBINED && model.getColor( layout ) == null )
+    		return;
         double scale = Math.min( (double)super.getWidth() / (int)model.getWidth( layout ), (double)super.getHeight() / (int)model.getHeight( layout ));
         ((Graphics2D)g).scale( scale, scale );
         paintComponent( g );