use of com.codename1.ui.FontImage in project CodenameOne by codenameone.
the class DefaultLookAndFeel method updateRadioButtonConstants.
private void updateRadioButtonConstants(UIManager m, boolean focus, String append) {
Image radioSel = m.getThemeImageConstant("radioSelected" + append + "Image");
if (radioSel != null) {
Image radioUnsel = m.getThemeImageConstant("radioUnselected" + append + "Image");
if (radioUnsel != null) {
Image disUnsel = m.getThemeImageConstant("radioUnselectedDis" + append + "Image");
Image disSel = m.getThemeImageConstant("radioSelectedDis" + append + "Image");
if (disUnsel == null) {
disUnsel = radioUnsel;
}
if (disSel == null) {
disSel = radioSel;
}
if (focus) {
setRadioButtonFocusImages(radioSel, radioUnsel, disSel, disUnsel);
} else {
setRadioButtonImages(radioSel, radioUnsel, disSel, disUnsel);
}
}
} else {
if (!Font.isTrueTypeFileSupported()) {
return;
}
UIManager uim = UIManager.getInstance();
Style unsel = uim.createStyle("RadioButton.", "", false);
Style sel = uim.createStyle("RadioButton.", "sel#", true);
Style dis = uim.createStyle("RadioButton.", "dis#", false);
FontImage checkedDis = FontImage.createMaterial(FontImage.MATERIAL_RADIO_BUTTON_CHECKED, dis);
FontImage uncheckedDis = FontImage.createMaterial(FontImage.MATERIAL_RADIO_BUTTON_UNCHECKED, sel);
if (focus) {
FontImage checkedSelected = FontImage.createMaterial(FontImage.MATERIAL_RADIO_BUTTON_CHECKED, sel);
FontImage uncheckedSelected = FontImage.createMaterial(FontImage.MATERIAL_RADIO_BUTTON_UNCHECKED, sel);
setRadioButtonFocusImages(checkedSelected, uncheckedSelected, checkedDis, uncheckedDis);
} else {
FontImage checkedUnselected = FontImage.createMaterial(FontImage.MATERIAL_RADIO_BUTTON_CHECKED, unsel);
FontImage uncheckedUnselected = FontImage.createMaterial(FontImage.MATERIAL_RADIO_BUTTON_UNCHECKED, unsel);
setRadioButtonImages(checkedUnselected, uncheckedUnselected, checkedDis, uncheckedDis);
}
}
}
use of com.codename1.ui.FontImage in project CodenameOne by codenameone.
the class InfiniteProgress method paint.
/**
* {@inheritDoc}
*/
public void paint(Graphics g) {
if (this.getComponentForm() != null && Display.getInstance().getCurrent() != this.getComponentForm()) {
return;
}
super.paint(g);
if (animation == null) {
return;
}
int v = angle % 360;
Style s = getStyle();
/*if(g.isAffineSupported()) {
g.rotate(((float)v) / 57.2957795f, getAbsoluteX() + s.getPadding(LEFT) + getWidth() / 2, getAbsoluteY() + s.getPadding(TOP) + getHeight() / 2);
g.drawImage(getAnimation(), getX() + s.getPadding(LEFT), getY() + s.getPadding(TOP));
g.resetAffine();
} else {*/
Image rotated;
if (animation instanceof FontImage) {
rotated = animation.rotate(v);
} else {
Integer angle = new Integer(v);
rotated = cache.get(angle);
if (rotated == null) {
rotated = animation.rotate(v);
cache.put(v, rotated);
}
}
g.drawImage(rotated, getX() + s.getPaddingLeftNoRTL(), getY() + s.getPaddingTop());
// }
}
use of com.codename1.ui.FontImage in project CodenameOne by codenameone.
the class ComponentSelector method setIcon.
/**
* Sets the icon of all elements in this set to a material icon. This will use
* the foreground color of each label as the icon's foreground color.
* @param materialIcon The icon charcode.
* @param size The size of the icon (in mm)
* @return Self for chaining
* @see FontImage#createMaterial(char, com.codename1.ui.plaf.Style, float)
*/
public ComponentSelector setIcon(char materialIcon, float size) {
for (Component c : this) {
if (c instanceof Label) {
Label l = (Label) c;
Style style = new Style();
Style cStyle = c.getUnselectedStyle();
style.setBgTransparency(0);
style.setFgColor(cStyle.getFgColor());
l.setIcon(FontImage.createMaterial(materialIcon, style, size));
if (c instanceof Button) {
Button b = (Button) c;
style = new Style();
cStyle = c.getPressedStyle();
style.setBgTransparency(0);
style.setFgColor(cStyle.getFgColor());
b.setPressedIcon(FontImage.createMaterial(materialIcon, style, size));
}
}
}
return this;
}
use of com.codename1.ui.FontImage in project CodenameOne by codenameone.
the class FloatingActionButton method styleChanged.
/**
* We override this method to track style changes to the background color and map them to the border
*
* {@inheritDoc}
*/
@Override
public void styleChanged(String propertyName, Style source) {
if (propertyName.equals(Style.BG_COLOR)) {
updateBorder();
}
if (getIcon() instanceof FontImage && propertyName.equals(Style.FG_COLOR)) {
FontImage i = (FontImage) getIcon();
FontImage image = FontImage.createMaterial(i.getText().charAt(0), "FloatingActionButton", sizeMm);
setIcon(image);
}
}
use of com.codename1.ui.FontImage in project CodenameOne by codenameone.
the class FloatingActionButton method setUIID.
/**
* Overriden to update the icon
* {@inheritDoc}
*/
@Override
public void setUIID(String id) {
super.setUIID(id);
FontImage i = (FontImage) getIcon();
if (i != null) {
Style all = getAllStyles();
all.setAlignment(CENTER);
updateBorder();
FontImage image = FontImage.createMaterial(i.getText().charAt(0), id, sizeMm);
setIcon(image);
}
}
Aggregations