package de.achim.turnier.tabellen;
import info.clearthought.layout.TableLayout;
import java.awt.Font;
import java.util.Vector;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import de.achim.turnier.Turniervewaltung2;
import de.achim.turnier.endrunde.EndrundenTabelle;
public class TabellenContainer extends JPanel {
private JLabel title;
private Vector<TabellenPanel> vTP = new Vector<TabellenPanel>();
private Turniervewaltung2 motherFrame;
private TableLayout tabLayout;
int rows;
int columns;
public TabellenContainer(){
title = new JLabel();
Font font = new Font( Font.SANS_SERIF, Font.PLAIN, 20 );
title.setFont(font);
title.setHorizontalAlignment(title.CENTER);
}
public void setGridDimensions(int r, int c){
this.rows = r;
this.columns = c;
tabLayout = new TableLayout();
double[] row = makeSize(r);
double[] col = makeSize(c);
tabLayout.setRow(row);
tabLayout.setColumn(row);
setLayout(tabLayout);
}
public void addTabellenPanel(TabellenPanel tp, String constraint) {
vTP.add(tp);
add(tp, constraint);
revalidate();
}
public void addEndrundenTabelle(EndrundenTabelle tp, String constraint) {
//vTP.add(tp);
add(tp, constraint);
revalidate();
}
public Vector<TabellenPanel> getTabellenPanels(){
return vTP;
}
public void setTitle(String s){
this.title.setText(s);
revalidate();
}
public void setMotherFrame(JFrame mother){
this.motherFrame = (Turniervewaltung2)mother;
motherFrame.registerComponent(this);
}
public JFrame getMotherFrame(){
return this.motherFrame;
}
public void updateData(JComponent comp){
if(comp.getName().equals("tabellenpanel")){
Turniervewaltung2 tv2 = ((Turniervewaltung2)getMotherFrame());
tv2.updateData(comp);
}
}
private double[] makeSize(int count){
double [] arr = new double[count];
for(int i = 0;i < count; i++){
arr[i] = TableLayout.FILL;
}
return arr;
}
}