@Override protected void createContent(Composite parent) { final Composite content = new Composite(parent, SWT.NONE); content.setLayout(new GridLayout(2, false)); content.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); final Group animGroup = new Group(content, SWT.NONE); animGroup.setLayout(new GridLayout(1, false)); animGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); animGroup.setText(Messages.AnimationEditor_Animation); final TabFolder animationTabs = new TabFolder(animGroup, SWT.TOP); final AnimationFrameSelector animationFrameSelector = createAnimationFrameSelector(animationTabs); final AnimationRenderer animationRenderer = createAnimationRenderer(animationTabs); final AnimationProperties animationProperties = new AnimationProperties(animationList, animationRenderer); animationList.addListener(animationProperties); final AnimationPlayer animationPlayer = new AnimationPlayer(animationList, animationRenderer); animationPlayer.createAnimationPlayer(animationRenderer.getParent().getParent()); animationFrameSelector.setAnimationList(animationList); animationFrameSelector.setAnimationProperties(animationProperties); animationProperties.setAnimationFrameSelector(animationFrameSelector); animationRenderer.setAnimationPlayer(animationPlayer); final Composite properties = new Composite(content, SWT.NONE); properties.setLayout(new GridLayout(1, false)); properties.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); animationList.create(properties); animationProperties.create(properties); animationList.loadAnimations(); }
/** Example panel. Animate an example file (E short) and play a tone (D long). */ public static void main(String[] args) { try { JFrame f = new JFrame(AnimationPanel.class.getName()); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); AnimationRenderer ani = new AnimationRenderer(); final AnimationPanel view = new AnimationPanel(ani); f.getContentPane().add(view, BorderLayout.CENTER); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true); File file = new File("datafiles/examples/vis/es_.txt"); final AnimationSequence animation = AnimationParser.parseFile(file); String filename = NotesEnum.D.toString().toLowerCase() + "_" + DurationEnum.LONG.codeString() + ".wav"; // System.out.printf("sound clip filename = %s\n", filename); File dir = new File("datafiles/examples/aud"); final Playable audio = SoundClip.findPlayable(filename, dir, false); Runnable r = new Runnable() { @Override public void run() { audio.play(); } }; long currentTime = System.nanoTime(); ani.setAnimationSource( new AnimationSource() { public AnimationSequence getAnimationSequence() { return animation; } public int getNumPoints() { return 5; } public float getDiskRadius() { return 0.3f; } public boolean isConnected() { return true; } }); ani.setNanoStartTime(currentTime); SwingUtilities.invokeLater(r); } catch (Throwable ex) { ex.printStackTrace(); } }