Need help to draw recangle on video

Hi guys ,
Below I have pasted my code . In this code I have defined frame and in that frame stored video run. The other class has defined rectangle in cnvas . My problem is that I want rectangle to be drawn on video player and I havnt been successful.
So its my reequest to please help me out.
Thanks a ton in advance........
public class Map extends JFrame
* MAIN PROGRAM / STATIC METHODS
public static void main(String args[])
Map mdi = new Map();
static void Fatal(String s)
MessageBox mb = new MessageBox("JMF Error", s);
* VARIABLES
JMFrame jmframe = null;
JDesktopPane desktop;
FileDialog fd = null;
CheckboxMenuItem cbAutoLoop = null;
Player player = null;
Player newPlayer = null;
//JPanel glass = null;
SelectionArea drawingPanel;
String filename;
// code//
//ArrayList<Rectangle> rectangles = new ArrayList<Rectangle>();
// boolean stop=false;
* METHODS
public Map()
super("Java Media Player");
drawingPanel = new SelectionArea(this);
// Add the desktop pane
setLayout( new BorderLayout() );
desktop = new JDesktopPane();
desktop.setDoubleBuffered(true);
add("Center", desktop);
setMenuBar(createMenuBar());
setSize(640, 480);
setVisible(true);
//add(drawingPanel);
//drawingPanel.setVisible(true);
try
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
catch (Exception e)
System.err.println("Could not initialize java.awt Metal lnf");
addWindowListener( new WindowAdapter()
public void windowClosing(WindowEvent we)
System.exit(0);
Manager.setHint(Manager.LIGHTWEIGHT_RENDERER, new Boolean(true));
private MenuBar createMenuBar()
ActionListener al = new ActionListener()
public void actionPerformed(ActionEvent ae)
String command = ae.getActionCommand();
if (command.equals("Open"))
if (fd == null)
fd = new FileDialog(Map.this, "Open File",
FileDialog.LOAD);
fd.setDirectory("/movies");
fd.show();
if (fd.getFile() != null)
String filename = fd.getDirectory() + fd.getFile();
openFile("file:" + filename);
else if (command.equals("Exit"))
dispose();
System.exit(0);
MenuItem item;
MenuBar mb = new MenuBar();
// File Menu
Menu mnFile = new Menu("File");
mnFile.add(item = new MenuItem("Open"));
item.addActionListener(al);
mnFile.add(item = new MenuItem("Exit"));
item.addActionListener(al);
// Options Menu
Menu mnOptions = new Menu("Options");
cbAutoLoop = new CheckboxMenuItem("Auto replay");
cbAutoLoop.setState(true);
mnOptions.add(cbAutoLoop);
mb.add(mnFile);
mb.add(mnOptions);
return mb;
* Open a media file.
public void openFile(String filename)
String mediaFile = filename;
Player player = null;
// URL for our media file
URL url = null;
try
// Create an url from the file name and the url to the
// document containing this applet.
if ((url = new URL(mediaFile)) == null)
Fatal("Can't build URL for " + mediaFile);
return;
// Create an instance of a player for this media
try
player = Manager.createPlayer(url);
catch (NoPlayerException e)
Fatal("Error: " + e);
catch (MalformedURLException e)
Fatal("Error:" + e);
catch (IOException e)
Fatal("Error:" + e);
if (player != null)
this.filename = filename;
JMFrame jmframe = new JMFrame(player, filename);
desktop.add(jmframe);
if (player.getVisualComponent() != null)
getContentPane().add(player.getVisualComponent());
player.start();
jmframe.add(drawingPanel);
drawingPanel.setVisible(true);
/*validate();
public void paint(Graphics g)
drawingPanel.repaint();
public void update(Graphics g)
paint(g);
drawingPanel.repaint();
class SelectionArea extends Canvas implements ActionListener, MouseListener, MouseMotionListener
Rectangle currentRect;
Map controller;
//for double buffering
Image image;
Graphics offscreen;
public SelectionArea(Map controller)
super();
this.controller = controller;
addMouseListener(this);
addMouseMotionListener(this);
public void actionPerformed(ActionEvent ae)
repaintoffscreen();
public void repaintoffscreen()
image = createImage(this.getWidth(), this.getHeight());
offscreen = image.getGraphics();
Dimension d = size();
if(currentRect != null)
//Rectangle box = new Rectangle();
//box.getDrawable(currentRect, d);
Rectangle box = getDrawableRect(currentRect, d);
//Draw the box outline.
offscreen.drawRect(box.x, box.y, box.width - 1, box.height - 1);
repaint();
public void mouseEntered(MouseEvent me) {}
public void mouseExited(MouseEvent me){ }
public void mouseClicked(MouseEvent me){}
public void mouseMoved(MouseEvent me){}
public void mousePressed(MouseEvent me)
currentRect = new Rectangle(me.getX(), me.getY(), 0, 0);
repaintoffscreen();
public void mouseDragged(MouseEvent me)
System.out.println("here in dragged()");
currentRect.setSize(me.getX() - currentRect.x, me.getY() - currentRect.y);
repaintoffscreen();
repaint();
public void mouseReleased(MouseEvent me)
currentRect.setSize(me.getX() - currentRect.x, me.getY() - currentRect.y);
repaintoffscreen();
repaint();
public void update(Graphics g)
paint(g);
public void paint(Graphics g)
g.drawImage(image, 0, 0, this);
Rectangle getDrawableRect(Rectangle originalRect, Dimension drawingArea)
int x = originalRect.x;
int y = originalRect.y;
int width = originalRect.width;
int height = originalRect.height;
//Make sure rectangle width and height are positive.
if (width < 0)
width = 0 - width;
x = x - width + 1;
if (x < 0)
width += x;
x = 0;
if (height < 0)
height = 0 - height;
y = y - height + 1;
if (y < 0)
height += y;
y = 0;
//The rectangle shouldn't extend past the drawing area.
if ((x + width) > drawingArea.width)
width = drawingArea.width - x;
if ((y + height) > drawingArea.height)
height = drawingArea.height - y;
return new Rectangle(x, y, width, height);
}

Chances of someone reading a gazillion lines of unformatted code: < 1%
Paste your code (from the source), highlight it and click the CODE button to retain formatting and make it readable.

Similar Messages

  • I need help to draw in a frame, please

    Hi Im new to java and I need some help to draw a rainbow in a frame. I already made the frame , but i dont know how to draw inside the frame.
    here is my code so far:
    import java.awt.*;
    import javax.swing.*;
    public class Regnbue {
         public static void main(String[]args){
              JFrame ramme = new JFrame();
              ramme.setSize(600,300);
              Container cp = ramme.getContentPane();
              cp.setBackground(Color.white);
              ramme.setVisible(true);
    any help to finish this simple draw would be nice!!
    thanx

    I forgot , here is my code so far :
    import java.awt.*;
    import javax.swing.*;
    public class Regnbue {
         public static void main(String[]args){
              Rainbowpanel r= new Rainbowpanel();// her is where i make
    // my frame I think.
              JFrame ramme = new JFrame();
              ramme.setSize(600,300);
              Container cp = ramme.getContentPane();
              cp.setBackground(Color.white);
              ramme.setVisible(true);
    class Rainbowpanel extends JPanel {
         public void paintComponent(Graphics g) {// this is the part that I
    // dont understand, how can I put the arc into the container above??
              super.paintComponent(g);
              g.fillArc(5, 5, 10, 50, 0, 180);
         thanks
    elektropan

  • Need help to draw a graph from the output I get with my program please

    Hi all,
    I please need help with this program, I need to display the amount of money over the years (which the user has to enter via the textfields supplied)
    on a graph, I'm not sure what to do further with my program, but I have created a test with a System.out.println() method just to see if I get the correct output and it looks fine.
    My question is, how do I get the input that was entered by the user (the initial deposit amount as well as the number of years) and using these to draw up the graph? (I used a button for the user to click after he/she has entered both the deposit and year values to draw the graph but I don't know how to get this to work?)
    Please help me.
    The output that I got looked liked this: (just for a test!) - basically this kind of output must be shown on the graph...
    The initial deposit made was: 200.0
    After year: 1        Amount is:  210.00
    After year: 2        Amount is:  220.50
    After year: 3        Amount is:  231.53
    After year: 4        Amount is:  243.10
    After year: 5        Amount is:  255.26
    After year: 6        Amount is:  268.02
    After year: 7        Amount is:  281.42
    After year: 8        Amount is:  295.49
    After year: 9        Amount is:  310.27
    After year: 10        Amount is:  325.78
    After year: 11        Amount is:  342.07
    After year: 12        Amount is:  359.17
    After year: 13        Amount is:  377.13
    After year: 14        Amount is:  395.99
    After year: 15        Amount is:  415.79
    After year: 16        Amount is:  436.57
    After year: 17        Amount is:  458.40And here is my code that Iv'e done so far:
    import javax.swing.*;
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.RenderingHints;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.lang.Math;
    import java.text.DecimalFormat;
    public class CompoundInterestProgram extends JFrame implements ActionListener {
        JLabel amountLabel = new JLabel("Please enter the initial deposit amount:");
        JTextField amountText = new JTextField(5);
        JLabel yearsLabel = new JLabel("Please enter the numbers of years:");
        JTextField yearstext = new JTextField(5);
        JButton drawButton = new JButton("Draw Graph");
        public CompoundInterestProgram() {
            super("Compound Interest Program");
            setSize(500, 500);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            amountText.addActionListener(this);
            yearstext.addActionListener(this);
            JPanel panel = new JPanel();
            panel.setBackground(Color.white);
            panel.add(amountLabel);
            amountLabel.setToolTipText("Range of deposit must be 20 - 200!");
            panel.add(amountText);
            panel.add(yearsLabel);
            yearsLabel.setToolTipText("Range of years must be 1 - 25!");
            panel.add(yearstext);
            panel.add(drawButton);
            add(panel);
            setVisible(true);
            public static void main(String[] args) {
                 DecimalFormat dec2 = new DecimalFormat( "0.00" );
                CompoundInterestProgram cip1 = new CompoundInterestProgram();
                JFrame f = new JFrame();
                f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                f.getContentPane().add(new GraphPanel());
                f.setSize(500, 500);
                f.setLocation(200,200);
                f.setVisible(true);
                Account a = new Account(200);
                System.out.println("The initial deposit made was: " + a.getBalance() + "\n");
                for (int year = 1; year <= 17; year++) {
                      System.out.println("After year: " + year + "   \t" + "Amount is:  " + dec2.format(a.getBalance() + a.calcInterest(year)));
              @Override
              public void actionPerformed(ActionEvent arg0) {
                   // TODO Auto-generated method stub
    class Account {
        double balance = 0;
        double interest = 0.05;
        public Account() {
             balance = 0;
             interest = 0.05;
        public Account(int deposit) {
             balance = deposit;
             interest = 0.05;
        public double calcInterest(int year) {
               return  balance * Math.pow((1 + interest), year) - balance;
        public double getBalance() {
              return balance;
    class GraphPanel extends JPanel {
        public GraphPanel() {
        public void paintComponent(Graphics g) {
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            g2.setColor(Color.red);
    }Your help would be much appreciated.
    Thanks in advance.

    watertownjordan wrote:
    http://www.jgraph.com/jgraph.html
    The above is also good.Sorry but you need to look a bit more closely at URLs that you cite. What the OP wants is a chart (as in X against Y) not a graph (as in links and nodes) . 'jgraph' deals with links and nodes.
    The best free charting library that I know of is JFreeChart from www.jfree.org.

  • Need help regarding "Macbook Pro Distorted Video or No Video issues"

    Hi there, I'm new and I'm kinda need help or opinion from all of you Mac users.
    I have a MPB which is the first generation released 2005-2006, which its 4 years back. Now, the main problem is after 4 years of non-graphic problems, I encounter the NVIDIA graphics processor problems, which make my screen scrambled and unable to click or do anything. For some reason that Apple did say they will change/replace the graphic processor for free due faulty issue of the NVIDIA. But what I wanted to know and reconfirm is, since my MPB was 1st generation and version 2005/06, will Apple cover the change/replacement NVIDIA processor for free? Because I really need to have a confirmed answer before I went to the AASP in Malaysia, which I know they will make a fuss by asking me to pay with my previous incident which my battery deflect and charger/adapter melted. So, please kindly reply this post. Thank you for you time.
    Message was edited by: dannflamer

    Welcome to Apple Discussions!
    How about printing out the Apple article about this and taking it with you?
    http://support.apple.com/kb/TS2377
    However, if you really do have the first MBP introduced in January 2006, it actually has a different video chip, the ATI Mobility Radeon X 1600, which unfortunately is not the NVIDIA chip covered by the NVIDIA program. So if that's what you have, you are out of luck for a free repair. ATI Mobility Radeon chips can also go bad, but there is no program that I know of that will cover them.
    Sorry to not have better news for you.
    Good luck!

  • Need help with coding for HTML5 Video with Flash fallback

    Hello, need help with my coding in Dreamweaver CS5.5 for HTML5 video with Flash fallback. Not sure if the coding is correct. Do I need anything else Javascipt etc?

    The reason you see a blank page is because it's trying to load the file that is pretty humungous and there is no preloader. So, you see a white screen till it complets loading.
    Also, the reason why its loading a SWF file and not any of HTML5 type video is because your doctype declaration is XHTML1.0 and not HTML5.
    Change the 1st line in your .html file from:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    to:
    <!DOCTYPE html>
    Then see if your HTML5 video types load with <video> tag.

  • I need help with my new iPod video!!!!!

    i got an iPod video and i am trying to get some songs onto it. i plugged my iPod into my computer and opened up iTunes. i was told that an iPod icon is supposed to pop up. when i plugged my iPod in, the icon did not show up. what do i do?!
    signed,
    I NEED HELP DESPERATELY!!!!!!!!!
    Dell Inspiron   Windows 2000  

    Make sure you have the latest version of iTunes (iTunes 7.0.2.16). To find the version of iTunes you have open iTunes, click Help, then About iTunes. If this does not work then follow the following instructions:
    For iTunes Technical support please call 1-800-APL-CARE
    or
    Another problem might be that your service pack of Windows 2000 is not the latest version (Windows 2000 Service Pack 4).
    I would recogmend getting Windows XP, many advantages over Windows 2000. Especially security and looks wise.

  • Need help in drawing inside the Oval and outside it

    I need help in something
    I have an array and I want the numbers to be around the oval and I have part of the array and I want to fill part of the oval
    and when I want to put a number I would like a line from the center to point at the number
    I know its hard to explain so I have picture maybe you will know hwo its work
    http://img265.imageshack.us/i/55788522.jpg/
    I have almost everything done the oval and all the code but I have no clue how to do what I explained

    import static java.lang.Math.*;
    import java.awt.*;
    import javax.swing.*;
    @SuppressWarnings("serial") public class Trefoil extends JComponent {
            setPreferredSize(new Dimension(400, 400));
        @Override protected void paintComponent(Graphics g) {
            Graphics2D g2 = (Graphics2D) g.create();
            int w = getWidth(), h = getHeight();
            g2.setColor(getBackground());
            g2.fillRect(0, 0, w, h);
            g2.setColor(getForeground());
            g2.translate(w/2, h/2);
            g2.setRenderingHint(
                RenderingHints.KEY_ANTIALIASING,
                RenderingHints.VALUE_ANTIALIAS_ON);
            int rays = 100;
            for(int i=0; i<rays; ++i) {
                double angle = i*(2 * PI)/rays;
                double flange = cos(1.5* angle - PI/4);
                int r = (int)(190 * flange * flange);
                int x = (int)(r* cos(angle));
                int y = (int)(r* sin(angle));
                g2.drawLine(0, 0, x, y);
            g2.dispose();
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable(){
                public void run() {
                    JFrame f = new JFrame("Trefoil");
                    f.add(new Trefoil());
                    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    f.pack();
                    f.setLocationRelativeTo(null);
                    f.setVisible(true);
    }

  • Need Help to Draw and Drag Triangle - URGENT

    Hi everyone - I am developing various proofs of the pythagora's theorem
    and the following code draws a triangle on screen and the proof follows -
    but i need to know how to drag the triangle such tht 1 angle is always set to 90 degrees.
    i.e. i need to resize the triangle by dragging its vertex points by which the1 angle remains at 90 no matter what the size.
    The proof has got some graphics code hardcoded in it - i.e. LINES AND POLYGONS have been hardcoded
    i need to reconfigure that such that everytime the user increases the size of the triagnle and clicks on next it draws the lines and polygons in the correct area and place
    PLEASE HELP
    the code is as follows
    MAIN CLASS
    import java.awt.BorderLayout;
    import java.awt.Container;
    import java.awt.*;
    import java.awt.event.*;
    import java.text.*;
    import javax.swing.*;
    public class TestProof {
        TestControl control;          // the controls for the visual proof
        TestView view;          // the drawing area to display proof
        // called upon class creation
        public TestProof() {
            view = new TestView();
    view.setBackground(Color.WHITE);
            control = new TestControl(view);
            Frame f = new Frame("Pythagoras");
            f.add(view,"Center");
            f.add(control,"South");
            f.setSize(600,600);
            f.setBackground(Color.lightGray);
            f.addMouseMotionListener(
            new MouseMotionListener() { //anonymous inner class
                //handle mouse drag event
                public void mouseMoved(MouseEvent e) {
                    System.out.println("Mouse  " + e.getX() +","  + e.getY());
                public void mouseDragged(MouseEvent e) {
                    System.out.println("Draggg: x=" + e.getX() + "; y=" + e.getY());
            JMenu File = new JMenu("File");
            JMenuItem Exit = new JMenuItem("Exit");
            Exit.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    ExitActionPerformed(evt);
            JMenuBar menuBar = new JMenuBar();
            menuBar.add(File);
       File.add(Exit);
            f.add(menuBar,"North");
            f.show();
        private JMenuBar getMenuBar() {
            JMenu File = new JMenu("File");
            JMenuItem Exit = new JMenuItem("Exit");
            Exit.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    ExitActionPerformed(evt);
            JMenuBar menuBar = new JMenuBar();
            menuBar.add(File);
                 File.add(Exit);   
            return menuBar;
        private void ExitActionPerformed(java.awt.event.ActionEvent evt) {
            // TODO add your handling code here:
            System.exit(0);
        // for standalone use
        public static void main(String args[]) {
      TestProof TP = new TestProof();
    }Test VIEW
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.text.*;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    public class TestView extends Canvas {
        int TRANSLUCENT = 1;
        int sequence;          // sequencer that determines what should be drawn
        // notes matter
        int noteX = 100;     // note coordinates
        int noteY = 60;
        int fontSize = 11;     // font size
        int lineSpacing     // space between two consecutive lines
        = fontSize + 2;
        Font noteFaceFont;     // font used to display notes
        // objects matter
        Polygon tri;          // right-angled triangle with sides A, B, and C
        Polygon tri1;
        Polygon sqrA;          // square with side of length A
        Polygon sqrB;          // square with side of length B
        Polygon sqrC;          // square with side of length C
        Polygon parA;          // parallelogram of base A and height A
        Polygon parB;          // parallelogram of base B and height B
        Polygon poly1;
        Polygon poly2;
        Polygon poly3;
        Polygon poly4;
        Polygon poly5;
        Polygon poly6;
        int X0 = 350;          // coordinates of triangle
        int Y0 = 350;
        int A = 90;//60;          // triangle size
        int B = 120;//80;
        int C = 150;//100;
        //CORDS of 2nd triangle
        int X1 = 350;
        int Y1 = 500;
        // notes: three lines per note
        String notes[] = {
            // note 0
            // note 1
            // note 2
            // note 3
            // note 4
            // note 5
            // note 6
            // note 7
            // note 8
            // note 9
            // note 10
            // note 11
            // note 12
            // note 13
            // note 14
        // constructor
        public TestView() {
            addMouseMotionListener(
            new MouseMotionListener() { //anonymous inner class
                //handle mouse drag event
                public void mouseMoved(MouseEvent e) {
                    System.out.println("Mouse  " + e.getX() +","  + e.getY());
                public void mouseDragged(MouseEvent e) {
                    System.out.println("Draggg: x=" + e.getX() + "; y=" + e.getY());
            // set font
            noteFaceFont = new Font("TimesRoman", Font.PLAIN, fontSize);
            // (coordinates specified w.r.t. to P0, unless otherwise specified)
            // create the triangle
            tri = new Polygon();
            tri.addPoint(0, 0);                    // add P0 coordinate
            tri.addPoint(A*A/C, -A*B/C);          // add A3 coordinate
            tri.addPoint(C, 0);                    // add C1 coordinate
            tri.translate(X0, Y0);               // place triangle
            tri1 = new Polygon();
            tri1.addPoint(0,0);                    // add P0 coordinate
            tri1.addPoint(A*A/C +38, +A*B/C);          // add A3 coordinate
            tri1.addPoint(C, 0);                    // add C1 coordinate
            tri1.translate(X1, Y1);
            // create square of side A
            sqrA = new Polygon();
            sqrA.addPoint(0, 0);               // add P0 coordinate
            sqrA.addPoint(-A*B/C, -A*A/C);          // add A1 coordinate
            sqrA.addPoint(-A*(B-A)/C, -A*(A+B)/C);     // add A2 coordinate
            sqrA.addPoint(A*A/C, -A*B/C);          // add A3 coordinate
            sqrA.translate(X0, Y0);               // place square
            // create square of side B
            // warning: the coordinate of this object are specified relative to C1
            sqrB = new Polygon();
            sqrB.addPoint(0, 0);               // add C1 coordinate
            sqrB.addPoint(B*A/C, -B*B/C);          // add B1 coordinate
            sqrB.addPoint(B*(A-B)/C, -B*(A+B)/C);     // add B2 coordinate
            sqrB.addPoint(-B*B/C, -B*A/C);          // add A3 coordinate
            sqrB.translate(X0 + C, Y0);               // place square
            // create square of side C
            sqrC = new Polygon();
            sqrC.addPoint(0, 0);               // add P0 coordinate
            sqrC.addPoint(C, 0);               // add C1 coordinate
            sqrC.addPoint(C, C);               // add C2 coordinate
            sqrC.addPoint(0, C);               // add C3 coordinate
            sqrC.translate(X0, Y0);               // place square
            poly1 = new Polygon();
            poly1.addPoint(405,279);
            poly1.addPoint(413,350);
            poly1.addPoint(432,500);
            poly1.addPoint(442,571);
            poly1.addPoint(500,500);
            poly1.addPoint(500,350);
            poly2 = new Polygon();
            poly2.addPoint(279,297);
            poly2.addPoint(404,280);
            poly2.addPoint(571,254);
            poly2.addPoint(500,350);
            poly2.addPoint(350,350);
            //Polygon 3
            poly3 = new Polygon();
            poly3.addPoint(404,280);
            poly3.addPoint(350,350);
            poly3.addPoint(414,350);
            poly4 = new Polygon();
            poly4.addPoint(350,350);
            poly4.addPoint(350,500);
            poly4.addPoint(442,572);
            poly4.addPoint(433,500);
            poly4.addPoint(414,350);
            poly5 = new Polygon();
            poly5.addPoint(476,183);
            poly5.addPoint(332,225);
            poly5.addPoint(278,295);
            poly5.addPoint(404,279);
            poly5.addPoint(571,254);
            poly6= new Polygon();
            poly6.addPoint(405,278);
            poly6.addPoint(332,224);
            poly6.addPoint(476,182);
            // create parallelogram of height A
            parA = new Polygon();
            parA.addPoint(0, 0);               // add P0 coordinate
            parA.addPoint(0, C);               // add C3 coordinate
            parA.addPoint(A*A/C, C - A*B/C);          // add Q0 coordinate
            parA.addPoint(A*A/C, -A*B/C);          // add A3 coordinate
            parA.translate(X0,Y0);               // place parallelogram
            // create parallelogram of height B
            // warning: the coordinate of this object are specified from C1
            parB = new Polygon();
            parB.addPoint(0, 0);               // add C1 coordinate
            parB.addPoint(-B*B/C, -B*A/C);          // add A3 coordinate
            parB.addPoint(A*A/C - C, C - A*B/C);     // add Q0 coordinate
            parB.addPoint(0, C);               // add C2 coordinate
            parB.translate(X0 + C, Y0);
            // place parallelogram
        // depending on the sequence number we draw certain objects
        public void paint(Graphics gfx) {
            super.paint(gfx);
            Graphics2D g = (Graphics2D) gfx;
            g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);
            // text first, then objects (and animation)
            // we always output some notes
            g.drawString(notes[3*sequence], noteX, noteY);
            g.drawString(notes[3*sequence + 1], noteX, noteY + lineSpacing);
            g.drawString(notes[3*sequence + 2], noteX, noteY + 2*lineSpacing);
            // the object are drawn in an order so that they are properly overlapped
            if(sequence == 13) {
                g.setColor(Color.green);
                g.fillPolygon(poly1);
                g.fillPolygon(poly2);
                g.fillPolygon(poly3);
                g.fillPolygon(poly4);
                g.fillPolygon(poly5);
                g.setColor(Color.RED);
                g.setColor(Color.GREEN);
                g.drawLine(413,351,433,499);
                g.setColor(Color.white);
                g.fillPolygon(tri);
                g.fillPolygon(tri1);
                g.fillPolygon(poly6);
            if(sequence == 12 ) {
                g.setColor(Color.green);
                g.fillPolygon(poly1);
                g.fillPolygon(poly2);
                g.fillPolygon(poly3);
                g.fillPolygon(poly4);
                g.fillPolygon(poly5);
                g.setColor(Color.BLACK);
            if(sequence == 11){
                g.setColor(Color.green);
                g.fillPolygon(poly1);
                g.fillPolygon(poly3);
                g.fillPolygon(poly4);
                g.setColor(Color.BLACK);
            if(sequence == 8 ){
                g.setColor(Color.green);
                g.fillPolygon(poly5);
                g.setColor(Color.MAGENTA);
                g.drawString("E",578,254);
                g.drawString("D",268,302);
                g.setColor(Color.black);
                g.drawArc(250,150,350,250,320,65);
            else if (sequence == 9 ){
                g.setColor(Color.green);
                g.fillPolygon(poly2);
                g.setColor(Color.MAGENTA);
                g.drawString("E",578,254);
                g.drawString("D",268,302);
                g.setColor(Color.black);
                g.drawArc(250,150,350,250,320,65);
            if( sequence == 10){
                g.setColor(Color.green);
                g.fillPolygon(poly2);
                g.fillPolygon(poly5);
                g.setColor(Color.black);
                g.setColor(Color.MAGENTA);
                g.drawString("E",578,254);
                g.drawString("D",268,302);
                g.setColor(Color.black);
                g.drawArc(250,150,350,250,320,65);
            if(sequence == 7){
                g.setColor(Color.green);
                g.fillPolygon(poly2);
                g.setColor(Color.MAGENTA);
                g.drawString("E",578,254);
                g.drawString("D",268,302);
                g.setColor(Color.black);
            if(sequence == 6){
                g.setColor(Color.yellow);
                g.fillPolygon(poly2);
                g.setColor(Color.green);
                g.fillPolygon(poly3);
                g.setColor(Color.blue);
                g.fillPolygon(poly4);
                g.setColor(Color.black);
                g.drawArc(250,175,350,275,300,65);
                //g.drawArc(250,150,350,250,320,65);
                g.drawLine( 606,309,599,299);
                g.drawLine(592,313, 599,299);
                g.drawString("+90 degrees",605,378);
            if (sequence == 5 ) {
                g.setColor(Color.yellow);
                g.fillPolygon(poly2);
                g.setColor(Color.black);
            if (sequence == 4) {
                g.setColor(Color.YELLOW);
                g.fillPolygon(poly1);
                g.setColor(Color.black);
                g.drawArc(319,310,250,195,89,-35);
                g.drawLine(499,319, 492,312);
                g.drawLine(499,319, 492,325);
                g.drawArc(200,180, 233,238,-120,-60);
                g.drawLine(200,298, 208,309);
                g.drawLine(200,298, 194,313);
                g.drawString("-90 degrees",227,347);
            if (sequence >= 3) {
                g.drawLine(404,279,442,572);
            // draw the squares
            if (sequence >= 2) {
                g.drawLine(278,296,572,254);
            // draw the squares
            if (sequence >= 1) {
                g.drawLine(333,224,476,182);
                g.drawPolygon(tri1);
            // always draw the triangle
            g.drawPolygon(tri);
            g.drawPolygon(sqrA);
            g.drawPolygon(sqrB);
            g.drawPolygon(sqrC);
            g.setColor(Color.MAGENTA);
            g.drawString("C", X0 + C/2 - fontSize/2, Y0 + lineSpacing);
            g.drawString("A",
            X0 + A*A/(2*C) - fontSize*A/B/2,
            Y0 - A*B/(2*C) - lineSpacing*A/B);
            g.drawString("B",
            X0 + C - B*B/(2*C) - fontSize*A/B/2,// the last "-" isn't log.
            Y0 - B*A/(2*C) - lineSpacing*A/B);
        public void redraw(int sequence) {
            this.sequence = sequence;
            repaint();
    }TEST CONTROL
    * TestControl.java
    * Created on 28 February 2005, 11:16
    import java.awt.*;
    import java.awt.event.*;
    import java.text.*;
    import javax.swing.JFrame;
    * @author  Kripa Bhojwani
    public class TestControl extends Panel implements ActionListener {
      TestView view;
      int sequence;                    // event sequence
      // constructor
      public TestControl(TestView view) {
        Button b = null;
        Label label = new Label("A^2 ");
        this.view = view;          // initialize drawble area
        sequence = 0;               // initialize sequence
        b = new Button("Prev");
        b.addActionListener(this);
        add(b);
        b = new Button("Next");
        b.addActionListener(this);
        add(b);
        add(label);
      // exported method
      public void actionPerformed(ActionEvent ev) {
        String label = ev.getActionCommand();
        if (label.equals("Prev")) {
          if (sequence >0) {
         --sequence;
        else {
          if (sequence < 15) {
         ++sequence;
        this.setEnabled(false);          // disable the controls
        view.redraw(sequence);
        this.setEnabled(true);          // enable the controls
    }Please help --- really need to sort this out...
    THANKS

    One of the problems you face is that it is hard to recognise which parts of your code are drawing the triangle. This is because you are writing code in a procedural way rather than an object oriented way.
    In object oriented code you would have a triangle object that could draw itself. You would create the triangle object by specifying its sizes and angles in some way. Then it should be easy to change the triangles sizes and angles and ask all the drawn objects to redraw themselves.

  • I need help to draw an image and move it plz plz : )

    Ok, so I have this whole code and I understand most of it but not all of it but I'm trying to make image "drop.gif" to move down the right side of the window. For each shot that is taken the image moves down ever so much and if the image hits the Entity ship "background" than notify death. PLease anyone help me !
    there are 7 classes but here is the main ...
    package spaceinvaderss;
    import java.awt.Canvas;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Graphics2D;
    import java.awt.Image;
    import java.awt.Toolkit;
    import java.awt.event.KeyAdapter;
    import java.awt.event.KeyEvent;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.awt.image.BufferStrategy;
    import java.util.ArrayList;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    public class Main extends Canvas {
    /*A Canvas component represents a blank rectangular area of the screen onto which the application can draw or from which the application can trap input events from the user.
    An application must subclass the Canvas class in order to get useful functionality such as creating a custom component.
    The paint method must be overridden in order to perform custom graphics on the canvas.*/
    /** The stragey that allows us to use accelerate page flipping.*/
    private BufferStrategy strategy;
    /** True if the game is currently "running", i.e. the game loop is looping */
    private boolean gameRunning = true;
    /** The list of all the entities that exist in our game */
    private ArrayList entities = new ArrayList();
    /** The list of entities that need to be removed from the game this loop */
    private ArrayList removeList = new ArrayList();
    /** The entity representing the player */
    private Entity ship;
    /** The entity representing the alien */
    private Entity alien;
    /** The speed at which the player's ship should move (pixels/sec) */
    private double moveSpeed = 600;
    /** The time at which last fired a shot */
    private long lastFire = 0;
    /** The interval between our players shot (ms) */
    private long firingInterval = 400;
    /** timer */
    private long time = 0;
    /** The number of aliens left on the screen */
    private int alienCount;
    /** The message to display which waiting for a key press */
    private String message = "";
    /** True if we're holding up game play until a key has been pressed */
    private boolean waitingForKeyPress = true;
    /** True if the left cursor key is currently pressed */
    private boolean leftPressed = false;
    /** True if the right cursor key is currently pressed */
    private boolean rightPressed = false;
    /** True if we are firing */
    private boolean firePressed = false;
    /** True if game logic needs to be applied this loop, normally as a result of a game event */
    private boolean logicRequiredThisLoop = false;
    private static Image drop;
    /** The constant for the width*/
    private int DOMAIN = 800;
    /** The constant fot the length*/
    private int RANGE = 950;
    /** The constant for the number of rows of aliens */
    private int numbaofrows = 8;
    /** The constant for the number of aliens per row */
    private int aliensperrow = 12;
    /** The constant for the percent of which the speed increases*/
    private double speedincrease = 1.02;
    /** Starts the variable that counts the shots*/
    private int shotsfired = 0;
    /** Construct our game and set it running.*/
    public Main() {
    // Creates a frame to contain Main.
    JFrame container = new JFrame("SPACE INVADERS !!! WOOT !!! WOOT !!!");
    // Gets a hold of the content of the frame and sets up the resolution of the game
    // Names the inside of the "container" as panel.
    JPanel panel = (JPanel) container.getContentPane();
    // Stes the demensions of the panel.
    panel.setPreferredSize(new Dimension(DOMAIN,RANGE));
    //Sets the layout as nothing which overrides any automatic properties.
    panel.setLayout(null);
    // Sets up our canvas size and puts it into the content of the frame
    setBounds(0, 0, DOMAIN, RANGE);
    panel.add(this);
    // Tell AWT not to bother repainting our canvas since we're
    // going to do that our self in accelerated mode.
    setIgnoreRepaint(true);
    // Actually sizes the window approximately.
    container.pack();
    // Makes it so that the window can't be resized.
    container.setResizable(false);
    // Makes the window visible.
    container.setVisible(true);
    // Add a listener to respond to the user pressing the x.
    // End the program when the window is closed.
    container.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    // add a key input system (defined below) to our canvas
    // so we can respond to key pressed
    addKeyListener(new KeyInputHandler());
    // request the focus so key events come to us
    requestFocus();
    // Create the buffering strategy which will allow AWT
    // to manage our accelerated graphics.
    createBufferStrategy(2);
    strategy = getBufferStrategy();
    // initialise the entities in our game so there's something
    // to see at startup
    initEntities();
    time = System.currentTimeMillis();
    * Start a fresh game, this should clear out any old data and
    * create a new set.
    private void startGame() {
    // clear out any existing entities and intialise a new set
    entities.clear();
    initEntities();
    // blank out any keyboard settings we might currently have
    leftPressed = false;
    rightPressed = false;
    firePressed = false;
    * Initialise the starting state of the entities (ship and aliens). Each
    * entitiy will be added to the overall list of entities in the game.
    private void initEntities() {
    ClassLoader cloader = Main.class.getClassLoader();
    drop = Toolkit.getDefaultToolkit().getImage(cloader.getResource("drop.gif"));
    prepareImage(drop, this);
    // create the player ship and place it in the center of the screen
    ship = new ShipEntity(this,"background.gif", 0, (RANGE - 75));
    entities.add(ship);
    ship = new ShipEntity(this,"ship.gif", (DOMAIN / 2) - 0, (RANGE - 50));
    entities.add(ship);
    // create a block of aliens
    alienCount = 0;
    for (int row = 0; row < numbaofrows; row++) {
    for (int x = 0; x < aliensperrow; x++) {
    alien = new AlienEntity(this,"alien.gif", 100 + (x*50),(50)+row*30);
    entities.add(alien);
    alienCount++;
    * Notification from a game entity that the logic of the game
    * should be run at the next opportunity (normally as a result of some
    * game event)
    public void updateLogic() {
    logicRequiredThisLoop = true;
    * Remove an entity from the game. The entity removed will
    * no longer move or be drawn.
    * Remove the entity
    public void removeEntity(Entity entity) {
    removeList.add(entity);
    /**Notify that the player has died.*/
    public void notifyDeath() {
    message = "Oh no! The aliens win, wanna try again?";
    waitingForKeyPress = true;
    /** Notification that the player has won since all the aliensare dead.*/
    public void notifyWin() {
    long time2;
    time2 = (System.currentTimeMillis() - time) / 1000;
    int acuracy = 1000*(aliensperrow*numbaofrows)/shotsfired;
    message = "Congradulations! You win! Your time was: " + time2 + " seconds. Your acuracy was " + acuracy + "%.";
    waitingForKeyPress = true;
    /**Notification that an alien has been killed*/
    public void notifyAlienKilled() {
    // reduce the alient count, if there are none left, the player has won!
    alienCount--;
    if (alienCount == 0) {
    notifyWin();
    // if there are still some aliens left then they all need to get faster, so
    // speed up all the existing aliens
    for (int i = 0; i < entities.size(); i++) {
    Entity entity = (Entity) entities.get(i);
    if (entity instanceof AlienEntity) {
    // speed up every time the aliens move down
    entity.setHorizontalMovement(entity.getHorizontalMovement() * speedincrease);
    /**Attempt to fire a shot from the player. Its called "try" since we must first
    * check that the player can fire at this point, i.e. has he/she waited long
    * enough between shots.*/
    public void tryToFire() {
    // check that we have been waiting long enough to fire
    if (System.currentTimeMillis() - lastFire < firingInterval) {
    return;
    // if we waited long enough, create the shot entity, and record the time.
    lastFire = System.currentTimeMillis();
    ShotEntity shot = new ShotEntity(this, "bullet.gif", ship.getX() + 27, ship.getY() - 30);
    entities.add(shot);
    * The main game loop. This loop is running during all game
    * play as is responsible for the following activities:
    * - Working out the speed of the game loop to update moves
    * - Moving the game entities
    * - Drawing the screen contents (entities, text)
    * - Updating game events
    * - Checking Input
    public void gameLoop() {
    long lastLoopTime = System.currentTimeMillis();
    // Keep looping around till the game ends.
    while (gameRunning) {
    // Work out how long its been since the last update, this
    // will be used to calculate how far the entities should
    // move this loop.
    long delta = System.currentTimeMillis() - lastLoopTime;
    lastLoopTime = System.currentTimeMillis();
    // Get hold of a graphics context for the accelerated
    // surface and black it out.
    Graphics2D g = (Graphics2D) strategy.getDrawGraphics();
    g.setColor(Color.black);
    g.fillRect(0, 0, DOMAIN, RANGE);
    // Cycle around asking for each entity to move itself.
    if (!waitingForKeyPress) {
    for (int i = 0; i < entities.size(); i++) {
    Entity entity = (Entity) entities.get(i);
    entity.move(delta);
    // cycle round drawing all the entities we have in the game
    for (int i = 0; i < entities.size(); i++) {
    Entity entity = (Entity) entities.get(i);
    entity.draw(g);
    // brute force collisions, compare every entity against
    // every other entity. If any of them collide notify
    // both entities that the collision has occured
    for (int p = 0; p < entities.size(); p++) {
    for (int s = p + 1; s < entities.size(); s++) {
    Entity me = (Entity) entities.get(p);
    Entity him = (Entity) entities.get(s);
    if (me.collidesWith(him)) {
    me.collidedWith(him);
    him.collidedWith(me);
    // remove any entity that has been marked for clear up
    entities.removeAll(removeList);
    removeList.clear();
    // if a game event has indicated that game logic should
    // be resolved, cycle round every entity requesting that
    // their personal logic should be considered.
    if (logicRequiredThisLoop) {
    for (int i = 0; i < entities.size(); i++) {
    Entity entity = (Entity) entities.get(i);
    entity.doLogic();
    logicRequiredThisLoop = false;
    // if we're waiting for an "any key" press then draw the
    // current message
    if (waitingForKeyPress) {
    g.setColor(Color.green);
    g.drawString(message,(DOMAIN-g.getFontMetrics().stringWidth(message)) / 2, 250);
    g.drawString("TO PLAY, PRESS ANY KEY : )", (DOMAIN-g.getFontMetrics().stringWidth("TO PLAY, PRESS ANY KEY : )")) / 2, 40);
    // Clear up the graphics.
    g.dispose();
    // Flip the buffer over.
    strategy.show();
    // resolve the movement of the ship. First assume the ship
    // isn't moving. If either cursor key is pressed then
    // update the movement appropraitely
    ship.setHorizontalMovement(0);
    if ((leftPressed) && (!rightPressed)) {
    ship.setHorizontalMovement(-moveSpeed);
    } else if ((rightPressed) && (!leftPressed)) {
    ship.setHorizontalMovement(moveSpeed);
    // if we're pressing fire, attempt to fire
    if (firePressed) {
    shotsfired++;
    tryToFire();
    // finally pause for a bit. Note: this should run us at about
    // 100 fps but on windows this might vary each loop due to
    // a bad implementation of timer
    try { Thread.sleep(10); } catch (Exception e) {}
    * A class to handle keyboard input from the user. The class
    * handles both dynamic input during game play, i.e. left/right
    * and shoot, and more static type input (i.e. press any key to
    * continue)
    * This has been implemented as an inner class more through
    * habbit then anything else. Its perfectly normal to implement
    * this as seperate class if slight less convienient.
    private class KeyInputHandler extends KeyAdapter {
    /** The number of key presses we've had while waiting for an "any key" press */
    private int pressCount = 1;
    * Notification from AWT that a key has been pressed. Note that
    * a key being pressed is equal to being pushed down but NOT
    * released. Thats where keyTyped() comes in.
    * @param e The details of the key that was pressed
    public void keyPressed(KeyEvent e) {
    // if we're waiting for an "any key" typed then we don't
    // want to do anything with just a "press"
    if (waitingForKeyPress) {
    return;
    if (e.getKeyCode() == KeyEvent.VK_LEFT) {
    leftPressed = true;
    if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
    rightPressed = true;
    if (e.getKeyCode() == KeyEvent.VK_SPACE) {
    firePressed = true;
    * Notification from AWT that a key has been released.
    * @param e The details of the key that was released
    public void keyReleased(KeyEvent e) {
    // if we're waiting for an "any key" typed then we don't
    // want to do anything with just a "released"
    if (waitingForKeyPress) {
    return;
    if (e.getKeyCode() == KeyEvent.VK_LEFT) {
    leftPressed = false;
    if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
    rightPressed = false;
    if (e.getKeyCode() == KeyEvent.VK_SPACE) {
    firePressed = false;
    * Notification from AWT that a key has been typed. Note that
    * typing a key means to both press and then release it.
    * @param e The details of the key that was typed.
    public void keyTyped(KeyEvent e) {
    // if we're waiting for a "any key" type then
    // check if we've recieved any recently. We may
    // have had a keyType() event from the user releasing
    // the shoot or move keys, hence the use of the "pressCount"
    // counter.
    if (waitingForKeyPress) {
    if (pressCount == 1) {
    // since we've now recieved our key typed
    // event we can mark it as such and start
    // our new game
    waitingForKeyPress = false;
    startGame();
    pressCount = 0;
    } else {
    pressCount++;
    // if we hit escape, then quit the game
    if (e.getKeyChar() == 27) {
    System.exit(0);
    * The entry point into the game. We'll simply create an
    * instance of class which will start the display and game
    * loop.
    * @param argv The arguments that are passed into our game
    public static void main(String argv[]) {
    Main g = new Main();
    // Starts the main game loop, this method will not return until the game has finished running. Hence we are
    // using the actual main thread to run the game.
    g.gameLoop();
    }                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Ap_Compsci_student_13 wrote:
    ok sorry but doesn't sscce say to post the whole code?the first S is Short, and yes, it needs to be all the code needed to illustrate the problem and let use reproduce it. If you were developing a new Web framework, your example might be short, but for a student game it's very long.

  • I need help putting together different sized video/photo

    I just got back from a trip to Yellowstone National Park.  I want to put three different pieces of media - GOPRO HD video shot at 1280 x 960, NIKON jpegs at 3872 x 2592, and SDV (Sony DCR-TRV33) shot at 16:9 resolution (can't figure out pixel size.)  I have Compressor (of course) and also MPEG Streamclip.
    First of all I need to convert the GOPRO HD (compressed at h.264) and digitize the SDV.  What format would be best for editing and integrating the three pieces of media - Apple Pro Res, DV/DCVPRO, ...
    1280 x 960 is 4:3 (too late to change the SDV to 4:3) so what would be the best compromise?
    Thanks for the help,
    William

    So you recommend digitizing (log and capture) the SDV in FCP as a ProRes (422?)  Also convert the h.264 (GOPRO) to ProRes.  Trim the jpegs in Photoshop (is there a simple batch program that can do this?)
    When you say to leave the GOPRO in it 1280x960 frame size so it can be re-framed in a Sequence - how does that work?
    I'd just use ProRes 422 for both types of video. You could probably get along with ProRes LT for the SD, but I like to keep things simple.
    Create your timeline by dropping a "SDV" clip in and answering "yes" to the auto-conform question that will appear. This should give you a 16:9 aspect ratio SD timeline. Now, when you drop in a GoPro clip it will scale down and try to fit in.
    If you double click it into Viewer and go to the Motion tab, you can hit the Reset button (the one with the red X) and you will have a 1280x960 clip again. It will seem as if you're looking at it through a hole in a template; you can "steer" it or resize it just as you usually do with a still. You can do a zoom in or out on the video, or pan from side to side.
    Use this to sharpen your story visually. Have fun with it.

  • I need help in using Presenter 9 Video Creator

    I'm struggling to get started with Adobe Presenter 9 Video Creator.
    I need detailed, step-by-step instructions but the information that I have been able to find is far too sketchy. I have looked in the "Presenter Help and Tutorials" and I have looked at several video tutorials on You Tube but none of them given me the detail that I need.
    If anyone can help directly or can point me to good sources of information, please let me know.
    With thanks,
    Gerry

    Many thanks for this. It helps a bit but what I'm needing is a proper manual with details of how things are done, possible snags and how to deal with them.
    I have now had a bit of help from someone from Adobe and I may now be able to get round the things that were holding me up.
    Thanks again.
    Gerry

  • Moving from Linux to Final Cut Pro, Need Help Creating Same Mpeg-4 videos

    I am seeking to move into Final Cut Pro to develop these types of videos that I have previously been creating in Linux.
    How can Final Cut Pro make these videos in the format specified below (OR VERY CLOSE TO IT)?
    Please let me know what settings with screenshots, etc. will make final cut pro output in this way.
    MINIMUM output requirements Video codec: Mpeg-4 (divx) with 2400 vbitrate, Audio Codec: MP3 and File container .avi
    I look forward to your help, below are the details I've used in Linux, so please help me create these videos using Final Cut Pro.
    I need this information by the end of the week.
    Thanks!
    To Convert from a captured uncompressed video to MPEG-4 (Divx) with MP3
    audio at 2400 bits using mencoder
    http://www.mplayerhq.hu/DOCS/man/en/mplayer.1.html
    mencoder -ffourcc divx capture002.avi -oac mp3lame -ovc lavc -lavcopts
    vcodec=mpeg4:vbitrate=2400:v4mv:mbd=2:trell:cmp=3:subcmp=3:mbcmp=3:autoaspect:vp ass=1
    -vf harddup -noskip -mc 0 -o test.avi
    -------------VIDEO ------------
    Video Encoded to Codec (MPEG-4) with ffourcc divx (divx4)
    Video Bitrate = 2400 (vbitrate=2400),
    Allow 4 motion vectors per macroblock (slightly better quality) (v4mv)
    Motion estimation=2 (mbd=2)
    Trellis searched quantization. This will find the optimal encoding for
    each 8x8 block. Trellis searched quantization is quite simply an optimal
    quantization in the PSNR versus bitrate sense (Assuming that there would
    be no rounding errors introduced by the IDCT, which is obviously not the
    case.). It simply finds a block for the minimum of error and lambda*bits.
    (trell)
    Sets the comparison function for full pel motion estimation (cmp=3)
    Sets the comparison function for sub pel motion estimation (subcmp=3)
    Motion Search Algorithm (mbcmp=3)
    Same as the aspect option, but automatically computes aspect, taking into
    account all the adjustments (crop/expand/scale/ etc.) made in the filter
    chain. Does not incur a performance penalty, so you can safely leave it
    always on. (autoaspect)
    Activates internal two (or more) pass mode, only specify if you wish to
    use two (or more) pass encoding. (vpass=1)
    duplicate frames (harddup)
    no skipping (-noskip)
    ------------- AUDIO ------------
    Audio Encoded to Codec (MPEG-3)
    ------------- FILE CONTAINER ------------
    File Container (.avi)
    DOCUMENTATION FOR MENCODER
    http://www.mplayerhq.hu/DOCS/man/en/mplayer.1.html#GENERAL%20ENCODING%20OPTIONS% 20(MENCODER%20ONLY)

    I need this information by the end of the week.< </div>
    Not likely.
    Easiest solution is to produce your edited material in FCP and then move the fully rendered, self-contained movie, in whatever format you are producing, to your Linux machine and use its encoder/transcoder.
    Compressor will do the job for MP3 and MP4 but you will need to purchase the DIVX codec or transport it to your Mac. You need to talk to DiVX and you need to open the manual for Compressor. Compressor is not easy to learn how to use i na day but whatever you were using on your Linux box was much more difficult to learn.
    bogiesan

  • NEED HELP!! ICHAT & SKYPE video screwed. QTPRO&ImovieHD video fine!

    Unable to get help from apple support. Can't figure out how to fix video problem with isight, ichat & skype. the image is broken up into vertical lines like looking through glass. This is a recent problem. However, ichat and skype work fine with a camcorder. How can this be?
    Image is perfect on qtpro & Imovie HD as well as Quicktime Broadcaster.
    Support wanted me to reinstall 10.3.5 over 10.3.9 and to preserve settings. Recently installed isight update 1.0.3 and a few programs on apple website.

    Hello pickmynose
    Whenever a user is having as much difficulty as you are, I suggest you keep your important files backed up regularly. If you have not backed up recently, now would be a good time. Then, on to your issue.
    Unable to get help from apple support.
    Support wanted me to reinstall 10.3.5 ...
    Sounds like they are trying to help. Why have you not tried their suggestion?
    ... image is broken up into vertical lines like looking through glass ...
    ... ichat and skype work fine with a camcorder ... How can this be?
    ... Image is perfect on qtpro & Imovie HD ... Quicktime Broadcaster...
    The fact that your iSight "image is broken up into vertical lines like looking through glass" while "ichat and skype work fine with a camcorder" coupled with your assertion that "Image is perfect on qtpro & Imovie HD as well as Quicktime Broadcaster" leads me to think (as apparently do "apple support") that you have a software problem.
    If you do not want to try the suggestion offered by "apple support", consider
    applying the Mac OS X Combined Update 10.3.9. Repair permissions immediately before and after updating.
    Users have reported fixes to a variety of audio, video, connectivity, and software conflicts and unreliability issues after properly applying Combo Updates.
    Although you report that "Image is perfect on qtpro ...", the fact that you are post this problem
    http://discussions.apple.com/message.jspa?messageID=4153016#4153016
    about using QT Pro, have added "a few programs on apple website," and list several accessory devices in your system information leads me to wonder if you might have a Possible hardware or software conflict. Unplug, uninstall, and disconnect everything possible while you check for potential conflicts.
    I see from another of your posts that you were using FileVault. FileVault Can Affect Performance on any application that writes to disk. Turn off FileVault, at least while you are troubleshooting and until you get things working properly. I only turn FileVault on while my laptop Mac is in transit or not in my possession. I turn FileVault back off while I use it. This takes some time, but saves a lot of trouble.
    Seemingly unrelated problems in multiple applications or operations can sometimes be a symptom of a startup disk that needs more free space or some other Mac OS X Maintenance. Perform maintenance now unless you know your maintenance is up to date.
    Finally, try any relevant suggestions you have not already tried from Apple's How to Troubleshoot iSight kbase article. Sometimes strange problems occur in only one user account. Test to see whether the problem is resolved if you start a new user account.
    If you still have the problem, unless you get better suggestions here, I think you should contact your Apple-Authorized Service Provider for professional service.
    Jim
      Mac OS X (10.4.9)    G5 DP 1.8  External iSight

  • Need help timing titles on black video

    Here is what I’ve been doing but maybe there is another (better way) to do it… I select Black Video from Edit and it automatically shows up at the beginning of the timeline. Next I select Title from Edit and type the title, intros, etc. The title will play for 4.5 seconds, but the Black Video will play longer or shorter (if I increase or decrease the duration). I would like to be able to increase or decrease the duration of the title within black video.  Like have the title, intros, etc., fade in and out on a black background after so many seconds. Thanks for any and all help.

    Possibly an easier way to do what you want is to not use the Black Video beneath your Titles. So long as you do not change the background of the Title, you will get black.
    Now, in Timeline View Mode, use a small segment of Black Video. Normally, I start all Timelines with 02 sec. of Black Video for a couple of reasons. I create the Black Video (New Icon>Black Video) and then Dbl-click it to open it in the Source Monitor. There, I set the Out Point, so that I get 02 sec. Duration. I drag this to the start of the Timeline. Then, create you Titles as needed, and place them behind the Black Video on the same Video Track. If you wish another Title Duration, than the default, in Edit>Preferences>General, set the Duration for Still Images (note - this is in Frames, so you might need to do a bit of math). Between your Titles, use the Dip-to-Black Transitions. You will get the same effect as having the Titles over Black Video.
    Hope that this is what you need, and that this helps,
    Hunt

  • I need help on drawing a circuit

    Hi im a student and relatively new to Multisim. I need to draw a circuit that shows a PIR sensor connected up with 12V relay that's it connected to 85 LED's at 3.5V 20mA. The LED's contain a resistor of 1K ohms every 3 LED's. My power supply is a 12V battery.
    If anyone could put me in the right direction for drawing this circuit it would be much appreciated.

    Hello,
    If you're looking for components, go to the component selector window (ctrl+w), there you'll find LEDs under the Diode group, and resistors under Basic. There is alot of helpful resources on how to use MultSIM here on the NI website. You'll find kownledge base articles, tutorials, labs, and help pages.
    http://sine.ni.com/psp/app/doc/p/id/psp-412
    Best of luck with your studies,
    Miguel V
    National Instruments

Maybe you are looking for

  • Help needed on installation of Oracle 9i EE on Sun Solaris 8

    Hey, Help needed on installation of Oracle 9i EE on Sun Solaris 8. The problem I met was: we followed the installation guide from the documentation. And we selected the choice "install software only". After it was done successfully, we run Database C

  • Fix found: Illustrator CS3 (PC) crashes when opening file or starting new file

    Issue: -Running Windows XP, tried installing CS3 Web premium on a new machine. -All programs worked well except Illustrator; when opening a file or creating a new one, illustrator would crash and give a message of "Microsoft has experienced an error"

  • CJ20N tcode in display mode

    Dear Experts, I have a task step in workflow. I use a BO method in it . In that method I need to write code to open CJ20N tcode in display mode. I want to know is there any tcode to display CJ20N in display mode. If yes then using call transaction i

  • Keynote '09: 2 transition effects per slide initiated by 2 hyperlinks?

    I want to do a flip book.  So far it looks great. I'm using forward and back hyperlinks to transition b/w slides. Problem: I can only get one style of transition effects/slide, so when I flip back to a previous slide the flip animation looks like I'm

  • Dual Apple (metal) 20-inch monitors different colours... why?

    Hi, I have 2x 20 inch monitors. One I bought 9 months ago and the other just recently. I have them both set-up using the same ICC calibration profile (the factory default). My problem is that the newer monitor has more vivid colours. Shouldn't they b