public void setSpeed() { if (fromToEnable.isSelected()) { int d = Math.round(to.getFloatValue() - from.getFloatValue()); animator.speed = (int) Math.round(speed.getValue() * d / 360); if (animator.speed == 0) animator.speed = 1; } }
public void actionPerformed(ActionEvent e) { if (e.getSource() == fromToEnable) { boolean b = ((JCheckBox) e.getSource()).isSelected(); animator.fromToEnable = b; from.setEnable(b); to.setEnable(b); if (!b) animator.speed = (int) Math.round(speed.getValue()); } else if (e.getSource() == from) { animator.from = from.getFloatValue(); } else if (e.getSource() == to) { animator.to = to.getFloatValue(); } else if (e.getSource() == speed) { animator.speed = speed.getValue(); } else if (e.getActionCommand().equals("Omega")) { if (((JToggleButton) e.getSource()).isSelected()) { animator.animateSingleAngle( paramPane.rotX, paramPane.rotX.getValue(), (JToggleButton) e.getSource()); } else { animator.stopAnimation(); } } else if (e.getActionCommand().equals("Chi")) { if (((JToggleButton) e.getSource()).isSelected()) { animator.animateSingleAngle( paramPane.rotY, paramPane.rotY.getValue(), (JToggleButton) e.getSource()); } else { animator.stopAnimation(); } } else if (e.getActionCommand().equals("Phi")) { if (((JToggleButton) e.getSource()).isSelected()) { animator.animateSingleAngle( paramPane.rotZ, paramPane.rotZ.getValue(), (JToggleButton) e.getSource()); } else { animator.stopAnimation(); } } else if (e.getActionCommand().equals("Lambda")) { if (((JToggleButton) e.getSource()).isSelected()) { animator.animateLambda( paramPane.lambda, paramPane.lambda.getMin(), paramPane.lambda.getMax(), (JToggleButton) e.getSource()); } else { animator.stopAnimation(); } } else if (e.getActionCommand().equals("Debye-Scherrer")) { if (((JToggleButton) e.getSource()).isSelected()) { animator.animateRandom( paramPane.rotX, paramPane.rotY, paramPane.rotZ, (JToggleButton) e.getSource()); } else { animator.stopAnimation(); } } else if (e.getActionCommand().equals("Laue")) { model3d.projScreen.clearImage(); model3d.doLaue(); } else if (e.getActionCommand().equals("Sequential")) { if (((JToggleButton) e.getSource()).isSelected()) { animator.animateSequential( paramPane.rotX, paramPane.rotY, paramPane.rotZ, paramPane.rotX.getValue(), paramPane.rotY.getValue(), paramPane.rotZ.getValue(), (JToggleButton) e.getSource()); } else { animator.stopAnimation(); } } else if (e.getActionCommand().equals("Speed")) { animator.speed = (int) Math.round(((SliderAndValue) e.getSource()).getValue()); setSpeed(); } else if (e.getActionCommand().equals(" Angle")) { double mu = angle.getFloatValue(); model3d.precessionClass.setAngle(mu); model3d.mask3d.setR( Math.sin(model3d.precessionClass.mu) * (model3d.p3d.y * defaultValues.maskDistFract)); model3d.doRays(false); } else if (e.getActionCommand().equals("Mask")) { model3d.setMask(((JCheckBox) e.getSource()).isSelected()); model3d.doRays(false); } else if (e.getActionCommand().equals("Precession")) { if (((JToggleButton) e.getSource()).isSelected()) { animator.animatePrecession( paramPane.precess, paramPane.precess.getValue(), (JToggleButton) e.getSource()); } else { animator.stopAnimation(); } } }
public Animation() { setBorder(new TitledBorder("Animation")); HVPanel.v p1 = new HVPanel.v(); HVPanel p2 = new HVPanel.h(); p2.addButton(new JToggleButton("Omega")); p2.addButton(new JToggleButton("Chi")); p2.addButton(new JToggleButton("Phi")); p1.addSubPane(p2); HVPanel p3 = new HVPanel.h(); p3.addButton(new JToggleButton("Sequential")); p3.addButton(new JToggleButton("Debye-Scherrer")); p1.addSubPane(p3); HVPanel.h p5 = new HVPanel.h(); p5.left(); p5.addButton(fromToEnable = new JCheckBox("")); HVPanel.v p61 = new HVPanel.v(); p61.expand(false); from = p61.addIntField("", "°", 2, defaultValues.startAngle); p5.addSubPane(p61); HVPanel.v p62 = new HVPanel.v(); p62.expand(false); to = p62.addIntField("-", "°", 2, defaultValues.stopAngle); p5.addSubPane(p62); p5.putExtraSpace(); p1.addSubPane(p5); p5.expand(true); speed = p5.addSliderAndValueH("Speed", null, 1, 20, defaultValues.speed, 0, 80); HVPanel p7 = new HVPanel.h(); p7.addButton(new JToggleButton("Lambda")); p7.addButton(laue = new JButton("Laue")); p1.addSubPane(p7); // p1.putExtraSpace(); HVPanel.h p8 = new HVPanel.h(); p8.expand(true); p8.addButton(precession = new JToggleButton("Precession")); HVPanel.v p9 = new HVPanel.v(); p9.expand(false); angle = p9.addIntFieldSpinner(" Angle", "°", 2, defaultValues.mu); model3d.precessionClass.setAngle(defaultValues.mu); model3d.mask3d.setR( Math.sin(model3d.precessionClass.mu) * (model3d.p3d.y * defaultValues.maskDistFract)); p8.addSubPane(p9); p8.addButton(mask = new JCheckBox("Mask")); p1.addSubPane(p8); addSubPane(p1); laue.setForeground(Color.blue); animator = new Animator(); animator.from = defaultValues.startAngle; animator.to = defaultValues.stopAngle; animator.fromToEnable = false; animator.speed = 1; setSpeed(); fromToEnable.setSelected(false); from.setEnable(false); to.setEnable(false); }