Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 2 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
View
4 EnergySaver/EnergyBusterViewController.m
@@ -7,7 +7,7 @@
//
#import "EnergyBusterViewController.h"
-
+#import "EnergySaverAppDelegate.h"
@implementation EnergyBusterViewController
@@ -83,7 +83,7 @@ - (IBAction)actNever:(id) sender {
- (void)loadDailyRate {
[self selectNextEnergyBuster];
- NSWindow *window = [[[NSApplication sharedApplication] delegate] window];
+ NSWindow *window = [(EnergySaverAppDelegate *)[[NSApplication sharedApplication] delegate] window];
NSTabView *tabView = (NSTabView *)[[[window contentView] subviews] lastObject];
[tabView selectTabViewItemAtIndex:1];
}
View
6 EnergySaver/EnergySaverAppDelegate.h
@@ -7,10 +7,14 @@
//
#import <Cocoa/Cocoa.h>
+#import <CorePlot/CorePlot.h>
-@interface EnergySaverAppDelegate : NSObject <NSApplicationDelegate> {
+@interface EnergySaverAppDelegate : NSObject <NSApplicationDelegate, CPPlotDataSource> {
@private
NSWindow *window;
+
+ IBOutlet CPLayerHostingView *graphView;
+ CPXYGraph *graph;
}
@property (assign) IBOutlet NSWindow *window;
View
95 EnergySaver/EnergySaverAppDelegate.m
@@ -12,6 +12,10 @@
//#import "EnergyBusterController.h"
#import "EnergyBusterViewController.h"
+@interface EnergySaverAppDelegate ()
+- (void)createGraph;
+@end
+
@implementation EnergySaverAppDelegate
@synthesize window;
@@ -65,6 +69,97 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
[[[tabView tabViewItemAtIndex:0] view] addSubview:ebvc.view];
[tabView selectFirstTabViewItem:self];
+
+ [self createGraph];
+}
+
+- (void)createGraph {
+ // Create graph from theme
+ graph = [(CPXYGraph *)[CPXYGraph alloc] initWithFrame:CGRectZero];
+ //CPTheme *theme = [CPTheme themeNamed:kCPPlainWhiteTheme];
+ //[graph applyTheme:theme];
+ graphView.hostedLayer = graph;
+
+ graph.paddingTop = 40.0;
+ graph.paddingRight = 40.0;
+ graph.paddingBottom = 40.0;
+
+ float minimumValueForXAxis = -10;
+ float minimumValueForYAxis = -10;
+ float majorIntervalLengthForX = 2;
+ float majorIntervalLengthForY = 2;
+ float maximumValueForXAxis = 10;
+ float maximumValueForYAxis = 10;
+
+ // Setup plot space
+ CPXYPlotSpace *plotSpace = (CPXYPlotSpace *)graph.defaultPlotSpace;
+ plotSpace.xRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(minimumValueForXAxis) length:CPDecimalFromFloat(maximumValueForXAxis - minimumValueForXAxis)];
+ plotSpace.yRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(minimumValueForYAxis) length:CPDecimalFromFloat(maximumValueForYAxis - minimumValueForYAxis)];
+
+ CPXYAxisSet *axisSet = (CPXYAxisSet *)graph.axisSet;
+ CPXYAxis *x = axisSet.xAxis;
+ x.majorIntervalLength = CPDecimalFromDouble(majorIntervalLengthForX);
+ x.orthogonalCoordinateDecimal = CPDecimalFromDouble(minimumValueForYAxis);
+ x.minorTicksPerInterval = 5;
+
+ CPXYAxis *y = axisSet.yAxis;
+ y.majorIntervalLength = CPDecimalFromDouble(majorIntervalLengthForY);
+ y.minorTicksPerInterval = 5;
+ y.orthogonalCoordinateDecimal = CPDecimalFromDouble(minimumValueForXAxis);
+
+ CPMutableLineStyle *borderLineStyle = [CPMutableLineStyle lineStyle];
+ borderLineStyle.lineColor = [CPColor colorWithGenericGray:0.2];
+ borderLineStyle.lineWidth = 0.0f;
+
+ // CPBorderedLayer *borderedLayer = (CPBorderedLayer *)axisSet.overlayLayer;
+ // borderedLayer.borderLineStyle = borderLineStyle;
+ // borderedLayer.cornerRadius = 0.0f;
+
+ // Create the main plot for the delimited data
+ CPScatterPlot *dataSourceLinePlot = [[(CPScatterPlot *)[CPScatterPlot alloc] initWithFrame:graph.bounds] autorelease];
+ dataSourceLinePlot.identifier = @"Data Source Plot";
+
+ CPMutableLineStyle *lineStyle = [[dataSourceLinePlot.dataLineStyle mutableCopy] autorelease];
+ lineStyle.lineWidth = 1.f;
+ lineStyle.lineColor = [CPColor blackColor];
+ dataSourceLinePlot.dataLineStyle = lineStyle;
+
+ dataSourceLinePlot.dataSource = self;
+ [graph addPlot:dataSourceLinePlot];
+
+ // Add plot symbols
+ // CPLineStyle *symbolLineStyle = [CPLineStyle lineStyle];
+ // symbolLineStyle.lineColor = [CPColor whiteColor];
+ // CPPlotSymbol *plotSymbol = [CPPlotSymbol ellipsePlotSymbol];
+ // plotSymbol.fill = [CPFill fillWithColor:[CPColor blueColor]];
+ // plotSymbol.lineStyle = symbolLineStyle;
+ // plotSymbol.size = CGSizeMake(10.0, 10.0);
+ // dataSourceLinePlot.plotSymbol = plotSymbol;
+
+ [graph reloadData];
+}
+
+- (NSNumber *)numberForPlot:(CPPlot *)plot
+ field:(NSUInteger)fieldEnum
+ recordIndex:(NSUInteger)index
+{
+ double val = (index/5.0) - 5;
+
+ if (fieldEnum == CPScatterPlotFieldX)
+ {
+ return [NSNumber numberWithDouble: val];
+ }
+ else
+ {
+ if (plot.identifier == @"X Squared Plot")
+ return [NSNumber numberWithDouble:val*val];
+ else
+ return [NSNumber numberWithDouble: 1/val];
+ }
+}
+
+- (NSUInteger)numberOfRecordsForPlot:(CPPlot *)plot {
+ return 51;
}
@end
View
72 EnergySaver/en.lproj/MainMenu.xib
@@ -12,14 +12,14 @@
</object>
<object class="NSArray" key="IBDocument.IntegratedClassDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
+ <string>NSView</string>
+ <string>NSMenu</string>
+ <string>NSWindowTemplate</string>
+ <string>NSTabView</string>
+ <string>NSMenuItem</string>
<string>NSTabViewItem</string>
<string>NSCustomView</string>
- <string>NSMenuItem</string>
- <string>NSView</string>
<string>NSCustomObject</string>
- <string>NSTabView</string>
- <string>NSWindowTemplate</string>
- <string>NSMenu</string>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -1338,18 +1338,15 @@
<string key="NSFrame">{{13, 10}, {574, 384}}</string>
<reference key="NSSuperview" ref="9849326"/>
<reference key="NSWindow"/>
- <reference key="NSNextKeyView" ref="917457559"/>
+ <reference key="NSNextKeyView" ref="74576517"/>
<object class="NSMutableArray" key="NSTabViewItems">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSTabViewItem" id="302021017">
<string key="NSIdentifier">1</string>
<object class="NSView" key="NSView" id="917457559">
- <reference key="NSNextResponder" ref="915542123"/>
+ <nil key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<string key="NSFrame">{{10, 33}, {554, 338}}</string>
- <reference key="NSSuperview" ref="915542123"/>
- <reference key="NSWindow"/>
- <reference key="NSNextKeyView"/>
</object>
<string key="NSLabel">Energy Busters</string>
<object class="NSColor" key="NSColor" id="597572208">
@@ -1358,15 +1355,15 @@
<string key="NSColorName">controlColor</string>
<object class="NSColor" key="NSColor">
<int key="NSColorSpace">3</int>
- <bytes key="NSWhite">MC42NjY2NjY2ODY1AA</bytes>
+ <bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
</object>
</object>
<reference key="NSTabView" ref="915542123"/>
</object>
<object class="NSTabViewItem" id="77532878">
<string key="NSIdentifier">2</string>
<object class="NSView" key="NSView" id="74576517">
- <nil key="NSNextResponder"/>
+ <reference key="NSNextResponder" ref="915542123"/>
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -1375,10 +1372,14 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{17, 17}, {520, 318}}</string>
<reference key="NSSuperview" ref="74576517"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="915542123"/>
<string key="NSClassName">CPLayerHostingView</string>
</object>
</object>
<string key="NSFrame">{{10, 33}, {554, 338}}</string>
+ <reference key="NSSuperview" ref="915542123"/>
+ <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="838258117"/>
</object>
<string key="NSLabel">Daily Rate</string>
@@ -1396,7 +1397,7 @@
<reference key="NSTabView" ref="915542123"/>
</object>
</object>
- <reference key="NSSelectedTabViewItem" ref="302021017"/>
+ <reference key="NSSelectedTabViewItem" ref="77532878"/>
<object class="NSFont" key="NSFont">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">13</double>
@@ -1407,7 +1408,7 @@
<bool key="NSDrawsBackground">YES</bool>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
- <reference ref="917457559"/>
+ <reference ref="74576517"/>
</object>
</object>
</object>
@@ -2109,6 +2110,14 @@
</object>
<int key="connectionID">762</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">graphView</string>
+ <reference key="source" ref="976324537"/>
+ <reference key="destination" ref="838258117"/>
+ </object>
+ <int key="connectionID">766</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -3759,7 +3768,7 @@
<reference key="dict.values" ref="0"/>
</object>
<nil key="sourceID"/>
- <int key="maxID">765</int>
+ <int key="maxID">766</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -3776,14 +3785,35 @@
<string key="className">EnergySaverAppDelegate</string>
<string key="superclassName">NSObject</string>
<object class="NSMutableDictionary" key="outlets">
- <string key="NS.key.0">window</string>
- <string key="NS.object.0">NSWindow</string>
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>graphView</string>
+ <string>window</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>CPLayerHostingView</string>
+ <string>NSWindow</string>
+ </object>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
- <string key="NS.key.0">window</string>
- <object class="IBToOneOutletInfo" key="NS.object.0">
- <string key="name">window</string>
- <string key="candidateClassName">NSWindow</string>
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>graphView</string>
+ <string>window</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBToOneOutletInfo">
+ <string key="name">graphView</string>
+ <string key="candidateClassName">CPLayerHostingView</string>
+ </object>
+ <object class="IBToOneOutletInfo">
+ <string key="name">window</string>
+ <string key="candidateClassName">NSWindow</string>
+ </object>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">

No commit comments for this range

Something went wrong with that request. Please try again.