R-Tree Implementation in d-dimension

Hi
I'd like to know if exists a Java implementation fo R-Tree. I founded something in 2-dimensions, but I need one in d-dimensions.
Thank you.

hi,
take a look at
[http://sourceforge.net/projects/spatialindexlib/|http://sourceforge.net/projects/spatialindexlib/]
Then there is a Lucene which is full-featured text search engine written entirely in Java [http://lucene.apache.org/|http://lucene.apache.org/]
Regards,
Alan Mehio
London, UK
Edited by: alan_mehio on Apr 5, 2008 11:00 PM
Edited by: alan_mehio on Apr 5, 2008 11:02 PM

Similar Messages

  • Internal architecture of R-tree implementation

    Does anyone know where I can get whitepapers which describe the architecture of R-tree implementation in Oracle?
    I need it for my undergraduate thesis. It will be a case study of R-tree implementation in Oracle Spatial. Actually I want to focus on why R-tree is implemented while scientists still shape it into a more applicable and reliable state.
    But ya, if it is too hard, perhaps I will focus on the architecture itself.
    Anyone can help?

    Several papers were published in the last few
    ICDE, SIGMOD and SSTD conferences about how R-trees are implemented in Oracle.
    You can get most of the architecture details from those papers.

  • AVL tree implementation

    Hi all,
    I am interested in an AVL tree implementation in Java. I prefer it to be Open Source. Efficiency is my main concern, although a readable code would be appreciated.
    The question is if it exist a standard implementation or an implementation you know it is stable and efficient.
    thank you in advance,

    prometheuzz wrote:
    The TreeSet and TreeMap implementations from the java.util package are backed up by a red-black tree. So those classes have the same characteristics as an AVL tree: they're self balancing, and insertions and lookups are O(log(n)) where n is the total number of nodes in your tree.
    So, as far as I see, you can use those classes. If not, please explain why you need an AVL tree instead of a proven/reliable class already present in the standard API.Thank you for the answer.
    to be honest, in the past, I rejected the idea of using TreeMap or TreeSet, but I fail to understand (or remember) why.
    The only reason I see at the moment is that I would like the tree notion of child nodes etc, although I can live without that given that I have an efficient implementation in zero-time. :)
    The use of AVL trees is not needed in the implementation, it is just an offspring of the theoretical complexity analysis of what I am about to implement.

  • ExtJS Drag and Drop Tree Implementation

    Hello!
    I found this wonderful example of a drag and drop tree, with the ability to save the changes, but I'm not quite sure how to go about implementing it. Can someone point me in the right direction?
    Thank you,
    Tammy

    Hi Tammy
    My example uses drag and drop also, so the details are there.
    Regarding your question on how to get started:
    Really it's just a case of breaking the problem down into managable parts until you have solved all the pieces.
    Start by implementing the "AJAX form using globals" at http://apex.oracle.com/pls/otn/f?p=200801:2011
    It shows you how to pass data back to the database using AJAX with the WWV_FLOW variables, which are there for exactly that purpose.
    Make sure you also understand the response Ext is expecting, use Firebug to examine the responses in both examples.
    Once your comfortable with that, try loading a tree using an application process.
    You can create stubbed responses initially for the application process, e.g.
    htp.p(^'[{
        "text": "adapter",
        "id": "source\/adapter",
        "cls": "folder"
        "text": "dd",
        "id": "source\/dd",
        "cls": "folder"
        "text": "debug.js",
        "id": "source\/debug.js",
        "leaf": true,
        "cls": "file"
    }]^');From there, add drag and drop calls, replace your stubs with production code...
    I use application processes as a gateway, simply passing requests through to a database package.
    It's not a small task by any means, so allow plenty of time for learning and understanding.
    Regards
    Mark

  • Binary Tree Implementations - why both key and value?

    Hi there!
    I'm sitting here implementing a binary tree, and I was just wondering why most of the binary tree examples encapsulate both a key AND a value in their nodes. Wouldn't it be sufficient to just store comparable objects in the nodes (or provide a comparator for alternative ordering)?
    Thanks again, Oliver
    P.S.:Any suggestions on good books (free E-Books preferred :-)) on ADTs and algorithms? I'm reading 'Data Structures And Algorithms In Java' by Robert Lafore and not very happy with it (the examples are just plain awful).

    Trollhorn wrote:
    Hi there!
    I'm sitting here implementing a binary tree, and I was just wondering why most of the binary tree examples encapsulate both a key AND a value in their nodes. Wouldn't it be sufficient to just store comparable objects in the nodes (or provide a comparator for alternative ordering)?Yes.
    Thanks again, Oliver
    P.S.:Any suggestions on good books (free E-Books preferred :-)) on ADTs and algorithms? I'm reading 'Data Structures And Algorithms In Java' by Robert Lafore and not very happy with it (the examples are just plain awful).As online resources:
    [http://www.cs.princeton.edu/introcs/44st/]
    [http://ocw.mit.edu/OcwWeb/Electrical-Engineering-and-Computer-Science/6-006Spring-2008/CourseHome/index.htm]
    I don't know of any eBooks on the subject, but I can recommend an excellent hard copy book:
    Introduction To Algorithms, by Cormen et al. [http://highered.mcgraw-hill.com/sites/0070131511/information_center_view0/]

  • Tree Implementation - Like a file system

    Hi all,
    I'm want to implement something that will look similar to Windows's file explorer - it should have a tree on the left side and a table (datagrid) on the right side. The tree displays some hierarchy, let's say folders, and upon selection on a folder in the tree, the right side displays the files inside it. Important to say that the tree doesn't show leafs (files), just like in the file explorer in Windows.
    The entire hierarchy is supplied as an XML to my flex application.
    My XML structure will look something like this:
    <FOLDER label="folder1" id="folder1_id" >
        <FILE label="FILE1.1" id="FILE11_id" />
        <FILE label="FILE1.2" id="FILE12_id" />
    </FOLDER>
    <FOLDER label="folder2" id="folder2_id" >
        <FILE label="FILE2.1" id="FILE21_id" />
        <FILE label="FILE2.2" id="FILE22_id" />
    </FOLDER>
    How can I hide the leafs (the "File" tags) in the tree but show them on the table when clicking on the parent folder? How can I "slice" the XML and supply the children (and only them) to the table (datagrid)?
    Thanks!

    Yes. This possible with ADF Faces RC, which provides an af:tree component. Have a look at the Fusion Order Demo, which uses the tree to implement a similar usecase to the one you describe.
    http://www.oracle.com/technology/products/jdev/samples/fod/index.html
    Regards,
    RiC

  • Tree implementation in webdynpro project

    Hi,
    i want to devlop an application that shows a tree that gets data fron RFC .
    user will logged from portal & application will show all his/her subordinates in tree & on click on a
    subordinate, all other levels get displayed(if level are in system).
    plz help.
    Regards,
    Amit

    Hi Amit,
    If the hierarchy of the tree is know at design then you can implement the NonRecursive tree. Refer to the help.sap.com on this:
    http://help.sap.com/saphelp_nw70/helpdata/EN/c2/abfceffbacd24185ec7af8a3a2e76a/frameset.htm
    However if the hierarchy is not known, then you will have to implement the Recursive Tree. Please refer to the following link in help.sap.com for info:
    http://help.sap.com/saphelp_nw70/helpdata/EN/16/1ec1814e566f4baf943c53ccf48552/frameset.htm
    The above links also have code to explain how the tree can be populated.
    Populate the tree to the necessary level on initialization of the screen or the required action. The remaining tree can be filled when the user clicks on the nodes.
    If the child nodes/items are to be populated on click of the parent node, then you can use the onLoadChildren action. When a node is click the action linked to the onLoadChildren is called and the necessary processing can be done to load the data if present.
    Regards,
    Kartikaye

  • Binary Tree Implementation

    Hi,
    How to implement Binary search tree in java?
    How to create node & how to do backtracking?
    Thanks & Regards,
    Sathyavathy S

    Pretty much like in most other OO languages.
    What exactly is your problem? Do you have a bug in your code, a compiler error or don't you understand how a binary tree works?

  • Alternative tree issues for Time dimension

    Hi, there. I am developing a purchase system. We have two types of date one for goods receing and one for settlement date.
    I plan to create two alternative trees in Time dimension one for receving date and the other for settlement date.
    For each alternative tree, there would be four levels (Year->Quarter->Month->Date). Does Essbase support this kind of design?
    I would like leaf note be date format therefore I could use pre-defined Time function such as YTD, MTD etc.

    I'm just kibbitzing on this one -- I like Glenn's suggestion the best because of its simplicity (elegance?).
    One dimension to maintain versus two has to be the better approach. With that View or Type or whatever dimension you don't (I think) lose any analytic capability unless you specifically need to crossdim the two calendars, but that would be an almost herculean task for a given intersection given all of the potential nonintersections. And that requirement isn't in your post, so his suggestion would work.
    Regards,
    Cameron Lackpour

  • A Binary Tree Implementation in ABAP

    Hi,
    Can any one explaine me how to create a binary tree of random numbers with dynamic objects.
    Thanks,
    Manjula.

    Hi manjula,
    This sample code uses dynamic objects to create a binary tree of random numbers as per your requirement ...pls go through It. 
    It stores numbers on the left node or right node depending on the value comparison with the current value. There are two recursive subrotines used for the building of the tree and printing  through the tree.
    For comparison purpose, the same random numbers are stored and sorted in an internal table and printed.
    *& Report YBINTREE - Build/Print Binary Tree of numbers *
    report ybintree .
    types: begin of stree,
    value type i,
    left type ref to data,
    right type ref to data,
    end of stree.
    data: tree type stree.
    data: int type i.
    data: begin of rnd occurs 0,
    num type i,
    end of rnd.
    start-of-selection.
    do 100 times.
    generate random number between 0 and 100
    call function 'RANDOM_I4'
    exporting
    rnd_min = 0
    rnd_max = 100
    importing
    rnd_value = int.
    store numbers
    rnd-num = int.
    append rnd.
    build binary tree of random numbers
    perform add_value using tree int.
    enddo.
    stored numbers are sorted for comparison
    sort rnd by num.
    print sorted random numbers
    write: / 'Sorted Numbers'.
    write: / '=============='.
    skip.
    loop at rnd.
    write: rnd-num.
    endloop.
    skip.
    print binary tree. This should give the same result
    as the one listed from the internal table
    write: / 'Binary Tree List'.
    write: / '================'.
    skip.
    perform print_value using tree.
    skip.
    *& Form add_value
    text - Build tree with value provided
    -->TREE text
    -->VAL text
    form add_value using tree type stree val type i.
    field-symbols: <ltree> type any.
    data: work type stree.
    if tree is initial. "When node has no values
    tree-value = val. " assign value
    clear: tree-left, tree-right.
    create data tree-left type stree. "Create an empty node for left
    create data tree-right type stree. "create an empty node for right
    else.
    if val le tree-value. "if number is less than or equal
    assign tree-left->* to <ltree>. "assign the left node to fs
    call add_value recursively with left node
    perform add_value using <ltree> val.
    else. "if number is greater
    assign tree-right->* to <ltree>. "assign the right node to fs
    call add_value recursively with right node
    perform add_value using <ltree> val.
    endif.
    endif.
    endform. "add_value
    *& Form print_value
    text - traverse tree from left-mid-right order
    automatically this will be sorted list
    -->TREE text
    form print_value using tree type stree.
    field-symbols: <ltree> type any.
    if tree is initial. "node is empty
    else. "non-empty node
    assign tree-left->* to <ltree>. "left node
    perform print_value using <ltree>. "print left
    write: tree-value. "print the current value
    assign tree-right->* to <ltree>. "right node
    perform print_value using <ltree>. "print right
    endif.
    endform. "print_value
    pls reward if helps,
    regards.

  • Tree Model Implementation

    Hi All,
    I'm need to create a JATO tree implementation and need some advice. I
    want to modify the JATO sample tree implementation so that:
    1) The model is cached within the user's session.
    2) The model is created on demand. i.e. The data associated with the
    branches are only retrieved when the branches are opened.
    In the sample application E0115TreeView (view) creates a
    SimpleTreeModelImpl (model) each time it is instantiated and
    SimpleTreeModelImpl (model) creates dummy data each time it is
    instantiated.
    1) Is there a standard JATO technique for associating a model with a
    view (unlike the sample)? Does this involve the ModelTypeMapImpl class?
    My tree data is stored in LDAP, so I can't use a standard JATO database
    Model classes.
    2) The comment in the SimpleTreeModelImpl class definition indicates
    that it is normal practice to store the model in the user's session. Is
    there a standard JATO technique for doing this?
    3) What would be the best way to extend the sample so that I can create
    the model on-demand?
    Regards,
    Dennis Parrott.
    [Non-text portions of this message have been removed]

    Thanks Todd,
    That makes perfect sense.
    Regards,
    Dennis parrott.
    Todd Fast wrote:
    Hi Dennis--
    I have now added a SimpleTreeModel interface (which extends TreeModel) andhave added an
    mapping in ModelTypeMapImpl static initializer. i.e. To registerSimpleTreeModelImpl with the
    ModelManager.This is fine, but you can so without the additional interface if you want.
    You don't need to register the model in the ModelTypeMap, and you can
    instead just pass the implementation class to ModelManager.
    In the tree view constructor instead of creating the SimpleTreeModelImpleach time I use the
    ModelManager to retrieve the model, indicating that the model should bestored in the sesssion:
    public Treeview(View parent, String name) {
    super(parent, name);
    RequestContext requestContext = getRequestContext();
    ModelManager modelManager = requestContext.getModelManager();
    Class clazz = SimpleTreeModel.class;
    SimpleTreeModel simpleTreeModel =
    (SimpleTreeModel)modelManager.getModel( clazz,clazz.getName(), true, true );
    setPrimaryModel( simpleTreeModel );
    registerChildren();
    }This looks good, EXCEPT for the fact that you shouldn't be able to get the
    RequestContext at this point via the class's getRequestContext() method (it
    isn't set until after the constructor). However, you can use the static
    method RequestManager.getRequestContext() instead.
    The final bit I need to implement is the model creation on-demand.Currently the entire model
    is constructed on the first access and stored in the session. However,when model is large then
    this has a performance impact on constructing it for the first time.Instead I would like to
    construct peices of the model as the user accesses them. Any ideas?This is really a function of your model implementation. Nodes that are not
    needed in a particular rendering of a TreeModel are never accessed by the
    framework in that rendering, so you need to implement your model to lazily
    fetch sub-trees of the underlying data structure only as needed. Depending
    on the technology you are using, this may or may not be difficult.
    I suspect that right now you are fetching the entire tree data structure
    when the model is created, and this is the root of the problem. You need to
    fetch all nodes that are children of the root on the first request, then
    fetch child nodes of the next node the user expands on the next request, ad
    infinitum. Otherwise, you will have to settle for a one-time performance
    hit per session caused by retrieving the entire tree data structure at once.
    If you are using TreeModelBase as your superclass and just implementing the
    abstract methods therein, then the implementation of the firstChild() method
    is your opportunity to fetch the tree data lazily. This method will be
    called on a node to "step down" one level in the tree, and it will only be
    called for the nodes that are expanded. You should implement this method to
    figure out what node the model is on at the moment, then use that
    information to determine if you've already looked up that node's childre in
    the backend system, or if you need to go and fetch ONLY the current node's
    direct children. As the user descends through the tree, the tree will be
    fleshed out and cached lazily, one level at a time, via this mechanism.
    Does this make any sense?
    Todd
    To download the latest version of S1AF (JATO), please visit one of thefollowing locations:
    >
    Framework + IDE plugin for Sun ONE Studio 4 Update 1, Community Edition:
    http://wwws.sun.com/software/download/products/Appl_Frmwk_2.0_CE.html
    Framework + IDE pluign for Sun ONE Studio 4 Update 1, Enterprise Edition:
    http://wwws.sun.com/software/download/products/Appl_Frmwk_2.0_EE.html
    Previous versions of JATO:
    http://www.sun.com/software/download/developer/5102.html
    [Non-text portions of this message have been removed]

  • Display tree in applet

    i have a program to convert Xml to tree structure. But i am not able to call it in JSP. So i want to convert to applet. how to convert it.
    package TreeGen;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.FactoryConfigurationError;
    import javax.xml.parsers.ParserConfigurationException;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;
    import java.io.File;
    import java.io.IOException;
    import org.w3c.dom.Document;
    import org.w3c.dom.DOMException;
    import org.w3c.dom.Element;
    // Basic GUI components
    import javax.swing.JApplet;
    import javax.swing.JFrame;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTree;
    // GUI components for right-hand side
    import javax.swing.JSplitPane;
    import javax.swing.JEditorPane;
    // GUI support classes
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.Toolkit;
    import java.awt.event.KeyEvent;
    import java.awt.event.WindowEvent;
    import java.awt.event.WindowAdapter;
    // For creating borders
    import javax.swing.border.EmptyBorder;
    import javax.swing.border.BevelBorder;
    import javax.swing.border.CompoundBorder;
    // For creating a TreeModel
    import javax.swing.tree.*;
    import javax.swing.event.*;
    import java.util.*;
    import java.applet.*;
    public class TreeGen extends JPanel
         static Document document;
         boolean compress = false;
         static final int windowHeight = 660;
         static final int leftWidth = 300;
         static final int rightWidth = 640;
         static final int windowWidth = leftWidth + rightWidth;
         public TreeGen()
         EmptyBorder eb = new EmptyBorder(5,5,5,5);
         BevelBorder bb = new BevelBorder(BevelBorder.LOWERED);
         CompoundBorder cb = new CompoundBorder(eb,bb);
         this.setBorder(new CompoundBorder(cb,eb));
         JTree tree = new JTree(new DomToTreeModelAdapter());
         JScrollPane treeView = new JScrollPane(tree);
         treeView.setPreferredSize(
              new Dimension( leftWidth, windowHeight ));
         final
         JEditorPane htmlPane = new JEditorPane("text/html","");
         htmlPane.setEditable(true);
         JScrollPane htmlView = new JScrollPane(htmlPane);
         htmlView.setPreferredSize(
              new Dimension( rightWidth, windowHeight ));
         tree.addTreeSelectionListener(
              new TreeSelectionListener()
              public void valueChanged(TreeSelectionEvent e)
                   TreePath p = e.getNewLeadSelectionPath();
                   if (p != null)
                   AdapterNode adpNode =
                        (AdapterNode) p.getLastPathComponent();
                   htmlPane.setText(adpNode.content());
         JSplitPane splitPane =
              new JSplitPane( JSplitPane.HORIZONTAL_SPLIT,
                                  treeView,
                                  htmlView );
         splitPane.setContinuousLayout( false );
         splitPane.setDividerLocation( leftWidth );
         splitPane.setDividerSize(1);
         splitPane.setPreferredSize(
                   new Dimension( windowWidth + 10, windowHeight+10 ));
         this.setLayout(new BorderLayout());
         this.add("Center", splitPane );
         //return menuBar;
         } // constructor
         public static void main(String argv[])
              DocumentBuilderFactory factory =
                   DocumentBuilderFactory.newInstance();
              try {
              DocumentBuilder builder = factory.newDocumentBuilder();
              document = builder.parse("C:/Program Files/Apache Software Foundation/Tomcat 5.0/webapps/parser1/sample.xml");
                   makeFrame();
              } catch (SAXException sxe){
                   System.out.println("ERROR");
              Exception x = sxe;
              if (sxe.getException() != null)
                   x = sxe.getException();
              x.printStackTrace();
              } catch (ParserConfigurationException pce) {
                   pce.printStackTrace();
              } catch (IOException ioe) {
              ioe.printStackTrace();
         } // main
         public static void makeFrame()
              //JApplet app = new JApplet();
              //app.add
              JFrame frame = new JFrame("DOM Echo");
              frame.addWindowListener(
              new WindowAdapter() {
                   public void windowClosing(WindowEvent e) {System.exit(0);}
              final TreeGen echoPanel =
              new TreeGen();
              frame.getContentPane().add("Center", echoPanel );
              frame.pack();
              Dimension screenSize =
              Toolkit.getDefaultToolkit().getScreenSize();
              int w = windowWidth + 10;
              int h = windowHeight + 10;
              //TreeGen tg = new TreeGen();
              //MenuDemo demo = new MenuDemo();
              //frame.setJMenuBar(demo.createMenuBar());
              //frame.setContentPane(demo.createContentPane());
              //Display the window.
              frame.setSize(w, h);
              frame.setVisible(true);
         } // makeFrame
         static final String[] typeName = {
              "none",
              "Element",
              "Attr",
              "Text",
              "CDATA",
              "EntityRef",
              "Entity",
              "ProcInstr",
              "Comment",
              "Document",
              "DocType",
              "DocFragment",
              "Notation",
         static final int ELEMENT_TYPE = 1;
         static final int ATTR_TYPE = 2;
         static final int TEXT_TYPE = 3;
         static final int CDATA_TYPE = 4;
         static final int ENTITYREF_TYPE = 5;
         static final int ENTITY_TYPE = 6;
         static final int PROCINSTR_TYPE = 7;
         static final int COMMENT_TYPE = 8;
         static final int DOCUMENT_TYPE = 9;
         static final int DOCTYPE_TYPE = 10;
         static final int DOCFRAG_TYPE = 11;
         static final int NOTATION_TYPE = 12;
    static String[] treeElementNames = {
              "slideshow",
              "slide",
              "title", // For slideshow #1
              "slide-title", // For slideshow #10
              "item",
         boolean treeElement(String elementName) {
         for (int i=0; i<treeElementNames.length; i++) {
              //System.out.println(treeElementNames);
              if ( elementName.equals(treeElementNames[i]) )
              return true;
         return false;
         public class AdapterNode
         org.w3c.dom.Node domNode;
         public AdapterNode(org.w3c.dom.Node node)
              domNode = node;
         public String toString()
              String s = typeName[domNode.getNodeType()];
              String nodeName = domNode.getNodeName();
              if (! nodeName.startsWith("#"))
              s += ": " + nodeName;
              if (compress)
              String t = content().trim();
              int x = t.indexOf("\n");
              if (x >= 0) t = t.substring(0, x);
              s += " " + t;
              return s;
              if (domNode.getNodeValue() != null)
              if (s.startsWith("ProcInstr"))
                   s += ", ";
              else
                   s += ": ";
              // Trim the value to get rid of NL's at the front
              String t = domNode.getNodeValue().trim();
              int x = t.indexOf("\n");
              if (x >= 0) t = t.substring(0, x);
              s += t;
              return s;
         public String content()
              String s = "";
              org.w3c.dom.NodeList nodeList = domNode.getChildNodes();
              for (int i=0; i<nodeList.getLength(); i++)
              org.w3c.dom.Node node = nodeList.item(i);
              int type = node.getNodeType();
              //System.out.println(type);
              AdapterNode adpNode = new AdapterNode(node); //inefficient, but works
              if (type == ELEMENT_TYPE)
                   if ( treeElement(node.getNodeName()) ) continue;
                   s += "<" + node.getNodeName() + ">";
                   s += adpNode.content();
                   s += "</" + node.getNodeName() + ">";
              else if (type == TEXT_TYPE)
                   s += node.getNodeValue();
              else if (type == ENTITYREF_TYPE)
                   s += adpNode.content();
              else if (type == CDATA_TYPE)
                   StringBuffer sb = new StringBuffer( node.getNodeValue() );
                   for (int j=0; j<sb.length(); j++)
                   if (sb.charAt(j) == '<')
                        sb.setCharAt(j, '&');
                        sb.insert(j+1, "lt;");
                        j += 3;
                   else if (sb.charAt(j) == '&')
                        sb.setCharAt(j, '&');
                        sb.insert(j+1, "amp;");
                        j += 4;
                   s += "<pre>" + sb + "\n</pre>";
              return s;
         public int index(AdapterNode child)
              int count = childCount();
              for (int i=0; i<count; i++)
              AdapterNode n = this.child(i);
              if (child.domNode == n.domNode) return i;
              return -1; // Should never get here.
         public AdapterNode child(int searchIndex)
              org.w3c.dom.Node node =
                   domNode.getChildNodes().item(searchIndex);
              if (compress)
              int elementNodeIndex = 0;
              for (int i=0; i<domNode.getChildNodes().getLength(); i++)
                   node = domNode.getChildNodes().item(i);
                   if (node.getNodeType() == ELEMENT_TYPE
                   && treeElement( node.getNodeName() )
                   && elementNodeIndex++ == searchIndex)
                   break;
              return new AdapterNode(node);
         public int childCount()
              if (!compress)
              return domNode.getChildNodes().getLength();
              int count = 0;
              for (int i=0; i<domNode.getChildNodes().getLength(); i++)
              org.w3c.dom.Node node = domNode.getChildNodes().item(i);
              if (node.getNodeType() == ELEMENT_TYPE
              && treeElement( node.getNodeName() ))
                   ++count;
              return count;
         public class DomToTreeModelAdapter
         implements javax.swing.tree.TreeModel
         public Object getRoot()
              return new AdapterNode(document);
         public boolean isLeaf(Object aNode)
              AdapterNode node = (AdapterNode) aNode;
              if (node.childCount() > 0) return false;
              return true;
         public int getChildCount(Object parent)
              AdapterNode node = (AdapterNode) parent;
              return node.childCount();
         public Object getChild(Object parent, int index)
              AdapterNode node = (AdapterNode) parent;
              return node.child(index);
         public int getIndexOfChild(Object parent, Object child)
              AdapterNode node = (AdapterNode) parent;
              return node.index((AdapterNode) child);
         public void valueForPathChanged(TreePath path, Object newValue)
         private Vector listenerList = new Vector();
         public void addTreeModelListener(TreeModelListener listener)
              if ( listener != null
              && ! listenerList.contains( listener ) )
              listenerList.addElement( listener );
         public void removeTreeModelListener(TreeModelListener listener)
              if ( listener != null )
              listenerList.removeElement( listener );
         public void fireTreeNodesChanged( TreeModelEvent e )
              Enumeration listeners = listenerList.elements();
              while ( listeners.hasMoreElements() )
              TreeModelListener listener =
                   (TreeModelListener) listeners.nextElement();
              listener.treeNodesChanged( e );
         public void fireTreeNodesInserted( TreeModelEvent e )
              Enumeration listeners = listenerList.elements();
              while ( listeners.hasMoreElements() )
              TreeModelListener listener =
                   (TreeModelListener) listeners.nextElement();
              listener.treeNodesInserted( e );
         public void fireTreeNodesRemoved( TreeModelEvent e )
              Enumeration listeners = listenerList.elements();
              while ( listeners.hasMoreElements() )
              TreeModelListener listener =
                   (TreeModelListener) listeners.nextElement();
              listener.treeNodesRemoved( e );
         public void fireTreeStructureChanged( TreeModelEvent e )
              Enumeration listeners = listenerList.elements();
              while ( listeners.hasMoreElements() )
              TreeModelListener listener =
                   (TreeModelListener) listeners.nextElement();
              listener.treeStructureChanged( e );
    pls help.
    ramya

    There's already some applet code in there, although it's commented out. Did you add that?
    Anyway, the general principle for turning an app into an applet, is to replace the main() method with the Applet's (or JApplet's) init(), start(), and stop() methods. Also you won't be able to read data off the file system; use resources instead. (e.g., java.lang.Class.getResource)
    I'm not sure what this has to do with JSP.
    When you post code, please wrap it in &#91;code]&#91;/code] tags.

  • How to hide a tree node from the GUI but still keep it in the tree model?

    Hi, All
    I used a JTree in my project in which I have a DefaultTreeModel to store all the tree structure and a JTree show it on the screen. But for some reason, I want to hide some of the nodes from the user, but I don't want to remove them from the tree model because later on I still need to use them.
    I searched on the web, some people suggested method to hide the root node, but that's not appliable to my project because I want to hide some non-root nodes; Some people also suggested to collapse the parent node when there are child to hide, it is not appliable to me either, because there still some other childnodes (sibling of the node to hide) I want to show.
    How can I hide some of the tree node from the user? Thanks for any information.
    Linda

    Here's an example using a derivation of DefaultTreeModel that shows (or does not show) two types of Sneech (appologies to the good Dr Zeus) by overiding two methods on the model.
    Now, there are many things wrong with this example (using instanceof, for example), but it's pretty tight and shows one way of doing what you want.
    Note: to make it useful, you''d have to change the implementation of setShowStarBelliedSneeches() to do something more sophisticated than simply firing a structure change event on the root node. You'd want to find all the star bellied sneech nodes and call fireTreeNodesRemoved(). That way the tree would stay expanded rather than collapse as it does now.
    import javax.swing.JTree;
    import javax.swing.JScrollPane;
    import javax.swing.JOptionPane;
    import javax.swing.JCheckBox;
    import javax.swing.JPanel;
    import javax.swing.tree.TreePath;
    import javax.swing.tree.DefaultTreeModel;
    import javax.swing.tree.DefaultMutableTreeNode;
    import java.awt.Dimension;
    import java.awt.BorderLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.Enumeration;
    class FilteredTree
         private class PlainBelliedSneech {
              public String toString() { return "Plain Bellied Sneech"; }
         private class StarBelliedSneech {
              public String toString() { return "Star Bellied Sneech"; }
         private class FilteredTreeModel
              extends DefaultTreeModel
              private boolean mShowStarBelliedSneeches= true;
              private DefaultMutableTreeNode mRoot;
              FilteredTreeModel(DefaultMutableTreeNode root)
                   super(root);
                   mRoot= root;
              public Object getChild(Object parent, int index)
                   DefaultMutableTreeNode node=
                        (DefaultMutableTreeNode) parent;
                   if (mShowStarBelliedSneeches)
                        return node.getChildAt(index);
                   int pos= 0;
                   for (int i= 0, cnt= 0; i< node.getChildCount(); i++) {
                        if (((DefaultMutableTreeNode) node.getChildAt(i)).getUserObject()
                                            instanceof PlainBelliedSneech)
                             if (cnt++ == index) {
                                  pos= i;
                                  break;
                   return node.getChildAt(pos);
              public int getChildCount(Object parent)
                   DefaultMutableTreeNode node=
                        (DefaultMutableTreeNode) parent;
                   if (mShowStarBelliedSneeches)
                        return node.getChildCount();
                   int childCount= 0;
                   Enumeration children= node.children();
                   while (children.hasMoreElements()) {
                        if (((DefaultMutableTreeNode) children.nextElement()).getUserObject()
                                            instanceof PlainBelliedSneech)
                             childCount++;
                   return childCount;
              public boolean getShowStarBelliedSneeches() {
                   return mShowStarBelliedSneeches;
              public void setShowStarBelliedSneeches(boolean showStarBelliedSneeches)
                   if (showStarBelliedSneeches != mShowStarBelliedSneeches) {
                        mShowStarBelliedSneeches= showStarBelliedSneeches;
                        Object[] path= { mRoot };
                        int[] childIndices= new int[root.getChildCount()];
                        Object[] children= new Object[root.getChildCount()];
                        for (int i= 0; i< root.getChildCount(); i++) {
                             childIndices= i;
                             children[i]= root.getChildAt(i);
                        fireTreeStructureChanged(this, path, childIndices, children);
         private FilteredTree()
              final DefaultMutableTreeNode root= new DefaultMutableTreeNode("Root");
              DefaultMutableTreeNode parent;
              DefaultMutableTreeNode child;
              for (int i= 0; i< 2; i++) {
                   parent= new DefaultMutableTreeNode(new PlainBelliedSneech());
                   root.add(parent);
                   for (int j= 0; j< 2; j++) {
                        child= new DefaultMutableTreeNode(new StarBelliedSneech());
                        parent.add(child);
                        for (int k= 0; k< 2; k++)
                             child.add(new DefaultMutableTreeNode(new PlainBelliedSneech()));
                   for (int j= 0; j< 2; j++)
                        parent.add(new DefaultMutableTreeNode(new PlainBelliedSneech()));
                   parent= new DefaultMutableTreeNode(new StarBelliedSneech());
                   root.add(parent);
                   for (int j= 0; j< 2; j++) {
                        child= new DefaultMutableTreeNode(new PlainBelliedSneech());
                        parent.add(child);
                        for (int k= 0; k< 2; k++)
                             child.add(new DefaultMutableTreeNode(new StarBelliedSneech()));
                   for (int j= 0; j< 2; j++)
                        parent.add(new DefaultMutableTreeNode(new StarBelliedSneech()));
              final FilteredTreeModel model= new FilteredTreeModel(root);
              JTree tree= new JTree(model);
    tree.setShowsRootHandles(true);
    tree.putClientProperty("JTree.lineStyle", "Angled");
              tree.setRootVisible(false);
              JScrollPane sp= new JScrollPane(tree);
              sp.setPreferredSize(new Dimension(200,400));
              final JCheckBox check= new JCheckBox("Show Star Bellied Sneeches");
              check.setSelected(model.getShowStarBelliedSneeches());
              check.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        model.setShowStarBelliedSneeches(check.isSelected());
              JPanel panel= new JPanel(new BorderLayout());
              panel.add(check, BorderLayout.NORTH);
              panel.add(sp, BorderLayout.CENTER);
              JOptionPane.showOptionDialog(
                   null, panel, "Sneeches on Beeches",
                   JOptionPane.DEFAULT_OPTION,
                   JOptionPane.PLAIN_MESSAGE,
                   null, new String[0], null
              System.exit(0);
         public static void main(String[] argv) {
              new FilteredTree();

  • Tree Editors and Renderers

    What I am currently trying to implement is a tree editor renderer that displays label and a text field next to a tree node.
    The label contains text describing the contents of the text field to the right.
    The requirement is that the user can click in the textfield area and type a new value, which when they press return is accepted.
    My problem is that in order to detect single clicks in the textfield area to enable the editor for that tree node, I am implementing an Immediate Editor along the lines in the Geary Swing Book.
    However, a method to calculate the correct offset is not working:
    PMSPropertyBrowserTreeCellRenderer.getPropertyValueTextFieldOffset fails to calculate the correct value as two things appear to fail
    1. the "lastRow" member of the Tree is not the last component selected
    2. the call to obtain the Graphics class from the renderer's panel always returns null
    From Immediate Editor
    * Provides the means to edit a cell immediately with a mouse click
    * @param event
    * @return true if the event is of the right type
    protected boolean canEditImmediately(EventObject event)
    boolean retval = false;
    if (event instanceof MouseEvent)
    MouseEvent me = (MouseEvent)event;
    retval = inTextFieldHitRegion(me);
    return retval;
    * Should determine if the pointer is in the region of the property text field
    * @param me
    * @return id the mouse pointer is in the text field
    private boolean inTextFieldHitRegion(MouseEvent me)
    // obtain the place in the tree where this mouse event came from
    TreePath path = tree.getPathForLocation(me.getX(), me.getY());
    PMSPropertyBrowserTreeNode node =
    (PMSPropertyBrowserTreeNode)path.getLastPathComponent();
    boolean retval = false;
    // if the node is a leaf
    if (node.isLeaf())
    // determine if mouse point is in the JTextField part of the renderer component
    Rectangle bounds = tree.getRowBounds(this.lastRow);
    Dimension textFieldOffset = renderer.getPropertyValueTextFieldOffset();
    bounds.translate(
    offset + textFieldOffset.width,
    textFieldOffset.height);
    retval = bounds.contains(me.getPoint());
    return retval;
    public boolean shouldSelectCell(EventObject event)
    GUILog.log.writeLog(
    GUILog.logTypes.ADMINISTRATIVE_EVENT,
    "shouldSelectCell called");
    boolean retval = false;
    if (event instanceof MouseEvent)
    MouseEvent me = (MouseEvent)event;
    TreePath path = tree.getPathForLocation(me.getX(), me.getY());
    PMSPropertyBrowserTreeNode node =
    (PMSPropertyBrowserTreeNode)path.getLastPathComponent();
    boolean inField = !inTextFieldHitRegion(me);
    retval = node.isLeaf() || !inTextFieldHitRegion(me);
    return retval;
    ... end from ImmediateEditor
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.JTree;
    import javax.swing.tree.*;
    import java.awt.Component;
    public class PMSPropertyBrowserTreeCellRenderer extends DefaultTreeCellRenderer
    private JPanel propertyPanel = new JPanel();
    private JLabel propertyValueLabel = new JLabel();
    protected JTextField propertyValueTextField = new JTextField();
    private Component spacer = Box.createHorizontalStrut(5);
    public PMSPropertyBrowserTreeCellRenderer()
    super();
    propertyPanel.setBackground(UIManager.getColor("Tree.textBackground"));
    setOpaque(false);
    propertyValueTextField.setOpaque(false);
    propertyValueTextField.setBorder( BorderFactory.createLoweredBevelBorder());
    propertyValueTextField.setText("<empty>");
    propertyPanel.setOpaque(false);
    propertyPanel.setLayout(new FlowLayout(FlowLayout.CENTER,0,0));
    propertyPanel.add(this);
    propertyPanel.add(spacer);
    propertyPanel.add(propertyValueTextField);
    public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus)
    * Gives the offset for the tree node as far as the text component
    * Currently the graphics reference returns null.
    * @return an offset into the text field component
    public Dimension getPropertyValueTextFieldOffset()
    Graphics g = propertyPanel.getGraphics();
    int offset = 0;
    if (g != null)
    try
    FontMetrics fm = g.getFontMetrics();
    offset =
    fm.stringWidth(getText()+spacer.getPreferredSize().width);
    catch (Exception ex)
    // nothing happens if we get an exception
    finally
    g.dispose();
    } // end if
    return new Dimension(offset,0);
    } // end method

    JTree has a setRowHeight(int rowHeight) method. "If
    the specified value is less than or equal to zero the current cell
    renderer is queried for each row's height."
    (Say if you're reposting this in the Swing forum.)

  • SQL Server Agent Jobs error for Slowly changing dimension

    Hi,
    I have implemented Slowly changing dimension in 5 of my packages for lookup insert/update.
    All the packages are running good in SSDT. And when i deployed the project to SSISDB and run the packages all are running successfully. But when i created a job out of that and run the packages, then 3 packages ran successfully and 2 packages failed. 
    When i opened All Execution Report. I found the following error:
    Message
    Message Source Name
    Subcomponent Name
    Process Provider:Error: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available.  Source: "Microsoft SQL Server Native Client 10.0"  Hresult: 0x80004005  Description:
    "Login timeout expired". An OLE DB record is available.  Source: "Microsoft SQL Server Native Client 10.0"  Hresult: 0x80004005  Description: "A network-related or instance-specific error has occurred while establishing
    a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.". An OLE DB record is available. 
    Source: "Microsoft SQL Server Native Client 10.0"  Hresult: 0x80004005  Description: "Named Pipes Provider: Could not open a connection to SQL Server [53]. ".
    Process Provider
    Slowly Changing Dimension [212]
    Then i opened Provider package in SSDT and changed the source reading record limit from 4,00,000 to 15,000 in source query and deployed again and run, then the job succeeded. more than 15,000 failed.
    And in the 2nd experiment, I removed slowly changing dimension task and implemented normal lookup for insert/update, and set the source reading limit again to 4,00,000 and deployed again and run, then the job succeeded.
    Now i am not able to figure out, what exactly is the problem with Slowly changing dimension task for more than 15,00 records in SQL Server  Agent Job run?
    Can anybody pls help me out.
    Thanks
    Bikram

    Hi Vikash,
    As i have mentioned in the above post, below 2 scenarios: 
    "Then i opened Provider package in SSDT and changed the source reading record limit from 4,00,000 to 15,000 in source
    query and deployed again and run, then the job succeeded. more than 15,000 failed.
    And in the 2nd experiment, I removed slowly changing dimension task and implemented normal lookup for insert/update, and set the source reading limit again to 4,00,000 and deployed again and run, then the job succeeded."
    That means i am able to connect to sql server.
    But if i change the 1st scenario and read 4,00,000 records, the job fails and shows the above mentioned error.
    Similarly in the 2nd scenario, if i implement SCD look up,  the job fails and shows the above mentioned error.
    And i am consistently reproducing this.
    Thanks
    Bikram

Maybe you are looking for

  • How to re-install I-work on my iMac, as hard-disc has been replaced

    Prior to replacing hard-disg, back-up were made by capsule. Tried to Restore Iwork from Capsule, but Iwork wont open. Can I download I-Work from Applestore without any cost, as I have the lisence which came with the iMac when new?

  • Use same player for images and video

    Greetings, I am working on a media player using Flash Pro CS4. I am totally new to Flash, but I do have experience coding in C#. I have included a URL to a media player used by the UFC. I'm trying to figure out how they have a single media player tha

  • How to create an Array which holds numbers ?!?!

    I must be going mad... I just write: var directio:Number=1 //or any other number var someArray:Array=new Array( 1, 0, -1, 0); var deltaX:Number = anyNumber*someArray[directio]; trace (deltaX); and this returns NaN !! I tried even creating a numeric v

  • Imac white screen in lion... help

    Hello Yesterday, I switched off My imac when it being in sleep mode. Next morning, when I switch on, my computer stop turning on, on white screen!!! Nothing helps. I unplug everything from it, and it the same history. After couple of hours, I format

  • Interfaces WLC 5508

    Hi good afternoon, I have an easy question, checking  how WLC with AP associated making a tunneling in CAPWAP (standard RFC 4188) using a UDP dest port looks like its necessary L3. Let me try to explain what i want: I have a WLC 5508 with a Switch th