/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MosaicControl.java
 *
 * Created on 2010-01-15, 01:51:51
 */

package webcamstudio.sources.effects.controls;

import webcamstudio.sources.effects.Twirl;

/**
 *
 * @author pballeux
 */
public class TwirlControl extends javax.swing.JPanel {

    Twirl effect = null;
    /** Creates new form MosaicControl
     * @param effect */
    public TwirlControl(Twirl effect) {
        initComponents();
        this.effect=effect;
        sliderAngle.setValue((int)Math.toDegrees(effect.getAngle()));
        sliderRadius.setValue((int)effect.getRadius());
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        sliderAngle = new javax.swing.JSlider();
        jLabel2 = new javax.swing.JLabel();
        sliderRadius = new javax.swing.JSlider();

        setPreferredSize(new java.awt.Dimension(250, 76));

        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("webcamstudio/Languages"); // NOI18N
        jLabel1.setText(bundle.getString("ANGLE")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        sliderAngle.setMaximum(359);
        sliderAngle.setMinorTickSpacing(30);
        sliderAngle.setPaintLabels(true);
        sliderAngle.setPaintTicks(true);
        sliderAngle.setName("sliderAngle"); // NOI18N
        sliderAngle.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                sliderAngleStateChanged(evt);
            }
        });

        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel2.setText(bundle.getString("RADIUS")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        sliderRadius.setMajorTickSpacing(10);
        sliderRadius.setMaximum(210);
        sliderRadius.setMinimum(1);
        sliderRadius.setMinorTickSpacing(30);
        sliderRadius.setValue(160);
        sliderRadius.setName("sliderRadius"); // NOI18N
        sliderRadius.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                sliderRadiusStateChanged(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(sliderAngle, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(sliderRadius, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(sliderAngle, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(sliderRadius, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addGap(6, 6, 6))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void sliderAngleStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_sliderAngleStateChanged
        effect.setAngle((float)Math.toRadians(sliderAngle.getValue()));
    }//GEN-LAST:event_sliderAngleStateChanged

    private void sliderRadiusStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_sliderRadiusStateChanged
        effect.setRadius(sliderRadius.getValue());
    }//GEN-LAST:event_sliderRadiusStateChanged


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JSlider sliderAngle;
    private javax.swing.JSlider sliderRadius;
    // End of variables declaration//GEN-END:variables

}
