001 package edu.harvard.deas.hyperenc.gui; 002 003 import java.awt.GridLayout; 004 005 import javax.swing.JLabel; 006 import javax.swing.JPanel; 007 008 public class StatusPanel extends JPanel 009 { 010 private static final long serialVersionUID = 1L; 011 012 /** 013 * Number of system blocks 014 */ 015 private NumberLabel sysBlocksLabel; 016 017 /** 018 * Number of unreconciled pages 019 */ 020 private NumberLabel unrecPagesLabel; 021 022 /** 023 * Number of reconciled pages 024 */ 025 private NumberLabel recPagesLabel; 026 027 /** 028 * Number of encryption blocks 029 */ 030 private NumberLabel encryptBlocksLabel; 031 032 /** 033 * Creates a new status panel with all values set at 0. 034 */ 035 public StatusPanel() { 036 super(new GridLayout(1, 4)); 037 setSize(850, 20); 038 039 sysBlocksLabel = new NumberLabel("System Blocks", 0); 040 sysBlocksLabel.setVerticalAlignment(JLabel.CENTER); 041 sysBlocksLabel.setHorizontalAlignment(JLabel.LEFT); 042 add(sysBlocksLabel); 043 044 unrecPagesLabel = new NumberLabel("Unreconciled Pages", 0); 045 unrecPagesLabel.setVerticalAlignment(JLabel.CENTER); 046 unrecPagesLabel.setHorizontalAlignment(JLabel.LEFT); 047 add(unrecPagesLabel); 048 049 recPagesLabel = new NumberLabel("Reconciled Pages", 0); 050 recPagesLabel.setVerticalAlignment(JLabel.CENTER); 051 recPagesLabel.setHorizontalAlignment(JLabel.LEFT); 052 add(recPagesLabel); 053 054 encryptBlocksLabel = new NumberLabel("Encryption Blocks", 0); 055 encryptBlocksLabel.setVerticalAlignment(JLabel.CENTER); 056 encryptBlocksLabel.setHorizontalAlignment(JLabel.LEFT); 057 add(encryptBlocksLabel); 058 } 059 060 /** 061 * Sets the panel to show that there are <code>n</code> system blocks available. 062 * @param n the number of system blocks 063 */ 064 public void setNumSysBlocks(int n) { 065 sysBlocksLabel.updateNum(n); 066 } 067 068 /** 069 * Sets the panel to show that there are <code>n</code> unreconciled pages available. 070 * @param n the number of unreconciled pages 071 */ 072 public void setNumUnrecPages(int n) { 073 unrecPagesLabel.updateNum(n); 074 } 075 076 /** 077 * Sets the panel to show that there are <code>n</code> reconciled pages available. 078 * @param n the number of reconciled pages 079 */ 080 public void setNumRecPages(int n) { 081 recPagesLabel.updateNum(n); 082 } 083 084 /** 085 * Sets the panel to show that there are <code>n</code> encryptiong blocks available. 086 * @param n the number of encryption blocks 087 */ 088 public void setNumEncBlocks(int n) { 089 encryptBlocksLabel.updateNum(n); 090 } 091 092 private static class NumberLabel extends JLabel { 093 private static final long serialVersionUID = 1L; 094 private String text; 095 096 public NumberLabel(String text, int num) { 097 super(); 098 this.text = text; 099 updateNum(num); 100 } 101 102 public void updateNum(int n) { 103 this.setText(text + ": " + n); 104 } 105 } 106 107 }