package com.gx.obe.server.im; import java.awt.Color; import javax.swing.text.SimpleAttributeSet; import javax.swing.text.StyleConstants; /** * @Description: * @Description: * @author guoyr */ /** * @preserve private */ public class UserConfig { private static UserConfig userConfig = new UserConfig(); private String showNew; private int contentSize = 16; private int hideSize = 14; private Color headColor = Color.blue; private Color color = Color.black; private String headFontName ="宋体"; private String fontName ="宋体"; private int bold = 0; private int italic = 0; private SimpleAttributeSet headAttributeSet = new SimpleAttributeSet(); // 属性集 private SimpleAttributeSet attributeSet = new SimpleAttributeSet(); // 属性集 public static UserConfig getInstance(){ if(null == userConfig){ userConfig = new UserConfig(); } return userConfig; } public String getShowNew() { return showNew; } public void setShowNew(String showNew) { this.showNew = showNew; } public Color getHeadColor() { return headColor; } public void setHeadColor(Color headColor) { this.headColor = headColor; } public String getFontName() { return fontName; } public void setFontName(String fontName) { this.fontName = fontName; } public SimpleAttributeSet getHeadAttributeSet() { if (fontName != null) { StyleConstants.setFontFamily(headAttributeSet, fontName); } StyleConstants.setBold(headAttributeSet, false); StyleConstants.setItalic(headAttributeSet, false); StyleConstants.setFontSize(headAttributeSet, hideSize); if (headColor != null) { StyleConstants.setForeground(headAttributeSet, headColor); }else { StyleConstants.setForeground(headAttributeSet, Color.blue); } StyleConstants.setBackground(headAttributeSet, Color.WHITE); StyleConstants.setLeftIndent(headAttributeSet, 0); return headAttributeSet; } public void setAttributeSet(SimpleAttributeSet attributeSet) { this.headAttributeSet = attributeSet; } public int getContentSize() { return contentSize; } public void setContentSize(int contentSize) { this.contentSize = contentSize; } public int getHideSize() { return hideSize; } public void setHideSize(int hideSize) { this.hideSize = hideSize; } public int getBold() { return bold; } public void setBold(int bold) { this.bold = bold; } public int getItalic() { return italic; } public void setItalic(int italic) { this.italic = italic; } public SimpleAttributeSet getAttributeSet() { if (fontName != null) { StyleConstants.setFontFamily(attributeSet, fontName); } if(bold == 1){ StyleConstants.setBold(attributeSet, true); }else { StyleConstants.setBold(attributeSet, false); } if(italic == 1){ StyleConstants.setItalic(attributeSet, true); }else { StyleConstants.setItalic(attributeSet, false); } StyleConstants.setFontSize(attributeSet, contentSize); // if (color != null) { // StyleConstants.setForeground(attributeSet, color); // }else { // StyleConstants.setForeground(attributeSet, Color.darkGray); // } // StyleConstants.setLeftIndent(attributeSet, 10); // StyleConstants.setFirstLineIndent(attributeSet, 10); // doc.setLogicalStyle(0, mainStyle); StyleConstants.setBackground(attributeSet, Color.WHITE); return attributeSet; } public String getHeadFontName() { return headFontName; } public void setHeadFontName(String headFontName) { this.headFontName = headFontName; } public Color getColor() { return color; } public void setColor(Color color) { this.color = color; } }