use of org.freeplane.features.icon.factory.IconFactory in project freeplane by freeplane.
the class AttributeTableCellRenderer method getTableCellRendererComponent.
@Override
public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) {
final Component rendererComponent = super.getTableCellRendererComponent(table, value, hasFocus, isSelected, row, column);
final AttributeTable attributeTable = (AttributeTable) table;
zoom = attributeTable.getZoom();
final IAttributeTableModel attributeTableModel = (IAttributeTableModel) table.getModel();
final String originalText = value == null ? null : value.toString();
String text = originalText;
Icon icon;
if (column == 1 && value != null) {
try {
// evaluate values only
final TextController textController = TextController.getController();
Object transformedObject = textController.getTransformedObject(value, attributeTableModel.getNode(), null);
text = transformedObject.toString();
if (transformedObject instanceof HighlightedTransformedObject && TextController.isMarkTransformedTextSet()) {
setBorder(BorderFactory.createLineBorder(Color.GREEN));
}
} catch (Exception e) {
text = TextUtils.format("MainView.errorUpdateText", originalText, e.getLocalizedMessage());
setBorder(BorderFactory.createLineBorder(Color.RED));
}
if (value instanceof URI) {
icon = ((AttributeTable) table).getLinkIcon((URI) value);
} else {
icon = null;
}
} else {
icon = null;
}
final Icon scaledIcon;
final IconFactory iconFactory = IconFactory.getInstance();
if (icon != null && iconFactory.canScaleIcon(icon)) {
final int fontSize = getFont().getSize();
scaledIcon = iconFactory.getScaledIcon(icon, new Quantity<LengthUnits>(fontSize, LengthUnits.px));
} else
scaledIcon = icon;
if (scaledIcon != getIcon()) {
setIcon(scaledIcon);
}
setText(text);
if (text != originalText) {
final String toolTip = HtmlUtils.isHtmlNode(originalText) ? text : HtmlUtils.plainToHTML(originalText);
setToolTipText(toolTip);
} else {
final int prefWidth = getPreferredSize().width;
final int width = table.getColumnModel().getColumn(column).getWidth();
if (prefWidth > width) {
final String toolTip = HtmlUtils.isHtmlNode(text) ? text : HtmlUtils.plainToHTML(text);
setToolTipText(toolTip);
} else {
setToolTipText(null);
}
}
setOpaque(hasFocus);
return rendererComponent;
}
use of org.freeplane.features.icon.factory.IconFactory in project freeplane by freeplane.
the class MenuIconScaling method scaleIcon.
static void scaleIcon(final AbstractButton actionComponent) {
final Icon icon = actionComponent.getIcon();
final IconFactory imageIconFactory = IconFactory.getInstance();
if (icon != null && imageIconFactory.canScaleIcon(icon)) {
final Font font = actionComponent.getFont();
final int fontHeight = actionComponent.getFontMetrics(font).getHeight();
final Quantity<LengthUnits> iconHeight = new Quantity<LengthUnits>(1.2 * fontHeight, LengthUnits.px);
actionComponent.setIcon(FreeplaneIconFactory.toImageIcon(imageIconFactory.getScaledIcon(icon, iconHeight)));
}
}
use of org.freeplane.features.icon.factory.IconFactory in project freeplane by freeplane.
the class TypedListCellRenderer method getListCellRendererComponent.
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
final Icon icon;
if (value instanceof String) {
icon = textIcon;
} else if (value instanceof FormattedDate) {
final FormattedDate fd = (FormattedDate) value;
if (fd.containsTime())
icon = dateTimeIcon;
else
icon = dateIcon;
} else if (value instanceof URI) {
icon = linkIcon;
} else if (value instanceof Number) {
icon = numberIcon;
} else if (value instanceof ObjectAndIcon) {
icon = ((ObjectAndIcon) value).getIcon();
} else
icon = null;
final IconFactory iconFactory = IconFactory.getInstance();
if (icon != null && iconFactory.canScaleIcon(icon)) {
final int fontSize = getFont().getSize();
setIcon(iconFactory.getScaledIcon(icon, new Quantity<LengthUnits>(fontSize, LengthUnits.px)));
} else
setIcon(icon);
return this;
}
use of org.freeplane.features.icon.factory.IconFactory in project freeplane by freeplane.
the class MultipleImage method addLinkIcon.
public void addLinkIcon(Icon icon, NodeModel node) {
final Quantity<LengthUnits> iconHeight = IconController.getController().getIconSize(node);
final IconFactory iconFactory = IconFactory.getInstance();
final Icon scaledIcon = iconFactory.canScaleIcon(icon) ? iconFactory.getScaledIcon(icon, iconHeight) : icon;
mIcons.add(scaledIcon);
mUIIcons.add(null);
}
Aggregations