use of com.codename1.ui.Component in project codenameone-google-maps by codenameone.
the class MapLayout method layoutContainer.
@Override
public void layoutContainer(Container parent) {
// if (true) {
// return;
// }
int parentX = 0;
int parentY = 0;
for (Component current : parent) {
Coord crd = (Coord) current.getClientProperty(COORD_KEY);
Point p = (Point) current.getClientProperty(POINT_KEY);
if (p == null) {
p = map.getScreenCoordinate(crd);
current.putClientProperty(POINT_KEY, p);
}
Float h = (Float) current.getClientProperty(HORIZONTAL_ALIGNMENT);
if (h == null) {
h = 0f;
}
Float v = (Float) current.getClientProperty(VERTICAL_ALIGNMENT);
if (v == null) {
v = 0f;
}
current.setSize(current.getPreferredSize());
current.setX(convertX(p.getX() - parentX, current.getWidth(), h));
current.setY(convertY(p.getY() - parentY, current.getHeight(), v));
}
}
use of com.codename1.ui.Component in project codenameone-google-maps by codenameone.
the class MapInfoPanel method styleLabels.
private void styleLabels(Component... roots) {
for (Component c : roots) {
if (c instanceof Label) {
Label l = (Label) c;
l.getAllStyles().setFgColor(0xffffff);
l.getAllStyles().setBgTransparency(0);
l.getAllStyles().setFont(Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL));
}
if (c instanceof Container) {
Container cnt = (Container) c;
for (Component child : cnt) {
styleLabels(child);
}
}
}
}
use of com.codename1.ui.Component in project CodenameOne by codenameone.
the class GenericListCellRenderer method findComponentsOfInterest.
private void findComponentsOfInterest(Component cmp, ArrayList dest) {
if (cmp instanceof Container) {
Container c = (Container) cmp;
int count = c.getComponentCount();
for (int iter = 0; iter < count; iter++) {
findComponentsOfInterest(c.getComponentAt(iter), dest);
}
return;
}
// performance optimization for fixed images in lists
if (cmp.getName() != null) {
if (cmp instanceof Label) {
Label l = (Label) cmp;
if (l.getName().toLowerCase().endsWith("fixed") && l.getIcon() != null) {
l.getIcon().lock();
}
dest.add(cmp);
return;
}
if (cmp instanceof TextArea) {
dest.add(cmp);
return;
}
}
}
use of com.codename1.ui.Component in project CodenameOne by codenameone.
the class GenericListCellRenderer method setComponentValue.
/**
* Initializes the given component with the given value
*
* @param cmp one of the components that is or is a part of the renderer
* @param value the value to install into the component
*/
private void setComponentValue(Component cmp, Object value, Component parent, Component rootRenderer) {
// process so renderer selected/unselected styles are applied
if (cmp.getName().toLowerCase().endsWith("fixed")) {
return;
}
if (cmp instanceof Label) {
if (value instanceof Image) {
Image i = (Image) value;
if (i.isAnimation()) {
if (pendingAnimations == null) {
pendingAnimations = new ArrayList<Image>();
}
if (!pendingAnimations.contains(i)) {
pendingAnimations.add(i);
if (parentList == null) {
parentList = parent;
}
if (parentList != null) {
Form f = parentList.getComponentForm();
if (f != null) {
f.registerAnimated(mon);
waitingForRegisterAnimation = false;
} else {
waitingForRegisterAnimation = true;
}
}
} else {
if (waitingForRegisterAnimation) {
if (parentList != null) {
Form f = parentList.getComponentForm();
if (f != null) {
f.registerAnimated(mon);
waitingForRegisterAnimation = false;
}
}
}
}
}
Image oldImage = ((Label) cmp).getIcon();
((Label) cmp).setIcon(i);
((Label) cmp).setText("");
if (oldImage == null || oldImage.getWidth() != i.getWidth() || oldImage.getHeight() != i.getHeight()) {
((Container) rootRenderer).revalidate();
}
return;
} else {
((Label) cmp).setIcon(null);
}
if (cmp instanceof CheckBox) {
((CheckBox) cmp).setSelected(isSelectedValue(value));
return;
}
if (cmp instanceof RadioButton) {
((RadioButton) cmp).setSelected(isSelectedValue(value));
return;
}
if (cmp instanceof Slider) {
((Slider) cmp).setProgress(((Integer) value).intValue());
return;
}
Label l = (Label) cmp;
if (value == null) {
l.setText("");
} else {
if (value instanceof Label) {
l.setText(((Label) value).getText());
l.setIcon(((Label) value).getIcon());
} else {
l.setText(value.toString());
}
}
if (firstCharacterRTL) {
String t = l.getText();
if (t.length() > 0) {
l.setRTL(Display.getInstance().isRTL(t.charAt(0)));
}
}
return;
}
if (cmp instanceof TextArea) {
if (value == null) {
((TextArea) cmp).setText("");
} else {
((TextArea) cmp).setText(value.toString());
}
}
}
use of com.codename1.ui.Component in project CodenameOne by codenameone.
the class GenericListCellRenderer method extractLastClickedComponent.
/**
* Allows partitioning the renderer into "areas" that can be clicked. When
* receiving an action event in the list this method allows a developer to
* query the renderer to "see" whether a button within the component was "touched"
* by the user on a touch screen device.
* This method will reset the value to null after returning a none-null value!
*
* @return a button or null
*/
public Button extractLastClickedComponent() {
Button c = lastClickedComponent;
lastClickedComponent = null;
return c;
}
Aggregations