📄 rtfborder.java
字号:
*/ public static final int BORDER_HAIRLINE = 6; /** * Constant for a double border */ public static final int BORDER_DOUBLE = 7; /** * Constant for a dot dash border */ public static final int BORDER_DOT_DASH = 8; /** * Constant for a dot dot dash border */ public static final int BORDER_DOT_DOT_DASH = 9; /** * Constant for a triple border */ public static final int BORDER_TRIPLE = 10; /** * Constant for a thick thin border */ public static final int BORDER_THICK_THIN = 11; /** * Constant for a thin thick border */ public static final int BORDER_THIN_THICK = 12; /** * Constant for a thin thick thin border */ public static final int BORDER_THIN_THICK_THIN = 13; /** * Constant for a thick thin medium border */ public static final int BORDER_THICK_THIN_MED = 14; /** * Constant for a thin thick medium border */ public static final int BORDER_THIN_THICK_MED = 15; /** * Constant for a thin thick thin medium border */ public static final int BORDER_THIN_THICK_THIN_MED = 16; /** * Constant for a thick thin large border */ public static final int BORDER_THICK_THIN_LARGE = 17; /** * Constant for a thin thick large border */ public static final int BORDER_THIN_THICK_LARGE = 18; /** * Constant for a thin thick thin large border */ public static final int BORDER_THIN_THICK_THIN_LARGE = 19; /** * Constant for a wavy border */ public static final int BORDER_WAVY = 20; /** * Constant for a double wavy border */ public static final int BORDER_DOUBLE_WAVY = 21; /** * Constant for a striped border */ public static final int BORDER_STRIPED = 22; /** * Constant for an embossed border */ public static final int BORDER_EMBOSS = 23; /** * Constant for an engraved border */ public static final int BORDER_ENGRAVE = 24; /** * The type of this RtfBorder */ private int borderType = ROW_BORDER; /** * The position of this RtfBorder */ private int borderPosition = NO_BORDER; /** * The style of this RtfBorder */ private int borderStyle = BORDER_NONE; /** * The width of this RtfBorder */ private int borderWidth = 20; /** * The color of this RtfBorder */ private RtfColor borderColor = null; /** * Makes a copy of the given RtfBorder * * @param doc The RtfDocument this RtfBorder belongs to * @param borderType The border type of this RtfBorder * @param border The RtfBorder to copy */ protected RtfBorder(RtfDocument doc, int borderType, RtfBorder border) { super(doc); this.borderType = borderType; this.borderPosition = border.getBorderPosition(); this.borderStyle = border.getBorderStyle(); this.borderWidth = border.getBorderWidth(); this.borderColor = new RtfColor(this.document, border.getBorderColor()); } /** * Constructs a RtfBorder * * @param doc The RtfDocument this RtfBorder belongs to * @param borderType The type of border this RtfBorder is * @param borderPosition The position of this RtfBorder * @param borderStyle The style of this RtfBorder * @param borderWidth The width of this RtfBorder * @param borderColor The color of this RtfBorder */ protected RtfBorder(RtfDocument doc, int borderType, int borderPosition, int borderStyle, float borderWidth, Color borderColor) { super(doc); this.borderType = borderType; this.borderPosition = borderPosition; this.borderStyle = borderStyle; this.borderWidth = (int) Math.min((borderWidth * TWIPS_FACTOR), 75); if(this.borderWidth == 0) { this.borderStyle = BORDER_NONE; } if(borderColor == null) { this.borderColor = new RtfColor(this.document, new Color(0, 0, 0)); } else { this.borderColor = new RtfColor(this.document, borderColor); } } /** * Writes the RtfBorder settings */ public void writeContent(final OutputStream result) throws IOException { if(this.borderStyle == BORDER_NONE || this.borderPosition == NO_BORDER || this.borderWidth == 0) { return; } if(this.borderType == ROW_BORDER) { switch(this.borderPosition) { case LEFT_BORDER: result.write(ROW_BORDER_LEFT); break; case TOP_BORDER: result.write(ROW_BORDER_TOP); break; case RIGHT_BORDER: result.write(ROW_BORDER_RIGHT); break; case BOTTOM_BORDER: result.write(ROW_BORDER_BOTTOM); break; case HORIZONTAL_BORDER: result.write(ROW_BORDER_HORIZONTAL); break; case VERTICAL_BORDER: result.write(ROW_BORDER_VERTICAL); break; default: return; } result.write(writeBorderStyle()); result.write(BORDER_WIDTH); result.write(intToByteArray(this.borderWidth)); result.write(BORDER_COLOR_NUMBER); result.write(intToByteArray(this.borderColor.getColorNumber())); this.document.outputDebugLinebreak(result); } else if(this.borderType == CELL_BORDER) { switch(this.borderPosition) { case LEFT_BORDER: result.write(CELL_BORDER_LEFT); break; case TOP_BORDER: result.write(CELL_BORDER_TOP); break; case RIGHT_BORDER: result.write(CELL_BORDER_RIGHT); break; case BOTTOM_BORDER: result.write(CELL_BORDER_BOTTOM); break; default: return; } result.write(writeBorderStyle()); result.write(BORDER_WIDTH); result.write(intToByteArray(this.borderWidth)); result.write(BORDER_COLOR_NUMBER); result.write(intToByteArray(this.borderColor.getColorNumber())); this.document.outputDebugLinebreak(result); } } /** * Writes the style of this RtfBorder * * @return A byte array containing the style of this RtfBorder */ private byte[] writeBorderStyle() { switch(this.borderStyle) { case BORDER_NONE : return new byte[0]; case BORDER_SINGLE : return BORDER_STYLE_SINGLE; case BORDER_DOUBLE_THICK : return BORDER_STYLE_DOUBLE_THICK; case BORDER_SHADOWED : return BORDER_STYLE_SHADOWED; case BORDER_DOTTED : return BORDER_STYLE_DOTTED; case BORDER_DASHED : return BORDER_STYLE_DASHED; case BORDER_HAIRLINE : return BORDER_STYLE_HAIRLINE; case BORDER_DOUBLE : return BORDER_STYLE_DOUBLE; case BORDER_DOT_DASH : return BORDER_STYLE_DOT_DASH; case BORDER_DOT_DOT_DASH : return BORDER_STYLE_DOT_DOT_DASH; case BORDER_TRIPLE : return BORDER_STYLE_TRIPLE; case BORDER_THICK_THIN : return BORDER_STYLE_THICK_THIN; case BORDER_THIN_THICK : return BORDER_STYLE_THIN_THICK; case BORDER_THIN_THICK_THIN : return BORDER_STYLE_THIN_THICK_THIN; case BORDER_THICK_THIN_MED : return BORDER_STYLE_THICK_THIN_MED; case BORDER_THIN_THICK_MED : return BORDER_STYLE_THIN_THICK_MED; case BORDER_THIN_THICK_THIN_MED : return BORDER_STYLE_THIN_THICK_THIN_MED; case BORDER_THICK_THIN_LARGE : return BORDER_STYLE_THICK_THIN_LARGE; case BORDER_THIN_THICK_LARGE : return BORDER_STYLE_THIN_THICK_LARGE; case BORDER_THIN_THICK_THIN_LARGE : return BORDER_STYLE_THIN_THICK_THIN_LARGE; case BORDER_WAVY : return BORDER_STYLE_WAVY; case BORDER_DOUBLE_WAVY : return BORDER_STYLE_DOUBLE_WAVY; case BORDER_STRIPED : return BORDER_STYLE_STRIPED; case BORDER_EMBOSS : return BORDER_STYLE_EMBOSS; case BORDER_ENGRAVE : return BORDER_STYLE_ENGRAVE; default : return BORDER_STYLE_SINGLE; } } /** * Gets the color of this RtfBorder * * @return Returns RtfColor of this RtfBorder */ protected RtfColor getBorderColor() { return borderColor; } /** * Gets the position of this RtfBorder * @return Returns the position of this RtfBorder */ protected int getBorderPosition() { return borderPosition; } /** * Gets the style of this RtfBorder * * @return Returns the style of this RtfBorder */ protected int getBorderStyle() { return borderStyle; } /** * Gets the type of this RtfBorder * * @return Returns the type of this RtfBorder */ protected int getBorderType() { return borderType; } /** * Gets the width of this RtfBorder * * @return Returns the width of this RtfBorder */ protected int getBorderWidth() { return borderWidth; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -