epreston / pstreegraph Goto Github PK
View Code? Open in Web Editor NEWA tree graph view control for iPad applications. This is a port of the sample code from Max OS X to iOS (iPad).
Home Page: http://epreston.github.io/PSTreeGraph/
A tree graph view control for iPad applications. This is a port of the sample code from Max OS X to iOS (iPad).
Home Page: http://epreston.github.io/PSTreeGraph/
Absolutely fantastic control! Forgive me for creating an issue, as I just really want to ask you a question.
How do I add a new item to the tree and refresh the tree to show the new item while the app is running.
(void)addButtonTapped:(id)sender
{
NSLog(@"addButtonTapped model root %@", treeGraphView.modelRoot);
EntityModel *rootEntity = (EntityModel *)treeGraphView.modelRoot;
EntityModel *newEntityModel = [[EntityModel alloc]initWithParentNode:rootEntity];
[rootEntity addChildModelNode:newEntityModel];
[newEntityModel release];
}
This control loads the NIB once, then stamps it for each node in the graph.
Hello Team,
I'll really appreciate the work you done in Tree Graph API. I'm looking for some customization in it.
For example: For root node , we have multiple childs lets say 18 childs in a row for single root node.
Can we show fixed 8 or 10 childs in row and then rest childs should be desing in second row of it. I have atttached screen shots of what i m looking for. also added present implementaion.
Also. Is this possible to add childs left and right side of connectingLine. Attached shot for it too.
Please help me in customizations like this. I'll really thankful to you.
When child nodes are expanded and collapsed, the animations for the lines connecting them are close but not exact. The animations are quick so it appears to be correct. Improvement can be made in this area.
Hello,
i would like to display some hierarchical data from a xml-file or json-response.
Now I am looking for some hints or tips how to start with.
Yours Johannes
Hi,
I just did a simple test, with a larger object tree.
Doing that, the connecting lines between the root node and its first siblings will not be drawn.
If you move the tree in the iPhone simulator, the display will be cluttered. It seems to me, that there is a horizontal band, which is not redrawn correctly.
You can repeat this test very easily, by just replacing the line
[self setRootClassName:@"UIControl"];
with
[self setRootClassName:@"NSObject"];
in the PSHTreeGraphViewController.m file.
If you would do the same in the original Apple's TreeViewExample, the rendering is correct.
I saw this behaviour in the IOS Simulator for the iPhone and iPad as well.
Any ideas how to fix this?
Best wishes Johannes
It wasn't clear to me from the example whether you can select any node in the tree, even if the node can't be expanded.
Hi
Could you provide some documentation on the following?
I seem to have an issue with the events fired:
toggleExpansion of the SubtreeView is never called when pressing the icon.
I did correctly wire my model, and the root item implemented the required protocol methods.
The children also get rendered, but behind the rootModel. and I can't seem to interact at all, and every touch on the leaf view calls touchesBegan instead of toggleExpansion.
I'm guessing there is something I'm missing by looking at the example as a reference?
Any ideas as to what this is?
Kind regards,
0x
The keyboard navigation might need to be updated when the view is flipped. The "a" and "d" keys should logically move left and right around the hierarchy to the nearest node to each side.
I need to represent an array of strings in tree like structure. How can I do this with PSTreeGraph? I couldn't find any function for adding arbitrary nodes. Please explain.
Node selection does not change as items are pressed. The root node remains selected in the sample project. Multiple node selection not possible.
Hi,
I would like to use this awesome implementation of tree structure for my requirement (to draw a flowchart). Here I have a requirement where I need to draw a flow chart in a na iPad. The chart is similar to tree-structure this project, just that a node might have multiple parents.
I tried to start editing the code by first changing the - (id <PSTreeGraphModelNode> )parentModelNode;
method in PSTreeGraphModelNode
protocol to - (NSArray <PSTreeGraphModelNode> *)parentModelNode;
I met lot of roadblocks in #pragma mark - Model Tree Navigation
implementations of PSBaseTreeGraphView.m
. I would like to know if these implementations can be discarded because I do not need #pragma mark - Selection State
methods as I intend to show all the nodes.
Any help is well appreciated.
Hello,
this is just a little info.
If you want that the expand/collapse button of the provided example app shows the according icon of the tree state (collapsed/expanded), then you can achieve this behaviour with this code snippet.
Just connect the IBAction "toggleUIButtonImage" with the "Touch up inside" event in the IB of your xxxleaf.xib.
-(IBAction) toggleUIButtonImage:(id)sender{
if ([sender isSelected]) {
[sender setImage:[UIImage imageNamed:@"TreeViewSubtreeCollapsedButton.png"] forState:UIControlStateNormal];
[sender setSelected:NO];
}else {
[sender setImage:[UIImage imageNamed:@"TreeViewSubtreeExpandedButton.png"] forState:UIControlStateSelected];
[sender setSelected:YES];
}
}
HTH Johannes
Hi again,
I seem to have a hit another snag. I'm trying to create a graph like this.
How can I create a custom model for something like this? What type of data structure should I use? In the example, I see you're using the NSObject and its descendants. How can I create a something similar for my graph too.
Many thanks.
Hello,
this is just a little info.
If you want that the expand/collapse button of the provided example app shows the according icon of the tree state (collapsed/expanded), then you can achieve this behaviour with this code snippet.
Just connect the IBAction "toggleUIButtonImage" with the "Touch up inside" event in the IB of your xxxleaf.xib.
-(IBAction) toggleUIButtonImage:(id)sender{
if ([sender isSelected]) {
[sender setImage:[UIImage imageNamed:@"TreeViewSubtreeCollapsedButton.png"] forState:UIControlStateNormal];
[sender setSelected:NO];
}else {
[sender setImage:[UIImage imageNamed:@"TreeViewSubtreeExpandedButton.png"] forState:UIControlStateSelected];
[sender setSelected:YES];
}
}
HTH Johannes
Hi, just a little info.
There exists a flag named "showsSubtreeFrames", which might help you by visual inspecting your subtrees.
Setting this flag to YES and the corresponding subtrees are surrounded by a green rectangle.
HTH Johannes
Hi,
thanks for the great control. I cannot seem to find the 'Documentation' build target to generate the docs. I have successfully installed Doxygen.
Can you please tell me where to select the build targets in Xcode 5?
Thanks
Is it possible to implement a zoom in zoom out feature?
Hello sir,
after first node , i have to create right side and left side add one node . so i am confuse How can i do this . please give me solution . same question i have post on stackoverflow . http://stackoverflow.com/questions/40631912/ios-pstreegraphview-how-to-create-two-node-one-left-side-and-one-right-side
on this stackoverflow i have add images this easy to undastanding my problem.
plase share with me you valuable knowledge .
Move instance variables to the class extension in the implementation file. Where possible, dependant headers will also be moved into the implementation file as well. These changes will clean up the header files greatly.
It is now possible to place the instance variables (specifically the ones that you want to be private) into the implementation section or into a class extension. I typically use a class extension in the implementation file for private interfaces, so it makes sense to group things there.
Some dependant header files are included in project header files just for these instance variables. Once the variables are moved into the implementation file, some dependant headers can be hidden in the implementation file as well.
The layout code for horizontal and vertical rendering is all mixed together in single methods. This needs to be refactored into separate methods for clarity and future improvements.
Replace the NSAutoreleasePool wrapper object usage with the new direct language construct. An example is found below.
@autoreleasepool {
// code for nested auto-release pool here
}
This syntax requires Xcode 4.2
Hi, I really love your PSTreeGraph! Thank you for your time spent on this, I think.
I just want to know if it is possible to place a root on the bottom of the screen and draw a tree bottom-up? Thank you
I read your demo, but I didn't find how to pass my own data source? Can you give an example?
Hello,
First of all thanks for creating PSTreeGraph it is very good But I am having one issue i.e. I trying to customize the PSTreeGraph and use json as datasource, I already referred the issue that MR. johannes has posted (URL : #9).
Can you please share more detail for same, It would be very help-full for me because I have wasted 3 days on same
Thanks for the great work you've put into this. I have a couple observations.
In my leaf view subclass, I tried setting the fill color within initWithFrame but found that it wasn't being called. InitWithCoder is though. Additionally, although the fill color was being set, it was later being reset by configureDetaults in PSBaseLeafView.m because of a call from within awakeFromNib.
Hi,
this is just a little hack to get a collapsing or expanding tree with a double tap gesture.
Thanks to the excellent design of PSTreeGraph, this feature is easy to realize.
First implement the tap gesture recognizer:
With a double tap on the view, the "handleDoubleTap" function is called:
-(void)handleDoubleTap:(UITapGestureRecognizer*)gestureRecognizer {
if (gestureRecognizer.state == UIGestureRecognizerStateEnded)
{
NSLog(@"See a tap double gesture");
ruleOutsTreeView = [gestureRecognizer view];
if (isCollapsed) {
[ruleOutsTreeView expandRoot];
isCollapsed = false;
}
else if (!isCollapsed) {
[ruleOutsTreeView collapseRoot];
isCollapsed = true;
}
}
}
"isCollapsed" is just a local, private variable, which holds the state of the tree.
"ruleOutsTreeView" represents the "PSBaseTreeGraphView".
You can register the tap gesture recognizer in your custom tree view class, e.g. PSHTreeGraphView
(id) initWithCoder:(NSCoder *)decoder
{
self = [super initWithCoder:decoder];
if (self) {
// Initialization code when loaded from XIB (this example)
// init gesture recognizer
[self initTapGestureRecognition];
bool isCollapsed = false;
}
return self;
}
To get the tree collapsed or expanded, I modified the functions "expandRoot()" and "collapseRoot()" of PSBaseTreeGraphView.m
E.g.:
(void) collapseRoot
{
[UIView beginAnimations:@"TreeNodeExpansion" context:nil];
[UIView setAnimationDuration:2.0];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[[self rootSubtreeView] setExpanded:NO];
[[[self rootSubtreeView] enclosingTreeGraph] layoutGraphIfNeeded];
[UIView commitAnimations];
}
(void) expandRoot
{
[UIView beginAnimations:@"TreeNodeExpansion" context:nil];
[UIView setAnimationDuration:2.0];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[[self rootSubtreeView] setExpanded:NO]; // if not set, a collapsed subtree node will not expand
[[self rootSubtreeView] setExpanded:YES];
[[[self rootSubtreeView] enclosingTreeGraph] layoutGraphIfNeeded];
[UIView commitAnimations];
}
That's all, now you have a tree collapsing or expanding with a double tap.
Have fun
Johannes
Hello,
i would like to start with a collapsed tree and with pressing the expand button, only the next layer of the subtree should be shown.
Actually the whole subtree is displayed.
Has anybody realized such a feature?
Yours Johannes
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.