Permalink
Browse files

Refactored layout code.

Reviewed graphLayout code and supporting routines.  Refactored code for
clarity and new features, it reads better now.
  • Loading branch information...
epreston committed Sep 15, 2011
1 parent 167cbfa commit 878a7ee110f54f4f484043595c1d522aa213c5cb
@@ -6,9 +6,9 @@
// Copyright 2010 Preston Software. All rights reserved.
//
//
-// This is a port of the sample code from Max OS X to iOS (iPad).
+// This is a port of the sample code from Max OS X to iOS (iPad).
//
-// WWDC 2010 Session 141, “Crafting Custom Cocoa Views”
+// WWDC 2010 Session 141, “Crafting Custom Cocoa Views”
//
@@ -6,9 +6,9 @@
// Copyright 2010 Preston Software. All rights reserved.
//
//
-// This is a port of the sample code from Max OS X to iOS (iPad).
+// This is a port of the sample code from Max OS X to iOS (iPad).
//
-// WWDC 2010 Session 141, “Crafting Custom Cocoa Views”
+// WWDC 2010 Session 141, “Crafting Custom Cocoa Views”
//
@@ -52,9 +52,11 @@ - (UIBezierPath *) directConnectionsPath
PSTreeGraphOrientationStyle treeDirection = [[self enclosingTreeGraph] treeGraphOrientation];
if ( treeDirection == PSTreeGraphOrientationStyleHorizontal ) {
- rootPoint = CGPointMake(CGRectGetMinX(bounds), CGRectGetMidY(bounds));
+ rootPoint = CGPointMake(CGRectGetMinX(bounds),
+ CGRectGetMidY(bounds));
} else {
- rootPoint = CGPointMake(CGRectGetMidX(bounds), CGRectGetMinY(bounds));
+ rootPoint = CGPointMake(CGRectGetMidX(bounds),
+ CGRectGetMinY(bounds));
}
// Create a single bezier path that we'll use to stroke all the lines.
@@ -70,9 +72,11 @@ - (UIBezierPath *) directConnectionsPath
CGPoint targetPoint = CGPointZero;
if ( treeDirection == PSTreeGraphOrientationStyleHorizontal ) {
- targetPoint = [self convertPoint:CGPointMake(CGRectGetMinX(subviewBounds), CGRectGetMidY(subviewBounds)) fromView:subview];
+ targetPoint = [self convertPoint:CGPointMake(CGRectGetMinX(subviewBounds), CGRectGetMidY(subviewBounds))
+ fromView:subview];
} else {
- targetPoint = [self convertPoint:CGPointMake(CGRectGetMidX(subviewBounds), CGRectGetMinY(subviewBounds)) fromView:subview];
+ targetPoint = [self convertPoint:CGPointMake(CGRectGetMidX(subviewBounds), CGRectGetMinY(subviewBounds))
+ fromView:subview];
}
[path moveToPoint:rootPoint];
@@ -111,9 +115,11 @@ - (UIBezierPath *) orthogonalConnectionsPath
CGPoint rootPoint = CGPointZero;
if ( treeDirection == PSTreeGraphOrientationStyleHorizontal ) {
// Compute point at right edge of root node, from which its connecting line to the vertical line will emerge.
- rootPoint = CGPointMake(CGRectGetMinX(bounds), CGRectGetMidY(bounds));
+ rootPoint = CGPointMake(CGRectGetMinX(bounds),
+ CGRectGetMidY(bounds));
} else {
- rootPoint = CGPointMake(CGRectGetMidX(bounds), CGRectGetMinY(bounds));
+ rootPoint = CGPointMake(CGRectGetMidX(bounds),
+ CGRectGetMinY(bounds));
}
@@ -124,8 +130,8 @@ - (UIBezierPath *) orthogonalConnectionsPath
// rootPoint = [self convertPointFromBase:basePoint];
- // Compute point (really, we're just interested in the x value) at which line from root node intersects the
- // vertical connecting line.
+ // Compute point (really, we're just interested in the x value) at which line
+ // from root node intersects the vertical connecting line.
CGPoint rootIntersection = CGPointMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds));
@@ -161,9 +167,11 @@ - (UIBezierPath *) orthogonalConnectionsPath
CGPoint targetPoint = CGPointZero;
if ( treeDirection == PSTreeGraphOrientationStyleHorizontal ) {
- targetPoint = [self convertPoint:CGPointMake(CGRectGetMinX(subviewBounds), CGRectGetMidY(subviewBounds)) fromView:subview];
+ targetPoint = [self convertPoint:CGPointMake(CGRectGetMinX(subviewBounds), CGRectGetMidY(subviewBounds))
+ fromView:subview];
} else {
- targetPoint = [self convertPoint:CGPointMake(CGRectGetMidX(subviewBounds), CGRectGetMinY(subviewBounds)) fromView:subview];
+ targetPoint = [self convertPoint:CGPointMake(CGRectGetMidX(subviewBounds), CGRectGetMinY(subviewBounds))
+ fromView:subview];
}
// Align the line to get exact pixel coverage, for sharper rendering.
@@ -222,7 +230,7 @@ - (UIBezierPath *) orthogonalConnectionsPath
}
- (void) drawRect:(CGRect)dirtyRect
-{
+{
// Build the set of lines to stroke, according to our enclosingTreeGraph's connectingLineStyle.
UIBezierPath *path = nil;
@@ -6,9 +6,9 @@
// Copyright 2010 Preston Software. All rights reserved.
//
//
-// This is a port of the sample code from Max OS X to iOS (iPad).
+// This is a port of the sample code from Max OS X to iOS (iPad).
//
-// WWDC 2010 Session 141, “Crafting Custom Cocoa Views”
+// WWDC 2010 Session 141, “Crafting Custom Cocoa Views”
//
@@ -6,9 +6,9 @@
// Copyright 2010 Preston Software. All rights reserved.
//
//
-// This is a port of the sample code from Max OS X to iOS (iPad).
+// This is a port of the sample code from Max OS X to iOS (iPad).
//
-// WWDC 2010 Session 141, “Crafting Custom Cocoa Views”
+// WWDC 2010 Session 141, “Crafting Custom Cocoa Views”
//
@@ -6,22 +6,24 @@
// Copyright 2010 Preston Software. All rights reserved.
//
//
-// This is a port of the sample code from Max OS X to iOS (iPad).
+// This is a port of the sample code from Max OS X to iOS (iPad).
//
-// WWDC 2010 Session 141, “Crafting Custom Cocoa Views”
+// WWDC 2010 Session 141, “Crafting Custom Cocoa Views”
//
#import <UIKit/UIKit.h>
#import "PSTreeGraphModelNode.h"
+
@class PSBaseBranchView;
@class PSBaseTreeGraphView;
-/// A SubtreeView draws nothing itself (unless showsSubtreeFrames is set to YES for the enclosingTreeGraph), but
-/// provides a local coordinate frame and grouping mechanism for a graph subtree, and implements subtree layout.
+/// A SubtreeView draws nothing itself (unless showsSubtreeFrames is set to YES for
+/// the enclosingTreeGraph), but provides a local coordinate frame and grouping mechanism
+/// for a graph subtree, and implements subtree layout.
@interface PSBaseSubtreeView : UIView
Oops, something went wrong.

0 comments on commit 878a7ee

Please sign in to comment.