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 += " " + 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 += " <span style='color: gray;'>[" + formatIEEE(c) + "]</span>";
text += xmlBreak;
}
}
}
text += "</html>";
return text;
}
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;
}