// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3) fieldsfirst 
// Source File Name:   TvarkaPanel.java

import java.awt.*;
import javax.swing.*;
import javax.swing.text.JTextComponent;

class TvarkaPanel extends JPanel
{

	JTextArea txtArea;
	int H;
	int W;
	Field f[][];

	TvarkaPanel()
	{
		txtArea = new JTextArea();
		JScrollPane jscrollpane = new JScrollPane(txtArea);
		H = -1;
		W = -1;
		setLayout(new BorderLayout());
		txtArea.setFont(new Font("Courier", 0, 12));
		txtArea.setText("You must select and start Tvarka task first.");
		add(jscrollpane, "Center");
	}

	void FieldsAlign(Field afield[][], int i, int j)
	{
		int ai[] = new int[4];
		ai[0] = 3;
		ai[1] = 20;
		ai[2] = 15;
		ai[3] = 5;
		for(int k = 0; k < 4; k++)
		{
			for(int l = 0; l < i; l++)
				afield[l][k].setText(StrLenN(afield[l][k].getText(), ai[k], 0));

		}

		byte byte0 = 6;
		for(int i1 = 4; i1 < j; i1++)
		{
			for(int j1 = 0; j1 < i; j1++)
				afield[j1][i1].setText(StrLenN(afield[j1][i1].getText(), byte0, 1));

		}

	}

	void FieldsFill(Field afield[][], int i, int j, Tvarka tvarka)
	{
		synchronized(tvarka.Mokytojai0)
		{
			String as1[][] = tvarka.Mokytojai0;
			afield[0][0] = new Field("Nr.");
			afield[0][1] = new Field("Mokytojas");
			afield[0][2] = new Field("Dalykas");
			afield[0][3] = new Field("Klase");
			for(int k = 1; k <= 5; k++)
			{
				for(int l = 1; l <= 7; l++)
					afield[0][(4 + ((k - 1) * 7 + l)) - 1] = new Field(Integer.toString(k) + "P" + Integer.toString(l));

			}

			for(int i1 = 1; i1 < i; i1++)
			{
				afield[i1][0] = new Field(Integer.toString(i1));
				afield[i1][1] = new Field(as1[i1 - 1][0]);
				afield[i1][2] = new Field(as1[i1 - 1][1]);
				afield[i1][3] = new Field(as1[i1 - 1][2]);
				for(int j1 = 4; j1 < j; j1++)
					afield[i1][j1] = new Field(as1[i1 - 1][j1 - 1]);

			}

		}
	}

	String FieldsToString(Field afield[][], int i, int j, boolean flag, boolean flag1)
	{
		String s = new String();
		for(int k = 0; k < i; k++)
			if(!((k == 0) & (flag ^ true)))
			{
				for(int l = 0; l < j; l++)
					if(!((l == 0) & (flag1 ^ true)))
						s = s + afield[k][l].getText() + " ";

				s = s + "\r\n";
			}

		return s;
	}

	public static String StrLenN(String s, int i, int j)
	{
		String s1 = new String();
		for(int k = 1; k <= i - s.length(); k++)
			s1 = s1 + " ";

		if(j == 0)
			return s + s1;
		else
			return s1 + s;
	}

	void TvarkaChanged(Tvarka tvarka)
	{
		TvarkaModified(tvarka);
	}

	void TvarkaModified(Tvarka tvarka)
	{
		Tvarka tvarka1 = tvarka;
		if(tvarka1 == null)
			return;
		H = 65;
		W = 39;
		f = new Field[H][W];
		if(f == null)
		{
			return;
		} else
		{
			FieldsFill(f, H, W, tvarka1);
			FieldsAlign(f, H, W);
			String s = FieldsToString(f, H, W, true, true);
			txtArea.setText(s);
			return;
		}
	}

	String getText()
	{
		return txtArea.getText();
	}
}
