Forum Stats

  • 3,837,393 Users
  • 2,262,255 Discussions
  • 7,900,269 Comments

Discussions

Conversion from VisualC++ to Java(AngleArc to drawArc)

User_AYF65
User_AYF65 Member Posts: 135 Red Ribbon
edited Oct 6, 2015 2:02AM in New To Java

Hi,

I want to convert from VC to JAVA. I have AngleArc in VC ( 5 arguments) & drawArc in Java(6 arguments). Their syntax is given below:

drawArc(int xTopLeft, int yTopLeft, int width, int height, int startAngle, int arcAngle);

BOOL AngleArc(   int x,   int y,   int nRadius,   float fStartAngle,   float fSweepAngle);

Instead of width & height they are using only radius. Some body please guide me how to do this conversion.

Zulfi.

Best Answer

Answers

  • Unknown
    edited Oct 4, 2015 2:51PM
    I want to convert from VC to JAVA. I have AngleArc in VC ( 5 arguments) & drawArc in Java(6 arguments). Their syntax is given below:
    
    drawArc(int xTopLeft, int yTopLeft, int width, int height, int startAngle, int arcAngle);
    BOOL AngleArc(   int x,   int y,   int nRadius,   float fStartAngle,   float fSweepAngle);
    
    Instead of width & height they are using only radius. Some body please guide me how to do this conversion.
    

    This is your THIRD thread about basic graphics topics. The forums are NOT a coding service. They are to help you with YOUR code.

    You will NOT be successful if you refuse to read the documentation and then follow tutorials to learn how to use Java functionality.

    If you review the API documentation for those functions you should be able to EASILY see that the width and height refers to a box that a circle/ellipse fits inside. Which means width and height are the DIAMETER.

    Graphics (Java Platform SE 7 )

    https://msdn.microsoft.com/en-us/library/windows/desktop/dd183354%28v=vs.85%29.aspx

    So if you know the diameter you should be able to compute the radius. And if you know the coordinates of the enclosing rectangle you should be able to determine the coordinates of the center of the enclosed circle.

    Then write some sample code and see what the results are.

  • User_AYF65
    User_AYF65 Member Posts: 135 Red Ribbon
    edited Oct 4, 2015 11:47PM

    Hi,

    Thanks for your guidance.

    >So if you know the diameter you should be able to compute the radius. And if you know the coordinates of the enclosing >rectangle you should be able to determine the coordinates of the center of the enclosed circle.


    What about the coordinates x & y? They refer to center of circle in VC but in Java it says upper left corner.


    Please guide me.


    Zulfi.

  • User_AYF65
    User_AYF65 Member Posts: 135 Red Ribbon
    edited Oct 5, 2015 1:11AM

    Hi,

    In VC i was using the command:

    pDC->AngleArc(90,124,10,30,150);

    In JAVA I tried:

    g.drawLine(0,250,0,160);

       g.drawLine(0,160,30,200);

       g.drawLine(30,200,80,120);

       g.drawArc(90,124,20,20,30,150);

    g.drawLine(99,119,150,180);

    This is what I am getting:

    Java Arc.png

    Some body please guide me.

    Zulfi.

  • Unknown
    edited Oct 5, 2015 12:10PM
    Please guide me.

    I did guide you - to The Java Tutorials trails that SHOW you , with working code, how to draw graphic objects in Java.

    And if you know the top, left corner of the square that encloses a circle you should be able to EASILY compute where the center of the circle is.

    There are NO SHORTCUTS. You have to be willing to WORK and try things.

    Draw that square. Draw a circle. Is the circle totally inside the square? Then move the circle up or down as needed as redraw it.

    You learn by DOING. Go through the tutorials and actually DO the examples.

  • User_AYF65
    User_AYF65 Member Posts: 135 Red Ribbon
    edited Oct 5, 2015 1:44PM Answer ✓

    Hi,

    I am able to solve this problem through trial & error method. Though i have to change the values but i have kept the angles constant.

    Zulfi.

  • User_AYF65
    User_AYF65 Member Posts: 135 Red Ribbon
    edited Oct 5, 2015 1:46PM

    Hi,

    >Draw a circle.

    There is a command for oval but no command for circle. Plz guide me how to draw a circle in Java.


    Zulfi.


  • Unknown
    edited Oct 5, 2015 6:12PM
    I am able to solve this problem through trial & error method. Though i have to change the values but i have kept the angles constant.
    

    Good for you! That wasn't so hard was it?

    When you TRY things you get a lot more feedback than you will ever get on the forums because you can SEE the result of what you did.

    Then you can change it a little bit and SEE how it is different. That visual feedback is what you MUST HAVE when you work with graphics. Very few people can 'visualize' graphic objects just by looking at a bunch of coordinate values.

    Especially with graphics you aren't going to break anything by trying stuff.

    You should now be able to create a simple program that draws your object and then AUTOMATICALLY changes each attribute, one at a time in a loop, and shows a 'movie' that shows how the object changes.

  • TPD-Opitz
    TPD-Opitz Member Posts: 2,465 Silver Trophy
    edited Oct 6, 2015 2:02AM

    what is the difference between an oval and a cycle in a mathematical sense?

    bye

    TPD

This discussion has been closed.