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 = 10; private int padding = 5; private Frame parent; private Dimension pref_size = new Dimension( 500, 500 ); private Dimension panel_dim; private DrawingPanel dps[]; public FlowPanel(AlgAnimFrame frame, DrawingPanel dp[]) { setBackground(Color.lightGray); parent = frame; // panel_height = parent.size().height - offset; // panel_width = parent.size().width - offset; Dimension f_size = new Dimension( panel_height, panel_width ); f_size = size(); System.out.println("FlowPanel: frame size : " + f_size ); setLayout(new FlowLayout()); int fw = pref_size.width - padding; int fh = pref_size.height - offset; int count = dp.length; for(int 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 ) { DrawingPanel dp = dps[dps.length-2]; FontMetrics fm = dp.getFontMetrics(label.getFont()); int str_width = fm.stringWidth(label.getText()); int x1 = (dp.getPanelHeight() - str_width)/2; shuffleDown(); Graphics g = dp.getGraphics(); label.draw(g); } } }