Skip to content

Commit

Permalink
Minor updates and defensive programming.
Browse files Browse the repository at this point in the history
Corrected retain count on new nodes. Changed color property to retain.
Defensive programming on model protocol with assertions to explain and
check.  Explicit floating point constants to clean up parse graph.
Reordered a few methods.  Cleaned up documentation build target.  Placed
a few method signatures of PSBaseBranchView in an extension so the
compiler ensures they are implemented.
  • Loading branch information
epreston committed Sep 12, 2011
1 parent 391eb03 commit 66c7644
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 135 deletions.
5 changes: 1 addition & 4 deletions Example 1/Classes/Controller/PSHTreeGraphViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ @implementation PSHTreeGraphViewController

@synthesize treeGraphView;

- (NSString *) rootClassName
{
return rootClassName;
}
@synthesize rootClassName;

- (void) setRootClassName:(NSString *)newRootClassName
{
Expand Down
30 changes: 5 additions & 25 deletions Example 1/PSHTreeGraph.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@
GCC_PREFIX_HEADER = PSHTreeGraph_Prefix.pch;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_PARAMETER = NO;
INFOPLIST_FILE = "PSHTreeGraph-Info.plist";
PRODUCT_NAME = PSHTreeGraph;
};
Expand All @@ -373,7 +372,6 @@
GCC_PREFIX_HEADER = PSHTreeGraph_Prefix.pch;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_PARAMETER = NO;
INFOPLIST_FILE = "PSHTreeGraph-Info.plist";
PRODUCT_NAME = PSHTreeGraph;
VALIDATE_PRODUCT = YES;
Expand All @@ -383,26 +381,12 @@
4F0E109B1407EB46009B9214 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
COPY_PHASE_STRIP = NO;
DEBUGGING_SYMBOLS = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
MACOSX_DEPLOYMENT_TARGET = 10.7;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = "";
OTHER_LDFLAGS = "";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
};
Expand All @@ -411,17 +395,8 @@
4F0E109C1407EB46009B9214 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
MACOSX_DEPLOYMENT_TARGET = 10.7;
OTHER_CFLAGS = "";
OTHER_LDFLAGS = "";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
};
Expand All @@ -435,6 +410,8 @@
GCC_C_LANGUAGE_STANDARD = c99;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = 2;
Expand All @@ -450,6 +427,8 @@
GCC_C_LANGUAGE_STANDARD = c99;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
SDKROOT = iphoneos;
Expand Down Expand Up @@ -477,6 +456,7 @@
4F0E109C1407EB46009B9214 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
C01FCF4E08A954540054247B /* Build configuration list for PBXProject "PSHTreeGraph" */ = {
isa = XCConfigurationList;
Expand Down
9 changes: 9 additions & 0 deletions PSTreeGraphView/PSBaseBranchView.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
#import "PSBaseTreeGraphView.h"



@interface PSBaseBranchView ()

- (UIBezierPath *) directConnectionsPath;
- (UIBezierPath *) orthogonalConnectionsPath;

@end


@implementation PSBaseBranchView


Expand Down
12 changes: 6 additions & 6 deletions PSTreeGraphView/PSBaseLeafView.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ - (void) updateLayerAppearanceToMatchContainerView
// [layer setBackgroundColor:[[self fillColor] CGColor] ];

// CGFloat scaleFactor = [[self window] userSpaceScaleFactor];
CGFloat scaleFactor = 1.0;
CGFloat scaleFactor = 1.0f;

[layer setBorderWidth:(borderWidth * scaleFactor)];
if (borderWidth > 0.0) {
if (borderWidth > 0.0f) {
[layer setBorderColor:[borderColor CGColor]];
}

Expand All @@ -71,10 +71,10 @@ - (void) configureDetaults
// Initialize ivars directly. As a rule, it's best to avoid invoking accessors from an -init...
// method, since they may wrongly expect the instance to be fully formed.

borderColor = [[UIColor colorWithRed:1.0 green:0.8 blue:0.4 alpha:1.0] retain];
borderWidth = 3.0;
cornerRadius = 8.0;
fillColor = [[UIColor colorWithRed:1.0 green:0.5 blue:0.0 alpha:1.0] retain];
borderColor = [[UIColor colorWithRed:1.0f green:0.8f blue:0.4f alpha:1.0f] retain];
borderWidth = 3.0f;
cornerRadius = 8.0f;
fillColor = [[UIColor colorWithRed:1.0f green:0.5f blue:0.0f alpha:1.0f] retain];
showingSelected = NO;

[self updateLayerAppearanceToMatchContainerView];
Expand Down
12 changes: 7 additions & 5 deletions PSTreeGraphView/PSBaseSubtreeView.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@
id <PSTreeGraphModelNode> modelNode; // the model node that nodeView represents

// Views
UIView *nodeView; // the subview of this SubtreeView that shows a representation of the modelNode
UIView *nodeView; // the subview of this SubtreeView that shows a representation
// of the modelNode

PSBaseBranchView *connectorsView; // the view that shows connections from nodeView to its child nodes

// State
BOOL expanded; // YES if this subtree is expanded to show its descendants; NO if it's been
// collapsed to show just its root node
BOOL expanded; // YES if this subtree is expanded to show its descendants;
// NO if it's been collapsed to show just its root node

BOOL needsGraphLayout; // YES if this SubtreeView needs to position its child views and assess its
// size; NO if we're sure its layout is up to date
BOOL needsGraphLayout; // YES if this SubtreeView needs to position its child views
// and assess its size; NO if we're sure its layout is up to date
}

/// Initializes a SubtreeView with the associated modelNode. This is SubtreeView's designated initializer.
Expand Down
Loading

0 comments on commit 66c7644

Please sign in to comment.