javax.swing.text.View#getAttributes ( )源码实例Demo

下面列出了javax.swing.text.View#getAttributes ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: SwingBox   文件: ElementBoxView.java
/**
 * Gets the box reference from properties.
 * 
 * @param v
 *            just a view.
 * @return the box set in properties, if there is one.
 */
public static final Box getBox(View v)
{
    if (v instanceof CSSBoxView) return getBox((CSSBoxView) v);

    AttributeSet attr = v.getAttributes();
    if (attr == null)
    {
        throw new NullPointerException("AttributeSet of " + v.getClass().getName() + "@"
                            + Integer.toHexString(v.hashCode()) + " is set to NULL.");
    }
    Object obj = attr.getAttribute(Constants.ATTRIBUTE_BOX_REFERENCE);
    if (obj != null && obj instanceof Box)
    {
        return (Box) obj;
    }
    else
    {
        throw new IllegalArgumentException("Box reference in attributes is not an instance of a Box.");
    }

}
 
源代码2 项目: Bytecoder   文件: ImageView.java
public Color getForeground() {
    View parent;
    if (fg == null && (parent = getParent()) != null) {
        Document doc = getDocument();
        AttributeSet attr = parent.getAttributes();

        if (attr != null && (doc instanceof StyledDocument)) {
            fg = ((StyledDocument)doc).getForeground(attr);
        }
    }
    return fg;
}
 
源代码3 项目: openjdk-jdk9   文件: bug4960629.java
private void test() {
    View root = ((View)label.getClientProperty(BasicHTML.propertyKey))
            .getView(0);
    int n = root.getViewCount();
    View v  = root.getView(n - 1);
    AttributeSet attrs = v.getAttributes();
    StyleSheet ss = ((HTMLDocument) v.getDocument()).getStyleSheet();
    Font font = ss.getFont(attrs);
    System.out.println(font.getSize());
    passed = (font.getSize() == 12);
    if(!passed) {
        throw new RuntimeException("Test failed.");
    }
}
 
源代码4 项目: jdk8u_jdk   文件: ImageView.java
public Color getForeground() {
    View parent;
    if (fg == null && (parent = getParent()) != null) {
        Document doc = getDocument();
        AttributeSet attr = parent.getAttributes();

        if (attr != null && (doc instanceof StyledDocument)) {
            fg = ((StyledDocument)doc).getForeground(attr);
        }
    }
    return fg;
}