package ciips.animation; import java.awt.*; import java.applet.*; import java.io.*; import java.util.*; /** FlowPanel encapsulates the before and after panels into a single panel */ public class FlowPanel extends Panel { private int panel_height = 400; private int panel_width = 400; private int offset = 40; private int padding = 10; private int top_bottom_margin = 200; private int side_margin = 50; private Frame parent; private Dimension pref_size = new Dimension( 800, 500 ); private Dimension panel_dim; private BasicDrawingPanel dps[]; private static final boolean DEBUG = true; private void setToMaxAvailable() { Dimension f_size = size(), p_size = parent.size(); if( DEBUG ) System.out.println("FlowPanel: actual frame size : " + f_size ); if( DEBUG ) System.out.println("FlowPanel: parent size : " + p_size ); // if ( f_size.width > pref_size.width ) pref_size.width = f_size.width; // if ( f_size.height > pref_size.height ) pref_size.height = f_size.height; pref_size.width = p_size.width - side_margin; pref_size.height = p_size.height - top_bottom_margin; if( DEBUG ) System.out.println("FlowPanel: pref_size " + pref_size ); } public FlowPanel( AlgAnimFrame frame) { if( DEBUG ) System.out.println("FlowPanel cons" ); setBackground( Color.yellow) ; parent = frame; validate(); show(); } public void addDrawingPanels( BasicDrawingPanel dp[] ) { int k; BasicDrawingPanel pre; int count = dp.length; if( DEBUG ) System.out.println("FlowPanel:addDrawingPanels - " + count + " panels" ); setLayout(new FlowLayout()); // Set maximum available size setToMaxAvailable(); int fw = pref_size.width - padding; int fh = pref_size.height - offset; int dp_width = fw/count; System.out.println("FlowPanel: ind panel width " + dp_width ); pre = null; for(k=0;k 1 ) { int k = 1; while( k < dps.length ) { Image prev_img = dps[k-1].getImage(); if ( prev_img == null ) { System.out.println("*** FlowPanel:shuffleDown - prev_img null"); return; } Graphics g = dps[k].getGraphics(); if ( g == null ) { System.out.println("*** FlowPanel:shuffleDown - g null"); return; } g.drawImage( prev_img, 0, 0, null ); dps[k].setImage( prev_img ); k++; } } **/ } /** Draw a label in the panel immediately preceding the current one */ public void drawBeforeLabel( ShadowLabel label ) { if ( dps.length > 1 ) { BasicDrawingPanel dp = dps[dps.length-2]; FontMetrics fm = dp.getFontMetrics(label.getFont()); int str_width = fm.stringWidth(label.getText()); int x1 = (dp.size().height - str_width)/2; // shuffleDown(); Graphics g = dp.getGraphics(); label.draw(g); } } }