How to draw a jerarchical tree in ASCII ??

Hi guys, I've been stuck in a small project of mine about organizational diagrams.
The idea is to produce a tiny domain specific language to describe a hierarchy of
entities in a organization. Like manager, offices, departaments, etc
So far the language part is already implemented parsing the input and creating
the hierarchy of this type
type unidad = {
name : string;
mutable parent : unidad option;
mutable children : unidad list;
the implementation language is Ocaml, the style of the hierarchy is procedural so we can treat
it as a C struct like this (I'm not experienced in C, maybe this struct definition is invalid...)
struct unidad {
char* name;
struct unidad* parent;
struct unidad** children;
the second phase is to draw some form of representation. Initially it was supposed this representation
be in ASCII. Here is an example of output (sorry the stupid example):
father
|
| | |
son girl boy
| | |
------- --------- |
| | | | |
dog cat doll bob-spongeball puppet
|
| | |
kitty spider homer
So far I'm short of ideas how to do this. I've tried in paper travelling from bottom nodes,
and mark every node as an offset (against an absolute columnt i don't know... see).
Say i reach to the last level and start with kitty, probe the parent, doll and mark it's
offset as 0, now mark it's children, kitty -1, spider 0 and homer 1, and now I know that
we need to go up... and then my head explodes...
Is there anyone who could enlighten me, designing an algorithm to draw this hierarchy ?

Tillotson wrote:Is Ocaml popular in Chile, how did you come to use it?
nah, I don't think so.
I am not that experienced guy to know the interests of people
into the languages field. I mean, I went to a 'good' university here and
sucked a lot because school was real easy that I had time to drink, being in
another planet... and stuff like that, but when the exigence
demanded to be constant I just couldn't handle it. Besides, topics
like economy or 'engineering' coming next year at that time scared
me more because I was really INTO my thing about computers. So I
dropped university with a really nice depression and got more
obsessed with knowledge (I have found this true, when you are sad
your mind is shouting more and more, beging for ideas to make sense of
your interests). This is how slowly my picture about the technical
side of the field has sharpened -languages more that anything else-...
I got interested in Turing as the man at that time, read one or
two papers of him and some revisions about his ideas, just to note
that it pervades computing (at that time I was a little paranoid) and
people actually keeps trying that path from different angles.
I've always been obsessed with programming-languages since I have a notion
of computation. So reading about Turing naturally took me to the theorical
side with references to some functional-or-like-that, lisp-or-like-that,
ml... you know.
As far of young people here, I don't believe their interests are
that independent to learn and explore Ocaml (even functional
programming is like voodo) because it's obvious when I try to talk to
teachers about the actual 'esoteric' paradigm I'm
fascinated with they don't want to involve.
Popular here would be C, php, social-shit,
networking as both consummers and theorists. That's my narrow vision
when this ideas haunt me at times.
So my idea is that they just do and think whatever their curricula
builds them in their heads. Yeah, it is a miserable
thought, I don't know, I just let my fixation with things like
this (languages) be my education -the real one- but I'm scared, I'm 24 and
I fear that when I finish university in this 2nd-or-3rd intent I'll get
jobs that make me neurotic and more miserable, typical web or repairing
houses jobs, thinking why I can't produce something interesting to sell.
I've found myself mentioning this discourse several times when talking to
people with my communication skills and irritability as an impediment.
Do you think I'm pedantic?, I mean when assisting to a shrink last year
we got to this theme and she attacked me -psichological tactic I think-
to the point it was patetic, me declaring 'I know nothing' but at the
same time it is clear that exploring things by your own gives you a
boost, an identity and a sense of being where you really want.

Similar Messages

  • Drawing a binary tree

    Hi guys ;
    I'm trying to write a Java GUI that draws a binary tree on a JPanel.
    the tree is dynamically filled while user is inserting nodes.
    I need a quit robust Implementation so that the tree is properly drawn with lines connecting nodes and most IMPORTANT ; the panel can expend to fit the tree (dynamically).
    can any one tell me how to get started ?
    Many thanks !

    My advice is to use a graphics framework, e.g. look at Piccolo:
    http://www.cs.umd.edu/hcil/piccolo/index.shtml
    If you put your panel in a piccolo scrollpane it will be able to expand in all directions, something that is very hard to achieve otherwise.
    OTOH Piccolo is not a dedicated graph framework (which knows about the distinction of nodes and edges and how to connect them). It comes with an example, though how to implement that.
    There are more dedicated graph frameworks, e.g. JGraph:
    http://sourceforge.net/projects/jgraph/

  • How to construct the component tree in my custom component?Help!

    Hi, i am writing a custom component like this:
    public class HtmlCategory extends HtmlPanelGrid
         public void processRestoreState(javax.faces.context.FacesContext context,
                java.lang.Object state)
              setColumns(1);
              HtmlCommandLink link=new HtmlCommandLink();
              link.setValue("Let's Bingo");
              MyUtil.setActionListener(context,link,"#{temp.mytest}");
              UIParameter param=new UIParameter();
              param.setName("name");
              param.setValue("Robin!");
              link.getChildren().add(param);
              param.setParent(link);
              getChildren().add(link);
              link.setParent(this);
              super.processRestoreState(context,state);
    }         you see, i want to construct the compont tree at Restore View phase this way,because the structure of the component tree will always be the same, so i don't the user to write extra code.
    But the children of the component are not rendered,the renderer of the HtmlCategory component just extends the HtmlGridRenderer(myfaces) directly,and always calls the "super" methods in the encode methods of the renderer.
    I got a message from the console:
    Wrong columns attribute for PanelGrid id0:id4: -2147483648
    but i have set the columns attribute in the code above, so what's happening? or please give some advice about how to render the component tree by myself in Restore View with the tree constructing code in the custom component class code,just lke the code above.
    Best Regards:)
    Robin

    Well, i don't know if i have got my question clear.
    usually, according to the tags you use in the jsf page, a component tree will be created at the Restore View phase,for example:
    <f:form>
      <h:panelGrid ...........>                         
              <h:dataTable ................>
              </h:dataTable>
       </h:panelGrid>
    </f:form>but because i am writing a component for my web app, all the child components and their attributes are not likely to change. so i want to reduce the tags into one custom tag, and construct the component tree internally by myself.But it is not the case of backing bean.So i wrote the the code in the method:
    public void processRestoreState(javax.faces.context.FacesContext context,java.lang.Object state)as it is shown in my orginal message.But it seems that it is not right way to construct my component tree.So where should i put the code that construct the component tree?Overriding the method :
    public void processRestoreState(javax.faces.context.FacesContext context,java.lang.Object state)is not the right way?
    Best Regards:)
    Robin

  • How to draw horizontal line in smartform after end of the all line items

    Hi Friends,
    I am working on the smartform. I have created TABLE node in Main window.
    i want to draw a horizontal line after end of the main window table node. i mean after printing all the line items of the table, I need to print one horizontal line.
    Could you please help me how to resolve this issue.
    FYI: I tried with the below two options. But no use.
    1. desinged footer area in the table node of the main window.
    2. tried with uline and system symbols.
    please correct me if i am wrong. please explain in detail how to draw horizontal line after end of the main window table.
    this is very urgent.
    Thanks in advance
    Regards
    Raghu

    Hello Valter Oliveira,
    Thanks for your answer. But I need some more detail about blank line text. i.e thrid point.
    Could you please tell me how to insert blank line text.
    1 - in your table, create a line type with only one column, with the same width of the table
    2 - in table painter, create a line under the line type
    3 - insert a blank line text in the footer section with the line type you have created.

  • How to draw text vertically, or in an angle

    please help me how to draw text vertically, or in an angle

    I robbed the framework from Dr Las or 74phillip (don't remember which) ...
    import java.awt.*;
    import java.awt.geom.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class AngleText extends JPanel {
      private int      degrees = 16;
      private JSpinner degreesSpinner;
      public AngleText () {
        setBackground ( Color.WHITE );
      }  // AngleText constructor
      protected void paintComponent ( Graphics _g ) {
        super.paintComponent ( _g );
        Graphics2D g = (Graphics2D)_g;
        g.setRenderingHint ( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
        AffineTransform at = AffineTransform.getRotateInstance ( Math.toRadians ( degrees ) );
        Font f =  g.getFont();
        g.setFont ( f.deriveFont ( at ) );
        g.drawString ( "Rotating Text!", getWidth()/2, getHeight()/2 );
        g.setRenderingHint ( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF );
      }  // paintComponent
      public JPanel getUIPanel () {
        SpinnerModel degreesModel = new SpinnerNumberModel (
                                      degrees  // initial
                                     ,0        // min
                                     ,360      // max
                                     ,2        // step
        degreesSpinner = new JSpinner ( degreesModel );
        degreesSpinner.addChangeListener ( new DegreesTracker() );
        JPanel panel = new JPanel();
        panel.add ( degreesSpinner );
        return panel;
      }  // getUIPanel
      //  DegreesTracker
      private class DegreesTracker implements ChangeListener {
        public void stateChanged ( ChangeEvent e ) {
          Integer i = (Integer)((JSpinner)e.getSource()).getValue();
          degrees   = i.intValue ();
          repaint();
      }  // DegreesTracker
      //  main
      public static void main ( String[] args ) {
        JFrame f = new JFrame ( "AngleText" );
        f.setDefaultCloseOperation ( JFrame.EXIT_ON_CLOSE );
        AngleText app = new AngleText();
        f.getContentPane().add ( app );
        f.getContentPane().add ( app.getUIPanel(), BorderLayout.SOUTH );
        f.setSize ( 200, 200 );
        f.setVisible ( true );
      }  // main
    }  // AngleText

  • How to draw vertical lines in SMART FORMS

    Hi Guys,
    Can anyone please let me know how to draw vertical and horizontal lines in smart forms, i have to do this in the secondary window.
    thanks,
    Ramesh

    Hi Ramesh,
    In the window output options you have option of check box to get lines.
    Then you need to give the spacing for vertical and horizontal.
    Another option is putting a template on window and getting the boxes, but it is quite little bit complex.
    Put the cursor on the WINDOW in which the lines you want.
    Right click on it>create>complex section.
    In that select the TEMPLATE radio button.
    Goto TAB TEMPLATE.
    Name: give some name of line.
    From: From coloumn.
    To: To coloumn
    Height: specify the height of the line.
    Next give the coloumn widths.
    Like this you can draw the vertical and horzontal lines.
    If the above option doesnot workout then u can try the below option also
    any how you can draw vertical and horizontal lines using Template and Table.
    for Template First define the Line and divide that into coloumns and goto select patterns and select the required pattern to get the vertical and horizontal lines.
    For table, you have to divide the total width of the table into required no.of columns and assign the select pattern to get the vertical and horizontal lines.
    if this helps, reward with points.
    Regards,
    Naveen

  • How can i call a tree from a subvi?

    I have a subvi which build a tree and give as an output a reference to it.
    how can i display that tree on the front panel of a main vi. for instance press a button on the main front panel esecutes the subvi and display the tree on the main front panel.
    thank you
    diego

    Hi
    Put tree control on front pane of main.vil, create his (of control) reference and send it to your subVI
    Eugene 

  • I would like to know how to draw up a list in a cell (like a pull-down menu) to ease data capture, but I don't know how to do that  ! Do you get the idea ? Thanks !

    I would like to know how to draw up a list in a cell (like a pull-down menu) to ease data capture, but I don't know how to do that  !
    Do you get the idea ?
    Thanks ever so much !

    the numbers manual can be downlaoded from this website under the Apple support area...
    http://support.apple.com/manuals/#numbers
    What your looking for is written out step by step for drop downs and all other special types of user input starting around page 96 in the '09 manual.
    Jason

  • How to draw horizontal line at the end of table for multiple line items

    Dear Experts,
                       Pls can anyone help me how to draw horizontal line at the end of table for multiple line items . kindly help me regarding this
    Thanks
    Ramesh Manoharan

    Hi
       I tried as per your logic but it is not solving my problem .  when i am gone to table painter it is showing line type 1 and line type 2
      is below format.. if u see here line type 1 bottom line and line type 2 top line both are same..  so how to avoid this ?
                              line type 1
                             line type 2

  • Please Help(How to get RadioButtons in tree View)

    Hi.
    Sub/Requirement: How to implement RadioButtons in tree view with/without using xml file.
    I have a requirement like this i want to display RadioButton in tree view.
    I implemented tree same as which is given in sampleApplications.
    In this sampleApplications they implemted tree by using xml file.
    I also implemented tree by Generating xml file. In this xml file i get the values from the database. I am using <netui:tree > tag.
    Is it possible to implement tree without using xml file. I need to generate tree Dynamically.
    Please any one help me to come out with this solution.

    The issue here is while you are retrieving all the details, you are consistently overwriting them in the request.setAttribute() call before you get to the JSP to display them.
    Do you actually have a class/object called Student?
    That object should have attributes for classes, subjects, teachers (all of which are lists apparently)
    public class Student{
      String name;
      List classes;
      List subjects;
      List teachers;
      // appropriate getter/setter methods
    }Then you load each student, and populate its individual lists.
    That lets you pass the list of students, each student having its own lists for display.
    Hope this helps,
    evnafets

  • How to draw table in layout in module pool

    how to draw table in layout in module pool with wizard or table control

    Hi
    Goto Screen Painter .
    here we can create table in 2 ways,
    with wizard and without wizard.
    with wizard it will step by step...
    for without wizard (its quite easy)
    Click Table control and Drag into ur screen.
    then --> click input box and place into to that table control
    for two column do this two times.
    then for header click the text icon in left side and drag into
    correspoding places .. then ur table is ready..
    then give names using double clicking the elements
    See the prgrams:
    DEMO_DYNPRO_TABLE_CONTROL_1 Table Control with LOOP Statement
    DEMO_DYNPRO_TABLE_CONTROL_2 Table Control with LOOP AT ITAB
    Reward if useful.

  • How to get the current tree element (node/childnode/childnode/...) ?

    Hello!
    I'm trying to create a kind of a navigation tree for my application.
    It should represent some elements of an XML structure and some other nodes for other options.
    The binding with the context is not a problem, I can create the tree up to all the levels I want to.
    The problem now is, that I don't know, how to get the "current tree element", when there is any action.
    For example:
    public void onActionSelect(...) {
    String test = wdContext.currentTreeNodeElement().getText();
    wdThis.wdGetContext().currentContextElement().setSelectedElement(test);
    With this method I can get the text of the "first level nodes". If I want to get the "second level node", I can do
    String test = wdContext.currentTreeNodeElement().currentChildElement.getText();
    ..and for the next levels so on.
    Isn't there any general method to get the information of the selected element without knowing before, whether it is a nodeElement or a nodeElement.currentChildElement or a nodeElement.currentChildElement.currentChildElement, ...?
    Greetings,
    Ramó

    Hi,
    if you following that pdf ,
    i think your not implemented the below code in DomodifyView method
    if (firstTime) {
          IWDTreeNodeType treeNode = (IWDTreeNodeType) view.getElement("TheNode");
          /* The following line is necessary to create parameter mapping from parameter "path" to parameter "selectedElement".
    Parameter "path" is of type string and contains the string representation of the tree element (its corresponding context element to be exact)
    that raised the onAction event. Parameter "selectedElement" is of type IWDNodeElement (or extends it) and is defined as parameter in the event handler
    that handles the onAction. The parameter mapping defined here translates the String "path" into the corresponding context element that then can
    be accessed within the event handler
          treeNode.mappingOfOnAction().addSourceMapping("path", "selectedElement");
          /* The following line is necessary to create parameter mapping from parameter "path" to parameter "element".
    Parameter "path" is of type string and contains the string representation of the tree element (its corresponding context element to be exact)
    that raised the onLoadChildren event. Parameter "element" is of type IWDNodeElement (or extends it) and is defined as parameter in the event handler
    that handles the onLoadChildren. The parameter mapping defined here translates the String "path" into the corresponding context element that then can
    be accessed within the event handler
          treeNode.mappingOfOnLoadChildren().addSourceMapping("path", "element");
    please cross check once.
    Thanks,
    Ramesh

  • How to Draw 3-D scatter plot in J2ME?

    HI all
    I am new in J2ME And I need to draw a three dimensional scatter plot in J2ME application. Can any body help me how to do so? It's urgent and I am eagerly waiting for your response. Even if you can tell me how to draw a 3-D point like (x,y,z)=(3,5,8) in J2ME?

    I've removed the thread you started in the Java3D forum.
    db

  • How to draw 2D shapes on the image generated by JMF MediaPlayer?

    Hello all:
    IS there any way that we can draw 2D shapes on the image generated by JMF
    MediaPlayer?
    I am currently working on a project which should draw 2D shapes(rectangle, circle etc) to
    mark the interesting part of image generated by JMF MediaPlayer.
    The software is supposed to work as follows:
    1> first use will open a mpg file and use JMF MediaPlayer to play this video
    2> if the user finds some interesting image on the video, he will pause the video
    and draw a circle to mark the interesting part on that image.
    I know how to draw a 2D shapes on JPanel, however, I have no idea how I can
    draw them on the Mediaplayer Screen.
    What technique I should learn to implement this software?
    any comments are welcome.
    thank you
    -Daniel

    If anyone can help?!
    thank you
    -Daniel

  • How to refresh the ALV Tree

    Hi,
    I have an ALV Tree report developed using the OOPS. In my ALV Tree output, I have some buttons which will update the database after clicking. The data is correctly updating in the database. But, it is not getting updated in the ALV Tree display. That means, it is not REFRESHing the ALV Tree display. We have to again execute the program in order to see the updated output.
    Could anyone please suggest me how to Refresh the ALV Tree display..?
    We can't use the method 'REFRESH_TABLE_DISPLAY' as it is a PRIVATE method is the class CL_GUI_ALV_TREE.
    Please share your valuable thoughts.
    Thanks & Regards,
    Paddu.

    Hi paddu.
    please check out the link mentioned below,this will help u.
    How to Refresh data on ALV tree
    Regards
    Theres

Maybe you are looking for

  • Calling a web service from a portal application / SOAP Action

    Hallo, Ich möchte aus einer Portal Applikation auf einen Web Service zugreifen. Dafür habe ich mit dem Wizard "Portal Service from Wsdl file - Client side" eine Portal Service erzeugt, auf den ich dann zugreife. Leider wird dabei ein Fehler ausgegebe

  • Macbookpro imessage contact names not listing - just numbers

    Hi there, I'm starting a new thread about this because everything I have read through has confused me. I just had a new hard-drive installed on my Macbook Pro (mid 2009) and Mavericks installed. All is great, BUT I can't get names to show up on my iM

  • ITunes Match freezes PC during Step 1!?!?!

    I am running Windows Vista on my PC and purchased iTunes Match to put my music collection in the cloud.  3/4 of the way through Step 1, iTunes freezes and so does my computer.  I have to unplug my computer (which is definitely not healthy for it) and

  • Late 2008 macbook, want to connect to apple tv

    what program do i need to connect to my apple tv, i guess i need something to run mirroring

  • Maintaining Cell Style with data update

    Having a difficult time trying to maintaining the styles and characteristics (built in ID) of a table from Excel when we update the link to refresh the data.  I have read old threads and went through the proper process of creating; Character, then Pa