📄 basefield.java
字号:
lines.add(buf.toString()); buf.setLength(0); refk = k; lastspace = -1; state = 2; } else { if (buf.length() > 1) { --k; buf.setLength(buf.length() - 1); } lines.add(buf.toString()); buf.setLength(0); refk = k; if (c == ' ') state = 2; } } break; case 2: if (c != ' ') { w = 0; --k; state = 1; } break; } } trimRight(buf); lines.add(buf.toString()); } return lines; } private void drawTopFrame(PdfAppearance app) { app.moveTo(borderWidth, borderWidth); app.lineTo(borderWidth, box.getHeight() - borderWidth); app.lineTo(box.getWidth() - borderWidth, box.getHeight() - borderWidth); app.lineTo(box.getWidth() - 2 * borderWidth, box.getHeight() - 2 * borderWidth); app.lineTo(2 * borderWidth, box.getHeight() - 2 * borderWidth); app.lineTo(2 * borderWidth, 2 * borderWidth); app.lineTo(borderWidth, borderWidth); app.fill(); } private void drawBottomFrame(PdfAppearance app) { app.moveTo(borderWidth, borderWidth); app.lineTo(box.getWidth() - borderWidth, borderWidth); app.lineTo(box.getWidth() - borderWidth, box.getHeight() - borderWidth); app.lineTo(box.getWidth() - 2 * borderWidth, box.getHeight() - 2 * borderWidth); app.lineTo(box.getWidth() - 2 * borderWidth, 2 * borderWidth); app.lineTo(2 * borderWidth, 2 * borderWidth); app.lineTo(borderWidth, borderWidth); app.fill(); } /** Gets the border width in points. * @return the border width in points */ public float getBorderWidth() { return this.borderWidth; } /** Sets the border width in points. To eliminate the border * set the border color to <CODE>null</CODE>. * @param borderWidth the border width in points */ public void setBorderWidth(float borderWidth) { this.borderWidth = borderWidth; } /** Gets the border style. * @return the border style */ public int getBorderStyle() { return this.borderStyle; } /** Sets the border style. The styles are found in <CODE>PdfBorderDictionary</CODE> * and can be <CODE>STYLE_SOLID</CODE>, <CODE>STYLE_DASHED</CODE>, * <CODE>STYLE_BEVELED</CODE>, <CODE>STYLE_INSET</CODE> and * <CODE>STYLE_UNDERLINE</CODE>. * @param borderStyle the border style */ public void setBorderStyle(int borderStyle) { this.borderStyle = borderStyle; } /** Gets the border color. * @return the border color */ public Color getBorderColor() { return this.borderColor; } /** Sets the border color. Set to <CODE>null</CODE> to remove * the border. * @param borderColor the border color */ public void setBorderColor(Color borderColor) { this.borderColor = borderColor; } /** Gets the background color. * @return the background color */ public Color getBackgroundColor() { return this.backgroundColor; } /** Sets the background color. Set to <CODE>null</CODE> for * transparent background. * @param backgroundColor the background color */ public void setBackgroundColor(Color backgroundColor) { this.backgroundColor = backgroundColor; } /** Gets the text color. * @return the text color */ public Color getTextColor() { return this.textColor; } /** Sets the text color. If <CODE>null</CODE> the color used * will be black. * @param textColor the text color */ public void setTextColor(Color textColor) { this.textColor = textColor; } /** Gets the text font. * @return the text font */ public BaseFont getFont() { return this.font; } /** Sets the text font. If <CODE>null</CODE> then Helvetica * will be used. * @param font the text font */ public void setFont(BaseFont font) { this.font = font; } /** Gets the font size. * @return the font size */ public float getFontSize() { return this.fontSize; } /** Sets the font size. If 0 then auto-sizing will be used but * only for text fields. * @param fontSize the font size */ public void setFontSize(float fontSize) { this.fontSize = fontSize; } /** Gets the text horizontal alignment. * @return the text horizontal alignment */ public int getAlignment() { return this.alignment; } /** Sets the text horizontal alignment. It can be <CODE>Element.ALIGN_LEFT</CODE>, * <CODE>Element.ALIGN_CENTER</CODE> and <CODE>Element.ALIGN_RIGHT</CODE>. * @param alignment the text horizontal alignment */ public void setAlignment(int alignment) { this.alignment = alignment; } /** Gets the text. * @return the text */ public String getText() { return this.text; } /** Sets the text for text fields. * @param text the text */ public void setText(String text) { this.text = text; } /** Gets the field dimension and position. * @return the field dimension and position */ public Rectangle getBox() { return this.box; } /** Sets the field dimension and position. * @param box the field dimension and position */ public void setBox(Rectangle box) { if (box == null) { this.box = null; } else { this.box = new Rectangle(box); this.box.normalize(); } } /** Gets the field rotation. * @return the field rotation */ public int getRotation() { return this.rotation; } /** Sets the field rotation. This value should be the same as * the page rotation where the field will be shown. * @param rotation the field rotation */ public void setRotation(int rotation) { if (rotation % 90 != 0) throw new IllegalArgumentException("Rotation must be a multiple of 90."); rotation %= 360; if (rotation < 0) rotation += 360; this.rotation = rotation; } /** Convenience method to set the field rotation the same as the * page rotation. * @param page the page */ public void setRotationFromPage(Rectangle page) { setRotation(page.getRotation()); } /** Gets the field visibility flag. * @return the field visibility flag */ public int getVisibility() { return this.visibility; } /** Sets the field visibility flag. This flags can be one of * <CODE>VISIBLE</CODE>, <CODE>HIDDEN</CODE>, <CODE>VISIBLE_BUT_DOES_NOT_PRINT</CODE> * and <CODE>HIDDEN_BUT_PRINTABLE</CODE>. * @param visibility field visibility flag */ public void setVisibility(int visibility) { this.visibility = visibility; } /** Gets the field name. * @return the field name */ public String getFieldName() { return this.fieldName; } /** Sets the field name. * @param fieldName the field name. If <CODE>null</CODE> only the widget keys * will be included in the field allowing it to be used as a kid field. */ public void setFieldName(String fieldName) { this.fieldName = fieldName; } /** Gets the option flags. * @return the option flags */ public int getOptions() { return this.options; } /** Sets the option flags. The option flags can be a combination by oring of * <CODE>READ_ONLY</CODE>, <CODE>REQUIRED</CODE>, * <CODE>MULTILINE</CODE>, <CODE>DO_NOT_SCROLL</CODE>, * <CODE>PASSWORD</CODE>, <CODE>FILE_SELECTION</CODE>, * <CODE>DO_NOT_SPELL_CHECK</CODE> and <CODE>EDIT</CODE>. * @param options the option flags */ public void setOptions(int options) { this.options = options; } /** Gets the maximum length of the field's text, in characters. * @return the maximum length of the field's text, in characters. */ public int getMaxCharacterLength() { return this.maxCharacterLength; } /** Sets the maximum length of the field's text, in characters. * It is only meaningful for text fields. * @param maxCharacterLength the maximum length of the field's text, in characters */ public void setMaxCharacterLength(int maxCharacterLength) { this.maxCharacterLength = maxCharacterLength; } /** * Getter for property writer. * @return Value of property writer. */ public PdfWriter getWriter() { return writer; } /** * Setter for property writer. * @param writer New value of property writer. */ public void setWriter(PdfWriter writer) { this.writer = writer; } /** * Moves the field keys from <CODE>from</CODE> to <CODE>to</CODE>. The moved keys * are removed from <CODE>from</CODE>. * @param from the source * @param to the destination. It may be <CODE>null</CODE> */ public static void moveFields(PdfDictionary from, PdfDictionary to) { for (Iterator i = from.getKeys().iterator(); i.hasNext();) { PdfName key = (PdfName)i.next(); if (fieldKeys.containsKey(key)) { if (to != null) to.put(key, from.get(key)); i.remove(); } } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -