Search in sources :

Example 1 with Info

use of org.opt4j.core.config.annotations.Info in project opt4j by felixreimann.

the class Format method getTooltip.

/**
 * Returns the formatted (html) tooltip of a {@link Property}.
 *
 * @param property
 *            the property
 * @return the tooltip
 */
public String getTooltip(Property property) {
    String text = "<html><b>" + getName(property) + "</b>";
    String info = property.getInfo();
    if (info != null) {
        text += xmlBreak + info;
    }
    if (property.getType().isEnum()) {
        Class<?> type = property.getType();
        text += xmlBreak;
        Field[] fields = type.getDeclaredFields();
        for (Field field : fields) {
            if (field.isEnumConstant()) {
                String name = field.getName();
                Icon icon = field.getAnnotation(Icon.class);
                Info i = field.getAnnotation(Info.class);
                text += "&nbsp;" + name;
                if (icon != null || i != null) {
                    text += " - ";
                }
                if (icon != null) {
                    text += "<img src=\"" + Icons.getURL(icon.value()) + "\">";
                    System.out.println(text + " " + icon.value());
                }
                if (i != null) {
                    text += i.value();
                }
                Citation c = field.getAnnotation(Citation.class);
                if (c != null)
                    text += "&nbsp;&nbsp;<span style='color: gray;'>[" + formatIEEE(c) + "]</span>";
                text += xmlBreak;
            }
        }
    }
    text += "</html>";
    return text;
}
Also used : Field(java.lang.reflect.Field) Icon(org.opt4j.core.config.annotations.Icon) ImageIcon(javax.swing.ImageIcon) Citation(org.opt4j.core.config.annotations.Citation) Info(org.opt4j.core.config.annotations.Info)

Example 2 with Info

use of org.opt4j.core.config.annotations.Info in project opt4j by felixreimann.

the class Format method getInfo.

/**
 * Returns the info of a {@link Class}.
 *
 * @param c
 *            the class
 * @return the info
 */
public String getInfo(Class<?> c) {
    Info info = c.getAnnotation(Info.class);
    String text = null;
    if (info != null && !"".equals(info.value())) {
        text = info.value();
    }
    return text;
}
Also used : Info(org.opt4j.core.config.annotations.Info)

Aggregations

Info (org.opt4j.core.config.annotations.Info)2 Field (java.lang.reflect.Field)1 ImageIcon (javax.swing.ImageIcon)1 Citation (org.opt4j.core.config.annotations.Citation)1 Icon (org.opt4j.core.config.annotations.Icon)1