?? styleset.java
字號(hào):
package jove.color4j;
import java.io.*;
import java.text.*;
import java.util.Properties;
/**
* @author Jove
*/
public abstract class StyleSet {
static class AnsiStyle extends StyleSet {
private NumberFormat numberFormat;
Style styleComment,
styleBlock,
styleClassName,
styleMethod,
styleQuote,
styleReservedWords,
stylePackage;
AnsiStyle() {
Properties prop = new Properties();
String filename = "style.cfg";
File styleFile = new File(filename);
if (styleFile.exists()) {
try {
prop.load(new FileInputStream(styleFile));
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
} else {
try {
prop.load(getClass().getResourceAsStream(filename));
prop.store(new FileOutputStream(styleFile), "");
} catch (IOException e) {
e.printStackTrace();
}
}
char ESC = (char) 27;
String BEGIN = ESC + "[";
String END = ESC + "[m";
styleComment =
new Style(BEGIN + prop.getProperty("ansi.comment") + 'm', END);
styleBlock =
new Style(
BEGIN + prop.getProperty("ansi.block", "") + 'm',
END);
styleClassName =
new Style(
BEGIN + prop.getProperty("ansi.classname") + 'm',
END);
styleMethod =
new Style(BEGIN + prop.getProperty("ansi.method") + 'm', END);
styleQuote =
new Style(BEGIN + prop.getProperty("ansi.quote") + 'm', END);
styleReservedWords =
new Style(BEGIN + prop.getProperty("ansi.reserved") + 'm', END);
stylePackage =
new Style(BEGIN + prop.getProperty("ansi.package") + 'm', END);
String line = prop.getProperty("ansi.line.num.format");
if (line != null) {
numberFormat = new DecimalFormat(line);
}
}
NumberFormat getLineNumberFormat() {
return numberFormat;
}
Style getStyleOfBlock() {
return this.styleBlock;
}
Style getStyleOfClassName() {
return this.styleClassName;
}
Style getStyleOfComment() {
return this.styleComment;
}
Style getStyleOfMethod() {
return this.styleMethod;
}
Style getStyleOfPackage() {
return this.stylePackage;
}
Style getStyleOfQuote() {
return this.styleQuote;
}
Style getStyleOfReservedWord() {
return this.styleReservedWords;
}
boolean needChanageBlankToNbsp() {
return false;
}
}
protected static class Style {
private String begin, end;
Style(String begin, String end) {
this.begin = begin;
this.end = end;
}
String getBegin() {
return begin;
}
String getEnd() {
return end;
}
}
static class UbbStyle extends StyleSet {
private NumberFormat numberFormat;
Style styleComment,
styleBlock,
styleClassName,
styleMethod,
styleQuote,
styleReservedWords,
stylePackage;
UbbStyle() {
Properties prop = new Properties();
String filename = "style.cfg";
File styleFile = new File(filename);
if (styleFile.exists()) {
try {
prop.load(new FileInputStream(styleFile));
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
} else {
try {
prop.load(getClass().getResourceAsStream(filename));
prop.store(new FileOutputStream(styleFile), "");
} catch (IOException e) {
e.printStackTrace();
}
}
styleComment =
new Style(
prop.getProperty("ubb.comment.begin"),
prop.getProperty("ubb.comment.end"));
styleBlock =
new Style(
prop.getProperty("ubb.block.begin"),
prop.getProperty("ubb.block.end"));
styleClassName =
new Style(
prop.getProperty("ubb.classname.begin"),
prop.getProperty("ubb.classname.end"));
styleMethod =
new Style(
prop.getProperty("ubb.method.begin"),
prop.getProperty("ubb.method.end"));
styleQuote =
new Style(
prop.getProperty("ubb.quote.begin"),
prop.getProperty("ubb.quote.end"));
styleReservedWords =
new Style(
prop.getProperty("ubb.reserved.begin"),
prop.getProperty("ubb.reserved.end"));
stylePackage =
new Style(
prop.getProperty("ubb.package.begin"),
prop.getProperty("ubb.package.end"));
String line = prop.getProperty("ubb.line.num.format");
if (line != null) {
numberFormat = new DecimalFormat(line);
}
}
NumberFormat getLineNumberFormat() {
return numberFormat;
}
Style getStyleOfBlock() {
return this.styleBlock;
}
Style getStyleOfClassName() {
return this.styleClassName;
}
Style getStyleOfComment() {
return this.styleComment;
}
Style getStyleOfMethod() {
return this.styleMethod;
}
Style getStyleOfPackage() {
return this.stylePackage;
}
Style getStyleOfQuote() {
return this.styleQuote;
}
Style getStyleOfReservedWord() {
return this.styleReservedWords;
}
boolean needChanageBlankToNbsp() {
return true;
}
}
public static final StyleSet ANSI = new AnsiStyle();
public static final StyleSet UBB = new UbbStyle();
abstract NumberFormat getLineNumberFormat();
abstract Style getStyleOfBlock();
abstract Style getStyleOfClassName();
abstract Style getStyleOfComment();
abstract Style getStyleOfMethod();
abstract Style getStyleOfPackage();
abstract Style getStyleOfQuote();
abstract Style getStyleOfReservedWord();
abstract boolean needChanageBlankToNbsp();
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -