use of com.codename1.ui.Label in project CodenameOne by codenameone.
the class MorphTransition method initTransition.
/**
* {@inheritDoc}
*/
public final void initTransition() {
animationMotion = Motion.createEaseInOutMotion(0, 255, duration);
animationMotion.start();
Container s = (Container) getSource();
Container d = (Container) getDestination();
Iterator<String> keyIterator = fromTo.keySet().iterator();
int size = fromTo.size();
fromToComponents = new CC[size];
Form destForm = d.getComponentForm();
Form sourceForm = s.getComponentForm();
for (int iter = 0; iter < size; iter++) {
String k = keyIterator.next();
String v = fromTo.get(k);
Component sourceCmp = findByName(s, k);
Component destCmp = findByName(d, v);
if (sourceCmp == null || destCmp == null) {
continue;
}
CC cc = new CC(sourceCmp, destCmp, sourceForm, destForm);
fromToComponents[iter] = cc;
cc.placeholderDest = new Label();
cc.placeholderDest.setVisible(false);
Container destParent = cc.dest.getParent();
cc.placeholderDest.setX(cc.dest.getX());
cc.placeholderDest.setY(cc.dest.getY() - destForm.getContentPane().getY());
cc.placeholderDest.setWidth(cc.dest.getWidth());
cc.placeholderDest.setHeight(cc.dest.getHeight());
cc.placeholderDest.setPreferredSize(new Dimension(cc.dest.getWidth(), cc.dest.getHeight()));
destParent.replace(cc.dest, cc.placeholderDest, null);
destForm.getLayeredPane().addComponent(cc.dest);
cc.placeholderSrc = new Label();
cc.placeholderSrc.setVisible(false);
cc.placeholderSrc.setX(cc.source.getX());
cc.placeholderSrc.setY(cc.source.getY() - sourceForm.getContentPane().getY());
cc.placeholderSrc.setWidth(cc.source.getWidth());
cc.placeholderSrc.setHeight(cc.source.getHeight());
cc.placeholderSrc.setPreferredSize(new Dimension(cc.source.getWidth(), cc.source.getHeight()));
cc.originalContainer = cc.source.getParent();
cc.originalConstraint = cc.originalContainer.getLayout().getComponentConstraint(cc.source);
cc.originalOffset = cc.originalContainer.getComponentIndex(cc.source);
cc.originalContainer.replace(cc.source, cc.placeholderSrc, null);
cc.originalContainer.getComponentForm().getLayeredPane().addComponent(cc.source);
}
}
use of com.codename1.ui.Label in project CodenameOne by codenameone.
the class MasterDetail method bindTabletLandscapeMaster.
/**
* @deprecated this was a half baked idea that made it into the public API
*/
public static void bindTabletLandscapeMaster(final Form rootForm, Container parentContainer, Component landscapeUI, final Component portraitUI, final String commandTitle, Image commandIcon) {
landscapeUI.setHideInPortrait(true);
parentContainer.addComponent(BorderLayout.WEST, landscapeUI);
final Command masterCommand = new Command(commandTitle, commandIcon) {
public void actionPerformed(ActionEvent ev) {
Dialog dlg = new Dialog();
dlg.setLayout(new BorderLayout());
dlg.setDialogUIID("Container");
dlg.getContentPane().setUIID("Container");
Container titleArea = new Container(new BorderLayout());
dlg.addComponent(BorderLayout.NORTH, titleArea);
titleArea.setUIID("TitleArea");
Label title = new Label(commandTitle);
titleArea.addComponent(BorderLayout.CENTER, title);
title.setUIID("Title");
Container body = new Container(new BorderLayout());
body.setUIID("Form");
body.addComponent(BorderLayout.CENTER, portraitUI);
dlg.setTransitionInAnimator(CommonTransitions.createSlide(CommonTransitions.SLIDE_HORIZONTAL, false, 250));
dlg.setTransitionOutAnimator(CommonTransitions.createSlide(CommonTransitions.SLIDE_HORIZONTAL, true, 250));
dlg.addComponent(BorderLayout.CENTER, body);
dlg.setDisposeWhenPointerOutOfBounds(true);
dlg.showStetched(BorderLayout.WEST, true);
dlg.removeComponent(portraitUI);
}
};
if (Display.getInstance().isPortrait()) {
if (rootForm.getCommandCount() > 0) {
rootForm.addCommand(masterCommand, 1);
} else {
rootForm.addCommand(masterCommand);
}
}
rootForm.addOrientationListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (portraitUI.getParent() != null) {
Form f = Display.getInstance().getCurrent();
if (f instanceof Dialog) {
((Dialog) f).dispose();
}
}
if (Display.getInstance().isPortrait()) {
rootForm.addCommand(masterCommand, 1);
} else {
rootForm.removeCommand(masterCommand);
rootForm.revalidate();
}
}
});
}
use of com.codename1.ui.Label in project CodenameOne by codenameone.
the class Ads method setHeight.
/**
* {@inheritDoc}
*/
public void setHeight(int height) {
float percent = ((float) height / (float) Display.getInstance().getDisplayHeight());
percent *= 100;
// remove it.
if (percent > 25) {
removeAll();
Label filler = new Label(" ");
filler.setPreferredSize(new Dimension(400, 2));
filler.getStyle().setBgTransparency(0);
addComponent(BorderLayout.CENTER, filler);
revalidate();
} else {
super.setHeight(height);
}
}
use of com.codename1.ui.Label in project CodenameOne by codenameone.
the class FloatingActionButton method createPopupContent.
/**
* Creates the popup content container to display on the dialog.
*
* @param fabs List of sub FloatingActionButton
* @return a Container that contains all fabs
*/
protected Container createPopupContent(List<FloatingActionButton> fabs) {
Container con = new Container(new BoxLayout(BoxLayout.Y_AXIS));
for (FloatingActionButton next : subMenu) {
next.setPreferredW(getWidth());
Container c = new Container(new BorderLayout());
Label txt = new Label(next.text);
txt.setUIID("FloatingActionText");
c.add(BorderLayout.CENTER, FlowLayout.encloseRight(txt));
c.add(BorderLayout.EAST, next);
con.add(c);
}
return con;
}
use of com.codename1.ui.Label in project CodenameOne by codenameone.
the class XYChart method drawYLabels.
/**
* The graphical representation of the labels on the Y axis.
*
* @param allYLabels the Y labels values
* @param canvas the canvas to paint to
* @param paint the paint to be used for drawing
* @param maxScaleNumber the maximum scale number
* @param left the left value of the labels area
* @param right the right value of the labels area
* @param bottom the bottom value of the labels area
* @param yPixelsPerUnit the amount of pixels per one unit in the chart labels
* @param minY the minimum value on the Y axis in the chart
*/
protected void drawYLabels(Map<Integer, List<Double>> allYLabels, Canvas canvas, Paint paint, int maxScaleNumber, int left, int right, int bottom, double[] yPixelsPerUnit, double[] minY) {
Orientation or = mRenderer.getOrientation();
boolean showGridX = mRenderer.isShowGridX();
boolean showLabels = mRenderer.isShowLabels();
boolean showTickMarks = mRenderer.isShowTickMarks();
paint.setTextSize(mRenderer.getLabelsTextSize());
for (int i = 0; i < maxScaleNumber; i++) {
paint.setTextAlign(mRenderer.getYLabelsAlign(i));
List<Double> yLabels = allYLabels.get(i);
int length = yLabels.size();
for (int j = 0; j < length; j++) {
double label = yLabels.get(j);
int axisAlign = mRenderer.getYAxisAlign(i);
boolean textLabel = mRenderer.getYTextLabel(label, i) != null;
float yLabel = (float) (bottom - yPixelsPerUnit[i] * (label - minY[i]));
if (or == Orientation.HORIZONTAL) {
if (showLabels && !textLabel) {
paint.setColor(mRenderer.getYLabelsColor(i));
if (axisAlign == Align.LEFT) {
if (showTickMarks) {
canvas.drawLine(left + getLabelLinePos(axisAlign), yLabel, left, yLabel, paint);
}
drawText(canvas, getLabel(mRenderer.getYLabelFormat(i), label), left - mRenderer.getYLabelsPadding(), yLabel - mRenderer.getYLabelsVerticalPadding(), paint, mRenderer.getYLabelsAngle());
} else {
if (showTickMarks) {
canvas.drawLine(right, yLabel, right + getLabelLinePos(axisAlign), yLabel, paint);
}
drawText(canvas, getLabel(mRenderer.getYLabelFormat(i), label), right + mRenderer.getYLabelsPadding(), yLabel - mRenderer.getYLabelsVerticalPadding(), paint, mRenderer.getYLabelsAngle());
}
}
if (showGridX) {
paint.setColor(mRenderer.getGridColor(i));
canvas.drawLine(left, yLabel, right, yLabel, paint);
}
} else if (or == Orientation.VERTICAL) {
if (showLabels && !textLabel) {
paint.setColor(mRenderer.getYLabelsColor(i));
if (showTickMarks) {
canvas.drawLine(right - getLabelLinePos(axisAlign), yLabel, right, yLabel, paint);
}
drawText(canvas, getLabel(mRenderer.getLabelFormat(), label), right + 10 + mRenderer.getYLabelsPadding(), yLabel - mRenderer.getYLabelsVerticalPadding(), paint, mRenderer.getYLabelsAngle());
}
if (showGridX) {
paint.setColor(mRenderer.getGridColor(i));
if (showTickMarks) {
canvas.drawLine(right, yLabel, left, yLabel, paint);
}
}
}
}
}
}
Aggregations