2 Replies Latest reply on Feb 7, 2013 6:01 PM by colin-java

    KeyFrame construction

      Hi, when creating a KeyFrame such as
      new KeyFrame(Duration.ZERO,
                      new KeyValue(...),
                      new KeyValue(...),
                      new KeyValue(...),
                      new KeyValue(...));
      But supposing I have 1000 KeyValues, then I don't really want to type it all.
      I tried to use an array, and also a HashSet, but it wasn't allowed.
      I'm quite new to this new parameter list technique, so I don't know if theres a shortcut for it.

      Thanks for any help.

      Edited by: colin-java on Feb 7, 2013 8:49 AM
        • 1. Re: KeyFrame construction
          You can use an array:
              final IntegerProperty val = new SimpleIntegerProperty();
              KeyValue[] values = new KeyValue[] {new KeyValue(val, 0), new KeyValue(val, 1)};
              KeyFrame kf = new KeyFrame(Duration.ZERO, values);
          and obviously if you have 1000 of them you can initialize them in a loop.

          Though why you would ever create a KeyFrame with 1000 KeyValues is somewhat beyond me...
          • 2. Re: KeyFrame construction
            Thanks, I must have done it wrong, the array works now.

            I'm just testing animating loads of polygons, I might not actually need to do what I said though.
            If the polygons are all together to form a 3D shape, I would just put rotate the group containing them.