use of org.freeplane.core.util.Quantity in project freeplane by freeplane.
the class MIconController method changeIconSize.
public void changeIconSize(final NodeModel node, final Quantity<LengthUnits> iconSize) {
final IActor actor = new IActor() {
private Quantity<LengthUnits> oldIconSize;
public void act() {
oldIconSize = node.getSharedData().getIcons().getIconSize();
node.getSharedData().getIcons().setIconSize(iconSize);
Controller.getCurrentModeController().getMapController().nodeChanged(node, NodeModel.NODE_ICON_SIZE, null, iconSize);
}
public String getDescription() {
return "changeIconSize";
}
public void undo() {
node.getSharedData().getIcons().setIconSize(oldIconSize);
Controller.getCurrentModeController().getMapController().nodeChanged(node, NodeModel.NODE_ICON_SIZE, oldIconSize, null);
}
};
Controller.getCurrentModeController().execute(actor, node.getMap());
}
use of org.freeplane.core.util.Quantity 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.core.util.Quantity in project freeplane by freeplane.
the class QuantityProperty method addChangeListeners.
private void addChangeListeners() {
numberSpinner.addChangeListener(new ChangeListener() {
public void stateChanged(final ChangeEvent pE) {
firePropertyChangeEvent();
}
});
unitBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
final U newUnit = getCurrentUnit();
double value = (Double) numberSpinner.getValue();
final Quantity<U> newQuantity = new Quantity<U>(value, currentUnit).in(newUnit);
currentUnit = newUnit;
if (value != newQuantity.value)
numberSpinner.setValue(newQuantity.value);
else
firePropertyChangeEvent();
}
}
});
}
use of org.freeplane.core.util.Quantity 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;
}
Aggregations