Java Code Examples for com.codename1.ui.Form#registerAnimated()

The following examples show how to use com.codename1.ui.Form#registerAnimated() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImageViewer.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the currently showing image
 * @param image the image to set
 */
public void setImage(Image image) {
    if(this.image != image) {
        panPositionX = 0.5f;
        panPositionY = 0.5f;
        zoom = MIN_ZOOM;
        this.image = image;
        updatePositions();
        repaint();
        if(image.isAnimation()) {
            Form f = getComponentForm();
            if(f != null) {
                f.registerAnimated(this);
            }
        }
    }
}
 
Example 2
Source File: ChartComponent.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
public void start(){
    Form f = ChartComponent.this.getComponentForm();
    if ( f != null ){
        f.registerAnimated(this);
        this.motion.start();
    } else {
        animations.remove(this);
    }
}
 
Example 3
Source File: ChartComponent.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
public void start(){
    Form f = ChartComponent.this.getComponentForm();
    if ( f != null ){
        f.registerAnimated(this);
        this.motion.start();
    } else {
        animations.remove(this);
    }
}
 
Example 4
Source File: GenericListCellRenderer.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
private void setComponentValueWithTickering(Component cmp, Object value, Component l, Component rootRenderer) {
    setComponentValue(cmp, value, l, rootRenderer);
    if(cmp instanceof Label) {
        if(selectionListener) {
            if(l instanceof List) {
                ((List)l).addActionListener(mon);
            }
            parentList = l;
        }
        Label label = (Label)cmp;
        if(label.shouldTickerStart() && Display.getInstance().shouldRenderSelection()) {
            if(!label.isTickerRunning()) {
                parentList = l;
                if(parentList != null) {
                    Form f = parentList.getComponentForm();
                    if(f != null) {
                        f.registerAnimated(mon);
                        label.startTicker(cmp.getUIManager().getLookAndFeel().getTickerSpeed(), true);
                    }
                }
            }
        } else {
            if(label.isTickerRunning()) {
                label.stopTicker();
            }
            label.setTextPosition(0);
        }
    }
}
 
Example 5
Source File: UITimer.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Binds the timer to start at the given schedule
 * 
 * @param timeMillis the time from now in milliseconds
 * @param repeat whether the timer repeats
 * @param bound  the form to which the timer is bound
 */
public void schedule(int timeMillis, boolean repeat, Form bound) {
    lastEllapse = System.currentTimeMillis();
    ms = timeMillis;
    this.repeat = repeat;
    this.bound = bound;
    bound.registerAnimated(i);
}
 
Example 6
Source File: ScaleImageLabel.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
void checkAnimation(Image icon) {
    if(icon != null && icon.isAnimation()) {
        Form parent = getComponentForm();
        if(parent != null) {
            // animations are always running so the internal animation isn't
            // good enough. We never want to stop this sort of animation
            parent.registerAnimated(this);
        }
    }
}
 
Example 7
Source File: InfiniteProgress.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected void initComponent() {
    super.initComponent();
    if(animation == null) {
        animation = UIManager.getInstance().getThemeImageConstant("infiniteImage");
    }
    Form f = getComponentForm();
    if(f != null) {
        f.registerAnimated(this);
    }
}
 
Example 8
Source File: ScaleImageButton.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
void checkAnimation(Image icon) {
    if(icon != null && icon.isAnimation()) {
        Form parent = getComponentForm();
        if(parent != null) {
            // animations are always running so the internal animation isn't
            // good enough. We never want to stop this sort of animation
            parent.registerAnimated(this);
        }
    }
}
 
Example 9
Source File: TrigonometricFunctionsChart.java    From codenameone-demos with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Executes the chart demo.
 * @param context the context
 * @return the built intent
 */
public Form execute() {
  String[] titles = new String[] { "sin", "cos" };
  List<double[]> x = new ArrayList<double[]>();
  List<double[]> values = new ArrayList<double[]>();
  int step = 4;
  int count = 360 / step + 1;
  x.add(new double[count]);
  x.add(new double[count]);
  double[] sinValues = new double[count];
  double[] cosValues = new double[count];
  values.add(sinValues);
  values.add(cosValues);
  for (int i = 0; i < count; i++) {
    int angle = i * step;
    x.get(0)[i] = angle;
    x.get(1)[i] = angle;
    double rAngle = Math.toRadians(angle);
    sinValues[i] = Math.sin(rAngle);
    cosValues[i] = Math.cos(rAngle);
  }
  int [] colors = new int[] { ColorUtil.BLUE, ColorUtil.CYAN };
  PointStyle[] styles = new PointStyle[] { PointStyle.POINT, PointStyle.POINT };
  final XYMultipleSeriesRenderer renderer = buildRenderer(colors, styles);
  setChartSettings(renderer, "Trigonometric functions", "X (in degrees)", "Y", 0, 360, -1, 1,
      ColorUtil.GRAY, ColorUtil.LTGRAY);
  
  int strWidth = smallFont.stringWidth("360") / 2;
  int numXLabels = Display.getInstance().getDisplayWidth() / (strWidth + 20);
  renderer.setXLabels(numXLabels);
  renderer.setYLabels(10);
  renderer.setXAxisMin(0);
  renderer.setXAxisMax(50);
  
  final Motion m = Motion.createLinearMotion(0, 310, 10000);
  
  
  final LineChart chart = new LineChart(buildDataset(titles, x, values), renderer);
  final ChartComponent cmp = new ChartComponent(chart);
  Form out = wrap("", cmp);
  out.registerAnimated(new Animation() {

      public boolean animate() {
          if (m.isFinished()) {
              return false;
          } else {
              renderer.setXAxisMin(m.getValue());
              renderer.setXAxisMax(m.getValue()+50);
              cmp.repaint();
              return true;
          }
      }

      public void paint(Graphics g) {
          
      }
      
  });
  m.start();
  return out;
  
}