package gve.calc.formula;

import java.awt.*;

public class MatrixView extends TabularView {
	public MatrixView(Matrix model,FormulaView view) {
		super(model,view);
		TabularLayout layout = (TabularLayout)getLayout();
		layout.setHgap(5);
		layout.setVgap(2);
	}

	public void paint(Graphics g) {
		super.paint(g);
		Dimension siz = getSize();
		TabularLayout layout = (TabularLayout)getLayout();
		int hgap = layout.getHgap();
		// Left bracket
		int xpos = 0;
		if (getCursorPos() == Somewhere_LEFT)
			xpos = getFontMetrics(getFont()).charWidth(' ');
		g.drawLine(xpos+hgap,0,xpos,0);
		g.drawLine(xpos,0,xpos,siz.height-1);
		g.drawLine(xpos,0+siz.height-1,xpos+hgap,siz.height-1);
		// Right bracket
		xpos = siz.width - 1;
		if (getCursorPos() == Somewhere_RIGHT)
			xpos -= getFontMetrics(getFont()).charWidth(' ');
		g.drawLine(xpos-hgap,0,xpos,0);
		g.drawLine(xpos,0,xpos,siz.height-1);
		g.drawLine(xpos,siz.height-1,xpos-hgap,siz.height-1);
	}
}