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 8629249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:45:23+00:00 2026-06-12T08:45:23+00:00

I have a java component on which I draw 100 by 40 rectangles to

  • 0

I have a java component on which I draw 100 by 40 rectangles to represent nodes of a graph. When a new node is added, I would like to be able to position it in a useful position. Currently, I simply choose the next available space on the x-axis. However, this means when I load a graph, I get a large chain of nodes spanning off the view to the right – not ideal!

A better solution may involve adding a node at the point closest to the center-point of the user’s view. I’m sure there are many solutions to this problem I am unable to think of a reasonable way to achieve this.

I have three methods that are relevant to this problem:

positionNode(Node) // which tries to find suitable x,y to place a node
setPos(x,y) // which moves a node to the respective position
findElementAt(x,y) // which returns a node's model if such a node exists at (x,y)

A potential solution may somehow involve spiraling around the center point but I am unable to imagine a good solution for performing this.

  • 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-06-12T08:45:25+00:00Added an answer on June 12, 2026 at 8:45 am

    Graph rendering is a hard problem which is the subject of a lot of research.

    If you want to make the nodes into a sort of a bundle, rather than a line of nodes, the main disadvantage will be that lines coming out of the nodes will get overlapped by the other children.

    You can make a square bundle or a round bundle. To make a square bundle, take the square root of the number of nodes and add one. For example, if you have 17 nodes, the sides of the square is 4 + 1 = 5. So you have a 5 x 5 square. Position each node in a cell of the square.

    To make a round bundle draw concentric circles. So first node is at center. Then calculate an imaginary circle around that node. Divide the circle into segments by degrees according to how much space you need. Then locate each additional node in the center of each segment.

    Note that you might want to overlap nodes. Depending on how your interface works, overlapping might allow you to fit more nodes in.

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

Sidebar

Related Questions

I would like to have a Java component which has a resize icon on
I would like to have a reusable ui component which is tied to the
I have a Java application which uses a third-party COM component through a Java-COM
I have java program which receives encrypted message through TCP/IP from one component of
I have a server java component which has a huge memory demand at startup
I have a Component which I am using both in a standalone Java application
I just learned (the hard way) that Java Component s can only have one
I have Java application which sends pointer to function (callback) to some native dll
in Java I have a HTTPClient which use Headers in a POST Method with
I have developed some reusable android component which is basically a class . This

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.