package paint2D;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;

public class Paint2D {

	private static int size = 100;
	private static float location = 150;

	private int width;
	private int height;
	private String title;
	private String align; // bottom, middle, top
	private String hspace;
	private String vspace;
	private String format; // jpeg|gif|png
	private String bgcolor;
	private String border;
	private boolean rendered;
	private boolean style;

	public boolean isStyle() {
		return style;
	}

	public void setStyle(boolean style) {
		this.style = style;
	}

	public boolean isRerender() {
		return rendered;
	}

	public void setRerender(boolean rendered) {
		this.rendered = rendered;
	}

	public String getBorder() {
		return border;
	}

	public void setBorder(String border) {
		this.border = border;
	}

	public Paint2D() {

		width = 400;
		align = "left";
		height = 200;
		title = "Pain2D title";
		bgcolor = "white";
		rendered = true;
		border = "4px";
		style = false;
	}
	
	public String getStyleString() {
		if(style)
			return "style";
		else 
			return "";
	}

	public void paint(Graphics2D g2, Object obj) {
		PaintData data = (PaintData) obj;
		int testLenght = data.text.length();
		int fontSize = testLenght < 8 ? 40 : 40 - (testLenght - 8);
		if (fontSize < 12) fontSize = 12;
		Font font = new Font("Serif", Font.HANGING_BASELINE, fontSize);
		g2.setFont(font);

		int x = 10;
		int y = fontSize * 5 / 2;
		g2.translate(x, y);

		g2.setPaint(Color.BLUE);
		g2.drawString(data.text, 0, 0);
	}

	public int getHeight() {
		return height;
	}

	public void setHeight(int height) {
		this.height = height;
	}

	public int getWidth() {
		return width;
	}

	public void setWidth(int width) {
		this.width = width;
	}

	public String getAlign() {
		return align;
	}

	public void setAlign(String align) {
		this.align = align;
	}

	public String getHspace() {
		return hspace;
	}

	public void setHspace(String hspace) {
		this.hspace = hspace;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getVspace() {
		return vspace;
	}

	public void setVspace(String vspace) {
		this.vspace = vspace;
	}

	public String getFormat() {
		return format;
	}

	public void setFormat(String format) {
		this.format = format;
	}

	public String getBgcolor() {
		return bgcolor;
	}

	public void setBgcolor(String bgcolor) {
		this.bgcolor = bgcolor;
	}

	public float getLocation() {
		return location;
	}

	public void setLocation(float location) {
		this.location = location;
	}

	public int getSize() {
		return size;
	}

	public void setSize(int size) {
		this.size = size;
	}

	public boolean isRendered() {
		return rendered;
	}

	public void setRendered(boolean rendered) {
		this.rendered = rendered;
	}
}
