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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:01:47+00:00 2026-06-02T15:01:47+00:00

When adding nodes to my DelegateTree , they don’t appear visually in the order

  • 0

When adding nodes to my DelegateTree, they don’t appear visually in the order I added them.
I’ve been looking for a solution, but haven’t found anything yet.
Is there anyone who might know how to change this?

Thanks in advance!

EDIT: My code

/**
 * Generate a visualization of the decision tree.
 * 
 * @param tree
 *            The decision tree
 * @return A component to be placed inside a JPanel
 */
public static GraphZoomScrollPane generateTree(Tree tree,
        GraphicalUserInterface gui) {

    /* Create a new tree */
    DelegateTree<Node, Edge> graphTree = new DelegateTree<Node, Edge>();

    /* Add all nodes and vertices to the tree */
    graphTree.addVertex(tree.getRoot());
    addChildren(tree.getRoot(), graphTree);

    /* Create the visualization */
    DynamicTreeLayout<Node, Edge> treeLayout = new DynamicTreeLayout<Node, Edge>(graphTree, 100, 100);
    VisualizationViewer<Node, Edge> vv = new VisualizationViewer<Node, Edge>(
            treeLayout);
    vv.setDoubleBuffered(true);
    vv.setBackground(Color.WHITE);
    vv.getRenderContext().setEdgeLabelTransformer(
            new ToStringLabeller<Edge>());
    vv.getRenderContext().setEdgeShapeTransformer(
            new EdgeShape.Line<Node, Edge>());
    vv.getRenderContext().setVertexLabelTransformer(
            new ToStringLabeller<Node>());
    vv.getRenderer().getVertexLabelRenderer()
            .setPosition(Renderer.VertexLabel.Position.S);

    vv.addGraphMouseListener(new ClickNode(gui, vv));

    final DefaultModalGraphMouse<Node, Edge> graphMouse = new DefaultModalGraphMouse<Node, Edge>();

    graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);

    vv.setGraphMouse(graphMouse);

    final GraphZoomScrollPane gzsp = new GraphZoomScrollPane(vv);

    return gzsp;
}

/**
 * Recursively add all nodes and edges to the tree.
 * 
 * @param node
 *            The parent node
 * @param tree
 *            The tree visualization
 */
private static void addChildren(Node node, DelegateTree<Node, Edge> tree) {
    for (int i = 0; i < node.getChildren().size(); i++) {
        tree.addChild(new Edge(node.getChildren().get(i).getEdgeLabel()), node, node
        .getChildren().get(i));
        addChildren(node.getChildren().get(i), tree);
    }
}
  • 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-02T15:01:56+00:00Added an answer on June 2, 2026 at 3:01 pm

    Use an underlying implementation for the DelegateTree that either sorts its vertices according to their natural ordering (*Sorted*Graph) or that uses insertion ordering (*Ordered*Graph).

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

Sidebar

Related Questions

I'm adding nodes to my XML document as part some in-house processing, but cannot
I'm adding Nodes to TreeView dynamically. I'm just creating labels and add them to
I am looking for a recipe for adding Drupal node records. I have identified
Adding Exceptional Handling is a good practise, but I have a doubt, In our
Adding the row one by one in the button click.. (i tried but its
Adding strings localization files in iPhone bundle is very simple and perfectly fine but
I have a networkx graph. I am adding nodes by adding edges G.add_edge(route[i-1],route[i]); Now
I'm adding images (nodes) to an HTML5 canvas with the following JavaScript function: function
Given a URL, if it has any RSS nodes, then I am adding to
I'm trying to create a dynamically-updated Prefuse graph, where nodes are added and deleted

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.