use of org.opt4j.core.config.annotations.Citation 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.Citation in project opt4j by felixreimann.
the class Format method getTooltip.
/**
* Returns the tooltip of a {@link Class}.
*
* @param c
* the class
* @return the tooltip
*/
public String getTooltip(Class<?> c) {
String name = getName(c);
String info = getInfo(c);
String text = "<html><b>" + name + "</b>";
if (info != null) {
text += xmlBreak + info;
}
Citation citation = c.getAnnotation(Citation.class);
if (citation != null)
text += xmlBreak + xmlBreak + "<span style='color: gray;'>[" + formatIEEE(citation) + "]</span>";
text += "</html>";
return text;
}
use of org.opt4j.core.config.annotations.Citation in project opt4j by felixreimann.
the class PropertyPanel method updatePropertyPanel.
protected void updatePropertyPanel() {
panel.removeAll();
for (final Property property : module.getProperties()) {
if (property.isActive()) {
String name = property.getName();
int i = getIndent(property);
String s = "";
for (int j = 0; j < i; j++) {
s += " ";
}
if (i > 0) {
s = s.substring(2) + "\u21aa ";
}
JPanel labelPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
JLabel label = new JLabel(s + name);
label.setFocusable(false);
String tooltip = format.getTooltip(property);
if (tooltip != null) {
label.setToolTipText(tooltip);
}
labelPanel.add(label);
File file = property.getAnnotation(File.class);
if (file != null) {
JButton browse = new JButton(Icons.getIcon(Icons.FOLDER));
browse.setFocusable(false);
browse.setBorderPainted(false);
browse.setContentAreaFilled(false);
browse.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 0));
browse.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
selectFile(property);
}
});
browse.setCursor(new Cursor(Cursor.HAND_CURSOR));
browse.setToolTipText("Browse ...");
labelPanel.add(browse);
}
panel.add(labelPanel);
Component component = components.get(property);
panel.add(component);
}
}
if (module.getModule().getClass().isAnnotationPresent(Citation.class)) {
Citation citation = module.getModule().getClass().getAnnotation(Citation.class);
addReferenceRow(citation);
}
}
Aggregations