Animating vertices in shapes

hello guys
i have a question regarding the drawing api and animating the
resulting drawn images.
im using flash cs3 (actionscript 3 of course) and need to
draw in some skewed rectangular shapes, where i can control where
each of the 4 points of the rectangle are (because the shapes are
not necessarily straight angled). from what i've seen, i need to
use the lineTo commands (as opposed to drawRect) because of this.
then, i need to animate each of the 4 vertices of these
shapes in an independent fashion. i really want to use the new
Tween libraries (seem to be more effiicient than enterFrames), but
these seem designed to animate only the object as a whole (and not
just the vertices of the object). because of this im being forced
to use enterframes to redraw the shape, which i feel is missing the
poing entirely of the Tween libraries.
is there an effiicient way of doing this?
thank you very much,
federico

You can create a frame animation.  What you will have is a series of layers each with a step in your progression.  You start by creating the first frame in the frame animation dialog box and turn on the visibility of the layer that you want in that first frame.  Then you create a new layer with your painting.  Then, leaving the original layer visible, you create a new frame.  What ever is visiable in your layer pallet will be visible in the created frame.

Similar Messages

  • Number of vertices in shape

    Hello,
    I have the following problem:
    I load an .obj file containing a certain number of vertices into my Java3D application
    ObjectFile f = new ObjectFile();Then I access these vertices/coordinates via
    GeometryInfo gi = new GeometryInfo((GeometryArray)shape.getGeometry());
    GemometryArray ga = gi.getGeometryArray();
    // create array which holds vertices as Point3d
    verticesArr = new Point3d[ga.getVertexCount()]
    // fill in array with all vertices
    for (int i=0; i<ga.getVertexCount(); i++) {
    verticesArr[i] = new Point3d();
    ga.getCoordinates(i, verticesArr);
    My problem is, that the number of vertices (i.e. ga.getVertexCount) in the loaded shape does not equal the number of vertices in the original file that I load!
    How can that be? Does Java3D increase the number of vertices or am I getting something wrong?
    Thanks

    Any idea how I can access each coordinate one by one
    and do my calculation?yup.. i have done this but my object is WAY more simple than your one. What i done is first get all the points (this will include repetitions as u have found out):
    Enumeration en = obj.getAllGeometries();
    TriangleStripArray tsa = (TriangleStripArray)en.nextElement();
    points = new Point3d[tsa.getVertexCount()];
    //initialise array
    for(int i = 0; i<points.length;i++)
    points[i] = new Point3d();
    tsa.getCoordinates(0,points);
    then i search through the repetitions and place any repeating point3d with null:
    //copies 'null' into repetitions of points
    for(int i = 0; i<points.length; i++){
    for(int j = i+1; j < points.length; j++){
    if(points[i] == null || points[j] == null );
    else if( points.equals(points[j]) ){
    points[j] = null;
    i have done this in my initialisation stage to save me having to repeatedly work out the same vertices over and over again. what u could then do is to store the final set of Point3d's in a new array or into a Vector.

  • Timer Class not accurate and slows down my animation!?

    Does anyknow how why my timer object is not accurate and why it slows down my animation that is also present on my GUI at the same time?
    I have a timer in the form of 0.00 the left of the decimal point should represent a second but it doesnt, run my code and see for yourselves. below is my code if anyone can fix these 2 problems i will be very thankfull:
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.Shape;
    import java.io.*;
    import java.text.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.swing.event.*;
    import javax.swing.Timer;
    import java.sql.*;
    import java.text.*;
    public class RT extends JFrame implements MouseMotionListener
        //declares a number of swing componets to be used for the JFrame
        private JTextArea infoJTextArea;
        private JPanel showJPanel, startJPanel, helpJPanel, resultsJPanel;
        private JLabel de4JLabel, de3JLabel, mainTitleJLabel, nameJLabel, ageJLabel,
                       deJLabel, de1JLabel, de2JLabel, timeJLabel,nameResultJLabel,
                       ageResultJLabel, timeResultsJLabel, ratingJLabel, coJLabel, shJLabel;
        private JTextField nameJTextField, ageJTextField,nameResultJTextField,
                       ageResultsJTextField, timeResultsJTextField, ratingJTextField;
        private JButton exitJButton, showJButton, loginJButton, startTestJButton,
                        tempObjectJButton;
        private JScrollPane scroll;
    public JComboBox colourJComboBox, sizeJComboBox, shapeJComboBox, speedJComboBox;
    private static Connection dbcon;
    int temp=0;
    private String[] col = { "Red", "Blue", "Green","Yellow","Orange","Black"};
    private String[] shapeA = { "Normal Rectangle", "Normal Circle", "Normal Oval","BIG Rectangle", "BIG Circle","BIG Oval","small rectangle","small circle", "small oval"};
    private String[] speed = { "Fast", "Normal", "Slow"};
    public int checking;
    static int flag, flagshape, flagspeed;
        // creates and sets up a number of varibles to be used by the class
        public long timeLimit = 0;
        DecimalFormat timeDec = new DecimalFormat (":00");
        public int age;
        public String name, shapeChoice="Normal Rectangle(Never selected anything)", colourChoice="Black(Never selected anything)";
        private Timer TimeNow;
        private JTextField timerJTextField;
        ShapeMovingPanel testJPanel;
        Random seed;
        Shape shape;
        Shape[] shapes = {new Rectangle2D.Double(50, 30, 75, 25),new Ellipse2D.Double(175, 125, 50, 50),new Ellipse2D.Double(90, 100, 75, 35),new Rectangle2D.Double(50, 30, 175, 125),new Ellipse2D.Double(175, 125, 125, 125),new Ellipse2D.Double(90, 100, 175, 135),new Rectangle2D.Double(50, 30, 55, 15),new Ellipse2D.Double(175, 125, 20,20),new Ellipse2D.Double(90, 100, 55, 15)};
    //50, 30, 75, 25 change starting point here****************************************
        public RT()            // constructor method
            seed = new Random();
            shape = shapes[0];
            //sets up the Timer
            TimeNow = new Timer((1), new TimerListener());//++++++++++++++++++++++++++timer -17
            createUserInterface();          // method that creates the user interface     
        private void createUserInterface()
            new Thread(new Runnable()
                public void run()
                    String results = "";
                    int count = 0;
                    boolean journeyOn = true;
                    while(journeyOn && count < 3)
                        try
                            Thread.sleep(1000);
                        catch(InterruptedException ie)
                            System.err.println("show interrupt: " + ie.getMessage());
                            journeyOn = false;
                        results += count++ + ", ";
                    try {
                             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                             dbcon = DriverManager.getConnection("jdbc:odbc:CMT3991", "", ""); // Access/ODBC
                          //connection ash used to connect to the user table in access
                           } catch(Exception eee)
                           eee.printStackTrace();  //exception if error occurs during the driver connection
                             System.out.println("* UserDA CONNECTED *");
            }).start();
            Container contentPane = getContentPane();
            contentPane.setLayout( null );
            // set up infoJTextField
            infoJTextArea = new JTextArea();
            infoJTextArea.setBounds( 20, 420, 550, 170  );
            infoJTextArea.setEditable( false);
            infoJTextArea.setText("\n    Welcome to the reaction testing program, this " +
                            "program is designed to test your reactions in a  \n"+
                            "    number of different situations.\n"+"\n    Please " +
                            "enter your name and age, or select show previous results.");
            contentPane.add( infoJTextArea );
            scroll = new JScrollPane(infoJTextArea);
            scroll.setBounds(  20, 420, 550, 170 );
            contentPane.add( scroll );
                  startJPanel = new JPanel();
            startJPanel.setBounds( 16,16, 560, 375 );
            startJPanel.setBorder(
                    new TitledBorder( "WELCOME - PLEASE ENTER YOUR NAME AND AGE:" ) );
            startJPanel.setLayout( null );
            contentPane.add( startJPanel );
            //sets up a JPanel
            mainTitleJLabel = new JLabel();
            mainTitleJLabel.setIcon( new ImageIcon( "title.png" ) );
            mainTitleJLabel.setBounds( 30, 10, 520, 170 );
            mainTitleJLabel.setHorizontalAlignment( JLabel.CENTER );
            startJPanel.add( mainTitleJLabel );
            //creates a newJLabel
            nameJLabel= new JLabel();
            nameJLabel.setBounds( 52, 200, 70, 35 );
            nameJLabel.setText("Name:");
            startJPanel.add( nameJLabel);
            //creates a new JTextField
            nameJTextField = new JTextField();
            nameJTextField.setBounds( 130, 200, 300, 24 );
            startJPanel.add( nameJTextField );
            //creates a newJLabel
            ageJLabel = new JLabel();
            ageJLabel.setBounds( 52, 245, 100, 35 );
            ageJLabel.setText("Age:");
            startJPanel.add( ageJLabel );
            //creates a new JTextField
            ageJTextField = new JTextField();
            ageJTextField.setBounds( 130, 245, 300, 24 );
            startJPanel.add( ageJTextField );
            //creates a JButton
            loginJButton = new JButton();
            loginJButton.setBounds( 440, 200, 90, 24 );
            loginJButton.setText( "Login" );
            loginJButton.setBackground( Color.YELLOW );
            startJPanel.add( loginJButton );
            loginJButton.setEnabled(true);
    //        loginJButton.setVisible(true);
            loginJButton.addActionListener(
                new ActionListener()    // adds an action listener,anonymous inner class
                    // event handler called when search is pressed
                    public void actionPerformed( ActionEvent event )
                        // not necessary to pass events to these methods...
                        Login();  // calls the Login method                       
            //creates a JButton
            showJButton = new JButton();
            showJButton.setBounds( 200, 320, 180, 24 );
            showJButton.setText( "Show previous results" );
            showJButton.setBackground( Color.YELLOW );
            startJPanel.add( showJButton );
            showJButton.setEnabled(true);
    //        showJButton.setVisible(true);
            showJButton.addActionListener(
                new ActionListener()    // adds an action listener,anonymous inner class
                    // event handler called when search is pressed
                    public void actionPerformed( ActionEvent event )
                        showData();   // calls the showData method                       
            //sets up a JPanel
            showJPanel = new JPanel();
            showJPanel.setBounds( 16,16, 560, 375 );
            showJPanel.setBorder(new TitledBorder( "PREVIOUS RESULTS:" ) );
            showJPanel.setLayout( null );
            contentPane.add( showJPanel );
            //sets up a JPanel
            helpJPanel = new JPanel();
            helpJPanel.setBounds( 16,16, 560, 375 );
            helpJPanel.setBorder(
            new TitledBorder( "CHOOSE A NUMBER OF OPTIONS AND GET READY:" ) );
            helpJPanel.setLayout( null );
            helpJPanel.setVisible(false);
            contentPane.add( helpJPanel );
            //creates a newJLabel
            deJLabel= new JLabel();
            deJLabel.setBounds( 23, 390, 530, 35 );
            deJLabel.setText("Details:");
            contentPane.add( deJLabel);
            //creates a newJLabel
            coJLabel= new JLabel();
            coJLabel.setBounds( 70, 40, 530, 35 );
            coJLabel.setText("Choose a colour:");
            helpJPanel.add( coJLabel);
            //creates a newJLabel
            de1JLabel= new JLabel();
            de1JLabel.setBounds( 25, 100, 530, 35 );
            de1JLabel.setText("You are about to start the reaction test, when you " +
                              "press the start button it will begin.");
            helpJPanel.add( de1JLabel);
            //creates a newJLabel
            de1JLabel= new JLabel();
            de1JLabel.setBounds(160, 145, 530, 35 );
            de1JLabel.setText("Simply catch the moving item and click.");
            helpJPanel.add( de1JLabel);
            colourJComboBox = new JComboBox( col );
               colourJComboBox.setBounds( 70, 70, 135, 21 );
               colourJComboBox.setMaximumRowCount( 3 );
               helpJPanel.add( colourJComboBox );
              colourJComboBox.addActionListener(
                new ActionListener() // adds an action listener,anonymous inner class
                    // event handler called when search is pressed
                    public void actionPerformed( ActionEvent event )
                         colourChoice="Black";
                         int x = colourJComboBox.getSelectedIndex();
                        if( x  == 0)
                             flag = 1;
                             colourChoice="Red";
                        else if(x  == 1)
                             flag = 2;
                             colourChoice="Blue";
                        else if(x  == 2)
                             flag = 3;
                                colourChoice="Green";
                         else if(x  == 3)
                             flag = 4;
                                colourChoice="Yellow";
                         else if(x  == 4)
                             flag = 5;
                                colourChoice="Orange";
                           else if(x  == 5)
                             flag = 6;
                                colourChoice="Black";
            shJLabel= new JLabel();
            shJLabel.setBounds( 340, 40, 530, 35 );
            shJLabel.setText("Choose a shape and size:");
            helpJPanel.add( shJLabel);
            shapeJComboBox = new JComboBox( shapeA );
               shapeJComboBox.setBounds( 340, 70, 135, 21 );
               shapeJComboBox.setMaximumRowCount( 3 );
               helpJPanel.add( shapeJComboBox );
              shapeJComboBox.addActionListener(
                new ActionListener() // adds an action listener,anonymous inner class
                    // event handler called when search is pressed
                    public void actionPerformed( ActionEvent event )
                          int xshape = shapeJComboBox.getSelectedIndex();
                        //shapeChoice="Normal Rectangle";
                        if( xshape  == 0)
                        {     flagshape = 1;
                             shapeChoice="Normal Rectangle";
                        else if(xshape  == 1)
                        {     flagshape = 2;
                             shapeChoice="Normal Circle";
                        else if(xshape  == 2)//**********here
                        {     flagshape = 3;
                             shapeChoice="Normal Oval";
                        else if(xshape  == 3)
                        {     flagshape = 4;
                             shapeChoice="BIG Rectangle";
                        else if(xshape  == 4)
                       {      flagshape = 5;
                             shapeChoice="BIG Circle";
                        else if(xshape  == 5)
                     {        flagshape = 6;
                             shapeChoice="BIG Oval";
                        else if(xshape  == 6)
                             flagshape = 7;
                             shapeChoice="small rectangle";
                        else if(xshape  == 7)
                     {        flagshape = 8;
                             shapeChoice="small circle";
                        else if(xshape  == 8)
                     {        flagshape = 9;
                             shapeChoice="small oval";
          /*  speedJComboBox = new JComboBox( speed );
               speedJComboBox.setBounds( 10, 150, 135, 21 );
               speedJComboBox.setMaximumRowCount( 3 );
               helpJPanel.add( speedJComboBox );
              speedJComboBox.addActionListener(
                new ActionListener() // adds an action listener,anonymous inner class
                    // event handler called when search is pressed
                    public void actionPerformed( ActionEvent event )
                          int xspeed = speedJComboBox.getSelectedIndex();
                        if( xspeed  == 0)
                             flagspeed = 1;
                             else if(xspeed  == 1)
                             flagspeed = 2;
                             else
                             flagspeed = 3;
                        System.out.println(flagspeed);     
            //creates a newJLabel
            de2JLabel= new JLabel();
            de2JLabel.setBounds( 20, 380, 70, 35 );
            de2JLabel.setText("Details:");
            helpJPanel.add( de2JLabel);
            //creates a JButton
            startTestJButton = new JButton();
            startTestJButton.setBounds( 185, 205, 180, 60 );
            startTestJButton.setText( "START" );
            startTestJButton.setBackground( Color.YELLOW );
            helpJPanel.add( startTestJButton );
            startTestJButton.setEnabled(true);
    //        startTestJButton.setVisible(true);
            startTestJButton.addActionListener(
                new ActionListener() // adds an action listener,anonymous inner class
                    // event handler called when search is pressed
                    public void actionPerformed( ActionEvent event )
                        startTest();
            //sets up an animation panel
            testJPanel = new ShapeMovingPanel(this);
            testJPanel.setBounds( 16,16, 560, 375 );
            testJPanel.setBorder(new TitledBorder("Click the moving object:"));
            testJPanel.setLayout( null );
            testJPanel.setVisible(false);
            contentPane.add( testJPanel );
            testJPanel.addMouseMotionListener(this);
            //creates a newJLabel
            timeJLabel = new JLabel();
            timeJLabel.setBounds( 440, 330, 100, 35 );
            timeJLabel.setText("Time:");
            testJPanel.add( timeJLabel );
            //creates a new JTextField
            timerJTextField = new JTextField();
            timerJTextField.setBounds( 480, 335, 60, 24 );
            timerJTextField.setText(String.valueOf(timeLimit));
            timerJTextField.setHorizontalAlignment(JTextField.CENTER );
            timerJTextField.setEditable(false);
            timerJTextField.setBackground( Color.YELLOW );
            testJPanel.add( timerJTextField );
            resultsJPanel = new JPanel();
            resultsJPanel.setBounds( 16,16, 560, 375 );
            resultsJPanel.setBorder(new TitledBorder("HERE ARE YOUR RESULTS:"));
            resultsJPanel.setLayout( null );
            resultsJPanel.setVisible(false);
            contentPane.add( resultsJPanel );
            de3JLabel= new JLabel();
            de3JLabel.setBounds(20, 200, 530, 35 );
            de3JLabel.setText("Below is also the movements you made with your mouse, " +
                              "you may exit the program now.");
            resultsJPanel.add( de3JLabel);
            de4JLabel= new JLabel();
            de4JLabel.setBounds(135, 245, 530, 35 );
            de4JLabel.setText("Thank you for trying the Reaction Testing program");
            resultsJPanel.add( de4JLabel);
            //creates a newJLabel
            nameResultJLabel= new JLabel();
            nameResultJLabel.setBounds( 62, 55, 50, 35 );
            nameResultJLabel.setText("Name:");
            resultsJPanel.add( nameResultJLabel);
            //creates a new JTextField
            nameResultJTextField = new JTextField();
            nameResultJTextField.setBounds( 140, 55, 300, 24 );
            resultsJPanel.add( nameResultJTextField );
            nameResultJTextField.setEditable(false);
            //creates a newJLabel
            ageResultJLabel = new JLabel();
            ageResultJLabel.setBounds( 62, 90, 100, 35 );
            ageResultJLabel.setText("Age:");
            resultsJPanel.add( ageResultJLabel );
            //creates a new JTextField
            ageResultsJTextField = new JTextField();
            ageResultsJTextField.setBounds( 140, 90, 300, 24 );
            resultsJPanel.add( ageResultsJTextField );
            ageResultsJTextField.setEditable(false);
            //creates a newJLabel
            timeResultsJLabel = new JLabel();
            timeResultsJLabel.setBounds( 62, 125, 100, 35 );
            timeResultsJLabel.setText("Time taken:");
            resultsJPanel.add( timeResultsJLabel );
            //creates a new JTextField
            timeResultsJTextField = new JTextField();
            timeResultsJTextField.setBounds( 140, 125, 300, 24 );
            resultsJPanel.add( timeResultsJTextField );
            timeResultsJTextField.setEditable(false);
            //creates a newJLabel
            ratingJLabel = new JLabel();
            ratingJLabel.setBounds( 62, 160, 100, 35 );
            ratingJLabel.setText("Your Rating:");
            resultsJPanel.add( ratingJLabel );
            ratingJTextField = new JTextField();
            ratingJTextField.setBounds( 140, 160, 300, 24 );
            resultsJPanel.add( ratingJTextField );
            ratingJTextField.setEditable(false);
            //creates a JButton
            exitJButton = new JButton();
            exitJButton.setBounds( 235, 310, 90, 24 );
            exitJButton.setText( "Exit" );
            exitJButton.setBackground( Color.WHITE );
            resultsJPanel.add( exitJButton );
            exitJButton.setEnabled(true);
            exitJButton.addActionListener(
                new ActionListener() // adds an action listener,anonymous inner class
                    // event handler called when exitJButton is pressed
                    public void actionPerformed( ActionEvent event )
                        System.exit(0); //closes the programme
            }); // end anonymous inner class
            addWindowListener(new WindowAdapter()
                public void windowClosing(WindowEvent e)
                    System.exit(0);
            // set properties of application's window
            setTitle( "Reaction Tester - CMT3991" ); // set JFrame's title bar string
            //setSize( 1280,995 );    // set width and height of JFrame
            setSize( 608, 650 );         // set width and height of JFrame
            setVisible( true );       // display JFrame on screen
        //** set up of method main */
        public static void main( String[] args )
            RT application = new RT();
            application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        } // end method main
         * action listener for TimeNow Timer
        private class TimerListener implements ActionListener
            public void actionPerformed(ActionEvent event)
                timeLimit ++;          
                if (timeLimit==100)
                     temp++;
                     timeLimit=0;
                timerJTextField.setText(String.valueOf(temp +""+timeDec.format(timeLimit)));
        private void Login()
            try
                name = nameJTextField.getText();
                age = Integer.parseInt(ageJTextField.getText());
                startJPanel.setVisible(false);
                showJPanel.setVisible(false);
                helpJPanel.setVisible(true);
                infoJTextArea.setText("\n    Welcome "+name+" you will soon know how " +
                                      "fast your reactions are.");
            catch (NumberFormatException exception)
                JOptionPane.showMessageDialog(this,
                        "There is either a blank field or a number hasn't been entered",
                        "Input Type error", JOptionPane.ERROR_MESSAGE);
                //shows this is something has been entered wrong
        private void startTest()
            helpJPanel.setVisible(false);
          //  System.out.println(""+ seed.nextInt(shapes.length));
            //shape = shapes[seed.nextInt(shapes.length)];//****************************
            if (flagshape==1)
                 shape = shapes[0];// changed colour here***************************
            else if (flagshape==2)
                 shape = shapes[1];// changed colour here***************************
            else if (flagshape==3)
                 shape = shapes[2];// changed colour here***************************
           else if (flagshape==4)
                 shape = shapes[3];// changed colour here***************************
             else if (flagshape==5)
                 shape = shapes[4];// changed colour here***************************
            else if (flagshape==6)
                 shape = shapes[5];// changed colour here***************************
            else if (flagshape==7)
                 shape = shapes[6];// changed colour here***************************
            else if (flagshape==8)
                 shape = shapes[7];// changed colour here***************************
            else if (flagshape==9)
                 shape = shapes[8];// changed colour here***************************
           // shape = shapes[8];
            System.out.println(shape.toString());
            testJPanel.setShape(shape);
            testJPanel.setVisible(true);
            testJPanel.start();
            infoJTextArea.setText("");
            TimeNow.start();
         * called by animation panel after shape is clicked
        public void stop()
            TimeNow.stop();
            movingObject();
         * this will compete with your animation
         * ie, it will slow it down or make it appear jerky
        public void mouseMoved(MouseEvent e)
            saySomething("\n    Mouse moved", e);
        public void mouseDragged(MouseEvent e)
            saySomething("\n    Mouse dragged", e);
        void saySomething(String eventDescription, MouseEvent e)
            infoJTextArea.append(eventDescription
                         + " (" + e.getX() + "," + e.getY() + ")");
            infoJTextArea.setCaretPosition(infoJTextArea.getDocument().getLength());
        private void movingObject()
            TimeNow.stop();
            //timeLimit;
            testJPanel.setVisible(false);
            resultsJPanel.setVisible(true);
            nameResultJTextField.setText(name);
            ageResultsJTextField.setText(String.valueOf(age)+" years old");
    System.out.println("shape used: "+shapeChoice);
            String mouse = infoJTextArea.getText();
            String tick = timerJTextField.getText();
            timeResultsJTextField.setText(tick);
            try
                // create a file called welch.txt
                final FileWriter outputFile = new FileWriter("Backup_of_"+name+"s_results.txt", true);
                final BufferedWriter outputBuffer = new BufferedWriter(outputFile);
                // converts data to a formatted string
                final PrintWriter printstream = new PrintWriter(outputBuffer);
                printstream.println("THIS IS A BACKUP");
                printstream.println("The person's name is: "+name);
                printstream.println("There age is: "+age);
                printstream.println("Time taken: "+tick+" seconds");
                printstream.println("The Shape and size was: "+shapeChoice);
                printstream.println("It's colour was: "+colourChoice);
                printstream.println("The mouse moved as follows: "+mouse);
                //states what needs to be printed to the new file
                printstream.close(); // closes teh printstream
            catch(IOException eio)
                //catchs the IO exception
            if(temp<5.00)
                ratingJTextField.setText("Thierry Henry");     
            else if(timeLimit<=10)
                ratingJTextField.setText("Average");     
            else if(timeLimit<=15)
                ratingJTextField.setText("You gotta be fat or something");     
            else if(timeLimit<=20)
                ratingJTextField.setText("See a doctor");
            else if(timeLimit>20)
                ratingJTextField.setText("DO YOU KNOW WHAT YOU DOING!?");
            String rate=ratingJTextField.getText();
            try
                   Statement st = dbcon.createStatement();
                   String cmd = "INSERT INTO users (Name, Age, Time_Taken, Rating, Mouse_Movement,Shape_and_Size, Shape_Colour) VALUES ('" + name + "' , " + age + " , '" + tick + "' , '" + rate+"','"+ mouse+"','"+ shapeChoice+"','"+ colourChoice+"');";
                //creates a SQL statement and executes it
                st.executeUpdate(cmd);
                   st.close();//close the statement
              } catch (Exception eDA)
                   eDA.printStackTrace();
        private void showData()
            // pretend this takes awhile -> 3 seconds (count)
            new Thread(new Runnable()
                public void run()
                    String results = "";
                    int count = 0;
                    boolean journeyOn = true;
                    while(journeyOn && count < 3)
                        try
                            Thread.sleep(1000);
                        catch(InterruptedException ie)
                            System.err.println("show interrupt: " + ie.getMessage());
                            journeyOn = false;
                        results += count++ + ", ";
                    infoJTextArea.setText("Here are your results:\n"+results);
                    startJPanel.setVisible(false);
                    showJPanel.setVisible(true);
            }).start();
    class ShapeMovingPanel extends JPanel implements ActionListener
        RT host;
        Timer timer;
        Shape shape, xformed;
        int x, y, dx, dy;
        public ShapeMovingPanel(RT rt)
            timer = new Timer(-20, this);     
            host = rt;
        /*    if (rt.flagspeed==1)
            timer = new Timer(-20, this);
            else if (rt.flagspeed==2)
                timer = new Timer(20, this);
            else if (rt.flagspeed==3)
            timer = new Timer(100, this);
            //change speed here******************************
            x = 0;//0
            y = 0;//0
            dx =2;//2
            dy = 3;//3
            //setBackground(Color.pink);
            addMouseListener(new ShapeTender());
        public void actionPerformed(ActionEvent e)
            int w = getWidth();
            int h = getHeight();
            if(w <= 0 || h <= 0)
                return;
            checkBoundries(w,h);
            x += dx;
            y += dy;
            repaint();
        private void checkBoundries(int w, int h)
            Rectangle r = xformed.getBounds();
            Insets insets = getInsets();
            if(r.x + dx < insets.left || r.x + r.width + dx > w - insets.right)
                dx *= -1;
            if(r.y + dy < insets.top || r.y + r.height + dy > h - insets.bottom)
                dy *= -1;
        protected void paintComponent(Graphics g)
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            AffineTransform at = AffineTransform.getTranslateInstance(x, y);
            if (RT.flag==1)
            {g2.setPaint(Color.red);// changed colour here***************************
            else if (RT.flag==2)
            {g2.setPaint(Color.blue);// changed colour here***************************
            else if (RT.flag==3)
            {g2.setPaint(Color.green);// changed colour here***************************
            else if (RT.flag==4)
            {g2.setPaint(Color.yellow);// changed colour here***************************
            else if (RT.flag==5)
            {g2.setPaint(Color.orange);// changed colour here***************************
            else if (RT.flag==6)
            {g2.setPaint(Color.black);// changed colour here***************************
            xfo                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     

    I'm (being lazy and) using the older RT app posted on your last thread. I removed the
    TimeNow timer from the RT class and used System.currentTimeMillis (as you requested) to
    determine the elapsed time during the animation (see "startTest", "stop" and
    "movingObject" methods). Also changed the DecimalFormat to NumberFormat and set the
    "maximumFractionDigits" to "2" so it will truncate the fraction to two digits (more simple
    than before). Made arrangements for the ShapeMovingPanel class to update the
    "timerJTextField" during the animation (RT.updateTime method).
    The MouseMotionListener is causing the animation to appear jerky and uneven. The
    "mouseMoved" method is very busy while the mouse is moving. You might consider recording
    the "mousePressed" events instead of the "mouseMoved" events, ie, the events where the user
    is attempting to click inside the moving shape. It would allow the app to be more
    responsive and might eliminate the uneven motion of the animating shape.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.io.*;
    import java.text.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.swing.event.*;
    import javax.swing.Timer;
    public class RT extends JFrame implements MouseMotionListener
        //declares a number of swing componets to be used for the JFrame
        private JTextArea infoJTextArea;
        private JPanel showJPanel, startJPanel, helpJPanel, resultsJPanel;
        private JLabel de4JLabel, de3JLabel, mainTitleJLabel, nameJLabel, ageJLabel,
                       deJLabel, de1JLabel, de2JLabel, timeJLabel,nameResultJLabel,
                       ageResultJLabel, timeResultsJLabel, ratingJLabel;
        private JTextField nameJTextField, ageJTextField,nameResultJTextField,
                       ageResultsJTextField, timeResultsJTextField, ratingJTextField;
        private JButton exitJButton, showJButton, loginJButton, startTestJButton,
                        tempObjectJButton;
        private JScrollPane scroll;;
        // creates and sets up a number of varibles to be used by the class
        private long startTime;
        private long endTime;
        public int timeLimit = 0;
        public int age;
        public String name;
        private JTextField timerJTextField;
        ShapeMovingPanel testJPanel;
        NumberFormat timeDec;
        Random seed;
        Shape shape;
        Shape[] shapes = {
            new Rectangle2D.Double(50, 30, 75, 25),
            new Ellipse2D.Double(175, 125, 50, 50),
            new Ellipse2D.Double(90, 100, 75, 35)
        public RT()
            timeDec = NumberFormat.getInstance();
            timeDec.setMaximumFractionDigits(2);
            seed = new Random();
            shape = shapes[0];
            createUserInterface();
        private void createUserInterface()
            Container contentPane = getContentPane();
            contentPane.setLayout( null );
            // set up infoJTextField
            infoJTextArea = new JTextArea();
            infoJTextArea.setBounds( 20, 420, 550, 170  );
            infoJTextArea.setEditable( false);
            infoJTextArea.setText("\n    Welcome to the reaction testing program, this " +
                            "program is designed to test your reactions in a  \n"+
                            "    number of different situations.\n"+"\n    Please " +
                            "enter your name and age, or select show previous results.");
            contentPane.add( infoJTextArea );
            scroll = new JScrollPane(infoJTextArea);
            scroll.setBounds(  20, 420, 550, 170 );
            contentPane.add( scroll );
              startJPanel = new JPanel();
            startJPanel.setBounds( 16,16, 560, 375 );
            startJPanel.setBorder(
                    new TitledBorder( "WELCOME -PLEASE ENTER YOUR NAME AND AGE:" ) );
            startJPanel.setLayout( null );
            contentPane.add( startJPanel );
            //sets up a JPanel
            mainTitleJLabel = new JLabel();
            mainTitleJLabel.setIcon( new ImageIcon( "title.png" ) );
            mainTitleJLabel.setBounds( 30, 10, 520, 170 );
            mainTitleJLabel.setHorizontalAlignment( JLabel.CENTER );
            startJPanel.add( mainTitleJLabel );
            //creates a newJLabel
            nameJLabel= new JLabel();
            nameJLabel.setBounds( 52, 200, 70, 35 );
            nameJLabel.setText("Name:");
            startJPanel.add( nameJLabel);
            //creates a new JTextField
            nameJTextField = new JTextField();
            nameJTextField.setBounds( 130, 200, 300, 24 );
            startJPanel.add( nameJTextField );
            //creates a newJLabel
            ageJLabel = new JLabel();
            ageJLabel.setBounds( 52, 245, 100, 35 );
            ageJLabel.setText("Age:");
            startJPanel.add( ageJLabel );
            //creates a new JTextField
            ageJTextField = new JTextField();
            ageJTextField.setBounds( 130, 245, 300, 24 );
            startJPanel.add( ageJTextField );
            //creates a JButton
            loginJButton = new JButton();
            loginJButton.setBounds( 440, 200, 90, 24 );
            loginJButton.setText( "Login" );
            loginJButton.setBackground( Color.YELLOW );
            startJPanel.add( loginJButton );
            loginJButton.setEnabled(true);
            loginJButton.addActionListener(
                new ActionListener()    // adds an action listener,anonymous inner class
                    // event handler called when search is pressed
                    public void actionPerformed( ActionEvent event )
                        // not necessary to pass events to these methods...
                        Login();  // calls the Login method                       
            //creates a JButton
            showJButton = new JButton();
            showJButton.setBounds( 200, 320, 180, 24 );
            showJButton.setText( "Show previous results" );
            showJButton.setBackground( Color.YELLOW );
            startJPanel.add( showJButton );
            showJButton.setEnabled(true);
            showJButton.addActionListener(
                new ActionListener()    // adds an action listener,anonymous inner class
                    // event handler called when search is pressed
                    public void actionPerformed( ActionEvent event )
                        showData();   // calls the showData method                       
            //sets up a JPanel
            showJPanel = new JPanel();
            showJPanel.setBounds( 16,16, 560, 375 );
            showJPanel.setBorder(new TitledBorder( "PREVIOUS RESULTS:" ) );
            showJPanel.setLayout( null );
            contentPane.add( showJPanel );
            //sets up a JPanel
            helpJPanel = new JPanel();
            helpJPanel.setBounds( 16,16, 560, 375 );
            helpJPanel.setBorder(
            new TitledBorder( "HELP DETAILS:" ) );
            helpJPanel.setLayout( null );
            helpJPanel.setVisible(false);
            contentPane.add( helpJPanel );
            //creates a newJLabel
            deJLabel= new JLabel();
            deJLabel.setBounds( 23, 390, 530, 35 );
            deJLabel.setText("Details:");
            contentPane.add( deJLabel);
            //creates a newJLabel
            de1JLabel= new JLabel();
            de1JLabel.setBounds( 25, 100, 530, 35 );
            de1JLabel.setText("You are about to start the reaction test, when you " +
                              "press the start button it will begin.");
            helpJPanel.add( de1JLabel);
            //creates a newJLabel
            de1JLabel= new JLabel();
            de1JLabel.setBounds(160, 145, 530, 35 );
            de1JLabel.setText("Simply catch the moving item and click.");
            helpJPanel.add( de1JLabel);
            //creates a newJLabel
            de2JLabel= new JLabel();
            de2JLabel.setBounds( 20, 380, 70, 35 );
            de2JLabel.setText("Details:");
            helpJPanel.add( de2JLabel);
            //creates a JButton
            startTestJButton = new JButton();
            startTestJButton.setBounds( 185, 205, 180, 60 );
            startTestJButton.setText( "START" );
            startTestJButton.setBackground( Color.YELLOW );
            helpJPanel.add( startTestJButton );
            startTestJButton.setEnabled(true);
            startTestJButton.addActionListener(
                new ActionListener() // adds an action listener,anonymous inner class
                    // event handler called when search is pressed
                    public void actionPerformed( ActionEvent event )
                        startTest();
            //sets up an animation panel
            testJPanel = new ShapeMovingPanel(this);
            testJPanel.setBounds( 16,16, 560, 375 );
            testJPanel.setBorder(new TitledBorder("Click the moving object:"));
            testJPanel.setLayout( null );
            testJPanel.setVisible(false);
            contentPane.add( testJPanel );
    // this is causing the animation to appear uneven
    // you can try the app with and without this to see
    //        testJPanel.addMouseMotionListener(this);
            //creates a newJLabel
            timeJLabel = new JLabel();
            timeJLabel.setBounds( 440, 330, 100, 35 );
            timeJLabel.setText("Time:");
            testJPanel.add( timeJLabel );
            //creates a new JTextField
            timerJTextField = new JTextField();
            timerJTextField.setBounds( 480, 335, 60, 24 );
            timerJTextField.setText(String.valueOf(timeLimit));
            timerJTextField.setHorizontalAlignment(JTextField.CENTER );
            timerJTextField.setEditable(false);
            timerJTextField.setBackground( Color.YELLOW );
            testJPanel.add( timerJTextField );
            resultsJPanel = new JPanel();
            resultsJPanel.setBounds( 16,16, 560, 375 );
            resultsJPanel.setBorder(new TitledBorder("HERE ARE YOUR RESULTS:"));
            resultsJPanel.setLayout( null );
            resultsJPanel.setVisible(false);
            contentPane.add( resultsJPanel );
            de3JLabel= new JLabel();
            de3JLabel.setBounds(20, 200, 530, 35 );
            de3JLabel.setText("Below is also the movements you made with your mouse, " +
                              "you may exit the program now.");
            resultsJPanel.add( de3JLabel);
            de4JLabel= new JLabel();
            de4JLabel.setBounds(135, 245, 530, 35 );
            de4JLabel.setText("Thank you for trying the Reaction Testing program");
            resultsJPanel.add( de4JLabel);
            //creates a newJLabel
            nameResultJLabel= new JLabel();
            nameResultJLabel.setBounds( 62, 55, 50, 35 );
            nameResultJLabel.setText("Name:");
            resultsJPanel.add( nameResultJLabel);
            //creates a new JTextField
            nameResultJTextField = new JTextField();
            nameResultJTextField.setBounds( 140, 55, 300, 24 );
            resultsJPanel.add( nameResultJTextField );
            nameResultJTextField.setEditable(false);
            //creates a newJLabel
            ageResultJLabel = new JLabel();
            ageResultJLabel.setBounds( 62, 90, 100, 35 );
            ageResultJLabel.setText("Age:");
            resultsJPanel.add( ageResultJLabel );
            //creates a new JTextField
            ageResultsJTextField = new JTextField();
            ageResultsJTextField.setBounds( 140, 90, 300, 24 );
            resultsJPanel.add( ageResultsJTextField );
            ageResultsJTextField.setEditable(false);
            //creates a newJLabel
            timeResultsJLabel = new JLabel();
            timeResultsJLabel.setBounds( 62, 125, 100, 35 );
            timeResultsJLabel.setText("Time taken:");
            resultsJPanel.add( timeResultsJLabel );
            //creates a new JTextField
            timeResultsJTextField = new JTextField();
            timeResultsJTextField.setBounds( 140, 125, 300, 24 );
            resultsJPanel.add( timeResultsJTextField );
            timeResultsJTextField.setEditable(false);
            //creates a newJLabel
            ratingJLabel = new JLabel();
            ratingJLabel.setBounds( 62, 160, 100, 35 );
            ratingJLabel.setText("Your Rating:");
            resultsJPanel.add( ratingJLabel );
            ratingJTextField = new JTextField();
            ratingJTextField.setBounds( 140, 160, 300, 24 );
            resultsJPanel.add( ratingJTextField );
            ratingJTextField.setEditable(false);
            //creates a JButton
            exitJButton = new JButton();
            exitJButton.setBounds( 235, 310, 90, 24 );
            exitJButton.setText( "Exit" );
            exitJButton.setBackground( Color.WHITE );
            resultsJPanel.add( exitJButton );
            exitJButton.setEnabled(true);
            exitJButton.addActionListener(
                new ActionListener() // adds an action listener,anonymous inner class
                    // event handler called when exitJButton is pressed
                    public void actionPerformed( ActionEvent event )
                        System.exit(0); //closes the programme
            }); // end anonymous inner class
            addWindowListener(new WindowAdapter()
                public void windowClosing(WindowEvent e)
                    System.exit(0);
            // set properties of application's window
            setTitle( "Reaction Tester - CMT3991" ); // set JFrame's title bar string
            //setSize( 1280,995 );    // set width and height of JFrame
            setSize( 608, 650 );         // set width and height of JFrame
            setVisible( true );       // display JFrame on screen
        //** set up of method main */
        public static void main( String[] args )
            RT application = new RT();
            application.setDefaultCloseOperation( EXIT_ON_CLOSE );
        } // end method main
        private void Login()
            try
                name = nameJTextField.getText();
                age = Integer.parseInt(ageJTextField.getText());
                startJPanel.setVisible(false);
                showJPanel.setVisible(false);
                helpJPanel.setVisible(true);
                infoJTextArea.setText("\n    Welcome "+name+" you will soon know how " +
                                      "fast your reactions are");
            catch (NumberFormatException exception)
                JOptionPane.showMessageDialog(this,
                        "There is either a blank field or a number hasn't been entered",
                        "Input Type error", JOptionPane.ERROR_MESSAGE);
                //shows this is something has been entered wrong
        private void startTest()
            helpJPanel.setVisible(false);
            shape = shapes[seed.nextInt(shapes.length)];
            testJPanel.setShape(shape);
            testJPanel.setVisible(true);
            testJPanel.start();
            startTime = System.currentTimeMillis();
            infoJTextArea.setText("");
         * called by animation panel after shape is clicked
        public void stop()
            endTime = System.currentTimeMillis();
            movingObject();
         * called by timer actionPerformed in ShapeMovingPanel
        public void updateTime()
            long timeNow = System.currentTimeMillis();
            double elapsed = (timeNow - startTime)/1000.0;
            timerJTextField.setText(timeDec.format(elapsed));
         * this will compete with your animation
         * ie, it will slow it down or make it appear jerky
        public void mouseMoved(MouseEvent e)
            saySomething("\n    Mouse moved", e);
        public void mouseDragged(MouseEvent e)
            saySomething("\n    Mouse dragged", e);
        void saySomething(String eventDescription, MouseEvent e)
            infoJTextArea.append(eventDescription
                         + " (" + e.getX() + "," + e.getY() + ")");
            infoJTextArea.setCaretPosition(infoJTextArea.getDocument().getLength());
        private void movingObject()
            testJPanel.setVisible(false);
            resultsJPanel.setVisible(true);
            nameResultJTextField.setText(name);
            ageResultsJTextField.setText(String.valueOf(age)+" years old");
            double elapsedTime = (endTime - startTime)/1000.0;
            timeLimit = (int)elapsedTime;
            timeResultsJTextField.setText(timeDec.format(elapsedTime)+" seconds");
            String mouse = infoJTextArea.getText();
            String tick = timeDec.format(elapsedTime);
            try
                // create a file called welch.txt
                final FileWriter outputFile = new FileWriter(name+".txt", true);
                final BufferedWriter outputBuffer = new BufferedWriter(outputFile);
                // converts data to a formatted string
                final PrintWriter printstream = new PrintWriter(outputBuffer);
                printstream.println("The person's name is: "+name);
                printstream.println("There age is: "+age);
                printstream.println("Time taken: "+tick+" seconds");
                printstream.println("The mouse moved as follows: "+mouse);
                //states what needs to be printed to the new file
                printstream.close(); // closes teh printstream
            catch(IOException eio)
                //catchs the IO exception
            if(timeLimit<5)
                ratingJTextField.setText("Thierry Henry");     
            if(timeLimit>5)
                ratingJTextField.setText("Average");     
            if(timeLimit>10)
                ratingJTextField.setText("You gotta be fat or something");     
            if(timeLimit>20)
                ratingJTextField.setText("See a doctor");
            String rate=ratingJTextField.getText();
        private void showData()
    //        String results = "";
    //        infoJTextArea.setText("Here are your results:\n"+results);
            startJPanel.setVisible(false);
            showJPanel.setVisible(true);
    class ShapeMovingPanel extends JPanel implements ActionListener
        RT host;
        Timer timer;
        Shape shape, xformed;
        int x, y, dx, dy;
        public ShapeMovingPanel(RT rt)
            host = rt;
            timer = new Timer(25, this);
            x = 0;
            y = 0;
            dx = 2;
            dy = 3;
            setBackground(Color.pink);
            addMouseListener(new ShapeTender());
        public void actionPerformed(ActionEvent e)
            int w = getWidth();
            int h = getHeight();
            if(w <= 0 || h <= 0)
                return;
            checkBoundries(w,h);
            x += dx;
            y += dy;
            repaint();
            // update RT.timerJTextField
            host.updateTime();
        private void checkBoundries(int w, int h)
            Rectangle r = xformed.getBounds();
            Insets insets = getInsets();
            if(r.x + dx < insets.left || r.x + r.width + dx > w - insets.right)
                dx *= -1;
            if(r.y + dy < insets.top || r.y + r.height + dy > h - insets.bottom)
                dy *= -1;
        protected void paintComponent(Graphics g)
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            AffineTransform at = AffineTransform.getTranslateInstance(x, y);
            g2.setPaint(Color.red);
            xformed = at.createTransformedShape(shape);
            g2.draw(xformed);
        public void start()
            if(!timer.isRunning())
                timer.start();
        public void setShape(Shape s)
            shape = s;
            Rectangle r = shape.getBounds();
            x = r.x;
            y = r.y;
            repaint();
        private class ShapeTender extends MouseAdapter
            public void mousePressed(MouseEvent e)
                if(xformed.contains(e.getPoint()))
                    timer.stop();
                    host.stop();
    }

  • Flash app that allows users to create mini animations

    Hi,
    I am fairly new to flash, and was wondering if the community could point me in the right direction for my current project.
    I am looking to build an app that allows end users to draw and save mini animations (simple predetermined shapes that move in 2D).  So far I have a written a app that allows the user to draw a single frame using simple shapes and lines, but I am having some small troubles at this stage, and have not attempted to allow the user to animate or save the drawing.
    If anyone knows of a tutorial or some other resource to put me on the right path I would be very grateful.  I can also share what I have if anyone would be willing to give me some pointers (I am going to assume that as a newbie, my code could use a lot of improvement).
    Regards,
    Robbie Vos

    Hi Andei1,
    Thanks for the input.  I figured that the save functionality would be a little difficult. 
    However, if I can get the basic app going (allowing users to create mini animations) I think I should be able to get save going with some (ok, alot) of effort.
    Regards,
    Robbie Vos

  • Photoshop cs6 animation/timeline help

    I am trying to learn how to do a small animation. I have Timeline window open at bottom of screen but do not understand how to get images into the space. Everything is grayed out. I have read the Adobe tutorial but nothing really says how to place keyframes into the timeline space. I watched a YouTube video but it started with there already being an image there and then they showed how to copy and change it so an animation could be achieved.
    Could someone tell me the first steps, from the beginning, to get things set up right and have something to adjust and set times to ,etc.
    I have spent awhile now playing with it and decided to ask for help.
    Thank you!

    Each object must be on its own layer.
    For this example lets create a shape pick any of the shapes in the tool bar, just make sure you are using shapes which is found in the top tool bar.
    Click the create video time line in the animation panel, this should create a timeline for each layer.
    Before each layer in the timeline panel is an arrow, click on it to twirl it down.
    Lets use position for an example. Location the word Vector Mask Position for that object and click on the stopwatch
    Move the timeline head along the timeline to a new time (any new time will be fine for this example, just make sure its more than 15 frames just so its slow enough to see moving. {This will also depend on the distants traveled in the next step})
    With the move tool selected (lowercase v - keyboard shortcut)  Drag the shape elsewhere on the document. This will create the end keyframe.
    Just below the frames in the animation panel is a slider at the beginning and the end of the entire animation. Dragging the little gray box at either end adjusts the start and end work area. Drag the end work area box towards to the end keyframe. This will stop the animation when the shape stops moving. You will see it snap at that keyframe.
    Hit the space bar to play your animation. If done correctly you will see your shape move across the document.
    Your animation panel should look similar to the attachment. Don't worry about getting the same end timeframe as mine, as it is only an example.

  • Smart Shapes flashing during effects

    I have a series of cascading animations of Smart shapes.  Let's call them one through ten. All have alpha 0% to 100% and fly-in effects applied. During the animation of shape one, shape two will appear for a brief flash and then disappear. During the animation of shape two, shape three will appear for a brief flash and then disappear, and so on.  This happens both when I use 'Preview in Browser' and when I publish. I've tried using the 'Fade In Only' transition instead of the alpha effect, with no change.
    Thoughts?

    Does it work fine if you only use the Alfa ToFrom Effect with 0 to 100% value?
       I still get the flashing problem when I take out the Fly-in effect.
    Can you also verify the timing properties for smart shape two, does it extend to a single or multiple slide?
      All the animations begin and end within a single slide.
    Does it occur when you preview in F4.
      Yes.
    It looks like the behavior goes away if I turn off 'Use as Button' so I think I can do a workaround where I do the animation slide with just the dummy Smart Shapes then immediately progress to a slide with the Active buttons.  This does seem to be a glitch, however.

  • Shape tween variables?

    Hello :-]
    I'm using shape tweens to morph one shape into another:
    http://megaswf.com/serve/81955/
    While I enjoy some of the choices Flash makes for animating the transformations,
    I am wondering if you can control it in any way, or even have flash generate a different transformation.
    I would also love to know of any suggestions you might have for making animated videos with shapes more dynamic.
    That demo shows about what I know, which amounts to:
    applying shape tweens for morphing;
    and motion tweens for 2d spinning,
    and basic movement from point A to point B.
    Bless you!

    You can use shape hints for a measure of control on shape tweens.
    As for animating there are a lot of tricks. One of the simplest is to use easing. Select one of your tweens and look in the properties panel. There you will see and easing number. Try some different values (negative and positive).
    Other things that aren't just a technical fix are anticipation and overshooting. Matter of fact most of the things that make compelling animation have nothing to do with Flash or specific technologies. If you are interested in doing a lot of animating I would recommend any book by Chris Georgenes.

  • Animation will not work on when previewing in Folio builder

    I have created a simple animation in Edge Animate, but when I place it in InDesign and preview it only displays the poster image. When clicked it fades to nothing.
    This is the process I followed thus far:
    Created shapes  in illustrator and saved it as a SVG.
    Imported SVG in Edge animate, made a simple animation of the shapes getting larger and made a poster snap
    Gone to publish settings
    Ticked Animate Deployment Package and saved in Target direectory .\publish\animate_package
    In indesign placed the edge .oam file in
    gone to the folio builder and gone to preview > preview on desktop

    When preparing a demo we had a similar experience. We animated an SVG file from Illustrator in Edge Animate.
    The preview looked fine in a Browser.
    From InDesign, the placed OAM package would not play in the Desktop Content Viewer, did not  play on a connected iPad and did not play when it was exported with the Folio Builder in the iPad Content Viewer.
    I renamed the .oam file to .zip and unzipped it.
    In the resulting folder you will find an Assets folder with an .html file.
    I created a Web overlay in InDesign and selected the .html file from the Assets folder (and set the Autoplay checkbox)
    The preview in the Desktop Content Viewer showed nothing, but the animation played on a directly connected iPad and when exported from the Folio Builder in the iPad Content Viewer.
    I tried also to use the html export version from Edge Animate, but that does not work.
    The animation needs 2 javascripts that are included in a folder "edge_includes" in the OAM file (and in the "Assets" folder), but that folder is missing and they are only referenced from the web in the exported html from Edge Animate and that does not seem to load in the folio.
    So it can work with a little effort: unzip the .oam file and use the html from the Assets folder.
    regards,
    Ton

  • Animated mask on an animated clip : huge problem...

    Hello,
    Am I completely hallucinating or what ? That's several years I'm working with Flash, and today, i want to do the simplest animation ever, and it just doesn't work....
    I want to mask an animated clip with an animated mask (a shape animation), but every time the mask arrives at a keyframe, the clip restarts to the frame 1 !!
    I added a piece of code to see at which keyframe it is blocked, and at every mask keyframe, the code says 'TypeError: Error #1009: null property...'.
    What is this $@#?!@$ ???
    Here is an example : http://moonpalace.fr/AdobeForum/testClipMasked.fla
    Thanks for your replies !

    The 1009 error indicates that one of the objects being targeted by your code is out of scope.  This could mean that the object....
    - is declared but not instantiated
    - doesn't have an instance name (or the instance name is mispelled)
    - does not exist in the frame where that code is trying to talk to it
    - is animated into place but is not assigned instance names in every keyframe for it
    - is one of two or more consecutive keyframes of the same objects with no name assigned in the preceding frame(s).
    If you go into your Publish Settings Flash section and select the option to Permit debugging, your error message should have a line number following the frame number which will help you isolate which object is involved.

  • Shape tween with bone tool on bitmap

    I want to have shape tween animation with bone tool on bitmap image. Because shape tween animation supports only Shape data type, I converted the bitmap to that type (Bitmap -> Trace Bitmap). Problem is that trace command splits bitmap image into multiple shape fragments, so I can't use shape tween anymore.I tried to combine and group shape fragments, but it doesn't fix it. Solutions?

    You can create another instance of the bitmap symbol (drag it from library to your stage) to do tweening.

  • Keyframes and type animation

    hey there,
    one quick question, i can't figure out why i can't animate the tracking parameter in the type section on final cut pro x.
    i just want to put a strating point keyframe and an ending one, which i do, but it refuses to animate at all.
    when i press playback i can see the paramter values altering but i can't see a movement on the tracking of the letters.
    anybody that does have a clue on this issue?
    why everything changed that much in fcp x? fcp 7 for ever!
    thanks anyway!

    There are Text Animation behaviors in Motion. Mixing behaviors with keyframing in FCPX is disastrous (and most of the time, can't be done -- like -- animating the Mask shape -- behaviors are in use linking the onscreen controls with the shape points.)
    Try this out. It is VERY basic:
    http://sight-creations.com/fxexchange/TrackingTitle.zip
    It is a basic centered title - at "lower third position" (or close.) Use the text panel of the inspector to customize the text; the onscreen control to drag it to the position you want.
    There's a Track In and a Track Out -- you can apply whichever you want by using the Build In and Build Out options. For the Tracking animation, there is a Fade In/Out behavior to smooth it out (you really can't get tracking far enough to "disappear" all the characters reasonably [I gave up at 5000%].)
    HTH

  • Programmatic access to shapes

    Hi folks,
    I'm wondering if there's a way to create/manipulate the contents of shape layers through either the javascript scripting api or the sdk.
    I can't find any information about this in each respective documentation.
    The underlying problem I have is to import custom vector graphics programmatically (they come as neither ai or svg), but do consist of bezier primitives.
    Thank you in advance, Jens

    Hi Jens,
    if you can't use the importer, you can still do something if you know the curves data.
    I can't tell you how it would work in the sdk.
    In AE ExtendScript framework shapes are instances of Shape(), which are objects with 4 properties (for version < CS6) and slightly more since CS6 (for the feather, but for your purpose you can ignore those properties and leave them undefined):
    var shape = new Shape();
    shape.vertices = myVerticesData;
    shape.inTangents = myInTangentsData;
    shape.outTangents = myOutTangentsData;
    shape.closed = true/false;
    where myVerticesData, myInTangentsData, myOutTangentsData are to be defined by you from your shape data.
    You might need to do some sort of conversion if your data don't come out in the same form as AE uses.
    They should be arrays of 2D points/vectors ( [[x0,y0], [x1,y1], [x2,y2] ...]) of the same length.
    myVerticesData[k] is the kth vertex of the shape (a point), myInTangentsData[k] and myOutTangentsData[k] the incoming and outcoming tangents at that vertex (vectors).
    Apparently shape objects are being watched so you can't modify shape vertices individually like this: shape.vertices[k] = [x, y]; It won't work (ignored).
    You must set the shape array attributes in one shot as above.
    If the inTangents or outTangents arrays are not specified they will default to arrays of [0,0].
    Once you have transcripted your shape data into a AE Shape() object, you can use it to set the value of a shape layer path or a mask path.
    - For a shape layer it would be like this:
    var comp = [the comp you want to work with];
    var layer = comp.layers.addShape();
    var group = layer.content.addProperty("ADBE Vector Group");                              // adds a Group (Empty) to the shape content
    var shapeGroup = group.content.addProperty("ADBE Vector Shape - Group");       // adds a (custom) Path to that group
    shapeGroup.name = "Imported Shape";
    shapeGroup.path.setValue(shape);
    If you don't want a group, omit that line and do directly var shapeGroup = layer.content.addProperty("ADBE Vector Shape - Group");
    Note: for shape layers you'll probably have to work out the fact that they don't have exactly the same behaviour as bounded layers with respect to coordinates,
    so you'll have to translate all vertices.
    - For a mask:
    var comp = [the comp you want to work with];
    var layer = comp.layers.addSolid([1,0,0], "Imported Shape", comp.width, comp.height, comp.pixelAspect, comp.duration);
    var group = layer.property("ADBE Mask Parade"); // equivalently: var group = layer.mask;
    var shapeGroup = group.addProperty("ADBE Mask Atom");
    shapeGroup.name = "Imported Shape";
    shapeGroup.maskPath.setValue(shape);
    Xavier.

  • I need Help for Shape Hints.

    Dear friend,
    I want some help on Shape Hints. When we use a box for
    creating a animated
    cube using shape hints. The prespective view don't shows the
    center line
    between two sides while rotating. How to create or get that
    line?
    Thanks & Regards
    Arvind Sharma

    See my reply to your previous thread : https://discussions.apple.com/message/22851849#22851849

  • Moving 3D Shape

    Hi,
    I need some help in animating a 3D Shape rotating/translating using values entered in JTextField format,
    For example, I want the shape to rotate 60 degrees, I just key in 60 and the shape will be shown rotating 60 degrees.
    Thanks
    th

    Please study my code below. Ignore the parts you don't take interest. Class GeneralContourPanel is no importance to you either. This class cannot run as a standalone app. Just study how we rotate a 3D object. If necessary, you can get in touch with me by this email address: [email protected].
    package petrochina.riped.plot.post3d;
    import com.sun.j3d.utils.behaviors.mouse.MouseRotate;
    import com.sun.j3d.utils.behaviors.mouse.MouseTranslate;
    import com.sun.j3d.utils.behaviors.mouse.MouseZoom;
    import com.sun.j3d.utils.universe.SimpleUniverse;
    import java.awt.BorderLayout;
    import java.awt.Font;
    import java.awt.GraphicsConfiguration;
    import javax.media.j3d.Background;
    import javax.media.j3d.BoundingSphere;
    import javax.media.j3d.BranchGroup;
    import javax.media.j3d.Canvas3D;
    import javax.media.j3d.GeometryArray;
    import javax.media.j3d.IndexedLineArray;
    import javax.media.j3d.Shape3D;
    import javax.media.j3d.Transform3D;
    import javax.media.j3d.TransformGroup;
    import javax.vecmath.Color3f;
    import javax.vecmath.Point3d;
    import javax.vecmath.Point3f;
    import javax.vecmath.Vector3d;
    import petrochina.riped.util.Text2DForJ3D;
    * Acts as the base class for any Java3D objects.
    * <p>IMPORTANT NOTICE: The x-y-z axises used in this class is the same with
    * that in Java3D, only the default view is with a rotation.
    * @author Xiao Xiaochun & uanglin Du ([email protected] or [email protected])
    * @version 1.0, 2003/09/29 20:05
    public abstract class J3DPanel extends GeneralContourPanel {   
    /** The root BranchGroup */
    public BranchGroup rootBG = null;
    /** The root of the branch graph */
    public BranchGroup branchGroup = null;
    /** The <code>TransformGroup</code> used to hold . */
    public TransformGroup transformGroup = null;
    /** The <code>Transform3D</code> instance used to resume the visual view. */
    public Transform3D tempRotateTransform = null;
    /** The <code>Transform3D</code> instance used to scale the 3D objects. */
    public Transform3D scaleTransform = null;
    /** The <code>Transform3D</code> instance used in zoom functionality. */
    public Transform3D zoomTransform = null;
    * The <code>Transform3D</code> instance used to rotate the view in x y and z axis
    * clockwiselyorcounter.
    public Transform3D transform3DObject = null;
    /** The MouseTranslate to translate the 3D objects */
    public MouseTranslate myMouseTranslate = null;
    /** The incremental roation counterclockwise angle in radian. */
    private static double rotationIncrement =Math.PI/18.0;
    /** The zoom in count in double. */
    private static double zoomInFactor = 1.02;
    /** The zoom out count in double. */
    private static double zoomOutFactor = 0.98;
    /** The double-typed translate factor. */
    private static double translateFactor = 0.005;
    /** The only Canvas3D instance containing the Java3D objects. */
    private Canvas3D canvas3D = null;
    /** The zox slices indices (row), starting from 1. */
    public int[] zoxSliceIndices = null;
    /** The yoz slices indices (column), starting from 1. */
    public int[] yozSliceIndices = null;
    /** Determines if the 3D view has mesh drawn together, and the default value is true. */
    public boolean withMesh = true;
    /** Determines if the 3D view has well drawn together, and the default value is true. */
    public boolean withWell = true;
    /** Determines if the 3D view has well names drawn together, and the default value is true. */
    public boolean withWellName = true;
    /** Determines if the 3D view has the surrounding frame drawn together, and the default value is false. */
    public boolean withFrame = false;
    /** Determines if the 3D view has a 3D coordinate system drawn together, and the default value is false. */
    public boolean with3DCoord = false;
    * Constructs with a <code>title</code> and <code>workspaceDir</code>.
    * @param contourInfo the information of the contour
    * @param workspaceDir the workspace directory
    public J3DPanel(String contourInfo, String workspaceDir) {          
         super(contourInfo, workspaceDir);
    this.rootBG = new BranchGroup();
    this.rootBG.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
    this.rootBG.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
    this.rootBG.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);
    //Creates & adds the Java3D canvas3D to this internal frame's content pane.
    GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
    this.canvas3D = new Canvas3D(config);
    // SimpleUniverse is a Convenience Utility class
    SimpleUniverse simpleU = new SimpleUniverse(canvas3D);
         // This will move the ViewPlatform back a bit so the
         // objects in the scene can be viewed.
    simpleU.getViewingPlatform().setNominalViewingTransform();
    simpleU.addBranchGraph(this.rootBG);
    * Performs the scene graph initialization. This method is called by subclasses
    * to implement the specific 3D graph plotting.
    public void initialize() {     
         branchGroup = new BranchGroup();
    branchGroup.setCapability(BranchGroup.ALLOW_DETACH);
         transformGroup = new TransformGroup();
         tempRotateTransform =new Transform3D();
         scaleTransform = new Transform3D();
         transform3DObject = new Transform3D();
    zoomTransform = new Transform3D();
         transformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
         transformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
         branchGroup.addChild(transformGroup);
         //Adds the 3D axis
    if(this.withFrame){
    transformGroup.addChild(create3DAxis());
    } else {
    SimpleAxis sa = new SimpleAxis(0.08f);
    TransformGroup tg = sa.create3DAxis(-0.7, 0.7, 0.0);
    transformGroup.addChild(tg);
    //This is the magic to integrate Java3D with Swing.
         this.setLayout(new BorderLayout());
         this.add(canvas3D, BorderLayout.CENTER);
    //The bounding sphere
    Point3d p3d = new Point3d(0.0, 0.0, 0.0);
    BoundingSphere bs = new BoundingSphere(p3d, 10000);     
         //Adds the mouse translate, rotate & zoom behaviors
         myMouseTranslate = new MouseTranslate();
         myMouseTranslate.setTransformGroup(transformGroup);
         myMouseTranslate.setFactor(translateFactor);
    myMouseTranslate.setSchedulingBounds(bs);
         branchGroup.addChild(myMouseTranslate);
    MouseRotate myMouseRotate = new MouseRotate();
    myMouseRotate.setTransformGroup(transformGroup);
    myMouseRotate.setSchedulingBounds(bs);
    branchGroup.addChild(myMouseRotate);
    MouseTranslate myMouseTranslate = new MouseTranslate();
    myMouseTranslate.setTransformGroup(transformGroup);
    myMouseTranslate.setSchedulingBounds(bs);
    branchGroup.addChild(myMouseTranslate);
    MouseZoom myMouseZoom = new MouseZoom();
    myMouseZoom.setTransformGroup(transformGroup);
    myMouseZoom.setSchedulingBounds(bs);
    branchGroup.addChild(myMouseZoom);
         //Set the window size
         this.setSize(300,300);
         //Set the window's location.
         this.setLocation( 0, 0);                
         this.setVisible(true);
         //default background(white) setting, DGL, 01/25/2002
         Background backg = new Background(1.0f, 1.0f, 1.0f);
    backg.setApplicationBounds(bs);
         branchGroup.addChild(backg);     
         //Uses an abstract method as the entry to add specific 3D objects
    add3DShapes();
         // Let Java 3D perform optimizations on this scene graph.
    branchGroup.compile();
    //simpleU.addBranchGraph(branchGroup);
    this.rootBG.addChild(branchGroup);
    * This abstract method works as the entry for subclasses to addthe Java3D shapes.
    * This is done by adding the 3D objects, usually <code>Shape3D</code> objects
    * to the <code>transformGroup</code> node. A sample is as following:<p>
    * <code>transformGroup.addChild(new ColorCube(0.4));<code>
    * <br>or<p>
    * <code>transformGroup.addChild(new Shape3D(<code>NodeComponent</code> object));<code>
    public abstract void add3DShapes();
    /** Rotates along the view axis about x counterclockwisely */
    public void rotateAlongXCCW() {
         tempRotateTransform.rotX(rotationIncrement);
         transformGroup.getTransform(transform3DObject);
         transform3DObject.mul(tempRotateTransform);
         transformGroup.setTransform(transform3DObject);
         zoomTransform = transform3DObject;
    /** Rotates along the view axis about y counterclockwisely */
    public void rotateAlongYCCW() { 
         tempRotateTransform.rotY(rotationIncrement);
         transformGroup.getTransform(transform3DObject);
         transform3DObject.mul(tempRotateTransform);
         transformGroup.setTransform(transform3DObject);
         zoomTransform = transform3DObject;
    /** Rotates along the view axis about z counterclockwisely */
    public void rotateAlongZCCW() { 
         tempRotateTransform.rotZ(rotationIncrement);
         transformGroup.getTransform(transform3DObject);
         transform3DObject.mul(tempRotateTransform);
         transformGroup.setTransform(transform3DObject);
         zoomTransform = transform3DObject;
    /** Rotates along the view axis about x clockwisely */
    public void rotateAlongXCW() { 
         tempRotateTransform.rotX(-rotationIncrement);
         transformGroup.getTransform(transform3DObject);
         transform3DObject.mul(tempRotateTransform);
         transformGroup.setTransform(transform3DObject);
         zoomTransform = transform3DObject;
    /** Rotates along the view axis about y clockwisely */
    public void rotateAlongYCW() { 
         tempRotateTransform.rotY(-rotationIncrement);
         transformGroup.getTransform(transform3DObject);
         transform3DObject.mul(tempRotateTransform);
         transformGroup.setTransform(transform3DObject);
         zoomTransform = transform3DObject;
    /** Rotates along the view axis about z clockwisely */
    public void rotateAlongZCW() { 
         tempRotateTransform.rotZ(-rotationIncrement);
         transformGroup.getTransform(transform3DObject);
         transform3DObject.mul(tempRotateTransform);
         transformGroup.setTransform(transform3DObject);
         zoomTransform = transform3DObject;
    * Rotates the Java3D objects to the conventional view in
    * reservoir enginering: x axis extends upwardly, y right, and z inwardly.
    public void setPlanform() {
         Transform3D planformTransform = new Transform3D();
         planformTransform.rotX(Math.PI);
         transformGroup.getTransform(transform3DObject);
         transform3DObject = planformTransform;
         transformGroup.setTransform(transform3DObject);
         zoomTransform = transform3DObject;     
    * Rotates the Java3D objects to the conventional view in
    * reservoir enginering: x axis extends downwardly, y right, and z outwardly.
    public void setFundusView() {
         Transform3D fundusTransform = new Transform3D();
         fundusTransform.rotX(2.0*Math.PI);
         transformGroup.getTransform(transform3DObject);
         transform3DObject = fundusTransform;
         transformGroup.setTransform(transform3DObject);
         zoomTransform = transform3DObject;     
    * Rotates the Java3D objects to the conventional view in
    * reservoir enginering: y axis extends inwardly, x left, and z downwardly.
    public void setLeftView() {
         Transform3D leftTransformX = new Transform3D();
         Transform3D leftTransformY = new Transform3D();
         leftTransformX.rotX(Math.PI/2.0);
         leftTransformY.rotY(Math.PI/2.0);
         leftTransformY.mul(leftTransformX);
         transformGroup.getTransform(transform3DObject);
         transform3DObject = leftTransformY;
         transformGroup.setTransform(transform3DObject);
         zoomTransform = transform3DObject;     
    * Rotates the Java3D objects to the conventional view in
    * reservoir enginering: x axis right, y outwardly, and z downwardly.
    public void setRightView() {
         Transform3D rightTransformX = new Transform3D();
         Transform3D rightTransformY = new Transform3D();     
         rightTransformX.rotX(Math.PI/2.0);
         rightTransformY.rotY(1.5*Math.PI);
         rightTransformY.mul(rightTransformX);
         transformGroup.getTransform(transform3DObject);
         transform3DObject = rightTransformY;
         transformGroup.setTransform(transform3DObject);
         zoomTransform = transform3DObject;     
    /** Sets the default view which lets the user overlook the most parts of the 3D graph. */
    public void setDefaultView(){
    this.setFrontView();
    this.rotateAlongXCCW(); //twice
    this.rotateAlongXCCW();
    this.rotateAlongZCW();
    * Rotates the Java3D objects to the conventional view in
    * reservoir enginering: x axis extends inwardly, y right, and z downwardly.
    public void setFrontView() {
         Transform3D frontTransform = new Transform3D();     
         frontTransform.rotX(Math.PI/2.0);
         transformGroup.getTransform(transform3DObject);
         transform3DObject = frontTransform;
         transformGroup.setTransform(transform3DObject);
         zoomTransform = transform3DObject;     
    * Rotates the Java3D objects to the conventional view in
    * reservoir enginering: x axis extends outwardly, y left, and z downwardly.
    public void setBackView() {
         Transform3D backTransformX = new Transform3D();     
         Transform3D backTransformY = new Transform3D();     
         backTransformX.rotX(Math.PI/2.0);
         backTransformY.rotY(Math.PI);
         backTransformY.mul(backTransformX);     
         transformGroup.getTransform(transform3DObject);
         transform3DObject = backTransformY;
         transformGroup.setTransform(transform3DObject);
         zoomTransform = transform3DObject;
    /** Sets the J3D object's zoom in . */
    public void setZoomIn() {
         tempRotateTransform.set(zoomInFactor);
         transformGroup.getTransform(scaleTransform);
         scaleTransform.mul(tempRotateTransform);
         transformGroup.setTransform(scaleTransform);
    /** Sets the J3D object's zoom out. */
    public void setZoomOut() {
         tempRotateTransform.set(zoomOutFactor);
         transformGroup.getTransform(scaleTransform);
         scaleTransform.mul(tempRotateTransform);
         transformGroup.setTransform(scaleTransform);
    /** Sets the J3D object's zoom. */
    public void setZoom() {
         transformGroup.setTransform(zoomTransform);
    /** Removes the main graph from branchGroup. */
    public void removeBranchGroup(){
    try {
    this.branchGroup.detach();
    } catch(Throwable ex) {
    super.exceptionHandler(ex);
    }

  • I wanna dots instead of displaying it as a whole line in Linechart

    Hi Folks,
    I had one small doubt in the output of this program. The program is related to LineChart..Actually, Im getting the output as Line in the chart, but my requirement is to display only dots instead of displaying as a line...
    I just want only displaying as dots at particular name, insteading of getting that whole line from beginning to end...
    First of all whether its posiible to get dots or not?? and if it is possible, how??
    Here is the code:
    package com.home.practise.streams;
    import java.awt.BasicStroke;
    import java.awt.Color;
    import java.awt.Polygon;
    import java.awt.Shape;
    import java.awt.geom.Rectangle2D;
    import org.jfree.chart.ChartFactory;
    import org.jfree.chart.ChartPanel;
    import org.jfree.chart.JFreeChart;
    import org.jfree.chart.axis.NumberAxis;
    import org.jfree.chart.plot.CategoryPlot;
    import org.jfree.chart.plot.DefaultDrawingSupplier;
    import org.jfree.chart.plot.DrawingSupplier;
    import org.jfree.chart.plot.PlotOrientation;
    import org.jfree.chart.renderer.category.LineAndShapeRenderer;
    import org.jfree.data.category.CategoryDataset;
    import org.jfree.data.category.DefaultCategoryDataset;
    import org.jfree.ui.ApplicationFrame;
    import org.jfree.ui.RefineryUtilities;
    public class LineChartDemo5 extends ApplicationFrame {
        public LineChartDemo5(final String title) {
            super(title);
            final CategoryDataset dataset = createDataset();
            final JFreeChart chart = createChart(dataset);
            final ChartPanel chartPanel = new ChartPanel(chart);
            chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
            setContentPane(chartPanel);
        private CategoryDataset createDataset() {
            // row keys...
            final String series1 = "First";
            final String series2 = "Second";
            final String series3 = "Third";
            // column keys...
            final String type1 = "Hari";
            final String type2 = "Chary";
            final String type3 = "Trinetra";
            final String type4 = "Naveen";
            final String type5 = "Type 5";
            final String type6 = "Type 6";
            final String type7 = "Type 7";
            final String type8 = "Type 8";
            // create the dataset...
            final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
            dataset.addValue(0, series1, type1);
            dataset.addValue(0, series1, type2);
            dataset.addValue(1, series1, type3);
            dataset.addValue(1, series1, type4);
            /*dataset.addValue(5.0, series1, type5);
            dataset.addValue(7.0, series1, type6);
            dataset.addValue(7.0, series1, type7);
            dataset.addValue(8.0, series1, type8);*/
            /*dataset.addValue(5.0, series2, type1);
            dataset.addValue(7.0, series2, type2);
            dataset.addValue(6.0, series2, type3);
            dataset.addValue(8.0, series2, type4);
            dataset.addValue(4.0, series2, type5);
            dataset.addValue(4.0, series2, type6);
            dataset.addValue(2.0, series2, type7);
            dataset.addValue(1.0, series2, type8);
            dataset.addValue(4.0, series3, type1);
            dataset.addValue(3.0, series3, type2);
            dataset.addValue(2.0, series3, type3);
            dataset.addValue(3.0, series3, type4);
            dataset.addValue(6.0, series3, type5);
            dataset.addValue(3.0, series3, type6);
            dataset.addValue(4.0, series3, type7);
            dataset.addValue(3.0, series3, type8);*/
            return dataset;
        private JFreeChart createChart(final CategoryDataset dataset) {
            final JFreeChart chart = ChartFactory.createLineChart(
                "visualization",      // chart title
                "Names",                   // domain axis label
                "Gender",                  // range axis label
                dataset,                  // data
                PlotOrientation.VERTICAL, // orientation
                true,                     // include legend
                true,                     // tooltips
                false                     // urls
    //        final StandardLegend legend = (StandardLegend) chart.getLegend();
      //      legend.setDisplaySeriesShapes(true);
            final Shape[] shapes = new Shape[3];
            int[] xpoints;
            int[] ypoints;
            // right-pointing triangle
            xpoints = new int[] {-3, 3, -3};
            ypoints = new int[] {-3, 0, 3};
            shapes[0] = new Polygon(xpoints, ypoints, 3);
            // vertical rectangle
            shapes[1] = new Rectangle2D.Double(-2, -3, 3, 6);
            // left-pointing triangle
            xpoints = new int[] {-3, 3, 3};
            ypoints = new int[] {0, -3, 3};
            shapes[2] = new Polygon(xpoints, ypoints, 3);
            final DrawingSupplier supplier = new DefaultDrawingSupplier(
                DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE,
                DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE,
                DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
                DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE,
                shapes
            final CategoryPlot plot = chart.getCategoryPlot();
            plot.setDrawingSupplier(supplier);
            chart.setBackgroundPaint(Color.yellow);
            // set the stroke for each series...
            plot.getRenderer().setSeriesStroke(
                0,
                new BasicStroke(
                    2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
                    1.0f, new float[] {10.0f, 6.0f}, 0.0f
            plot.getRenderer().setSeriesStroke(
                1,
                new BasicStroke(
                    2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
                    1.0f, new float[] {6.0f, 6.0f}, 0.0f
            plot.getRenderer().setSeriesStroke(
                2,
                new BasicStroke(
                    2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
                    1.0f, new float[] {2.0f, 6.0f}, 0.0f
            // customise the renderer...
            final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    //        renderer.setDrawShapes(true);
            renderer.setItemLabelsVisible(true);
         //   renderer.setSeriesLinesVisible(0, false);
       //     renderer.setBaseLinesVisible(false);
      //      renderer.setBaseShapesVisible(true);
      //      renderer.setSeriesLinesVisible(1, true);
      //      renderer.setLabelGenerator(new StandardCategoryLabelGenerator());
            // customise the range axis...
            final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
            rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
            rangeAxis.setAutoRangeIncludesZero(false);
            rangeAxis.setUpperMargin(0.12);
            return chart;
        public static void main(final String[] args) {
            final LineChartDemo5 demo = new LineChartDemo5("Line Chart Demo 5");
            demo.pack();
            RefineryUtilities.centerFrameOnScreen(demo);
            demo.setVisible(true);
    }And here is the link, I have just used the above program from this link only
    http://www.java2s.com/Code/Java/Chart/JFreeChartLineChartDemo5showingtheuseofacustomdrawingsupplier.htm

    It looks like you're using BasicStrokes to create dashed lines
    plot.getRenderer().setSeriesStroke(
        0,
        new BasicStroke(
            2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
            1.0f, new float[] {10.0f, 6.0f}, 0.0f
    plot.getRenderer().setSeriesStroke(
        1,
        new BasicStroke(
            2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
            1.0f, new float[] {6.0f, 6.0f}, 0.0f
    plot.getRenderer().setSeriesStroke(
        2,
        new BasicStroke(
            2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
            1.0f, new float[] {2.0f, 6.0f}, 0.0f
    ); Is this not what you want? If you want points instead of dashes you just specify *1f* for first argument in the float array
    new BasicStroke(...,...,...,...,new float[]{1f,6f},....); That indicates that you want the dashed regions to be ~1 pixel long - that is, a point - and the empty regions between the dashes to be ~6 pixels long.

Maybe you are looking for

  • Can i have multiple itunes accounts under one apple id?

    I am trying to create seperate apple id's for my daughters (2) with only one main email account - is this possible?

  • Computer Forgets Audio Settings

    Hello, I am a new user to this forum and I have a problem that I need help with. When ever I restart or shut down my computer my creative audio control panel along with creative console launcher software forgets all of its prior settings of being set

  • Phtosmart wireless update fails. - uninstall loop ensues.

    HP Install Error - Windows 7: Anyone help with scenario below? Unsolicited Photosmart wireless HP109n-z software update fails on install. Report raised then continue. Asks to wait while unsuccessful install is removed. THis fails as existing uninstal

  • Can't print from Adobe 9.4.1

    Any known fix to be able to print any documents in Adobe? It started a couple months ago. I'm assuming it started when I downloaded the Adobe 9.4.1 update? I get this error message - pstopdffilter/pstocupsraster failed with err number 13 Any help wou

  • Projects and Enhancements

    Hi All ,   When we implement user exits what is the purpose of creating enhancements and projects , becuase even without it the exist is triggred. Is the purpose of creating them only to have this exit when we are upgrade our system to a newer versio