Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

v1.0

  • Loading branch information...
commit 603dd5ab4511c1a17a485a31c78639465a5d586d 0 parents
Ben Williamson authored

Showing 351 changed files with 33,229 additions and 0 deletions. Show diff stats Hide diff stats

  1. +4 0 .gitignore
  2. +52 0 Classes/AboutViewController.h
  3. +225 0 Classes/AboutViewController.m
  4. +43 0 Classes/AboutWebViewController.h
  5. +130 0 Classes/AboutWebViewController.m
  6. +66 0 Classes/CalendarHelpers.h
  7. +130 0 Classes/CalendarHelpers.m
  8. +59 0 Classes/Chart.h
  9. +45 0 Classes/Chart.m
  10. +47 0 Classes/ChartDataset.h
  11. +66 0 Classes/ChartDataset.m
  12. +42 0 Classes/ChartLoader.h
  13. +108 0 Classes/ChartLoader.m
  14. +69 0 Classes/ChartParser.h
  15. +357 0 Classes/ChartParser.m
  16. +46 0 Classes/ChartRequest.h
  17. +106 0 Classes/ChartRequest.m
  18. +59 0 Classes/ChartSeries.h
  19. +67 0 Classes/ChartSeries.m
  20. +48 0 Classes/ChartValue.h
  21. +62 0 Classes/ChartValue.m
  22. +92 0 Classes/ChartViewController.h
  23. +591 0 Classes/ChartViewController.m
  24. +91 0 Classes/DataLoader.h
  25. +241 0 Classes/DataLoader.m
  26. +122 0 Classes/DataManager.h
  27. +476 0 Classes/DataManager.m
  28. +46 0 Classes/DataParser.h
  29. +60 0 Classes/DataParser.m
  30. +69 0 Classes/DataRequest.h
  31. +72 0 Classes/DataRequest.m
  32. +38 0 Classes/FancyLabel.h
  33. +71 0 Classes/FancyLabel.m
  34. +50 0 Classes/FavouriteToggleButtonController.h
  35. +117 0 Classes/FavouriteToggleButtonController.m
  36. +51 0 Classes/Favourites.h
  37. +158 0 Classes/Favourites.m
  38. +43 0 Classes/FavouritesTableViewController.h
  39. +236 0 Classes/FavouritesTableViewController.m
  40. +51 0 Classes/FetchedPlaceTableViewController.h
  41. +139 0 Classes/FetchedPlaceTableViewController.m
  42. +50 0 Classes/JSON/JSON.h
  43. +68 0 Classes/JSON/NSObject+SBJSON.h
  44. +53 0 Classes/JSON/NSObject+SBJSON.m
  45. +58 0 Classes/JSON/NSString+SBJSON.h
  46. +55 0 Classes/JSON/NSString+SBJSON.m
  47. +75 0 Classes/JSON/SBJSON.h
  48. +212 0 Classes/JSON/SBJSON.m
  49. +86 0 Classes/JSON/SBJsonBase.h
  50. +78 0 Classes/JSON/SBJsonBase.m
  51. +87 0 Classes/JSON/SBJsonParser.h
  52. +475 0 Classes/JSON/SBJsonParser.m
  53. +129 0 Classes/JSON/SBJsonWriter.h
  54. +228 0 Classes/JSON/SBJsonWriter.m
  55. +82 0 Classes/LandscapeViewController.h
  56. +300 0 Classes/LandscapeViewController.m
  57. +61 0 Classes/Measurement.h
  58. +140 0 Classes/Measurement.m
  59. +43 0 Classes/NSDictionary+XMLStreamParserHelpers.h
  60. +49 0 Classes/NSDictionary+XMLStreamParserHelpers.m
  61. +41 0 Classes/NSManagedObject+StackHelpers.h
  62. +73 0 Classes/NSManagedObject+StackHelpers.m
  63. +39 0 Classes/NSManagedObjectContext+Helpers.h
  64. +54 0 Classes/NSManagedObjectContext+Helpers.m
  65. +51 0 Classes/Observation.h
  66. +58 0 Classes/Observation.m
  67. +104 0 Classes/Place.h
  68. +113 0 Classes/Place.m
  69. +59 0 Classes/PlaceCell.h
  70. +127 0 Classes/PlaceCell.m
  71. +92 0 Classes/PlaceDetailViewController.h
  72. +502 0 Classes/PlaceDetailViewController.m
  73. +42 0 Classes/PlaceLoader.h
  74. +104 0 Classes/PlaceLoader.m
  75. +49 0 Classes/PlaceParser.h
  76. +401 0 Classes/PlaceParser.m
  77. +56 0 Classes/PlaceRequest.h
  78. +128 0 Classes/PlaceRequest.m
  79. +60 0 Classes/PlaceTableViewController.h
  80. +110 0 Classes/PlaceTableViewController.m
  81. +53 0 Classes/PlaceType.h
  82. +120 0 Classes/PlaceType.m
  83. BIN  Classes/Places.xcdatamodel/elements
  84. BIN  Classes/Places.xcdatamodel/layout
  85. +92 0 Classes/Reachability.h
  86. +280 0 Classes/Reachability.m
  87. +44 0 Classes/SearchViewController.h
  88. +170 0 Classes/SearchViewController.m
  89. +44 0 Classes/SlakeAppDelegate.h
  90. +248 0 Classes/SlakeAppDelegate.m
  91. +105 0 Classes/XMLStreamParser.h
  92. +274 0 Classes/XMLStreamParser.m
  93. +173 0 Classes/XMLStreamParser.txt
  94. +90 0 LICENSE.txt
  95. BIN  Places.sqlite
  96. +37 0 README.md
  97. +87 0 Release-notes.txt
  98. +42 0 Slake-Info.plist
  99. +882 0 Slake.xcodeproj/project.pbxproj
  100. +17 0 Slake_Prefix.pch
  101. +28 0 Todo.txt
  102. +25 0 about/about.html
  103. +107 0 about/css/style.css
  104. +34 0 about/disclamer.html
  105. +49 0 about/features.html
  106. BIN  about/images/bg.png
  107. BIN  about/images/btn-about.png
  108. BIN  about/images/btn-aust.png
  109. BIN  about/images/btn-fav.png
  110. BIN  about/images/btn-search.png
  111. +35 0 core-plot/.hgignore
  112. +4 0 core-plot/.hgtags
  113. +9 0 core-plot/License.txt
  114. +59 0 core-plot/framework/CorePlot-CocoaTouch.h
  115. +1,120 0 core-plot/framework/CorePlot-CocoaTouch.xcodeproj/project.pbxproj
  116. +58 0 core-plot/framework/CorePlot.h
  117. BIN  core-plot/framework/CorePlot.xcodeproj/TemplateIcon.icns
  118. +1,433 0 core-plot/framework/CorePlot.xcodeproj/project.pbxproj
  119. +8 0 core-plot/framework/CorePlot_CocoaTouch_Prefix.pch
  120. +13 0 core-plot/framework/CorePlot_Prefix.pch
  121. BIN  core-plot/framework/English.lproj/InfoPlist.strings
  122. +3,098 0 core-plot/framework/English.lproj/MainMenu.xib
  123. +30 0 core-plot/framework/Info-CocoaTouch.plist
  124. +26 0 core-plot/framework/Info.plist
  125. +9 0 core-plot/framework/MacOnly/CPDecimalNumberValueTransformer.h
  126. +28 0 core-plot/framework/MacOnly/CPDecimalNumberValueTransformer.m
  127. +12 0 core-plot/framework/MacOnly/CPLayerHostingView.h
  128. +76 0 core-plot/framework/MacOnly/CPLayerHostingView.m
  129. +25 0 core-plot/framework/MacOnly/CPPlatformSpecificCategories.h
  130. +47 0 core-plot/framework/MacOnly/CPPlatformSpecificCategories.m
  131. +14 0 core-plot/framework/MacOnly/CPPlatformSpecificDefines.h
  132. 0  core-plot/framework/MacOnly/CPPlatformSpecificDefines.m
  133. +23 0 core-plot/framework/MacOnly/CPPlatformSpecificFunctions.h
  134. +87 0 core-plot/framework/MacOnly/CPPlatformSpecificFunctions.m
  135. +2 0  core-plot/framework/MacOnly/CPTextStylePlatformSpecific.h
  136. +57 0 core-plot/framework/MacOnly/CPTextStylePlatformSpecific.m
  137. +26 0 core-plot/framework/SDKBuild/README.txt
  138. +28 0 core-plot/framework/SDKBuild/build.sh
  139. +3 0  core-plot/framework/SDKBuild/cp.sed
  140. +51 0 core-plot/framework/SDKBuild/iphoneos-SDKSettings.plist
  141. +37 0 core-plot/framework/SDKBuild/iphonesimulator-SDKSettings.plist
  142. +46 0 core-plot/framework/Source/CPAnimation.h
  143. +101 0 core-plot/framework/Source/CPAnimation.m
  144. +17 0 core-plot/framework/Source/CPAnimationKeyFrame.h
  145. +56 0 core-plot/framework/Source/CPAnimationKeyFrame.m
  146. +35 0 core-plot/framework/Source/CPAnimationTransition.h
  147. +87 0 core-plot/framework/Source/CPAnimationTransition.m
  148. +29 0 core-plot/framework/Source/CPAnnotation.h
  149. +102 0 core-plot/framework/Source/CPAnnotation.m
  150. +15 0 core-plot/framework/Source/CPAnnotationHostLayer.h
  151. +82 0 core-plot/framework/Source/CPAnnotationHostLayer.m
  152. +210 0 core-plot/framework/Source/CPAxis.h
  153. +1,331 0 core-plot/framework/Source/CPAxis.m
  154. +36 0 core-plot/framework/Source/CPAxisLabel.h
  155. +204 0 core-plot/framework/Source/CPAxisLabel.m
  156. +8 0 core-plot/framework/Source/CPAxisLabelGroup.h
  157. +23 0 core-plot/framework/Source/CPAxisLabelGroup.m
  158. +8 0 core-plot/framework/Source/CPAxisLabelTests.h
  159. +138 0 core-plot/framework/Source/CPAxisLabelTests.m
  160. +17 0 core-plot/framework/Source/CPAxisSet.h
  161. +96 0 core-plot/framework/Source/CPAxisSet.m
  162. +10 0 core-plot/framework/Source/CPAxisTitle.h
  163. +62 0 core-plot/framework/Source/CPAxisTitle.m
  164. +89 0 core-plot/framework/Source/CPBarPlot.h
  165. +688 0 core-plot/framework/Source/CPBarPlot.m
  166. +16 0 core-plot/framework/Source/CPBorderedLayer.h
  167. +163 0 core-plot/framework/Source/CPBorderedLayer.m
  168. +42 0 core-plot/framework/Source/CPColor.h
  169. +395 0 core-plot/framework/Source/CPColor.m
  170. +16 0 core-plot/framework/Source/CPColorSpace.h
  171. +93 0 core-plot/framework/Source/CPColorSpace.m
  172. +31 0 core-plot/framework/Source/CPConstrainedPosition.h
  173. +135 0 core-plot/framework/Source/CPConstrainedPosition.m
  174. +8 0 core-plot/framework/Source/CPDarkGradientTheme.h
  175. +97 0 core-plot/framework/Source/CPDarkGradientTheme.m
  176. +6 0 core-plot/framework/Source/CPDarkGradientThemeTests.h
  177. +36 0 core-plot/framework/Source/CPDarkGradientThemeTests.m
  178. +28 0 core-plot/framework/Source/CPDataSourceTestCase.h
  179. +137 0 core-plot/framework/Source/CPDataSourceTestCase.m
  180. +106 0 core-plot/framework/Source/CPDefinitions.h
  181. +10 0 core-plot/framework/Source/CPDefinitions.m
  182. +7 0 core-plot/framework/Source/CPDerivedXYGraph.h
  183. +7 0 core-plot/framework/Source/CPDerivedXYGraph.m
  184. +10 0 core-plot/framework/Source/CPExceptions.h
  185. +5 0 core-plot/framework/Source/CPExceptions.m
  186. +40 0 core-plot/framework/Source/CPFill.h
  187. +136 0 core-plot/framework/Source/CPFill.m
  188. +98 0 core-plot/framework/Source/CPGradient.h
  189. +1,397 0 core-plot/framework/Source/CPGradient.m
  190. +107 0 core-plot/framework/Source/CPGraph.h
  191. +599 0 core-plot/framework/Source/CPGraph.m
  192. +14 0 core-plot/framework/Source/CPGridLineGroup.h
  193. +65 0 core-plot/framework/Source/CPGridLineGroup.m
  194. +15 0 core-plot/framework/Source/CPGridLines.h
  195. +51 0 core-plot/framework/Source/CPGridLines.m
  196. +33 0 core-plot/framework/Source/CPImage.h
  197. +176 0 core-plot/framework/Source/CPImage.m
  198. +84 0 core-plot/framework/Source/CPLayer.h
  199. +637 0 core-plot/framework/Source/CPLayer.m
  200. +18 0 core-plot/framework/Source/CPLayerAnnotation.h
  201. +153 0 core-plot/framework/Source/CPLayerAnnotation.m
  202. +48 0 core-plot/framework/Source/CPLayoutManager.h
  203. +1 0  core-plot/framework/Source/CPLayoutManager.m
  204. +38 0 core-plot/framework/Source/CPLineStyle.h
  205. +126 0 core-plot/framework/Source/CPLineStyle.m
  206. +8 0 core-plot/framework/Source/CPPathExtensions.h
  207. +40 0 core-plot/framework/Source/CPPathExtensions.m
  208. +69 0 core-plot/framework/Source/CPPieChart.h
  209. +232 0 core-plot/framework/Source/CPPieChart.m
  210. +9 0 core-plot/framework/Source/CPPlainBlackTheme.h
  211. +86 0 core-plot/framework/Source/CPPlainBlackTheme.m
  212. +9 0 core-plot/framework/Source/CPPlainWhiteTheme.h
  213. +86 0 core-plot/framework/Source/CPPlainWhiteTheme.m
  214. +148 0 core-plot/framework/Source/CPPlot.h
  215. +328 0 core-plot/framework/Source/CPPlot.m
  216. +55 0 core-plot/framework/Source/CPPlotArea.h
  217. +525 0 core-plot/framework/Source/CPPlotArea.m
  218. +16 0 core-plot/framework/Source/CPPlotAreaFrame.h
  219. +124 0 core-plot/framework/Source/CPPlotAreaFrame.m
  220. +18 0 core-plot/framework/Source/CPPlotGroup.h
  221. +64 0 core-plot/framework/Source/CPPlotGroup.m
  222. +45 0 core-plot/framework/Source/CPPlotRange.h
  223. +280 0 core-plot/framework/Source/CPPlotRange.m
  224. +119 0 core-plot/framework/Source/CPPlotSpace.h
  225. +175 0 core-plot/framework/Source/CPPlotSpace.m
  226. +8 0 core-plot/framework/Source/CPPlotSpaceAnnotation.h
  227. +10 0 core-plot/framework/Source/CPPlotSpaceAnnotation.m
  228. +67 0 core-plot/framework/Source/CPPlotSymbol.h
  229. +446 0 core-plot/framework/Source/CPPlotSymbol.m
  230. +9 0 core-plot/framework/Source/CPPolarPlotSpace.h
  231. +10 0 core-plot/framework/Source/CPPolarPlotSpace.m
  232. +35 0 core-plot/framework/Source/CPResponder.h
  233. +79 0 core-plot/framework/Source/CPScatterPlot.h
  234. +695 0 core-plot/framework/Source/CPScatterPlot.m
  235. +13 0 core-plot/framework/Source/CPScatterPlotTests.h
  236. +192 0 core-plot/framework/Source/CPScatterPlotTests.m
  237. +8 0 core-plot/framework/Source/CPSlateTheme.h
  238. +90 0 core-plot/framework/Source/CPSlateTheme.m
  239. +9 0 core-plot/framework/Source/CPStocksTheme.h
  240. +92 0 core-plot/framework/Source/CPStocksTheme.m
  241. +16 0 core-plot/framework/Source/CPTestCase.h
  242. +14 0 core-plot/framework/Source/CPTestCase.m
  243. +30 0 core-plot/framework/Source/CPTextLayer.h
  244. +133 0 core-plot/framework/Source/CPTextLayer.m
  245. +40 0 core-plot/framework/Source/CPTextStyle.h
  246. +90 0 core-plot/framework/Source/CPTextStyle.m
  247. +7 0 core-plot/framework/Source/CPTextStyleTests.h
  248. +18 0 core-plot/framework/Source/CPTextStyleTests.m
  249. +58 0 core-plot/framework/Source/CPTheme.h
  250. +177 0 core-plot/framework/Source/CPTheme.m
  251. +7 0 core-plot/framework/Source/CPThemeTests.h
  252. +72 0 core-plot/framework/Source/CPThemeTests.m
  253. +17 0 core-plot/framework/Source/CPTimeFormatter.h
  254. +83 0 core-plot/framework/Source/CPTimeFormatter.m
  255. +78 0 core-plot/framework/Source/CPTradingRangePlot.h
  256. +799 0 core-plot/framework/Source/CPTradingRangePlot.m
  257. +61 0 core-plot/framework/Source/CPUtilities.h
Sorry, we could not display the entire diff because too many files (351) changed.
4 .gitignore
... ... @@ -0,0 +1,4 @@
  1 +*.mode1v3
  2 +*.pbxuser
  3 +build
  4 +.DS_Store
52 Classes/AboutViewController.h
... ... @@ -0,0 +1,52 @@
  1 +//
  2 +// AboutViewController.h
  3 +// Slake
  4 +//
  5 +// Created by Ben Williamson on 8/04/10.
  6 +//
  7 +// Copyright (c) 2010 Bureau of Meteorology
  8 +// All rights reserved.
  9 +//
  10 +// Redistribution and use in source and binary forms, with or without
  11 +// modification, are permitted provided that the following conditions are met:
  12 +//
  13 +// * Redistributions of source code must retain the above copyright notice, this
  14 +// list of conditions and the following disclaimer.
  15 +//
  16 +// * Redistributions in binary form must reproduce the above copyright notice,
  17 +// this list of conditions and the following disclaimer in the documentation
  18 +// and/or other materials provided with the distribution.
  19 +//
  20 +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21 +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22 +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  23 +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  24 +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  25 +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  26 +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  27 +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28 +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30 +//
  31 +
  32 +#import <UIKit/UIKit.h>
  33 +
  34 +
  35 +@interface AboutViewController : UIViewController <UIActionSheetDelegate, MFMailComposeViewControllerDelegate> {
  36 + UIView* credits;
  37 + UILabel* versionLabel;
  38 + BOOL creditsVisible;
  39 + UISegmentedControl* segmentedButton;
  40 +}
  41 +
  42 +@property (nonatomic, retain) IBOutlet UIView* credits;
  43 +@property (nonatomic, retain) IBOutlet UILabel* versionLabel;
  44 +@property (nonatomic, retain) IBOutlet UISegmentedControl* segmentedButton;
  45 +
  46 +- (IBAction)showWebsite;
  47 +- (IBAction)sendFeedback;
  48 +- (IBAction)showCredits;
  49 +- (IBAction)hideCredits;
  50 +- (IBAction)segmentedButtonValueChanged;
  51 +
  52 +@end
225 Classes/AboutViewController.m
... ... @@ -0,0 +1,225 @@
  1 +//
  2 +// AboutViewController.m
  3 +// Slake
  4 +//
  5 +// Created by Ben Williamson on 8/04/10.
  6 +//
  7 +// Copyright (c) 2010 Bureau of Meteorology
  8 +// All rights reserved.
  9 +//
  10 +// Redistribution and use in source and binary forms, with or without
  11 +// modification, are permitted provided that the following conditions are met:
  12 +//
  13 +// * Redistributions of source code must retain the above copyright notice, this
  14 +// list of conditions and the following disclaimer.
  15 +//
  16 +// * Redistributions in binary form must reproduce the above copyright notice,
  17 +// this list of conditions and the following disclaimer in the documentation
  18 +// and/or other materials provided with the distribution.
  19 +//
  20 +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21 +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22 +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  23 +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  24 +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  25 +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  26 +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  27 +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28 +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30 +//
  31 +
  32 +#import "AboutViewController.h"
  33 +#import "AboutWebViewController.h"
  34 +
  35 +@interface AboutViewController () // private
  36 +
  37 +@property (nonatomic) BOOL creditsVisible;
  38 +
  39 +- (void)showActionSheet;
  40 +
  41 +@end
  42 +
  43 +static float kCreditsPositionHidden = 400.0f;
  44 +static float kCreditsPositionVisible = 245.0f;
  45 +
  46 +struct AboutPage {
  47 + NSString* title;
  48 + NSString* url;
  49 +};
  50 +
  51 +// These are in the same order as the segmentedButton segments:
  52 +static const struct AboutPage pages[] = {
  53 + { @"Features", @"about/features.html" },
  54 + { @"Copyright", @"http://www.bom.gov.au/water/waterstorage/iphone/copyright.php" },
  55 + { @"Disclaimer", @"about/disclamer.html" }
  56 +};
  57 +
  58 +static const int kNumberOfPages = sizeof pages / sizeof pages[0];
  59 +
  60 +@implementation AboutViewController
  61 +
  62 +@synthesize credits;
  63 +@synthesize versionLabel;
  64 +@synthesize creditsVisible;
  65 +@synthesize segmentedButton;
  66 +
  67 +
  68 +- (void)dealloc
  69 +{
  70 + [credits release];
  71 + [versionLabel release];
  72 + [segmentedButton release];
  73 + [super dealloc];
  74 +}
  75 +
  76 +// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
  77 +- (void)viewDidLoad
  78 +{
  79 + [super viewDidLoad];
  80 + NSString* version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleGetInfoString"];
  81 + self.versionLabel.text = [NSString stringWithFormat:@"Water Storage %@", version];
  82 + self.segmentedButton.tintColor = [UIColor colorWithRed:20.0/255.0 green:130.0/255.0 blue:192.0/255.0 alpha:1.0];
  83 +}
  84 +
  85 +- (void)didReceiveMemoryWarning
  86 +{
  87 + // Releases the view if it doesn't have a superview.
  88 + [super didReceiveMemoryWarning];
  89 +
  90 + // Release any cached data, images, etc that aren't in use.
  91 +}
  92 +
  93 +- (void)viewDidUnload
  94 +{
  95 + // Release any retained subviews of the main view.
  96 + // e.g. self.myOutlet = nil;
  97 + self.credits = nil;
  98 + self.versionLabel = nil;
  99 + self.segmentedButton = nil;
  100 +
  101 + [super viewDidUnload];
  102 +}
  103 +
  104 +- (void)showActionSheet
  105 +{
  106 + UIActionSheet* sheet = [[[UIActionSheet alloc] initWithTitle:@"Water Storage at www.bom.gov.au"
  107 + delegate:self
  108 + cancelButtonTitle:@"Cancel"
  109 + destructiveButtonTitle:nil
  110 + otherButtonTitles:@"Open in Safari", @"Copy URL", nil] autorelease];
  111 + sheet.actionSheetStyle = UIActionSheetStyleDefault;
  112 + UIView* rootView = [UIApplication sharedApplication].keyWindow;
  113 + [sheet showInView:rootView];
  114 +}
  115 +
  116 +- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
  117 +{
  118 + NSString* urlString = @"http://www.bom.gov.au/water/waterstorage/iphone.shtml";
  119 + NSURL* url = [NSURL URLWithString:urlString];
  120 + switch (buttonIndex) {
  121 + case 0:
  122 + [[UIApplication sharedApplication] openURL:url];
  123 + break;
  124 + case 1:
  125 + [UIPasteboard generalPasteboard].string = urlString;
  126 + break;
  127 + }
  128 +}
  129 +
  130 +- (IBAction)showWebsite
  131 +{
  132 + [self showActionSheet];
  133 +}
  134 +
  135 +- (BOOL)canBecomeFirstResponder
  136 +{
  137 + return YES;
  138 +}
  139 +
  140 +- (void)viewWillAppear:(BOOL)animated
  141 +{
  142 + CGRect frame = self.credits.frame;
  143 + frame.origin.y = kCreditsPositionHidden;
  144 + self.credits.frame = frame;
  145 + self.creditsVisible = NO;
  146 +}
  147 +
  148 +- (void)viewDidAppear:(BOOL)animated
  149 +{
  150 + [super viewDidAppear:animated];
  151 + [self becomeFirstResponder];
  152 + self.segmentedButton.selectedSegmentIndex = -1;
  153 +}
  154 +
  155 +- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
  156 +{
  157 + if (motion == UIEventSubtypeMotionShake) {
  158 + if (self.creditsVisible) {
  159 + [self hideCredits];
  160 + } else {
  161 + [self showCredits];
  162 + }
  163 + }
  164 +}
  165 +
  166 +- (IBAction)sendFeedback
  167 +{
  168 + MFMailComposeViewController *mailViewController = [[[MFMailComposeViewController alloc] init] autorelease];
  169 + mailViewController.mailComposeDelegate = self;
  170 + [mailViewController setToRecipients:[NSArray arrayWithObject:@"waterinfo@bom.gov.au"]];
  171 + [mailViewController setSubject:@"Feedback on Water Storage"];
  172 + [self presentModalViewController:mailViewController animated:YES];
  173 +}
  174 +
  175 +-(void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
  176 +{
  177 + [self dismissModalViewControllerAnimated:YES];
  178 +}
  179 +
  180 +- (IBAction)showCredits
  181 +{
  182 + [UIView beginAnimations:@"credits" context:nil];
  183 + [UIView setAnimationDuration:0.5f];
  184 + [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
  185 + CGRect frame = self.credits.frame;
  186 + frame.origin.y = kCreditsPositionVisible;
  187 + self.credits.frame = frame;
  188 + [UIView commitAnimations];
  189 + self.creditsVisible = YES;
  190 + if (UIAccessibilityIsVoiceOverRunning != nil && UIAccessibilityIsVoiceOverRunning()) {
  191 + UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, nil);
  192 + UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, @"Credits displayed");
  193 + }
  194 +}
  195 +
  196 +- (IBAction)hideCredits
  197 +{
  198 + [UIView beginAnimations:@"credits" context:nil];
  199 + [UIView setAnimationDuration:0.5f];
  200 + [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
  201 + CGRect frame = self.credits.frame;
  202 + frame.origin.y = kCreditsPositionHidden;
  203 + self.credits.frame = frame;
  204 + [UIView commitAnimations];
  205 + self.creditsVisible = NO;
  206 + if (UIAccessibilityIsVoiceOverRunning != nil && UIAccessibilityIsVoiceOverRunning()) {
  207 + UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, nil);
  208 + UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, @"Credits hidden");
  209 + }
  210 +}
  211 +
  212 +- (IBAction)segmentedButtonValueChanged
  213 +{
  214 + int page = self.segmentedButton.selectedSegmentIndex;
  215 + if (page >= 0 && page < kNumberOfPages) {
  216 + NSURL* bundleURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]];
  217 +
  218 + AboutWebViewController* awvc = [[[AboutWebViewController alloc] init] autorelease];
  219 + awvc.title = pages[page].title;
  220 + awvc.pageURL = [NSURL URLWithString:pages[page].url relativeToURL:bundleURL];
  221 + [self.navigationController pushViewController:awvc animated:YES];
  222 + }
  223 +}
  224 +
  225 +@end
43 Classes/AboutWebViewController.h
... ... @@ -0,0 +1,43 @@
  1 +//
  2 +// AboutWebViewController.h
  3 +// Slake
  4 +//
  5 +// Created by Quentin Leseney on 10/08/10.
  6 +//
  7 +// Copyright (c) 2010 Bureau of Meteorology
  8 +// All rights reserved.
  9 +//
  10 +// Redistribution and use in source and binary forms, with or without
  11 +// modification, are permitted provided that the following conditions are met:
  12 +//
  13 +// * Redistributions of source code must retain the above copyright notice, this
  14 +// list of conditions and the following disclaimer.
  15 +//
  16 +// * Redistributions in binary form must reproduce the above copyright notice,
  17 +// this list of conditions and the following disclaimer in the documentation
  18 +// and/or other materials provided with the distribution.
  19 +//
  20 +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21 +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22 +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  23 +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  24 +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  25 +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  26 +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  27 +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28 +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30 +//
  31 +
  32 +#import <UIKit/UIKit.h>
  33 +
  34 +
  35 +@interface AboutWebViewController : UIViewController <UIWebViewDelegate, UIActionSheetDelegate, MFMailComposeViewControllerDelegate> {
  36 + NSURL* pageURL;
  37 + NSURL* _actionURL;
  38 +}
  39 +
  40 +@property (nonatomic, retain) NSURL* pageURL;
  41 +@property (nonatomic, retain) NSURL* actionURL;
  42 +
  43 +@end
130 Classes/AboutWebViewController.m
... ... @@ -0,0 +1,130 @@
  1 +//
  2 +// AboutWebViewController.h
  3 +// Slake
  4 +//
  5 +// Created by Quentin Leseney on 10/08/10.
  6 +//
  7 +// Copyright (c) 2010 Bureau of Meteorology
  8 +// All rights reserved.
  9 +//
  10 +// Redistribution and use in source and binary forms, with or without
  11 +// modification, are permitted provided that the following conditions are met:
  12 +//
  13 +// * Redistributions of source code must retain the above copyright notice, this
  14 +// list of conditions and the following disclaimer.
  15 +//
  16 +// * Redistributions in binary form must reproduce the above copyright notice,
  17 +// this list of conditions and the following disclaimer in the documentation
  18 +// and/or other materials provided with the distribution.
  19 +//
  20 +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21 +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22 +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  23 +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  24 +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  25 +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  26 +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  27 +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28 +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30 +//
  31 +
  32 +#import "AboutWebViewController.h"
  33 +
  34 +@implementation AboutWebViewController
  35 +
  36 +@synthesize pageURL = _pageURL;
  37 +@synthesize actionURL = _actionURL;
  38 +
  39 +
  40 +- (void)dealloc
  41 +{
  42 + [_pageURL release];
  43 + [_actionURL release];
  44 + [super dealloc];
  45 +}
  46 +
  47 +- (void)viewDidLoad
  48 +{
  49 + [super viewDidLoad];
  50 +
  51 + UIWebView* webView = (UIWebView*)self.view;
  52 + NSURLRequest* request = [NSURLRequest requestWithURL:self.pageURL];
  53 + webView.scalesPageToFit = YES;
  54 + webView.delegate = self;
  55 + [webView loadRequest:request];
  56 +}
  57 +
  58 +- (void)viewDidUnload
  59 +{
  60 + // Release any retained subviews of the main view.
  61 + // e.g. self.myOutlet = nil;
  62 + [super viewDidUnload];
  63 +}
  64 +
  65 +- (void)viewDidAppear:(BOOL)animated
  66 +{
  67 + [super viewDidAppear:animated];
  68 +}
  69 +
  70 +- (void)showActionSheetForURL:(NSURL*)url
  71 +{
  72 + self.actionURL = url;
  73 + NSString* scheme = [url scheme];
  74 + NSString* openButtonTitle;
  75 + NSString* copyButtonTitle;
  76 + if ([scheme isEqualToString:@"mailto"]) {
  77 + openButtonTitle = @"Open in Mail";
  78 + copyButtonTitle = @"Copy Email Address";
  79 + } else {
  80 + openButtonTitle = @"Open in Safari";
  81 + copyButtonTitle = @"Copy URL";
  82 + }
  83 + UIActionSheet* sheet = [[[UIActionSheet alloc] initWithTitle:[url absoluteString]
  84 + delegate:self
  85 + cancelButtonTitle:@"Cancel"
  86 + destructiveButtonTitle:nil
  87 + otherButtonTitles:openButtonTitle, copyButtonTitle, nil] autorelease];
  88 + sheet.actionSheetStyle = UIActionSheetStyleDefault;
  89 + UIView* rootView = [UIApplication sharedApplication].keyWindow;
  90 + [sheet showInView:rootView];
  91 +}
  92 +
  93 +- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
  94 +{
  95 + switch (buttonIndex) {
  96 + case 0:
  97 + [[UIApplication sharedApplication] openURL:self.actionURL];
  98 + break;
  99 + case 1:
  100 + [UIPasteboard generalPasteboard].string = [self.actionURL absoluteString];
  101 + break;
  102 + }
  103 +}
  104 +
  105 +- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
  106 +{
  107 + if (navigationType == UIWebViewNavigationTypeLinkClicked) {
  108 + NSURL* url = [request URL];
  109 + NSString* scheme = [url scheme];
  110 + if ([scheme isEqualToString:@"mailto"] && [MFMailComposeViewController canSendMail]) {
  111 + // Trim off "mailto:"
  112 + NSString* emailAddress = [[url absoluteString] substringFromIndex:[scheme length] + 1];
  113 + MFMailComposeViewController *mailViewController = [[[MFMailComposeViewController alloc] init] autorelease];
  114 + mailViewController.mailComposeDelegate = self;
  115 + [mailViewController setToRecipients:[NSArray arrayWithObject:emailAddress]];
  116 + [self presentModalViewController:mailViewController animated:YES];
  117 + } else {
  118 + [self showActionSheetForURL:[request URL]];
  119 + }
  120 + return NO;
  121 + }
  122 + return YES;
  123 +}
  124 +
  125 +-(void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
  126 +{
  127 + [self dismissModalViewControllerAnimated:YES];
  128 +}
  129 +
  130 +@end
66 Classes/CalendarHelpers.h
... ... @@ -0,0 +1,66 @@
  1 +//
  2 +// CalendarHelpers.h
  3 +// Slake
  4 +//
  5 +// Created by Quentin Leseney on 7/07/10.
  6 +//
  7 +// Copyright (c) 2010 Bureau of Meteorology
  8 +// All rights reserved.
  9 +//
  10 +// Redistribution and use in source and binary forms, with or without
  11 +// modification, are permitted provided that the following conditions are met:
  12 +//
  13 +// * Redistributions of source code must retain the above copyright notice, this
  14 +// list of conditions and the following disclaimer.
  15 +//
  16 +// * Redistributions in binary form must reproduce the above copyright notice,
  17 +// this list of conditions and the following disclaimer in the documentation
  18 +// and/or other materials provided with the distribution.
  19 +//
  20 +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21 +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22 +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  23 +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  24 +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  25 +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  26 +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  27 +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28 +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30 +//
  31 +// All date structures are using a shared gregorian calendar in English locale and the UTC timezone
  32 +// (no daylight saving, safe to perform dates arithmetics)
  33 +//
  34 +
  35 +#import <Foundation/Foundation.h>
  36 +
  37 +@interface NSCalendar (CalendarHelpers)
  38 +
  39 ++ (BOOL)isLeapYear:(int)year;
  40 +
  41 ++ (NSCalendar*)gregorian;
  42 +
  43 +@end
  44 +
  45 +
  46 +@interface NSDate (CalendarHelpers)
  47 +
  48 +- (NSString*)readableDateWithWeekDay;
  49 +
  50 +- (NSString*)readableDateNoWeekDay;
  51 +
  52 +@end
  53 +
  54 +
  55 +@interface NSDateFormatter (CalendarHelpers)
  56 +
  57 ++ (NSDateFormatter*) dateFormatterWithFormat:(NSString*)format;
  58 +
  59 +@end
  60 +
  61 +
  62 +@interface NSObject (CalendarHelpers)
  63 +
  64 +- (NSDate*) dateFromStringISO8601DateTimeExtended;
  65 +
  66 +@end
130 Classes/CalendarHelpers.m
... ... @@ -0,0 +1,130 @@
  1 +//
  2 +// CalendarHelpers.m
  3 +// Slake
  4 +//
  5 +// Created by Quentin Leseney on 7/07/10.
  6 +//
  7 +// Copyright (c) 2010 Bureau of Meteorology
  8 +// All rights reserved.
  9 +//
  10 +// Redistribution and use in source and binary forms, with or without
  11 +// modification, are permitted provided that the following conditions are met:
  12 +//
  13 +// * Redistributions of source code must retain the above copyright notice, this
  14 +// list of conditions and the following disclaimer.
  15 +//
  16 +// * Redistributions in binary form must reproduce the above copyright notice,
  17 +// this list of conditions and the following disclaimer in the documentation
  18 +// and/or other materials provided with the distribution.
  19 +//
  20 +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21 +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22 +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  23 +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  24 +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  25 +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  26 +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  27 +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28 +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30 +//
  31 +#import "CalendarHelpers.h"
  32 +
  33 +@implementation NSCalendar (CalendarHelpers)
  34 +
  35 ++ (BOOL)isLeapYear:(int)year
  36 +{
  37 + if (year % 400 == 0) {
  38 + return YES;
  39 + } else if (year % 100 == 0) {
  40 + return NO;
  41 + } else if (year % 4 == 0) {
  42 + return YES;
  43 + } else {
  44 + return NO;
  45 + }
  46 +}
  47 +
  48 ++ (NSCalendar*)gregorian
  49 +{
  50 + static NSCalendar* gregorian = nil;
  51 + if (gregorian == nil) {
  52 + gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
  53 + gregorian.locale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en"] autorelease];
  54 + gregorian.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"];
  55 + }
  56 + return gregorian;
  57 +}
  58 +
  59 +@end
  60 +
  61 +
  62 +@implementation NSDate (CalendarHelpers)
  63 +
  64 +- (NSString*)readableDateWithWeekDay
  65 +{
  66 + static NSDateFormatter* dateFormatterReadableDateWithWeekDay = nil;
  67 + if (dateFormatterReadableDateWithWeekDay == nil) {
  68 + dateFormatterReadableDateWithWeekDay = [[NSDateFormatter alloc] init];
  69 + dateFormatterReadableDateWithWeekDay.dateFormat = @"EEE d MMM yyyy";
  70 + dateFormatterReadableDateWithWeekDay.calendar = [NSCalendar gregorian];
  71 + dateFormatterReadableDateWithWeekDay.locale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en"] autorelease];
  72 + dateFormatterReadableDateWithWeekDay.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"];
  73 + }
  74 + return [dateFormatterReadableDateWithWeekDay stringFromDate:self];
  75 +}
  76 +
  77 +- (NSString*)readableDateNoWeekDay
  78 +{
  79 + static NSDateFormatter* dateFormatterReadableDateNoWeekDay = nil;
  80 + if (dateFormatterReadableDateNoWeekDay == nil) {
  81 + dateFormatterReadableDateNoWeekDay = [[NSDateFormatter alloc] init];
  82 + dateFormatterReadableDateNoWeekDay.dateFormat = @"d MMM yyyy";
  83 + dateFormatterReadableDateNoWeekDay.calendar = [NSCalendar gregorian];
  84 + dateFormatterReadableDateNoWeekDay.locale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en"] autorelease];
  85 + dateFormatterReadableDateNoWeekDay.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"];
  86 + }
  87 + return [dateFormatterReadableDateNoWeekDay stringFromDate:self];
  88 +}
  89 +
  90 +@end
  91 +
  92 +
  93 +@implementation NSDateFormatter (CalendarHelpers)
  94 +
  95 +// Date formatter to parse NSString representing a basic (no hyphen) calendar date of the form 20100330
  96 +// http://en.wikipedia.org/wiki/ISO_8601#Calendar_dates
  97 ++ (NSDateFormatter*) dateFormatterWithFormat:(NSString*)format
  98 +{
  99 + NSDateFormatter* dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
  100 + dateFormatter.calendar = [NSCalendar gregorian];
  101 + dateFormatter.dateFormat = format;
  102 + dateFormatter.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"];
  103 + return dateFormatter;
  104 +}
  105 +
  106 +@end
  107 +
  108 +
  109 +@implementation NSObject (CalendarHelpers)
  110 +
  111 +// Parse an NSString representing an extended (using separators) date and time of the form 2010-03-30T00:00:00
  112 +// http://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations
  113 +- (NSDate*) dateFromStringISO8601DateTimeExtended
  114 +{
  115 + static NSDateFormatter* dateFormatterISO8601DateTimeExtended = nil;
  116 + if (dateFormatterISO8601DateTimeExtended == nil) {
  117 + dateFormatterISO8601DateTimeExtended = [[NSDateFormatter alloc] init];
  118 + dateFormatterISO8601DateTimeExtended.calendar = [NSCalendar gregorian];
  119 + dateFormatterISO8601DateTimeExtended.dateFormat = @"yyyy-MM-dd'T'HH:mm:ss";
  120 + dateFormatterISO8601DateTimeExtended.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"];
  121 + }
  122 +
  123 + if ([self isKindOfClass:[NSString class]]) {
  124 + return [dateFormatterISO8601DateTimeExtended dateFromString:(NSString*)self];
  125 + } else {
  126 + return nil;
  127 + }
  128 +}
  129 +
  130 +@end
59 Classes/Chart.h
... ... @@ -0,0 +1,59 @@
  1 +//
  2 +// Chart.h
  3 +// Slake
  4 +//
  5 +// Created by Quentin Leseney on 10/05/10.
  6 +//
  7 +// Copyright (c) 2010 Bureau of Meteorology
  8 +// All rights reserved.
  9 +//
  10 +// Redistribution and use in source and binary forms, with or without
  11 +// modification, are permitted provided that the following conditions are met:
  12 +//
  13 +// * Redistributions of source code must retain the above copyright notice, this
  14 +// list of conditions and the following disclaimer.
  15 +//
  16 +// * Redistributions in binary form must reproduce the above copyright notice,
  17 +// this list of conditions and the following disclaimer in the documentation
  18 +// and/or other materials provided with the distribution.
  19 +//
  20 +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21 +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22 +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  23 +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  24 +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  25 +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  26 +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  27 +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28 +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30 +//
  31 +
  32 +#import <CoreData/CoreData.h>
  33 +
  34 +@class ChartSeries;
  35 +@class Place;
  36 +
  37 +@interface Chart : NSManagedObject
  38 +{
  39 +}
  40 +
  41 +@property (nonatomic, retain) NSDate* xEnd;
  42 +@property (nonatomic, retain) NSDate* xStart;
  43 +@property (nonatomic, retain) NSNumber* yMax;
  44 +@property (nonatomic, retain) NSNumber* yMin;
  45 +@property (nonatomic, retain) Place* place;
  46 +@property (nonatomic, retain) NSSet* series;
  47 +@property (nonatomic, retain) NSDate* loadDate;
  48 +
  49 +@end
  50 +
  51 +
  52 +@interface Chart (CoreDataGeneratedAccessors)
  53 +- (void)addSeriesObject:(ChartSeries*)value;
  54 +- (void)removeSeriesObject:(ChartSeries*)value;
  55 +- (void)addSeries:(NSSet*)value;
  56 +- (void)removeSeries:(NSSet*)value;
  57 +
  58 +@end
  59 +
45 Classes/Chart.m
... ... @@ -0,0 +1,45 @@
  1 +//
  2 +// Chart.m
  3 +// Slake
  4 +//
  5 +// Created by Quentin Leseney on 10/05/10.
  6 +//
  7 +// Copyright (c) 2010 Bureau of Meteorology
  8 +// All rights reserved.
  9 +//
  10 +// Redistribution and use in source and binary forms, with or without
  11 +// modification, are permitted provided that the following conditions are met:
  12 +//
  13 +// * Redistributions of source code must retain the above copyright notice, this
  14 +// list of conditions and the following disclaimer.
  15 +//
  16 +// * Redistributions in binary form must reproduce the above copyright notice,
  17 +// this list of conditions and the following disclaimer in the documentation
  18 +// and/or other materials provided with the distribution.
  19 +//
  20 +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21 +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22 +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  23 +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  24 +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  25 +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  26 +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  27 +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28 +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30 +//
  31 +
  32 +#import "Chart.h"
  33 +#import "Place.h"
  34 +
  35 +@implementation Chart
  36 +
  37 +@dynamic xEnd;
  38 +@dynamic xStart;
  39 +@dynamic yMax;
  40 +@dynamic yMin;
  41 +@dynamic place;
  42 +@dynamic series;
  43 +@dynamic loadDate;
  44 +
  45 +@end
47 Classes/ChartDataset.h
... ... @@ -0,0 +1,47 @@
  1 +//
  2 +// ChartDataset.h
  3 +// Slake
  4 +//
  5 +// Created by Quentin Leseney on 10/05/10.
  6 +//
  7 +// Copyright (c) 2010 Bureau of Meteorology
  8 +// All rights reserved.
  9 +//
  10 +// Redistribution and use in source and binary forms, with or without
  11 +// modification, are permitted provided that the following conditions are met:
  12 +//
  13 +// * Redistributions of source code must retain the above copyright notice, this
  14 +// list of conditions and the following disclaimer.
  15 +//
  16 +// * Redistributions in binary form must reproduce the above copyright notice,
  17 +// this list of conditions and the following disclaimer in the documentation
  18 +// and/or other materials provided with the distribution.
  19 +//
  20 +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21 +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22 +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  23 +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  24 +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  25 +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  26 +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  27 +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28 +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30 +//
  31 +
  32 +#import <CoreData/CoreData.h>
  33 +#import "CorePlot-CocoaTouch.h"
  34 +
  35 +@class ChartSeries;
  36 +@class ChartValue;
  37 +
  38 +@interface ChartDataset : NSManagedObject <CPPlotDataSource>
  39 +{
  40 +}
  41 +
  42 +@property (nonatomic, retain) ChartSeries* series;
  43 +
  44 +// An array of ChartValues
  45 +@property (nonatomic, retain) NSArray* values;
  46 +
  47 +@end
66 Classes/ChartDataset.m
... ... @@ -0,0 +1,66 @@
  1 +//
  2 +// ChartDataset.m
  3 +// Slake
  4 +//
  5 +// Created by Quentin Leseney on 10/05/10.
  6 +//
  7 +// Copyright (c) 2010 Bureau of Meteorology
  8 +// All rights reserved.
  9 +//
  10 +// Redistribution and use in source and binary forms, with or without
  11 +// modification, are permitted provided that the following conditions are met:
  12 +//
  13 +// * Redistributions of source code must retain the above copyright notice, this
  14 +// list of conditions and the following disclaimer.
  15 +//
  16 +// * Redistributions in binary form must reproduce the above copyright notice,
  17 +// this list of conditions and the following disclaimer in the documentation
  18 +// and/or other materials provided with the distribution.
  19 +//
  20 +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21 +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22 +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  23 +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  24 +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  25 +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  26 +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  27 +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28 +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30 +//
  31 +
  32 +#import "ChartDataset.h"
  33 +#import "Place.h"
  34 +
  35 +@implementation ChartDataset
  36 +
  37 +@dynamic series;
  38 +@dynamic values;
  39 +
  40 +-(NSUInteger)numberOfRecordsForPlot:(CPPlot *)plot
  41 +{
  42 + return self.values.count;
  43 +}
  44 +
  45 +
  46 +-(NSArray*)numbersForPlot:(CPPlot*)plot field:(NSUInteger)fieldEnum
  47 + recordIndexRange:(NSRange)indexRange
  48 +{
  49 + NSAssert(indexRange.location == 0 && indexRange.length == self.values.count, @"ChartDataSet: incorrect indexRange requested");
  50 +
  51 + NSArray* result;
  52 + if(fieldEnum == CPScatterPlotFieldX)
  53 + {
  54 + result = [self.values valueForKey:@"dayInYear"];
  55 + //result = [fetchedObjects valueForKey:@"timeIntervalInReferenceYear"]; //uncomment to use interval
  56 + }
  57 + else
  58 + {
  59 + //CPScatterPlotFieldY
  60 + result = [self.values valueForKey: @"percentage"];
  61 + }
  62 + return result;
  63 +}
  64 +
  65 +
  66 +@end
42 Classes/ChartLoader.h
... ... @@ -0,0 +1,42 @@
  1 +//
  2 +// ChartLoader.h
  3 +// Slake
  4 +//
  5 +// Created by Ben Williamson on 8/06/10.
  6 +//
  7 +// Copyright (c) 2010 Bureau of Meteorology
  8 +// All rights reserved.
  9 +//
  10 +// Redistribution and use in source and binary forms, with or without
  11 +// modification, are permitted provided that the following conditions are met:
  12 +//
  13 +// * Redistributions of source code must retain the above copyright notice, this
  14 +// list of conditions and the following disclaimer.
  15 +//
  16 +// * Redistributions in binary form must reproduce the above copyright notice,
  17 +// this list of conditions and the following disclaimer in the documentation
  18 +// and/or other materials provided with the distribution.
  19 +//
  20 +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21 +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22 +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  23 +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  24 +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  25 +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  26 +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  27 +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28 +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30 +//
  31 +
  32 +#import <Foundation/Foundation.h>
  33 +#import "DataLoader.h"
  34 +
  35 +@interface ChartLoader : DataLoader
  36 +{
  37 + NSManagedObjectID* _placeID;
  38 +}
  39 +
  40 +- (id)initWithPlaceID:(NSManagedObjectID *)placeID;
  41 +
  42 +@end
108 Classes/ChartLoader.m
... ... @@ -0,0 +1,108 @@
  1 +//
  2 +// ChartLoader.m
  3 +// Slake
  4 +//
  5 +// Created by Ben Williamson on 8/06/10.
  6 +//
  7 +// Copyright (c) 2010 Bureau of Meteorology
  8 +// All rights reserved.
  9 +//
  10 +// Redistribution and use in source and binary forms, with or without
  11 +// modification, are permitted provided that the following conditions are met:
  12 +//
  13 +// * Redistributions of source code must retain the above copyright notice, this
  14 +// list of conditions and the following disclaimer.
  15 +//
  16 +// * Redistributions in binary form must reproduce the above copyright notice,
  17 +// this list of conditions and the following disclaimer in the documentation
  18 +// and/or other materials provided with the distribution.
  19 +//
  20 +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21 +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22 +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  23 +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  24 +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  25 +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  26 +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  27 +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28 +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30 +//
  31 +
  32 +#import "ChartLoader.h"
  33 +#import "ChartParser.h"
  34 +#import "Place.h"
  35 +#import "NSManagedObjectContext+Helpers.h"
  36 +
  37 +
  38 +@interface ChartLoader () // private
  39 +
  40 +@property (nonatomic, retain) NSManagedObjectID* placeID;
  41 +
  42 +@end
  43 +
  44 +
  45 +@implementation ChartLoader
  46 +
  47 +@synthesize placeID = _placeID;
  48 +
  49 +
  50 +- (void)dealloc
  51 +{
  52 + [_placeID release];
  53 + [super dealloc];
  54 +}
  55 +
  56 +- (id)initWithPlaceID:(NSManagedObjectID*)placeID
  57 +{
  58 + assert(![placeID isTemporaryID]);
  59 + if ((self = [super init])) {
  60 + self.placeID = placeID;
  61 + }
  62 + return self;
  63 +}
  64 +
  65 +- (NSString*)resourcePath
  66 +{
  67 + Place* place = (Place*)[self.context objectWithID:self.placeID];
  68 + return [@"resources/xmlchart/" stringByAppendingString:place.urn];