Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3396226
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:22:57+00:00 2026-05-18T04:22:57+00:00

A program that animates circles is not drawing them fluidly once several hundred are

  • 0

A program that animates circles is not drawing them fluidly once several hundred are drawn at once. It was suggested to use affine transformation to copy the shapes. This code, refactored to use graphics2D, works, but doesn’t cause any performance boost since it is still filling hundreds of ovals. How to use affinetransformation properly to fill a shape once and then copy/move it?


    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        setBackground(Color.WHITE);

    for (int i = 0; i < gameLogic.getParticleArrSize(); i++) {
        Graphics2D g2 = (Graphics2D) g;
        Color color = new Color(6,6,6);
        Ellipse2D oval = new Ellipse2D.Double(
                gameLogic.getParticleXCoor(i),
                gameLogic.getParticleYCoor(i),
                gameLogic.getParticleSize(i),
                gameLogic.getParticleSize(i));
        g2.setPaint(color);
        g2.fill(oval);
        g2.translate(15, 15);
        g2.fill(oval);
  }

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T04:22:58+00:00Added an answer on May 18, 2026 at 4:22 am

    The only way to know which is faster is to profile two or more implementations. As a concrete example, this kinetic model shows a slight advantage for Gradient mode, using drawImage(), over Color mode, using fill(), as seen in the paintComponent() method of DisplayPanel. In this context, AffineTransform is beneficial in pre-rendering the more complex gradient image.

    Addendum:

    I don’t know how to properly implement AffineTransform to move/copy ovals…

    I doubt that AffineTransform is the cure. Instead, move the object creation out of the loop, as @camickr suggests. In the example, note how an Ensemble only needs one Ellipse2D; it uses setFrame() repeatedly. Also, each Particle already knows its Color. Finally, observe how the example measures paint time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small program that has several checkedboxlists in VS2010. I wanted to
I have a program that needs to use sleep. Like really needs to. In
The program that I am currently assigned to has a requirement that I copy
A program that I work on assumes that the UUID generated by the Windows
I have a program that I'm writing where I am using another company's library
This is a test program that I have written for a larger project that
I have a program that should run every night. Another is started every boot.
I have a program that saves images, but when I debug it I get
I've written a program that consists of 3 threads: 2 threads that do something
Bassicly im creating a program that allows the user to enter values and if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.