Parcourir la source

fixed dummy node bug

Kolja Strohm il y a 6 ans
Parent
commit
01a32f2ab6
3 fichiers modifiés avec 31 ajouts et 2 suppressions
  1. 1 1
      src/main/Main.java
  2. 27 0
      src/view/MainView.java
  3. 3 1
      src/view/NodeView.java

+ 1 - 1
src/main/Main.java

@@ -17,7 +17,7 @@ public class Main {
      * @param args the command line arguments, currently not in use
      */
     public static void main(String[] args) {
-        Reader r = new Reader( "papergraph_in_two_nodes.json" );
+        Reader r = new Reader( "papergraph.json" );
         LayeredGraphNode graph = r.readInputGraph();
         SimpleNodePlacement.placeNodes( graph );
         new MainView( graph );

+ 27 - 0
src/view/MainView.java

@@ -681,6 +681,33 @@ public class MainView {
                 debugText.setFont( RenderHelper.font );
                 pseudoTree.setFont( RenderHelper.font );
                 pseudoTree.setRowHeight( (int)(15.0/12 * optionsDialog.getFontSize() ) );
+                pl.remove( topLeft );
+                pl.remove( topRight );
+                pl.remove( bottomLeft );
+                pl.remove( bottomRight );
+                pl.remove( combined );
+                switch( algorithm.getAlgorithmState() )
+                {
+                case CONFLICT_DETECTION:
+                    pl.add( topLeft );
+                    break;
+                case LEFTMOST_UPPER:
+                    pl.add( topLeft );
+                    break;
+                case RIGHTMOST_UPPER:
+                    pl.add( topRight );
+                    break;
+                case LEFTMOST_LOWER:
+                    pl.add( bottomLeft );
+                    break;
+                case RIGHTMOST_LOWER:
+                    pl.add( bottomRight );
+                    break;
+                case COMBINE:
+                    pl.add( combined );
+                    break;
+                }
+                pl.revalidate();
                 for( ComponentListener l : frame.getComponentListeners() )
                     l.componentResized( new ComponentEvent( frame, 0 ) );
             }

+ 3 - 1
src/view/NodeView.java

@@ -123,6 +123,8 @@ public class NodeView extends JPanel implements AnnimatedView, MouseListener {
     }
 
     public int getOriginalWidth() {
+    	if( model.isDummyNode() )
+            return (int)(originalWidth / 3);
         return originalWidth;
     }
 
@@ -180,7 +182,7 @@ public class NodeView extends JPanel implements AnnimatedView, MouseListener {
             AnnimatedView view = (AnnimatedView)c;
             if( c instanceof NodeView )
             {
-                c.setLocation( getScaledX( ((NodeView)c).getPlainVirtualX() - (int)minX ) + x, getScaledY( view.getVirtualY() ) + y);
+                c.setLocation( getScaledX( ((NodeView)c).getVirtualX() - (int)minX ) + x, getScaledY( view.getVirtualY() ) + y);
                 c.setSize( getScaledX( ((NodeView)c).getOriginalWidth() ), getScaledY( ((NodeView)c).getOriginalHeight() ) );
             }
             else