use of com.codename1.ui.plaf.Border in project CodenameOne by codenameone.
the class ResourceEditorView method removeImageOrAnimation.
private void removeImageOrAnimation(String resourceToRemove) {
Object resourceValue = loadedResources.getImage(resourceToRemove);
if (!loadedResources.isOverrideMode()) {
for (String themeName : loadedResources.getThemeResourceNames()) {
Hashtable theme = loadedResources.getTheme(themeName);
if (theme.values().contains(resourceValue)) {
JOptionPane.showMessageDialog(mainPanel, "Image is in use by the theme" + "\nYou must remove it from the theme first", "Image In Use", JOptionPane.ERROR_MESSAGE);
return;
}
// we need to check the existance of image borders to replace images there...
for (Object v : theme.values()) {
if (v instanceof Border) {
Border b = (Border) v;
// BORDER_TYPE_IMAGE
if (Accessor.getType(b) == 8) {
com.codename1.ui.Image[] images = Accessor.getImages(b);
for (int i = 0; i < images.length; i++) {
if (images[i] == resourceValue) {
JOptionPane.showMessageDialog(mainPanel, "Image is in use by the theme in a border" + "\nYou must remove it from the theme first", "Image In Use", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
}
}
}
// check if a timeline is making use of said image and replace it
for (String image : loadedResources.getImageResourceNames()) {
com.codename1.ui.Image current = loadedResources.getImage(image);
if (current instanceof com.codename1.ui.animations.Timeline) {
com.codename1.ui.animations.Timeline time = (com.codename1.ui.animations.Timeline) current;
for (int iter = 0; iter < time.getAnimationCount(); iter++) {
com.codename1.ui.animations.AnimationObject o = time.getAnimation(iter);
if (AnimationAccessor.getImage(o) == resourceValue) {
JOptionPane.showMessageDialog(mainPanel, "Image is in use by a timeline: " + image, "Image In Use", JOptionPane.ERROR_MESSAGE);
return;
}
}
}
}
if (isInUse(loadedResources.getImage(resourceToRemove))) {
JOptionPane.showMessageDialog(mainPanel, "Image is in use in the resource file", "Image In Use", JOptionPane.ERROR_MESSAGE);
return;
}
}
removeSelection(resourceToRemove);
imageList.refresh();
imageListMain.refresh();
imageListSVG.refresh();
imageListMulti.refresh();
imageListTimeline.refresh();
}
use of com.codename1.ui.plaf.Border in project CodenameOne by codenameone.
the class ResourceEditorView method imageBorderWizardMenuItemActionPerformed.
// GEN-LAST:event_addImageTimelineActionPerformed
private void imageBorderWizardMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_imageBorderWizardMenuItemActionPerformed
String themeName = null;
if (selectedResource != null) {
Object o = loadedResources.getResourceObject(selectedResource);
if (!(o instanceof Hashtable)) {
JOptionPane.showMessageDialog(mainPanel, "A theme must be selected to use this feature", "Image Border Wizard", JOptionPane.ERROR_MESSAGE);
return;
}
themeName = selectedResource;
}
ImageBorderWizardTabbedPane iw = new ImageBorderWizardTabbedPane(loadedResources, themeName);
JDialog dlg = new JDialog(SwingUtilities.windowForComponent(mainPanel), "Border Wizard");
dlg.setLayout(new java.awt.BorderLayout());
dlg.add(java.awt.BorderLayout.CENTER, iw);
dlg.pack();
dlg.setLocationRelativeTo(mainPanel);
dlg.setModal(true);
dlg.setVisible(true);
setSelectedResource(selectedResource);
}
use of com.codename1.ui.plaf.Border in project CodenameOne by codenameone.
the class ThemeEditor method findFlushingPropertyContrust.
/**
* Returns a "contrasting" value for the property to flash, e.g. for a font,
* return a differnet font or for a color return a ligher/darker color...
*/
private Object findFlushingPropertyContrust() {
if (flashingProperty.indexOf("Color") > -1) {
// flash to white or black depending on whether the color is closer to white
int val = Integer.decode("0x" + originalFlashingPropertyValue);
if (val > 0xf0f0f0) {
return "000000";
} else {
return "ffffff";
}
}
if (flashingProperty.indexOf("derive") > -1) {
return "NoPropertyUIIDExists";
}
if (flashingProperty.indexOf("font") > -1) {
// if this is not a bold font then just return a system bold font
if ((((com.codename1.ui.Font) originalFlashingPropertyValue).getStyle() & com.codename1.ui.Font.STYLE_BOLD) != 0) {
return com.codename1.ui.Font.createSystemFont(com.codename1.ui.Font.FACE_SYSTEM, com.codename1.ui.Font.STYLE_PLAIN, com.codename1.ui.Font.SIZE_LARGE);
}
return com.codename1.ui.Font.createSystemFont(com.codename1.ui.Font.FACE_SYSTEM, com.codename1.ui.Font.STYLE_BOLD, com.codename1.ui.Font.SIZE_LARGE);
}
if (flashingProperty.indexOf("bgImage") > -1) {
com.codename1.ui.Image i = (com.codename1.ui.Image) originalFlashingPropertyValue;
return i.modifyAlpha((byte) 128);
}
if (flashingProperty.indexOf("transparency") > -1) {
int v = Integer.parseInt((String) originalFlashingPropertyValue);
if (v < 128) {
return "255";
} else {
return "100";
}
}
/*
* if(flashingProperty.indexOf("scale") > -1) { return "false"; }
*/
if (flashingProperty.indexOf("padding") > -1 || flashingProperty.indexOf("margin") > -1) {
return "10,10,10,10";
}
if (flashingProperty.indexOf("border") > -1) {
if (originalFlashingPropertyValue != null) {
Border pressed = ((Border) originalFlashingPropertyValue).createPressedVersion();
if (pressed != null) {
return pressed;
}
}
return Border.createBevelRaised();
}
if (flashingProperty.indexOf("bgType") > -1) {
return originalFlashingPropertyValue;
}
if (flashingProperty.indexOf("bgGradient") > -1) {
Object[] gradient = new Object[4];
System.arraycopy(originalFlashingPropertyValue, 0, gradient, 0, 4);
gradient[0] = ((Object[]) originalFlashingPropertyValue)[1];
gradient[1] = ((Object[]) originalFlashingPropertyValue)[0];
return gradient;
}
if (flashingProperty.indexOf("align") > -1 || flashingProperty.indexOf("textDecoration") > -1) {
return originalFlashingPropertyValue;
}
throw new IllegalArgumentException("Unsupported property type: " + flashingProperty);
}
use of com.codename1.ui.plaf.Border in project CodenameOne by codenameone.
the class List method renderComponent.
/**
* Renders the current component on the screen
*/
private void renderComponent(Graphics g, Component cmp, int x, int y, int width, int height) {
Style s = cmp.getStyle();
int left = s.getMarginLeft(isRTL());
int top = s.getMarginTop();
cmp.setWidth(width - left - s.getMarginRight(isRTL()));
cmp.setHeight(height - top - s.getMarginBottom());
cmp.setX(x + left);
cmp.setY(y + top);
int oX = g.getClipX();
int oY = g.getClipY();
int oWidth = g.getClipWidth();
int oHeight = g.getClipHeight();
// g.pushClip();
g.clipRect(cmp.getX(), cmp.getY(), cmp.getWidth(), cmp.getHeight());
cmp.paint(g);
Border b = s.getBorder();
if (b != null && !b.isBackgroundPainter()) {
cmp.paintBorder(g);
}
g.setClip(oX, oY, oWidth, oHeight);
// g.popClip();
}
use of com.codename1.ui.plaf.Border in project CodenameOne by codenameone.
the class MenuBar method updateBackBorderToRTL.
private void updateBackBorderToRTL(Style s) {
Border b = s.getBorder();
if (b != null) {
b = b.mirrorBorder();
s.setBorder(b);
}
}
Aggregations