/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package simplesheet.model.cell;
import simplesheet.style.Style;
import simplesheet.style.CellStyleEvent;
import simplesheet.style.CellStyleListener;
import java.awt.Color;
import java.awt.Font;
import java.awt.Insets;
import javax.swing.event.EventListenerList;
import simplesheet.style.CellBorder;
import simplesheet.style.Margin;
import simplesheet.style.TextAlign;
import simplesheet.style.TextVAlign;
/**
*
* @author axe
*/
public class StyleDefault implements Style {
private EventListenerList listeners = new EventListenerList();
private Color background;
private Color foreground;
private Font font;
private TextAlign textAlign = TextAlign.undefined;;
private TextVAlign textVAlign = TextVAlign.undefined;
private CellBorder cellBorder;
private Margin margin;
public StyleDefault() {
}
public Style Clone() {
Style clone = new StyleDefault();
clone.setBackground(background);
clone.setForeground(foreground);
clone.setFont(font);
clone.setTextAlign(textAlign);
clone.setTextVAlign(textVAlign);
clone.setBorder(cellBorder);
clone.setMargin(margin);
return clone;
}
public Font getFont() {
return font;
}
public void setFont(Font font) {
this.font = font;
fireStyleChanged();
}
public Color getBackground() {
return background;
}
public void setBackground(Color background) {
this.background = background;
fireStyleChanged();
}
public Color getForeground() {
return foreground;
}
public void setForeground(Color foreground) {
this.foreground = foreground;
fireStyleChanged();
}
public TextAlign getTextAlign() {
return textAlign;
}
public void setTextAlign(TextAlign textAlign) {
this.textAlign = textAlign;
fireStyleChanged();
}
public TextVAlign getTextVAlign() {
return textVAlign;
}
public void setTextVAlign(TextVAlign textVAlign) {
this.textVAlign = textVAlign;
fireStyleChanged();
}
public CellBorder getBorder() {
return cellBorder;
}
public void setBorder(CellBorder cellBorder) {
this.cellBorder = cellBorder;
fireStyleChanged();
}
public Margin getMargin() {
return margin;
}
public void setMargin(Margin insets) {
this.margin = insets;
fireStyleChanged();
}
public void addCellStyleListener(CellStyleListener l) {
listeners.add(CellStyleListener.class, l);
}
public void removeCellStyleListener(CellStyleListener l) {
listeners.remove(CellStyleListener.class, l);
}
protected void fireStyleChanged() {
CellStyleEvent event = new CellStyleEvent(this);
for(CellStyleListener l : listeners.getListeners(CellStyleListener.class)) {
l.styleChanged(event);
}
}
}