473,387 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Display nodes in the specified structure

Ive got to display node based on the selected level...

Suppose the structure is as follows

A
-> B
->D
->E
->E1
->H
-> C
->F
->G

J
->K
->L
->M
->N
->O

HOW DO I DISPLAY IT IN THIS STRUCTURE WITH THE CORRESPONDING SPACE FOR EACH LEVEL?
I've done it using hashmap...took each node added it to hashmap and then added it to a collection.then its child node added it to hashmap and then to collection and so on...


doing so ive got the tree in the required order of display.
now how do i insert the appropriate space for each node corresponding to each level.?
ie,for level 1 node i,ve to insert 1 space
for level2 nodes i,ve to insert 2 space and so on
Mar 1 '07 #1
6 1103
r035198x
13,262 8TB
Ive got to display node based on the selected level...

Suppose the structure is as follows

A
-> B
->D
->E
->E1
->H
-> C
->F
->G

J
->K
->L
->M
->N
->O

HOW DO I DISPLAY IT IN THIS STRUCTURE WITH THE CORRESPONDING SPACE FOR EACH LEVEL?
I've done it using hashmap...took each node added it to hashmap and then added it to a collection.then its child node added it to hashmap and then to collection and so on...


doing so ive got the tree in the required order of display.
now how do i insert the appropriate space for each node corresponding to each level.?
ie,for level 1 node i,ve to insert 1 space
for level2 nodes i,ve to insert 2 space and so on
Perhaps if you give an example of what you want to do?
Mar 1 '07 #2
Perhaps if you give an example of what you want to do?
ie,,if i choose level 1 i must get the structure as
A
J
if level=2
the structure becomes
A
B
C
J
K
M
if level=3
the structure becomes
A
B
D
H
C
F
J
K
L
M
N

i want to get the logic to include those blank spaces according to the level chosen

now if i select level 3 im getting the output as
A
B
D
H
C
F
J
K
L
M
N

I want this structure as the above displayed one....Hope its clear now
Mar 1 '07 #3
r035198x
13,262 8TB
ie,,if i choose level 1 i must get the structure as
A
J
if level=2
the structure becomes
A
B
C
J
K
M
if level=3
the structure becomes
A
B
D
H
C
F
J
K
L
M
N

i want to get the logic to include those blank spaces according to the level chosen

now if i select level 3 im getting the output as
A
B
D
H
C
F
J
K
L
M
N

I want this structure as the above displayed one....Hope its clear now
Which blank spaces are you talking about?
Mar 1 '07 #4
Which blank spaces are you talking about?
sorry the blank spaces are not being shown when i submit the form...
Just imagine a tree structure, child coming under parent...
i just need to distinguish the child and its level from the collection i get
Mar 1 '07 #5
r035198x
13,262 8TB
sorry the blank spaces are not being shown when i submit the form...
Just imagine a tree structure, child coming under parent...
i just need to distinguish the child and its level from the collection i get
Well why din't you try something like

Expand|Select|Wrap|Line Numbers
  1.  for(int i = 0; i < level;i++) { 
  2.   System.out.print(" ");
  3. }
  4.  
Prints one space for level one, two spaces for level two, e.t.c
Mar 1 '07 #6
Well why din't you try something like

Expand|Select|Wrap|Line Numbers
  1.  for(int i = 0; i < level;i++) { 
  2.   System.out.print(" ");
  3. }
  4.  
Prints one space for level one, two spaces for level two, e.t.c
got it

Thankyou.......
Mar 1 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Piet | last post by:
Hi there, I have managed to write a small java program that display an xml file in a JTree. This was achieved by defining a suitable tree model. THe program works...somehow. The nodes (elements...
2
by: Claudio Jolowicz | last post by:
How can XSLT stylesheets be used to edit, remove and add nodes specified by their position in the document tree? The XML document stores development tasks in a hierarchical way, i.e. tasks can...
7
by: fremenusul | last post by:
I know I have been asking LOTS of xml questions and I really apprecaite all the help. Here is my XML file <?xml version="1.0" encoding="utf-8" ?> <products> <!-- Repeat the structure below...
1
by: Omega375 | last post by:
Hello. I'll first start off by showing the structure of my xml-file. <root> <node path="X"> More nodes containing data </node> </root>
3
by: Earl Teigrob | last post by:
I am considering writing a Class that Selects, Adds, Updates and Deletes Nodes in an XML File but do not what to reinvent the wheel. (See XML file below) That data format would emulate records...
1
by: Estela | last post by:
Hello, i have a big XML file, i load the xml to a xmldocument. My question is, how is the best way to display de information (aspx page). I tryng load the xml into a dataset an then displaying...
7
by: abhrajit | last post by:
I'm looking for a C/C++/Java library to create a balanced binary tree data structure given a set of leaf nodes as input. A leaf node should never become an interior node. So if I wish to create...
7
by: John | last post by:
Hi, Is there any control (free) that has same functionality as IE to display the XML document without having to create a physical file? if using Webbrowser control (ActiveX control) I have to...
24
by: Phil Latio | last post by:
Let's say I have a simple web application running with just two MySQL tables. The tables structure is as follows: Table: category category_id (PK) category_name parent_category (FK)...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.