📄 annotation.java
字号:
lly = Float.valueOf(value + "f").floatValue(); } value = (String)attributes.remove(ElementTags.URX); if (value != null) { urx = Float.valueOf(value + "f").floatValue(); } value = (String)attributes.remove(ElementTags.URY); if (value != null) { ury = Float.valueOf(value + "f").floatValue(); } String title = (String)attributes.remove(ElementTags.TITLE); String text = (String)attributes.remove(ElementTags.CONTENT); if (title != null || text != null) { annotationtype = TEXT; } else if ((value = (String)attributes.remove(ElementTags.URL)) != null) { annotationtype = URL_AS_STRING; annotationAttributes.put(FILE, value); } else if ((value = (String)attributes.remove(ElementTags.NAMED)) != null) { annotationtype = NAMED_DEST; annotationAttributes.put(NAMED, Integer.valueOf(value)); } else { String file = (String)attributes.remove(ElementTags.FILE); String destination = (String)attributes.remove(ElementTags.DESTINATION); String page = (String)attributes.remove(ElementTags.PAGE); if (file != null) { annotationAttributes.put(FILE, file); if (destination != null) { annotationtype = FILE_DEST; annotationAttributes.put(DESTINATION, destination); } else if (page != null) { annotationtype = FILE_PAGE; annotationAttributes.put(FILE, file); annotationAttributes.put(PAGE, Integer.valueOf(page)); } } else if ((value = (String)attributes.remove(ElementTags.NAMED)) != null) { annotationtype = LAUNCH; annotationAttributes.put(APPLICATION, value); annotationAttributes.put(PARAMETERS, (String)attributes.remove(ElementTags.PARAMETERS)); annotationAttributes.put(OPERATION, (String)attributes.remove(ElementTags.OPERATION)); annotationAttributes.put(DEFAULTDIR, (String)attributes.remove(ElementTags.DEFAULTDIR)); } } if (annotationtype == TEXT) { if (title == null) title = ""; if (text == null) text = ""; annotationAttributes.put(TITLE, title); annotationAttributes.put(CONTENT, text); } if (attributes.size() > 0) setMarkupAttributes(attributes); } // implementation of the Element-methods /** * Gets the type of the text element. * * @return a type */ public int type() { return Element.ANNOTATION; } // methods /** * Processes the element by adding it (or the different parts) to an * <CODE>ElementListener</CODE>. * * @param listener an <CODE>ElementListener</CODE> * @return <CODE>true</CODE> if the element was processed successfully */ public boolean process(ElementListener listener) { try { return listener.add(this); } catch(DocumentException de) { return false; } } /** * Gets all the chunks in this element. * * @return an <CODE>ArrayList</CODE> */ public ArrayList getChunks() { return new ArrayList(); } // methods /** * Sets the dimensions of this annotation. * * @param llx the lower left x-value * @param lly the lower left y-value * @param urx the upper right x-value * @param ury the upper right y-value */ public void setDimensions (float llx, float lly, float urx, float ury) { this.llx = llx; this.lly = lly; this.urx = urx; this.ury = ury; } // methods to retrieve information /** * Returns the lower left x-value. * * @return a value */ public float llx() { return llx; } /** * Returns the lower left y-value. * * @return a value */ public float lly() { return lly; } /** * Returns the uppper right x-value. * * @return a value */ public float urx() { return urx; } /** * Returns the uppper right y-value. * * @return a value */ public float ury() { return ury; } /** * Returns the lower left x-value. * * @param def the default value * @return a value */ public float llx(float def) { if (llx == Float.NaN) return def; return llx; } /** * Returns the lower left y-value. * * @param def the default value * @return a value */ public float lly(float def) { if (lly == Float.NaN) return def; return lly; } /** * Returns the upper right x-value. * * @param def the default value * @return a value */ public float urx(float def) { if (urx == Float.NaN) return def; return urx; } /** * Returns the upper right y-value. * * @param def the default value * @return a value */ public float ury(float def) { if (ury == Float.NaN) return def; return ury; } /** * Returns the type of this <CODE>Annotation</CODE>. * * @return a type */ public int annotationType() { return annotationtype; } /** * Returns the title of this <CODE>Annotation</CODE>. * * @return a name */ public String title() { String s = (String)annotationAttributes.get(TITLE); if (s == null) s = ""; return s; } /** * Gets the content of this <CODE>Annotation</CODE>. * * @return a reference */ public String content() { String s = (String)annotationAttributes.get(CONTENT); if (s == null) s = ""; return s; } /** * Gets the content of this <CODE>Annotation</CODE>. * * @return a reference */ public HashMap attributes() { return annotationAttributes; } /** * Checks if a given tag corresponds with this object. * * @param tag the given tag * @return true if the tag corresponds */ public static boolean isTag(String tag) { return ElementTags.ANNOTATION.equals(tag); } /** * @see com.lowagie.text.MarkupAttributes#setMarkupAttribute(java.lang.String, java.lang.String) */ public void setMarkupAttribute(String name, String value) { markupAttributes = (markupAttributes == null) ? new Properties() : markupAttributes; markupAttributes.put(name, value); } /** * @see com.lowagie.text.MarkupAttributes#setMarkupAttributes(java.util.Properties) */ public void setMarkupAttributes(Properties markupAttributes) { this.markupAttributes = markupAttributes; } /** * @see com.lowagie.text.MarkupAttributes#getMarkupAttribute(java.lang.String) */ public String getMarkupAttribute(String name) { return (markupAttributes == null) ? null : String.valueOf(markupAttributes.get(name)); } /** * @see com.lowagie.text.MarkupAttributes#getMarkupAttributeNames() */ public Set getMarkupAttributeNames() { return Chunk.getKeySet(markupAttributes); } /** * @see com.lowagie.text.MarkupAttributes#getMarkupAttributes() */ public Properties getMarkupAttributes() { return markupAttributes; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -