diff --git a/.DS_Store b/.DS_Store index 5edca46..54acaee 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/CorePlot/.DS_Store b/CorePlot/.DS_Store index 964d9ef..21c7bd3 100644 Binary files a/CorePlot/.DS_Store and b/CorePlot/.DS_Store differ diff --git a/CorePlot/License.txt b/CorePlot/License.txt index 53ba4f2..0cf1dfd 100644 --- a/CorePlot/License.txt +++ b/CorePlot/License.txt @@ -1,9 +1,13 @@ -Copyright (c) 2015, Drew McCormack, Brad Larson, Eric Skroch, Barry Wark, Dirkjan Krijnders, Rick Maddy, Vijay Kalusani, Caleb Cannon, Jeff Buck, Thomas Elstner, Jeroen Leenarts, Craig Hockenberry, Hartwig Wiesmann, Koen van der Drift, Nino Ag, Mike Lischke, Trevor Harmon, Travis Fischer, Graham Mueller, Rafał Wójcik, Mike Rossetti, Michael Merickel, Lane Roathe, Ingmar Stein, Sean Holbert, Victor Martin Garcia, Jérôme Morissard, and Demitri Muna. +Copyright (c) 2019, Drew McCormack, Brad Larson, Eric Skroch, Barry Wark, Dirkjan Krijnders, Rick Maddy, Vijay Kalusani, Caleb Cannon, Jeff Buck, Thomas Elstner, Jeroen Leenarts, Craig Hockenberry, Hartwig Wiesmann, Koen van der Drift, Nino Ag, Mike Lischke, Trevor Harmon, Travis Fischer, Graham Mueller, Rafał Wójcik, Mike Rossetti, Michael Merickel, Lane Roathe, Ingmar Stein, Sean Holbert, Victor Martin Garcia, Jérôme Morissard, Demitri Muna, Tim Monzures, Kirill Yakimovich, Tom Izaks, Pascal Freiburghaus, and Fred Potter. + All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + Neither the name of the Core Plot Project nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/CorePlot/README.md b/CorePlot/README.md index e3e3703..2b6f549 100644 --- a/CorePlot/README.md +++ b/CorePlot/README.md @@ -1,12 +1,12 @@ # Core Plot -*Cocoa plotting framework for Mac OS X and iOS.* +*Cocoa plotting framework for macOS, iOS, and tvOS.* -[![Build Status](https://secure.travis-ci.org/core-plot/core-plot.svg)](http://travis-ci.org/core-plot/core-plot) [![Version Status](https://img.shields.io/cocoapods/v/CorePlot.svg)](https://cocoapods.org/pods/CorePlot) [![license MIT](https://img.shields.io/cocoapods/l/CorePlot.svg)](http://opensource.org/licenses/BSD-3-Clause) [![Platform](https://img.shields.io/cocoapods/p/CorePlot.svg)](http://core-plot.github.io) +[![Build Status](https://secure.travis-ci.org/core-plot/core-plot.svg)](http://travis-ci.org/core-plot/core-plot) [![Version Status](https://img.shields.io/cocoapods/v/CorePlot.svg)](https://cocoapods.org/pods/CorePlot) [![license MIT](https://img.shields.io/cocoapods/l/CorePlot.svg)](http://opensource.org/licenses/BSD-3-Clause) [![Platform](https://img.shields.io/cocoapods/p/CorePlot.svg)](http://core-plot.github.io) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) # Introduction -Core Plot is a 2D plotting framework for Mac OS X and iOS. It is highly customizable and capable of drawing many types of plots. See the [Example Graphs](https://github.com/core-plot/core-plot/wiki/Example-Graphs) wiki page and the [example applications](https://github.com/core-plot/core-plot/tree/master/examples) for examples of some of its capabilities. +Core Plot is a 2D plotting framework for macOS, iOS, and tvOS. It is highly customizable and capable of drawing many types of plots. See the [Example Graphs](https://github.com/core-plot/core-plot/wiki/Example-Graphs) wiki page and the [example applications](https://github.com/core-plot/core-plot/tree/master/examples) for examples of some of its capabilities. # Getting Started @@ -18,7 +18,7 @@ Documentation of the Core Plot API and high-level architecture can be found in t * [Change log](https://github.com/core-plot/core-plot/blob/master/documentation/changelog.markdown) * [API documentation](http://core-plot.github.io/MacOS/index.html) for Mac - * [API documentation](http://core-plot.github.io/iOS/index.html) for iOS + * [API documentation](http://core-plot.github.io/iOS/index.html) for iOS and tvOS * API documentation built with [Doxygen](http://www.doxygen.org/) and installed locally in Xcode (see the [instructions](https://github.com/core-plot/core-plot/blob/master/READMEs/README%20for%20Docs%20Install.md) in the **READMEs** folder for details) * [Project Wiki](https://github.com/core-plot/core-plot/wiki) on GitHub * [Documentation](https://github.com/core-plot/core-plot/tree/master/documentation) folder in the code repository @@ -33,7 +33,6 @@ Documentation of the Core Plot API and high-level architecture can be found in t ## Social Networks * [Twitter](https://twitter.com/CorePlot) - * [App.net](https://alpha.app.net/coreplot); Subscribe to the [Announcements](https://app.net/c/2rw2) broadcast. # Contributing to Core Plot @@ -44,12 +43,12 @@ Core Plot is an open source project hosted on [GitHub](https://github.com/core-p * [core-plot.github.io](https://github.com/core-plot/core-plot.github.io): This is the HTML API documentation. You can view the pages online at [http://core-plot.github.io](http://core-plot.github.io). ## Coding Standards -Everyone has a their own preferred coding style, and no one way can be considered right. Nonetheless, in a project like Core Plot, with many developers contributing, it is worthwhile defining a set of basic coding standards to prevent a mishmash of different styles which can become frustrating when navigating the code base. See the file [Coding Style.markdown](https://github.com/core-plot/core-plot/blob/master/documentation/Coding%20Style.markdown) found in the [documentation](https://github.com/core-plot/core-plot/tree/master/documentation) directory of the project source for specific guidelines. +Everyone has a their own preferred coding style, and no one way can be considered right. Nonetheless, in a project like Core Plot, with many developers contributing, it is worthwhile defining a set of basic coding standards to prevent a mishmash of different styles which can become frustrating when navigating the code base. See the file [CONTRIBUTING.md](https://github.com/core-plot/core-plot/blob/master/.github/CONTRIBUTING.md) found in the [.github](https://github.com/core-plot/core-plot/tree/master/.github) directory of the project source for specific guidelines. Core Plot includes a [script](https://github.com/core-plot/core-plot/blob/master/scripts/format_core_plot.sh) to run [Uncrustify](http://uncrustify.sourceforge.net) on the source code to standardize the formatting. All source code will be formatted with this tool before being committed to the Core Plot repository. ## Testing -Because Core Plot is intended to be used in scientific, financial, and other domains where correctness is paramount, unit testing is integrated into the framework. Good test coverage protects developers from introducing accidental regressions and frees them to experiment and refactor without fear of breaking things. See the [unit testing](https://github.com/core-plot/core-plot/wiki/Unit-Testing) wiki page for instructions on how to build unit tests for any new code you add to the project. +Core Plot is intended to be applied in scientific, financial, and other domains where correctness is paramount. In order to assure the quality of the framework, unit testing is integrated. Good test coverage protects developers from introducing accidental regressions, and helps them to experiment and refactor without breaking existing code. See the [unit testing](https://github.com/core-plot/core-plot/wiki/Unit-Testing) wiki page for instructions on how to build unit tests for any new code you add to the project. # Support Core Plot diff --git a/CorePlot/framework/CocoaPods/CorePlot.h b/CorePlot/framework/CocoaPods/CorePlot.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/CorePlot-CocoaTouch.h b/CorePlot/framework/CorePlot-CocoaTouch.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/CorePlot.h b/CorePlot/framework/CorePlot.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/CorePlot.xcodeproj/TemplateIcon.icns b/CorePlot/framework/CorePlot.xcodeproj/TemplateIcon.icns old mode 100755 new mode 100644 diff --git a/CorePlot/framework/CorePlot.xcodeproj/project.pbxproj b/CorePlot/framework/CorePlot.xcodeproj/project.pbxproj old mode 100755 new mode 100644 index ef60f29..bc9f52b --- a/CorePlot/framework/CorePlot.xcodeproj/project.pbxproj +++ b/CorePlot/framework/CorePlot.xcodeproj/project.pbxproj @@ -1089,6 +1089,7 @@ C34BF5BA10A67633007F0894 /* CPTPlotArea.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CPTPlotArea.h; sourceTree = ""; }; C34BF5BB10A67633007F0894 /* CPTPlotArea.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = CPTPlotArea.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; C34F570D19D8CE5500446248 /* CorePlotWarnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = CorePlotWarnings.xcconfig; path = xcconfig/CorePlotWarnings.xcconfig; sourceTree = ""; }; + C3564CBD22A2D0E1000A54C9 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; C36468A80FE5533F0064B186 /* CPTTextStyleTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CPTTextStyleTests.h; sourceTree = ""; }; C36468A90FE5533F0064B186 /* CPTTextStyleTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CPTTextStyleTests.m; sourceTree = ""; }; C36E89B811EE7F97003DE309 /* CPTPlotRangeTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CPTPlotRangeTests.h; sourceTree = ""; }; @@ -1187,7 +1188,6 @@ C3F97F1C17A9E07B00A52FF2 /* CPTFunctionDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = CPTFunctionDataSource.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; C3F97F1D17A9E07B00A52FF2 /* CPTFunctionDataSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = CPTFunctionDataSource.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; C3FF6EF00FFFA51D00AF0496 /* mainpage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mainpage.h; path = Source/mainpage.h; sourceTree = ""; }; - CF17A9162258EC2C003D7465 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; D0C0477B12D6560900DA8047 /* CPTRangePlot.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = CPTRangePlot.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; D0C0477C12D6560900DA8047 /* CPTRangePlot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CPTRangePlot.h; sourceTree = ""; }; E1620CBC100F03A100A84E77 /* CPTThemeTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CPTThemeTests.h; sourceTree = ""; }; @@ -2455,7 +2455,7 @@ isa = PBXProject; attributes = { BuildIndependentTargetsInParallel = YES; - LastUpgradeCheck = 0900; + LastUpgradeCheck = 1100; TargetAttributes = { 8DC2EF4F0486A6940098B216 = { DevelopmentTeam = 28ZA45DE7D; @@ -2480,10 +2480,10 @@ hasScannedForEncodings = 1; knownRegions = ( Base, - ja, - fr, en, de, + ja, + fr, ); mainGroup = 0867D691FE84028FC02AAC07 /* CorePlot */; productRefGroup = 034768DFFF38A50411DB9C8B /* Products */; @@ -2586,7 +2586,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\nUFW_TARGET=\"CorePlot tvOS\"\nUFW_BUILD_DIR=\"${PROJECT_DIR}/../build\"\n\nif [ -z ${SDK_NAME} ]; then\n# Use the latest tvOS SDK available\nUFW_GREP_RESULT=$(xcodebuild -showsdks | grep -o \"appletvos.*$\")\nwhile read -r line; do\nUFW_SDK_VERSION=\"${line}\"\ndone <<< \"${UFW_GREP_RESULT}\"\nelse\n# Use the SDK specified by XCode\nUFW_SDK_VERSION=\"${SDK_NAME}\"\nfi\n\nFRAMEWORK_NAME=\"${PROJECT_NAME}\"\nUFW_SDK_VERSION=$(echo \"${UFW_SDK_VERSION}\" | grep -o \"[0-9].*$\")\nUFW_IPHONE_PATH=\"${UFW_BUILD_DIR}/Release-appletvos/${FRAMEWORK_NAME}.framework\"\nUFW_SIMULATOR_PATH=\"${UFW_BUILD_DIR}/Release-appletvsimulator/${FRAMEWORK_NAME}.framework\"\nUFW_UNIVERSAL_DIR=\"${UFW_BUILD_DIR}/Release-appletvuniversal\"\nUFW_FRAMEWORK=\"${UFW_UNIVERSAL_DIR}/${FRAMEWORK_NAME}.framework\"\n\n# Build Framework\n\nrm -rf \"${UFW_UNIVERSAL_DIR}\"\n\nxcodebuild -target \"${UFW_TARGET}\" -project CorePlot.xcodeproj -configuration Release -sdk appletvos${UFW_SDK_VERSION} clean build\nif [ \"$?\" != \"0\" ]; then echo >&2 \"Error: xcodebuild failed\"; exit 1; fi\nxcodebuild -target \"${UFW_TARGET}\" -project CorePlot.xcodeproj -configuration Release -sdk appletvsimulator${UFW_SDK_VERSION} clean build\nif [ \"$?\" != \"0\" ]; then echo >&2 \"Error: xcodebuild failed\"; exit 1; fi\n\nmkdir -p \"${UFW_UNIVERSAL_DIR}\"\nif [ \"$?\" != \"0\" ]; then echo >&2 \"Error: mkdir failed\"; exit 1; fi\n\ncp -r \"${UFW_IPHONE_PATH}/.\" \"${UFW_FRAMEWORK}\"\n\nlipo -create -output \"${UFW_FRAMEWORK}/${FRAMEWORK_NAME}\" \"${UFW_SIMULATOR_PATH}/${FRAMEWORK_NAME}\" \"${UFW_IPHONE_PATH}/${FRAMEWORK_NAME}\"\nif [ \"$?\" != \"0\" ]; then echo >&2 \"Error: lipo failed\"; exit 1; fi\n"; + shellScript = "\nUFW_TARGET=\"CorePlot tvOS\"\nUFW_BUILD_DIR=\"${PROJECT_DIR}/../build\"\n\nif [ -z ${SDK_NAME} ]; then\n# Use the latest tvOS SDK available\nUFW_GREP_RESULT=$(xcodebuild -showsdks | grep -o \"appletvos.*$\")\nwhile read -r line; do\nUFW_SDK_VERSION=\"${line}\"\ndone <<< \"${UFW_GREP_RESULT}\"\nelse\n# Use the SDK specified by XCode\nUFW_SDK_VERSION=\"${SDK_NAME}\"\nfi\n\nFRAMEWORK_NAME=\"${PROJECT_NAME}\"\nUFW_SDK_VERSION=$(echo \"${UFW_SDK_VERSION}\" | grep -o \"[0-9].*$\")\nUFW_IPHONE_PATH=\"${UFW_BUILD_DIR}/Release-appletvos/${FRAMEWORK_NAME}.framework\"\nUFW_SIMULATOR_PATH=\"${UFW_BUILD_DIR}/Release-appletvsimulator/${FRAMEWORK_NAME}.framework\"\nUFW_UNIVERSAL_DIR=\"${UFW_BUILD_DIR}/Release-appletvuniversal\"\nUFW_FRAMEWORK=\"${UFW_UNIVERSAL_DIR}/${FRAMEWORK_NAME}.framework\"\n\n# Build Framework\n\nrm -rf \"${UFW_UNIVERSAL_DIR}\"\n\nxcodebuild -target \"${UFW_TARGET}\" -project CorePlot.xcodeproj -configuration Release -sdk appletvos${UFW_SDK_VERSION} clean build\nif [ \"$?\" != \"0\" ]; then echo >&2 \"Error: xcodebuild failed\"; exit 1; fi\nxcodebuild -target \"${UFW_TARGET}\" -project CorePlot.xcodeproj -configuration Release -sdk appletvsimulator${UFW_SDK_VERSION} build\nif [ \"$?\" != \"0\" ]; then echo >&2 \"Error: xcodebuild failed\"; exit 1; fi\n\nmkdir -p \"${UFW_UNIVERSAL_DIR}\"\nif [ \"$?\" != \"0\" ]; then echo >&2 \"Error: mkdir failed\"; exit 1; fi\n\ncp -r \"${UFW_IPHONE_PATH}/.\" \"${UFW_FRAMEWORK}\"\n\nlipo -create -output \"${UFW_FRAMEWORK}/${FRAMEWORK_NAME}\" \"${UFW_SIMULATOR_PATH}/${FRAMEWORK_NAME}\" \"${UFW_IPHONE_PATH}/${FRAMEWORK_NAME}\"\nif [ \"$?\" != \"0\" ]; then echo >&2 \"Error: lipo failed\"; exit 1; fi\n"; }; C38A09921A4618B600D45436 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; @@ -2612,7 +2612,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\nUFW_TARGET=\"CorePlot-CocoaTouch\"\nUFW_BUILD_DIR=\"${PROJECT_DIR}/../build\"\n\nif [ -z ${SDK_NAME} ]; then\n# Use the latest iphoneos SDK available\nUFW_GREP_RESULT=$(xcodebuild -showsdks | grep -o \"iphoneos.*$\")\nwhile read -r line; do\nUFW_SDK_VERSION=\"${line}\"\ndone <<< \"${UFW_GREP_RESULT}\"\nelse\n# Use the SDK specified by XCode\nUFW_SDK_VERSION=\"${SDK_NAME}\"\nfi\n\nUFW_SDK_VERSION=$(echo \"${UFW_SDK_VERSION}\" | grep -o \"[0-9].*$\")\nUFW_IPHONE_DIR=\"${UFW_BUILD_DIR}/Release-iphoneos\"\nUFW_SIMULATOR_DIR=\"${UFW_BUILD_DIR}/Release-iphonesimulator\"\nUFW_UNIVERSAL_DIR=\"${UFW_BUILD_DIR}/Release-universal\"\nUFW_HEADER_DIR=\"${UFW_UNIVERSAL_DIR}/CorePlotHeaders\"\nUFW_EXE_PATH=\"libCorePlot-CocoaTouch.a\"\n\n# Build Framework\n\nrm -rf \"${UFW_UNIVERSAL_DIR}\"\n\nxcodebuild -target \"${UFW_TARGET}\" -project CorePlot.xcodeproj -configuration Release -sdk iphoneos${UFW_SDK_VERSION} clean build\nif [ \"$?\" != \"0\" ]; then echo >&2 \"Error: xcodebuild failed\"; exit 1; fi\nxcodebuild -target \"${UFW_TARGET}\" -project CorePlot.xcodeproj -configuration Release -sdk iphonesimulator${UFW_SDK_VERSION} clean build\nif [ \"$?\" != \"0\" ]; then echo >&2 \"Error: xcodebuild failed\"; exit 1; fi\n\nmkdir -p \"${UFW_UNIVERSAL_DIR}\"\nif [ \"$?\" != \"0\" ]; then echo >&2 \"Error: mkdir failed\"; exit 1; fi\n\nlipo -create -output \"${UFW_UNIVERSAL_DIR}/${UFW_EXE_PATH}\" \"${UFW_IPHONE_DIR}/${UFW_EXE_PATH}\" \"${UFW_SIMULATOR_DIR}/${UFW_EXE_PATH}\"\nif [ \"$?\" != \"0\" ]; then echo >&2 \"Error: lipo failed\"; exit 1; fi\n\n# copy header files\nmkdir -p \"${UFW_HEADER_DIR}\"\nif [ \"$?\" != \"0\" ]; then echo >&2 \"Error: mkdir failed\"; exit 1; fi\n\ncp \"${SOURCE_ROOT}/CorePlot-CocoaTouch.h\" \"${UFW_HEADER_DIR}\"\ncp \"${SOURCE_ROOT}/iPhoneOnly/\"[!_]*.h \"${UFW_HEADER_DIR}/\"\ncp \"${SOURCE_ROOT}/Source/\"[!_]*.h \"${UFW_HEADER_DIR}/\"\n\nrm \"${UFW_HEADER_DIR}/\"*Tests.*"; + shellScript = "\nUFW_TARGET=\"CorePlot-CocoaTouch\"\nUFW_BUILD_DIR=\"${PROJECT_DIR}/../build\"\n\nif [ -z ${SDK_NAME} ]; then\n# Use the latest iphoneos SDK available\nUFW_GREP_RESULT=$(xcodebuild -showsdks | grep -o \"iphoneos.*$\")\nwhile read -r line; do\nUFW_SDK_VERSION=\"${line}\"\ndone <<< \"${UFW_GREP_RESULT}\"\nelse\n# Use the SDK specified by XCode\nUFW_SDK_VERSION=\"${SDK_NAME}\"\nfi\n\nUFW_SDK_VERSION=$(echo \"${UFW_SDK_VERSION}\" | grep -o \"[0-9].*$\")\nUFW_IPHONE_DIR=\"${UFW_BUILD_DIR}/Release-iphoneos\"\nUFW_SIMULATOR_DIR=\"${UFW_BUILD_DIR}/Release-iphonesimulator\"\nUFW_UNIVERSAL_DIR=\"${UFW_BUILD_DIR}/Release-universal\"\nUFW_HEADER_DIR=\"${UFW_UNIVERSAL_DIR}/CorePlotHeaders\"\nUFW_EXE_PATH=\"libCorePlot-CocoaTouch.a\"\n\n# Build Framework\n\nrm -rf \"${UFW_UNIVERSAL_DIR}\"\n\nxcodebuild -target \"${UFW_TARGET}\" -project CorePlot.xcodeproj -configuration Release -sdk iphoneos${UFW_SDK_VERSION} clean build\nif [ \"$?\" != \"0\" ]; then echo >&2 \"Error: xcodebuild failed\"; exit 1; fi\nxcodebuild -target \"${UFW_TARGET}\" -project CorePlot.xcodeproj -configuration Release -sdk iphonesimulator${UFW_SDK_VERSION} build\nif [ \"$?\" != \"0\" ]; then echo >&2 \"Error: xcodebuild failed\"; exit 1; fi\n\nmkdir -p \"${UFW_UNIVERSAL_DIR}\"\nif [ \"$?\" != \"0\" ]; then echo >&2 \"Error: mkdir failed\"; exit 1; fi\n\nlipo -create -output \"${UFW_UNIVERSAL_DIR}/${UFW_EXE_PATH}\" \"${UFW_IPHONE_DIR}/${UFW_EXE_PATH}\" \"${UFW_SIMULATOR_DIR}/${UFW_EXE_PATH}\"\nif [ \"$?\" != \"0\" ]; then echo >&2 \"Error: lipo failed\"; exit 1; fi\n\n# copy header files\nmkdir -p \"${UFW_HEADER_DIR}\"\nif [ \"$?\" != \"0\" ]; then echo >&2 \"Error: mkdir failed\"; exit 1; fi\n\ncp \"${SOURCE_ROOT}/CorePlot-CocoaTouch.h\" \"${UFW_HEADER_DIR}\"\ncp \"${SOURCE_ROOT}/iPhoneOnly/\"[!_]*.h \"${UFW_HEADER_DIR}/\"\ncp \"${SOURCE_ROOT}/Source/\"[!_]*.h \"${UFW_HEADER_DIR}/\"\n\nrm \"${UFW_HEADER_DIR}/\"*Tests.*\n"; }; C3A546801BC1A817005C1BBC /* ShellScript */ = { isa = PBXShellScriptBuildPhase; @@ -2625,7 +2625,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\nUFW_TARGET=\"CorePlot iOS\"\nUFW_BUILD_DIR=\"${PROJECT_DIR}/../build\"\n\nif [ -z ${SDK_NAME} ]; then\n# Use the latest iphoneos SDK available\nUFW_GREP_RESULT=$(xcodebuild -showsdks | grep -o \"iphoneos.*$\")\nwhile read -r line; do\nUFW_SDK_VERSION=\"${line}\"\ndone <<< \"${UFW_GREP_RESULT}\"\nelse\n# Use the SDK specified by XCode\nUFW_SDK_VERSION=\"${SDK_NAME}\"\nfi\n\nFRAMEWORK_NAME=\"${PROJECT_NAME}\"\nUFW_SDK_VERSION=$(echo \"${UFW_SDK_VERSION}\" | grep -o \"[0-9].*$\")\nUFW_IPHONE_PATH=\"${UFW_BUILD_DIR}/Release-iphoneos/${FRAMEWORK_NAME}.framework\"\nUFW_SIMULATOR_PATH=\"${UFW_BUILD_DIR}/Release-iphonesimulator/${FRAMEWORK_NAME}.framework\"\nUFW_UNIVERSAL_DIR=\"${UFW_BUILD_DIR}/Release-iphoneuniversal\"\nUFW_FRAMEWORK=\"${UFW_UNIVERSAL_DIR}/${FRAMEWORK_NAME}.framework\"\n\n# Build Framework\n\nrm -rf \"${UFW_UNIVERSAL_DIR}\"\n\nxcodebuild -target \"${UFW_TARGET}\" -project CorePlot.xcodeproj -configuration Release -sdk iphoneos${UFW_SDK_VERSION} clean build\nif [ \"$?\" != \"0\" ]; then echo >&2 \"Error: xcodebuild failed\"; exit 1; fi\nxcodebuild -target \"${UFW_TARGET}\" -project CorePlot.xcodeproj -configuration Release -sdk iphonesimulator${UFW_SDK_VERSION} clean build\nif [ \"$?\" != \"0\" ]; then echo >&2 \"Error: xcodebuild failed\"; exit 1; fi\n\nmkdir -p \"${UFW_UNIVERSAL_DIR}\"\nif [ \"$?\" != \"0\" ]; then echo >&2 \"Error: mkdir failed\"; exit 1; fi\n\ncp -r \"${UFW_IPHONE_PATH}/.\" \"${UFW_FRAMEWORK}\"\n\nlipo -create -output \"${UFW_FRAMEWORK}/${FRAMEWORK_NAME}\" \"${UFW_SIMULATOR_PATH}/${FRAMEWORK_NAME}\" \"${UFW_IPHONE_PATH}/${FRAMEWORK_NAME}\"\nif [ \"$?\" != \"0\" ]; then echo >&2 \"Error: lipo failed\"; exit 1; fi\n"; + shellScript = "\nUFW_TARGET=\"CorePlot iOS\"\nUFW_BUILD_DIR=\"${PROJECT_DIR}/../build\"\n\nif [ -z ${SDK_NAME} ]; then\n# Use the latest iphoneos SDK available\nUFW_GREP_RESULT=$(xcodebuild -showsdks | grep -o \"iphoneos.*$\")\nwhile read -r line; do\nUFW_SDK_VERSION=\"${line}\"\ndone <<< \"${UFW_GREP_RESULT}\"\nelse\n# Use the SDK specified by XCode\nUFW_SDK_VERSION=\"${SDK_NAME}\"\nfi\n\nFRAMEWORK_NAME=\"${PROJECT_NAME}\"\nUFW_SDK_VERSION=$(echo \"${UFW_SDK_VERSION}\" | grep -o \"[0-9].*$\")\nUFW_IPHONE_PATH=\"${UFW_BUILD_DIR}/Release-iphoneos/${FRAMEWORK_NAME}.framework\"\nUFW_SIMULATOR_PATH=\"${UFW_BUILD_DIR}/Release-iphonesimulator/${FRAMEWORK_NAME}.framework\"\nUFW_UNIVERSAL_DIR=\"${UFW_BUILD_DIR}/Release-iphoneuniversal\"\nUFW_FRAMEWORK=\"${UFW_UNIVERSAL_DIR}/${FRAMEWORK_NAME}.framework\"\n\n# Build Framework\n\nrm -rf \"${UFW_UNIVERSAL_DIR}\"\n\nxcodebuild -target \"${UFW_TARGET}\" -project CorePlot.xcodeproj -configuration Release -sdk iphoneos${UFW_SDK_VERSION} clean build\nif [ \"$?\" != \"0\" ]; then echo >&2 \"Error: xcodebuild failed\"; exit 1; fi\nxcodebuild -target \"${UFW_TARGET}\" -project CorePlot.xcodeproj -configuration Release -sdk iphonesimulator${UFW_SDK_VERSION} build\nif [ \"$?\" != \"0\" ]; then echo >&2 \"Error: xcodebuild failed\"; exit 1; fi\n\nmkdir -p \"${UFW_UNIVERSAL_DIR}\"\nif [ \"$?\" != \"0\" ]; then echo >&2 \"Error: mkdir failed\"; exit 1; fi\n\ncp -r \"${UFW_IPHONE_PATH}/.\" \"${UFW_FRAMEWORK}\"\n\nlipo -create -output \"${UFW_FRAMEWORK}/${FRAMEWORK_NAME}\" \"${UFW_SIMULATOR_PATH}/${FRAMEWORK_NAME}\" \"${UFW_IPHONE_PATH}/${FRAMEWORK_NAME}\"\nif [ \"$?\" != \"0\" ]; then echo >&2 \"Error: lipo failed\"; exit 1; fi\n"; }; /* End PBXShellScriptBuildPhase section */ @@ -3192,7 +3192,7 @@ 089C1666FE841158C02AAC07 /* InfoPlist.strings */ = { isa = PBXVariantGroup; children = ( - CF17A9162258EC2C003D7465 /* en */, + C3564CBD22A2D0E1000A54C9 /* en */, ); name = InfoPlist.strings; sourceTree = ""; @@ -3462,7 +3462,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = C3C9D08C1BB5A44800931F32 /* CorePlotDebug.xcconfig */; buildSettings = { - CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; @@ -3484,7 +3484,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = C3C9D08D1BB5A45B00931F32 /* CorePlotRelease.xcconfig */; buildSettings = { - CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; @@ -3538,7 +3538,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = C3C9D08C1BB5A44800931F32 /* CorePlotDebug.xcconfig */; buildSettings = { - CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; @@ -3561,7 +3561,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = C3C9D08D1BB5A45B00931F32 /* CorePlotRelease.xcconfig */; buildSettings = { - CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; diff --git a/CorePlot/framework/CorePlot.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/CorePlot/framework/CorePlot.xcodeproj/project.xcworkspace/contents.xcworkspacedata old mode 100755 new mode 100644 diff --git a/CorePlot/framework/CorePlot.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/CorePlot/framework/CorePlot.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist old mode 100755 new mode 100644 diff --git a/CorePlot/framework/CorePlot.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/CorePlot/framework/CorePlot.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings old mode 100755 new mode 100644 diff --git a/CorePlot/framework/CorePlot.xcodeproj/xcshareddata/xcschemes/CorePlot Mac.xcscheme b/CorePlot/framework/CorePlot.xcodeproj/xcshareddata/xcschemes/CorePlot Mac.xcscheme old mode 100755 new mode 100644 index 600fbd8..6567660 --- a/CorePlot/framework/CorePlot.xcodeproj/xcshareddata/xcschemes/CorePlot Mac.xcscheme +++ b/CorePlot/framework/CorePlot.xcodeproj/xcshareddata/xcschemes/CorePlot Mac.xcscheme @@ -1,6 +1,6 @@ - - - - + + + + @@ -53,17 +62,6 @@ - - - - - - - - + + + + @@ -53,17 +62,6 @@ - - - - - - - - + + + + @@ -53,17 +62,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - CPTFloat(1.0) ) { + while ( imageScale > CPTFloat(1.0)) { NSMutableString *hiDpiPath = [path mutableCopy]; NSUInteger replaceCount = [hiDpiPath replaceOccurrencesOfString:@".png" withString:[NSString stringWithFormat:@"@%dx.png", (int)imageScale] diff --git a/CorePlot/framework/MacOnly/CPTPlatformSpecificCategories.h b/CorePlot/framework/MacOnly/CPTPlatformSpecificCategories.h old mode 100755 new mode 100644 index f47f00e..2102bc1 --- a/CorePlot/framework/MacOnly/CPTPlatformSpecificCategories.h +++ b/CorePlot/framework/MacOnly/CPTPlatformSpecificCategories.h @@ -16,17 +16,6 @@ @end -#pragma mark - CPTColor - -/** @category CPTColor(CPTPlatformSpecificColorExtensions) - * @brief Platform-specific extensions to CPTColor. - **/ -@interface CPTColor(CPTPlatformSpecificColorExtensions) - -@property (nonatomic, readonly, nonnull) NSColor *nsColor; - -@end - #pragma mark - NSAttributedString /** @category NSAttributedString(CPTPlatformSpecificAttributedStringExtensions) diff --git a/CorePlot/framework/MacOnly/CPTPlatformSpecificCategories.m b/CorePlot/framework/MacOnly/CPTPlatformSpecificCategories.m old mode 100755 new mode 100644 index 278bce6..71ddd9c --- a/CorePlot/framework/MacOnly/CPTPlatformSpecificCategories.m +++ b/CorePlot/framework/MacOnly/CPTPlatformSpecificCategories.m @@ -19,7 +19,7 @@ -(nonnull CPTNativeImage *)imageOfLayer CGFloat scale = 0.0; if ( [self respondsToSelector:@selector(hostingView)] ) { - scale = ( (CPTGraph *)self ).hostingView.window.backingScaleFactor; + scale = ((CPTGraph *)self).hostingView.window.backingScaleFactor; } else { NSWindow *myWindow = self.graph.hostingView.window; @@ -52,7 +52,7 @@ -(nonnull CPTNativeImage *)imageOfLayer NSGraphicsContext *bitmapContext = [NSGraphicsContext graphicsContextWithBitmapImageRep:layerImage]; CGContextRef context = (CGContextRef)bitmapContext.graphicsPort; - CGContextClearRect(context, CPTRectMake(0.0, 0.0, boundsSize.width, boundsSize.height) ); + CGContextClearRect(context, CPTRectMake(0.0, 0.0, boundsSize.width, boundsSize.height)); CGContextSetAllowsAntialiasing(context, true); CGContextSetShouldSmoothFonts(context, false); [self layoutAndRenderInContext:context]; diff --git a/CorePlot/framework/MacOnly/CPTPlatformSpecificDefines.h b/CorePlot/framework/MacOnly/CPTPlatformSpecificDefines.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/MacOnly/CPTPlatformSpecificDefines.m b/CorePlot/framework/MacOnly/CPTPlatformSpecificDefines.m old mode 100755 new mode 100644 diff --git a/CorePlot/framework/MacOnly/CPTPlatformSpecificFunctions.h b/CorePlot/framework/MacOnly/CPTPlatformSpecificFunctions.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/MacOnly/CPTPlatformSpecificFunctions.m b/CorePlot/framework/MacOnly/CPTPlatformSpecificFunctions.m old mode 100755 new mode 100644 diff --git a/CorePlot/framework/MacOnly/CPTTextStylePlatformSpecific.h b/CorePlot/framework/MacOnly/CPTTextStylePlatformSpecific.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/MacOnly/CPTTextStylePlatformSpecific.m b/CorePlot/framework/MacOnly/CPTTextStylePlatformSpecific.m old mode 100755 new mode 100644 index ffae248..6f59bce --- a/CorePlot/framework/MacOnly/CPTTextStylePlatformSpecific.m +++ b/CorePlot/framework/MacOnly/CPTTextStylePlatformSpecific.m @@ -54,7 +54,7 @@ +(nonnull instancetype)textStyleWithAttributes:(nullable CPTDictionary *)attribu else { const NSInteger numberOfComponents = styleColor.numberOfComponents; - CGFloat *components = calloc( (size_t)numberOfComponents, sizeof(CGFloat) ); + CGFloat *components = calloc((size_t)numberOfComponents, sizeof(CGFloat)); [styleColor getComponents:components]; CGColorSpaceRef colorSpace = styleColor.colorSpace.CGColorSpace; @@ -160,7 +160,7 @@ +(nonnull instancetype)textStyleWithAttributes:(nullable CPTDictionary *)attribu else { const NSInteger numberOfComponents = styleColor.numberOfComponents; - CGFloat *components = calloc( (size_t)numberOfComponents, sizeof(CGFloat) ); + CGFloat *components = calloc((size_t)numberOfComponents, sizeof(CGFloat)); [styleColor getComponents:components]; CGColorSpaceRef colorSpace = styleColor.colorSpace.CGColorSpace; diff --git a/CorePlot/framework/Source/CPTAnimation.h b/CorePlot/framework/Source/CPTAnimation.h old mode 100755 new mode 100644 index fed97c6..93f0e48 --- a/CorePlot/framework/Source/CPTAnimation.h +++ b/CorePlot/framework/Source/CPTAnimation.h @@ -46,8 +46,8 @@ typedef NS_ENUM (NSInteger, CPTAnimationCurve) { /** * @brief Animation delegate. **/ -#if ( ( TARGET_OS_SIMULATOR || TARGET_OS_IPHONE || TARGET_OS_TV) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= 100000) ) \ - || (TARGET_OS_MAC && (MAC_OS_X_VERSION_MAX_ALLOWED >= 101200) ) +#if ((TARGET_OS_SIMULATOR || TARGET_OS_IPHONE || TARGET_OS_TV) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= 100000)) \ + || (TARGET_OS_MAC && (MAC_OS_X_VERSION_MAX_ALLOWED >= 101200)) // CAAnimationDelegate is defined by Core Animation in iOS 10.0+, macOS 10.12+, and tvOS 10.0+ @protocol CPTAnimationDelegate #else diff --git a/CorePlot/framework/Source/CPTAnimation.m b/CorePlot/framework/Source/CPTAnimation.m old mode 100755 new mode 100644 index df5fe2c..4ef62d1 --- a/CorePlot/framework/Source/CPTAnimation.m +++ b/CorePlot/framework/Source/CPTAnimation.m @@ -100,7 +100,7 @@ @implementation CPTAnimation **/ -(nonnull instancetype)init { - if ( (self = [super init]) ) { + if ((self = [super init])) { animationOperations = [[NSMutableArray alloc] init]; runningAnimationOperations = [[NSMutableArray alloc] init]; timer = NULL; @@ -200,7 +200,7 @@ -(CPTAnimationOperation *)addAnimationOperation:(nonnull CPTAnimationOperation * id boundObject = animationOperation.boundObject; CPTAnimationPeriod *period = animationOperation.period; - if ( animationOperation.delegate || (boundObject && period && ![period.startValue isEqual:period.endValue]) ) { + if ( animationOperation.delegate || (boundObject && period && ![period.startValue isEqual:period.endValue])) { dispatch_async(self.animationQueue, ^{ [self.animationOperations addObject:animationOperation]; @@ -277,7 +277,7 @@ -(void)update CGFloat duration = period.duration; CGFloat startTime = period.startOffset; CGFloat delay = period.delay; - if ( isnan(delay) ) { + if ( isnan(delay)) { if ( [period canStartWithValueFromObject:animationOperation.boundObject propertyGetter:animationOperation.boundGetter] ) { period.delay = currentTime - startTime; startTime = currentTime; @@ -315,7 +315,7 @@ -(void)update for ( CPTAnimationOperation *operation in runningOperations ) { if ( operation.boundObject == boundObject ) { - if ( (operation.boundGetter == boundGetter) && (operation.boundSetter == boundSetter) ) { + if ((operation.boundGetter == boundGetter) && (operation.boundSetter == boundSetter)) { operation.canceled = YES; } } @@ -401,7 +401,7 @@ -(void)updateOnMainThreadWithParameters:(nonnull CPTDictionary *)parameters id tweenedValue = parameters[CPTAnimationValueKey]; if ( [tweenedValue isKindOfClass:[NSDecimalNumber class]] ) { - NSDecimal buffer = ( (NSDecimalNumber *)tweenedValue ).decimalValue; + NSDecimal buffer = ((NSDecimalNumber *)tweenedValue).decimalValue; typedef void (*SetterType)(id, SEL, NSDecimal); SetterType setterMethod = (SetterType)[boundObject methodForSelector:boundSetter]; diff --git a/CorePlot/framework/Source/CPTAnimationOperation.h b/CorePlot/framework/Source/CPTAnimationOperation.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTAnimationOperation.m b/CorePlot/framework/Source/CPTAnimationOperation.m old mode 100755 new mode 100644 index f807cca..e7047ab --- a/CorePlot/framework/Source/CPTAnimationOperation.m +++ b/CorePlot/framework/Source/CPTAnimationOperation.m @@ -77,7 +77,7 @@ @implementation CPTAnimationOperation **/ -(nonnull instancetype)initWithAnimationPeriod:(nonnull CPTAnimationPeriod *)animationPeriod animationCurve:(CPTAnimationCurve)curve object:(nonnull id)object getter:(nonnull SEL)getter setter:(nonnull SEL)setter { - if ( (self = [super init]) ) { + if ((self = [super init])) { period = animationPeriod; animationCurve = curve; boundObject = object; diff --git a/CorePlot/framework/Source/CPTAnimationPeriod.h b/CorePlot/framework/Source/CPTAnimationPeriod.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTAnimationPeriod.m b/CorePlot/framework/Source/CPTAnimationPeriod.m old mode 100755 new mode 100644 index 30c947d..f8e658b --- a/CorePlot/framework/Source/CPTAnimationPeriod.m +++ b/CorePlot/framework/Source/CPTAnimationPeriod.m @@ -125,7 +125,7 @@ +(nonnull instancetype)periodWithStartPoint:(CGPoint)aStartPoint endPoint:(CGPoi { NSValue *start = nil; - if ( !isnan(aStartPoint.x) && !isnan(aStartPoint.y) ) { + if ( !isnan(aStartPoint.x) && !isnan(aStartPoint.y)) { start = [NSValue valueWithBytes:&aStartPoint objCType:@encode(CGPoint)]; } @@ -148,7 +148,7 @@ +(nonnull instancetype)periodWithStartSize:(CGSize)aStartSize endSize:(CGSize)an { NSValue *start = nil; - if ( !isnan(aStartSize.width) && !isnan(aStartSize.height) ) { + if ( !isnan(aStartSize.width) && !isnan(aStartSize.height)) { start = [NSValue valueWithBytes:&aStartSize objCType:@encode(CGSize)]; } @@ -171,7 +171,7 @@ +(nonnull instancetype)periodWithStartRect:(CGRect)aStartRect endRect:(CGRect)an { NSValue *start = nil; - if ( !CGRectEqualToRect(aStartRect, CGRectNull) && !isnan(aStartRect.origin.x) && !isnan(aStartRect.origin.y) && !isnan(aStartRect.size.width) && !isnan(aStartRect.size.height) ) { + if ( !CGRectEqualToRect(aStartRect, CGRectNull) && !isnan(aStartRect.origin.x) && !isnan(aStartRect.origin.y) && !isnan(aStartRect.size.width) && !isnan(aStartRect.size.height)) { start = [NSValue valueWithBytes:&aStartRect objCType:@encode(CGRect)]; } @@ -230,7 +230,7 @@ +(nonnull instancetype)periodWithStartPlotRange:(nonnull CPTPlotRange *)aStartPl { CPTPlotRange *startRange = aStartPlotRange; - if ( isnan(aStartPlotRange.locationDouble) || isnan(aStartPlotRange.lengthDouble) ) { + if ( isnan(aStartPlotRange.locationDouble) || isnan(aStartPlotRange.lengthDouble)) { startRange = nil; } @@ -263,7 +263,7 @@ +(nonnull instancetype)periodWithStartPlotRange:(nonnull CPTPlotRange *)aStartPl **/ -(instancetype)initWithStartValue:(NSValue *)aStartValue endValue:(NSValue *)anEndValue ofClass:(Class)class duration:(CGFloat)aDuration withDelay:(CGFloat)aDelay { - if ( (self = [super init]) ) { + if ((self = [super init])) { startValue = [aStartValue copy]; endValue = [anEndValue copy]; valueClass = class; @@ -310,7 +310,7 @@ -(nonnull instancetype)initWithStartPoint:(CGPoint)aStartPoint endPoint:(CGPoint { NSValue *start = nil; - if ( !isnan(aStartPoint.x) && !isnan(aStartPoint.y) ) { + if ( !isnan(aStartPoint.x) && !isnan(aStartPoint.y)) { start = [NSValue valueWithBytes:&aStartPoint objCType:@encode(CGPoint)]; } @@ -335,7 +335,7 @@ -(nonnull instancetype)initWithStartSize:(CGSize)aStartSize endSize:(CGSize)anEn { NSValue *start = nil; - if ( !isnan(aStartSize.width) && !isnan(aStartSize.height) ) { + if ( !isnan(aStartSize.width) && !isnan(aStartSize.height)) { start = [NSValue valueWithBytes:&aStartSize objCType:@encode(CGSize)]; } @@ -360,7 +360,7 @@ -(nonnull instancetype)initWithStartRect:(CGRect)aStartRect endRect:(CGRect)anEn { NSValue *start = nil; - if ( !CGRectEqualToRect(aStartRect, CGRectNull) && !isnan(aStartRect.origin.x) && !isnan(aStartRect.origin.y) && !isnan(aStartRect.size.width) && !isnan(aStartRect.size.height) ) { + if ( !CGRectEqualToRect(aStartRect, CGRectNull) && !isnan(aStartRect.origin.x) && !isnan(aStartRect.origin.y) && !isnan(aStartRect.size.width) && !isnan(aStartRect.size.height)) { start = [NSValue valueWithBytes:&aStartRect objCType:@encode(CGRect)]; } @@ -425,7 +425,7 @@ -(nonnull instancetype)initWithStartPlotRange:(nonnull CPTPlotRange *)aStartPlot { CPTPlotRange *startRange = aStartPlotRange; - if ( isnan(aStartPlotRange.locationDouble) || isnan(aStartPlotRange.lengthDouble) ) { + if ( isnan(aStartPlotRange.locationDouble) || isnan(aStartPlotRange.lengthDouble)) { startRange = nil; } diff --git a/CorePlot/framework/Source/CPTAnnotation.h b/CorePlot/framework/Source/CPTAnnotation.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTAnnotation.m b/CorePlot/framework/Source/CPTAnnotation.m old mode 100755 new mode 100644 index 5021c4e..18483ec --- a/CorePlot/framework/Source/CPTAnnotation.m +++ b/CorePlot/framework/Source/CPTAnnotation.m @@ -55,7 +55,7 @@ @implementation CPTAnnotation **/ -(nonnull instancetype)init { - if ( (self = [super init]) ) { + if ((self = [super init])) { annotationHostLayer = nil; contentLayer = nil; displacement = CGPointZero; @@ -83,7 +83,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super init]) ) { + if ((self = [super init])) { annotationHostLayer = [coder decodeObjectOfClass:[CPTAnnotationHostLayer class] forKey:@"CPTAnnotation.annotationHostLayer"]; contentLayer = [coder decodeObjectOfClass:[CPTLayer class] @@ -155,7 +155,7 @@ -(void)setAnnotationHostLayer:(nullable CPTAnnotationHostLayer *)newLayer -(void)setDisplacement:(CGPoint)newDisplacement { - if ( !CGPointEqualToPoint(newDisplacement, displacement) ) { + if ( !CGPointEqualToPoint(newDisplacement, displacement)) { displacement = newDisplacement; [self.contentLayer.superlayer setNeedsLayout]; } @@ -163,7 +163,7 @@ -(void)setDisplacement:(CGPoint)newDisplacement -(void)setContentAnchorPoint:(CGPoint)newAnchorPoint { - if ( !CGPointEqualToPoint(newAnchorPoint, contentAnchorPoint) ) { + if ( !CGPointEqualToPoint(newAnchorPoint, contentAnchorPoint)) { contentAnchorPoint = newAnchorPoint; [self.contentLayer.superlayer setNeedsLayout]; } diff --git a/CorePlot/framework/Source/CPTAnnotationHostLayer.h b/CorePlot/framework/Source/CPTAnnotationHostLayer.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTAnnotationHostLayer.m b/CorePlot/framework/Source/CPTAnnotationHostLayer.m old mode 100755 new mode 100644 index 701b8b8..6fa9af6 --- a/CorePlot/framework/Source/CPTAnnotationHostLayer.m +++ b/CorePlot/framework/Source/CPTAnnotationHostLayer.m @@ -43,7 +43,7 @@ @implementation CPTAnnotationHostLayer **/ -(nonnull instancetype)initWithFrame:(CGRect)newFrame { - if ( (self = [super initWithFrame:newFrame]) ) { + if ((self = [super initWithFrame:newFrame])) { mutableAnnotations = [[NSMutableArray alloc] init]; } return self; @@ -55,7 +55,7 @@ -(nonnull instancetype)initWithFrame:(CGRect)newFrame -(nonnull instancetype)initWithLayer:(nonnull id)layer { - if ( (self = [super initWithLayer:layer]) ) { + if ((self = [super initWithLayer:layer])) { CPTAnnotationHostLayer *theLayer = (CPTAnnotationHostLayer *)layer; mutableAnnotations = theLayer->mutableAnnotations; @@ -79,7 +79,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super initWithCoder:coder]) ) { + if ((self = [super initWithCoder:coder])) { CPTAnnotationArray *annotations = [coder decodeObjectOfClasses:[NSSet setWithArray:@[[NSArray class], [CPTAnnotation class]]] forKey:@"CPTAnnotationHostLayer.mutableAnnotations"]; if ( annotations ) { @@ -230,7 +230,7 @@ -(BOOL)pointingDeviceDownEvent:(nonnull CPTNativeEvent *)event atPoint:(CGPoint) for ( CPTAnnotation *annotation in self.annotations ) { CPTLayer *content = annotation.contentLayer; if ( content ) { - if ( CGRectContainsPoint(content.frame, interactionPoint) ) { + if ( CGRectContainsPoint(content.frame, interactionPoint)) { BOOL handled = [content pointingDeviceDownEvent:event atPoint:interactionPoint]; if ( handled ) { return YES; @@ -261,7 +261,7 @@ -(BOOL)pointingDeviceUpEvent:(nonnull CPTNativeEvent *)event atPoint:(CGPoint)in for ( CPTAnnotation *annotation in self.annotations ) { CPTLayer *content = annotation.contentLayer; if ( content ) { - if ( CGRectContainsPoint(content.frame, interactionPoint) ) { + if ( CGRectContainsPoint(content.frame, interactionPoint)) { BOOL handled = [content pointingDeviceUpEvent:event atPoint:interactionPoint]; if ( handled ) { return YES; @@ -292,7 +292,7 @@ -(BOOL)pointingDeviceDraggedEvent:(nonnull CPTNativeEvent *)event atPoint:(CGPoi for ( CPTAnnotation *annotation in self.annotations ) { CPTLayer *content = annotation.contentLayer; if ( content ) { - if ( CGRectContainsPoint(content.frame, interactionPoint) ) { + if ( CGRectContainsPoint(content.frame, interactionPoint)) { BOOL handled = [content pointingDeviceDraggedEvent:event atPoint:interactionPoint]; if ( handled ) { return YES; diff --git a/CorePlot/framework/Source/CPTAxis.h b/CorePlot/framework/Source/CPTAxis.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTAxis.m b/CorePlot/framework/Source/CPTAxis.m old mode 100755 new mode 100644 index 116ea5a..1e060b2 --- a/CorePlot/framework/Source/CPTAxis.m +++ b/CorePlot/framework/Source/CPTAxis.m @@ -540,7 +540,7 @@ @implementation CPTAxis **/ -(nonnull instancetype)initWithFrame:(CGRect)newFrame { - if ( (self = [super initWithFrame:newFrame]) ) { + if ((self = [super initWithFrame:newFrame])) { plotSpace = nil; majorTickLocations = [NSSet set]; minorTickLocations = [NSSet set]; @@ -619,7 +619,7 @@ -(nonnull instancetype)initWithFrame:(CGRect)newFrame -(nonnull instancetype)initWithLayer:(nonnull id)layer { - if ( (self = [super initWithLayer:layer]) ) { + if ((self = [super initWithLayer:layer])) { CPTAxis *theLayer = (CPTAxis *)layer; plotSpace = theLayer->plotSpace; @@ -774,7 +774,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super initWithCoder:coder]) ) { + if ((self = [super initWithCoder:coder])) { coordinate = (CPTCoordinate)[coder decodeIntegerForKey:@"CPTAxis.coordinate"]; plotSpace = [coder decodeObjectOfClass:[CPTPlotSpace class] forKey:@"CPTAxis.plotSpace"]; @@ -940,7 +940,7 @@ -(void)generateFixedIntervalMajorTickLocations:(CPTNumberSet *__autoreleasing *) NSDecimal zero = CPTDecimalFromInteger(0); NSDecimal majorInterval = self.majorIntervalLength.decimalValue; - if ( CPTDecimalGreaterThan(majorInterval, zero) ) { + if ( CPTDecimalGreaterThan(majorInterval, zero)) { CPTMutablePlotRange *range = [[self.plotSpace plotRangeForCoordinate:self.coordinate] mutableCopy]; if ( range ) { CPTPlotRange *theVisibleRange = self.visibleRange; @@ -954,7 +954,7 @@ -(void)generateFixedIntervalMajorTickLocations:(CPTNumberSet *__autoreleasing *) NSDecimal minorInterval; NSUInteger minorTickCount = self.minorTicksPerInterval; if ( minorTickCount > 0 ) { - minorInterval = CPTDecimalDivide(majorInterval, CPTDecimalFromUnsignedInteger(minorTickCount + 1) ); + minorInterval = CPTDecimalDivide(majorInterval, CPTDecimalFromUnsignedInteger(minorTickCount + 1)); } else { minorInterval = zero; @@ -971,7 +971,7 @@ -(void)generateFixedIntervalMajorTickLocations:(CPTNumberSet *__autoreleasing *) NSDecimal minorCoord = CPTDecimalSubtract(coord, minorInterval); for ( NSUInteger minorTickIndex = 0; minorTickIndex < minorTickCount; minorTickIndex++ ) { - if ( CPTDecimalLessThan(minorCoord, rangeMin) ) { + if ( CPTDecimalLessThan(minorCoord, rangeMin)) { break; } [minorLocations addObject:[NSDecimalNumber decimalNumberWithDecimal:minorCoord]]; @@ -980,7 +980,7 @@ -(void)generateFixedIntervalMajorTickLocations:(CPTNumberSet *__autoreleasing *) } // Set tick locations - while ( CPTDecimalLessThanOrEqualTo(coord, rangeMax) ) { + while ( CPTDecimalLessThanOrEqualTo(coord, rangeMax)) { // Major tick [majorLocations addObject:[NSDecimalNumber decimalNumberWithDecimal:coord]]; @@ -989,7 +989,7 @@ -(void)generateFixedIntervalMajorTickLocations:(CPTNumberSet *__autoreleasing *) NSDecimal minorCoord = CPTDecimalAdd(coord, minorInterval); for ( NSUInteger minorTickIndex = 0; minorTickIndex < minorTickCount; minorTickIndex++ ) { - if ( CPTDecimalGreaterThan(minorCoord, rangeMax) ) { + if ( CPTDecimalGreaterThan(minorCoord, rangeMax)) { break; } [minorLocations addObject:[NSDecimalNumber decimalNumberWithDecimal:minorCoord]]; @@ -1037,7 +1037,7 @@ -(void)autoGenerateMajorTickLocations:(CPTNumberSet *__autoreleasing *)newMajorL case CPTScaleTypeLog: // supported scale type--check range - if ( (range.minLimitDouble <= 0.0) || (range.maxLimitDouble <= 0.0) ) { + if ((range.minLimitDouble <= 0.0) || (range.maxLimitDouble <= 0.0)) { valid = NO; } break; @@ -1064,7 +1064,7 @@ -(void)autoGenerateMajorTickLocations:(CPTNumberSet *__autoreleasing *)newMajorL double length = fabs(range.lengthDouble); // Filter troublesome values and return empty sets - if ( length != 0.0 ) { + if ((length != 0.0) && !isinf(length)) { switch ( scaleType ) { case CPTScaleTypeLinear: { @@ -1091,16 +1091,16 @@ -(void)autoGenerateMajorTickLocations:(CPTNumberSet *__autoreleasing *)newMajorL majorInterval = CPTNiceLength(range.lengthDecimal); } else { - majorInterval = CPTDecimalDivide(range.lengthDecimal, CPTDecimalFromUnsignedInteger(numTicks - 1) ); + majorInterval = CPTDecimalDivide(range.lengthDecimal, CPTDecimalFromUnsignedInteger(numTicks - 1)); majorInterval = CPTNiceNum(majorInterval); } - if ( CPTDecimalLessThan(majorInterval, zero) ) { - majorInterval = CPTDecimalMultiply(majorInterval, CPTDecimalFromInteger(-1) ); + if ( CPTDecimalLessThan(majorInterval, zero)) { + majorInterval = CPTDecimalMultiply(majorInterval, CPTDecimalFromInteger(-1)); } NSDecimal minorInterval; if ( minorTicks > 1 ) { - minorInterval = CPTDecimalDivide(majorInterval, CPTDecimalFromUnsignedInteger(minorTicks) ); + minorInterval = CPTDecimalDivide(majorInterval, CPTDecimalFromUnsignedInteger(minorTicks)); } else { minorInterval = zero; @@ -1118,26 +1118,26 @@ -(void)autoGenerateMajorTickLocations:(CPTNumberSet *__autoreleasing *)newMajorL NSDecimalRound(&finalIndex, &finalIndex, 0, NSRoundUp); // Iterate through the indexes with visible ticks and build the locations sets - for ( NSDecimal i = initialIndex; CPTDecimalLessThanOrEqualTo(i, finalIndex); i = CPTDecimalAdd(i, one) ) { + for ( NSDecimal i = initialIndex; CPTDecimalLessThanOrEqualTo(i, finalIndex); i = CPTDecimalAdd(i, one)) { NSDecimal pointLocation = CPTDecimalMultiply(majorInterval, i); NSDecimal minorPointLocation = pointLocation; for ( NSUInteger j = 1; j < minorTicks; j++ ) { minorPointLocation = CPTDecimalAdd(minorPointLocation, minorInterval); - if ( CPTDecimalLessThan(minorPointLocation, minLimit) ) { + if ( CPTDecimalLessThan(minorPointLocation, minLimit)) { continue; } - if ( CPTDecimalGreaterThan(minorPointLocation, maxLimit) ) { + if ( CPTDecimalGreaterThan(minorPointLocation, maxLimit)) { continue; } [minorLocations addObject:[NSDecimalNumber decimalNumberWithDecimal:minorPointLocation]]; } - if ( CPTDecimalLessThan(pointLocation, minLimit) ) { + if ( CPTDecimalLessThan(pointLocation, minLimit)) { continue; } - if ( CPTDecimalGreaterThan(pointLocation, maxLimit) ) { + if ( CPTDecimalGreaterThan(pointLocation, maxLimit)) { continue; } [majorLocations addObject:[NSDecimalNumber decimalNumberWithDecimal:pointLocation]]; @@ -1150,19 +1150,19 @@ -(void)autoGenerateMajorTickLocations:(CPTNumberSet *__autoreleasing *)newMajorL double minLimit = range.minLimitDouble; double maxLimit = range.maxLimitDouble; - if ( (minLimit > 0.0) && (maxLimit > 0.0) ) { + if ((minLimit > 0.0) && (maxLimit > 0.0)) { // Determine interval value length = log10(maxLimit / minLimit); double interval = signbit(length) ? -1.0 : 1.0; - double intervalStep = pow(10.0, fabs(interval) ); + double intervalStep = pow(10.0, fabs(interval)); // Determine minor interval - double minorInterval = intervalStep * 0.9 * pow(10.0, floor(log10(minLimit) ) ) / minorTicks; + double minorInterval = intervalStep * 0.9 * pow(10.0, floor(log10(minLimit))) / minorTicks; // Determine the initial and final major indexes for the actual visible range - NSInteger initialIndex = (NSInteger)lrint(floor(log10(minLimit / fabs(interval) ) ) ); // can be negative - NSInteger finalIndex = (NSInteger)lrint(ceil(log10(maxLimit / fabs(interval) ) ) ); // can be negative + NSInteger initialIndex = (NSInteger)lrint(floor(log10(minLimit / fabs(interval)))); // can be negative + NSInteger finalIndex = (NSInteger)lrint(ceil(log10(maxLimit / fabs(interval)))); // can be negative // Iterate through the indexes with visible ticks and build the locations sets for ( NSInteger i = initialIndex; i <= finalIndex; i++ ) { @@ -1200,14 +1200,14 @@ -(void)autoGenerateMajorTickLocations:(CPTNumberSet *__autoreleasing *)newMajorL double modMinLimit = CPTLogModulus(minLimit); double modMaxLimit = CPTLogModulus(maxLimit); - double multiplier = pow(10.0, floor(log10(length) ) ); + double multiplier = pow(10.0, floor(log10(length))); multiplier = (multiplier < 1.0) ? multiplier : 1.0; double intervalStep = 10.0; // Determine the initial and final major indexes for the actual visible range - NSInteger initialIndex = (NSInteger)lrint(floor(modMinLimit / multiplier) ); // can be negative - NSInteger finalIndex = (NSInteger)lrint(ceil(modMaxLimit / multiplier) ); // can be negative + NSInteger initialIndex = (NSInteger)lrint(floor(modMinLimit / multiplier)); // can be negative + NSInteger finalIndex = (NSInteger)lrint(ceil(modMaxLimit / multiplier)); // can be negative if ( initialIndex < 0 ) { // Determine minor interval @@ -1218,10 +1218,10 @@ -(void)autoGenerateMajorTickLocations:(CPTNumberSet *__autoreleasing *)newMajorL double sign = -multiplier; if ( multiplier < 1.0 ) { - pointLocation = sign * pow(10.0, fabs( (double)i ) - 1.0); + pointLocation = sign * pow(10.0, fabs((double)i) - 1.0); } else { - pointLocation = sign * pow(10.0, fabs( (double)i ) ); + pointLocation = sign * pow(10.0, fabs((double)i)); } for ( NSUInteger j = 1; j < minorTicks; j++ ) { @@ -1258,10 +1258,10 @@ -(void)autoGenerateMajorTickLocations:(CPTNumberSet *__autoreleasing *)newMajorL double sign = multiplier; if ( multiplier < 1.0 ) { - pointLocation = sign * pow(10.0, fabs( (double)i ) - 1.0); + pointLocation = sign * pow(10.0, fabs((double)i) - 1.0); } else { - pointLocation = sign * pow(10.0, fabs( (double)i ) ); + pointLocation = sign * pow(10.0, fabs((double)i)); } for ( NSUInteger j = 1; j < minorTicks; j++ ) { @@ -1330,15 +1330,15 @@ -(void)generateEqualMajorTickLocations:(CPTNumberSet *__autoreleasing *)newMajor if ( majorTickCount < 2 ) { majorTickCount = 2; } - NSDecimal majorInterval = CPTDecimalDivide(range.lengthDecimal, CPTDecimalFromUnsignedInteger(majorTickCount - 1) ); - if ( CPTDecimalLessThan(majorInterval, zero) ) { - majorInterval = CPTDecimalMultiply(majorInterval, CPTDecimalFromInteger(-1) ); + NSDecimal majorInterval = CPTDecimalDivide(range.lengthDecimal, CPTDecimalFromUnsignedInteger(majorTickCount - 1)); + if ( CPTDecimalLessThan(majorInterval, zero)) { + majorInterval = CPTDecimalMultiply(majorInterval, CPTDecimalFromInteger(-1)); } NSDecimal minorInterval; NSUInteger minorTickCount = self.minorTicksPerInterval; if ( minorTickCount > 0 ) { - minorInterval = CPTDecimalDivide(majorInterval, CPTDecimalFromUnsignedInteger(minorTickCount + 1) ); + minorInterval = CPTDecimalDivide(majorInterval, CPTDecimalFromUnsignedInteger(minorTickCount + 1)); } else { minorInterval = zero; @@ -1347,7 +1347,7 @@ -(void)generateEqualMajorTickLocations:(CPTNumberSet *__autoreleasing *)newMajor NSDecimal coord = rangeMin; // Set tick locations - while ( CPTDecimalLessThanOrEqualTo(coord, rangeMax) ) { + while ( CPTDecimalLessThanOrEqualTo(coord, rangeMax)) { // Major tick [majorLocations addObject:[NSDecimalNumber decimalNumberWithDecimal:coord]]; @@ -1356,7 +1356,7 @@ -(void)generateEqualMajorTickLocations:(CPTNumberSet *__autoreleasing *)newMajor NSDecimal minorCoord = CPTDecimalAdd(coord, minorInterval); for ( NSUInteger minorTickIndex = 0; minorTickIndex < minorTickCount; minorTickIndex++ ) { - if ( CPTDecimalGreaterThan(minorCoord, rangeMax) ) { + if ( CPTDecimalGreaterThan(minorCoord, rangeMax)) { break; } [minorLocations addObject:[NSDecimalNumber decimalNumberWithDecimal:minorCoord]]; @@ -1382,7 +1382,7 @@ NSDecimal CPTNiceNum(NSDecimal x) { NSDecimal zero = CPTDecimalFromInteger(0); - if ( CPTDecimalEquals(x, zero) ) { + if ( CPTDecimalEquals(x, zero)) { return zero; } @@ -1393,20 +1393,20 @@ NSDecimal CPTNiceNum(NSDecimal x) x = CPTDecimalMultiply(x, minusOne); } - short exponent = (short)lrint(floor(log10(CPTDecimalDoubleValue(x) ) ) ); + short exponent = (short)lrint(floor(log10(CPTDecimalDoubleValue(x)))); NSDecimal fractionPart; NSDecimalMultiplyByPowerOf10(&fractionPart, &x, -exponent, NSRoundPlain); NSDecimal roundedFraction; - if ( CPTDecimalLessThan(fractionPart, CPTDecimalFromDouble(1.5) ) ) { + if ( CPTDecimalLessThan(fractionPart, CPTDecimalFromDouble(1.5))) { roundedFraction = CPTDecimalFromInteger(1); } - else if ( CPTDecimalLessThan(fractionPart, CPTDecimalFromInteger(3) ) ) { + else if ( CPTDecimalLessThan(fractionPart, CPTDecimalFromInteger(3))) { roundedFraction = CPTDecimalFromInteger(2); } - else if ( CPTDecimalLessThan(fractionPart, CPTDecimalFromInteger(7) ) ) { + else if ( CPTDecimalLessThan(fractionPart, CPTDecimalFromInteger(7))) { roundedFraction = CPTDecimalFromInteger(5); } else { @@ -1432,7 +1432,7 @@ NSDecimal CPTNiceLength(NSDecimal length) { NSDecimal zero = CPTDecimalFromInteger(0); - if ( CPTDecimalEquals(length, zero) ) { + if ( CPTDecimalEquals(length, zero)) { return zero; } @@ -1445,11 +1445,11 @@ NSDecimal CPTNiceLength(NSDecimal length) NSDecimal roundedNumber; - if ( CPTDecimalGreaterThan(length, CPTDecimalFromInteger(10) ) ) { + if ( CPTDecimalGreaterThan(length, CPTDecimalFromInteger(10))) { NSDecimalRound(&roundedNumber, &length, 0, NSRoundDown); } else { - short exponent = (short)lrint(floor(log10(CPTDecimalDoubleValue(length) ) ) ) - 1; + short exponent = (short)lrint(floor(log10(CPTDecimalDoubleValue(length)))) - 1; NSDecimalRound(&roundedNumber, &length, -exponent, NSRoundDown); } @@ -1589,7 +1589,7 @@ -(void)updateAxisLabelsAtLocations:(nullable CPTNumberSet *)locations inRange:(n theShadow = self.minorTickLabelShadow; } - if ( (locations.count == 0) || !theLabelTextStyle || !theLabelFormatter ) { + if ((locations.count == 0) || !theLabelTextStyle || !theLabelFormatter ) { if ( useMajorAxisLabels ) { self.axisLabels = nil; } @@ -1613,7 +1613,7 @@ -(void)updateAxisLabelsAtLocations:(nullable CPTNumberSet *)locations inRange:(n theLabelDirection = direction; } - if ( (direction == CPTSignNone) || (theLabelDirection == direction) ) { + if ((direction == CPTSignNone) || (theLabelDirection == direction)) { theLabelOffset += self.tickOffset; } @@ -1875,7 +1875,7 @@ -(void)updateMajorTickLabelOffsets CGFloat majorOffset = self.labelOffset; - if ( (direction == CPTSignNone) || (labelDirection == direction) ) { + if ((direction == CPTSignNone) || (labelDirection == direction)) { majorOffset += self.tickOffset; } @@ -1895,7 +1895,7 @@ -(void)updateMinorTickLabelOffsets CGFloat minorOffset = self.minorTickLabelOffset; - if ( (direction == CPTSignNone) || (labelDirection == direction) ) { + if ((direction == CPTSignNone) || (labelDirection == direction)) { minorOffset += self.tickOffset; } @@ -2089,7 +2089,7 @@ -(BOOL)pointingDeviceDownEvent:(nonnull CPTNativeEvent *)event atPoint:(CGPoint) if ( contentLayer && !contentLayer.hidden ) { CGPoint labelPoint = [theGraph convertPoint:interactionPoint toLayer:contentLayer]; - if ( CGRectContainsPoint(contentLayer.bounds, labelPoint) ) { + if ( CGRectContainsPoint(contentLayer.bounds, labelPoint)) { self.pointingDeviceDownLabel = label; BOOL handled = NO; @@ -2121,7 +2121,7 @@ -(BOOL)pointingDeviceDownEvent:(nonnull CPTNativeEvent *)event atPoint:(CGPoint) if ( contentLayer && !contentLayer.hidden ) { CGPoint labelPoint = [theGraph convertPoint:interactionPoint toLayer:contentLayer]; - if ( CGRectContainsPoint(contentLayer.bounds, labelPoint) ) { + if ( CGRectContainsPoint(contentLayer.bounds, labelPoint)) { self.pointingDeviceDownTickLabel = label; BOOL handled = NO; @@ -2200,7 +2200,7 @@ -(BOOL)pointingDeviceUpEvent:(nonnull CPTNativeEvent *)event atPoint:(CGPoint)in if ( contentLayer && !contentLayer.hidden ) { CGPoint labelPoint = [theGraph convertPoint:interactionPoint toLayer:contentLayer]; - if ( CGRectContainsPoint(contentLayer.bounds, labelPoint) ) { + if ( CGRectContainsPoint(contentLayer.bounds, labelPoint)) { BOOL handled = NO; if ( [theDelegate respondsToSelector:@selector(axis:labelTouchUp:)] ) { @@ -2243,7 +2243,7 @@ -(BOOL)pointingDeviceUpEvent:(nonnull CPTNativeEvent *)event atPoint:(CGPoint)in if ( contentLayer && !contentLayer.hidden ) { CGPoint labelPoint = [theGraph convertPoint:interactionPoint toLayer:contentLayer]; - if ( CGRectContainsPoint(contentLayer.bounds, labelPoint) ) { + if ( CGRectContainsPoint(contentLayer.bounds, labelPoint)) { BOOL handled = NO; if ( [theDelegate respondsToSelector:@selector(axis:minorTickTouchUp:)] ) { @@ -2385,7 +2385,7 @@ -(void)setLabelTextStyle:(nullable CPTTextStyle *)newStyle for ( CPTAxisLabel *axisLabel in self.axisLabels ) { CPTLayer *contentLayer = axisLabel.contentLayer; if ( [contentLayer isKindOfClass:textLayerClass] ) { - ( (CPTTextLayer *)contentLayer ).textStyle = labelTextStyle; + ((CPTTextLayer *)contentLayer).textStyle = labelTextStyle; } } @@ -2402,7 +2402,7 @@ -(void)setMinorTickLabelTextStyle:(nullable CPTTextStyle *)newStyle for ( CPTAxisLabel *axisLabel in self.minorTickAxisLabels ) { CPTLayer *contentLayer = axisLabel.contentLayer; if ( [contentLayer isKindOfClass:textLayerClass] ) { - ( (CPTTextLayer *)contentLayer ).textStyle = minorTickLabelTextStyle; + ((CPTTextLayer *)contentLayer).textStyle = minorTickLabelTextStyle; } } @@ -2463,7 +2463,7 @@ -(void)setTitleTextStyle:(nullable CPTTextStyle *)newStyle CPTLayer *contentLayer = self.axisTitle.contentLayer; if ( [contentLayer isKindOfClass:[CPTTextLayer class]] ) { - ( (CPTTextLayer *)contentLayer ).textStyle = titleTextStyle; + ((CPTTextLayer *)contentLayer).textStyle = titleTextStyle; [self updateAxisTitle]; } } @@ -2512,7 +2512,7 @@ -(void)setTitle:(nullable NSString *)newTitle if ( title ) { CPTLayer *contentLayer = self.axisTitle.contentLayer; if ( [contentLayer isKindOfClass:[CPTTextLayer class]] ) { - ( (CPTTextLayer *)contentLayer ).text = title; + ((CPTTextLayer *)contentLayer).text = title; [self updateAxisTitle]; } } @@ -2538,7 +2538,7 @@ -(void)setAttributedTitle:(nullable NSAttributedString *)newTitle CPTLayer *contentLayer = self.axisTitle.contentLayer; if ( [contentLayer isKindOfClass:[CPTTextLayer class]] ) { - ( (CPTTextLayer *)contentLayer ).attributedText = attributedTitle; + ((CPTTextLayer *)contentLayer).attributedText = attributedTitle; [self updateAxisTitle]; } } @@ -2571,7 +2571,7 @@ -(void)setTitleLocation:(nullable NSNumber *)newLocation -(nullable NSNumber *)titleLocation { - if ( isnan(titleLocation.doubleValue) ) { + if ( isnan(titleLocation.doubleValue)) { return self.defaultTitleLocation; } else { @@ -3070,6 +3070,9 @@ -(void)setPlotArea:(nullable CPTPlotArea *)newPlotArea for ( CPTAxisLabel *label in self.axisLabels ) { [label.contentLayer removeFromSuperlayer]; } + for ( CPTAxisLabel *label in self.minorTickAxisLabels ) { + [label.contentLayer removeFromSuperlayer]; + } [self.axisTitle.contentLayer removeFromSuperlayer]; } } diff --git a/CorePlot/framework/Source/CPTAxisLabel.h b/CorePlot/framework/Source/CPTAxisLabel.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTAxisLabel.m b/CorePlot/framework/Source/CPTAxisLabel.m old mode 100755 new mode 100644 index 576ca00..2f9f23f --- a/CorePlot/framework/Source/CPTAxisLabel.m +++ b/CorePlot/framework/Source/CPTAxisLabel.m @@ -63,7 +63,7 @@ -(nonnull instancetype)initWithText:(nullable NSString *)newText textStyle:(null **/ -(nonnull instancetype)initWithContentLayer:(nonnull CPTLayer *)layer { - if ( (self = [super init]) ) { + if ((self = [super init])) { contentLayer = layer; offset = CPTFloat(20.0); rotation = CPTFloat(0.0); @@ -105,7 +105,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder */ -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super init]) ) { + if ((self = [super init])) { contentLayer = [coder decodeObjectOfClass:[CPTLayer class] forKey:@"CPTAxisLabel.contentLayer"]; offset = [coder decodeCGFloatForKey:@"CPTAxisLabel.offset"]; @@ -151,14 +151,14 @@ -(void)positionRelativeToViewPoint:(CGPoint)point forCoordinate:(CPTCoordinate)c } CGPoint newPosition = point; - CGFloat *value = (coordinate == CPTCoordinateX ? &(newPosition.x) : &(newPosition.y) ); + CGFloat *value = (coordinate == CPTCoordinateX ? &(newPosition.x) : &(newPosition.y)); CGFloat angle = CPTFloat(0.0); CGFloat labelRotation = self.rotation; - if ( isnan(labelRotation) ) { - labelRotation = (coordinate == CPTCoordinateX ? CPTFloat(M_PI_2) : CPTFloat(0.0) ); + if ( isnan(labelRotation)) { + labelRotation = (coordinate == CPTCoordinateX ? CPTFloat(M_PI_2) : CPTFloat(0.0)); } - content.transform = CATransform3DMakeRotation(labelRotation, CPTFloat(0.0), CPTFloat(0.0), CPTFloat(1.0) ); + content.transform = CATransform3DMakeRotation(labelRotation, CPTFloat(0.0), CPTFloat(0.0), CPTFloat(1.0)); CGRect contentFrame = content.frame; // Position the anchor point along the closest edge. @@ -272,7 +272,7 @@ -(void)positionRelativeToViewPoint:(CGPoint)point forCoordinate:(CPTCoordinate)c CGFloat newAnchorX = cos(angle); CGFloat newAnchorY = sin(angle); - if ( ABS(newAnchorX) <= ABS(newAnchorY) ) { + if ( ABS(newAnchorX) <= ABS(newAnchorY)) { newAnchorX /= ABS(newAnchorY); newAnchorY = signbit(newAnchorY) ? CPTFloat(-1.0) : CPTFloat(1.0); } @@ -280,7 +280,7 @@ -(void)positionRelativeToViewPoint:(CGPoint)point forCoordinate:(CPTCoordinate)c newAnchorY /= ABS(newAnchorX); newAnchorX = signbit(newAnchorX) ? CPTFloat(-1.0) : CPTFloat(1.0); } - CGPoint anchor = CPTPointMake( (newAnchorX + CPTFloat(1.0) ) / CPTFloat(2.0), (newAnchorY + CPTFloat(1.0) ) / CPTFloat(2.0) ); + CGPoint anchor = CPTPointMake((newAnchorX + CPTFloat(1.0)) / CPTFloat(2.0), (newAnchorY + CPTFloat(1.0)) / CPTFloat(2.0)); content.anchorPoint = anchor; content.position = newPosition; @@ -295,7 +295,7 @@ -(void)positionRelativeToViewPoint:(CGPoint)point forCoordinate:(CPTCoordinate)c **/ -(void)positionBetweenViewPoint:(CGPoint)firstPoint andViewPoint:(CGPoint)secondPoint forCoordinate:(CPTCoordinate)coordinate inDirection:(CPTSign)direction { - [self positionRelativeToViewPoint:CPTPointMake( (firstPoint.x + secondPoint.x) / CPTFloat(2.0), (firstPoint.y + secondPoint.y) / CPTFloat(2.0) ) + [self positionRelativeToViewPoint:CPTPointMake((firstPoint.x + secondPoint.x) / CPTFloat(2.0), (firstPoint.y + secondPoint.y) / CPTFloat(2.0)) forCoordinate:coordinate inDirection:direction]; } @@ -329,7 +329,7 @@ -(BOOL)isEqual:(nullable id)object return YES; } else if ( [object isKindOfClass:[self class]] ) { - NSNumber *location = ( (CPTAxisLabel *)object ).tickLocation; + NSNumber *location = ((CPTAxisLabel *)object).tickLocation; if ( location ) { return [self.tickLocation isEqualToNumber:location]; @@ -354,8 +354,8 @@ -(NSUInteger)hash // Equal objects must hash the same. double tickLocationAsDouble = self.tickLocation.doubleValue; - if ( !isnan(tickLocationAsDouble) ) { - hashValue = (NSUInteger)lrint(fmod(ABS(tickLocationAsDouble), (double)NSUIntegerMax) ); + if ( !isnan(tickLocationAsDouble)) { + hashValue = (NSUInteger)lrint(fmod(ABS(tickLocationAsDouble), (double)NSUIntegerMax)); } return hashValue; diff --git a/CorePlot/framework/Source/CPTAxisLabelGroup.h b/CorePlot/framework/Source/CPTAxisLabelGroup.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTAxisLabelGroup.m b/CorePlot/framework/Source/CPTAxisLabelGroup.m old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTAxisLabelTests.h b/CorePlot/framework/Source/CPTAxisLabelTests.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTAxisLabelTests.m b/CorePlot/framework/Source/CPTAxisLabelTests.m old mode 100755 new mode 100644 index 21efacd..9bb03a5 --- a/CorePlot/framework/Source/CPTAxisLabelTests.m +++ b/CorePlot/framework/Source/CPTAxisLabelTests.m @@ -19,8 +19,8 @@ static CGPoint roundPoint(CGPoint position, CGSize contentSize, CGPoint anchor) CGPoint newAnchor = CGPointMake(contentSize.width * anchor.x, contentSize.height * anchor.y); - newPosition.x = ceil(position.x - newAnchor.x - CPTFloat(0.5) ) + newAnchor.x; - newPosition.y = ceil(position.y - newAnchor.y - CPTFloat(0.5) ) + newAnchor.y; + newPosition.x = ceil(position.x - newAnchor.x - CPTFloat(0.5)) + newAnchor.x; + newPosition.y = ceil(position.y - newAnchor.y - CPTFloat(0.5)) + newAnchor.y; return newPosition; } @@ -60,8 +60,8 @@ -(void)testPositionRelativeToViewPointPositionsForXCoordinate CGPoint newPosition = roundPoint(CGPointMake(start - label.offset, start), contentSize, contentLayer.anchorPoint); - XCTAssertEqualWithAccuracy(contentLayer.position.x, newPosition.x, precision, @"Should add negative offset, %@ != %@", CPTStringFromPoint(contentLayer.position), CPTStringFromPoint(newPosition) ); - XCTAssertEqualWithAccuracy(contentLayer.position.y, newPosition.y, precision, @"Should add negative offset, %@ != %@", CPTStringFromPoint(contentLayer.position), CPTStringFromPoint(newPosition) ); + XCTAssertEqualWithAccuracy(contentLayer.position.x, newPosition.x, precision, @"Should add negative offset, %@ != %@", CPTStringFromPoint(contentLayer.position), CPTStringFromPoint(newPosition)); + XCTAssertEqualWithAccuracy(contentLayer.position.y, newPosition.y, precision, @"Should add negative offset, %@ != %@", CPTStringFromPoint(contentLayer.position), CPTStringFromPoint(newPosition)); XCTAssertEqualWithAccuracy(contentLayer.anchorPoint.x, CPTFloat(1.0), precision, @"Should anchor at (1.0, 0.5)"); XCTAssertEqualWithAccuracy(contentLayer.anchorPoint.y, CPTFloat(0.5), precision, @"Should anchor at (1.0, 0.5)"); @@ -73,8 +73,8 @@ -(void)testPositionRelativeToViewPointPositionsForXCoordinate newPosition = roundPoint(CGPointMake(start - label.offset, start), contentSize, contentLayer.anchorPoint); - XCTAssertEqualWithAccuracy(contentLayer.position.x, newPosition.x, precision, @"Should add negative offset, %@ != %@", CPTStringFromPoint(contentLayer.position), CPTStringFromPoint(newPosition) ); - XCTAssertEqualWithAccuracy(contentLayer.position.y, newPosition.y, precision, @"Should add negative offset, %@ != %@", CPTStringFromPoint(contentLayer.position), CPTStringFromPoint(newPosition) ); + XCTAssertEqualWithAccuracy(contentLayer.position.x, newPosition.x, precision, @"Should add negative offset, %@ != %@", CPTStringFromPoint(contentLayer.position), CPTStringFromPoint(newPosition)); + XCTAssertEqualWithAccuracy(contentLayer.position.y, newPosition.y, precision, @"Should add negative offset, %@ != %@", CPTStringFromPoint(contentLayer.position), CPTStringFromPoint(newPosition)); XCTAssertEqualWithAccuracy(contentLayer.anchorPoint.x, CPTFloat(1.0), precision, @"Should anchor at (1.0, 0.5)"); XCTAssertEqualWithAccuracy(contentLayer.anchorPoint.y, CPTFloat(0.5), precision, @"Should anchor at (1.0, 0.5)"); @@ -86,8 +86,8 @@ -(void)testPositionRelativeToViewPointPositionsForXCoordinate newPosition = roundPoint(CGPointMake(start + label.offset, start), contentSize, contentLayer.anchorPoint); - XCTAssertEqualWithAccuracy(contentLayer.position.x, newPosition.x, precision, @"Should add positive offset, %@ != %@", CPTStringFromPoint(contentLayer.position), CPTStringFromPoint(newPosition) ); - XCTAssertEqualWithAccuracy(contentLayer.position.y, newPosition.y, precision, @"Should add positive offset, %@ != %@", CPTStringFromPoint(contentLayer.position), CPTStringFromPoint(newPosition) ); + XCTAssertEqualWithAccuracy(contentLayer.position.x, newPosition.x, precision, @"Should add positive offset, %@ != %@", CPTStringFromPoint(contentLayer.position), CPTStringFromPoint(newPosition)); + XCTAssertEqualWithAccuracy(contentLayer.position.y, newPosition.y, precision, @"Should add positive offset, %@ != %@", CPTStringFromPoint(contentLayer.position), CPTStringFromPoint(newPosition)); XCTAssertEqualWithAccuracy(contentLayer.anchorPoint.x, CPTFloat(0.0), precision, @"Should anchor at (0.0, 0.5)"); XCTAssertEqualWithAccuracy(contentLayer.anchorPoint.y, CPTFloat(0.5), precision, @"Should anchor at (0.0, 0.5)"); } @@ -117,8 +117,8 @@ -(void)testPositionRelativeToViewPointPositionsForYCoordinate CGPoint newPosition = roundPoint(CGPointMake(start, start - label.offset), contentSize, contentLayer.anchorPoint); - XCTAssertEqualWithAccuracy(contentLayer.position.x, newPosition.x, precision, @"Should add negative offset, %@ != %@", CPTStringFromPoint(contentLayer.position), CPTStringFromPoint(newPosition) ); - XCTAssertEqualWithAccuracy(contentLayer.position.y, newPosition.y, precision, @"Should add negative offset, %@ != %@", CPTStringFromPoint(contentLayer.position), CPTStringFromPoint(newPosition) ); + XCTAssertEqualWithAccuracy(contentLayer.position.x, newPosition.x, precision, @"Should add negative offset, %@ != %@", CPTStringFromPoint(contentLayer.position), CPTStringFromPoint(newPosition)); + XCTAssertEqualWithAccuracy(contentLayer.position.y, newPosition.y, precision, @"Should add negative offset, %@ != %@", CPTStringFromPoint(contentLayer.position), CPTStringFromPoint(newPosition)); XCTAssertEqualWithAccuracy(contentLayer.anchorPoint.x, CPTFloat(0.5), precision, @"Should anchor at (0.5, 1.0)"); XCTAssertEqualWithAccuracy(contentLayer.anchorPoint.y, CPTFloat(1.0), precision, @"Should anchor at (0.5, 1.0)"); @@ -130,8 +130,8 @@ -(void)testPositionRelativeToViewPointPositionsForYCoordinate newPosition = roundPoint(CGPointMake(start, start - label.offset), contentSize, contentLayer.anchorPoint); - XCTAssertEqualWithAccuracy(contentLayer.position.x, newPosition.x, precision, @"Should add negative offset, %@ != %@", CPTStringFromPoint(contentLayer.position), CPTStringFromPoint(newPosition) ); - XCTAssertEqualWithAccuracy(contentLayer.position.y, newPosition.y, precision, @"Should add negative offset, %@ != %@", CPTStringFromPoint(contentLayer.position), CPTStringFromPoint(newPosition) ); + XCTAssertEqualWithAccuracy(contentLayer.position.x, newPosition.x, precision, @"Should add negative offset, %@ != %@", CPTStringFromPoint(contentLayer.position), CPTStringFromPoint(newPosition)); + XCTAssertEqualWithAccuracy(contentLayer.position.y, newPosition.y, precision, @"Should add negative offset, %@ != %@", CPTStringFromPoint(contentLayer.position), CPTStringFromPoint(newPosition)); XCTAssertEqualWithAccuracy(contentLayer.anchorPoint.x, CPTFloat(0.5), precision, @"Should anchor at (0.5, 1.0)"); XCTAssertEqualWithAccuracy(contentLayer.anchorPoint.y, CPTFloat(1.0), precision, @"Should anchor at (0.5, 1.0)"); @@ -143,8 +143,8 @@ -(void)testPositionRelativeToViewPointPositionsForYCoordinate newPosition = roundPoint(CGPointMake(start, start + label.offset), contentSize, contentLayer.anchorPoint); - XCTAssertEqualWithAccuracy(contentLayer.position.x, newPosition.x, precision, @"Should add positive offset, %@ != %@", CPTStringFromPoint(contentLayer.position), CPTStringFromPoint(newPosition) ); - XCTAssertEqualWithAccuracy(contentLayer.position.y, newPosition.y, precision, @"Should add positive offset, %@ != %@", CPTStringFromPoint(contentLayer.position), CPTStringFromPoint(newPosition) ); + XCTAssertEqualWithAccuracy(contentLayer.position.x, newPosition.x, precision, @"Should add positive offset, %@ != %@", CPTStringFromPoint(contentLayer.position), CPTStringFromPoint(newPosition)); + XCTAssertEqualWithAccuracy(contentLayer.position.y, newPosition.y, precision, @"Should add positive offset, %@ != %@", CPTStringFromPoint(contentLayer.position), CPTStringFromPoint(newPosition)); XCTAssertEqualWithAccuracy(contentLayer.anchorPoint.x, CPTFloat(0.5), precision, @"Should anchor at (0.5, 0.0)"); XCTAssertEqualWithAccuracy(contentLayer.anchorPoint.y, CPTFloat(0.0), precision, @"Should anchor at (0.5, 0.0)"); } diff --git a/CorePlot/framework/Source/CPTAxisSet.h b/CorePlot/framework/Source/CPTAxisSet.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTAxisSet.m b/CorePlot/framework/Source/CPTAxisSet.m old mode 100755 new mode 100644 index c5678d1..0f37e6c --- a/CorePlot/framework/Source/CPTAxisSet.m +++ b/CorePlot/framework/Source/CPTAxisSet.m @@ -38,7 +38,7 @@ @implementation CPTAxisSet **/ -(nonnull instancetype)initWithFrame:(CGRect)newFrame { - if ( (self = [super initWithFrame:newFrame]) ) { + if ((self = [super initWithFrame:newFrame])) { axes = @[]; borderLineStyle = nil; @@ -53,7 +53,7 @@ -(nonnull instancetype)initWithFrame:(CGRect)newFrame -(nonnull instancetype)initWithLayer:(nonnull id)layer { - if ( (self = [super initWithLayer:layer]) ) { + if ((self = [super initWithLayer:layer])) { CPTAxisSet *theLayer = (CPTAxisSet *)layer; axes = theLayer->axes; @@ -79,7 +79,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super initWithCoder:coder]) ) { + if ((self = [super initWithCoder:coder])) { axes = [[coder decodeObjectOfClasses:[NSSet setWithArray:@[[NSArray class], [CPTAxis class]]] forKey:@"CPTAxisSet.axes"] copy]; borderLineStyle = [[coder decodeObjectOfClass:[CPTLineStyle class] diff --git a/CorePlot/framework/Source/CPTAxisTitle.h b/CorePlot/framework/Source/CPTAxisTitle.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTAxisTitle.m b/CorePlot/framework/Source/CPTAxisTitle.m old mode 100755 new mode 100644 index d195c82..99b26a3 --- a/CorePlot/framework/Source/CPTAxisTitle.m +++ b/CorePlot/framework/Source/CPTAxisTitle.m @@ -18,7 +18,7 @@ @implementation CPTAxisTitle -(nonnull instancetype)initWithContentLayer:(nonnull CPTLayer *)layer { if ( layer ) { - if ( (self = [super initWithContentLayer:layer]) ) { + if ((self = [super initWithContentLayer:layer])) { self.rotation = CPTNAN; } } @@ -49,14 +49,14 @@ -(BOOL)isEqual:(nullable id)object else if ( [object isKindOfClass:[self class]] ) { CPTAxisTitle *otherTitle = object; - if ( (self.rotation != otherTitle.rotation) || (self.offset != otherTitle.offset) ) { + if ((self.rotation != otherTitle.rotation) || (self.offset != otherTitle.offset)) { return NO; } if ( ![self.contentLayer isEqual:otherTitle] ) { return NO; } - NSNumber *location = ( (CPTAxisLabel *)object ).tickLocation; + NSNumber *location = ((CPTAxisLabel *)object).tickLocation; if ( location ) { return [self.tickLocation isEqualToNumber:location]; @@ -81,11 +81,11 @@ -(NSUInteger)hash // Equal objects must hash the same. double tickLocationAsDouble = self.tickLocation.doubleValue; - if ( !isnan(tickLocationAsDouble) ) { - hashValue = (NSUInteger)lrint(fmod(ABS(tickLocationAsDouble), (double)NSUIntegerMax) ); + if ( !isnan(tickLocationAsDouble)) { + hashValue = (NSUInteger)lrint(fmod(ABS(tickLocationAsDouble), (double)NSUIntegerMax)); } - hashValue += (NSUInteger)lrint(fmod(ABS(self.rotation), (double)NSUIntegerMax) ); - hashValue += (NSUInteger)lrint(fmod(ABS(self.offset), (double)NSUIntegerMax) ); + hashValue += (NSUInteger)lrint(fmod(ABS(self.rotation), (double)NSUIntegerMax)); + hashValue += (NSUInteger)lrint(fmod(ABS(self.offset), (double)NSUIntegerMax)); return hashValue; } diff --git a/CorePlot/framework/Source/CPTBarPlot.h b/CorePlot/framework/Source/CPTBarPlot.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTBarPlot.m b/CorePlot/framework/Source/CPTBarPlot.m old mode 100755 new mode 100644 index d2bc184..7a977ab --- a/CorePlot/framework/Source/CPTBarPlot.m +++ b/CorePlot/framework/Source/CPTBarPlot.m @@ -237,7 +237,7 @@ +(void)initialize **/ -(nonnull instancetype)initWithFrame:(CGRect)newFrame { - if ( (self = [super initWithFrame:newFrame]) ) { + if ((self = [super initWithFrame:newFrame])) { lineStyle = [[CPTLineStyle alloc] init]; fill = [CPTFill fillWithColor:[CPTColor blackColor]]; barWidth = @0.5; @@ -263,7 +263,7 @@ -(nonnull instancetype)initWithFrame:(CGRect)newFrame -(nonnull instancetype)initWithLayer:(nonnull id)layer { - if ( (self = [super initWithLayer:layer]) ) { + if ((self = [super initWithLayer:layer])) { CPTBarPlot *theLayer = (CPTBarPlot *)layer; lineStyle = theLayer->lineStyle; @@ -311,7 +311,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super initWithCoder:coder]) ) { + if ((self = [super initWithCoder:coder])) { NSNumber *num; lineStyle = [[coder decodeObjectOfClass:[CPTLineStyle class] @@ -406,7 +406,7 @@ -(void)reloadPlotDataInIndexRange:(NSRange)indexRange CPTMutableNumericData *locationData = nil; if ( self.doublePrecisionCache ) { locationData = [[CPTMutableNumericData alloc] initWithData:[NSData data] - dataType:CPTDataType(CPTFloatingPointDataType, sizeof(double), CFByteOrderGetCurrent() ) + dataType:CPTDataType(CPTFloatingPointDataType, sizeof(double), CFByteOrderGetCurrent()) shape:nil]; locationData.shape = @[@(indexRange.length)]; @@ -425,13 +425,13 @@ -(void)reloadPlotDataInIndexRange:(NSRange)indexRange } else { locationData = [[CPTMutableNumericData alloc] initWithData:[NSData data] - dataType:CPTDataType(CPTDecimalDataType, sizeof(NSDecimal), CFByteOrderGetCurrent() ) + dataType:CPTDataType(CPTDecimalDataType, sizeof(NSDecimal), CFByteOrderGetCurrent()) shape:nil]; locationData.shape = @[@(indexRange.length)]; NSDecimal delta = CPTDecimalFromInteger(1); if ( indexRange.length > 1 ) { - delta = CPTDecimalDivide(self.plotRange.lengthDecimal, CPTDecimalFromUnsignedInteger(indexRange.length - 1) ); + delta = CPTDecimalDivide(self.plotRange.lengthDecimal, CPTDecimalFromUnsignedInteger(indexRange.length - 1)); } NSDecimal locationDecimal = self.plotRange.locationDecimal; @@ -454,7 +454,7 @@ -(void)reloadPlotDataInIndexRange:(NSRange)indexRange CPTMutableNumericData *locationData = nil; if ( self.doublePrecisionCache ) { locationData = [[CPTMutableNumericData alloc] initWithData:[NSData data] - dataType:CPTDataType(CPTFloatingPointDataType, sizeof(double), CFByteOrderGetCurrent() ) + dataType:CPTDataType(CPTFloatingPointDataType, sizeof(double), CFByteOrderGetCurrent()) shape:nil]; locationData.shape = @[@(indexRange.length)]; @@ -468,7 +468,7 @@ -(void)reloadPlotDataInIndexRange:(NSRange)indexRange } else { locationData = [[CPTMutableNumericData alloc] initWithData:[NSData data] - dataType:CPTDataType(CPTDecimalDataType, sizeof(NSDecimal), CFByteOrderGetCurrent() ) + dataType:CPTDataType(CPTDecimalDataType, sizeof(NSDecimal), CFByteOrderGetCurrent()) shape:nil]; locationData.shape = @[@(indexRange.length)]; @@ -789,12 +789,12 @@ -(nullable CPTPlotRange *)plotRangeEnclosingBars NSDecimal barOffsetLength = [self lengthInPlotCoordinates:self.barOffset.decimalValue]; NSDecimal barWidthLength = [self lengthInPlotCoordinates:self.barWidth.decimalValue]; - NSDecimal halfBarWidth = CPTDecimalDivide(barWidthLength, CPTDecimalFromInteger(2) ); + NSDecimal halfBarWidth = CPTDecimalDivide(barWidthLength, CPTDecimalFromInteger(2)); NSDecimal rangeLocation = range.locationDecimal; NSDecimal rangeLength = range.lengthDecimal; - if ( CPTDecimalGreaterThanOrEqualTo(rangeLength, CPTDecimalFromInteger(0) ) ) { + if ( CPTDecimalGreaterThanOrEqualTo(rangeLength, CPTDecimalFromInteger(0))) { rangeLocation = CPTDecimalSubtract(rangeLocation, halfBarWidth); range.locationDecimal = CPTDecimalAdd(rangeLocation, barOffsetLength); @@ -823,13 +823,13 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context CPTMutableNumericData *cachedLocations = [self cachedNumbersForField:CPTBarPlotFieldBarLocation]; CPTMutableNumericData *cachedLengths = [self cachedNumbersForField:CPTBarPlotFieldBarTip]; - if ( (cachedLocations == nil) || (cachedLengths == nil) ) { + if ((cachedLocations == nil) || (cachedLengths == nil)) { return; } BOOL basesVary = self.barBasesVary; CPTMutableNumericData *cachedBases = [self cachedNumbersForField:CPTBarPlotFieldBarBase]; - if ( basesVary && (cachedBases == nil) ) { + if ( basesVary && (cachedBases == nil)) { return; } @@ -842,7 +842,7 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context [NSException raise:CPTException format:@"Number of bar locations and lengths do not match"]; } - if ( basesVary && (cachedLengths.numberOfSamples != cachedBases.numberOfSamples) ) { + if ( basesVary && (cachedLengths.numberOfSamples != cachedBases.numberOfSamples)) { [NSException raise:CPTException format:@"Number of bar lengths and bases do not match"]; } @@ -869,13 +869,13 @@ -(BOOL)barAtRecordIndex:(NSUInteger)idx basePoint:(nonnull CGPoint *)basePoint t if ( self.doublePrecisionCache ) { double plotPoint[2]; plotPoint[independentCoord] = [self cachedDoubleForField:CPTBarPlotFieldBarLocation recordIndex:idx]; - if ( isnan(plotPoint[independentCoord]) ) { + if ( isnan(plotPoint[independentCoord])) { return NO; } // Tip point plotPoint[dependentCoord] = [self cachedDoubleForField:CPTBarPlotFieldBarTip recordIndex:idx]; - if ( isnan(plotPoint[dependentCoord]) ) { + if ( isnan(plotPoint[dependentCoord])) { return NO; } *tipPoint = [thePlotSpace plotAreaViewPointForDoublePrecisionPlotPoint:plotPoint numberOfCoordinates:2]; @@ -887,7 +887,7 @@ -(BOOL)barAtRecordIndex:(NSUInteger)idx basePoint:(nonnull CGPoint *)basePoint t else { plotPoint[dependentCoord] = [self cachedDoubleForField:CPTBarPlotFieldBarBase recordIndex:idx]; } - if ( isnan(plotPoint[dependentCoord]) ) { + if ( isnan(plotPoint[dependentCoord])) { return NO; } *basePoint = [thePlotSpace plotAreaViewPointForDoublePrecisionPlotPoint:plotPoint numberOfCoordinates:2]; @@ -895,13 +895,13 @@ -(BOOL)barAtRecordIndex:(NSUInteger)idx basePoint:(nonnull CGPoint *)basePoint t else { NSDecimal plotPoint[2]; plotPoint[independentCoord] = [self cachedDecimalForField:CPTBarPlotFieldBarLocation recordIndex:idx]; - if ( NSDecimalIsNotANumber(&plotPoint[independentCoord]) ) { + if ( NSDecimalIsNotANumber(&plotPoint[independentCoord])) { return NO; } // Tip point plotPoint[dependentCoord] = [self cachedDecimalForField:CPTBarPlotFieldBarTip recordIndex:idx]; - if ( NSDecimalIsNotANumber(&plotPoint[dependentCoord]) ) { + if ( NSDecimalIsNotANumber(&plotPoint[dependentCoord])) { return NO; } *tipPoint = [thePlotSpace plotAreaViewPointForPlotPoint:plotPoint numberOfCoordinates:2]; @@ -913,7 +913,7 @@ -(BOOL)barAtRecordIndex:(NSUInteger)idx basePoint:(nonnull CGPoint *)basePoint t else { plotPoint[dependentCoord] = [self cachedDecimalForField:CPTBarPlotFieldBarBase recordIndex:idx]; } - if ( NSDecimalIsNotANumber(&plotPoint[dependentCoord]) ) { + if ( NSDecimalIsNotANumber(&plotPoint[dependentCoord])) { return NO; } *basePoint = [thePlotSpace plotAreaViewPointForPlotPoint:plotPoint numberOfCoordinates:2]; @@ -985,7 +985,7 @@ -(nonnull CGMutablePathRef)newBarPathWithContext:(nullable CGContextRef)context CGContextRef theContext = context; - if ( self.lineStyle.lineWidth > CPTFloat(0.0) ) { + if ( self.lineStyle.lineWidth > CPTFloat(0.0)) { barRect = CPTAlignRectToUserSpace(theContext, barRect); } else { @@ -993,21 +993,21 @@ -(nonnull CGMutablePathRef)newBarPathWithContext:(nullable CGContextRef)context } } - CGFloat radius = MIN(MIN(self.barCornerRadius, ABS(barRect.size.width) * CPTFloat(0.5) ), ABS(barRect.size.height) * CPTFloat(0.5) ); - CGFloat baseRadius = MIN(MIN(self.barBaseCornerRadius, ABS(barRect.size.width) * CPTFloat(0.5) ), ABS(barRect.size.height) * CPTFloat(0.5) ); + CGFloat radius = MIN(MIN(self.barCornerRadius, ABS(barRect.size.width) * CPTFloat(0.5)), ABS(barRect.size.height) * CPTFloat(0.5)); + CGFloat baseRadius = MIN(MIN(self.barBaseCornerRadius, ABS(barRect.size.width) * CPTFloat(0.5)), ABS(barRect.size.height) * CPTFloat(0.5)); - if ( widthNegative && (barRect.size.width > CPTFloat(0.0) ) ) { + if ( widthNegative && (barRect.size.width > CPTFloat(0.0))) { barRect.origin.x += barRect.size.width; barRect.size.width = -barRect.size.width; } - if ( heightNegative && (barRect.size.height > CPTFloat(0.0) ) ) { + if ( heightNegative && (barRect.size.height > CPTFloat(0.0))) { barRect.origin.y += barRect.size.height; barRect.size.height = -barRect.size.height; } CGMutablePathRef path = CGPathCreateMutable(); - if ( radius == CPTFloat(0.0) ) { - if ( baseRadius == CPTFloat(0.0) ) { + if ( radius == CPTFloat(0.0)) { + if ( baseRadius == CPTFloat(0.0)) { // square corners CGPathAddRect(path, NULL, barRect); } @@ -1035,7 +1035,7 @@ -(nonnull CGMutablePathRef)newBarPathWithContext:(nullable CGContextRef)context CGFloat tipX = barRect.origin.x + barRect.size.width; CGFloat tipY = barRect.origin.y + barRect.size.height; - if ( baseRadius == CPTFloat(0.0) ) { + if ( baseRadius == CPTFloat(0.0)) { // rounded at tip end only CGPathMoveToPoint(path, NULL, barRect.origin.x, barRect.origin.y); if ( horizontalBars ) { @@ -1053,14 +1053,14 @@ -(nonnull CGMutablePathRef)newBarPathWithContext:(nullable CGContextRef)context else { // rounded at both ends if ( horizontalBars ) { - CGPathMoveToPoint(path, NULL, barRect.origin.x, CGRectGetMidY(barRect) ); + CGPathMoveToPoint(path, NULL, barRect.origin.x, CGRectGetMidY(barRect)); CGPathAddArcToPoint(path, NULL, barRect.origin.x, tipY, CGRectGetMidX(barRect), tipY, baseRadius); CGPathAddArcToPoint(path, NULL, tipX, tipY, tipX, CGRectGetMidY(barRect), radius); CGPathAddArcToPoint(path, NULL, tipX, barRect.origin.y, CGRectGetMidX(barRect), barRect.origin.y, radius); CGPathAddArcToPoint(path, NULL, barRect.origin.x, barRect.origin.y, barRect.origin.x, CGRectGetMidY(barRect), baseRadius); } else { - CGPathMoveToPoint(path, NULL, barRect.origin.x, CGRectGetMidY(barRect) ); + CGPathMoveToPoint(path, NULL, barRect.origin.x, CGRectGetMidY(barRect)); CGPathAddArcToPoint(path, NULL, barRect.origin.x, tipY, CGRectGetMidX(barRect), tipY, radius); CGPathAddArcToPoint(path, NULL, tipX, tipY, tipX, CGRectGetMidY(barRect), radius); CGPathAddArcToPoint(path, NULL, tipX, barRect.origin.y, CGRectGetMidX(barRect), barRect.origin.y, baseRadius); @@ -1081,8 +1081,8 @@ -(BOOL)barIsVisibleWithBasePoint:(CGPoint)basePoint CPTPlotArea *thePlotArea = self.plotArea; - CGFloat lowerBound = (horizontalBars ? CGRectGetMinY(thePlotArea.bounds) : CGRectGetMinX(thePlotArea.bounds) ); - CGFloat upperBound = (horizontalBars ? CGRectGetMaxY(thePlotArea.bounds) : CGRectGetMaxX(thePlotArea.bounds) ); + CGFloat lowerBound = (horizontalBars ? CGRectGetMinY(thePlotArea.bounds) : CGRectGetMinX(thePlotArea.bounds)); + CGFloat upperBound = (horizontalBars ? CGRectGetMaxY(thePlotArea.bounds) : CGRectGetMaxX(thePlotArea.bounds)); CGFloat base = (horizontalBars ? basePoint.y : basePoint.x); return (base + halfBarWidth >= lowerBound) && (base - halfBarWidth <= upperBound); @@ -1092,7 +1092,7 @@ -(nullable CPTFill *)barFillForIndex:(NSUInteger)idx { CPTFill *theBarFill = [self cachedValueForKey:CPTBarPlotBindingBarFills recordIndex:idx]; - if ( (theBarFill == nil) || (theBarFill == [CPTPlot nilData]) ) { + if ((theBarFill == nil) || (theBarFill == [CPTPlot nilData])) { theBarFill = self.fill; } @@ -1103,7 +1103,7 @@ -(nullable CPTLineStyle *)barLineStyleForIndex:(NSUInteger)idx { CPTLineStyle *theBarLineStyle = [self cachedValueForKey:CPTBarPlotBindingBarLineStyles recordIndex:idx]; - if ( (theBarLineStyle == nil) || (theBarLineStyle == [CPTPlot nilData]) ) { + if ((theBarLineStyle == nil) || (theBarLineStyle == [CPTPlot nilData])) { theBarLineStyle = self.lineStyle; } @@ -1231,7 +1231,7 @@ -(void)positionLabelAnnotation:(nonnull CPTPlotSpaceAnnotation *)label forIndex: BOOL horizontalBars = self.barsAreHorizontal; CPTCoordinate coordinate = (horizontalBars ? CPTCoordinateX : CPTCoordinateY); CPTPlotRange *lengthRange = [self.plotSpace plotRangeForCoordinate:coordinate]; - if ( CPTDecimalLessThan(lengthRange.lengthDecimal, CPTDecimalFromInteger(0) ) ) { + if ( CPTDecimalLessThan(lengthRange.lengthDecimal, CPTDecimalFromInteger(0))) { positiveDirection = !positiveDirection; } @@ -1351,10 +1351,10 @@ -(NSUInteger)dataIndexFromInteractionPoint:(CGPoint)point NSUInteger barCount = self.cachedDataCount; NSUInteger ii = 0; - while ( (ii < barCount) && (idx == NSNotFound) ) { + while ((ii < barCount) && (idx == NSNotFound)) { CGMutablePathRef path = [self newBarPathWithContext:NULL recordIndex:ii]; - if ( CGPathContainsPoint(path, NULL, point, false) ) { + if ( CGPathContainsPoint(path, NULL, point, false)) { idx = ii; } diff --git a/CorePlot/framework/Source/CPTBorderedLayer.h b/CorePlot/framework/Source/CPTBorderedLayer.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTBorderedLayer.m b/CorePlot/framework/Source/CPTBorderedLayer.m old mode 100755 new mode 100644 index 4087581..7a6126c --- a/CorePlot/framework/Source/CPTBorderedLayer.m +++ b/CorePlot/framework/Source/CPTBorderedLayer.m @@ -68,7 +68,7 @@ @implementation CPTBorderedLayer **/ -(nonnull instancetype)initWithFrame:(CGRect)newFrame { - if ( (self = [super initWithFrame:newFrame]) ) { + if ((self = [super initWithFrame:newFrame])) { borderLineStyle = nil; fill = nil; inLayout = NO; @@ -84,7 +84,7 @@ -(nonnull instancetype)initWithFrame:(CGRect)newFrame -(nonnull instancetype)initWithLayer:(nonnull id)layer { - if ( (self = [super initWithLayer:layer]) ) { + if ((self = [super initWithLayer:layer])) { CPTBorderedLayer *theLayer = (CPTBorderedLayer *)layer; borderLineStyle = theLayer->borderLineStyle; @@ -114,7 +114,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super initWithCoder:coder]) ) { + if ((self = [super initWithCoder:coder])) { borderLineStyle = [[coder decodeObjectOfClass:[CPTLineStyle class] forKey:@"CPTBorderedLayer.borderLineStyle"] copy]; fill = [[coder decodeObjectOfClass:[CPTFill class] @@ -183,7 +183,7 @@ -(void)renderBorderedLayerAsVectorInContext:(nonnull CGContextRef)context CGFloat radius = self.cornerRadius; - if ( radius > CPTFloat(0.0) ) { + if ( radius > CPTFloat(0.0)) { CGContextBeginPath(context); CPTAddRoundedRectPath(context, layerBounds, radius); [theLineStyle strokePathInContext:context]; @@ -212,7 +212,7 @@ -(void)sublayerMarginLeft:(nonnull CGFloat *)left top:(nonnull CGFloat *)top rig CGFloat inset = self.borderLineStyle.lineWidth * CPTFloat(0.5); - if ( inset > CPTFloat(0.0) ) { + if ( inset > CPTFloat(0.0)) { *left += inset; *top += inset; *right += inset; @@ -271,7 +271,7 @@ -(nullable CGPathRef)sublayerMaskingPath CGFloat lineWidth = self.borderLineStyle.lineWidth; CGRect selfBounds = CGRectInset(self.bounds, lineWidth, lineWidth); - path = CPTCreateRoundedRectPath(selfBounds, self.cornerRadius - lineWidth * CPTFloat(0.5) ); + path = CPTCreateRoundedRectPath(selfBounds, self.cornerRadius - lineWidth * CPTFloat(0.5)); self.innerBorderPath = path; CGPathRelease(path); @@ -306,7 +306,7 @@ -(void)removeFromSuperlayer -(void)updateOpacity { - BOOL opaqueLayer = (self.cornerRadius <= CPTFloat(0.0) ); + BOOL opaqueLayer = (self.cornerRadius <= CPTFloat(0.0)); CPTFill *theFill = self.fill; @@ -353,7 +353,7 @@ -(void)setFill:(nullable CPTFill *)newFill fill = [newFill copy]; CPTLayer *border = self.borderLayer; - if ( self.cornerRadius != CPTFloat(0.0) ) { + if ( self.cornerRadius != CPTFloat(0.0)) { border.backgroundColor = NULL; } else { diff --git a/CorePlot/framework/Source/CPTCalendarFormatter.h b/CorePlot/framework/Source/CPTCalendarFormatter.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTCalendarFormatter.m b/CorePlot/framework/Source/CPTCalendarFormatter.m old mode 100755 new mode 100644 index a197159..928263b --- a/CorePlot/framework/Source/CPTCalendarFormatter.m +++ b/CorePlot/framework/Source/CPTCalendarFormatter.m @@ -67,7 +67,7 @@ -(nonnull instancetype)init **/ -(nonnull instancetype)initWithDateFormatter:(nullable NSDateFormatter *)aDateFormatter { - if ( (self = [super init]) ) { + if ((self = [super init])) { dateFormatter = aDateFormatter; referenceDate = nil; referenceCalendar = nil; @@ -99,7 +99,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder */ -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super init]) ) { + if ((self = [super init])) { dateFormatter = [coder decodeObjectForKey:@"CPTCalendarFormatter.dateFormatter"]; referenceDate = [[coder decodeObjectForKey:@"CPTCalendarFormatter.referenceDate"] copy]; referenceCalendar = [[coder decodeObjectForKey:@"CPTCalendarFormatter.referenceCalendar"] copy]; diff --git a/CorePlot/framework/Source/CPTCalendarFormatterTests.h b/CorePlot/framework/Source/CPTCalendarFormatterTests.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTCalendarFormatterTests.m b/CorePlot/framework/Source/CPTCalendarFormatterTests.m old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTColor.h b/CorePlot/framework/Source/CPTColor.h old mode 100755 new mode 100644 index 2f66881..f8a6fd6 --- a/CorePlot/framework/Source/CPTColor.h +++ b/CorePlot/framework/Source/CPTColor.h @@ -5,6 +5,8 @@ #if TARGET_OS_OSX @property (nonatomic, readonly, nonnull) NSColor *nsColor; +#elif TARGET_OS_SIMULATOR || TARGET_OS_IPHONE +@property (nonatomic, readonly, nonnull) UIColor *uiColor; #endif /// @name Factory Methods @@ -31,6 +33,8 @@ #if TARGET_OS_OSX +(nonnull instancetype)colorWithNSColor:(nonnull NSColor *)newNSColor; +#elif TARGET_OS_SIMULATOR || TARGET_OS_IPHONE ++(nonnull instancetype)colorWithUIColor:(nonnull UIColor *)newUIColor; #endif /// @} @@ -43,6 +47,8 @@ #if TARGET_OS_OSX -(nonnull instancetype)initWithNSColor:(nonnull NSColor *)newNSColor NS_DESIGNATED_INITIALIZER; +#elif TARGET_OS_SIMULATOR || TARGET_OS_IPHONE +-(nonnull instancetype)initWithUIColor:(nonnull UIColor *)newUIColor NS_DESIGNATED_INITIALIZER; #endif -(nonnull instancetype)colorWithAlphaComponent:(CGFloat)alpha; diff --git a/CorePlot/framework/Source/CPTColor.m b/CorePlot/framework/Source/CPTColor.m old mode 100755 new mode 100644 index ba9cfdc..a45090e --- a/CorePlot/framework/Source/CPTColor.m +++ b/CorePlot/framework/Source/CPTColor.m @@ -11,6 +11,8 @@ @interface CPTColor() #if TARGET_OS_OSX @property (nonatomic, readonly, nullable) NSColor *nsColorCache; +#elif TARGET_OS_SIMULATOR || TARGET_OS_IPHONE +@property (nonatomic, readonly, nullable) UIColor *uiColorCache; #endif @end @@ -52,6 +54,31 @@ -(NSColor *)nsColor } } +#elif TARGET_OS_SIMULATOR || TARGET_OS_IPHONE + +/** @internal + * @property nullable UIColor *uiColorCache + * @brief The UIColor to wrap around. + **/ +@synthesize uiColorCache; + +/** @property nonnull UIColor *uiColor + * @brief The UIColor to wrap around. + **/ +@dynamic uiColor; + +-(UIColor *)uiColor +{ + UIColor *theUIColor = self.uiColorCache; + + if ( theUIColor ) { + return theUIColor; + } + else { + return [UIColor colorWithCGColor:self.cgColor]; + } +} + #endif /** @property nonnull CGColorRef cgColor @@ -66,6 +93,11 @@ -(CGColorRef)cgColor if ( theNSColor ) { return theNSColor.CGColor; } +#elif TARGET_OS_SIMULATOR || TARGET_OS_IPHONE + UIColor *theUIColor = self.uiColorCache; + if ( theUIColor ) { + return theUIColor.CGColor; + } #endif return cgColor; } @@ -383,6 +415,20 @@ +(nonnull instancetype)colorWithNSColor:(nonnull NSColor *)newNSColor return [[self alloc] initWithNSColor:newNSColor]; } +#elif TARGET_OS_SIMULATOR || TARGET_OS_IPHONE + +/** @brief Creates and returns a new CPTColor instance initialized with the provided UIColor. + * + * UIColor can be a dynamic system color or catalog color. This adds support for dark mode in iOS13. + * + * @param newUIColor The color to wrap. + * @return A new CPTColor instance initialized with the provided UIColor. + **/ ++(nonnull instancetype)colorWithUIColor:(nonnull UIColor *)newUIColor +{ + return [[self alloc] initWithUIColor:newUIColor]; +} + #endif #pragma mark - @@ -395,7 +441,7 @@ +(nonnull instancetype)colorWithNSColor:(nonnull NSColor *)newNSColor **/ -(nonnull instancetype)initWithCGColor:(nonnull CGColorRef)newCGColor { - if ( (self = [super init]) ) { + if ((self = [super init])) { CGColorRetain(newCGColor); cgColor = newCGColor; } @@ -435,12 +481,29 @@ -(nonnull instancetype)initWithComponentRed:(CGFloat)red green:(CGFloat)green bl **/ -(nonnull instancetype)initWithNSColor:(nonnull NSColor *)newNSColor { - if ( (self = [super init]) ) { + if ((self = [super init])) { nsColorCache = newNSColor; } return self; } +#elif TARGET_OS_SIMULATOR || TARGET_OS_IPHONE + +/** @brief Initializes a newly allocated CPTColor object with the provided UIColor. + * + * UIColor can be a dynamic system color or catalog color. This adds support for dark mode in iOS13. + * + * @param newUIColor The color to wrap. + * @return The initialized CPTColor object. + **/ +-(nonnull instancetype)initWithUIColor:(nonnull UIColor *)newUIColor +{ + if ((self = [super init])) { + uiColorCache = newUIColor; + } + return self; +} + #endif /// @cond @@ -473,6 +536,12 @@ -(nonnull instancetype)colorWithAlphaComponent:(CGFloat)alpha NSColor *newNSColor = [theNSColor colorWithAlphaComponent:alpha]; return [[self class] colorWithNSColor:newNSColor]; } +#elif TARGET_OS_SIMULATOR || TARGET_OS_IPHONE + UIColor *theUIColor = self.uiColorCache; + if ( theUIColor ) { + UIColor *newUIColor = [theUIColor colorWithAlphaComponent:alpha]; + return [[self class] colorWithUIColor:newUIColor]; + } #endif CGColorRef newCGColor = CGColorCreateCopyWithAlpha(self.cgColor, alpha); CPTColor *newColor = [[self class] colorWithCGColor:newCGColor]; @@ -502,6 +571,8 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder { #if TARGET_OS_OSX [coder encodeConditionalObject:self.nsColorCache forKey:@"CPTColor.nsColorCache"]; +#elif TARGET_OS_SIMULATOR || TARGET_OS_IPHONE + [coder encodeConditionalObject:self.uiColorCache forKey:@"CPTColor.uiColorCache"]; #endif CGColorRef theColor = self.cgColor; @@ -527,19 +598,25 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder */ -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super init]) ) { + if ((self = [super init])) { #if TARGET_OS_OSX NSColor *decodedNSColor = [coder decodeObjectOfClass:[NSColor class] forKey:@"CPTColor.nsColorCache"]; if ( decodedNSColor ) { nsColorCache = decodedNSColor; } +#elif TARGET_OS_SIMULATOR || TARGET_OS_IPHONE + UIColor *decodedUIColor = [coder decodeObjectOfClass:[UIColor class] + forKey:@"CPTColor.uiColorCache"]; + if ( decodedUIColor ) { + uiColorCache = decodedUIColor; + } #endif CGColorSpaceRef colorSpace = [coder newCGColorSpaceDecodeForKey:@"CPTColor.colorSpace"]; size_t numberOfComponents = (size_t)[coder decodeInt64ForKey:@"CPTColor.numberOfComponents"]; - CGFloat *colorComponents = calloc(numberOfComponents, sizeof(CGFloat) ); + CGFloat *colorComponents = calloc(numberOfComponents, sizeof(CGFloat)); for ( size_t i = 0; i < numberOfComponents; i++ ) { NSString *newKey = [[NSString alloc] initWithFormat:@"CPTColor.component[%zu]", i]; @@ -580,6 +657,12 @@ -(nonnull id)copyWithZone:(nullable NSZone *)zone CPTColor *colorCopy = [[[self class] allocWithZone:zone] initWithNSColor:nsColorCopy]; return colorCopy; } +#elif TARGET_OS_SIMULATOR || TARGET_OS_IPHONE + UIColor *uiColorCopy = [self.uiColorCache copyWithZone:zone]; + if ( uiColorCopy ) { + CPTColor *colorCopy = [[[self class] allocWithZone:zone] initWithUIColor:uiColorCopy]; + return colorCopy; + } #endif CGColorRef cgColorCopy = NULL; @@ -615,7 +698,7 @@ -(BOOL)isEqual:(nullable id)object return YES; } else if ( [object isKindOfClass:[self class]] ) { - return CGColorEqualToColor(self.cgColor, ( (CPTColor *)object ).cgColor); + return CGColorEqualToColor(self.cgColor, ((CPTColor *)object).cgColor); } else { return NO; diff --git a/CorePlot/framework/Source/CPTColorSpace.h b/CorePlot/framework/Source/CPTColorSpace.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTColorSpace.m b/CorePlot/framework/Source/CPTColorSpace.m old mode 100755 new mode 100644 index de9e352..6086f09 --- a/CorePlot/framework/Source/CPTColorSpace.m +++ b/CorePlot/framework/Source/CPTColorSpace.m @@ -55,7 +55,7 @@ +(nonnull instancetype)genericRGBSpace **/ -(nonnull instancetype)initWithCGColorSpace:(nonnull CGColorSpaceRef)colorSpace { - if ( (self = [super init]) ) { + if ((self = [super init])) { CGColorSpaceRetain(colorSpace); cgColorSpace = colorSpace; } @@ -106,7 +106,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder */ -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super init]) ) { + if ((self = [super init])) { CGColorSpaceRef colorSpace = [coder newCGColorSpaceDecodeForKey:@"CPTColorSpace.cgColorSpace"]; if ( colorSpace ) { diff --git a/CorePlot/framework/Source/CPTColorSpaceTests.h b/CorePlot/framework/Source/CPTColorSpaceTests.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTColorSpaceTests.m b/CorePlot/framework/Source/CPTColorSpaceTests.m old mode 100755 new mode 100644 index 61a22d2..40fecd1 --- a/CorePlot/framework/Source/CPTColorSpaceTests.m +++ b/CorePlot/framework/Source/CPTColorSpaceTests.m @@ -13,8 +13,18 @@ -(void)testKeyedArchivingRoundTrip CPTColorSpace *newColorSpace = [self archiveRoundTrip:colorSpace]; - CFDataRef iccProfile = CGColorSpaceCopyICCProfile(colorSpace.cgColorSpace); - CFDataRef newIccProfile = CGColorSpaceCopyICCProfile(newColorSpace.cgColorSpace); + CFDataRef iccProfile = NULL; + CFDataRef newIccProfile = NULL; + + // CGColorSpaceCopyICCProfile() is deprecated as of macOS 10.13 + if ( CGColorSpaceCopyICCData ) { + iccProfile = CGColorSpaceCopyICCData(colorSpace.cgColorSpace); + newIccProfile = CGColorSpaceCopyICCData(newColorSpace.cgColorSpace); + } + else { + iccProfile = CGColorSpaceCopyICCProfile(colorSpace.cgColorSpace); + newIccProfile = CGColorSpaceCopyICCProfile(newColorSpace.cgColorSpace); + } if ( iccProfile && newIccProfile ) { XCTAssertTrue([(__bridge NSData *) iccProfile isEqualToData:(__bridge NSData *)newIccProfile], @"Color spaces not equal"); diff --git a/CorePlot/framework/Source/CPTColorTests.h b/CorePlot/framework/Source/CPTColorTests.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTColorTests.m b/CorePlot/framework/Source/CPTColorTests.m old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTConstraints.h b/CorePlot/framework/Source/CPTConstraints.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTConstraints.m b/CorePlot/framework/Source/CPTConstraints.m old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTDarkGradientThemeTests.h b/CorePlot/framework/Source/CPTDarkGradientThemeTests.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTDarkGradientThemeTests.m b/CorePlot/framework/Source/CPTDarkGradientThemeTests.m old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTDataSourceTestCase.h b/CorePlot/framework/Source/CPTDataSourceTestCase.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTDataSourceTestCase.m b/CorePlot/framework/Source/CPTDataSourceTestCase.m old mode 100755 new mode 100644 index 117f957..8c601b1 --- a/CorePlot/framework/Source/CPTDataSourceTestCase.m +++ b/CorePlot/framework/Source/CPTDataSourceTestCase.m @@ -51,7 +51,7 @@ -(void)buildData arr = [NSMutableArray arrayWithCapacity:recordCount]; for ( NSUInteger i = 0; i < recordCount; i++ ) { - [arr insertObject:@(sin(2 * M_PI * (double)i / (double)recordCount) ) atIndex:i]; + [arr insertObject:@(sin(2 * M_PI * (double)i / (double)recordCount)) atIndex:i]; } self.yData = arr; } @@ -81,7 +81,7 @@ -(nonnull CPTPlotRange *)yRange CPTMutablePlotRange *range = [self plotRangeForData:data]; if ( self.plots.count > 1 ) { - range.lengthDecimal = CPTDecimalAdd(range.lengthDecimal, CPTDecimalFromUnsignedInteger(self.plots.count) ); + range.lengthDecimal = CPTDecimalAdd(range.lengthDecimal, CPTDecimalFromUnsignedInteger(self.plots.count)); } return range; @@ -122,7 +122,7 @@ -(nullable CPTNumberArray *)numbersForPlot:(nonnull CPTPlot *)plot XCTAssertTrue([[self plots] containsObject:plot], @"Plot missing"); CPTMutableNumberArray *shiftedResult = [NSMutableArray arrayWithCapacity:result.count]; for ( NSDecimalNumber *d in result ) { - [shiftedResult addObject:[d decimalNumberByAdding:[NSDecimalNumber decimalNumberWithDecimal:CPTDecimalFromCGFloat(CPTDataSourceTestCasePlotOffset * ([self.plots indexOfObject:plot] + 1) )]]]; + [shiftedResult addObject:[d decimalNumberByAdding:[NSDecimalNumber decimalNumberWithDecimal:CPTDecimalFromCGFloat(CPTDataSourceTestCasePlotOffset * ([self.plots indexOfObject:plot] + 1))]]]; } result = shiftedResult; diff --git a/CorePlot/framework/Source/CPTDebugQuickLook.h b/CorePlot/framework/Source/CPTDebugQuickLook.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTDefinitions.h b/CorePlot/framework/Source/CPTDefinitions.h old mode 100755 new mode 100644 index 6668c85..f282f88 --- a/CorePlot/framework/Source/CPTDefinitions.h +++ b/CorePlot/framework/Source/CPTDefinitions.h @@ -40,7 +40,7 @@ * @brief Marks a method declaration as deprecated. **/ -#define cpt_deprecated __attribute__( (deprecated) ) +#define cpt_deprecated __attribute__((deprecated)) // Swift wrappers @@ -49,14 +49,14 @@ * @hideinitializer * @brief Marks a type definition to be imported into Swift as an enumeration. **/ -#define cpt_swift_enum __attribute__( (swift_wrapper(enum) ) ) +#define cpt_swift_enum __attribute__((swift_wrapper(enum))) /** * @def cpt_swift_struct * @hideinitializer * @brief Marks a type definition to be imported into Swift as a structure. **/ -#define cpt_swift_struct __attribute__( (swift_wrapper(struct) ) ) +#define cpt_swift_struct __attribute__((swift_wrapper(struct))) // Type safety defines @@ -66,7 +66,7 @@ * @param x The number to cast. * @brief Casts a number to @ref CGFloat. **/ -#define CPTFloat(x) ( (CGFloat)(x) ) +#define CPTFloat(x) ((CGFloat)(x)) /** * @def CPTPointMake @@ -75,7 +75,7 @@ * @param y The y-coordinate of the point. * @brief A replacement for @ref CGPointMake(), casting each parameter to @ref CGFloat. **/ -#define CPTPointMake(x, y) CGPointMake( (CGFloat)(x), (CGFloat)(y) ) +#define CPTPointMake(x, y) CGPointMake((CGFloat)(x), (CGFloat)(y)) /** * @def CPTSizeMake @@ -84,7 +84,7 @@ * @param h The height of the size. * @brief A replacement for @ref CGSizeMake(), casting each parameter to @ref CGFloat. **/ -#define CPTSizeMake(w, h) CGSizeMake( (CGFloat)(w), (CGFloat)(h) ) +#define CPTSizeMake(w, h) CGSizeMake((CGFloat)(w), (CGFloat)(h)) /** * @def CPTRectMake @@ -95,7 +95,7 @@ * @param h The height of the rectangle. * @brief A replacement for @ref CGRectMake(), casting each parameter to @ref CGFloat. **/ -#define CPTRectMake(x, y, w, h) CGRectMake( (CGFloat)(x), (CGFloat)(y), (CGFloat)(w), (CGFloat)(h) ) +#define CPTRectMake(x, y, w, h) CGRectMake((CGFloat)(x), (CGFloat)(y), (CGFloat)(w), (CGFloat)(h)) /** * @def CPTRectInset @@ -105,14 +105,14 @@ * @param dy The y-offset. * @brief A replacement for @ref CGRectInset(), casting each offset parameter to @ref CGFloat. **/ -#define CPTRectInset(rect, dx, dy) CGRectInset(rect, (CGFloat)(dx), (CGFloat)(dy) ) +#define CPTRectInset(rect, dx, dy) CGRectInset(rect, (CGFloat)(dx), (CGFloat)(dy)) /** * @def CPTNAN * @hideinitializer * @brief The not-a-number constant (@NAN), cast to @ref CGFloat. **/ -#define CPTNAN ( (CGFloat)NAN ) +#define CPTNAN ((CGFloat)NAN) /** * @brief Enumeration of numeric types @@ -168,7 +168,7 @@ CPTRGBAColor; /** * @brief Enumeration of label positioning offset directions **/ -typedef NS_ENUM (NSInteger, CPTSign) { +typedef NS_CLOSED_ENUM (NSInteger, CPTSign) { CPTSignNone = 0, ///< No offset CPTSignPositive = +1, ///< Positive offset CPTSignNegative = -1 ///< Negative offset diff --git a/CorePlot/framework/Source/CPTDefinitions.m b/CorePlot/framework/Source/CPTDefinitions.m old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTDerivedXYGraph.h b/CorePlot/framework/Source/CPTDerivedXYGraph.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTDerivedXYGraph.m b/CorePlot/framework/Source/CPTDerivedXYGraph.m old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTExceptions.h b/CorePlot/framework/Source/CPTExceptions.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTExceptions.m b/CorePlot/framework/Source/CPTExceptions.m old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTFill.h b/CorePlot/framework/Source/CPTFill.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTFill.m b/CorePlot/framework/Source/CPTFill.m old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTFillTests.h b/CorePlot/framework/Source/CPTFillTests.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTFillTests.m b/CorePlot/framework/Source/CPTFillTests.m old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTFunctionDataSource.h b/CorePlot/framework/Source/CPTFunctionDataSource.h old mode 100755 new mode 100644 index 8a38b30..251919c --- a/CorePlot/framework/Source/CPTFunctionDataSource.h +++ b/CorePlot/framework/Source/CPTFunctionDataSource.h @@ -25,17 +25,17 @@ typedef double (^CPTDataSourceBlock)(double); /// @name Factory Methods /// @{ -+(nonnull instancetype)dataSourceForPlot:(nonnull CPTPlot *)plot withFunction:(nonnull CPTDataSourceFunction) function NS_SWIFT_NAME(init(for:withFunction:) ); ++(nonnull instancetype)dataSourceForPlot:(nonnull CPTPlot *)plot withFunction:(nonnull CPTDataSourceFunction) function NS_SWIFT_NAME(init(for:withFunction:)); -+(nonnull instancetype)dataSourceForPlot:(nonnull CPTPlot *)plot withBlock:(nonnull CPTDataSourceBlock) block NS_SWIFT_NAME(init(for:withBlock:) ); ++(nonnull instancetype)dataSourceForPlot:(nonnull CPTPlot *)plot withBlock:(nonnull CPTDataSourceBlock) block NS_SWIFT_NAME(init(for:withBlock:)); /// @} /// @name Initialization /// @{ --(nonnull instancetype)initForPlot:(nonnull CPTPlot *)plot withFunction:(nonnull CPTDataSourceFunction) function NS_SWIFT_NAME(init(forPlot:withFunction:) ); +-(nonnull instancetype)initForPlot:(nonnull CPTPlot *)plot withFunction:(nonnull CPTDataSourceFunction) function NS_SWIFT_NAME(init(forPlot:withFunction:)); --(nonnull instancetype)initForPlot:(nonnull CPTPlot *)plot withBlock:(nonnull CPTDataSourceBlock) block NS_SWIFT_NAME(init(forPlot:withBlock:) ); +-(nonnull instancetype)initForPlot:(nonnull CPTPlot *)plot withBlock:(nonnull CPTDataSourceBlock) block NS_SWIFT_NAME(init(forPlot:withBlock:)); /// @} diff --git a/CorePlot/framework/Source/CPTFunctionDataSource.m b/CorePlot/framework/Source/CPTFunctionDataSource.m old mode 100755 new mode 100644 index 5a682aa..9b6fc73 --- a/CorePlot/framework/Source/CPTFunctionDataSource.m +++ b/CorePlot/framework/Source/CPTFunctionDataSource.m @@ -97,7 +97,7 @@ -(nonnull instancetype)initForPlot:(nonnull CPTPlot *)plot withFunction:(nonnull { NSParameterAssert(function); - if ( (self = [self initForPlot:plot]) ) { + if ((self = [self initForPlot:plot])) { dataSourceFunction = function; plot.dataSource = self; @@ -114,7 +114,7 @@ -(nonnull instancetype)initForPlot:(nonnull CPTPlot *)plot withBlock:(nonnull CP { NSParameterAssert(block); - if ( (self = [self initForPlot:plot]) ) { + if ((self = [self initForPlot:plot])) { dataSourceBlock = block; plot.dataSource = self; @@ -128,7 +128,7 @@ -(nonnull instancetype)initForPlot:(nonnull CPTPlot *)plot { NSParameterAssert([plot isKindOfClass:[CPTScatterPlot class]]); - if ( (self = [super init]) ) { + if ((self = [super init])) { dataPlot = plot; dataSourceFunction = NULL; dataSourceBlock = nil; @@ -176,7 +176,7 @@ -(void)dealloc -(void)setResolution:(CGFloat)newResolution { - NSParameterAssert(newResolution > CPTFloat(0.0) ); + NSParameterAssert(newResolution > CPTFloat(0.0)); if ( newResolution != resolution ) { resolution = newResolution; @@ -221,8 +221,8 @@ -(void)plotBoundsChanged if ( plotSpace ) { CGFloat width = plot.bounds.size.width; - if ( width > CPTFloat(0.0) ) { - NSUInteger count = (NSUInteger)lrint(ceil(width / self.resolution) ) + 1; + if ( width > CPTFloat(0.0)) { + NSUInteger count = (NSUInteger)lrint(ceil(width / self.resolution)) + 1; if ( count > self.cachedCount ) { self.dataCount = count; @@ -261,7 +261,7 @@ -(void)plotSpaceChanged if ( [cachedRange containsRange:plotRange] ) { // no new data needed } - else if ( ![cachedRange intersectsRange:plotRange] || (step == 0.0) ) { + else if ( ![cachedRange intersectsRange:plotRange] || (step == 0.0)) { self.cachedCount = 0; self.cachedPlotRange = plotRange; @@ -271,7 +271,7 @@ -(void)plotSpaceChanged if ( step > 0.0 ) { double minLimit = plotRange.minLimitDouble; if ( ![cachedRange containsDouble:minLimit] ) { - NSUInteger numPoints = (NSUInteger)lrint( (ceil( (cachedRange.minLimitDouble - minLimit) / step ) ) ); + NSUInteger numPoints = (NSUInteger)lrint((ceil((cachedRange.minLimitDouble - minLimit) / step))); NSDecimal offset = CPTDecimalFromDouble(step * numPoints); cachedRange.locationDecimal = CPTDecimalSubtract(cachedRange.locationDecimal, offset); @@ -284,7 +284,7 @@ -(void)plotSpaceChanged double maxLimit = plotRange.maxLimitDouble; if ( ![cachedRange containsDouble:maxLimit] ) { - NSUInteger numPoints = (NSUInteger)lrint(ceil( (maxLimit - cachedRange.maxLimitDouble) / step ) ); + NSUInteger numPoints = (NSUInteger)lrint(ceil((maxLimit - cachedRange.maxLimitDouble) / step)); NSDecimal offset = CPTDecimalFromDouble(step * numPoints); cachedRange.lengthDecimal = CPTDecimalAdd(cachedRange.lengthDecimal, offset); @@ -297,7 +297,7 @@ -(void)plotSpaceChanged else { double maxLimit = plotRange.maxLimitDouble; if ( ![cachedRange containsDouble:maxLimit] ) { - NSUInteger numPoints = (NSUInteger)lrint(ceil( (cachedRange.maxLimitDouble - maxLimit) / step ) ); + NSUInteger numPoints = (NSUInteger)lrint(ceil((cachedRange.maxLimitDouble - maxLimit) / step)); NSDecimal offset = CPTDecimalFromDouble(step * numPoints); cachedRange.locationDecimal = CPTDecimalSubtract(cachedRange.locationDecimal, offset); @@ -310,7 +310,7 @@ -(void)plotSpaceChanged double minLimit = plotRange.minLimitDouble; if ( ![cachedRange containsDouble:minLimit] ) { - NSUInteger numPoints = (NSUInteger)lrint(ceil( (minLimit - cachedRange.minLimitDouble) / step ) ); + NSUInteger numPoints = (NSUInteger)lrint(ceil((minLimit - cachedRange.minLimitDouble) / step)); NSDecimal offset = CPTDecimalFromDouble(step * numPoints); cachedRange.lengthDecimal = CPTDecimalAdd(cachedRange.lengthDecimal, offset); @@ -332,7 +332,7 @@ -(void)plotSpaceChanged -(void)observeValueForKeyPath:(nullable NSString *)keyPath ofObject:(nullable id)object change:(NSDictionary *)change context:(nullable void *)context { - if ( (context == CPTFunctionDataSourceKVOContext) && [keyPath isEqualToString:@"plotSpace"] && [object isEqual:self.dataPlot] ) { + if ((context == CPTFunctionDataSourceKVOContext) && [keyPath isEqualToString:@"plotSpace"] && [object isEqual:self.dataPlot] ) { CPTPlotSpace *oldSpace = change[NSKeyValueChangeOldKey]; CPTPlotSpace *newSpace = change[NSKeyValueChangeNewKey]; @@ -392,11 +392,11 @@ -(nullable CPTNumericData *)dataForPlot:(nonnull CPTPlot *)plot recordIndexRange NSMutableData *data = [[NSMutableData alloc] initWithLength:indexRange.length * 2 * sizeof(double)]; double *xBytes = data.mutableBytes; - double *yBytes = data.mutableBytes + (indexRange.length * sizeof(double) ); + double *yBytes = data.mutableBytes + (indexRange.length * sizeof(double)); double location = xRange.locationDouble; double length = xRange.lengthDouble; - double denom = (double)(count - ( (count > 1) ? 1 : 0 ) ); + double denom = (double)(count - ((count > 1) ? 1 : 0)); NSUInteger lastIndex = NSMaxRange(indexRange); @@ -404,7 +404,7 @@ -(nullable CPTNumericData *)dataForPlot:(nonnull CPTPlot *)plot recordIndexRange if ( function ) { for ( NSUInteger i = indexRange.location; i < lastIndex; i++ ) { - double x = location + ( (double)i / denom ) * length; + double x = location + ((double)i / denom) * length; *xBytes++ = x; *yBytes++ = function(x); @@ -415,7 +415,7 @@ -(nullable CPTNumericData *)dataForPlot:(nonnull CPTPlot *)plot recordIndexRange if ( functionBlock ) { for ( NSUInteger i = indexRange.location; i < lastIndex; i++ ) { - double x = location + ( (double)i / denom ) * length; + double x = location + ((double)i / denom) * length; *xBytes++ = x; *yBytes++ = functionBlock(x); @@ -424,7 +424,7 @@ -(nullable CPTNumericData *)dataForPlot:(nonnull CPTPlot *)plot recordIndexRange } numericData = [CPTNumericData numericDataWithData:data - dataType:CPTDataType(CPTFloatingPointDataType, sizeof(double), CFByteOrderGetCurrent() ) + dataType:CPTDataType(CPTFloatingPointDataType, sizeof(double), CFByteOrderGetCurrent()) shape:@[@(indexRange.length), @2] dataOrder:CPTDataOrderColumnsFirst]; } diff --git a/CorePlot/framework/Source/CPTGradient.h b/CorePlot/framework/Source/CPTGradient.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTGradient.m b/CorePlot/framework/Source/CPTGradient.m old mode 100755 new mode 100644 index 30cec7e..965903a --- a/CorePlot/framework/Source/CPTGradient.m +++ b/CorePlot/framework/Source/CPTGradient.m @@ -117,7 +117,7 @@ @implementation CPTGradient **/ -(nonnull instancetype)init { - if ( (self = [super init]) ) { + if ((self = [super init])) { [self commonInit]; self.blendingMode = CPTLinearBlendingMode; @@ -207,7 +207,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super init]) ) { + if ((self = [super init])) { [self commonInit]; gradientType = (CPTGradientType)[coder decodeIntegerForKey:@"CPTGradient.type"]; @@ -739,7 +739,7 @@ -(CPTGradient *)removeColorStopAtPosition:(CGFloat)position CPTGradient *newGradient = [self copy]; CPTGradientElement removedElement = [newGradient removeElementAtPosition:position]; - if ( isnan(removedElement.position) ) { + if ( isnan(removedElement.position)) { [NSException raise:NSRangeException format:@"-[%@ removeColorStopAtPosition:]: no such colorStop at position (%g)", [self class], (double)position]; } @@ -755,7 +755,7 @@ -(CPTGradient *)removeColorStopAtIndex:(NSUInteger)idx CPTGradient *newGradient = [self copy]; CPTGradientElement removedElement = [newGradient removeElementAtIndex:idx]; - if ( isnan(removedElement.position) ) { + if ( isnan(removedElement.position)) { [NSException raise:NSRangeException format:@"-[%@ removeColorStopAtIndex:]: index (%lu) beyond bounds", [self class], (unsigned long)idx]; } @@ -798,15 +798,15 @@ -(CGColorRef)newColorAtPosition:(CGFloat)position switch ( self.blendingMode ) { case CPTLinearBlendingMode: - CPTLinearEvaluation( (__bridge void *)(self), &position, components ); + CPTLinearEvaluation((__bridge void *)(self), &position, components); break; case CPTChromaticBlendingMode: - CPTChromaticEvaluation( (__bridge void *)(self), &position, components ); + CPTChromaticEvaluation((__bridge void *)(self), &position, components); break; case CPTInverseChromaticBlendingMode: - CPTInverseChromaticEvaluation( (__bridge void *)(self), &position, components ); + CPTInverseChromaticEvaluation((__bridge void *)(self), &position, components); break; } @@ -865,7 +865,7 @@ -(void)fillRect:(CGRect)rect inContext:(nonnull CGContextRef)context **/ -(void)fillPathInContext:(nonnull CGContextRef)context { - if ( !CGContextIsPathEmpty(context) ) { + if ( !CGContextIsPathEmpty(context)) { CGShadingRef myCGShading = NULL; CGContextSaveGState(context); @@ -901,8 +901,8 @@ -(BOOL)isOpaque CPTGradientElement *list = self.elementList; - while ( opaqueGradient && (list != NULL) ) { - opaqueGradient = opaqueGradient && (list->color.alpha >= CPTFloat(1.0) ); + while ( opaqueGradient && (list != NULL)) { + opaqueGradient = opaqueGradient && (list->color.alpha >= CPTFloat(1.0)); list = list->nextElement; } @@ -1002,7 +1002,7 @@ -(NSUInteger)hash return (NSUInteger)theHash; } else { - return self.blendingMode + self.gradientType; + return (NSUInteger)(self.blendingMode + self.gradientType); } } @@ -1033,13 +1033,13 @@ -(nonnull CGShadingRef)newAxialGradientInRect:(CGRect)rect // First Calculate where the beginning and ending points should be CGPoint startPoint, endPoint; - if ( self.angle == CPTFloat(0.0) ) { - startPoint = CPTPointMake(CGRectGetMinX(rect), CGRectGetMinY(rect) ); // right of rect - endPoint = CPTPointMake(CGRectGetMaxX(rect), CGRectGetMinY(rect) ); // left of rect + if ( self.angle == CPTFloat(0.0)) { + startPoint = CPTPointMake(CGRectGetMinX(rect), CGRectGetMinY(rect)); // right of rect + endPoint = CPTPointMake(CGRectGetMaxX(rect), CGRectGetMinY(rect)); // left of rect } - else if ( self.angle == CPTFloat(90.0) ) { - startPoint = CPTPointMake(CGRectGetMinX(rect), CGRectGetMinY(rect) ); // bottom of rect - endPoint = CPTPointMake(CGRectGetMinX(rect), CGRectGetMaxY(rect) ); // top of rect + else if ( self.angle == CPTFloat(90.0)) { + startPoint = CPTPointMake(CGRectGetMinX(rect), CGRectGetMinY(rect)); // bottom of rect + endPoint = CPTPointMake(CGRectGetMinX(rect), CGRectGetMaxY(rect)); // top of rect } else { // ok, we'll do the calculations now CGFloat x, y; @@ -1050,7 +1050,7 @@ -(nonnull CGShadingRef)newAxialGradientInRect:(CGRect)rect CGFloat rAngle = self.angle * CPTFloat(M_PI / 180.0); // convert the angle to radians - if ( fabs(tan(rAngle) ) <= CPTFloat(1.0) ) { // for range [-45,45], [135,225] + if ( fabs(tan(rAngle)) <= CPTFloat(1.0)) { // for range [-45,45], [135,225] x = CGRectGetWidth(rect); y = CGRectGetHeight(rect); @@ -1058,7 +1058,7 @@ -(nonnull CGShadingRef)newAxialGradientInRect:(CGRect)rect cosA = cos(rAngle); tanA = tan(rAngle); - length = x / fabs(cosA) + (y - x * fabs(tanA) ) * fabs(sinA); + length = x / fabs(cosA) + (y - x * fabs(tanA)) * fabs(sinA); deltaX = length * cosA / CPTFloat(2.0); deltaY = length * sinA / CPTFloat(2.0); @@ -1073,7 +1073,7 @@ -(nonnull CGShadingRef)newAxialGradientInRect:(CGRect)rect cosA = cos(rAngle); tanA = tan(rAngle); - length = x / fabs(cosA) + (y - x * fabs(tanA) ) * fabs(sinA); + length = x / fabs(cosA) + (y - x * fabs(tanA)) * fabs(sinA); deltaX = -length * sinA / CPTFloat(2.0); deltaY = length * cosA / CPTFloat(2.0); @@ -1096,15 +1096,15 @@ -(nonnull CGShadingRef)newRadialGradientInRect:(CGRect)rect context:(nonnull CGC CGPoint theStartAnchor = self.startAnchor; - startPoint = CPTPointMake(fma(CGRectGetWidth(rect), theStartAnchor.x, CGRectGetMinX(rect) ), - fma(CGRectGetHeight(rect), theStartAnchor.y, CGRectGetMinY(rect) ) ); + startPoint = CPTPointMake(fma(CGRectGetWidth(rect), theStartAnchor.x, CGRectGetMinX(rect)), + fma(CGRectGetHeight(rect), theStartAnchor.y, CGRectGetMinY(rect))); CGPoint theEndAnchor = self.endAnchor; - endPoint = CPTPointMake(fma(CGRectGetWidth(rect), theEndAnchor.x, CGRectGetMinX(rect) ), - fma(CGRectGetHeight(rect), theEndAnchor.y, CGRectGetMinY(rect) ) ); + endPoint = CPTPointMake(fma(CGRectGetWidth(rect), theEndAnchor.x, CGRectGetMinX(rect)), + fma(CGRectGetHeight(rect), theEndAnchor.y, CGRectGetMinY(rect))); startRadius = CPTFloat(-1.0); - if ( CGRectGetHeight(rect) > CGRectGetWidth(rect) ) { + if ( CGRectGetHeight(rect) > CGRectGetWidth(rect)) { scaleX = CGRectGetWidth(rect) / CGRectGetHeight(rect); startPoint.x /= scaleX; endPoint.x /= scaleX; @@ -1151,10 +1151,10 @@ -(void)setBlendingMode:(CPTGradientBlendingMode)mode static const CGFloat input_value_range[2] = { 0, 1 }; // range for the evaluator input static const CGFloat output_value_ranges[8] = { 0, 1, 0, 1, 0, 1, 0, 1 }; // ranges for the evaluator output (4 returned values) - CGFunctionRef cgFunction = CGFunctionCreate( (__bridge void *)(self), // the two transition colors - 1, input_value_range, // number of inputs (just fraction of progression) - 4, output_value_ranges, // number of outputs (4 - RGBa) - &evaluationCallbackInfo ); // info for using the evaluator function + CGFunctionRef cgFunction = CGFunctionCreate((__bridge void *)(self), // the two transition colors + 1, input_value_range, // number of inputs (just fraction of progression) + 4, output_value_ranges, // number of outputs (4 - RGBa) + &evaluationCallbackInfo); // info for using the evaluator function if ( cgFunction ) { self.gradientFunction = cgFunction; @@ -1165,9 +1165,9 @@ -(void)addElement:(nonnull CPTGradientElement *)newElement { CPTGradientElement *curElement = self.elementList; - if ( (curElement == NULL) || (newElement->position < curElement->position) ) { + if ((curElement == NULL) || (newElement->position < curElement->position)) { CPTGradientElement *tmpNext = curElement; - CPTGradientElement *newElementList = calloc(1, sizeof(CPTGradientElement) ); + CPTGradientElement *newElementList = calloc(1, sizeof(CPTGradientElement)); if ( newElementList ) { *newElementList = *newElement; newElementList->nextElement = tmpNext; @@ -1176,13 +1176,13 @@ -(void)addElement:(nonnull CPTGradientElement *)newElement } else { while ( curElement->nextElement != NULL && - !( (curElement->position <= newElement->position) && - (newElement->position < curElement->nextElement->position) ) ) { + !((curElement->position <= newElement->position) && + (newElement->position < curElement->nextElement->position))) { curElement = curElement->nextElement; } CPTGradientElement *tmpNext = curElement->nextElement; - curElement->nextElement = calloc(1, sizeof(CPTGradientElement) ); + curElement->nextElement = calloc(1, sizeof(CPTGradientElement)); *(curElement->nextElement) = *newElement; curElement->nextElement->nextElement = tmpNext; } @@ -1573,11 +1573,11 @@ void CPTTransformRGB_HSV(CGFloat *__nonnull components) // H,S,B -> R,G,B void CPTTransformHSV_RGB(CGFloat *__nonnull components) // H,S,B -> R,G,B { CGFloat R = CPTFloat(0.0), G = CPTFloat(0.0), B = CPTFloat(0.0); - CGFloat H = fmod(components[0], CPTFloat(360.0) ); // map to [0,360) + CGFloat H = fmod(components[0], CPTFloat(360.0)); // map to [0,360) CGFloat S = components[1]; CGFloat V = components[2]; - int Hi = (int)lrint(floor(H / CPTFloat(60.0) ) ) % 6; + int Hi = (int)lrint(floor(H / CPTFloat(60.0))) % 6; CGFloat f = H / CPTFloat(60.0) - Hi; CGFloat p = V * (CPTFloat(1.0) - S); CGFloat q = V * (CPTFloat(1.0) - f * S); @@ -1631,13 +1631,13 @@ void CPTTransformHSV_RGB(CGFloat *__nonnull components) // H,S,B -> R,G,B void CPTResolveHSV(CGFloat *__nonnull color1, CGFloat *__nonnull color2) // H value may be undefined (i.e. grayscale color) { // we want to fill it with a sensible value - if ( isnan(color1[0]) && isnan(color2[0]) ) { + if ( isnan(color1[0]) && isnan(color2[0])) { color1[0] = color2[0] = 0; } - else if ( isnan(color1[0]) ) { + else if ( isnan(color1[0])) { color1[0] = color2[0]; } - else if ( isnan(color2[0]) ) { + else if ( isnan(color2[0])) { color2[0] = color1[0]; } } diff --git a/CorePlot/framework/Source/CPTGradientTests.h b/CorePlot/framework/Source/CPTGradientTests.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTGradientTests.m b/CorePlot/framework/Source/CPTGradientTests.m old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTGraph.h b/CorePlot/framework/Source/CPTGraph.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTGraph.m b/CorePlot/framework/Source/CPTGraph.m old mode 100755 new mode 100644 index 4259476..0b74000 --- a/CorePlot/framework/Source/CPTGraph.m +++ b/CorePlot/framework/Source/CPTGraph.m @@ -200,7 +200,7 @@ @implementation CPTGraph **/ -(nonnull instancetype)initWithFrame:(CGRect)newFrame { - if ( (self = [super initWithFrame:newFrame]) ) { + if ((self = [super initWithFrame:newFrame])) { hostingView = nil; plots = [[NSMutableArray alloc] init]; @@ -250,7 +250,7 @@ -(nonnull instancetype)initWithFrame:(CGRect)newFrame -(nonnull instancetype)initWithLayer:(nonnull id)layer { - if ( (self = [super initWithLayer:layer]) ) { + if ((self = [super initWithLayer:layer])) { CPTGraph *theLayer = (CPTGraph *)layer; hostingView = theLayer->hostingView; @@ -309,7 +309,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super initWithCoder:coder]) ) { + if ((self = [super initWithCoder:coder])) { hostingView = [coder decodeObjectOfClass:[CPTGraphHostingView class] forKey:@"CPTGraph.hostingView"]; plotAreaFrame = [coder decodeObjectOfClass:[CPTPlotAreaFrame class] @@ -380,9 +380,9 @@ -(void)layoutAndRenderInContext:(nonnull CGContextRef)context [self reloadDataIfNeeded]; [self.axisSet.axes makeObjectsPerformSelector:@selector(relabel)]; -#if TARGET_OS_OSX #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wundeclared-selector" +#if TARGET_OS_OSX // Workaround since @available macro is not there if ( [NSView instancesRespondToSelector:@selector(effectiveAppearance)] ) { NSAppearance *oldAppearance = NSAppearance.currentAppearance; @@ -394,10 +394,28 @@ -(void)layoutAndRenderInContext:(nonnull CGContextRef)context else { [super layoutAndRenderInContext:context]; } -#pragma clang diagnostic pop #else - [super layoutAndRenderInContext:context]; + if ( @available(iOS 13, *)) { + if ( [UITraitCollection instancesRespondToSelector:@selector(performAsCurrentTraitCollection:)] ) { + UITraitCollection *traitCollection = ((UIView *)self.graph.hostingView).traitCollection; + if ( traitCollection ) { + [traitCollection performAsCurrentTraitCollection: ^{ + [super display]; + }]; + } + else { + [super display]; + } + } + else { + [super display]; + } + } + else { + [super display]; + } #endif +#pragma clang diagnostic pop } /// @endcond @@ -800,7 +818,7 @@ -(void)setLegendAnchor:(CPTRectAnchor)newLegendAnchor -(void)setLegendDisplacement:(CGPoint)newLegendDisplacement { - if ( !CGPointEqualToPoint(newLegendDisplacement, legendDisplacement) ) { + if ( !CGPointEqualToPoint(newLegendDisplacement, legendDisplacement)) { legendDisplacement = newLegendDisplacement; self.legendAnnotation.displacement = newLegendDisplacement; } @@ -914,7 +932,7 @@ -(void)setTitle:(nullable NSString *)newTitle if ( title ) { if ( theTitleAnnotation ) { - ( (CPTTextLayer *)theTitleAnnotation.contentLayer ).text = title; + ((CPTTextLayer *)theTitleAnnotation.contentLayer).text = title; } else { CPTPlotAreaFrame *frameLayer = self.plotAreaFrame; @@ -956,7 +974,7 @@ -(void)setAttributedTitle:(nullable NSAttributedString *)newTitle self.title = [attributedTitle.string copy]; if ( theTitleAnnotation ) { - ( (CPTTextLayer *)theTitleAnnotation.contentLayer ).attributedText = attributedTitle; + ((CPTTextLayer *)theTitleAnnotation.contentLayer).attributedText = attributedTitle; } else { CPTPlotAreaFrame *frameLayer = self.plotAreaFrame; @@ -1007,7 +1025,7 @@ -(void)setTitleTextStyle:(nullable CPTTextStyle *)newStyle -(void)setTitleDisplacement:(CGPoint)newDisplace { - if ( !CGPointEqualToPoint(newDisplace, titleDisplacement) ) { + if ( !CGPointEqualToPoint(newDisplace, titleDisplacement)) { titleDisplacement = newDisplace; self.titleAnnotation.displacement = newDisplace; @@ -1147,7 +1165,7 @@ -(BOOL)pointingDeviceUpEvent:(nonnull CPTNativeEvent *)event atPoint:(CGPoint)in // Plot spaces do not block events, because several spaces may need to receive // the same event sequence (e.g., dragging coordinate translation) for ( CPTPlotSpace *space in self.plotSpaces ) { - if ( !handledEvent || (handledEvent && space.isDragging) ) { + if ( !handledEvent || (handledEvent && space.isDragging)) { BOOL handled = [space pointingDeviceUpEvent:event atPoint:interactionPoint]; handledEvent |= handled; } diff --git a/CorePlot/framework/Source/CPTGridLineGroup.h b/CorePlot/framework/Source/CPTGridLineGroup.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTGridLineGroup.m b/CorePlot/framework/Source/CPTGridLineGroup.m old mode 100755 new mode 100644 index 431264f..d68f67f --- a/CorePlot/framework/Source/CPTGridLineGroup.m +++ b/CorePlot/framework/Source/CPTGridLineGroup.m @@ -40,7 +40,7 @@ @implementation CPTGridLineGroup **/ -(nonnull instancetype)initWithFrame:(CGRect)newFrame { - if ( (self = [super initWithFrame:newFrame]) ) { + if ((self = [super initWithFrame:newFrame])) { plotArea = nil; major = NO; @@ -55,7 +55,7 @@ -(nonnull instancetype)initWithFrame:(CGRect)newFrame -(nonnull instancetype)initWithLayer:(nonnull id)layer { - if ( (self = [super initWithLayer:layer]) ) { + if ((self = [super initWithLayer:layer])) { CPTGridLineGroup *theLayer = (CPTGridLineGroup *)layer; plotArea = theLayer->plotArea; @@ -81,7 +81,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super initWithCoder:coder]) ) { + if ((self = [super initWithCoder:coder])) { plotArea = [coder decodeObjectOfClass:[CPTPlotArea class] forKey:@"CPTGridLineGroup.plotArea"]; major = [coder decodeBoolForKey:@"CPTGridLineGroup.major"]; diff --git a/CorePlot/framework/Source/CPTGridLines.h b/CorePlot/framework/Source/CPTGridLines.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTGridLines.m b/CorePlot/framework/Source/CPTGridLines.m old mode 100755 new mode 100644 index c9f39db..6c0992e --- a/CorePlot/framework/Source/CPTGridLines.m +++ b/CorePlot/framework/Source/CPTGridLines.m @@ -35,7 +35,7 @@ @implementation CPTGridLines **/ -(nonnull instancetype)initWithFrame:(CGRect)newFrame { - if ( (self = [super initWithFrame:newFrame]) ) { + if ((self = [super initWithFrame:newFrame])) { axis = nil; major = NO; @@ -50,7 +50,7 @@ -(nonnull instancetype)initWithFrame:(CGRect)newFrame -(nonnull instancetype)initWithLayer:(nonnull id)layer { - if ( (self = [super initWithLayer:layer]) ) { + if ((self = [super initWithLayer:layer])) { CPTGridLines *theLayer = (CPTGridLines *)layer; axis = theLayer->axis; @@ -76,7 +76,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super initWithCoder:coder]) ) { + if ((self = [super initWithCoder:coder])) { axis = [coder decodeObjectOfClass:[CPTAxis class] forKey:@"CPTGridLines.axis"]; major = [coder decodeBoolForKey:@"CPTGridLines.major"]; diff --git a/CorePlot/framework/Source/CPTImage.h b/CorePlot/framework/Source/CPTImage.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTImage.m b/CorePlot/framework/Source/CPTImage.m old mode 100755 new mode 100644 index 1ed0e56..baebbc2 --- a/CorePlot/framework/Source/CPTImage.m +++ b/CorePlot/framework/Source/CPTImage.m @@ -134,9 +134,9 @@ -(nonnull instancetype)initWithContentsOfFile:(nonnull NSString *)path **/ -(nonnull instancetype)initWithCGImage:(nullable CGImageRef)anImage scale:(CGFloat)newScale { - NSParameterAssert(newScale > CPTFloat(0.0) ); + NSParameterAssert(newScale > CPTFloat(0.0)); - if ( (self = [super init]) ) { + if ((self = [super init])) { CGImageRetain(anImage); nativeImage = nil; image = anImage; @@ -215,7 +215,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder */ -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super init]) ) { + if ((self = [super init])) { nativeImage = [[coder decodeObjectOfClass:[CPTNativeImage class] forKey:@"CPTImage.nativeImage"] copy]; image = [coder newCGImageDecodeForKey:@"CPTImage.image"]; @@ -371,35 +371,35 @@ -(BOOL)isEqual:(nullable id)object CGColorSpaceRef otherColorSpace = CGImageGetColorSpace(otherCGImage); if ( equalImages ) { - equalImages = (CGImageGetWidth(selfCGImage) == CGImageGetWidth(otherCGImage) ); + equalImages = (CGImageGetWidth(selfCGImage) == CGImageGetWidth(otherCGImage)); } if ( equalImages ) { - equalImages = (CGImageGetHeight(selfCGImage) == CGImageGetHeight(otherCGImage) ); + equalImages = (CGImageGetHeight(selfCGImage) == CGImageGetHeight(otherCGImage)); } if ( equalImages ) { - equalImages = (CGImageGetBitsPerComponent(selfCGImage) == CGImageGetBitsPerComponent(otherCGImage) ); + equalImages = (CGImageGetBitsPerComponent(selfCGImage) == CGImageGetBitsPerComponent(otherCGImage)); } if ( equalImages ) { - equalImages = (CGImageGetBitsPerPixel(selfCGImage) == CGImageGetBitsPerPixel(otherCGImage) ); + equalImages = (CGImageGetBitsPerPixel(selfCGImage) == CGImageGetBitsPerPixel(otherCGImage)); } if ( equalImages ) { - equalImages = (CGImageGetBytesPerRow(selfCGImage) == CGImageGetBytesPerRow(otherCGImage) ); + equalImages = (CGImageGetBytesPerRow(selfCGImage) == CGImageGetBytesPerRow(otherCGImage)); } if ( equalImages ) { - equalImages = (CGImageGetBitmapInfo(selfCGImage) == CGImageGetBitmapInfo(otherCGImage) ); + equalImages = (CGImageGetBitmapInfo(selfCGImage) == CGImageGetBitmapInfo(otherCGImage)); } if ( equalImages ) { - equalImages = (CGImageGetShouldInterpolate(selfCGImage) == CGImageGetShouldInterpolate(otherCGImage) ); + equalImages = (CGImageGetShouldInterpolate(selfCGImage) == CGImageGetShouldInterpolate(otherCGImage)); } if ( equalImages ) { - equalImages = (CGImageGetRenderingIntent(selfCGImage) == CGImageGetRenderingIntent(otherCGImage) ); + equalImages = (CGImageGetRenderingIntent(selfCGImage) == CGImageGetRenderingIntent(otherCGImage)); } // decode array @@ -423,15 +423,15 @@ -(BOOL)isEqual:(nullable id)object equalImages = NO; } } - else if ( (selfDecodeArray && !otherDecodeArray) || (!selfDecodeArray && otherDecodeArray) ) { + else if ((selfDecodeArray && !otherDecodeArray) || (!selfDecodeArray && otherDecodeArray)) { equalImages = NO; } } // color space if ( equalImages ) { - equalImages = (CGColorSpaceGetModel(selfColorSpace) == CGColorSpaceGetModel(otherColorSpace) ) && - (CGColorSpaceGetNumberOfComponents(selfColorSpace) == CGColorSpaceGetNumberOfComponents(otherColorSpace) ); + equalImages = (CGColorSpaceGetModel(selfColorSpace) == CGColorSpaceGetModel(otherColorSpace)) && + (CGColorSpaceGetNumberOfComponents(selfColorSpace) == CGColorSpaceGetNumberOfComponents(otherColorSpace)); } // data provider @@ -472,13 +472,13 @@ -(NSUInteger)hash // Equal objects must hash the same. CGImageRef selfCGImage = self.image; - return (CGImageGetWidth(selfCGImage) * CGImageGetHeight(selfCGImage) ) + + return (CGImageGetWidth(selfCGImage) * CGImageGetHeight(selfCGImage)) + CGImageGetBitsPerComponent(selfCGImage) + CGImageGetBitsPerPixel(selfCGImage) + CGImageGetBytesPerRow(selfCGImage) + CGImageGetBitmapInfo(selfCGImage) + CGImageGetShouldInterpolate(selfCGImage) + - CGImageGetRenderingIntent(selfCGImage) * (NSUInteger)self.scale; + (NSUInteger)(CGImageGetRenderingIntent(selfCGImage) * self.scale); } /// @endcond @@ -526,7 +526,7 @@ -(nullable CPTNativeImage *)nativeImage #if TARGET_OS_SIMULATOR || TARGET_OS_IPHONE CGFloat theScale = self.scale; - if ( imageRef && (theScale > CPTFloat(0.0) ) ) { + if ( imageRef && (theScale > CPTFloat(0.0))) { nativeImage = [UIImage imageWithCGImage:imageRef scale:theScale orientation:UIImageOrientationUp]; @@ -536,7 +536,7 @@ -(nullable CPTNativeImage *)nativeImage nativeImage = [[NSImage alloc] initWithCGImage:imageRef size:NSZeroSize]; } else { - CGSize imageSize = CGSizeMake(CGImageGetWidth(imageRef), CGImageGetHeight(imageRef) ); + CGSize imageSize = CGSizeMake(CGImageGetWidth(imageRef), CGImageGetHeight(imageRef)); NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL pixelsWide:(NSInteger)imageSize.width @@ -565,7 +565,7 @@ -(nullable CPTNativeImage *)nativeImage -(void)setScale:(CGFloat)newScale { - NSParameterAssert(newScale > CPTFloat(0.0) ); + NSParameterAssert(newScale > CPTFloat(0.0)); if ( newScale != scale ) { scale = newScale; @@ -574,7 +574,7 @@ -(void)setScale:(CGFloat)newScale -(void)setEdgeInsets:(CPTEdgeInsets)newEdgeInsets { - if ( !CPTEdgeInsetsEqualToEdgeInsets(edgeInsets, newEdgeInsets) ) { + if ( !CPTEdgeInsetsEqualToEdgeInsets(edgeInsets, newEdgeInsets)) { edgeInsets = newEdgeInsets; CPTImageSlices imageSlices = {}; @@ -631,55 +631,55 @@ -(void)makeImageSlices } // top row - if ( capTop > CPTFloat(0.0) ) { - if ( capLeft > CPTFloat(0.0) ) { - CGImageRef sliceImage = CGImageCreateWithImageInRect(theImage, CPTRectMake(0.0, 0.0, capLeft, capTop) ); + if ( capTop > CPTFloat(0.0)) { + if ( capLeft > CPTFloat(0.0)) { + CGImageRef sliceImage = CGImageCreateWithImageInRect(theImage, CPTRectMake(0.0, 0.0, capLeft, capTop)); imageSlices.slice[CPTSliceTopLeft] = sliceImage; } - if ( centerSize.width > CPTFloat(0.0) ) { - CGImageRef sliceImage = CGImageCreateWithImageInRect(theImage, CPTRectMake(capLeft, 0.0, centerSize.width, capTop) ); + if ( centerSize.width > CPTFloat(0.0)) { + CGImageRef sliceImage = CGImageCreateWithImageInRect(theImage, CPTRectMake(capLeft, 0.0, centerSize.width, capTop)); imageSlices.slice[CPTSliceTop] = sliceImage; } - if ( capRight > CPTFloat(0.0) ) { - CGImageRef sliceImage = CGImageCreateWithImageInRect(theImage, CPTRectMake(width - capRight, 0.0, capRight, capTop) ); + if ( capRight > CPTFloat(0.0)) { + CGImageRef sliceImage = CGImageCreateWithImageInRect(theImage, CPTRectMake(width - capRight, 0.0, capRight, capTop)); imageSlices.slice[CPTSliceTopRight] = sliceImage; } } // middle row - if ( centerSize.height > CPTFloat(0.0) ) { - if ( capLeft > CPTFloat(0.0) ) { - CGImageRef sliceImage = CGImageCreateWithImageInRect(theImage, CPTRectMake(0.0, capTop, capLeft, centerSize.height) ); + if ( centerSize.height > CPTFloat(0.0)) { + if ( capLeft > CPTFloat(0.0)) { + CGImageRef sliceImage = CGImageCreateWithImageInRect(theImage, CPTRectMake(0.0, capTop, capLeft, centerSize.height)); imageSlices.slice[CPTSliceLeft] = sliceImage; } - if ( centerSize.width > CPTFloat(0.0) ) { - CGImageRef sliceImage = CGImageCreateWithImageInRect(theImage, CPTRectMake(capLeft, capTop, centerSize.width, centerSize.height) ); + if ( centerSize.width > CPTFloat(0.0)) { + CGImageRef sliceImage = CGImageCreateWithImageInRect(theImage, CPTRectMake(capLeft, capTop, centerSize.width, centerSize.height)); imageSlices.slice[CPTSliceMiddle] = sliceImage; } - if ( capRight > CPTFloat(0.0) ) { - CGImageRef sliceImage = CGImageCreateWithImageInRect(theImage, CPTRectMake(width - capRight, capTop, capRight, centerSize.height) ); + if ( capRight > CPTFloat(0.0)) { + CGImageRef sliceImage = CGImageCreateWithImageInRect(theImage, CPTRectMake(width - capRight, capTop, capRight, centerSize.height)); imageSlices.slice[CPTSliceRight] = sliceImage; } } // bottom row - if ( capBottom > CPTFloat(0.0) ) { - if ( capLeft > CPTFloat(0.0) ) { - CGImageRef sliceImage = CGImageCreateWithImageInRect(theImage, CPTRectMake(0.0, height - capBottom, capLeft, capBottom) ); + if ( capBottom > CPTFloat(0.0)) { + if ( capLeft > CPTFloat(0.0)) { + CGImageRef sliceImage = CGImageCreateWithImageInRect(theImage, CPTRectMake(0.0, height - capBottom, capLeft, capBottom)); imageSlices.slice[CPTSliceBottomLeft] = sliceImage; } - if ( centerSize.width > CPTFloat(0.0) ) { - CGImageRef sliceImage = CGImageCreateWithImageInRect(theImage, CPTRectMake(capLeft, height - capBottom, centerSize.width, capBottom) ); + if ( centerSize.width > CPTFloat(0.0)) { + CGImageRef sliceImage = CGImageCreateWithImageInRect(theImage, CPTRectMake(capLeft, height - capBottom, centerSize.width, capBottom)); imageSlices.slice[CPTSliceBottom] = sliceImage; } - if ( capRight > CPTFloat(0.0) ) { - CGImageRef sliceImage = CGImageCreateWithImageInRect(theImage, CPTRectMake(width - capRight, height - capBottom, capRight, capBottom) ); + if ( capRight > CPTFloat(0.0)) { + CGImageRef sliceImage = CGImageCreateWithImageInRect(theImage, CPTRectMake(width - capRight, height - capBottom, capRight, capBottom)); imageSlices.slice[CPTSliceBottomRight] = sliceImage; } } @@ -692,7 +692,7 @@ -(void)makeImageSlices -(void)drawImage:(nonnull CGImageRef)theImage inContext:(nonnull CGContextRef)context rect:(CGRect)rect scaleRatio:(CGFloat)scaleRatio { - if ( theImage && (rect.size.width > CPTFloat(0.0) ) && (rect.size.height > CPTFloat(0.0) ) ) { + if ( theImage && (rect.size.width > CPTFloat(0.0)) && (rect.size.height > CPTFloat(0.0))) { CGFloat imageScale = self.scale; CGContextSaveGState(context); @@ -735,13 +735,13 @@ -(void)drawInRect:(CGRect)rect inContext:(nonnull CGContextRef)context CGFloat lastScale = self.lastDrawnScale; CGFloat contextScale = CPTFloat(1.0); - if ( rect.size.height != CPTFloat(0.0) ) { + if ( rect.size.height != CPTFloat(0.0)) { CGRect deviceRect = CGContextConvertRectToDeviceSpace(context, rect); contextScale = deviceRect.size.height / rect.size.height; } // generate a Core Graphics image if needed - if ( !theImage || (contextScale != lastScale) ) { + if ( !theImage || (contextScale != lastScale)) { CPTNativeImage *theNativeImage = self.nativeImage; if ( theNativeImage ) { @@ -771,7 +771,7 @@ -(void)drawInRect:(CGRect)rect inContext:(nonnull CGContextRef)context CPTEdgeInsets insets = self.edgeInsets; - if ( CPTEdgeInsetsEqualToEdgeInsets(insets, CPTEdgeInsetsZero) ) { + if ( CPTEdgeInsetsEqualToEdgeInsets(insets, CPTEdgeInsetsZero)) { [self drawImage:theImage inContext:context rect:rect scaleRatio:scaleRatio]; } else { @@ -786,7 +786,7 @@ -(void)drawInRect:(CGRect)rect inContext:(nonnull CGContextRef)context } // create new slices if needed - if ( !hasSlices || (contextScale != lastScale) ) { + if ( !hasSlices || (contextScale != lastScale)) { [self makeImageSlices]; imageSlices = self.slices; } diff --git a/CorePlot/framework/Source/CPTImageTests.h b/CorePlot/framework/Source/CPTImageTests.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTImageTests.m b/CorePlot/framework/Source/CPTImageTests.m old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTLayer.h b/CorePlot/framework/Source/CPTLayer.h old mode 100755 new mode 100644 index e3ccd5f..18cf5b9 --- a/CorePlot/framework/Source/CPTLayer.h +++ b/CorePlot/framework/Source/CPTLayer.h @@ -68,8 +68,8 @@ typedef NSMutableSet CPTMutableSublayerSet; /** * @brief Layer delegate. **/ -#if ( ( TARGET_OS_SIMULATOR || TARGET_OS_IPHONE || TARGET_OS_TV) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= 100000) ) \ - || (TARGET_OS_MAC && (MAC_OS_X_VERSION_MAX_ALLOWED >= 101200) ) +#if ((TARGET_OS_SIMULATOR || TARGET_OS_IPHONE || TARGET_OS_TV) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= 100000)) \ + || (TARGET_OS_MAC && (MAC_OS_X_VERSION_MAX_ALLOWED >= 101200)) // CALayerDelegate is defined by Core Animation in iOS 10.0+, macOS 10.12+, and tvOS 10.0+ @protocol CPTLayerDelegate #else diff --git a/CorePlot/framework/Source/CPTLayer.m b/CorePlot/framework/Source/CPTLayer.m old mode 100755 new mode 100644 index ad78b05..2973226 --- a/CorePlot/framework/Source/CPTLayer.m +++ b/CorePlot/framework/Source/CPTLayer.m @@ -166,7 +166,7 @@ @implementation CPTLayer **/ -(nonnull instancetype)initWithFrame:(CGRect)newFrame { - if ( (self = [super init]) ) { + if ((self = [super init])) { paddingLeft = CPTFloat(0.0); paddingTop = CPTFloat(0.0); paddingRight = CPTFloat(0.0); @@ -207,7 +207,7 @@ -(nonnull instancetype)init */ -(nonnull instancetype)initWithLayer:(nonnull id)layer { - if ( (self = [super initWithLayer:layer]) ) { + if ((self = [super initWithLayer:layer])) { CPTLayer *theLayer = (CPTLayer *)layer; paddingLeft = theLayer->paddingLeft; @@ -268,7 +268,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder */ -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super initWithCoder:coder]) ) { + if ((self = [super initWithCoder:coder])) { paddingLeft = [coder decodeCGFloatForKey:@"CPTLayer.paddingLeft"]; paddingTop = [coder decodeCGFloatForKey:@"CPTLayer.paddingTop"]; paddingRight = [coder decodeCGFloatForKey:@"CPTLayer.paddingRight"]; @@ -323,24 +323,42 @@ -(void)display return; } else { -#if TARGET_OS_OSX #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wundeclared-selector" +#if TARGET_OS_OSX // Workaround since @available macro is not there if ( [NSView instancesRespondToSelector:@selector(effectiveAppearance)] ) { NSAppearance *oldAppearance = NSAppearance.currentAppearance; - NSAppearance.currentAppearance = ( (NSView *)self.graph.hostingView ).effectiveAppearance; + NSAppearance.currentAppearance = ((NSView *)self.graph.hostingView).effectiveAppearance; [super display]; NSAppearance.currentAppearance = oldAppearance; } else { [super display]; } -#pragma clang diagnostic pop #else - [super display]; + if ( @available(iOS 13, *)) { + if ( [UITraitCollection instancesRespondToSelector:@selector(performAsCurrentTraitCollection:)] ) { + UITraitCollection *traitCollection = ((UIView *)self.graph.hostingView).traitCollection; + if ( traitCollection ) { + [traitCollection performAsCurrentTraitCollection: ^{ + [super display]; + }]; + } + else { + [super display]; + } + } + else { + [super display]; + } + } + else { + [super display]; + } #endif +#pragma clang diagnostic pop } } @@ -429,15 +447,15 @@ -(void)recursivelyRenderInContext:(nonnull CGContextRef)context -(void)applyTransform:(CATransform3D)transform3D toContext:(nonnull CGContextRef)context { - if ( !CATransform3DIsIdentity(transform3D) ) { - if ( CATransform3DIsAffine(transform3D) ) { + if ( !CATransform3DIsIdentity(transform3D)) { + if ( CATransform3DIsAffine(transform3D)) { CGRect selfBounds = self.bounds; CGPoint anchorPoint = self.anchorPoint; CGPoint anchorOffset = CPTPointMake(anchorOffset.x = selfBounds.origin.x + anchorPoint.x * selfBounds.size.width, anchorOffset.y = selfBounds.origin.y + anchorPoint.y * selfBounds.size.height); CGAffineTransform affineTransform = CGAffineTransformMakeTranslation(-anchorOffset.x, -anchorOffset.y); - affineTransform = CGAffineTransformConcat(affineTransform, CATransform3DGetAffineTransform(transform3D) ); + affineTransform = CGAffineTransformConcat(affineTransform, CATransform3DGetAffineTransform(transform3D)); affineTransform = CGAffineTransformTranslate(affineTransform, anchorOffset.x, anchorOffset.y); CGRect transformedBounds = CGRectApplyAffineTransform(selfBounds, affineTransform); @@ -465,7 +483,7 @@ -(void)layoutAndRenderInContext:(nonnull CGContextRef)context -(nonnull NSData *)dataForPDFRepresentationOfLayer { NSMutableData *pdfData = [[NSMutableData alloc] init]; - CGDataConsumerRef dataConsumer = CGDataConsumerCreateWithCFData( (__bridge CFMutableDataRef)pdfData ); + CGDataConsumerRef dataConsumer = CGDataConsumerCreateWithCFData((__bridge CFMutableDataRef)pdfData); const CGRect mediaBox = CPTRectMake(0.0, 0.0, self.bounds.size.width, self.bounds.size.height); CGContextRef pdfContext = CGPDFContextCreate(dataConsumer, &mediaBox, NULL); @@ -538,38 +556,38 @@ -(void)pixelAlign CGPoint newPosition; - if ( CGSizeEqualToSize(boundsSize, frameSize) ) { // rotated 0° or 180° + if ( CGSizeEqualToSize(boundsSize, frameSize)) { // rotated 0° or 180° CGPoint anchor = self.anchorPoint; CGPoint newAnchor = CGPointMake(boundsSize.width * anchor.x, boundsSize.height * anchor.y); - if ( scale == CPTFloat(1.0) ) { - newPosition.x = ceil(currentPosition.x - newAnchor.x - CPTFloat(0.5) ) + newAnchor.x; - newPosition.y = ceil(currentPosition.y - newAnchor.y - CPTFloat(0.5) ) + newAnchor.y; + if ( scale == CPTFloat(1.0)) { + newPosition.x = ceil(currentPosition.x - newAnchor.x - CPTFloat(0.5)) + newAnchor.x; + newPosition.y = ceil(currentPosition.y - newAnchor.y - CPTFloat(0.5)) + newAnchor.y; } else { - newPosition.x = ceil( (currentPosition.x - newAnchor.x) * scale - CPTFloat(0.5) ) / scale + newAnchor.x; - newPosition.y = ceil( (currentPosition.y - newAnchor.y) * scale - CPTFloat(0.5) ) / scale + newAnchor.y; + newPosition.x = ceil((currentPosition.x - newAnchor.x) * scale - CPTFloat(0.5)) / scale + newAnchor.x; + newPosition.y = ceil((currentPosition.y - newAnchor.y) * scale - CPTFloat(0.5)) / scale + newAnchor.y; } } - else if ( (boundsSize.width == frameSize.height) && (boundsSize.height == frameSize.width) ) { // rotated 90° or 270° + else if ((boundsSize.width == frameSize.height) && (boundsSize.height == frameSize.width)) { // rotated 90° or 270° CGPoint anchor = self.anchorPoint; CGPoint newAnchor = CGPointMake(boundsSize.height * anchor.y, boundsSize.width * anchor.x); - if ( scale == CPTFloat(1.0) ) { - newPosition.x = ceil(currentPosition.x - newAnchor.x - CPTFloat(0.5) ) + newAnchor.x; - newPosition.y = ceil(currentPosition.y - newAnchor.y - CPTFloat(0.5) ) + newAnchor.y; + if ( scale == CPTFloat(1.0)) { + newPosition.x = ceil(currentPosition.x - newAnchor.x - CPTFloat(0.5)) + newAnchor.x; + newPosition.y = ceil(currentPosition.y - newAnchor.y - CPTFloat(0.5)) + newAnchor.y; } else { - newPosition.x = ceil( (currentPosition.x - newAnchor.x) * scale - CPTFloat(0.5) ) / scale + newAnchor.x; - newPosition.y = ceil( (currentPosition.y - newAnchor.y) * scale - CPTFloat(0.5) ) / scale + newAnchor.y; + newPosition.x = ceil((currentPosition.x - newAnchor.x) * scale - CPTFloat(0.5)) / scale + newAnchor.x; + newPosition.y = ceil((currentPosition.y - newAnchor.y) * scale - CPTFloat(0.5)) / scale + newAnchor.y; } } else { - if ( scale == CPTFloat(1.0) ) { + if ( scale == CPTFloat(1.0)) { newPosition.x = round(currentPosition.x); newPosition.y = round(currentPosition.y); } @@ -626,7 +644,7 @@ -(CGSize)shadowMargin CGSize shadowOffset = myShadow.shadowOffset; CGFloat shadowRadius = myShadow.shadowBlurRadius; - margin = CGSizeMake(ceil(ABS(shadowOffset.width) + ABS(shadowRadius) ), ceil(ABS(shadowOffset.height) + ABS(shadowRadius) ) ); + margin = CGSizeMake(ceil(ABS(shadowOffset.width) + ABS(shadowRadius)), ceil(ABS(shadowOffset.height) + ABS(shadowRadius))); } return margin; @@ -656,14 +674,14 @@ -(void)layoutSublayers CGSize subLayerSize = selfBounds.size; subLayerSize.width -= leftPadding + rightPadding; - subLayerSize.width = MAX(subLayerSize.width, CPTFloat(0.0) ); + subLayerSize.width = MAX(subLayerSize.width, CPTFloat(0.0)); subLayerSize.width = round(subLayerSize.width); subLayerSize.height -= topPadding + bottomPadding; - subLayerSize.height = MAX(subLayerSize.height, CPTFloat(0.0) ); + subLayerSize.height = MAX(subLayerSize.height, CPTFloat(0.0)); subLayerSize.height = round(subLayerSize.height); CGRect subLayerFrame; - subLayerFrame.origin = CGPointMake(round(leftPadding), round(bottomPadding) ); + subLayerFrame.origin = CGPointMake(round(leftPadding), round(bottomPadding)); subLayerFrame.size = subLayerSize; CPTSublayerSet *excludedSublayers = self.sublayersExcludedFromAutomaticLayout; @@ -714,7 +732,7 @@ -(void)setSublayers:(nullable CPTSublayerArray *)sublayers CGFloat scale = self.contentsScale; for ( CALayer *layer in sublayers ) { if ( [layer isKindOfClass:layerClass] ) { - ( (CPTLayer *)layer ).contentsScale = scale; + ((CPTLayer *)layer).contentsScale = scale; } } } @@ -724,7 +742,7 @@ -(void)addSublayer:(nonnull CALayer *)layer [super addSublayer:layer]; if ( [layer isKindOfClass:[CPTLayer class]] ) { - ( (CPTLayer *)layer ).contentsScale = self.contentsScale; + ((CPTLayer *)layer).contentsScale = self.contentsScale; } } @@ -733,7 +751,7 @@ -(void)insertSublayer:(nonnull CALayer *)layer atIndex:(unsigned)idx [super insertSublayer:layer atIndex:idx]; if ( [layer isKindOfClass:[CPTLayer class]] ) { - ( (CPTLayer *)layer ).contentsScale = self.contentsScale; + ((CPTLayer *)layer).contentsScale = self.contentsScale; } } @@ -742,7 +760,7 @@ -(void)insertSublayer:(nonnull CALayer *)layer below:(nullable CALayer *)sibling [super insertSublayer:layer below:sibling]; if ( [layer isKindOfClass:[CPTLayer class]] ) { - ( (CPTLayer *)layer ).contentsScale = self.contentsScale; + ((CPTLayer *)layer).contentsScale = self.contentsScale; } } @@ -751,7 +769,7 @@ -(void)insertSublayer:(nonnull CALayer *)layer above:(nullable CALayer *)sibling [super insertSublayer:layer above:sibling]; if ( [layer isKindOfClass:[CPTLayer class]] ) { - ( (CPTLayer *)layer ).contentsScale = self.contentsScale; + ((CPTLayer *)layer).contentsScale = self.contentsScale; } } @@ -760,7 +778,7 @@ -(void)replaceSublayer:(nonnull CALayer *)layer with:(nonnull CALayer *)layer2 [super replaceSublayer:layer with:layer2]; if ( [layer2 isKindOfClass:[CPTLayer class]] ) { - ( (CPTLayer *)layer2 ).contentsScale = self.contentsScale; + ((CPTLayer *)layer2).contentsScale = self.contentsScale; } } @@ -819,7 +837,7 @@ -(void)applySublayerMaskToContext:(nonnull CGContextRef)context forSublayer:(non } CGAffineTransform sublayerTransform = CATransform3DGetAffineTransform(sublayer.transform); - CGContextConcatCTM(context, CGAffineTransformInvert(sublayerTransform) ); + CGContextConcatCTM(context, CGAffineTransformInvert(sublayerTransform)); CALayer *superlayer = self.superlayer; if ( [superlayer isKindOfClass:[CPTLayer class]] ) { @@ -907,7 +925,7 @@ -(void)setHidden:(BOOL)newHidden -(void)setContentsScale:(CGFloat)newContentsScale { - NSParameterAssert(newContentsScale > CPTFloat(0.0) ); + NSParameterAssert(newContentsScale > CPTFloat(0.0)); if ( self.contentsScale != newContentsScale ) { if ( [CALayer instancesRespondToSelector:@selector(setContentsScale:)] ) { @@ -979,7 +997,7 @@ -(CGRect)bounds -(void)setBounds:(CGRect)newBounds { - if ( !CGRectEqualToRect(self.bounds, newBounds) ) { + if ( !CGRectEqualToRect(self.bounds, newBounds)) { if ( self.shadow ) { CGSize sizeOffset = self.shadowMargin; @@ -1007,13 +1025,13 @@ -(CGPoint)anchorPoint CGSize sizeOffset = self.shadowMargin; CGRect selfBounds = self.bounds; CGSize adjustedSize = CGSizeMake(selfBounds.size.width + sizeOffset.width * CPTFloat(2.0), - selfBounds.size.height + sizeOffset.height * CPTFloat(2.0) ); + selfBounds.size.height + sizeOffset.height * CPTFloat(2.0)); - if ( selfBounds.size.width > CPTFloat(0.0) ) { - adjustedAnchor.x = (adjustedAnchor.x - CPTFloat(0.5) ) * (adjustedSize.width / selfBounds.size.width) + CPTFloat(0.5); + if ( selfBounds.size.width > CPTFloat(0.0)) { + adjustedAnchor.x = (adjustedAnchor.x - CPTFloat(0.5)) * (adjustedSize.width / selfBounds.size.width) + CPTFloat(0.5); } - if ( selfBounds.size.height > CPTFloat(0.0) ) { - adjustedAnchor.y = (adjustedAnchor.y - CPTFloat(0.5) ) * (adjustedSize.height / selfBounds.size.height) + CPTFloat(0.5); + if ( selfBounds.size.height > CPTFloat(0.0)) { + adjustedAnchor.y = (adjustedAnchor.y - CPTFloat(0.5)) * (adjustedSize.height / selfBounds.size.height) + CPTFloat(0.5); } } @@ -1026,13 +1044,13 @@ -(void)setAnchorPoint:(CGPoint)newAnchorPoint CGSize sizeOffset = self.shadowMargin; CGRect selfBounds = self.bounds; CGSize adjustedSize = CGSizeMake(selfBounds.size.width + sizeOffset.width * CPTFloat(2.0), - selfBounds.size.height + sizeOffset.height * CPTFloat(2.0) ); + selfBounds.size.height + sizeOffset.height * CPTFloat(2.0)); - if ( adjustedSize.width > CPTFloat(0.0) ) { - newAnchorPoint.x = (newAnchorPoint.x - CPTFloat(0.5) ) * (selfBounds.size.width / adjustedSize.width) + CPTFloat(0.5); + if ( adjustedSize.width > CPTFloat(0.0)) { + newAnchorPoint.x = (newAnchorPoint.x - CPTFloat(0.5)) * (selfBounds.size.width / adjustedSize.width) + CPTFloat(0.5); } - if ( adjustedSize.height > CPTFloat(0.0) ) { - newAnchorPoint.y = (newAnchorPoint.y - CPTFloat(0.5) ) * (selfBounds.size.height / adjustedSize.height) + CPTFloat(0.5); + if ( adjustedSize.height > CPTFloat(0.0)) { + newAnchorPoint.y = (newAnchorPoint.y - CPTFloat(0.5)) * (selfBounds.size.height / adjustedSize.height) + CPTFloat(0.5); } } diff --git a/CorePlot/framework/Source/CPTLayerAnnotation.h b/CorePlot/framework/Source/CPTLayerAnnotation.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTLayerAnnotation.m b/CorePlot/framework/Source/CPTLayerAnnotation.m old mode 100755 new mode 100644 index d24f6dd..69c68d6 --- a/CorePlot/framework/Source/CPTLayerAnnotation.m +++ b/CorePlot/framework/Source/CPTLayerAnnotation.m @@ -61,7 +61,7 @@ -(nonnull instancetype)initWithAnchorLayer:(nonnull CPTLayer *)newAnchorLayer { NSParameterAssert(newAnchorLayer); - if ( (self = [super init]) ) { + if ((self = [super init])) { anchorLayer = newAnchorLayer; rectAnchor = CPTRectAnchorTop; xConstraints = nil; @@ -118,7 +118,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder */ -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super initWithCoder:coder]) ) { + if ((self = [super initWithCoder:coder])) { CPTLayer *anchor = [coder decodeObjectOfClass:[CPTLayer class] forKey:@"CPTLayerAnnotation.anchorLayer"]; xConstraints = [coder decodeObjectOfClass:[CPTConstraints class] @@ -168,7 +168,7 @@ -(void)positionContentLayer content.anchorPoint = self.contentAnchorPoint; content.position = newPosition; - content.transform = CATransform3DMakeRotation(self.rotation, CPTFloat(0.0), CPTFloat(0.0), CPTFloat(1.0) ); + content.transform = CATransform3DMakeRotation(self.rotation, CPTFloat(0.0), CPTFloat(0.0), CPTFloat(1.0)); [content pixelAlign]; } } diff --git a/CorePlot/framework/Source/CPTLayerTests.h b/CorePlot/framework/Source/CPTLayerTests.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTLayerTests.m b/CorePlot/framework/Source/CPTLayerTests.m old mode 100755 new mode 100644 index 879fb87..d94be1d --- a/CorePlot/framework/Source/CPTLayerTests.m +++ b/CorePlot/framework/Source/CPTLayerTests.m @@ -142,14 +142,14 @@ -(void)testPositionsWithScale:(CGFloat)scale anchorPoint:(CGPoint)anchor expecte self.layer.anchorPoint = anchor; for ( NSUInteger i = 0; i < positionCount; i++ ) { - CGFloat position = ( (NSNumber *)( (self.positions)[i] ) ).cgFloatValue; + CGFloat position = ((NSNumber *)((self.positions)[i])).cgFloatValue; CGPoint layerPosition = CGPointMake(position, position); self.layer.position = layerPosition; [self.layer pixelAlign]; CGPoint alignedPoint = self.layer.position; - CGFloat expected = ( (NSNumber *)(expectedValues[i]) ).cgFloatValue; + CGFloat expected = ((NSNumber *)(expectedValues[i])).cgFloatValue; NSString *errMessage; errMessage = [NSString stringWithFormat:@"pixelAlign at x = %g with scale %g and anchor %@", (double)position, (double)scale, CPTStringFromPoint(anchor)]; diff --git a/CorePlot/framework/Source/CPTLegend.h b/CorePlot/framework/Source/CPTLegend.h old mode 100755 new mode 100644 index 06c9bf9..d865a3e --- a/CorePlot/framework/Source/CPTLegend.h +++ b/CorePlot/framework/Source/CPTLegend.h @@ -37,8 +37,10 @@ extern CPTLegendNotification __nonnull const CPTLegendNeedsReloadEntriesForPlotN * @brief Enumeration of legend layout options. **/ typedef NS_ENUM (NSInteger, CPTLegendSwatchLayout) { - CPTLegendSwatchLayoutLeft, ///< Lay out the swatch to the left side of the title. - CPTLegendSwatchLayoutRight ///< Lay out the swatch to the right side of the title. + CPTLegendSwatchLayoutLeft, ///< Lay out the swatch to the left side of the title. + CPTLegendSwatchLayoutRight, ///< Lay out the swatch to the right side of the title. + CPTLegendSwatchLayoutTop, ///< Lay out the swatch above the title. + CPTLegendSwatchLayoutBottom ///< Lay out the swatch below the title. }; #pragma mark - diff --git a/CorePlot/framework/Source/CPTLegend.m b/CorePlot/framework/Source/CPTLegend.m old mode 100755 new mode 100644 index 47567c8..15f06c8 --- a/CorePlot/framework/Source/CPTLegend.m +++ b/CorePlot/framework/Source/CPTLegend.m @@ -208,7 +208,7 @@ @implementation CPTLegend @synthesize titleOffset; /** @property CPTLegendSwatchLayout swatchLayout - * @brief Draw the legend swatch to the left or right side of the title. Default is #CPTLegendSwatchLayoutLeft. + * @brief Where to draw the legend swatch relative to the title. Default is #CPTLegendSwatchLayoutLeft. **/ @synthesize swatchLayout; @@ -301,7 +301,7 @@ +(nonnull instancetype)legendWithGraph:(nullable __kindof CPTGraph *)graph **/ -(nonnull instancetype)initWithFrame:(CGRect)newFrame { - if ( (self = [super initWithFrame:newFrame]) ) { + if ((self = [super initWithFrame:newFrame])) { plots = [[NSMutableArray alloc] init]; legendEntries = [[NSMutableArray alloc] init]; layoutChanged = YES; @@ -350,7 +350,7 @@ -(nonnull instancetype)initWithFrame:(CGRect)newFrame **/ -(nonnull instancetype)initWithPlots:(nullable CPTPlotArray *)newPlots { - if ( (self = [self initWithFrame:CGRectZero]) ) { + if ((self = [self initWithFrame:CGRectZero])) { for ( CPTPlot *plot in newPlots ) { [self addPlot:plot]; } @@ -364,7 +364,7 @@ -(nonnull instancetype)initWithPlots:(nullable CPTPlotArray *)newPlots **/ -(nonnull instancetype)initWithGraph:(nullable __kindof CPTGraph *)graph { - if ( (self = [self initWithFrame:CGRectZero]) ) { + if ((self = [self initWithFrame:CGRectZero])) { for ( CPTPlot *plot in [graph allPlots] ) { [self addPlot:plot]; } @@ -376,7 +376,7 @@ -(nonnull instancetype)initWithGraph:(nullable __kindof CPTGraph *)graph -(nonnull instancetype)initWithLayer:(nonnull id)layer { - if ( (self = [super initWithLayer:layer]) ) { + if ((self = [super initWithLayer:layer])) { CPTLegend *theLayer = (CPTLegend *)layer; plots = theLayer->plots; @@ -462,7 +462,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super initWithCoder:coder]) ) { + if ((self = [super initWithCoder:coder])) { NSArray *plotArray = [coder decodeObjectOfClasses:[NSSet setWithArray:@[[NSArray class], [CPTPlot class]]] forKey:@"CPTLegend.plots"]; if ( plotArray ) { @@ -552,11 +552,25 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context return; } + BOOL isHorizontalLayout; + + switch ( self.swatchLayout ) { + case CPTLegendSwatchLayoutLeft: + case CPTLegendSwatchLayoutRight: + isHorizontalLayout = YES; + break; + + case CPTLegendSwatchLayoutTop: + case CPTLegendSwatchLayoutBottom: + isHorizontalLayout = NO; + break; + } + // calculate column positions CPTNumberArray *computedColumnWidths = self.columnWidthsThatFit; NSUInteger columnCount = computedColumnWidths.count; - CGFloat *actualColumnWidths = calloc(columnCount, sizeof(CGFloat) ); - CGFloat *columnPositions = calloc(columnCount, sizeof(CGFloat) ); + CGFloat *actualColumnWidths = calloc(columnCount, sizeof(CGFloat)); + CGFloat *columnPositions = calloc(columnCount, sizeof(CGFloat)); columnPositions[0] = self.paddingLeft; CGFloat theOffset = self.titleOffset; CGSize theSwatchSize = self.swatchSize; @@ -572,15 +586,15 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context CGFloat width = [colWidth cgFloatValue]; actualColumnWidths[col] = width; if ( col < columnCount - 1 ) { - columnPositions[col + 1] = columnPositions[col] + padLeft + width + padRight + theOffset + theSwatchSize.width + theColumnMargin; + columnPositions[col + 1] = columnPositions[col] + padLeft + width + padRight + (isHorizontalLayout ? theOffset + theSwatchSize.width : CPTFloat(0.0)) + theColumnMargin; } } // calculate row positions CPTNumberArray *computedRowHeights = self.rowHeightsThatFit; NSUInteger rowCount = computedRowHeights.count; - CGFloat *actualRowHeights = calloc(rowCount, sizeof(CGFloat) ); - CGFloat *rowPositions = calloc(rowCount, sizeof(CGFloat) ); + CGFloat *actualRowHeights = calloc(rowCount, sizeof(CGFloat)); + CGFloat *rowPositions = calloc(rowCount, sizeof(CGFloat)); rowPositions[rowCount - 1] = self.paddingBottom; CGFloat theRowMargin = self.rowMargin; CGFloat lastRowHeight = 0.0; @@ -591,7 +605,7 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context CGFloat height = [rowHeight cgFloatValue]; actualRowHeights[row] = height; if ( row < rowCount - 1 ) { - rowPositions[row] = rowPositions[row + 1] + padBottom + lastRowHeight + padTop + theRowMargin; + rowPositions[row] = rowPositions[row + 1] + padBottom + lastRowHeight + padTop + (isHorizontalLayout ? CPTFloat(0.0) : theOffset + theSwatchSize.height) + theRowMargin; } lastRowHeight = height; } @@ -613,17 +627,28 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context NSUInteger row = legendEntry.row; NSUInteger col = legendEntry.column; - if ( ( (desiredRowCount == 0) || (row < desiredRowCount) ) && - ( (desiredColumnCount == 0) || (col < desiredColumnCount) ) ) { + if (((desiredRowCount == 0) || (row < desiredRowCount)) && + ((desiredColumnCount == 0) || (col < desiredColumnCount))) { NSUInteger entryIndex = legendEntry.index; CPTPlot *entryPlot = legendEntry.plot; CGFloat left = columnPositions[col]; CGFloat rowPosition = rowPositions[row]; - CGRect entryRect = CPTRectMake(left, - rowPosition, - padLeft + theSwatchSize.width + theOffset + actualColumnWidths[col] + CPTFloat(1.0) + padRight, - padBottom + actualRowHeights[row] + padTop); + + CGRect entryRect; + + if ( isHorizontalLayout ) { + entryRect = CPTRectMake(left, + rowPosition, + padLeft + theSwatchSize.width + theOffset + actualColumnWidths[col] + CPTFloat(1.0) + padRight, + padBottom + actualRowHeights[row] + padTop); + } + else { + entryRect = CPTRectMake(left, + rowPosition, + padLeft + MAX(theSwatchSize.width, actualColumnWidths[col]) + CPTFloat(1.0) + padRight, + padBottom + theSwatchSize.height + theOffset + actualRowHeights[row] + padTop); + } // draw background CPTFill *theFill = nil; @@ -654,24 +679,46 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context } // lay out swatch and title - CGFloat swatchLeft; - CGFloat titleLeft; + CGFloat swatchLeft, swatchBottom; + CGFloat titleLeft, titleBottom; switch ( self.swatchLayout ) { case CPTLegendSwatchLayoutLeft: - swatchLeft = left + padLeft; - titleLeft = swatchLeft + theSwatchSize.width + theOffset; + swatchLeft = CGRectGetMinX(entryRect) + padLeft; + swatchBottom = CGRectGetMinY(entryRect) + (entryRect.size.height - theSwatchSize.height) * CPTFloat(0.5); + + titleLeft = swatchLeft + theSwatchSize.width + theOffset; + titleBottom = CGRectGetMinY(entryRect) + padBottom; break; case CPTLegendSwatchLayoutRight: - swatchLeft = CGRectGetMaxX(entryRect) - padRight - theSwatchSize.width; - titleLeft = left + padLeft; + swatchLeft = CGRectGetMaxX(entryRect) - padRight - theSwatchSize.width; + swatchBottom = CGRectGetMinY(entryRect) + (entryRect.size.height - theSwatchSize.height) * CPTFloat(0.5); + + titleLeft = CGRectGetMinX(entryRect) + padLeft; + titleBottom = CGRectGetMinY(entryRect) + padBottom; + break; + + case CPTLegendSwatchLayoutTop: + swatchLeft = CGRectGetMidX(entryRect) - theSwatchSize.width * CPTFloat(0.5); + swatchBottom = CGRectGetMaxY(entryRect) - padTop - theSwatchSize.height; + + titleLeft = CGRectGetMidX(entryRect) - actualColumnWidths[col] * CPTFloat(0.5); + titleBottom = CGRectGetMinY(entryRect) + padBottom; + break; + + case CPTLegendSwatchLayoutBottom: + swatchLeft = CGRectGetMidX(entryRect) - theSwatchSize.width * CPTFloat(0.5); + swatchBottom = CGRectGetMinY(entryRect) + padBottom; + + titleLeft = CGRectGetMidX(entryRect) - actualColumnWidths[col] * CPTFloat(0.5); + titleBottom = swatchBottom + theOffset + theSwatchSize.height; break; } // draw swatch CGRect swatchRect = CPTRectMake(swatchLeft, - rowPosition + (entryRect.size.height - theSwatchSize.height) * CPTFloat(0.5), + swatchBottom, theSwatchSize.width, theSwatchSize.height); @@ -691,7 +738,12 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context } // draw title - [legendEntry drawTitleInRect:CPTAlignRectToUserSpace(context, CPTRectMake(titleLeft, rowPosition + padBottom, actualColumnWidths[col] + CPTFloat(1.0), actualRowHeights[row]) ) + CGRect titleRect = CPTRectMake(titleLeft, + titleBottom, + actualColumnWidths[col] + CPTFloat(1.0), + actualRowHeights[row]); + + [legendEntry drawTitleInRect:CPTAlignRectToUserSpace(context, titleRect) inContext:context scale:self.contentsScale]; } @@ -755,6 +807,20 @@ -(void)recalculateLayout return; } + BOOL isHorizontalLayout; + + switch ( self.swatchLayout ) { + case CPTLegendSwatchLayoutLeft: + case CPTLegendSwatchLayoutRight: + isHorizontalLayout = YES; + break; + + case CPTLegendSwatchLayoutTop: + case CPTLegendSwatchLayoutBottom: + isHorizontalLayout = NO; + break; + } + // compute the number of rows and columns needed to hold the legend entries NSUInteger rowCount = self.numberOfRows; NSUInteger columnCount = self.numberOfColumns; @@ -762,8 +828,8 @@ -(void)recalculateLayout NSUInteger desiredColumnCount = columnCount; NSUInteger legendEntryCount = self.legendEntries.count; - if ( (rowCount == 0) && (columnCount == 0) ) { - rowCount = (NSUInteger)lrint(sqrt( (double)legendEntryCount ) ); + if ((rowCount == 0) && (columnCount == 0)) { + rowCount = (NSUInteger)lrint(sqrt((double)legendEntryCount)); columnCount = rowCount; if ( rowCount * columnCount < legendEntryCount ) { columnCount++; @@ -772,13 +838,13 @@ -(void)recalculateLayout rowCount++; } } - else if ( (rowCount == 0) && (columnCount > 0) ) { + else if ((rowCount == 0) && (columnCount > 0)) { rowCount = legendEntryCount / columnCount; if ( legendEntryCount % columnCount ) { rowCount++; } } - else if ( (rowCount > 0) && (columnCount == 0) ) { + else if ((rowCount > 0) && (columnCount == 0)) { columnCount = legendEntryCount / rowCount; if ( legendEntryCount % rowCount ) { columnCount++; @@ -788,8 +854,8 @@ -(void)recalculateLayout // compute row heights and column widths NSUInteger row = 0; NSUInteger col = 0; - CGFloat *maxTitleHeight = calloc(rowCount, sizeof(CGFloat) ); - CGFloat *maxTitleWidth = calloc(columnCount, sizeof(CGFloat) ); + CGFloat *maxTitleHeight = calloc(rowCount, sizeof(CGFloat)); + CGFloat *maxTitleWidth = calloc(columnCount, sizeof(CGFloat)); CGSize theSwatchSize = self.swatchSize; CPTNumberArray *desiredRowHeights = self.rowHeights; CPTNumberArray *desiredColumnWidths = self.columnWidths; @@ -800,8 +866,11 @@ -(void)recalculateLayout legendEntry.column = col; CGSize titleSize = legendEntry.titleSize; - if ( (desiredRowCount == 0) || (row < desiredRowCount) ) { - maxTitleHeight[row] = MAX(MAX(maxTitleHeight[row], titleSize.height), theSwatchSize.height); + if ((desiredRowCount == 0) || (row < desiredRowCount)) { + maxTitleHeight[row] = MAX(maxTitleHeight[row], titleSize.height); + if ( isHorizontalLayout ) { + maxTitleHeight[row] = MAX(maxTitleHeight[row], theSwatchSize.height); + } if ( row < desiredRowHeights.count ) { id desiredRowHeight = desiredRowHeights[row]; @@ -811,8 +880,11 @@ -(void)recalculateLayout } } - if ( (desiredColumnCount == 0) || (col < desiredColumnCount) ) { - maxTitleWidth[col] = MAX(MAX(maxTitleWidth[col], titleSize.width), theSwatchSize.width); + if ((desiredColumnCount == 0) || (col < desiredColumnCount)) { + maxTitleWidth[col] = MAX(maxTitleWidth[col], titleSize.width); + if ( !isHorizontalLayout ) { + maxTitleWidth[col] = MAX(maxTitleWidth[col], theSwatchSize.width); + } if ( col < desiredColumnWidths.count ) { id desiredColumnWidth = desiredColumnWidths[col]; @@ -865,7 +937,10 @@ -(void)recalculateLayout } } if ( columnCount > 0 ) { - legendSize.width += ( (theSwatchSize.width + self.titleOffset + self.entryPaddingLeft + self.entryPaddingRight) * columnCount ) + (self.columnMargin * (columnCount - 1) ); + legendSize.width += ((self.entryPaddingLeft + self.entryPaddingRight) * columnCount) + (self.columnMargin * (columnCount - 1)); + if ( isHorizontalLayout ) { + legendSize.width += (theSwatchSize.width + self.titleOffset) * columnCount; + } } NSUInteger rows = row; @@ -876,10 +951,13 @@ -(void)recalculateLayout legendSize.height += [height cgFloatValue]; } if ( rows > 0 ) { - legendSize.height += ( (self.entryPaddingBottom + self.entryPaddingTop) * rowCount ) + (self.rowMargin * (rows - 1) ); + legendSize.height += ((self.entryPaddingBottom + self.entryPaddingTop) * rowCount) + (self.rowMargin * (rows - 1)); + if ( !isHorizontalLayout ) { + legendSize.height += (theSwatchSize.height + self.titleOffset) * rowCount; + } } - self.bounds = CPTRectMake(0.0, 0.0, ceil(legendSize.width), ceil(legendSize.height) ); + self.bounds = CPTRectMake(0.0, 0.0, ceil(legendSize.width), ceil(legendSize.height)); [self pixelAlign]; self.layoutChanged = NO; @@ -1152,7 +1230,7 @@ -(void)legendEntryForInteractionPoint:(CGPoint)interactionPoint row:(nonnull NSU for ( NSNumber *height in self.rowHeightsThatFit ) { CGFloat rowHeight = height.cgFloatValue + padVertical; - if ( (interactionPoint.y <= position) && (interactionPoint.y >= position - rowHeight) ) { + if ((interactionPoint.y <= position) && (interactionPoint.y >= position - rowHeight)) { *row = i; break; } @@ -1168,7 +1246,7 @@ -(void)legendEntryForInteractionPoint:(CGPoint)interactionPoint row:(nonnull NSU for ( NSNumber *width in self.columnWidthsThatFit ) { CGFloat colWidth = width.cgFloatValue + swatchWidth + padHorizontal; - if ( (interactionPoint.x >= position) && (interactionPoint.x <= position + colWidth) ) { + if ((interactionPoint.x >= position) && (interactionPoint.x <= position + colWidth)) { *col = i; break; } @@ -1202,7 +1280,7 @@ -(void)legendEntryForInteractionPoint:(CGPoint)interactionPoint row:(nonnull NSU **/ -(BOOL)pointingDeviceDownEvent:(nonnull CPTNativeEvent *)event atPoint:(CGPoint)interactionPoint { - if ( self.hidden || (self.plots.count == 0) ) { + if ( self.hidden || (self.plots.count == 0)) { return NO; } @@ -1216,9 +1294,9 @@ -(BOOL)pointingDeviceDownEvent:(nonnull CPTNativeEvent *)event atPoint:(CGPoint) [self legendEntryForInteractionPoint:interactionPoint row:&row col:&col]; // Notify the delegate if we found a hit - if ( (row != NSNotFound) && (col != NSNotFound) ) { + if ((row != NSNotFound) && (col != NSNotFound)) { for ( CPTLegendEntry *legendEntry in self.legendEntries ) { - if ( (legendEntry.row == row) && (legendEntry.column == col) ) { + if ((legendEntry.row == row) && (legendEntry.column == col)) { self.pointingDeviceDownEntry = legendEntry; CPTPlot *legendPlot = legendEntry.plot; @@ -1273,7 +1351,7 @@ -(BOOL)pointingDeviceUpEvent:(nonnull CPTNativeEvent *)event atPoint:(CGPoint)in self.pointingDeviceDownEntry = nil; - if ( self.hidden || (self.plots.count == 0) ) { + if ( self.hidden || (self.plots.count == 0)) { return NO; } @@ -1287,9 +1365,9 @@ -(BOOL)pointingDeviceUpEvent:(nonnull CPTNativeEvent *)event atPoint:(CGPoint)in [self legendEntryForInteractionPoint:interactionPoint row:&row col:&col]; // Notify the delegate if we found a hit - if ( (row != NSNotFound) && (col != NSNotFound) ) { + if ((row != NSNotFound) && (col != NSNotFound)) { for ( CPTLegendEntry *legendEntry in self.legendEntries ) { - if ( (legendEntry.row == row) && (legendEntry.column == col) ) { + if ((legendEntry.row == row) && (legendEntry.column == col)) { BOOL handled = NO; CPTPlot *entryPlot = legendEntry.plot; @@ -1356,7 +1434,7 @@ -(void)setTextStyle:(nullable CPTTextStyle *)newTextStyle -(void)setSwatchSize:(CGSize)newSwatchSize { - if ( !CGSizeEqualToSize(newSwatchSize, swatchSize) ) { + if ( !CGSizeEqualToSize(newSwatchSize, swatchSize)) { swatchSize = newSwatchSize; self.layoutChanged = YES; } @@ -1366,10 +1444,10 @@ -(CGSize)swatchSize { CGSize theSwatchSize = swatchSize; - if ( CGSizeEqualToSize(theSwatchSize, CGSizeZero) ) { + if ( CGSizeEqualToSize(theSwatchSize, CGSizeZero)) { CPTTextStyle *theTextStyle = self.textStyle; CGFloat fontSize = theTextStyle.fontSize; - if ( fontSize > CPTFloat(0.0) ) { + if ( fontSize > CPTFloat(0.0)) { fontSize *= CPTFloat(1.5); fontSize = round(fontSize); theSwatchSize = CPTSizeMake(fontSize, fontSize); diff --git a/CorePlot/framework/Source/CPTLegendEntry.h b/CorePlot/framework/Source/CPTLegendEntry.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTLegendEntry.m b/CorePlot/framework/Source/CPTLegendEntry.m old mode 100755 new mode 100644 index e50c088..02f5bc3 --- a/CorePlot/framework/Source/CPTLegendEntry.m +++ b/CorePlot/framework/Source/CPTLegendEntry.m @@ -86,7 +86,7 @@ @implementation CPTLegendEntry **/ -(nonnull instancetype)init { - if ( (self = [super init]) ) { + if ((self = [super init])) { plot = nil; index = 0; row = 0; @@ -114,7 +114,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super init]) ) { + if ((self = [super init])) { plot = [coder decodeObjectOfClass:[CPTPlot class] forKey:@"CPTLegendEntry.plot"]; index = (NSUInteger)[coder decodeIntegerForKey:@"CPTLegendEntry.index"]; @@ -153,15 +153,15 @@ -(void)drawTitleInRect:(CGRect)rect inContext:(nonnull CGContextRef)context scal #if TARGET_OS_SIMULATOR || TARGET_OS_IPHONE CGContextSaveGState(context); CGContextTranslateCTM(context, CPTFloat(0.0), rect.origin.y); - CGContextScaleCTM(context, CPTFloat(1.0), CPTFloat(-1.0) ); - CGContextTranslateCTM(context, CPTFloat(0.0), -CGRectGetMaxY(rect) ); + CGContextScaleCTM(context, CPTFloat(1.0), CPTFloat(-1.0)); + CGContextTranslateCTM(context, CPTFloat(0.0), -CGRectGetMaxY(rect)); #endif // center the title vertically CGRect textRect = rect; CGSize theTitleSize = self.titleSize; if ( theTitleSize.height < textRect.size.height ) { CGFloat offset = (textRect.size.height - theTitleSize.height) / CPTFloat(2.0); - if ( scale == CPTFloat(1.0) ) { + if ( scale == CPTFloat(1.0)) { offset = round(offset); } else { @@ -173,7 +173,7 @@ -(void)drawTitleInRect:(CGRect)rect inContext:(nonnull CGContextRef)context scal NSAttributedString *styledTitle = self.attributedTitle; - if ( (styledTitle.length > 0) && [styledTitle respondsToSelector:@selector(drawInRect:)] ) { + if ((styledTitle.length > 0) && [styledTitle respondsToSelector:@selector(drawInRect:)] ) { [styledTitle drawInRect:textRect inContext:context]; } diff --git a/CorePlot/framework/Source/CPTLimitBand.h b/CorePlot/framework/Source/CPTLimitBand.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTLimitBand.m b/CorePlot/framework/Source/CPTLimitBand.m old mode 100755 new mode 100644 index 67541c0..2f75847 --- a/CorePlot/framework/Source/CPTLimitBand.m +++ b/CorePlot/framework/Source/CPTLimitBand.m @@ -38,7 +38,7 @@ +(nonnull instancetype)limitBandWithRange:(nullable CPTPlotRange *)newRange fill **/ -(nonnull instancetype)initWithRange:(nullable CPTPlotRange *)newRange fill:(nullable CPTFill *)newFill { - if ( (self = [super init]) ) { + if ((self = [super init])) { range = newRange; fill = newFill; } @@ -91,7 +91,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)encoder */ -(nullable instancetype)initWithCoder:(nonnull NSCoder *)decoder { - if ( (self = [super init]) ) { + if ((self = [super init])) { range = [decoder decodeObjectOfClass:[CPTPlotRange class] forKey:@"CPTLimitBand.range"]; fill = [decoder decodeObjectOfClass:[CPTFill class] diff --git a/CorePlot/framework/Source/CPTLineCap.h b/CorePlot/framework/Source/CPTLineCap.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTLineCap.m b/CorePlot/framework/Source/CPTLineCap.m old mode 100755 new mode 100644 index ac606d7..e86e063 --- a/CorePlot/framework/Source/CPTLineCap.m +++ b/CorePlot/framework/Source/CPTLineCap.m @@ -80,7 +80,7 @@ @implementation CPTLineCap **/ -(nonnull instancetype)init { - if ( (self = [super init]) ) { + if ((self = [super init])) { size = CPTSizeMake(5.0, 5.0); lineCapType = CPTLineCapTypeNone; lineStyle = [[CPTLineStyle alloc] init]; @@ -124,7 +124,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super init]) ) { + if ((self = [super init])) { size = [coder decodeCPTSizeForKey:@"CPTLineCap.size"]; lineCapType = (CPTLineCapType)[coder decodeIntegerForKey:@"CPTLineCap.lineCapType"]; lineStyle = [coder decodeObjectOfClass:[CPTLineStyle class] @@ -160,7 +160,7 @@ +(BOOL)supportsSecureCoding -(void)setSize:(CGSize)newSize { - if ( !CGSizeEqualToSize(newSize, size) ) { + if ( !CGSizeEqualToSize(newSize, size)) { size = newSize; self.cachedLineCapPath = NULL; } @@ -431,16 +431,16 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context atPoint:(CGPoint)ce if ( theLineStyle || theFill ) { CGContextSaveGState(context); CGContextTranslateCTM(context, center.x, center.y); - CGContextRotateCTM(context, atan2(direction.y, direction.x) - CPTFloat(M_PI_2) ); // standard symbol points up + CGContextRotateCTM(context, atan2(direction.y, direction.x) - CPTFloat(M_PI_2)); // standard symbol points up if ( theFill ) { // use fillRect instead of fillPath so that images and gradients are properly centered in the symbol CGSize symbolSize = self.size; - CGSize halfSize = CPTSizeMake(symbolSize.width / CPTFloat(2.0), symbolSize.height / CPTFloat(2.0) ); + CGSize halfSize = CPTSizeMake(symbolSize.width / CPTFloat(2.0), symbolSize.height / CPTFloat(2.0)); CGRect bounds = CPTRectMake(-halfSize.width, -halfSize.height, symbolSize.width, symbolSize.height); CGContextSaveGState(context); - if ( !CGPathIsEmpty(theLineCapPath) ) { + if ( !CGPathIsEmpty(theLineCapPath)) { CGContextBeginPath(context); CGContextAddPath(context, theLineCapPath); if ( self.usesEvenOddClipRule ) { @@ -480,7 +480,7 @@ -(nonnull CGPathRef)newLineCapPath { CGFloat dx, dy; CGSize lineCapSize = self.size; - CGSize halfSize = CPTSizeMake(lineCapSize.width / CPTFloat(2.0), lineCapSize.height / CPTFloat(2.0) ); + CGSize halfSize = CPTSizeMake(lineCapSize.width / CPTFloat(2.0), lineCapSize.height / CPTFloat(2.0)); CGMutablePathRef lineCapPath = CGPathCreateMutable(); @@ -491,47 +491,47 @@ -(nonnull CGPathRef)newLineCapPath case CPTLineCapTypeOpenArrow: CGPathMoveToPoint(lineCapPath, NULL, -halfSize.width, -halfSize.height); - CGPathAddLineToPoint(lineCapPath, NULL, CPTFloat(0.0), CPTFloat(0.0) ); + CGPathAddLineToPoint(lineCapPath, NULL, CPTFloat(0.0), CPTFloat(0.0)); CGPathAddLineToPoint(lineCapPath, NULL, halfSize.width, -halfSize.height); break; case CPTLineCapTypeSolidArrow: CGPathMoveToPoint(lineCapPath, NULL, -halfSize.width, -halfSize.height); - CGPathAddLineToPoint(lineCapPath, NULL, CPTFloat(0.0), CPTFloat(0.0) ); + CGPathAddLineToPoint(lineCapPath, NULL, CPTFloat(0.0), CPTFloat(0.0)); CGPathAddLineToPoint(lineCapPath, NULL, halfSize.width, -halfSize.height); CGPathCloseSubpath(lineCapPath); break; case CPTLineCapTypeSweptArrow: CGPathMoveToPoint(lineCapPath, NULL, -halfSize.width, -halfSize.height); - CGPathAddLineToPoint(lineCapPath, NULL, CPTFloat(0.0), CPTFloat(0.0) ); + CGPathAddLineToPoint(lineCapPath, NULL, CPTFloat(0.0), CPTFloat(0.0)); CGPathAddLineToPoint(lineCapPath, NULL, halfSize.width, -halfSize.height); - CGPathAddLineToPoint(lineCapPath, NULL, CPTFloat(0.0), -lineCapSize.height * CPTFloat(0.375) ); + CGPathAddLineToPoint(lineCapPath, NULL, CPTFloat(0.0), -lineCapSize.height * CPTFloat(0.375)); CGPathCloseSubpath(lineCapPath); break; case CPTLineCapTypeRectangle: - CGPathAddRect(lineCapPath, NULL, CPTRectMake(-halfSize.width, -halfSize.height, halfSize.width * CPTFloat(2.0), halfSize.height * CPTFloat(2.0) ) ); + CGPathAddRect(lineCapPath, NULL, CPTRectMake(-halfSize.width, -halfSize.height, halfSize.width * CPTFloat(2.0), halfSize.height * CPTFloat(2.0))); break; case CPTLineCapTypeEllipse: - CGPathAddEllipseInRect(lineCapPath, NULL, CPTRectMake(-halfSize.width, -halfSize.height, halfSize.width * CPTFloat(2.0), halfSize.height * CPTFloat(2.0) ) ); + CGPathAddEllipseInRect(lineCapPath, NULL, CPTRectMake(-halfSize.width, -halfSize.height, halfSize.width * CPTFloat(2.0), halfSize.height * CPTFloat(2.0))); break; case CPTLineCapTypeDiamond: CGPathMoveToPoint(lineCapPath, NULL, CPTFloat(0.0), halfSize.height); - CGPathAddLineToPoint(lineCapPath, NULL, halfSize.width, CPTFloat(0.0) ); + CGPathAddLineToPoint(lineCapPath, NULL, halfSize.width, CPTFloat(0.0)); CGPathAddLineToPoint(lineCapPath, NULL, CPTFloat(0.0), -halfSize.height); - CGPathAddLineToPoint(lineCapPath, NULL, -halfSize.width, CPTFloat(0.0) ); + CGPathAddLineToPoint(lineCapPath, NULL, -halfSize.width, CPTFloat(0.0)); CGPathCloseSubpath(lineCapPath); break; case CPTLineCapTypePentagon: CGPathMoveToPoint(lineCapPath, NULL, CPTFloat(0.0), halfSize.height); - CGPathAddLineToPoint(lineCapPath, NULL, halfSize.width * CPTFloat(0.95105651630), halfSize.height * CPTFloat(0.30901699437) ); - CGPathAddLineToPoint(lineCapPath, NULL, halfSize.width * CPTFloat(0.58778525229), -halfSize.height * CPTFloat(0.80901699437) ); - CGPathAddLineToPoint(lineCapPath, NULL, -halfSize.width * CPTFloat(0.58778525229), -halfSize.height * CPTFloat(0.80901699437) ); - CGPathAddLineToPoint(lineCapPath, NULL, -halfSize.width * CPTFloat(0.95105651630), halfSize.height * CPTFloat(0.30901699437) ); + CGPathAddLineToPoint(lineCapPath, NULL, halfSize.width * CPTFloat(0.95105651630), halfSize.height * CPTFloat(0.30901699437)); + CGPathAddLineToPoint(lineCapPath, NULL, halfSize.width * CPTFloat(0.58778525229), -halfSize.height * CPTFloat(0.80901699437)); + CGPathAddLineToPoint(lineCapPath, NULL, -halfSize.width * CPTFloat(0.58778525229), -halfSize.height * CPTFloat(0.80901699437)); + CGPathAddLineToPoint(lineCapPath, NULL, -halfSize.width * CPTFloat(0.95105651630), halfSize.height * CPTFloat(0.30901699437)); CGPathCloseSubpath(lineCapPath); break; @@ -549,8 +549,8 @@ -(nonnull CGPathRef)newLineCapPath break; case CPTLineCapTypeBar: - CGPathMoveToPoint(lineCapPath, NULL, halfSize.width, CPTFloat(0.0) ); - CGPathAddLineToPoint(lineCapPath, NULL, -halfSize.width, CPTFloat(0.0) ); + CGPathMoveToPoint(lineCapPath, NULL, halfSize.width, CPTFloat(0.0)); + CGPathAddLineToPoint(lineCapPath, NULL, -halfSize.width, CPTFloat(0.0)); break; case CPTLineCapTypeCross: @@ -582,7 +582,7 @@ -(nonnull CGPathRef)newLineCapPath CGAffineTransform scaleTransform = CGAffineTransformScale(CGAffineTransformIdentity, dx1, dy1); scaleTransform = CGAffineTransformConcat(scaleTransform, - CGAffineTransformMakeTranslation(-halfSize.width, -halfSize.height) ); + CGAffineTransformMakeTranslation(-halfSize.width, -halfSize.height)); CGPathAddPath(lineCapPath, &scaleTransform, customPath); } } @@ -601,7 +601,7 @@ -(nonnull CGPathRef)newLineCapPath -(nullable id)debugQuickLookObject { const CGSize symbolSize = self.size; - const CGSize halfSize = CPTSizeMake(symbolSize.width * CPTFloat(0.5), symbolSize.height * CPTFloat(0.5) ); + const CGSize halfSize = CPTSizeMake(symbolSize.width * CPTFloat(0.5), symbolSize.height * CPTFloat(0.5)); const CGRect rect = CGRectMake(-halfSize.width, -halfSize.height, symbolSize.width, symbolSize.height); const CGPoint centerPoint = CGPointMake(halfSize.width, halfSize.height); diff --git a/CorePlot/framework/Source/CPTLineStyle.h b/CorePlot/framework/Source/CPTLineStyle.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTLineStyle.m b/CorePlot/framework/Source/CPTLineStyle.m old mode 100755 new mode 100644 index 330f4c0..7916ffa --- a/CorePlot/framework/Source/CPTLineStyle.m +++ b/CorePlot/framework/Source/CPTLineStyle.m @@ -154,7 +154,7 @@ +(nonnull instancetype)lineStyleWithStyle:(nullable CPTLineStyle *)lineStyle **/ -(nonnull instancetype)init { - if ( (self = [super init]) ) { + if ((self = [super init])) { lineCap = kCGLineCapButt; lineJoin = kCGLineJoinMiter; miterLimit = CPTFloat(10.0); @@ -190,7 +190,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super init]) ) { + if ((self = [super init])) { lineCap = (CGLineCap)[coder decodeIntForKey:@"CPTLineStyle.lineCap"]; lineJoin = (CGLineJoin)[coder decodeIntForKey:@"CPTLineStyle.lineJoin"]; miterLimit = [coder decodeCGFloatForKey:@"CPTLineStyle.miterLimit"]; @@ -239,7 +239,7 @@ -(void)setLineStyleInContext:(nonnull CGContextRef)context NSUInteger dashCount = myDashPattern.count; if ( dashCount > 0 ) { - CGFloat *dashLengths = (CGFloat *)calloc(dashCount, sizeof(CGFloat) ); + CGFloat *dashLengths = (CGFloat *)calloc(dashCount, sizeof(CGFloat)); NSUInteger dashCounter = 0; for ( NSNumber *currentDashLength in myDashPattern ) { @@ -309,7 +309,7 @@ -(void)strokeRect:(CGRect)rect inContext:(nonnull CGContextRef)context -(void)strokePathWithGradient:(nonnull CPTGradient *)gradient inContext:(nonnull CGContextRef)context { if ( gradient ) { - CGRect deviceRect = CGContextConvertRectToDeviceSpace(context, CPTRectMake(0.0, 0.0, 1.0, 1.0) ); + CGRect deviceRect = CGContextConvertRectToDeviceSpace(context, CPTRectMake(0.0, 0.0, 1.0, 1.0)); CGFloat step = CPTFloat(2.0) / deviceRect.size.height; @@ -319,7 +319,7 @@ -(void)strokePathWithGradient:(nonnull CPTGradient *)gradient inContext:(nonnull CGContextBeginPath(context); CGFloat width = startWidth; - while ( width > CPTFloat(0.0) ) { + while ( width > CPTFloat(0.0)) { CGContextSetLineWidth(context, width); CGColorRef gradientColor = [gradient newColorAtPosition:CPTFloat(1.0) - width / startWidth]; diff --git a/CorePlot/framework/Source/CPTLineStyleTests.h b/CorePlot/framework/Source/CPTLineStyleTests.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTLineStyleTests.m b/CorePlot/framework/Source/CPTLineStyleTests.m old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTMutableLineStyle.h b/CorePlot/framework/Source/CPTMutableLineStyle.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTMutableLineStyle.m b/CorePlot/framework/Source/CPTMutableLineStyle.m old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTMutableNumericData+TypeConversion.h b/CorePlot/framework/Source/CPTMutableNumericData+TypeConversion.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTMutableNumericData+TypeConversion.m b/CorePlot/framework/Source/CPTMutableNumericData+TypeConversion.m old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTMutableNumericData.h b/CorePlot/framework/Source/CPTMutableNumericData.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTMutableNumericData.m b/CorePlot/framework/Source/CPTMutableNumericData.m old mode 100755 new mode 100644 index 0e80d6e..631d707 --- a/CorePlot/framework/Source/CPTMutableNumericData.m +++ b/CorePlot/framework/Source/CPTMutableNumericData.m @@ -49,7 +49,7 @@ @implementation CPTMutableNumericData -(nullable void *)mutableSamplePointer:(NSUInteger)sample { if ( sample < self.numberOfSamples ) { - return (void *)( (char *)self.mutableBytes + sample * self.sampleBytes ); + return (void *)((char *)self.mutableBytes + sample * self.sampleBytes); } else { return NULL; @@ -87,7 +87,7 @@ -(nullable void *)mutableSamplePointerAtIndex:(NSUInteger)idx, ... -(nonnull void *)mutableBytes { - return ( (NSMutableData *)self.data ).mutableBytes; + return ((NSMutableData *)self.data).mutableBytes; } /// @endcond diff --git a/CorePlot/framework/Source/CPTMutableNumericDataTests.h b/CorePlot/framework/Source/CPTMutableNumericDataTests.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTMutableNumericDataTests.m b/CorePlot/framework/Source/CPTMutableNumericDataTests.m old mode 100755 new mode 100644 index 9a218d5..d5cc087 --- a/CorePlot/framework/Source/CPTMutableNumericDataTests.m +++ b/CorePlot/framework/Source/CPTMutableNumericDataTests.m @@ -28,7 +28,7 @@ -(void)testNumberOfDimensionsGivesShapeCount NSMutableData *data = [NSMutableData dataWithLength:nElems * sizeof(float)]; CPTMutableNumericData *nd = [[CPTMutableNumericData alloc] initWithData:data - dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder() ) + dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder()) shape:shape]; XCTAssertEqual(nd.numberOfDimensions, nd.shape.count, @"numberOfDimensions == shape.count == 3"); @@ -64,7 +64,7 @@ -(void)testIllegalShapeRaisesException NSMutableData *data = [NSMutableData dataWithLength:nElems * sizeof(NSUInteger)]; XCTAssertThrowsSpecificNamed(testData = [[CPTMutableNumericData alloc] initWithData:data - dataType:CPTDataType(CPTUnsignedIntegerDataType, sizeof(NSUInteger), NSHostByteOrder() ) + dataType:CPTDataType(CPTUnsignedIntegerDataType, sizeof(NSUInteger), NSHostByteOrder()) shape:shape], NSException, CPTNumericDataException, @@ -95,7 +95,7 @@ -(void)testBytesEqualDataBytes } CPTMutableNumericData *nd = [[CPTMutableNumericData alloc] initWithData:data - dataType:CPTDataType(CPTIntegerDataType, sizeof(NSInteger), NSHostByteOrder() ) + dataType:CPTDataType(CPTIntegerDataType, sizeof(NSInteger), NSHostByteOrder()) shape:nil]; NSMutableData *expected = data; @@ -113,7 +113,7 @@ -(void)testArchivingRoundTrip } CPTMutableNumericData *nd = [[CPTMutableNumericData alloc] initWithData:data - dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder() ) + dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder()) shape:nil]; CPTMutableNumericData *nd2 = [self archiveRoundTrip:nd]; @@ -140,7 +140,7 @@ -(void)testNumberOfSamplesCorrectForDataType } CPTMutableNumericData *nd = [[CPTMutableNumericData alloc] initWithData:data - dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder() ) + dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder()) shape:nil]; XCTAssertEqual([nd numberOfSamples], nElems, @"numberOfSamples == nElems"); @@ -153,7 +153,7 @@ -(void)testNumberOfSamplesCorrectForDataType } nd = [[CPTMutableNumericData alloc] initWithData:data - dataType:CPTDataType(CPTIntegerDataType, sizeof(char), NSHostByteOrder() ) + dataType:CPTDataType(CPTIntegerDataType, sizeof(char), NSHostByteOrder()) shape:nil]; XCTAssertEqual([nd numberOfSamples], nElems, @"numberOfSamples == nElems"); @@ -170,7 +170,7 @@ -(void)testDataTypeAccessorsCorrectForDataType } CPTMutableNumericData *nd = [[CPTMutableNumericData alloc] initWithData:data - dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder() ) + dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder()) shape:nil]; XCTAssertEqual([nd dataTypeFormat], CPTFloatingPointDataType, @"dataTypeFormat"); @@ -189,7 +189,7 @@ -(void)testConvertTypeConvertsType } CPTMutableNumericData *fd = [[CPTMutableNumericData alloc] initWithData:data - dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder() ) + dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder()) shape:nil]; CPTNumericData *dd = [fd dataByConvertingToType:CPTFloatingPointDataType @@ -198,7 +198,7 @@ -(void)testConvertTypeConvertsType const double *doubleSamples = (const double *)dd.data.bytes; for ( NSUInteger i = 0; i < numberOfSamples; i++ ) { - XCTAssertTrue( (double)samples[i] == doubleSamples[i], @"(float)%g != (double)%g", (double)samples[i], doubleSamples[i] ); + XCTAssertTrue((double)samples[i] == doubleSamples[i], @"(float)%g != (double)%g", (double)samples[i], doubleSamples[i]); } } @@ -213,12 +213,12 @@ -(void)testSamplePointerCorrect } CPTMutableNumericData *fd = [[CPTMutableNumericData alloc] initWithData:data - dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder() ) + dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder()) shape:nil]; - XCTAssertEqual( ( (float *)[fd mutableBytes] ) + 4, (float *)[fd mutableSamplePointer:4], @"%p,%p", samples + 4, (float *)[fd mutableSamplePointer:4] ); - XCTAssertEqual( ( (float *)[fd mutableBytes] ), (float *)[fd mutableSamplePointer:0], @"" ); - XCTAssertEqual( ( (float *)[fd mutableBytes] ) + nElems - 1, (float *)[fd mutableSamplePointer:nElems - 1], @"" ); + XCTAssertEqual(((float *)[fd mutableBytes]) + 4, (float *)[fd mutableSamplePointer:4], @"%p,%p", samples + 4, (float *)[fd mutableSamplePointer:4]); + XCTAssertEqual(((float *)[fd mutableBytes]), (float *)[fd mutableSamplePointer:0], @""); + XCTAssertEqual(((float *)[fd mutableBytes]) + nElems - 1, (float *)[fd mutableSamplePointer:nElems - 1], @""); XCTAssertNil([fd samplePointer:nElems], @"too many samples"); } @@ -233,7 +233,7 @@ -(void)testSampleValueCorrect } CPTMutableNumericData *fd = [[CPTMutableNumericData alloc] initWithData:data - dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder() ) + dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder()) shape:nil]; XCTAssertEqualWithAccuracy([[fd sampleValue:0] doubleValue], sin(0), 0.01, @"sample value"); @@ -245,13 +245,13 @@ -(void)testMutableCopy const NSUInteger nElems = 10; NSMutableData *data = [NSMutableData dataWithLength:nElems * sizeof(float)]; CPTNumericData *nd = [[CPTNumericData alloc] initWithData:data - dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder() ) + dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder()) shape:nil]; CPTMutableNumericData *ndCopy = [nd mutableCopy]; // should be mutable--if not, this will error - ndCopy.dataType = CPTDataType(CPTFloatingPointDataType, sizeof(double), NSHostByteOrder() ); + ndCopy.dataType = CPTDataType(CPTFloatingPointDataType, sizeof(double), NSHostByteOrder()); } @end diff --git a/CorePlot/framework/Source/CPTMutableNumericDataTypeConversionTests.h b/CorePlot/framework/Source/CPTMutableNumericDataTypeConversionTests.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTMutableNumericDataTypeConversionTests.m b/CorePlot/framework/Source/CPTMutableNumericDataTypeConversionTests.m old mode 100755 new mode 100644 index ec1154c..2c01ecf --- a/CorePlot/framework/Source/CPTMutableNumericDataTypeConversionTests.m +++ b/CorePlot/framework/Source/CPTMutableNumericDataTypeConversionTests.m @@ -18,14 +18,14 @@ -(void)testFloatToDoubleInPlaceConversion } CPTMutableNumericData *numericData = [[CPTMutableNumericData alloc] initWithData:data - dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder() ) + dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder()) shape:nil]; numericData.sampleBytes = sizeof(double); const double *doubleSamples = (const double *)numericData.data.bytes; for ( NSUInteger i = 0; i < numberOfSamples; i++ ) { - XCTAssertEqualWithAccuracy( (double)samples[i], doubleSamples[i], precision, @"(float)%g != (double)%g", (double)samples[i], doubleSamples[i] ); + XCTAssertEqualWithAccuracy((double)samples[i], doubleSamples[i], precision, @"(float)%g != (double)%g", (double)samples[i], doubleSamples[i]); } } @@ -39,14 +39,14 @@ -(void)testDoubleToFloatInPlaceConversion } CPTMutableNumericData *numericData = [[CPTMutableNumericData alloc] initWithData:data - dataType:CPTDataType(CPTFloatingPointDataType, sizeof(double), NSHostByteOrder() ) + dataType:CPTDataType(CPTFloatingPointDataType, sizeof(double), NSHostByteOrder()) shape:nil]; numericData.sampleBytes = sizeof(float); const float *floatSamples = (const float *)numericData.data.bytes; for ( NSUInteger i = 0; i < numberOfSamples; i++ ) { - XCTAssertEqualWithAccuracy( (double)floatSamples[i], samples[i], precision, @"(float)%g != (double)%g", (double)floatSamples[i], samples[i] ); + XCTAssertEqualWithAccuracy((double)floatSamples[i], samples[i], precision, @"(float)%g != (double)%g", (double)floatSamples[i], samples[i]); } } @@ -60,14 +60,14 @@ -(void)testFloatToIntegerInPlaceConversion } CPTMutableNumericData *numericData = [[CPTMutableNumericData alloc] initWithData:data - dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder() ) + dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder()) shape:nil]; - numericData.dataType = CPTDataType(CPTIntegerDataType, sizeof(NSInteger), NSHostByteOrder() ); + numericData.dataType = CPTDataType(CPTIntegerDataType, sizeof(NSInteger), NSHostByteOrder()); const NSInteger *intSamples = (const NSInteger *)numericData.data.bytes; for ( NSUInteger i = 0; i < numberOfSamples; i++ ) { - XCTAssertEqualWithAccuracy( (NSInteger)samples[i], intSamples[i], precision, @"(float)%g != (NSInteger)%ld", (double)samples[i], (long)intSamples[i] ); + XCTAssertEqualWithAccuracy((NSInteger)samples[i], intSamples[i], precision, @"(float)%g != (NSInteger)%ld", (double)samples[i], (long)intSamples[i]); } } @@ -81,10 +81,10 @@ -(void)testIntegerToFloatInPlaceConversion } CPTMutableNumericData *numericData = [[CPTMutableNumericData alloc] initWithData:data - dataType:CPTDataType(CPTIntegerDataType, sizeof(NSInteger), NSHostByteOrder() ) + dataType:CPTDataType(CPTIntegerDataType, sizeof(NSInteger), NSHostByteOrder()) shape:nil]; - numericData.dataType = CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder() ); + numericData.dataType = CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder()); const float *floatSamples = (const float *)numericData.data.bytes; for ( NSUInteger i = 0; i < numberOfSamples; i++ ) { @@ -98,14 +98,14 @@ -(void)testDecimalToDoubleInPlaceConversion NSDecimal *samples = (NSDecimal *)data.mutableBytes; for ( NSUInteger i = 0; i < numberOfSamples; i++ ) { - samples[i] = CPTDecimalFromDouble(sin(i) ); + samples[i] = CPTDecimalFromDouble(sin(i)); } CPTMutableNumericData *numericData = [[CPTMutableNumericData alloc] initWithData:data - dataType:CPTDataType(CPTDecimalDataType, sizeof(NSDecimal), NSHostByteOrder() ) + dataType:CPTDataType(CPTDecimalDataType, sizeof(NSDecimal), NSHostByteOrder()) shape:nil]; - numericData.dataType = CPTDataType(CPTFloatingPointDataType, sizeof(double), NSHostByteOrder() ); + numericData.dataType = CPTDataType(CPTFloatingPointDataType, sizeof(double), NSHostByteOrder()); const double *doubleSamples = (const double *)numericData.data.bytes; for ( NSUInteger i = 0; i < numberOfSamples; i++ ) { @@ -123,14 +123,14 @@ -(void)testDoubleToDecimalInPlaceConversion } CPTMutableNumericData *numericData = [[CPTMutableNumericData alloc] initWithData:data - dataType:CPTDataType(CPTFloatingPointDataType, sizeof(double), NSHostByteOrder() ) + dataType:CPTDataType(CPTFloatingPointDataType, sizeof(double), NSHostByteOrder()) shape:nil]; - numericData.dataType = CPTDataType(CPTDecimalDataType, sizeof(NSDecimal), NSHostByteOrder() ); + numericData.dataType = CPTDataType(CPTDecimalDataType, sizeof(NSDecimal), NSHostByteOrder()); const NSDecimal *decimalSamples = (const NSDecimal *)numericData.data.bytes; for ( NSUInteger i = 0; i < numberOfSamples; i++ ) { - XCTAssertTrue(CPTDecimalEquals(decimalSamples[i], CPTDecimalFromDouble(samples[i]) ), @"(NSDecimal)%@ != (double)%g", CPTDecimalStringValue(decimalSamples[i]), samples[i]); + XCTAssertTrue(CPTDecimalEquals(decimalSamples[i], CPTDecimalFromDouble(samples[i])), @"(NSDecimal)%@ != (double)%g", CPTDecimalStringValue(decimalSamples[i]), samples[i]); } } diff --git a/CorePlot/framework/Source/CPTMutablePlotRange.h b/CorePlot/framework/Source/CPTMutablePlotRange.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTMutablePlotRange.m b/CorePlot/framework/Source/CPTMutablePlotRange.m old mode 100755 new mode 100644 index 4a5870f..eb10798 --- a/CorePlot/framework/Source/CPTMutablePlotRange.m +++ b/CorePlot/framework/Source/CPTMutablePlotRange.m @@ -73,24 +73,76 @@ -(void)unionPlotRange:(nullable CPTPlotRange *)other NSDecimal min1 = self.minLimitDecimal; NSDecimal min2 = other.minLimitDecimal; - NSDecimal minimum = CPTDecimalLessThan(min1, min2) ? min1 : min2; + NSDecimal minimum = CPTDecimalMin(min1, min2); NSDecimal max1 = self.maxLimitDecimal; NSDecimal max2 = other.maxLimitDecimal; - NSDecimal maximum = CPTDecimalGreaterThan(max1, max2) ? max1 : max2; - - NSDecimal newLocation, newLength; - if ( CPTDecimalGreaterThanOrEqualTo(self.lengthDecimal, CPTDecimalFromInteger(0) ) ) { - newLocation = minimum; - newLength = CPTDecimalSubtract(maximum, minimum); + NSDecimal maximum = CPTDecimalMax(max1, max2); + + if ( self.isInfinite && other.isInfinite ) { + if ( self.lengthSign == other.lengthSign ) { + switch ( self.lengthSign ) { + case CPTSignPositive: + self.locationDecimal = minimum; + break; + + case CPTSignNegative: + self.locationDecimal = maximum; + break; + + default: + break; + } + } + else { + self.locationDouble = -HUGE_VAL; + self.lengthDouble = HUGE_VAL; + } + } + else if ( self.isInfinite && !other.isInfinite ) { + switch ( self.lengthSign ) { + case CPTSignPositive: + self.locationDecimal = minimum; + break; + + case CPTSignNegative: + self.locationDecimal = maximum; + break; + + default: + break; + } + } + else if ( !self.isInfinite && other.isInfinite ) { + switch ( other.lengthSign ) { + case CPTSignPositive: + self.locationDecimal = minimum; + self.lengthDouble = HUGE_VAL; + break; + + case CPTSignNegative: + self.locationDecimal = maximum; + self.lengthDouble = -HUGE_VAL; + break; + + default: + break; + } + } + else if ( NSDecimalIsNotANumber(&minimum) || NSDecimalIsNotANumber(&maximum)) { + self.locationDecimal = CPTDecimalNaN(); + self.lengthDecimal = CPTDecimalNaN(); } else { - newLocation = maximum; - newLength = CPTDecimalSubtract(minimum, maximum); + if ( CPTDecimalGreaterThanOrEqualTo(self.lengthDecimal, CPTDecimalFromInteger(0))) { + self.locationDecimal = minimum; + self.lengthDecimal = CPTDecimalSubtract(maximum, minimum); + } + else { + self.locationDecimal = maximum; + self.lengthDecimal = CPTDecimalSubtract(minimum, maximum); + } } - - self.locationDecimal = newLocation; - self.lengthDecimal = newLength; } /** @brief Sets the messaged object to the intersection with another range. The sign of @ref length is unchanged. @@ -104,28 +156,75 @@ -(void)intersectionPlotRange:(nullable CPTPlotRange *)other NSDecimal min1 = self.minLimitDecimal; NSDecimal min2 = other.minLimitDecimal; - NSDecimal minimum = CPTDecimalGreaterThan(min1, min2) ? min1 : min2; + NSDecimal minimum = CPTDecimalMax(min1, min2); NSDecimal max1 = self.maxLimitDecimal; NSDecimal max2 = other.maxLimitDecimal; - NSDecimal maximum = CPTDecimalLessThan(max1, max2) ? max1 : max2; + NSDecimal maximum = CPTDecimalMin(max1, max2); - if ( CPTDecimalGreaterThanOrEqualTo(maximum, minimum) ) { - NSDecimal newLocation, newLength; - if ( CPTDecimalGreaterThanOrEqualTo(self.lengthDecimal, CPTDecimalFromInteger(0) ) ) { - newLocation = minimum; - newLength = CPTDecimalSubtract(maximum, minimum); + if ( ![self intersectsRange:other] ) { + self.locationDecimal = CPTDecimalNaN(); + self.lengthDecimal = CPTDecimalNaN(); + } + else if ( self.isInfinite && other.isInfinite ) { + switch ( self.lengthSign ) { + case CPTSignPositive: + self.locationDecimal = minimum; + break; + + case CPTSignNegative: + self.locationDecimal = maximum; + break; + + default: + break; } - else { - newLocation = maximum; - newLength = CPTDecimalSubtract(minimum, maximum); + } + else if ( self.isInfinite && !other.isInfinite ) { + switch ( self.lengthSign ) { + case CPTSignPositive: + self.locationDecimal = minimum; + self.lengthDecimal = CPTDecimalSubtract(other.maxLimitDecimal, minimum); + break; + + case CPTSignNegative: + self.locationDecimal = maximum; + self.lengthDecimal = CPTDecimalSubtract(other.minLimitDecimal, maximum); + break; + + default: + break; + } + } + else if ( !self.isInfinite && other.isInfinite ) { + switch ( other.lengthSign ) { + case CPTSignPositive: + self.locationDecimal = minimum; + self.lengthDecimal = CPTDecimalSubtract(self.maxLimitDecimal, minimum); + break; + + case CPTSignNegative: + self.locationDecimal = maximum; + self.lengthDecimal = CPTDecimalSubtract(self.minLimitDecimal, maximum); + break; + + default: + break; } - - self.locationDecimal = newLocation; - self.lengthDecimal = newLength; + } + else if ( NSDecimalIsNotANumber(&minimum) || NSDecimalIsNotANumber(&maximum)) { + self.locationDecimal = CPTDecimalNaN(); + self.lengthDecimal = CPTDecimalNaN(); } else { - self.lengthDecimal = CPTDecimalFromInteger(0); + if ( CPTDecimalGreaterThanOrEqualTo(self.lengthDecimal, CPTDecimalFromInteger(0))) { + self.locationDecimal = minimum; + self.lengthDecimal = CPTDecimalSubtract(maximum, minimum); + } + else { + self.locationDecimal = maximum; + self.lengthDecimal = CPTDecimalSubtract(minimum, maximum); + } } } @@ -140,7 +239,7 @@ -(void)expandRangeByFactor:(nonnull NSNumber *)factor { NSDecimal oldLength = self.lengthDecimal; NSDecimal newLength = CPTDecimalMultiply(oldLength, factor.decimalValue); - NSDecimal locationOffset = CPTDecimalDivide(CPTDecimalSubtract(oldLength, newLength), CPTDecimalFromInteger(2) ); + NSDecimal locationOffset = CPTDecimalDivide(CPTDecimalSubtract(oldLength, newLength), CPTDecimalFromInteger(2)); NSDecimal newLocation = CPTDecimalAdd(self.locationDecimal, locationOffset); self.locationDecimal = newLocation; @@ -201,8 +300,10 @@ -(void)shiftEndToFitInRange:(nonnull CPTPlotRange *)otherRange /// @cond --(void)setLocation:(NSNumber *)newLocation +-(void)setLocation:(nonnull NSNumber *)newLocation { + NSParameterAssert(newLocation); + self.inValueUpdate = YES; self.locationDecimal = newLocation.decimalValue; @@ -211,8 +312,10 @@ -(void)setLocation:(NSNumber *)newLocation self.inValueUpdate = NO; } --(void)setLength:(NSNumber *)newLength +-(void)setLength:(nonnull NSNumber *)newLength { + NSParameterAssert(newLength); + self.inValueUpdate = YES; self.lengthDecimal = newLength.decimalValue; diff --git a/CorePlot/framework/Source/CPTMutableShadow.h b/CorePlot/framework/Source/CPTMutableShadow.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTMutableShadow.m b/CorePlot/framework/Source/CPTMutableShadow.m old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTMutableTextStyle.h b/CorePlot/framework/Source/CPTMutableTextStyle.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTMutableTextStyle.m b/CorePlot/framework/Source/CPTMutableTextStyle.m old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTNumericData+TypeConversion.h b/CorePlot/framework/Source/CPTNumericData+TypeConversion.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTNumericData+TypeConversion.m b/CorePlot/framework/Source/CPTNumericData+TypeConversion.m old mode 100755 new mode 100644 index d947421..2ebfd19 --- a/CorePlot/framework/Source/CPTNumericData+TypeConversion.m +++ b/CorePlot/framework/Source/CPTNumericData+TypeConversion.m @@ -29,17 +29,17 @@ -(nonnull CPTNumericData *)dataByConvertingToDataType:(CPTNumericDataType)newDat NSParameterAssert(myDataType.dataTypeFormat != CPTUndefinedDataType); NSParameterAssert(myDataType.byteOrder != CFByteOrderUnknown); - NSParameterAssert(CPTDataTypeIsSupported(newDataType) ); + NSParameterAssert(CPTDataTypeIsSupported(newDataType)); NSParameterAssert(newDataType.dataTypeFormat != CPTUndefinedDataType); NSParameterAssert(newDataType.byteOrder != CFByteOrderUnknown); NSData *newData = nil; CFByteOrder hostByteOrder = CFByteOrderGetCurrent(); - if ( CPTDataTypeEqualToDataType(myDataType, newDataType) ) { + if ( CPTDataTypeEqualToDataType(myDataType, newDataType)) { newData = self.data; } - else if ( (myDataType.sampleBytes == sizeof(int8_t) ) && (newDataType.sampleBytes == sizeof(int8_t) ) ) { + else if ((myDataType.sampleBytes == sizeof(int8_t)) && (newDataType.sampleBytes == sizeof(int8_t))) { newData = self.data; } else { @@ -105,7 +105,7 @@ case sizeof(int8_t): switch ( destDataType->sampleBytes ) { case sizeof(int8_t): { // int8_t -> int8_t - memcpy(destData.mutableBytes, sourceData.bytes, sampleCount * sizeof(int8_t) ); + memcpy(destData.mutableBytes, sourceData.bytes, sampleCount * sizeof(int8_t)); } break; @@ -281,7 +281,7 @@ case sizeof(int8_t): case sizeof(int16_t): { // int16_t -> int16_t - memcpy(destData.mutableBytes, sourceData.bytes, sampleCount * sizeof(int16_t) ); + memcpy(destData.mutableBytes, sourceData.bytes, sampleCount * sizeof(int16_t)); } break; @@ -457,7 +457,7 @@ case sizeof(int16_t): case sizeof(int32_t): { // int32_t -> int32_t - memcpy(destData.mutableBytes, sourceData.bytes, sampleCount * sizeof(int32_t) ); + memcpy(destData.mutableBytes, sourceData.bytes, sampleCount * sizeof(int32_t)); } break; @@ -633,7 +633,7 @@ case sizeof(int32_t): case sizeof(int64_t): { // int64_t -> int64_t - memcpy(destData.mutableBytes, sourceData.bytes, sampleCount * sizeof(int64_t) ); + memcpy(destData.mutableBytes, sourceData.bytes, sampleCount * sizeof(int64_t)); } break; } @@ -817,7 +817,7 @@ case sizeof(int64_t): switch ( destDataType->sampleBytes ) { case sizeof(uint8_t): { // uint8_t -> uint8_t - memcpy(destData.mutableBytes, sourceData.bytes, sampleCount * sizeof(uint8_t) ); + memcpy(destData.mutableBytes, sourceData.bytes, sampleCount * sizeof(uint8_t)); } break; @@ -993,7 +993,7 @@ case sizeof(uint8_t): case sizeof(uint16_t): { // uint16_t -> uint16_t - memcpy(destData.mutableBytes, sourceData.bytes, sampleCount * sizeof(uint16_t) ); + memcpy(destData.mutableBytes, sourceData.bytes, sampleCount * sizeof(uint16_t)); } break; @@ -1169,7 +1169,7 @@ case sizeof(uint16_t): case sizeof(uint32_t): { // uint32_t -> uint32_t - memcpy(destData.mutableBytes, sourceData.bytes, sampleCount * sizeof(uint32_t) ); + memcpy(destData.mutableBytes, sourceData.bytes, sampleCount * sizeof(uint32_t)); } break; @@ -1345,7 +1345,7 @@ case sizeof(uint32_t): case sizeof(uint64_t): { // uint64_t -> uint64_t - memcpy(destData.mutableBytes, sourceData.bytes, sampleCount * sizeof(uint64_t) ); + memcpy(destData.mutableBytes, sourceData.bytes, sampleCount * sizeof(uint64_t)); } break; } @@ -1529,7 +1529,7 @@ case sizeof(uint64_t): switch ( destDataType->sampleBytes ) { case sizeof(float): { // float -> float - memcpy(destData.mutableBytes, sourceData.bytes, sampleCount * sizeof(float) ); + memcpy(destData.mutableBytes, sourceData.bytes, sampleCount * sizeof(float)); } break; @@ -1705,7 +1705,7 @@ case sizeof(float): case sizeof(double): { // double -> double - memcpy(destData.mutableBytes, sourceData.bytes, sampleCount * sizeof(double) ); + memcpy(destData.mutableBytes, sourceData.bytes, sampleCount * sizeof(double)); } break; } @@ -1889,7 +1889,7 @@ case sizeof(double): switch ( destDataType->sampleBytes ) { case sizeof(float complex): { // float complex -> float complex - memcpy(destData.mutableBytes, sourceData.bytes, sampleCount * sizeof(float complex) ); + memcpy(destData.mutableBytes, sourceData.bytes, sampleCount * sizeof(float complex)); } break; @@ -1914,7 +1914,7 @@ case sizeof(NSDecimal): const float complex *lastSample = fromBytes + sampleCount; NSDecimal *toBytes = (NSDecimal *)destData.mutableBytes; while ( fromBytes < lastSample ) { - *toBytes++ = CPTDecimalFromFloat(crealf(*fromBytes++) ); + *toBytes++ = CPTDecimalFromFloat(crealf(*fromBytes++)); } } break; @@ -2065,7 +2065,7 @@ case sizeof(float complex): case sizeof(double complex): { // double complex -> double complex - memcpy(destData.mutableBytes, sourceData.bytes, sampleCount * sizeof(double complex) ); + memcpy(destData.mutableBytes, sourceData.bytes, sampleCount * sizeof(double complex)); } break; } @@ -2079,7 +2079,7 @@ case sizeof(NSDecimal): const double complex *lastSample = fromBytes + sampleCount; NSDecimal *toBytes = (NSDecimal *)destData.mutableBytes; while ( fromBytes < lastSample ) { - *toBytes++ = CPTDecimalFromDouble(creal(*fromBytes++) ); + *toBytes++ = CPTDecimalFromDouble(creal(*fromBytes++)); } } break; @@ -2249,7 +2249,7 @@ case sizeof(double complex): switch ( destDataType->sampleBytes ) { case sizeof(NSDecimal): { // NSDecimal -> NSDecimal - memcpy(destData.mutableBytes, sourceData.bytes, sampleCount * sizeof(NSDecimal) ); + memcpy(destData.mutableBytes, sourceData.bytes, sampleCount * sizeof(NSDecimal)); } break; } diff --git a/CorePlot/framework/Source/CPTNumericData+TypeConversions_Generation.py b/CorePlot/framework/Source/CPTNumericData+TypeConversions_Generation.py old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTNumericData.h b/CorePlot/framework/Source/CPTNumericData.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTNumericData.m b/CorePlot/framework/Source/CPTNumericData.m old mode 100755 new mode 100644 index 15577b4..b8c5d12 --- a/CorePlot/framework/Source/CPTNumericData.m +++ b/CorePlot/framework/Source/CPTNumericData.m @@ -341,7 +341,7 @@ -(nonnull instancetype)initWithData:(nonnull NSData *)newData shape:(nullable CPTNumberArray *)shapeArray dataOrder:(CPTDataOrder)order { - if ( (self = [super init]) ) { + if ((self = [super init])) { [self commonInitWithData:newData dataType:newDataType shape:shapeArray @@ -418,7 +418,7 @@ -(nonnull instancetype)initWithArray:(nonnull CPTNumberArray *)newData -(nonnull instancetype)init { return [self initWithData:[NSData data] - dataType:CPTDataType(CPTFloatingPointDataType, sizeof(double), CFByteOrderGetCurrent() ) + dataType:CPTDataType(CPTFloatingPointDataType, sizeof(double), CFByteOrderGetCurrent()) shape:nil]; } @@ -427,7 +427,7 @@ -(void)commonInitWithData:(nonnull NSData *)newData shape:(nullable CPTNumberArray *)shapeArray dataOrder:(CPTDataOrder)order { - NSParameterAssert(CPTDataTypeIsSupported(newDataType) ); + NSParameterAssert(CPTDataTypeIsSupported(newDataType)); self.data = newData; self.dataType = newDataType; @@ -511,21 +511,21 @@ -(void)setDataType:(CPTNumericDataType)newDataType { CPTNumericDataType oldDataType = dataType; - if ( CPTDataTypeEqualToDataType(oldDataType, newDataType) ) { + if ( CPTDataTypeEqualToDataType(oldDataType, newDataType)) { return; } - NSParameterAssert(CPTDataTypeIsSupported(newDataType) ); + NSParameterAssert(CPTDataTypeIsSupported(newDataType)); NSParameterAssert(newDataType.dataTypeFormat != CPTUndefinedDataType); NSParameterAssert(newDataType.byteOrder != CFByteOrderUnknown); dataType = newDataType; - if ( (oldDataType.sampleBytes == sizeof(int8_t) ) && (newDataType.sampleBytes == sizeof(int8_t) ) ) { + if ((oldDataType.sampleBytes == sizeof(int8_t)) && (newDataType.sampleBytes == sizeof(int8_t))) { return; } - if ( (oldDataType.dataTypeFormat != CPTUndefinedDataType) && (oldDataType.byteOrder != CFByteOrderUnknown) ) { + if ((oldDataType.dataTypeFormat != CPTUndefinedDataType) && (oldDataType.byteOrder != CFByteOrderUnknown)) { NSMutableData *myData = (NSMutableData *)self.data; CFByteOrder hostByteOrder = CFByteOrderGetCurrent(); @@ -669,11 +669,11 @@ case sizeof(double): case CPTComplexFloatingPointDataType: switch ( self.sampleBytes ) { case sizeof(float complex): - result = @(crealf(*(const float complex *)[self samplePointer:sample]) ); + result = @(crealf(*(const float complex *)[self samplePointer:sample])); break; case sizeof(double complex): - result = @(creal(*(const double complex *)[self samplePointer:sample]) ); + result = @(creal(*(const double complex *)[self samplePointer:sample])); break; } break; @@ -728,7 +728,7 @@ -(NSNumber *)sampleValueAtIndex:(NSUInteger)idx, ... -(nullable const void *)samplePointer:(NSUInteger)sample { if ( sample < self.numberOfSamples ) { - return (const void *)( (const char *)self.bytes + sample * self.sampleBytes ); + return (const void *)((const char *)self.bytes + sample * self.sampleBytes); } else { return NULL; @@ -802,9 +802,9 @@ -(NSUInteger)sampleIndex:(NSUInteger)idx indexList:(va_list)indexList NSUInteger newIndex = 0; if ( numDims > 1 ) { - NSUInteger *dims = calloc(numDims, sizeof(NSUInteger) ); - NSUInteger *dimProducts = calloc(numDims, sizeof(NSUInteger) ); - NSUInteger *indices = calloc(numDims, sizeof(NSUInteger) ); + NSUInteger *dims = calloc(numDims, sizeof(NSUInteger)); + NSUInteger *dimProducts = calloc(numDims, sizeof(NSUInteger)); + NSUInteger *indices = calloc(numDims, sizeof(NSUInteger)); NSUInteger argIndex = 0; indices[0] = idx; @@ -865,7 +865,7 @@ -(NSUInteger)sampleIndex:(NSUInteger)idx indexList:(va_list)indexList -(nonnull NSData *)dataFromArray:(nonnull CPTNumberArray *)newData dataType:(CPTNumericDataType)newDataType { - NSParameterAssert(CPTDataTypeIsSupported(newDataType) ); + NSParameterAssert(CPTDataTypeIsSupported(newDataType)); NSParameterAssert(newDataType.dataTypeFormat != CPTUndefinedDataType); NSParameterAssert(newDataType.dataTypeFormat != CPTComplexFloatingPointDataType); @@ -1085,7 +1085,7 @@ case sizeof(NSDecimal): // End of code generated with "CPTNumericData+TypeConversions_Generation.py" // ======================================================================== - if ( (newDataType.byteOrder != CFByteOrderGetCurrent() ) && (newDataType.byteOrder != CFByteOrderUnknown) ) { + if ((newDataType.byteOrder != CFByteOrderGetCurrent()) && (newDataType.byteOrder != CFByteOrderUnknown)) { [self swapByteOrderForData:sampleData sampleSize:newDataType.sampleBytes]; } @@ -1177,7 +1177,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)encoder */ -(nullable instancetype)initWithCoder:(nonnull NSCoder *)decoder { - if ( (self = [super init]) ) { + if ((self = [super init])) { NSData *newData; CPTNumericDataType newDataType; CPTNumberArray *shapeArray; @@ -1186,9 +1186,9 @@ -(nullable instancetype)initWithCoder:(nonnull NSCoder *)decoder newData = [decoder decodeObjectOfClass:[NSData class] forKey:@"CPTNumericData.data"]; - newDataType = CPTDataType( (CPTDataTypeFormat)[decoder decodeIntegerForKey:@"CPTNumericData.dataType.dataTypeFormat"], - (size_t)[decoder decodeInt64ForKey:@"CPTNumericData.dataType.sampleBytes"], - (CFByteOrder)[decoder decodeInt64ForKey:@"CPTNumericData.dataType.byteOrder"] ); + newDataType = CPTDataType((CPTDataTypeFormat)[decoder decodeIntegerForKey:@"CPTNumericData.dataType.dataTypeFormat"], + (size_t)[decoder decodeInt64ForKey:@"CPTNumericData.dataType.sampleBytes"], + (CFByteOrder)[decoder decodeInt64ForKey:@"CPTNumericData.dataType.byteOrder"]); shapeArray = [decoder decodeObjectOfClasses:[NSSet setWithArray:@[[NSArray class], [NSNumber class]]] forKey:@"CPTNumericData.shape"]; diff --git a/CorePlot/framework/Source/CPTNumericDataTests.h b/CorePlot/framework/Source/CPTNumericDataTests.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTNumericDataTests.m b/CorePlot/framework/Source/CPTNumericDataTests.m old mode 100755 new mode 100644 index 3819fa7..26e0ca4 --- a/CorePlot/framework/Source/CPTNumericDataTests.m +++ b/CorePlot/framework/Source/CPTNumericDataTests.m @@ -27,7 +27,7 @@ -(void)testNumberOfDimensionsGivesShapeCount NSMutableData *data = [NSMutableData dataWithLength:nElems * sizeof(float)]; CPTNumericData *nd = [[CPTNumericData alloc] initWithData:data - dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder() ) + dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder()) shape:shape]; XCTAssertEqual(nd.numberOfDimensions, nd.shape.count, @"numberOfDimensions == shape.count == 3"); @@ -63,7 +63,7 @@ -(void)testIllegalShapeRaisesException NSMutableData *data = [NSMutableData dataWithLength:nElems * sizeof(NSUInteger)]; XCTAssertThrowsSpecificNamed(testData = [[CPTNumericData alloc] initWithData:data - dataType:CPTDataType(CPTUnsignedIntegerDataType, sizeof(NSUInteger), NSHostByteOrder() ) + dataType:CPTDataType(CPTUnsignedIntegerDataType, sizeof(NSUInteger), NSHostByteOrder()) shape:shape], NSException, CPTNumericDataException, @@ -94,7 +94,7 @@ -(void)testBytesEqualDataBytes } CPTNumericData *nd = [[CPTNumericData alloc] initWithData:data - dataType:CPTDataType(CPTIntegerDataType, sizeof(NSInteger), NSHostByteOrder() ) + dataType:CPTDataType(CPTIntegerDataType, sizeof(NSInteger), NSHostByteOrder()) shape:nil]; NSData *expected = data; @@ -113,7 +113,7 @@ -(void)testArchivingRoundTrip } CPTNumericData *nd = [[CPTNumericData alloc] initWithData:data - dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder() ) + dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder()) shape:nil]; CPTNumericData *nd2 = [self archiveRoundTrip:nd]; @@ -140,7 +140,7 @@ -(void)testKeyedArchivingRoundTrip } CPTNumericData *nd = [[CPTNumericData alloc] initWithData:data - dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder() ) + dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder()) shape:nil]; CPTNumericData *nd2 = [self archiveRoundTrip:nd]; @@ -167,7 +167,7 @@ -(void)testNumberOfSamplesCorrectForDataType } CPTNumericData *nd = [[CPTNumericData alloc] initWithData:data - dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder() ) + dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder()) shape:nil]; XCTAssertEqual([nd numberOfSamples], nElems, @"numberOfSamples == nElems"); @@ -180,7 +180,7 @@ -(void)testNumberOfSamplesCorrectForDataType } nd = [[CPTNumericData alloc] initWithData:data - dataType:CPTDataType(CPTIntegerDataType, sizeof(char), NSHostByteOrder() ) + dataType:CPTDataType(CPTIntegerDataType, sizeof(char), NSHostByteOrder()) shape:nil]; XCTAssertEqual([nd numberOfSamples], nElems, @"numberOfSamples == nElems"); @@ -197,7 +197,7 @@ -(void)testDataTypeAccessorsCorrectForDataType } CPTNumericData *nd = [[CPTNumericData alloc] initWithData:data - dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder() ) + dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder()) shape:nil]; XCTAssertEqual([nd dataTypeFormat], CPTFloatingPointDataType, @"dataTypeFormat"); @@ -216,7 +216,7 @@ -(void)testConvertTypeConvertsType } CPTNumericData *fd = [[CPTNumericData alloc] initWithData:data - dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder() ) + dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder()) shape:nil]; CPTNumericData *dd = [fd dataByConvertingToType:CPTFloatingPointDataType @@ -225,7 +225,7 @@ -(void)testConvertTypeConvertsType const double *doubleSamples = (const double *)dd.data.bytes; for ( NSUInteger i = 0; i < numberOfSamples; i++ ) { - XCTAssertTrue( (double)samples[i] == doubleSamples[i], @"(float)%g != (double)%g", (double)samples[i], doubleSamples[i] ); + XCTAssertTrue((double)samples[i] == doubleSamples[i], @"(float)%g != (double)%g", (double)samples[i], doubleSamples[i]); } } @@ -240,12 +240,12 @@ -(void)testSamplePointerCorrect } CPTNumericData *fd = [[CPTNumericData alloc] initWithData:data - dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder() ) + dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder()) shape:nil]; - XCTAssertEqual( ( (const float *)[fd.data bytes] ) + 4, (const float *)[fd samplePointer:4], @"%p,%p", samples + 4, (const float *)[fd samplePointer:4] ); - XCTAssertEqual( ( (const float *)[fd.data bytes] ), (const float *)[fd samplePointer:0], @"" ); - XCTAssertEqual( ( (const float *)[fd.data bytes] ) + nElems - 1, (const float *)[fd samplePointer:nElems - 1], @"" ); + XCTAssertEqual(((const float *)[fd.data bytes]) + 4, (const float *)[fd samplePointer:4], @"%p,%p", samples + 4, (const float *)[fd samplePointer:4]); + XCTAssertEqual(((const float *)[fd.data bytes]), (const float *)[fd samplePointer:0], @""); + XCTAssertEqual(((const float *)[fd.data bytes]) + nElems - 1, (const float *)[fd samplePointer:nElems - 1], @""); XCTAssertNil([fd samplePointer:nElems], @"too many samples"); } @@ -260,7 +260,7 @@ -(void)testSampleValueCorrect } CPTNumericData *fd = [[CPTNumericData alloc] initWithData:data - dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder() ) + dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder()) shape:nil]; XCTAssertEqualWithAccuracy([[fd sampleValue:0] doubleValue], sin(0), 0.01, @"sample value"); @@ -280,16 +280,16 @@ -(void)testSampleIndexRowsFirstOrder } CPTNumericData *fd = [[CPTNumericData alloc] initWithData:data - dataType:CPTDataType(CPTFloatingPointDataType, sizeof(NSUInteger), NSHostByteOrder() ) + dataType:CPTDataType(CPTFloatingPointDataType, sizeof(NSUInteger), NSHostByteOrder()) shape:@[@(rows), @(cols)] dataOrder:CPTDataOrderRowsFirst]; - XCTAssertEqual( ([fd sampleIndex:rows, 0]), (NSUInteger)NSNotFound, @"row index out of range" ); - XCTAssertEqual( ([fd sampleIndex:0, cols]), (NSUInteger)NSNotFound, @"column index out of range" ); + XCTAssertEqual(([fd sampleIndex:rows, 0]), (NSUInteger)NSNotFound, @"row index out of range"); + XCTAssertEqual(([fd sampleIndex:0, cols]), (NSUInteger)NSNotFound, @"column index out of range"); for ( NSUInteger i = 0; i < rows; i++ ) { for ( NSUInteger j = 0; j < cols; j++ ) { - XCTAssertEqual( ([fd sampleIndex:i, j]), i * cols + j, @"(%lu, %lu)", (unsigned long)i, (unsigned long)j ); + XCTAssertEqual(([fd sampleIndex:i, j]), i * cols + j, @"(%lu, %lu)", (unsigned long)i, (unsigned long)j); } } } @@ -307,16 +307,16 @@ -(void)testSampleIndexColumnsFirstOrder } CPTNumericData *fd = [[CPTNumericData alloc] initWithData:data - dataType:CPTDataType(CPTFloatingPointDataType, sizeof(NSUInteger), NSHostByteOrder() ) + dataType:CPTDataType(CPTFloatingPointDataType, sizeof(NSUInteger), NSHostByteOrder()) shape:@[@(rows), @(cols)] dataOrder:CPTDataOrderColumnsFirst]; - XCTAssertEqual( ([fd sampleIndex:rows, 0]), (NSUInteger)NSNotFound, @"row index out of range" ); - XCTAssertEqual( ([fd sampleIndex:0, cols]), (NSUInteger)NSNotFound, @"column index out of range" ); + XCTAssertEqual(([fd sampleIndex:rows, 0]), (NSUInteger)NSNotFound, @"row index out of range"); + XCTAssertEqual(([fd sampleIndex:0, cols]), (NSUInteger)NSNotFound, @"column index out of range"); for ( NSUInteger i = 0; i < rows; i++ ) { for ( NSUInteger j = 0; j < cols; j++ ) { - XCTAssertEqual( ([fd sampleIndex:i, j]), i + j * rows, @"(%lu, %lu)", (unsigned long)i, (unsigned long)j ); + XCTAssertEqual(([fd sampleIndex:i, j]), i + j * rows, @"(%lu, %lu)", (unsigned long)i, (unsigned long)j); } } } diff --git a/CorePlot/framework/Source/CPTNumericDataType.h b/CorePlot/framework/Source/CPTNumericDataType.h old mode 100755 new mode 100644 index b629c7b..bee6089 --- a/CorePlot/framework/Source/CPTNumericDataType.h +++ b/CorePlot/framework/Source/CPTNumericDataType.h @@ -16,7 +16,7 @@ typedef NS_ENUM (NSInteger, CPTDataTypeFormat) { * @brief Enumeration of memory arrangements for multi-dimensional data arrays. * @see See Wikipedia for more information. **/ -typedef NS_ENUM (NSInteger, CPTDataOrder) { +typedef NS_CLOSED_ENUM (NSInteger, CPTDataOrder) { CPTDataOrderRowsFirst, ///< Numeric data is arranged in row-major order. CPTDataOrderColumnsFirst ///< Numeric data is arranged in column-major order. }; diff --git a/CorePlot/framework/Source/CPTNumericDataType.m b/CorePlot/framework/Source/CPTNumericDataType.m old mode 100755 new mode 100644 index e2ab630..af09806 --- a/CorePlot/framework/Source/CPTNumericDataType.m +++ b/CorePlot/framework/Source/CPTNumericDataType.m @@ -161,14 +161,14 @@ case sizeof(double): case sizeof(float complex): case sizeof(double complex): // only the native byte order is supported - valid = (format.byteOrder == CFByteOrderGetCurrent() ); + valid = (format.byteOrder == CFByteOrderGetCurrent()); break; } break; case CPTDecimalDataType: // only the native byte order is supported - valid = (format.sampleBytes == sizeof(NSDecimal) ) && (format.byteOrder == CFByteOrderGetCurrent() ); + valid = (format.sampleBytes == sizeof(NSDecimal)) && (format.byteOrder == CFByteOrderGetCurrent()); break; } diff --git a/CorePlot/framework/Source/CPTNumericDataTypeConversionPerformanceTests.h b/CorePlot/framework/Source/CPTNumericDataTypeConversionPerformanceTests.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTNumericDataTypeConversionPerformanceTests.m b/CorePlot/framework/Source/CPTNumericDataTypeConversionPerformanceTests.m old mode 100755 new mode 100644 index 31f5cf2..431999f --- a/CorePlot/framework/Source/CPTNumericDataTypeConversionPerformanceTests.m +++ b/CorePlot/framework/Source/CPTNumericDataTypeConversionPerformanceTests.m @@ -17,7 +17,7 @@ -(void)testFloatToDoubleConversion } CPTNumericData *floatNumericData = [[CPTNumericData alloc] initWithData:data - dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), CFByteOrderGetCurrent() ) + dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), CFByteOrderGetCurrent()) shape:nil]; __block CPTNumericData *doubleNumericData = nil; @@ -37,7 +37,7 @@ -(void)testDoubleToFloatConversion } CPTNumericData *doubleNumericData = [[CPTNumericData alloc] initWithData:data - dataType:CPTDataType(CPTFloatingPointDataType, sizeof(double), CFByteOrderGetCurrent() ) + dataType:CPTDataType(CPTFloatingPointDataType, sizeof(double), CFByteOrderGetCurrent()) shape:nil]; __block CPTNumericData *floatNumericData = nil; @@ -57,7 +57,7 @@ -(void)testIntegerToDoubleConversion } CPTNumericData *integerNumericData = [[CPTNumericData alloc] initWithData:data - dataType:CPTDataType(CPTIntegerDataType, sizeof(NSInteger), CFByteOrderGetCurrent() ) + dataType:CPTDataType(CPTIntegerDataType, sizeof(NSInteger), CFByteOrderGetCurrent()) shape:nil]; __block CPTNumericData *doubleNumericData = nil; @@ -77,7 +77,7 @@ -(void)testDoubleToIntegerConversion } CPTNumericData *doubleNumericData = [[CPTNumericData alloc] initWithData:data - dataType:CPTDataType(CPTFloatingPointDataType, sizeof(double), CFByteOrderGetCurrent() ) + dataType:CPTDataType(CPTFloatingPointDataType, sizeof(double), CFByteOrderGetCurrent()) shape:nil]; __block CPTNumericData *integerNumericData = nil; diff --git a/CorePlot/framework/Source/CPTNumericDataTypeConversionTests.h b/CorePlot/framework/Source/CPTNumericDataTypeConversionTests.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTNumericDataTypeConversionTests.m b/CorePlot/framework/Source/CPTNumericDataTypeConversionTests.m old mode 100755 new mode 100644 index 92fafba..8fc2153 --- a/CorePlot/framework/Source/CPTNumericDataTypeConversionTests.m +++ b/CorePlot/framework/Source/CPTNumericDataTypeConversionTests.m @@ -18,7 +18,7 @@ -(void)testFloatToDoubleConversion } CPTNumericData *fd = [[CPTNumericData alloc] initWithData:data - dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder() ) + dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder()) shape:nil]; CPTNumericData *dd = [fd dataByConvertingToType:CPTFloatingPointDataType @@ -27,7 +27,7 @@ -(void)testFloatToDoubleConversion const double *doubleSamples = (const double *)dd.data.bytes; for ( NSUInteger i = 0; i < numberOfSamples; i++ ) { - XCTAssertEqualWithAccuracy( (double)samples[i], doubleSamples[i], precision, @"(float)%g != (double)%g", (double)samples[i], doubleSamples[i] ); + XCTAssertEqualWithAccuracy((double)samples[i], doubleSamples[i], precision, @"(float)%g != (double)%g", (double)samples[i], doubleSamples[i]); } } @@ -41,7 +41,7 @@ -(void)testDoubleToFloatConversion } CPTNumericData *dd = [[CPTNumericData alloc] initWithData:data - dataType:CPTDataType(CPTFloatingPointDataType, sizeof(double), NSHostByteOrder() ) + dataType:CPTDataType(CPTFloatingPointDataType, sizeof(double), NSHostByteOrder()) shape:nil]; CPTNumericData *fd = [dd dataByConvertingToType:CPTFloatingPointDataType @@ -50,7 +50,7 @@ -(void)testDoubleToFloatConversion const float *floatSamples = (const float *)fd.data.bytes; for ( NSUInteger i = 0; i < numberOfSamples; i++ ) { - XCTAssertEqualWithAccuracy( (double)floatSamples[i], samples[i], precision, @"(float)%g != (double)%g", (double)floatSamples[i], samples[i] ); + XCTAssertEqualWithAccuracy((double)floatSamples[i], samples[i], precision, @"(float)%g != (double)%g", (double)floatSamples[i], samples[i]); } } @@ -64,7 +64,7 @@ -(void)testFloatToIntegerConversion } CPTNumericData *fd = [[CPTNumericData alloc] initWithData:data - dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder() ) + dataType:CPTDataType(CPTFloatingPointDataType, sizeof(float), NSHostByteOrder()) shape:nil]; CPTNumericData *intData = [fd dataByConvertingToType:CPTIntegerDataType @@ -73,7 +73,7 @@ -(void)testFloatToIntegerConversion const NSInteger *intSamples = (const NSInteger *)intData.data.bytes; for ( NSUInteger i = 0; i < numberOfSamples; i++ ) { - XCTAssertEqualWithAccuracy( (NSInteger)samples[i], intSamples[i], precision, @"(float)%g != (NSInteger)%ld", (double)samples[i], (long)intSamples[i] ); + XCTAssertEqualWithAccuracy((NSInteger)samples[i], intSamples[i], precision, @"(float)%g != (NSInteger)%ld", (double)samples[i], (long)intSamples[i]); } } @@ -87,7 +87,7 @@ -(void)testIntegerToFloatConversion } CPTNumericData *intData = [[CPTNumericData alloc] initWithData:data - dataType:CPTDataType(CPTIntegerDataType, sizeof(NSInteger), NSHostByteOrder() ) + dataType:CPTDataType(CPTIntegerDataType, sizeof(NSInteger), NSHostByteOrder()) shape:nil]; CPTNumericData *fd = [intData dataByConvertingToType:CPTFloatingPointDataType @@ -136,11 +136,11 @@ -(void)testDecimalToDoubleConversion NSDecimal *samples = (NSDecimal *)data.mutableBytes; for ( NSUInteger i = 0; i < numberOfSamples; i++ ) { - samples[i] = CPTDecimalFromDouble(sin(i) ); + samples[i] = CPTDecimalFromDouble(sin(i)); } CPTNumericData *decimalData = [[CPTNumericData alloc] initWithData:data - dataType:CPTDataType(CPTDecimalDataType, sizeof(NSDecimal), NSHostByteOrder() ) + dataType:CPTDataType(CPTDecimalDataType, sizeof(NSDecimal), NSHostByteOrder()) shape:nil]; CPTNumericData *doubleData = [decimalData dataByConvertingToType:CPTFloatingPointDataType @@ -163,7 +163,7 @@ -(void)testDoubleToDecimalConversion } CPTNumericData *doubleData = [[CPTNumericData alloc] initWithData:data - dataType:CPTDataType(CPTFloatingPointDataType, sizeof(double), NSHostByteOrder() ) + dataType:CPTDataType(CPTFloatingPointDataType, sizeof(double), NSHostByteOrder()) shape:nil]; CPTNumericData *decimalData = [doubleData dataByConvertingToType:CPTDecimalDataType @@ -172,7 +172,7 @@ -(void)testDoubleToDecimalConversion const NSDecimal *decimalSamples = (const NSDecimal *)decimalData.data.bytes; for ( NSUInteger i = 0; i < numberOfSamples; i++ ) { - XCTAssertTrue(CPTDecimalEquals(decimalSamples[i], CPTDecimalFromDouble(samples[i]) ), @"(NSDecimal)%@ != (double)%g", CPTDecimalStringValue(decimalSamples[i]), samples[i]); + XCTAssertTrue(CPTDecimalEquals(decimalSamples[i], CPTDecimalFromDouble(samples[i])), @"(NSDecimal)%@ != (double)%g", CPTDecimalStringValue(decimalSamples[i]), samples[i]); } } @@ -220,7 +220,7 @@ -(void)testRoundTripToDoubleArray for ( NSUInteger i = 0; i < numberOfSamples; i++ ) { samples[i] = sin(i); } - CPTNumericDataType theDataType = CPTDataType(CPTFloatingPointDataType, sizeof(double), NSHostByteOrder() ); + CPTNumericDataType theDataType = CPTDataType(CPTFloatingPointDataType, sizeof(double), NSHostByteOrder()); CPTNumericData *doubleData = [[CPTNumericData alloc] initWithData:data dataType:theDataType @@ -248,7 +248,7 @@ -(void)testRoundTripToIntegerArray for ( NSUInteger i = 0; i < numberOfSamples; i++ ) { samples[i] = (NSInteger)(sin(i) * 1000.0); } - CPTNumericDataType theDataType = CPTDataType(CPTIntegerDataType, sizeof(NSInteger), NSHostByteOrder() ); + CPTNumericDataType theDataType = CPTDataType(CPTIntegerDataType, sizeof(NSInteger), NSHostByteOrder()); CPTNumericData *intData = [[CPTNumericData alloc] initWithData:data dataType:theDataType @@ -274,9 +274,9 @@ -(void)testRoundTripToDecimalArray NSDecimal *samples = (NSDecimal *)data.mutableBytes; for ( NSUInteger i = 0; i < numberOfSamples; i++ ) { - samples[i] = CPTDecimalFromDouble(sin(i) ); + samples[i] = CPTDecimalFromDouble(sin(i)); } - CPTNumericDataType theDataType = CPTDataType(CPTDecimalDataType, sizeof(NSDecimal), NSHostByteOrder() ); + CPTNumericDataType theDataType = CPTDataType(CPTDecimalDataType, sizeof(NSDecimal), NSHostByteOrder()); CPTNumericData *decimalData = [[CPTNumericData alloc] initWithData:data dataType:theDataType diff --git a/CorePlot/framework/Source/CPTPathExtensions.h b/CorePlot/framework/Source/CPTPathExtensions.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTPathExtensions.m b/CorePlot/framework/Source/CPTPathExtensions.m old mode 100755 new mode 100644 index 62ab596..fbd20d9 --- a/CorePlot/framework/Source/CPTPathExtensions.m +++ b/CorePlot/framework/Source/CPTPathExtensions.m @@ -10,8 +10,8 @@ **/ __nonnull CGPathRef CPTCreateRoundedRectPath(CGRect rect, CGFloat cornerRadius) { - if ( cornerRadius > CPTFloat(0.0) ) { - cornerRadius = MIN(MIN(cornerRadius, rect.size.width * CPTFloat(0.5) ), rect.size.height * CPTFloat(0.5) ); + if ( cornerRadius > CPTFloat(0.0)) { + cornerRadius = MIN(MIN(cornerRadius, rect.size.width * CPTFloat(0.5)), rect.size.height * CPTFloat(0.5)); // CGPathCreateWithRoundedRect() is available in macOS 10.9 and iOS 7 but not marked in the header file #pragma clang diagnostic push diff --git a/CorePlot/framework/Source/CPTPieChart.h b/CorePlot/framework/Source/CPTPieChart.h old mode 100755 new mode 100644 index e7aeb6e..079cac2 --- a/CorePlot/framework/Source/CPTPieChart.h +++ b/CorePlot/framework/Source/CPTPieChart.h @@ -33,7 +33,7 @@ typedef NS_ENUM (NSInteger, CPTPieChartField) { /** * @brief Enumeration of pie slice drawing directions. **/ -typedef NS_ENUM (NSInteger, CPTPieDirection) { +typedef NS_CLOSED_ENUM (NSInteger, CPTPieDirection) { CPTPieDirectionClockwise, ///< Pie slices are drawn in a clockwise direction. CPTPieDirectionCounterClockwise ///< Pie slices are drawn in a counter-clockwise direction. }; diff --git a/CorePlot/framework/Source/CPTPieChart.m b/CorePlot/framework/Source/CPTPieChart.m old mode 100755 new mode 100644 index c211102..83bbda7 --- a/CorePlot/framework/Source/CPTPieChart.m +++ b/CorePlot/framework/Source/CPTPieChart.m @@ -160,9 +160,9 @@ @implementation CPTPieChart +(nonnull CPTColor *)defaultPieSliceColorForIndex:(NSUInteger)pieSliceIndex { - return [CPTColor colorWithComponentRed:(colorLookupTable[pieSliceIndex % 10][0] + (CGFloat)(pieSliceIndex / 10) * CPTFloat(0.1) ) - green:(colorLookupTable[pieSliceIndex % 10][1] + (CGFloat)(pieSliceIndex / 10) * CPTFloat(0.1) ) - blue:(colorLookupTable[pieSliceIndex % 10][2] + (CGFloat)(pieSliceIndex / 10) * CPTFloat(0.1) ) + return [CPTColor colorWithComponentRed:(colorLookupTable[pieSliceIndex % 10][0] + (CGFloat)(pieSliceIndex / 10) * CPTFloat(0.1)) + green:(colorLookupTable[pieSliceIndex % 10][1] + (CGFloat)(pieSliceIndex / 10) * CPTFloat(0.1)) + blue:(colorLookupTable[pieSliceIndex % 10][2] + (CGFloat)(pieSliceIndex / 10) * CPTFloat(0.1)) alpha:CPTFloat(1.0)]; } @@ -209,8 +209,8 @@ +(void)initialize **/ -(nonnull instancetype)initWithFrame:(CGRect)newFrame { - if ( (self = [super initWithFrame:newFrame]) ) { - pieRadius = CPTFloat(0.8) * (MIN(newFrame.size.width, newFrame.size.height) / CPTFloat(2.0) ); + if ((self = [super initWithFrame:newFrame])) { + pieRadius = CPTFloat(0.8) * (MIN(newFrame.size.width, newFrame.size.height) / CPTFloat(2.0)); pieInnerRadius = CPTFloat(0.0); startAngle = CPTFloat(M_PI_2); // pi/2 endAngle = CPTNAN; @@ -233,7 +233,7 @@ -(nonnull instancetype)initWithFrame:(CGRect)newFrame -(nonnull instancetype)initWithLayer:(nonnull id)layer { - if ( (self = [super initWithLayer:layer]) ) { + if ((self = [super initWithLayer:layer])) { CPTPieChart *theLayer = (CPTPieChart *)layer; pieRadius = theLayer->pieRadius; @@ -277,7 +277,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super initWithCoder:coder]) ) { + if ((self = [super initWithCoder:coder])) { pieRadius = [coder decodeCGFloatForKey:@"CPTPieChart.pieRadius"]; pieInnerRadius = [coder decodeCGFloatForKey:@"CPTPieChart.pieInnerRadius"]; startAngle = [coder decodeCGFloatForKey:@"CPTPieChart.startAngle"]; @@ -385,12 +385,12 @@ -(void)updateNormalizedData const double *dataEnd = dataBytes + sampleCount; while ( dataBytes < dataEnd ) { double currentWidth = *dataBytes++; - if ( !isnan(currentWidth) ) { + if ( !isnan(currentWidth)) { valueSum += currentWidth; } } - CPTNumericDataType dataType = CPTDataType(CPTFloatingPointDataType, sizeof(double), CFByteOrderGetCurrent() ); + CPTNumericDataType dataType = CPTDataType(CPTFloatingPointDataType, sizeof(double), CFByteOrderGetCurrent()); CPTMutableNumericData *normalizedSliceValues = [[CPTMutableNumericData alloc] initWithData:[NSData data] dataType:dataType shape:nil]; normalizedSliceValues.shape = @[@(sampleCount)]; @@ -404,7 +404,7 @@ -(void)updateNormalizedData double *cumulativeBytes = cumulativeSliceValues.mutableBytes; while ( dataBytes < dataEnd ) { double currentWidth = *dataBytes++; - if ( isnan(currentWidth) ) { + if ( isnan(currentWidth)) { *normalizedBytes++ = (double)NAN; } else { @@ -422,12 +422,12 @@ -(void)updateNormalizedData const NSDecimal *dataEnd = dataBytes + sampleCount; while ( dataBytes < dataEnd ) { NSDecimal currentWidth = *dataBytes++; - if ( !NSDecimalIsNotANumber(¤tWidth) ) { + if ( !NSDecimalIsNotANumber(¤tWidth)) { valueSum = CPTDecimalAdd(valueSum, currentWidth); } } - CPTNumericDataType dataType = CPTDataType(CPTDecimalDataType, sizeof(NSDecimal), CFByteOrderGetCurrent() ); + CPTNumericDataType dataType = CPTDataType(CPTDecimalDataType, sizeof(NSDecimal), CFByteOrderGetCurrent()); CPTMutableNumericData *normalizedSliceValues = [[CPTMutableNumericData alloc] initWithData:[NSData data] dataType:dataType shape:nil]; normalizedSliceValues.shape = @[@(sampleCount)]; @@ -442,7 +442,7 @@ -(void)updateNormalizedData NSDecimal *cumulativeBytes = cumulativeSliceValues.mutableBytes; while ( dataBytes < dataEnd ) { NSDecimal currentWidth = *dataBytes++; - if ( NSDecimalIsNotANumber(¤tWidth) ) { + if ( NSDecimalIsNotANumber(¤tWidth)) { *normalizedBytes++ = decimalNAN; } else { @@ -597,7 +597,7 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context BOOL hasNonZeroOffsets = NO; CPTNumberArray *offsetArray = [self cachedArrayForKey:CPTPieChartBindingPieSliceRadialOffsets]; for ( NSNumber *offset in offsetArray ) { - if ( [offset cgFloatValue] != CPTFloat(0.0) ) { + if ( [offset cgFloatValue] != CPTFloat(0.0)) { hasNonZeroOffsets = YES; break; } @@ -607,7 +607,7 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context if ( overlay && hasNonZeroOffsets ) { CGFloat radius = self.pieRadius + borderStyle.lineWidth * CPTFloat(0.5); - bounds = CPTRectMake(centerPoint.x - radius, centerPoint.y - radius, radius * CPTFloat(2.0), radius * CPTFloat(2.0) ); + bounds = CPTRectMake(centerPoint.x - radius, centerPoint.y - radius, radius * CPTFloat(2.0), radius * CPTFloat(2.0)); } else { bounds = CGRectZero; @@ -619,7 +619,7 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context while ( currentIndex < sampleCount ) { CGFloat currentWidth = (CGFloat)[self cachedDoubleForField:CPTPieChartFieldSliceWidthNormalized recordIndex:currentIndex]; - if ( !isnan(currentWidth) ) { + if ( !isnan(currentWidth)) { CGFloat radialOffset = [(NSNumber *) offsetArray[currentIndex] cgFloatValue]; // draw slice @@ -631,7 +631,7 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context CGFloat xOffset = CPTFloat(0.0); CGFloat yOffset = CPTFloat(0.0); CGPoint center = centerPoint; - if ( radialOffset != CPTFloat(0.0) ) { + if ( radialOffset != CPTFloat(0.0)) { CGFloat medianAngle = CPTFloat(0.5) * (startingAngle + finishingAngle); xOffset = cos(medianAngle) * radialOffset; yOffset = sin(medianAngle) * radialOffset; @@ -689,7 +689,7 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context CGMutablePathRef fillPath = CGPathCreateMutable(); CGFloat innerRadius = self.pieInnerRadius; - if ( innerRadius > CPTFloat(0.0) ) { + if ( innerRadius > CPTFloat(0.0)) { CGPathAddArc(fillPath, NULL, centerPoint.x, centerPoint.y, self.pieRadius, CPTFloat(0.0), CPTFloat(2.0 * M_PI), false); CGPathAddArc(fillPath, NULL, centerPoint.x, centerPoint.y, innerRadius, CPTFloat(2.0 * M_PI), CPTFloat(0.0), true); } @@ -724,7 +724,7 @@ -(CGFloat)radiansForPieSliceValue:(CGFloat)pieSliceValue angle += pieSliceValue * pieRange; break; } - return isnan(endingAngle) ? angle : fmod(angle, CPTFloat(2.0 * M_PI) ); + return isnan(endingAngle) ? angle : fmod(angle, CPTFloat(2.0 * M_PI)); } -(void)addSliceToPath:(nonnull CGMutablePathRef)slicePath centerPoint:(CGPoint)center startingAngle:(CGFloat)startingAngle finishingAngle:(CGFloat)finishingAngle width:(CGFloat)currentWidth @@ -733,8 +733,8 @@ -(void)addSliceToPath:(nonnull CGMutablePathRef)slicePath centerPoint:(CGPoint)c CGFloat outerRadius = self.pieRadius; CGFloat innerRadius = self.pieInnerRadius; - if ( innerRadius > CPTFloat(0.0) ) { - if ( currentWidth >= CPTFloat(1.0) ) { + if ( innerRadius > CPTFloat(0.0)) { + if ( currentWidth >= CPTFloat(1.0)) { CGPathAddArc(slicePath, NULL, center.x, center.y, outerRadius, startingAngle, startingAngle + CPTFloat(2.0 * M_PI), direction); CGPathAddArc(slicePath, NULL, center.x, center.y, innerRadius, startingAngle + CPTFloat(2.0 * M_PI), startingAngle, !direction); } @@ -744,8 +744,8 @@ -(void)addSliceToPath:(nonnull CGMutablePathRef)slicePath centerPoint:(CGPoint)c } } else { - if ( currentWidth >= CPTFloat(1.0) ) { - CGPathAddEllipseInRect(slicePath, NULL, CGRectMake(center.x - outerRadius, center.y - outerRadius, outerRadius * CPTFloat(2.0), outerRadius * CPTFloat(2.0) ) ); + if ( currentWidth >= CPTFloat(1.0)) { + CGPathAddEllipseInRect(slicePath, NULL, CGRectMake(center.x - outerRadius, center.y - outerRadius, outerRadius * CPTFloat(2.0), outerRadius * CPTFloat(2.0))); } else { CGPathMoveToPoint(slicePath, NULL, center.x, center.y); @@ -759,7 +759,7 @@ -(nullable CPTFill *)sliceFillForIndex:(NSUInteger)idx { CPTFill *currentFill = [self cachedValueForKey:CPTPieChartBindingPieSliceFills recordIndex:idx]; - if ( (currentFill == nil) || (currentFill == [CPTPlot nilData]) ) { + if ((currentFill == nil) || (currentFill == [CPTPlot nilData])) { currentFill = [CPTFill fillWithColor:[CPTPieChart defaultPieSliceColorForIndex:idx]]; } @@ -813,7 +813,7 @@ -(NSUInteger)pieSliceIndexAtAngle:(CGFloat)angle // of that pie slice. for ( NSUInteger currentIndex = 0; currentIndex < self.cachedDataCount; currentIndex++ ) { CGFloat width = CPTFloat([self cachedDoubleForField:CPTPieChartFieldSliceWidthNormalized recordIndex:currentIndex]); - if ( isnan(width) ) { + if ( isnan(width)) { continue; } CGFloat endingAngle = startingAngle; @@ -858,7 +858,7 @@ -(CGFloat)medianAngleForPieSliceIndex:(NSUInteger)idx CGFloat currentWidth = CPTFloat([self cachedDoubleForField:CPTPieChartFieldSliceWidthNormalized recordIndex:currentIndex]); // If the slice index is a match... - if ( !isnan(currentWidth) && (idx == currentIndex) ) { + if ( !isnan(currentWidth) && (idx == currentIndex)) { // Compute and return the angle that is halfway between the slice's starting and ending angles CGFloat startingAngle = [self radiansForPieSliceValue:startingWidth]; CGFloat finishingAngle = [self radiansForPieSliceValue:startingWidth + currentWidth]; @@ -940,7 +940,7 @@ -(void)positionLabelAnnotation:(nonnull CPTPlotSpaceAnnotation *)label forIndex: label.anchorPlotPoint = @[xValue, yValue]; CGFloat currentWidth = (CGFloat)[self cachedDoubleForField:CPTPieChartFieldSliceWidthNormalized recordIndex:idx]; - if ( self.hidden || isnan(currentWidth) ) { + if ( self.hidden || isnan(currentWidth)) { contentLayer.hidden = YES; } else { @@ -953,11 +953,11 @@ -(void)positionLabelAnnotation:(nonnull CPTPlotSpaceAnnotation *)label forIndex: } CGFloat labelAngle = [self radiansForPieSliceValue:startingWidth + currentWidth / CPTFloat(2.0)]; - label.displacement = CPTPointMake(labelRadius * cos(labelAngle), labelRadius * sin(labelAngle) ); + label.displacement = CPTPointMake(labelRadius * cos(labelAngle), labelRadius * sin(labelAngle)); if ( self.labelRotationRelativeToRadius ) { CGFloat rotation = [self normalizedPosition:self.labelRotation + labelAngle]; - if ( (rotation > CPTFloat(0.25) ) && (rotation < CPTFloat(0.75) ) ) { + if ((rotation > CPTFloat(0.25)) && (rotation < CPTFloat(0.75))) { rotation -= CPTFloat(0.5); } @@ -1044,8 +1044,8 @@ -(CGFloat)normalizedPosition:(CGFloat)rawPosition CGFloat result = rawPosition; result /= (CGFloat)(2.0 * M_PI); - result = fmod(result, CPTFloat(1.0) ); - if ( result < CPTFloat(0.0) ) { + result = fmod(result, CPTFloat(1.0)); + if ( result < CPTFloat(0.0)) { result += CPTFloat(1.0); } @@ -1056,19 +1056,19 @@ -(BOOL)angle:(CGFloat)touchedAngle betweenStartAngle:(CGFloat)startingAngle endA { switch ( self.sliceDirection ) { case CPTPieDirectionClockwise: - if ( (touchedAngle <= startingAngle) && (touchedAngle >= endingAngle) ) { + if ((touchedAngle <= startingAngle) && (touchedAngle >= endingAngle)) { return YES; } - else if ( (endingAngle < CPTFloat(0.0) ) && (touchedAngle - CPTFloat(1.0) >= endingAngle) ) { + else if ((endingAngle < CPTFloat(0.0)) && (touchedAngle - CPTFloat(1.0) >= endingAngle)) { return YES; } break; case CPTPieDirectionCounterClockwise: - if ( (touchedAngle >= startingAngle) && (touchedAngle <= endingAngle) ) { + if ((touchedAngle >= startingAngle) && (touchedAngle <= endingAngle)) { return YES; } - else if ( (endingAngle > CPTFloat(1.0) ) && (touchedAngle + CPTFloat(1.0) <= endingAngle) ) { + else if ((endingAngle > CPTFloat(1.0)) && (touchedAngle + CPTFloat(1.0) <= endingAngle)) { return YES; } break; @@ -1260,17 +1260,17 @@ -(NSUInteger)dataIndexFromInteractionPoint:(CGPoint)point switch ( self.sliceDirection ) { case CPTPieDirectionClockwise: - if ( isnan(theEndAngle) || (CPTFloat(2.0 * M_PI) == ABS(theEndAngle - theStartAngle) ) ) { + if ( isnan(theEndAngle) || (CPTFloat(2.0 * M_PI) == ABS(theEndAngle - theStartAngle))) { widthFactor = CPTFloat(1.0); } else { - widthFactor = CPTFloat(2.0 * M_PI) / (CPTFloat(2.0 * M_PI) - ABS(theEndAngle - theStartAngle) ); + widthFactor = CPTFloat(2.0 * M_PI) / (CPTFloat(2.0 * M_PI) - ABS(theEndAngle - theStartAngle)); } for ( NSUInteger currentIndex = 0; currentIndex < sampleCount; currentIndex++ ) { // calculate angles for this slice CGFloat width = (CGFloat)[self cachedDoubleForField:CPTPieChartFieldSliceWidthNormalized recordIndex:currentIndex]; - if ( isnan(width) ) { + if ( isnan(width)) { continue; } @@ -1282,7 +1282,7 @@ -(NSUInteger)dataIndexFromInteractionPoint:(CGPoint)point CGFloat offsetTouchedAngle = touchedAngle; CGFloat offsetDistanceSquared = distanceSquared; CGFloat radialOffset = [(NSNumber *)[self cachedValueForKey:CPTPieChartBindingPieSliceRadialOffsets recordIndex:currentIndex] cgFloatValue]; - if ( radialOffset != CPTFloat(0.0) ) { + if ( radialOffset != CPTFloat(0.0)) { CGPoint offsetCenter; CGFloat medianAngle = CPTFloat(M_PI) * (startingAngle + endingAngle); offsetCenter = CPTPointMake(centerPoint.x + cos(medianAngle) * radialOffset, @@ -1307,7 +1307,7 @@ -(NSUInteger)dataIndexFromInteractionPoint:(CGPoint)point } // check distance - if ( angleInSlice && (offsetDistanceSquared >= chartInnerRadiusSquared) && (offsetDistanceSquared <= chartRadiusSquared) ) { + if ( angleInSlice && (offsetDistanceSquared >= chartInnerRadiusSquared) && (offsetDistanceSquared <= chartRadiusSquared)) { return currentIndex; } @@ -1317,7 +1317,7 @@ -(NSUInteger)dataIndexFromInteractionPoint:(CGPoint)point break; case CPTPieDirectionCounterClockwise: - if ( isnan(theEndAngle) || (theStartAngle == theEndAngle) ) { + if ( isnan(theEndAngle) || (theStartAngle == theEndAngle)) { widthFactor = CPTFloat(1.0); } else { @@ -1327,7 +1327,7 @@ -(NSUInteger)dataIndexFromInteractionPoint:(CGPoint)point for ( NSUInteger currentIndex = 0; currentIndex < sampleCount; currentIndex++ ) { // calculate angles for this slice CGFloat width = (CGFloat)[self cachedDoubleForField:CPTPieChartFieldSliceWidthNormalized recordIndex:currentIndex]; - if ( isnan(width) ) { + if ( isnan(width)) { continue; } width /= widthFactor; @@ -1338,7 +1338,7 @@ -(NSUInteger)dataIndexFromInteractionPoint:(CGPoint)point CGFloat offsetTouchedAngle = touchedAngle; CGFloat offsetDistanceSquared = distanceSquared; CGFloat radialOffset = [(NSNumber *)[self cachedValueForKey:CPTPieChartBindingPieSliceRadialOffsets recordIndex:currentIndex] cgFloatValue]; - if ( radialOffset != CPTFloat(0.0) ) { + if ( radialOffset != CPTFloat(0.0)) { CGPoint offsetCenter; CGFloat medianAngle = CPTFloat(M_PI) * (startingAngle + endingAngle); offsetCenter = CPTPointMake(centerPoint.x + cos(medianAngle) * radialOffset, @@ -1363,7 +1363,7 @@ -(NSUInteger)dataIndexFromInteractionPoint:(CGPoint)point } // check distance - if ( angleInSlice && (offsetDistanceSquared >= chartInnerRadiusSquared) && (offsetDistanceSquared <= chartRadiusSquared) ) { + if ( angleInSlice && (offsetDistanceSquared >= chartInnerRadiusSquared) && (offsetDistanceSquared <= chartRadiusSquared)) { return currentIndex; } @@ -1472,7 +1472,7 @@ -(void)setBorderLineStyle:(nullable CPTLineStyle *)newStyle -(void)setCenterAnchor:(CGPoint)newCenterAnchor { - if ( !CGPointEqualToPoint(centerAnchor, newCenterAnchor) ) { + if ( !CGPointEqualToPoint(centerAnchor, newCenterAnchor)) { centerAnchor = newCenterAnchor; [self setNeedsDisplay]; [self repositionAllLabelAnnotations]; diff --git a/CorePlot/framework/Source/CPTPlot.h b/CorePlot/framework/Source/CPTPlot.h old mode 100755 new mode 100644 index e0ed4c6..d9dd3d9 --- a/CorePlot/framework/Source/CPTPlot.h +++ b/CorePlot/framework/Source/CPTPlot.h @@ -332,9 +332,9 @@ typedef NSMutableArray<__kindof CPTPlot *> CPTMutablePlotArray; -(void)reloadDataInIndexRange:(NSRange)indexRange; -(void)insertDataAtIndex:(NSUInteger)idx numberOfRecords:(NSUInteger)numberOfRecords; -(void)deleteDataInIndexRange:(NSRange)indexRange; --(void) reloadPlotData NS_SWIFT_NAME(CPTPlot.reloadPlotData() ); +-(void) reloadPlotData NS_SWIFT_NAME(CPTPlot.reloadPlotData()); --(void)reloadPlotDataInIndexRange:(NSRange) indexRange NS_SWIFT_NAME(CPTPlot.reloadPlotData(inIndexRange:) ); +-(void)reloadPlotDataInIndexRange:(NSRange) indexRange NS_SWIFT_NAME(CPTPlot.reloadPlotData(inIndexRange:)); /// @} diff --git a/CorePlot/framework/Source/CPTPlot.m b/CorePlot/framework/Source/CPTPlot.m old mode 100755 new mode 100644 index c7fff7f..6798340 --- a/CorePlot/framework/Source/CPTPlot.m +++ b/CorePlot/framework/Source/CPTPlot.m @@ -292,7 +292,7 @@ +(void)initialize **/ -(nonnull instancetype)initWithFrame:(CGRect)newFrame { - if ( (self = [super initWithFrame:newFrame]) ) { + if ((self = [super initWithFrame:newFrame])) { cachedData = [[NSMutableDictionary alloc] initWithCapacity:5]; cachedDataCount = 0; cachePrecision = CPTPlotCachePrecisionAuto; @@ -330,7 +330,7 @@ -(nonnull instancetype)initWithFrame:(CGRect)newFrame -(nonnull instancetype)initWithLayer:(nonnull id)layer { - if ( (self = [super initWithLayer:layer]) ) { + if ((self = [super initWithLayer:layer])) { CPTPlot *theLayer = (CPTPlot *)layer; cachedData = theLayer->cachedData; @@ -404,7 +404,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super initWithCoder:coder]) ) { + if ((self = [super initWithCoder:coder])) { dataSource = [coder decodeObjectOfClass:[NSObject class] forKey:@"CPTPlot.dataSource"]; title = [[coder decodeObjectOfClass:[NSString class] @@ -855,7 +855,7 @@ -(BOOL)loadNumbersForAllFieldsFromDataSourceInRecordIndexRange:(NSRange)indexRan const NSUInteger sampleCount = data.numberOfSamples; CPTNumericDataType dataType = data.dataType; - if ( (sampleCount > 0) && (data.numberOfDimensions == 2) ) { + if ((sampleCount > 0) && (data.numberOfDimensions == 2)) { CPTNumberArray *theShape = data.shape; const NSUInteger rowCount = theShape[0].unsignedIntegerValue; const NSUInteger fieldCount = theShape[1].unsignedIntegerValue; @@ -865,14 +865,14 @@ -(BOOL)loadNumbersForAllFieldsFromDataSourceInRecordIndexRange:(NSRange)indexRan switch ( self.cachePrecision ) { case CPTPlotCachePrecisionAuto: if ( self.doublePrecisionCache ) { - if ( !CPTDataTypeEqualToDataType(dataType, self.doubleDataType) ) { + if ( !CPTDataTypeEqualToDataType(dataType, self.doubleDataType)) { CPTMutableNumericData *mutableData = [data mutableCopy]; mutableData.dataType = self.doubleDataType; data = mutableData; } } else { - if ( !CPTDataTypeEqualToDataType(dataType, self.decimalDataType) ) { + if ( !CPTDataTypeEqualToDataType(dataType, self.decimalDataType)) { CPTMutableNumericData *mutableData = [data mutableCopy]; mutableData.dataType = self.decimalDataType; data = mutableData; @@ -881,7 +881,7 @@ -(BOOL)loadNumbersForAllFieldsFromDataSourceInRecordIndexRange:(NSRange)indexRan break; case CPTPlotCachePrecisionDecimal: - if ( !CPTDataTypeEqualToDataType(dataType, self.decimalDataType) ) { + if ( !CPTDataTypeEqualToDataType(dataType, self.decimalDataType)) { CPTMutableNumericData *mutableData = [data mutableCopy]; mutableData.dataType = self.decimalDataType; data = mutableData; @@ -889,7 +889,7 @@ -(BOOL)loadNumbersForAllFieldsFromDataSourceInRecordIndexRange:(NSRange)indexRan break; case CPTPlotCachePrecisionDouble: - if ( !CPTDataTypeEqualToDataType(dataType, self.doubleDataType) ) { + if ( !CPTDataTypeEqualToDataType(dataType, self.doubleDataType)) { CPTMutableNumericData *mutableData = [data mutableCopy]; mutableData.dataType = self.doubleDataType; data = mutableData; @@ -908,7 +908,7 @@ -(BOOL)loadNumbersForAllFieldsFromDataSourceInRecordIndexRange:(NSRange)indexRan for ( NSUInteger fieldNum = 0; fieldNum < fieldCount; fieldNum++ ) { NSMutableData *tempData = [[NSMutableData alloc] initWithLength:bufferLength]; - if ( CPTDataTypeEqualToDataType(dataType, self.doubleDataType) ) { + if ( CPTDataTypeEqualToDataType(dataType, self.doubleDataType)) { const double *sourceData = [data samplePointerAtIndex:0, fieldNum]; double *destData = tempData.mutableBytes; @@ -1141,7 +1141,7 @@ -(void)cacheNumbers:(nullable id)numbers forField:(NSUInteger)fieldEnum atRecord break; } - if ( mutableNumbers && (sampleCount > 0) ) { + if ( mutableNumbers && (sampleCount > 0)) { // Ensure the data cache exists and is the right size CPTMutableNumericData *cachedNumbers = (self.cachedData)[cacheKey]; if ( !cachedNumbers ) { @@ -1180,7 +1180,7 @@ -(nonnull CPTMutableNumericData *)numericDataForNumbers:(nonnull id)numbers mutableNumbers = [numbers mutableCopy]; // ensure the numeric data is in a supported format; default to double if not already NSDecimal if ( !CPTDataTypeEqualToDataType(mutableNumbers.dataType, self.decimalDataType) && - !CPTDataTypeEqualToDataType(mutableNumbers.dataType, self.doubleDataType) ) { + !CPTDataTypeEqualToDataType(mutableNumbers.dataType, self.doubleDataType)) { mutableNumbers.dataType = self.doubleDataType; } } @@ -1189,10 +1189,10 @@ -(nonnull CPTMutableNumericData *)numericDataForNumbers:(nonnull id)numbers mutableNumbers = [[CPTMutableNumericData alloc] initWithData:numbers dataType:loadedDataType shape:nil]; } else if ( [numbers isKindOfClass:[NSArray class]] ) { - if ( ( (CPTNumberArray *)numbers ).count == 0 ) { + if (((CPTNumberArray *)numbers).count == 0 ) { loadedDataType = self.doubleDataType; } - else if ( [( (NSArray *)numbers )[0] isKindOfClass:[NSDecimalNumber class]] ) { + else if ( [((NSArray *)numbers)[0] isKindOfClass:[NSDecimalNumber class]] ) { loadedDataType = self.decimalDataType; } else { @@ -1221,7 +1221,7 @@ -(BOOL)doublePrecisionCache Class numberClass = [NSNumber class]; for ( id key in dataCache.allKeys ) { if ( [key isKindOfClass:numberClass] ) { - result = CPTDataTypeEqualToDataType( ( (CPTMutableNumericData *)dataCache[key] ).dataType, self.doubleDataType ); + result = CPTDataTypeEqualToDataType(((CPTMutableNumericData *)dataCache[key]).dataType, self.doubleDataType); break; } } @@ -1358,7 +1358,7 @@ -(CPTNumericDataType)doubleDataType static dispatch_once_t onceToken = 0; dispatch_once(&onceToken, ^{ - dataType = CPTDataType(CPTFloatingPointDataType, sizeof(double), CFByteOrderGetCurrent() ); + dataType = CPTDataType(CPTFloatingPointDataType, sizeof(double), CFByteOrderGetCurrent()); }); return dataType; @@ -1370,7 +1370,7 @@ -(CPTNumericDataType)decimalDataType static dispatch_once_t onceToken = 0; dispatch_once(&onceToken, ^{ - dataType = CPTDataType(CPTDecimalDataType, sizeof(NSDecimal), CFByteOrderGetCurrent() ); + dataType = CPTDataType(CPTDecimalDataType, sizeof(NSDecimal), CFByteOrderGetCurrent()); }); return dataType; @@ -1476,7 +1476,7 @@ -(nullable CPTPlotRange *)plotRangeForField:(NSUInteger)fieldEnum while ( doubles < lastSample ) { double value = *doubles++; - if ( !isnan(value) ) { + if ( !isnan(value)) { if ( value < min ) { min = value; } @@ -1500,17 +1500,17 @@ -(nullable CPTPlotRange *)plotRangeForField:(NSUInteger)fieldEnum while ( decimals < lastSample ) { NSDecimal value = *decimals++; - if ( !NSDecimalIsNotANumber(&value) ) { - if ( CPTDecimalLessThan(value, min) ) { + if ( !NSDecimalIsNotANumber(&value)) { + if ( CPTDecimalLessThan(value, min)) { min = value; } - if ( CPTDecimalGreaterThan(value, max) ) { + if ( CPTDecimalGreaterThan(value, max)) { max = value; } } } - if ( CPTDecimalGreaterThanOrEqualTo(max, min) ) { + if ( CPTDecimalGreaterThanOrEqualTo(max, min)) { range = [CPTPlotRange plotRangeWithLocationDecimal:min lengthDecimal:CPTDecimalSubtract(max, min)]; } } @@ -1620,7 +1620,7 @@ -(void)relabel } } - if ( !self.showLabels || (!hasCachedLabels && !plotProvidesLabels) ) { + if ( !self.showLabels || (!hasCachedLabels && !plotProvidesLabels)) { for ( CPTAnnotation *annotation in self.labelAnnotations ) { if ( [annotation isKindOfClass:annotationClass] ) { [self removeAnnotation:annotation]; @@ -1655,13 +1655,13 @@ -(void)relabel NSNumber *dataValue = [labelFieldDataCache sampleValue:i]; CPTLayer *newLabelLayer; - if ( isnan([dataValue doubleValue]) ) { + if ( isnan([dataValue doubleValue])) { newLabelLayer = nil; } else { newLabelLayer = [self cachedValueForKey:CPTPlotBindingDataLabels recordIndex:i]; - if ( ( (newLabelLayer == nil) || (newLabelLayer == nilObject) ) && plotProvidesLabels ) { + if (((newLabelLayer == nil) || (newLabelLayer == nilObject)) && plotProvidesLabels ) { if ( hasAttributedFormatter ) { NSAttributedString *labelString = [dataLabelFormatter attributedStringForObjectValue:dataValue withDefaultAttributes:textAttributes]; newLabelLayer = [[CPTTextLayer alloc] initWithAttributedText:labelString]; @@ -1672,7 +1672,7 @@ -(void)relabel } } - if ( [newLabelLayer isKindOfClass:nullClass] || (newLabelLayer == nilObject) ) { + if ( [newLabelLayer isKindOfClass:nullClass] || (newLabelLayer == nilObject)) { newLabelLayer = nil; } } @@ -1740,14 +1740,14 @@ -(void)updateContentAnchorForLabel:(nonnull CPTPlotSpaceAnnotation *)label { if ( label && self.adjustLabelAnchors ) { CGPoint displacement = label.displacement; - if ( CGPointEqualToPoint(displacement, CGPointZero) ) { + if ( CGPointEqualToPoint(displacement, CGPointZero)) { displacement.y = CPTFloat(1.0); // put the label above the data point if zero displacement } CGFloat angle = CPTFloat(M_PI) + atan2(displacement.y, displacement.x) - label.rotation; CGFloat newAnchorX = cos(angle); CGFloat newAnchorY = sin(angle); - if ( ABS(newAnchorX) <= ABS(newAnchorY) ) { + if ( ABS(newAnchorX) <= ABS(newAnchorY)) { newAnchorX /= ABS(newAnchorY); newAnchorY = signbit(newAnchorY) ? CPTFloat(-1.0) : CPTFloat(1.0); } @@ -1756,7 +1756,7 @@ -(void)updateContentAnchorForLabel:(nonnull CPTPlotSpaceAnnotation *)label newAnchorX = signbit(newAnchorX) ? CPTFloat(-1.0) : CPTFloat(1.0); } - label.contentAnchorPoint = CPTPointMake( (newAnchorX + CPTFloat(1.0) ) / CPTFloat(2.0), (newAnchorY + CPTFloat(1.0) ) / CPTFloat(2.0) ); + label.contentAnchorPoint = CPTPointMake((newAnchorX + CPTFloat(1.0)) / CPTFloat(2.0), (newAnchorY + CPTFloat(1.0)) / CPTFloat(2.0)); } } @@ -1925,7 +1925,7 @@ -(BOOL)pointingDeviceDownEvent:(nonnull CPTNativeEvent *)event atPoint:(CGPoint) if ( labelLayer && !labelLayer.hidden ) { CGPoint labelPoint = [theGraph convertPoint:interactionPoint toLayer:labelLayer]; - if ( CGRectContainsPoint(labelLayer.bounds, labelPoint) ) { + if ( CGRectContainsPoint(labelLayer.bounds, labelPoint)) { self.pointingDeviceDownLabelIndex = idx; BOOL handled = NO; @@ -2003,7 +2003,7 @@ -(BOOL)pointingDeviceUpEvent:(nonnull CPTNativeEvent *)event atPoint:(CGPoint)in if ( labelLayer && !labelLayer.hidden ) { CGPoint labelPoint = [theGraph convertPoint:interactionPoint toLayer:labelLayer]; - if ( CGRectContainsPoint(labelLayer.bounds, labelPoint) ) { + if ( CGRectContainsPoint(labelLayer.bounds, labelPoint)) { BOOL handled = NO; if ( [theDelegate respondsToSelector:@selector(plot:dataLabelTouchUpAtRecordIndex:)] ) { diff --git a/CorePlot/framework/Source/CPTPlotArea.h b/CorePlot/framework/Source/CPTPlotArea.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTPlotArea.m b/CorePlot/framework/Source/CPTPlotArea.m old mode 100755 new mode 100644 index ccb5dae..34f0461 --- a/CorePlot/framework/Source/CPTPlotArea.m +++ b/CorePlot/framework/Source/CPTPlotArea.m @@ -152,7 +152,7 @@ @implementation CPTPlotArea **/ -(nonnull instancetype)initWithFrame:(CGRect)newFrame { - if ( (self = [super initWithFrame:newFrame]) ) { + if ((self = [super initWithFrame:newFrame])) { minorGridLineGroup = nil; majorGridLineGroup = nil; axisSet = nil; @@ -162,7 +162,7 @@ -(nonnull instancetype)initWithFrame:(CGRect)newFrame fill = nil; touchedPoint = CPTPointMake(NAN, NAN); topDownLayerOrder = nil; - bottomUpLayerOrder = calloc(kCPTNumberOfLayers, sizeof(CPTGraphLayerType) ); + bottomUpLayerOrder = calloc(kCPTNumberOfLayers, sizeof(CPTGraphLayerType)); [self updateLayerOrder]; CPTPlotGroup *newPlotGroup = [[CPTPlotGroup alloc] initWithFrame:newFrame]; @@ -183,7 +183,7 @@ -(nonnull instancetype)initWithFrame:(CGRect)newFrame -(nonnull instancetype)initWithLayer:(nonnull id)layer { - if ( (self = [super initWithLayer:layer]) ) { + if ((self = [super initWithLayer:layer])) { CPTPlotArea *theLayer = (CPTPlotArea *)layer; minorGridLineGroup = theLayer->minorGridLineGroup; @@ -195,8 +195,8 @@ -(nonnull instancetype)initWithLayer:(nonnull id)layer fill = theLayer->fill; touchedPoint = theLayer->touchedPoint; topDownLayerOrder = theLayer->topDownLayerOrder; - bottomUpLayerOrder = calloc(kCPTNumberOfLayers, sizeof(CPTGraphLayerType) ); - memcpy(bottomUpLayerOrder, theLayer->bottomUpLayerOrder, kCPTNumberOfLayers * sizeof(CPTGraphLayerType) ); + bottomUpLayerOrder = calloc(kCPTNumberOfLayers, sizeof(CPTGraphLayerType)); + memcpy(bottomUpLayerOrder, theLayer->bottomUpLayerOrder, kCPTNumberOfLayers * sizeof(CPTGraphLayerType)); widthDecimal = theLayer->widthDecimal; heightDecimal = theLayer->heightDecimal; } @@ -238,7 +238,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super initWithCoder:coder]) ) { + if ((self = [super initWithCoder:coder])) { minorGridLineGroup = [coder decodeObjectOfClass:[CPTGridLineGroup class] forKey:@"CPTPlotArea.minorGridLineGroup"]; majorGridLineGroup = [coder decodeObjectOfClass:[CPTGridLineGroup class] @@ -256,7 +256,7 @@ -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder topDownLayerOrder = [coder decodeObjectOfClasses:[NSSet setWithArray:@[[NSArray class], [NSNumber class]]] forKey:@"CPTPlotArea.topDownLayerOrder"]; - bottomUpLayerOrder = calloc(kCPTNumberOfLayers, sizeof(CPTGraphLayerType) ); + bottomUpLayerOrder = calloc(kCPTNumberOfLayers, sizeof(CPTGraphLayerType)); [self updateLayerOrder]; touchedPoint = CPTPointMake(NAN, NAN); @@ -710,7 +710,7 @@ -(BOOL)pointingDeviceDownEvent:(nonnull CPTNativeEvent *)event atPoint:(CGPoint) // Inform delegate if a point was hit CGPoint plotAreaPoint = [theGraph convertPoint:interactionPoint toLayer:self]; - if ( CGRectContainsPoint(self.bounds, plotAreaPoint) ) { + if ( CGRectContainsPoint(self.bounds, plotAreaPoint)) { self.touchedPoint = plotAreaPoint; if ( [theDelegate respondsToSelector:@selector(plotAreaTouchDown:)] ) { @@ -764,9 +764,9 @@ -(BOOL)pointingDeviceUpEvent:(nonnull CPTNativeEvent *)event atPoint:(CGPoint)in // Inform delegate if a point was hit CGPoint plotAreaPoint = [theGraph convertPoint:interactionPoint toLayer:self]; - if ( CGRectContainsPoint(self.bounds, plotAreaPoint) ) { + if ( CGRectContainsPoint(self.bounds, plotAreaPoint)) { CGVector offset = CGVectorMake(plotAreaPoint.x - lastPoint.x, plotAreaPoint.y - lastPoint.y); - if ( (offset.dx * offset.dx + offset.dy * offset.dy) <= CPTFloat(25.0) ) { + if ((offset.dx * offset.dx + offset.dy * offset.dy) <= CPTFloat(25.0)) { if ( [theDelegate respondsToSelector:@selector(plotAreaTouchUp:)] ) { [theDelegate plotAreaTouchUp:self]; } @@ -818,7 +818,7 @@ -(void)setFill:(nullable CPTFill *)newFill -(void)setMinorGridLineGroup:(nullable CPTGridLineGroup *)newGridLines { - if ( (newGridLines != minorGridLineGroup) || self.isUpdatingLayers ) { + if ((newGridLines != minorGridLineGroup) || self.isUpdatingLayers ) { [minorGridLineGroup removeFromSuperlayer]; minorGridLineGroup = newGridLines; if ( newGridLines ) { @@ -834,7 +834,7 @@ -(void)setMinorGridLineGroup:(nullable CPTGridLineGroup *)newGridLines -(void)setMajorGridLineGroup:(nullable CPTGridLineGroup *)newGridLines { - if ( (newGridLines != majorGridLineGroup) || self.isUpdatingLayers ) { + if ((newGridLines != majorGridLineGroup) || self.isUpdatingLayers ) { [majorGridLineGroup removeFromSuperlayer]; majorGridLineGroup = newGridLines; if ( newGridLines ) { @@ -850,7 +850,7 @@ -(void)setMajorGridLineGroup:(nullable CPTGridLineGroup *)newGridLines -(void)setAxisSet:(nullable CPTAxisSet *)newAxisSet { - if ( (newAxisSet != axisSet) || self.isUpdatingLayers ) { + if ((newAxisSet != axisSet) || self.isUpdatingLayers ) { [axisSet removeFromSuperlayer]; for ( CPTAxis *axis in axisSet.axes ) { axis.plotArea = nil; @@ -878,7 +878,7 @@ -(void)setAxisSet:(nullable CPTAxisSet *)newAxisSet -(void)setPlotGroup:(nullable CPTPlotGroup *)newPlotGroup { - if ( (newPlotGroup != plotGroup) || self.isUpdatingLayers ) { + if ((newPlotGroup != plotGroup) || self.isUpdatingLayers ) { [plotGroup removeFromSuperlayer]; plotGroup = newPlotGroup; if ( newPlotGroup ) { @@ -892,7 +892,7 @@ -(void)setPlotGroup:(nullable CPTPlotGroup *)newPlotGroup -(void)setAxisLabelGroup:(nullable CPTAxisLabelGroup *)newAxisLabelGroup { - if ( (newAxisLabelGroup != axisLabelGroup) || self.isUpdatingLayers ) { + if ((newAxisLabelGroup != axisLabelGroup) || self.isUpdatingLayers ) { [axisLabelGroup removeFromSuperlayer]; axisLabelGroup = newAxisLabelGroup; if ( newAxisLabelGroup ) { @@ -906,7 +906,7 @@ -(void)setAxisLabelGroup:(nullable CPTAxisLabelGroup *)newAxisLabelGroup -(void)setAxisTitleGroup:(nullable CPTAxisLabelGroup *)newAxisTitleGroup { - if ( (newAxisTitleGroup != axisTitleGroup) || self.isUpdatingLayers ) { + if ((newAxisTitleGroup != axisTitleGroup) || self.isUpdatingLayers ) { [axisTitleGroup removeFromSuperlayer]; axisTitleGroup = newAxisTitleGroup; if ( newAxisTitleGroup ) { @@ -939,7 +939,7 @@ -(void)setGraph:(nullable CPTGraph *)newGraph -(void)setBounds:(CGRect)newBounds { - if ( !CGRectEqualToRect(self.bounds, newBounds) ) { + if ( !CGRectEqualToRect(self.bounds, newBounds)) { self.widthDecimal = CPTDecimalFromCGFloat(newBounds.size.width); self.heightDecimal = CPTDecimalFromCGFloat(newBounds.size.height); diff --git a/CorePlot/framework/Source/CPTPlotAreaFrame.h b/CorePlot/framework/Source/CPTPlotAreaFrame.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTPlotAreaFrame.m b/CorePlot/framework/Source/CPTPlotAreaFrame.m old mode 100755 new mode 100644 index b706c27..c5723c6 --- a/CorePlot/framework/Source/CPTPlotAreaFrame.m +++ b/CorePlot/framework/Source/CPTPlotAreaFrame.m @@ -56,7 +56,7 @@ @implementation CPTPlotAreaFrame **/ -(nonnull instancetype)initWithFrame:(CGRect)newFrame { - if ( (self = [super initWithFrame:newFrame]) ) { + if ((self = [super initWithFrame:newFrame])) { plotArea = nil; CPTPlotArea *newPlotArea = [[CPTPlotArea alloc] initWithFrame:newFrame]; @@ -74,7 +74,7 @@ -(nonnull instancetype)initWithFrame:(CGRect)newFrame -(nonnull instancetype)initWithLayer:(nonnull id)layer { - if ( (self = [super initWithLayer:layer]) ) { + if ((self = [super initWithLayer:layer])) { CPTPlotAreaFrame *theLayer = (CPTPlotAreaFrame *)layer; plotArea = theLayer->plotArea; @@ -98,7 +98,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super initWithCoder:coder]) ) { + if ((self = [super initWithCoder:coder])) { plotArea = [coder decodeObjectOfClass:[CPTPlotArea class] forKey:@"CPTPlotAreaFrame.plotArea"]; } diff --git a/CorePlot/framework/Source/CPTPlotGroup.h b/CorePlot/framework/Source/CPTPlotGroup.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTPlotGroup.m b/CorePlot/framework/Source/CPTPlotGroup.m old mode 100755 new mode 100644 index 09c4ea9..e2ce5f3 --- a/CorePlot/framework/Source/CPTPlotGroup.m +++ b/CorePlot/framework/Source/CPTPlotGroup.m @@ -14,7 +14,7 @@ @implementation CPTPlotGroup -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super initWithCoder:coder]) ) { + if ((self = [super initWithCoder:coder])) { // support old archives if ( [coder containsValueForKey:@"CPTPlotGroup.identifier"] ) { self.identifier = [coder decodeObjectOfClass:[NSObject class] diff --git a/CorePlot/framework/Source/CPTPlotRange.h b/CorePlot/framework/Source/CPTPlotRange.h old mode 100755 new mode 100644 index 6ba3f43..ce6fbb8 --- a/CorePlot/framework/Source/CPTPlotRange.h +++ b/CorePlot/framework/Source/CPTPlotRange.h @@ -7,10 +7,11 @@ /** * @brief Enumeration of possible results of a plot range comparison. **/ -typedef NS_ENUM (NSInteger, CPTPlotRangeComparisonResult) { +typedef NS_CLOSED_ENUM (NSInteger, CPTPlotRangeComparisonResult) { CPTPlotRangeComparisonResultNumberBelowRange, ///< Number is below the range. CPTPlotRangeComparisonResultNumberInRange, ///< Number is in the range. - CPTPlotRangeComparisonResultNumberAboveRange ///< Number is above the range. + CPTPlotRangeComparisonResultNumberAboveRange, ///< Number is above the range. + CPTPlotRangeComparisonResultNumberUndefined ///< Number is undefined (e.g., @NAN). }; /** @@ -46,6 +47,9 @@ typedef NSMutableArray CPTMutablePlotRangeArray; @property (nonatomic, readonly) double minLimitDouble; @property (nonatomic, readonly) double midPointDouble; @property (nonatomic, readonly) double maxLimitDouble; + +@property (nonatomic, readonly) BOOL isInfinite; +@property (nonatomic, readonly) CPTSign lengthSign; /// @} /// @name Factory Methods @@ -56,8 +60,8 @@ typedef NSMutableArray CPTMutablePlotRangeArray; /// @name Initialization /// @{ --(nonnull instancetype)initWithLocation:(nonnull NSNumber *)loc length:(nonnull NSNumber *)len; --(nonnull instancetype)initWithLocationDecimal:(NSDecimal)loc lengthDecimal:(NSDecimal)len NS_DESIGNATED_INITIALIZER; +-(nonnull instancetype)initWithLocation:(nonnull NSNumber *)loc length:(nonnull NSNumber *)len NS_DESIGNATED_INITIALIZER; +-(nonnull instancetype)initWithLocationDecimal:(NSDecimal)loc lengthDecimal:(NSDecimal)len; -(nullable instancetype)initWithCoder:(nonnull NSCoder *)decoder NS_DESIGNATED_INITIALIZER; /// @} diff --git a/CorePlot/framework/Source/CPTPlotRange.m b/CorePlot/framework/Source/CPTPlotRange.m old mode 100755 new mode 100644 index ef2e047..c83c432 --- a/CorePlot/framework/Source/CPTPlotRange.m +++ b/CorePlot/framework/Source/CPTPlotRange.m @@ -12,6 +12,9 @@ @interface CPTPlotRange() @property (nonatomic, readwrite) double locationDouble; @property (nonatomic, readwrite) double lengthDouble; +@property (nonatomic, readwrite) BOOL isInfinite; +@property (nonatomic, readwrite) CPTSign lengthSign; + @property (nonatomic, readwrite) BOOL inValueUpdate; @end @@ -121,6 +124,16 @@ @implementation CPTPlotRange **/ @dynamic maxLimitDouble; +/** @property BOOL isInfinite + * @brief @YES if the length of the range is infinite. + **/ +@synthesize isInfinite; + +/** @property CPTSign lengthSign + * @brief The direction (positive or negative) if the length of the range is infinite. + **/ +@synthesize lengthSign; + @synthesize inValueUpdate; #pragma mark - @@ -156,8 +169,24 @@ -(nonnull instancetype)initWithLocation:(nonnull NSNumber *)loc length:(nonnull NSParameterAssert(loc); NSParameterAssert(len); - return [self initWithLocationDecimal:loc.decimalValue - lengthDecimal:len.decimalValue]; + if ((self = [super init])) { + locationDecimal = loc.decimalValue; + locationDouble = loc.doubleValue; + + lengthDecimal = len.decimalValue; + lengthDouble = len.doubleValue; + + if ( isnan(lengthDouble)) { + isInfinite = NO; + lengthSign = CPTSignNone; + } + else { + isInfinite = (BOOL)isinf(lengthDouble); + lengthSign = signbit(lengthDouble) ? CPTSignNegative : CPTSignPositive; + } + } + + return self; } /** @brief Initializes a newly allocated CPTPlotRange object with the provided location and length. @@ -167,11 +196,8 @@ -(nonnull instancetype)initWithLocation:(nonnull NSNumber *)loc length:(nonnull **/ -(nonnull instancetype)initWithLocationDecimal:(NSDecimal)loc lengthDecimal:(NSDecimal)len { - if ( (self = [super init]) ) { - self.locationDecimal = loc; - self.lengthDecimal = len; - } - return self; + return [self initWithLocation:[NSDecimalNumber decimalNumberWithDecimal:loc] + length:[NSDecimalNumber decimalNumberWithDecimal:len]]; } /// @name Initialization @@ -204,11 +230,15 @@ -(NSNumber *)location -(void)setLocationDecimal:(NSDecimal)newLocation { - if ( !CPTDecimalEquals(locationDecimal, newLocation) ) { + if ( !CPTDecimalEquals(locationDecimal, newLocation)) { locationDecimal = newLocation; if ( !self.inValueUpdate ) { - self.locationDouble = [NSDecimalNumber decimalNumberWithDecimal:newLocation].doubleValue; + self.inValueUpdate = YES; + + self.locationDouble = CPTDecimalDoubleValue(newLocation); + + self.inValueUpdate = NO; } } } @@ -219,7 +249,11 @@ -(void)setLocationDouble:(double)newLocation locationDouble = newLocation; if ( !self.inValueUpdate ) { - self.locationDecimal = @(newLocation).decimalValue; + self.inValueUpdate = YES; + + self.locationDecimal = CPTDecimalFromDouble(newLocation); + + self.inValueUpdate = NO; } } } @@ -231,11 +265,15 @@ -(NSNumber *)length -(void)setLengthDecimal:(NSDecimal)newLength { - if ( !CPTDecimalEquals(lengthDecimal, newLength) ) { + if ( !CPTDecimalEquals(lengthDecimal, newLength)) { lengthDecimal = newLength; if ( !self.inValueUpdate ) { - self.lengthDouble = [NSDecimalNumber decimalNumberWithDecimal:newLength].doubleValue; + self.inValueUpdate = YES; + + self.lengthDouble = CPTDecimalDoubleValue(newLength); + + self.inValueUpdate = NO; } } } @@ -245,8 +283,21 @@ -(void)setLengthDouble:(double)newLength if ( lengthDouble != newLength ) { lengthDouble = newLength; + if ( isnan(newLength)) { + self.isInfinite = NO; + self.lengthSign = CPTSignNone; + } + else { + self.isInfinite = (BOOL)isinf(newLength); + self.lengthSign = signbit(newLength) ? CPTSignNegative : CPTSignPositive; + } + if ( !self.inValueUpdate ) { - self.lengthDecimal = @(newLength).decimalValue; + self.inValueUpdate = YES; + + self.lengthDecimal = CPTDecimalFromDouble(newLength); + + self.inValueUpdate = NO; } } } @@ -276,7 +327,10 @@ -(NSDecimal)minLimitDecimal NSDecimal loc = self.locationDecimal; NSDecimal len = self.lengthDecimal; - if ( CPTDecimalLessThan(len, CPTDecimalFromInteger(0) ) ) { + if ( NSDecimalIsNotANumber(&len)) { + return loc; + } + else if ( CPTDecimalLessThan(len, CPTDecimalFromInteger(0))) { return CPTDecimalAdd(loc, len); } else { @@ -304,7 +358,7 @@ -(NSNumber *)midPoint -(NSDecimal)midPointDecimal { - return CPTDecimalAdd(self.locationDecimal, CPTDecimalDivide(self.lengthDecimal, CPTDecimalFromInteger(2) ) ); + return CPTDecimalAdd(self.locationDecimal, CPTDecimalDivide(self.lengthDecimal, CPTDecimalFromInteger(2))); } -(double)midPointDouble @@ -322,7 +376,10 @@ -(NSDecimal)maxLimitDecimal NSDecimal loc = self.locationDecimal; NSDecimal len = self.lengthDecimal; - if ( CPTDecimalGreaterThan(len, CPTDecimalFromInteger(0) ) ) { + if ( NSDecimalIsNotANumber(&len)) { + return loc; + } + else if ( CPTDecimalGreaterThan(len, CPTDecimalFromInteger(0))) { return CPTDecimalAdd(loc, len); } else { @@ -355,10 +412,15 @@ -(nonnull id)copyWithZone:(nullable NSZone *)zone CPTPlotRange *newRange = [[CPTPlotRange allocWithZone:zone] init]; if ( newRange ) { + newRange.inValueUpdate = YES; + newRange.locationDecimal = self.locationDecimal; - newRange.lengthDecimal = self.lengthDecimal; newRange.locationDouble = self.locationDouble; - newRange.lengthDouble = self.lengthDouble; + + newRange.lengthDecimal = self.lengthDecimal; + newRange.lengthDouble = self.lengthDouble; + + newRange.inValueUpdate = NO; } return newRange; } @@ -375,10 +437,15 @@ -(nonnull id)mutableCopyWithZone:(nullable NSZone *)zone CPTPlotRange *newRange = [[CPTMutablePlotRange allocWithZone:zone] init]; if ( newRange ) { + newRange.inValueUpdate = YES; + newRange.locationDecimal = self.locationDecimal; - newRange.lengthDecimal = self.lengthDecimal; newRange.locationDouble = self.locationDouble; - newRange.lengthDouble = self.lengthDouble; + + newRange.lengthDecimal = self.lengthDecimal; + newRange.lengthDouble = self.lengthDouble; + + newRange.inValueUpdate = NO; } return newRange; } @@ -394,6 +461,8 @@ -(void)encodeWithCoder:(nonnull NSCoder *)encoder { [encoder encodeDecimal:self.locationDecimal forKey:@"CPTPlotRange.location"]; [encoder encodeDecimal:self.lengthDecimal forKey:@"CPTPlotRange.length"]; + [encoder encodeBool:self.isInfinite forKey:@"CPTPlotRange.isInfinite"]; + [encoder encodeInteger:self.lengthSign forKey:@"CPTPlotRange.lengthSign"]; } /// @endcond @@ -404,9 +473,12 @@ -(void)encodeWithCoder:(nonnull NSCoder *)encoder */ -(nullable instancetype)initWithCoder:(nonnull NSCoder *)decoder { - if ( (self = [super init]) ) { + if ((self = [super init])) { self.locationDecimal = [decoder decodeDecimalForKey:@"CPTPlotRange.location"]; self.lengthDecimal = [decoder decodeDecimalForKey:@"CPTPlotRange.length"]; + + isInfinite = [decoder decodeBoolForKey:@"CPTPlotRange.isInfinite"]; + lengthSign = [decoder decodeIntegerForKey:@"CPTPlotRange.lengthSign"]; } return self; @@ -433,7 +505,27 @@ +(BOOL)supportsSecureCoding **/ -(BOOL)contains:(NSDecimal)number { - return CPTDecimalGreaterThanOrEqualTo(number, self.minLimitDecimal) && CPTDecimalLessThanOrEqualTo(number, self.maxLimitDecimal); + BOOL result = NO; + + if ( self.isInfinite ) { + switch ( self.lengthSign ) { + case CPTSignPositive: + result = CPTDecimalGreaterThanOrEqualTo(number, self.minLimitDecimal); + break; + + case CPTSignNegative: + result = CPTDecimalLessThanOrEqualTo(number, self.maxLimitDecimal); + break; + + default: + break; + } + } + else { + result = CPTDecimalGreaterThanOrEqualTo(number, self.minLimitDecimal) && CPTDecimalLessThanOrEqualTo(number, self.maxLimitDecimal); + } + + return result; } /** @brief Determines whether a given number is inside the range. @@ -452,12 +544,10 @@ -(BOOL)containsDouble:(double)number -(BOOL)containsNumber:(nullable NSNumber *)number { if ( [number isKindOfClass:[NSDecimalNumber class]] ) { - NSDecimal numericValue = number.decimalValue; - return CPTDecimalGreaterThanOrEqualTo(numericValue, self.minLimitDecimal) && CPTDecimalLessThanOrEqualTo(numericValue, self.maxLimitDecimal); + return [self contains:number.decimalValue]; } else { - double numericValue = number.doubleValue; - return (numericValue >= self.minLimitDouble) && (numericValue <= self.maxLimitDouble); + return [self containsDouble:number.doubleValue]; } } @@ -468,7 +558,10 @@ -(BOOL)containsNumber:(nullable NSNumber *)number -(BOOL)isEqualToRange:(nullable CPTPlotRange *)otherRange { if ( otherRange ) { - return CPTDecimalEquals(self.locationDecimal, otherRange.locationDecimal) && CPTDecimalEquals(self.lengthDecimal, otherRange.lengthDecimal); + return CPTDecimalEquals(self.locationDecimal, otherRange.locationDecimal) && + CPTDecimalEquals(self.lengthDecimal, otherRange.lengthDecimal) && + (self.isInfinite == otherRange.isInfinite) && + (self.lengthSign == otherRange.lengthSign); } else { return NO; @@ -481,12 +574,31 @@ -(BOOL)isEqualToRange:(nullable CPTPlotRange *)otherRange **/ -(BOOL)containsRange:(nullable CPTPlotRange *)otherRange { + BOOL result = NO; + if ( otherRange ) { - return CPTDecimalGreaterThanOrEqualTo(otherRange.minLimitDecimal, self.minLimitDecimal) && CPTDecimalLessThanOrEqualTo(otherRange.maxLimitDecimal, self.maxLimitDecimal); - } - else { - return NO; + if ( self.isInfinite ) { + if ( !otherRange.isInfinite || (otherRange.lengthSign == self.lengthSign)) { + switch ( self.lengthSign ) { + case CPTSignPositive: + result = CPTDecimalGreaterThanOrEqualTo(otherRange.minLimitDecimal, self.minLimitDecimal); + break; + + case CPTSignNegative: + result = CPTDecimalLessThanOrEqualTo(otherRange.maxLimitDecimal, self.maxLimitDecimal); + break; + + default: + break; + } + } + } + else { + result = CPTDecimalGreaterThanOrEqualTo(otherRange.minLimitDecimal, self.minLimitDecimal) && CPTDecimalLessThanOrEqualTo(otherRange.maxLimitDecimal, self.maxLimitDecimal); + } } + + return result; } /** @brief Determines whether a given range intersects the receiver. @@ -495,19 +607,58 @@ -(BOOL)containsRange:(nullable CPTPlotRange *)otherRange **/ -(BOOL)intersectsRange:(nullable CPTPlotRange *)otherRange { - if ( !otherRange ) { - return NO; - } - - NSDecimal min1 = self.minLimitDecimal; - NSDecimal min2 = otherRange.minLimitDecimal; - NSDecimal minimum = CPTDecimalGreaterThan(min1, min2) ? min1 : min2; + BOOL result = NO; - NSDecimal max1 = self.maxLimitDecimal; - NSDecimal max2 = otherRange.maxLimitDecimal; - NSDecimal maximum = CPTDecimalLessThan(max1, max2) ? max1 : max2; + if ( otherRange ) { + if ( self.isInfinite ) { + if ( otherRange.isInfinite ) { + result = (otherRange.lengthSign == self.lengthSign); + } + if ( !result ) { + switch ( self.lengthSign ) { + case CPTSignPositive: + result = CPTDecimalGreaterThanOrEqualTo(otherRange.maxLimitDecimal, self.minLimitDecimal); + break; + + case CPTSignNegative: + result = CPTDecimalLessThanOrEqualTo(otherRange.minLimitDecimal, self.maxLimitDecimal); + break; + + default: + break; + } + } + } + else { + if ( otherRange.isInfinite ) { + switch ( otherRange.lengthSign ) { + case CPTSignPositive: + result = CPTDecimalLessThanOrEqualTo(otherRange.minLimitDecimal, self.maxLimitDecimal); + break; + + case CPTSignNegative: + result = CPTDecimalLessThanOrEqualTo(otherRange.maxLimitDecimal, self.minLimitDecimal); + break; + + default: + break; + } + } + else { + NSDecimal min1 = self.minLimitDecimal; + NSDecimal min2 = otherRange.minLimitDecimal; + NSDecimal minimum = CPTDecimalMax(min1, min2); + + NSDecimal max1 = self.maxLimitDecimal; + NSDecimal max2 = otherRange.maxLimitDecimal; + NSDecimal maximum = CPTDecimalMin(max1, max2); + + result = CPTDecimalGreaterThanOrEqualTo(maximum, minimum); + } + } + } - return CPTDecimalGreaterThanOrEqualTo(maximum, minimum); + return result; } /** @brief Compares a number to the range, determining if it is in the range, or above or below it. @@ -535,10 +686,13 @@ -(CPTPlotRangeComparisonResult)compareToDecimal:(NSDecimal)number { CPTPlotRangeComparisonResult result; - if ( [self contains:number] ) { + if ( NSDecimalIsNotANumber(&number)) { + result = CPTPlotRangeComparisonResultNumberUndefined; + } + else if ( [self contains:number] ) { result = CPTPlotRangeComparisonResultNumberInRange; } - else if ( CPTDecimalLessThan(number, self.minLimitDecimal) ) { + else if ( CPTDecimalLessThan(number, self.minLimitDecimal)) { result = CPTPlotRangeComparisonResultNumberBelowRange; } else { @@ -555,7 +709,10 @@ -(CPTPlotRangeComparisonResult)compareToDouble:(double)number { CPTPlotRangeComparisonResult result; - if ( number < self.minLimitDouble ) { + if ( isnan(number)) { + result = CPTPlotRangeComparisonResultNumberUndefined; + } + else if ( number < self.minLimitDouble ) { result = CPTPlotRangeComparisonResultNumberBelowRange; } else if ( number > self.maxLimitDouble ) { @@ -608,7 +765,7 @@ -(nullable NSString *)description return [NSString stringWithFormat:@"<%@ {%@, %@}>", super.description, NSDecimalString(&myLocation, [NSLocale currentLocale]), - NSDecimalString(&myLength, [NSLocale currentLocale])]; + self.isInfinite ? (self.lengthSign == CPTSignPositive ? @"+INF" : @"-INF") : NSDecimalString(&myLength, [NSLocale currentLocale])]; } /// @endcond @@ -625,7 +782,7 @@ -(nullable id)debugQuickLookObject return [NSString stringWithFormat:@"Location: %@\nLength: %@", NSDecimalString(&myLocation, [NSLocale currentLocale]), - NSDecimalString(&myLength, [NSLocale currentLocale])]; + self.isInfinite ? (self.lengthSign == CPTSignPositive ? @"+INF" : @"-INF") : NSDecimalString(&myLength, [NSLocale currentLocale])]; } /// @endcond diff --git a/CorePlot/framework/Source/CPTPlotRangeTests.h b/CorePlot/framework/Source/CPTPlotRangeTests.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTPlotRangeTests.m b/CorePlot/framework/Source/CPTPlotRangeTests.m old mode 100755 new mode 100644 index bb32866..c5cfeab --- a/CorePlot/framework/Source/CPTPlotRangeTests.m +++ b/CorePlot/framework/Source/CPTPlotRangeTests.m @@ -37,6 +37,17 @@ -(void)testContains XCTAssertFalse([self.plotRange contains:CPTDecimalFromDouble(3.001)], @"Test contains:3.001"); } +-(void)testContainsInfinite +{ + self.plotRange.lengthDouble = HUGE_VAL; + + XCTAssertFalse([self.plotRange contains:CPTDecimalFromDouble(0.999)], @"Test contains:0.999"); + XCTAssertTrue([self.plotRange contains:CPTDecimalFromDouble(1.0)], @"Test contains:1.0"); + XCTAssertTrue([self.plotRange contains:CPTDecimalFromDouble(2.0)], @"Test contains:2.0"); + XCTAssertTrue([self.plotRange contains:CPTDecimalFromDouble(3.0)], @"Test contains:3.0"); + XCTAssertTrue([self.plotRange contains:CPTDecimalFromDouble(3.001)], @"Test contains:3.001"); +} + -(void)testContainsNegative { self.plotRange.lengthDouble = -2.0; @@ -48,6 +59,17 @@ -(void)testContainsNegative XCTAssertFalse([self.plotRange contains:CPTDecimalFromDouble(1.001)], @"Test contains:1.001"); } +-(void)testContainsNegativeInfinite +{ + self.plotRange.lengthDouble = -HUGE_VAL; + + XCTAssertTrue([self.plotRange contains:CPTDecimalFromDouble(-1.001)], @"Test contains:-1.001"); + XCTAssertTrue([self.plotRange contains:CPTDecimalFromDouble(-1.0)], @"Test contains:-1.0"); + XCTAssertTrue([self.plotRange contains:CPTDecimalFromDouble(0.0)], @"Test contains:0.0"); + XCTAssertTrue([self.plotRange contains:CPTDecimalFromDouble(1.0)], @"Test contains:1.0"); + XCTAssertFalse([self.plotRange contains:CPTDecimalFromDouble(1.001)], @"Test contains:1.001"); +} + -(void)testContainsDouble { XCTAssertFalse([self.plotRange containsDouble:0.999], @"Test contains:0.999"); @@ -57,6 +79,17 @@ -(void)testContainsDouble XCTAssertFalse([self.plotRange containsDouble:3.001], @"Test contains:3.001"); } +-(void)testContainsDoubleInfinite +{ + self.plotRange.lengthDouble = HUGE_VAL; + + XCTAssertFalse([self.plotRange containsDouble:0.999], @"Test contains:0.999"); + XCTAssertTrue([self.plotRange containsDouble:1.0], @"Test contains:1.0"); + XCTAssertTrue([self.plotRange containsDouble:2.0], @"Test contains:2.0"); + XCTAssertTrue([self.plotRange containsDouble:3.0], @"Test contains:3.0"); + XCTAssertTrue([self.plotRange containsDouble:3.001], @"Test contains:3.001"); +} + -(void)testContainsNumber { XCTAssertFalse([self.plotRange containsNumber:@(0.999)], @"Test contains:0.999"); @@ -66,6 +99,17 @@ -(void)testContainsNumber XCTAssertFalse([self.plotRange containsNumber:@(3.001)], @"Test contains:3.001"); } +-(void)testContainsNumberInfinite +{ + self.plotRange.lengthDouble = HUGE_VAL; + + XCTAssertFalse([self.plotRange containsNumber:@(0.999)], @"Test contains:0.999"); + XCTAssertTrue([self.plotRange containsNumber:[NSDecimalNumber one]], @"Test contains:1.0"); + XCTAssertTrue([self.plotRange containsNumber:@(2.0)], @"Test contains:2.0"); + XCTAssertTrue([self.plotRange containsNumber:@(3.0)], @"Test contains:3.0"); + XCTAssertTrue([self.plotRange containsNumber:@(3.001)], @"Test contains:3.001"); +} + -(void)testContainsDoubleNegative { self.plotRange.lengthDouble = -2.0; @@ -77,6 +121,17 @@ -(void)testContainsDoubleNegative XCTAssertFalse([self.plotRange containsDouble:1.001], @"Test contains:1.001"); } +-(void)testContainsDoubleNegativeInfinite +{ + self.plotRange.lengthDouble = -HUGE_VAL; + + XCTAssertTrue([self.plotRange containsDouble:-1.001], @"Test contains:-1.001"); + XCTAssertTrue([self.plotRange containsDouble:-1.0], @"Test contains:-1.0"); + XCTAssertTrue([self.plotRange containsDouble:0.0], @"Test contains:0.0"); + XCTAssertTrue([self.plotRange containsDouble:1.0], @"Test contains:1.0"); + XCTAssertFalse([self.plotRange containsDouble:1.001], @"Test contains:1.001"); +} + -(void)testContainsRange { CPTPlotRange *otherRange = [CPTPlotRange plotRangeWithLocation:@0.0 length:@4.0]; @@ -96,6 +151,48 @@ -(void)testContainsRange XCTAssertFalse([self.plotRange containsRange:otherRange], @"otherRange was {%g, %g}", otherRange.locationDouble, otherRange.lengthDouble); } +-(void)testContainsRangeInfinite +{ + self.plotRange.lengthDouble = HUGE_VAL; + + CPTPlotRange *otherRange = [CPTPlotRange plotRangeWithLocation:@0.0 length:@4.0]; + + XCTAssertFalse([self.plotRange containsRange:otherRange], @"otherRange was {%g, %g}", otherRange.locationDouble, otherRange.lengthDouble); + + otherRange = [CPTPlotRange plotRangeWithLocation:@1.0 length:@2.0]; + XCTAssertTrue([self.plotRange containsRange:otherRange], @"otherRange was {%g, %g}", otherRange.locationDouble, otherRange.lengthDouble); + + otherRange = [CPTPlotRange plotRangeWithLocation:@2.0 length:@1.0]; + XCTAssertTrue([self.plotRange containsRange:otherRange], @"otherRange was {%g, %g}", otherRange.locationDouble, otherRange.lengthDouble); + + otherRange = [CPTPlotRange plotRangeWithLocation:@2.0 length:@4.0]; + XCTAssertTrue([self.plotRange containsRange:otherRange], @"otherRange was {%g, %g}", otherRange.locationDouble, otherRange.lengthDouble); + + otherRange = [CPTPlotRange plotRangeWithLocation:@0.0 length:@2.0]; + XCTAssertFalse([self.plotRange containsRange:otherRange], @"otherRange was {%g, %g}", otherRange.locationDouble, otherRange.lengthDouble); +} + +-(void)testContainsRangeNegativeInfinite +{ + self.plotRange.lengthDouble = -HUGE_VAL; + + CPTPlotRange *otherRange = [CPTPlotRange plotRangeWithLocation:@0.0 length:@4.0]; + + XCTAssertFalse([self.plotRange containsRange:otherRange], @"otherRange was {%g, %g}", otherRange.locationDouble, otherRange.lengthDouble); + + otherRange = [CPTPlotRange plotRangeWithLocation:@1.0 length:@(-2.0)]; + XCTAssertTrue([self.plotRange containsRange:otherRange], @"otherRange was {%g, %g}", otherRange.locationDouble, otherRange.lengthDouble); + + otherRange = [CPTPlotRange plotRangeWithLocation:@2.0 length:@(-1.0)]; + XCTAssertFalse([self.plotRange containsRange:otherRange], @"otherRange was {%g, %g}", otherRange.locationDouble, otherRange.lengthDouble); + + otherRange = [CPTPlotRange plotRangeWithLocation:@2.0 length:@4.0]; + XCTAssertFalse([self.plotRange containsRange:otherRange], @"otherRange was {%g, %g}", otherRange.locationDouble, otherRange.lengthDouble); + + otherRange = [CPTPlotRange plotRangeWithLocation:@0.0 length:@(-2.0)]; + XCTAssertTrue([self.plotRange containsRange:otherRange], @"otherRange was {%g, %g}", otherRange.locationDouble, otherRange.lengthDouble); +} + #pragma mark - #pragma mark Union @@ -120,6 +217,32 @@ -(void)testUnionRange [self checkRangeWithLocation:-5.0 length:12.0]; } +-(void)testUnionRangeInfinite +{ + self.plotRange.lengthDouble = HUGE_VAL; + + [self.plotRange unionPlotRange:[CPTPlotRange plotRangeWithLocation:@0.0 length:@4.0]]; + [self checkRangeWithLocation:0.0 length:HUGE_VAL]; + + [self.plotRange unionPlotRange:[CPTPlotRange plotRangeWithLocation:@(-1.0) length:@1.0]]; + [self checkRangeWithLocation:-1.0 length:HUGE_VAL]; + + [self.plotRange unionPlotRange:[CPTPlotRange plotRangeWithLocation:@5.0 length:@2.0]]; + [self checkRangeWithLocation:-1.0 length:HUGE_VAL]; + + [self.plotRange unionPlotRange:[CPTPlotRange plotRangeWithLocation:@0.0 length:@(-4.0)]]; + [self checkRangeWithLocation:-4.0 length:HUGE_VAL]; + + [self.plotRange unionPlotRange:[CPTPlotRange plotRangeWithLocation:@(-1.0) length:@(-4.0)]]; + [self checkRangeWithLocation:-5.0 length:HUGE_VAL]; + + [self.plotRange unionPlotRange:[CPTPlotRange plotRangeWithLocation:@5.0 length:@(HUGE_VAL)]]; + [self checkRangeWithLocation:-5.0 length:HUGE_VAL]; + + [self.plotRange unionPlotRange:[CPTPlotRange plotRangeWithLocation:@5.0 length:@(-HUGE_VAL)]]; + [self checkRangeWithLocation:-HUGE_VAL length:HUGE_VAL]; +} + -(void)testUnionRangeNegative { self.plotRange.lengthDouble = -2.0; @@ -143,6 +266,32 @@ -(void)testUnionRangeNegative [self checkRangeWithLocation:7.0 length:-12.0]; } +-(void)testUnionRangeNegativeInfinite +{ + self.plotRange.lengthDouble = -HUGE_VAL; + + [self.plotRange unionPlotRange:[CPTPlotRange plotRangeWithLocation:@0.0 length:@4.0]]; + [self checkRangeWithLocation:4.0 length:-HUGE_VAL]; + + [self.plotRange unionPlotRange:[CPTPlotRange plotRangeWithLocation:@(-1.0) length:@1.0]]; + [self checkRangeWithLocation:4.0 length:-HUGE_VAL]; + + [self.plotRange unionPlotRange:[CPTPlotRange plotRangeWithLocation:@5.0 length:@2.0]]; + [self checkRangeWithLocation:7.0 length:-HUGE_VAL]; + + [self.plotRange unionPlotRange:[CPTPlotRange plotRangeWithLocation:@0.0 length:@(-4.0)]]; + [self checkRangeWithLocation:7.0 length:-HUGE_VAL]; + + [self.plotRange unionPlotRange:[CPTPlotRange plotRangeWithLocation:@(-1.0) length:@(-4.0)]]; + [self checkRangeWithLocation:7.0 length:-HUGE_VAL]; + + [self.plotRange unionPlotRange:[CPTPlotRange plotRangeWithLocation:@10.0 length:@(-HUGE_VAL)]]; + [self checkRangeWithLocation:10.0 length:-HUGE_VAL]; + + [self.plotRange unionPlotRange:[CPTPlotRange plotRangeWithLocation:@5.0 length:@(HUGE_VAL)]]; + [self checkRangeWithLocation:-HUGE_VAL length:HUGE_VAL]; +} + #pragma mark - #pragma mark Intersection @@ -162,7 +311,7 @@ -(void)testIntersectRange otherRange = [CPTPlotRange plotRangeWithLocation:@(-1.0) length:@1.0]; XCTAssertFalse([self.plotRange intersectsRange:otherRange], @"otherRange was {%g, %g}", otherRange.locationDouble, otherRange.lengthDouble); [self.plotRange intersectionPlotRange:otherRange]; - [self checkRangeWithLocation:1.0 length:0.0]; + [self checkRangeWithLocation:(double)NAN length:(double)NAN]; } -(void)testIntersectRange2 @@ -181,7 +330,7 @@ -(void)testIntersectRange2 otherRange = [CPTPlotRange plotRangeWithLocation:@0.0 length:@(-4.0)]; XCTAssertFalse([self.plotRange intersectsRange:otherRange], @"otherRange was {%g, %g}", otherRange.locationDouble, otherRange.lengthDouble); [self.plotRange intersectionPlotRange:otherRange]; - [self checkRangeWithLocation:1.0 length:0.0]; + [self checkRangeWithLocation:(double)NAN length:(double)NAN]; } -(void)testIntersectRangeNegative @@ -201,7 +350,7 @@ -(void)testIntersectRangeNegative otherRange = [CPTPlotRange plotRangeWithLocation:@5.0 length:@2.0]; XCTAssertFalse([self.plotRange intersectsRange:otherRange], @"otherRange was {%g, %g}", otherRange.locationDouble, otherRange.lengthDouble); [self.plotRange intersectionPlotRange:otherRange]; - [self checkRangeWithLocation:1.0 length:0.0]; + [self checkRangeWithLocation:(double)NAN length:(double)NAN]; } -(void)testIntersectRangeNegative2 @@ -221,7 +370,67 @@ -(void)testIntersectRangeNegative2 otherRange = [CPTPlotRange plotRangeWithLocation:@5.0 length:@(-4.0)]; XCTAssertFalse([self.plotRange intersectsRange:otherRange], @"otherRange was {%g, %g}", otherRange.locationDouble, otherRange.lengthDouble); [self.plotRange intersectionPlotRange:otherRange]; - [self checkRangeWithLocation:0.0 length:0.0]; + [self checkRangeWithLocation:(double)NAN length:(double)NAN]; +} + +-(void)testIntersectRangeInfinite1 +{ + self.plotRange.lengthDouble = HUGE_VAL; + + CPTPlotRange *otherRange = [CPTPlotRange plotRangeWithLocation:@0.0 length:@4.0]; + XCTAssertTrue([self.plotRange intersectsRange:otherRange], @"otherRange was {%g, %g}", otherRange.locationDouble, otherRange.lengthDouble); + [self.plotRange intersectionPlotRange:otherRange]; + [self checkRangeWithLocation:1.0 length:3.0]; +} + +-(void)testIntersectRangeInfinite2 +{ + self.plotRange.lengthDouble = HUGE_VAL; + + CPTPlotRange *otherRange = [CPTPlotRange plotRangeWithLocation:@0.0 length:@(HUGE_VAL)]; + XCTAssertTrue([self.plotRange intersectsRange:otherRange], @"otherRange was {%g, %g}", otherRange.locationDouble, otherRange.lengthDouble); + [self.plotRange intersectionPlotRange:otherRange]; + [self checkRangeWithLocation:1.0 length:HUGE_VAL]; +} + +-(void)testIntersectRangeInfinite3 +{ + self.plotRange.lengthDouble = HUGE_VAL; + + CPTPlotRange *otherRange = [CPTPlotRange plotRangeWithLocation:@0.0 length:@(-4.0)]; + XCTAssertFalse([self.plotRange intersectsRange:otherRange], @"otherRange was {%g, %g}", otherRange.locationDouble, otherRange.lengthDouble); + [self.plotRange intersectionPlotRange:otherRange]; + [self checkRangeWithLocation:(double)NAN length:(double)NAN]; +} + +-(void)testIntersectRangeNegativeInfinite1 +{ + self.plotRange.lengthDouble = -HUGE_VAL; + + CPTPlotRange *otherRange = [CPTPlotRange plotRangeWithLocation:@0.0 length:@4.0]; + XCTAssertTrue([self.plotRange intersectsRange:otherRange], @"otherRange was {%g, %g}", otherRange.locationDouble, otherRange.lengthDouble); + [self.plotRange intersectionPlotRange:otherRange]; + [self checkRangeWithLocation:1.0 length:-1.0]; +} + +-(void)testIntersectRangeNegativeInfinite2 +{ + self.plotRange.lengthDouble = -HUGE_VAL; + + CPTPlotRange *otherRange = [CPTPlotRange plotRangeWithLocation:@0.0 length:@(-HUGE_VAL)]; + XCTAssertTrue([self.plotRange intersectsRange:otherRange], @"otherRange was {%g, %g}", otherRange.locationDouble, otherRange.lengthDouble); + [self.plotRange intersectionPlotRange:otherRange]; + [self checkRangeWithLocation:0.0 length:-HUGE_VAL]; +} + +-(void)testIntersectRangeNegativeInfinite3 +{ + self.plotRange.lengthDouble = -HUGE_VAL; + + CPTPlotRange *otherRange = [CPTPlotRange plotRangeWithLocation:@10.0 length:@(-4.0)]; + XCTAssertFalse([self.plotRange intersectsRange:otherRange], @"otherRange was {%g, %g}", otherRange.locationDouble, otherRange.lengthDouble); + [self.plotRange intersectionPlotRange:otherRange]; + [self checkRangeWithLocation:(double)NAN length:(double)NAN]; } #pragma mark - @@ -370,6 +579,19 @@ -(void)testCompareToDecimal XCTAssertEqual([self.plotRange compareToDecimal:CPTDecimalFromDouble(2.0)], CPTPlotRangeComparisonResultNumberInRange, @"Test compareTo:2.0"); XCTAssertEqual([self.plotRange compareToDecimal:CPTDecimalFromDouble(3.0)], CPTPlotRangeComparisonResultNumberInRange, @"Test compareTo:3.0"); XCTAssertEqual([self.plotRange compareToDecimal:CPTDecimalFromDouble(3.001)], CPTPlotRangeComparisonResultNumberAboveRange, @"Test compareTo:3.001"); + XCTAssertEqual([self.plotRange compareToDecimal:CPTDecimalNaN()], CPTPlotRangeComparisonResultNumberUndefined, @"Test compareTo:NAN"); +} + +-(void)testCompareToDecimalInfinite +{ + self.plotRange.lengthDouble = HUGE_VAL; + + XCTAssertEqual([self.plotRange compareToDecimal:CPTDecimalFromDouble(0.999)], CPTPlotRangeComparisonResultNumberBelowRange, @"Test compareTo:0.999"); + XCTAssertEqual([self.plotRange compareToDecimal:CPTDecimalFromDouble(1.0)], CPTPlotRangeComparisonResultNumberInRange, @"Test compareTo:1.0"); + XCTAssertEqual([self.plotRange compareToDecimal:CPTDecimalFromDouble(2.0)], CPTPlotRangeComparisonResultNumberInRange, @"Test compareTo:2.0"); + XCTAssertEqual([self.plotRange compareToDecimal:CPTDecimalFromDouble(3.0)], CPTPlotRangeComparisonResultNumberInRange, @"Test compareTo:3.0"); + XCTAssertEqual([self.plotRange compareToDecimal:CPTDecimalFromDouble(3.001)], CPTPlotRangeComparisonResultNumberInRange, @"Test compareTo:3.001"); + XCTAssertEqual([self.plotRange compareToDecimal:CPTDecimalNaN()], CPTPlotRangeComparisonResultNumberUndefined, @"Test compareTo:NAN"); } -(void)testCompareToDecimalNegative @@ -381,6 +603,19 @@ -(void)testCompareToDecimalNegative XCTAssertEqual([self.plotRange compareToDecimal:CPTDecimalFromDouble(0.0)], CPTPlotRangeComparisonResultNumberInRange, @"Test compareTo:0.0"); XCTAssertEqual([self.plotRange compareToDecimal:CPTDecimalFromDouble(1.0)], CPTPlotRangeComparisonResultNumberInRange, @"Test compareTo:1.0"); XCTAssertEqual([self.plotRange compareToDecimal:CPTDecimalFromDouble(1.001)], CPTPlotRangeComparisonResultNumberAboveRange, @"Test compareTo:1.001"); + XCTAssertEqual([self.plotRange compareToDecimal:CPTDecimalNaN()], CPTPlotRangeComparisonResultNumberUndefined, @"Test compareTo:NAN"); +} + +-(void)testCompareToDecimalNegativeInfinite +{ + self.plotRange.lengthDouble = -HUGE_VAL; + + XCTAssertEqual([self.plotRange compareToDecimal:CPTDecimalFromDouble(-1.001)], CPTPlotRangeComparisonResultNumberInRange, @"Test compareTo:-1.001"); + XCTAssertEqual([self.plotRange compareToDecimal:CPTDecimalFromDouble(-1.0)], CPTPlotRangeComparisonResultNumberInRange, @"Test compareTo:-1.0"); + XCTAssertEqual([self.plotRange compareToDecimal:CPTDecimalFromDouble(0.0)], CPTPlotRangeComparisonResultNumberInRange, @"Test compareTo:0.0"); + XCTAssertEqual([self.plotRange compareToDecimal:CPTDecimalFromDouble(1.0)], CPTPlotRangeComparisonResultNumberInRange, @"Test compareTo:1.0"); + XCTAssertEqual([self.plotRange compareToDecimal:CPTDecimalFromDouble(1.001)], CPTPlotRangeComparisonResultNumberAboveRange, @"Test compareTo:1.001"); + XCTAssertEqual([self.plotRange compareToDecimal:CPTDecimalNaN()], CPTPlotRangeComparisonResultNumberUndefined, @"Test compareTo:NAN"); } -(void)testCompareToDouble @@ -390,6 +625,23 @@ -(void)testCompareToDouble XCTAssertEqual([self.plotRange compareToDouble:2.0], CPTPlotRangeComparisonResultNumberInRange, @"Test compareTo:2.0"); XCTAssertEqual([self.plotRange compareToDouble:3.0], CPTPlotRangeComparisonResultNumberInRange, @"Test compareTo:3.0"); XCTAssertEqual([self.plotRange compareToDouble:3.001], CPTPlotRangeComparisonResultNumberAboveRange, @"Test compareTo:3.001"); + XCTAssertEqual([self.plotRange compareToDouble:HUGE_VAL], CPTPlotRangeComparisonResultNumberAboveRange, @"Test compareTo:+INF"); + XCTAssertEqual([self.plotRange compareToDouble:-HUGE_VAL], CPTPlotRangeComparisonResultNumberBelowRange, @"Test compareTo:-INF"); + XCTAssertEqual([self.plotRange compareToDouble:(double)NAN], CPTPlotRangeComparisonResultNumberUndefined, @"Test compareTo:NAN"); +} + +-(void)testCompareToDoubleInfinite +{ + self.plotRange.lengthDouble = HUGE_VAL; + + XCTAssertEqual([self.plotRange compareToDouble:0.999], CPTPlotRangeComparisonResultNumberBelowRange, @"Test compareTo:0.999"); + XCTAssertEqual([self.plotRange compareToDouble:1.0], CPTPlotRangeComparisonResultNumberInRange, @"Test compareTo:1.0"); + XCTAssertEqual([self.plotRange compareToDouble:2.0], CPTPlotRangeComparisonResultNumberInRange, @"Test compareTo:2.0"); + XCTAssertEqual([self.plotRange compareToDouble:3.0], CPTPlotRangeComparisonResultNumberInRange, @"Test compareTo:3.0"); + XCTAssertEqual([self.plotRange compareToDouble:3.001], CPTPlotRangeComparisonResultNumberInRange, @"Test compareTo:3.001"); + XCTAssertEqual([self.plotRange compareToDouble:HUGE_VAL], CPTPlotRangeComparisonResultNumberInRange, @"Test compareTo:+INF"); + XCTAssertEqual([self.plotRange compareToDouble:-HUGE_VAL], CPTPlotRangeComparisonResultNumberBelowRange, @"Test compareTo:-INF"); + XCTAssertEqual([self.plotRange compareToDouble:(double)NAN], CPTPlotRangeComparisonResultNumberUndefined, @"Test compareTo:NAN"); } -(void)testCompareToDoubleNegative @@ -401,6 +653,23 @@ -(void)testCompareToDoubleNegative XCTAssertEqual([self.plotRange compareToDouble:0.0], CPTPlotRangeComparisonResultNumberInRange, @"Test compareTo:0.0"); XCTAssertEqual([self.plotRange compareToDouble:1.0], CPTPlotRangeComparisonResultNumberInRange, @"Test compareTo:1.0"); XCTAssertEqual([self.plotRange compareToDouble:1.001], CPTPlotRangeComparisonResultNumberAboveRange, @"Test compareTo:1.001"); + XCTAssertEqual([self.plotRange compareToDouble:HUGE_VAL], CPTPlotRangeComparisonResultNumberAboveRange, @"Test compareTo:+INF"); + XCTAssertEqual([self.plotRange compareToDouble:-HUGE_VAL], CPTPlotRangeComparisonResultNumberBelowRange, @"Test compareTo:-INF"); + XCTAssertEqual([self.plotRange compareToDouble:(double)NAN], CPTPlotRangeComparisonResultNumberUndefined, @"Test compareTo:NAN"); +} + +-(void)testCompareToDoubleNegativeInfinite +{ + self.plotRange.lengthDouble = -HUGE_VAL; + + XCTAssertEqual([self.plotRange compareToDouble:-1.001], CPTPlotRangeComparisonResultNumberInRange, @"Test compareTo:-1.001"); + XCTAssertEqual([self.plotRange compareToDouble:-1.0], CPTPlotRangeComparisonResultNumberInRange, @"Test compareTo:-1.0"); + XCTAssertEqual([self.plotRange compareToDouble:0.0], CPTPlotRangeComparisonResultNumberInRange, @"Test compareTo:0.0"); + XCTAssertEqual([self.plotRange compareToDouble:1.0], CPTPlotRangeComparisonResultNumberInRange, @"Test compareTo:1.0"); + XCTAssertEqual([self.plotRange compareToDouble:1.001], CPTPlotRangeComparisonResultNumberAboveRange, @"Test compareTo:1.001"); + XCTAssertEqual([self.plotRange compareToDouble:HUGE_VAL], CPTPlotRangeComparisonResultNumberAboveRange, @"Test compareTo:+INF"); + XCTAssertEqual([self.plotRange compareToDouble:-HUGE_VAL], CPTPlotRangeComparisonResultNumberInRange, @"Test compareTo:-INF"); + XCTAssertEqual([self.plotRange compareToDouble:(double)NAN], CPTPlotRangeComparisonResultNumberUndefined, @"Test compareTo:NAN"); } #pragma mark - @@ -423,11 +692,11 @@ -(void)checkRangeWithLocation:(double)loc length:(double)len NSDecimal newLocation = self.plotRange.locationDecimal; errMessage = [NSString stringWithFormat:@"expected location = %g, was %@", loc, NSDecimalString(&newLocation, nil)]; - XCTAssertTrue(CPTDecimalEquals(newLocation, CPTDecimalFromDouble(loc) ), @"%@", errMessage); + XCTAssertTrue(CPTDecimalEquals(newLocation, CPTDecimalFromDouble(loc)), @"%@", errMessage); NSDecimal newLength = self.plotRange.lengthDecimal; errMessage = [NSString stringWithFormat:@"expected location = %g, was %@", loc, NSDecimalString(&newLength, nil)]; - XCTAssertTrue(CPTDecimalEquals(newLength, CPTDecimalFromDouble(len) ), @"%@", errMessage); + XCTAssertTrue(CPTDecimalEquals(newLength, CPTDecimalFromDouble(len)), @"%@", errMessage); } @end diff --git a/CorePlot/framework/Source/CPTPlotSpace.h b/CorePlot/framework/Source/CPTPlotSpace.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTPlotSpace.m b/CorePlot/framework/Source/CPTPlotSpace.m old mode 100755 new mode 100644 index 628d255..738a85a --- a/CorePlot/framework/Source/CPTPlotSpace.m +++ b/CorePlot/framework/Source/CPTPlotSpace.m @@ -92,7 +92,7 @@ @implementation CPTPlotSpace **/ -(nonnull instancetype)init { - if ( (self = [super init]) ) { + if ((self = [super init])) { identifier = nil; allowsUserInteraction = NO; isDragging = NO; @@ -143,7 +143,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder */ -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super init]) ) { + if ((self = [super init])) { graph = [coder decodeObjectOfClass:[CPTGraph class] forKey:@"CPTPlotSpace.graph"]; identifier = [[coder decodeObjectOfClass:[NSObject class] @@ -666,7 +666,7 @@ -(void)scaleToFitPlots:(nullable CPTPlotArray *)plots forCoordinate:(CPTCoordina // Set range if ( unionRange ) { - if ( CPTDecimalEquals(unionRange.lengthDecimal, CPTDecimalFromInteger(0) ) ) { + if ( CPTDecimalEquals(unionRange.lengthDecimal, CPTDecimalFromInteger(0))) { [unionRange unionPlotRange:[self plotRangeForCoordinate:coordinate]]; } [self setPlotRange:unionRange forCoordinate:coordinate]; @@ -702,7 +702,7 @@ -(void)scaleToFitEntirePlots:(nullable CPTPlotArray *)plots forCoordinate:(CPTCo // Set range if ( unionRange ) { - if ( CPTDecimalEquals(unionRange.lengthDecimal, CPTDecimalFromInteger(0) ) ) { + if ( CPTDecimalEquals(unionRange.lengthDecimal, CPTDecimalFromInteger(0))) { [unionRange unionPlotRange:[self plotRangeForCoordinate:coordinate]]; } [self setPlotRange:unionRange forCoordinate:coordinate]; diff --git a/CorePlot/framework/Source/CPTPlotSpaceAnnotation.h b/CorePlot/framework/Source/CPTPlotSpaceAnnotation.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTPlotSpaceAnnotation.m b/CorePlot/framework/Source/CPTPlotSpaceAnnotation.m old mode 100755 new mode 100644 index 57dde69..db08c43 --- a/CorePlot/framework/Source/CPTPlotSpaceAnnotation.m +++ b/CorePlot/framework/Source/CPTPlotSpaceAnnotation.m @@ -60,7 +60,7 @@ -(nonnull instancetype)initWithPlotSpace:(nonnull CPTPlotSpace *)newPlotSpace an { NSParameterAssert(newPlotSpace); - if ( (self = [super init]) ) { + if ((self = [super init])) { plotSpace = newPlotSpace; self.anchorPlotPoint = newPlotPoint; @@ -112,7 +112,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder */ -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super initWithCoder:coder]) ) { + if ((self = [super initWithCoder:coder])) { self.anchorPlotPoint = [[coder decodeObjectOfClasses:[NSSet setWithArray:@[[NSArray class], [NSNumber class]]] forKey:@"CPTPlotSpaceAnnotation.anchorPlotPoint"] copy]; @@ -180,7 +180,7 @@ -(void)positionContentLayer content.anchorPoint = self.contentAnchorPoint; content.position = newPosition; - content.transform = CATransform3DMakeRotation(self.rotation, CPTFloat(0.0), CPTFloat(0.0), CPTFloat(1.0) ); + content.transform = CATransform3DMakeRotation(self.rotation, CPTFloat(0.0), CPTFloat(0.0), CPTFloat(1.0)); [content pixelAlign]; } } @@ -201,7 +201,7 @@ -(void)setAnchorPlotPoint:(nullable CPTNumberArray *)newPlotPoint self.anchorCount = anchorPlotPoint.count; - NSDecimal *decimalPoint = calloc(self.anchorCount, sizeof(NSDecimal) ); + NSDecimal *decimalPoint = calloc(self.anchorCount, sizeof(NSDecimal)); for ( NSUInteger i = 0; i < self.anchorCount; i++ ) { decimalPoint[i] = anchorPlotPoint[i].decimalValue; } diff --git a/CorePlot/framework/Source/CPTPlotSpaceTests.h b/CorePlot/framework/Source/CPTPlotSpaceTests.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTPlotSpaceTests.m b/CorePlot/framework/Source/CPTPlotSpaceTests.m old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTPlotSymbol.h b/CorePlot/framework/Source/CPTPlotSymbol.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTPlotSymbol.m b/CorePlot/framework/Source/CPTPlotSymbol.m old mode 100755 new mode 100644 index d8b6030..9bae6be --- a/CorePlot/framework/Source/CPTPlotSymbol.m +++ b/CorePlot/framework/Source/CPTPlotSymbol.m @@ -98,7 +98,7 @@ @implementation CPTPlotSymbol **/ -(nonnull instancetype)init { - if ( (self = [super init]) ) { + if ((self = [super init])) { anchorPoint = CPTPointMake(0.5, 0.5); size = CPTSizeMake(5.0, 5.0); symbolType = CPTPlotSymbolTypeNone; @@ -151,7 +151,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super init]) ) { + if ((self = [super init])) { anchorPoint = [coder decodeCPTPointForKey:@"CPTPlotSymbol.anchorPoint"]; size = [coder decodeCPTSizeForKey:@"CPTPlotSymbol.size"]; symbolType = (CPTPlotSymbolType)[coder decodeIntegerForKey:@"CPTPlotSymbol.symbolType"]; @@ -192,7 +192,7 @@ +(BOOL)supportsSecureCoding -(void)setSize:(CGSize)newSize { - if ( !CGSizeEqualToSize(newSize, size) ) { + if ( !CGSizeEqualToSize(newSize, size)) { size = newSize; self.cachedSymbolPath = NULL; } @@ -479,7 +479,7 @@ -(void)renderInContext:(nonnull CGContextRef)context atPoint:(CGPoint)center sca CGLayerRef theCachedLayer = self.cachedLayer; CGFloat theCachedScale = self.cachedScale; - if ( !theCachedLayer || (theCachedScale != scale) ) { + if ( !theCachedLayer || (theCachedScale != scale)) { CGSize layerSize = [self layerSizeForScale:scale]; self.anchorPoint = CPTPointMake(0.5, 0.5); @@ -488,7 +488,7 @@ -(void)renderInContext:(nonnull CGContextRef)context atPoint:(CGPoint)center sca CGContextRef layerContext = CGLayerGetContext(newLayer); [self renderAsVectorInContext:layerContext - atPoint:CPTPointMake(layerSize.width * CPTFloat(0.5), layerSize.height * CPTFloat(0.5) ) + atPoint:CPTPointMake(layerSize.width * CPTFloat(0.5), layerSize.height * CPTFloat(0.5)) scale:scale]; self.cachedLayer = newLayer; @@ -500,18 +500,18 @@ -(void)renderInContext:(nonnull CGContextRef)context atPoint:(CGPoint)center sca if ( theCachedLayer ) { CGSize layerSize = CGLayerGetSize(theCachedLayer); - if ( scale != CPTFloat(1.0) ) { + if ( scale != CPTFloat(1.0)) { layerSize.width /= scale; layerSize.height /= scale; } CGSize symbolSize = self.size; - CGPoint origin = CPTPointMake(center.x - layerSize.width * CPTFloat(0.5) - symbolSize.width * (symbolAnchor.x - CPTFloat(0.5) ), - center.y - layerSize.height * CPTFloat(0.5) - symbolSize.height * (symbolAnchor.y - CPTFloat(0.5) ) ); + CGPoint origin = CPTPointMake(center.x - layerSize.width * CPTFloat(0.5) - symbolSize.width * (symbolAnchor.x - CPTFloat(0.5)), + center.y - layerSize.height * CPTFloat(0.5) - symbolSize.height * (symbolAnchor.y - CPTFloat(0.5))); if ( alignToPixels ) { - if ( scale == CPTFloat(1.0) ) { + if ( scale == CPTFloat(1.0)) { origin.x = round(origin.x); origin.y = round(origin.y); } @@ -599,12 +599,12 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context atPoint:(CGPoint)ce CPTShadow *myShadow = self.shadow; CGContextSaveGState(context); - CGContextTranslateCTM(context, center.x + (symbolAnchor.x - CPTFloat(0.5) ) * symbolSize.width, center.y + (symbolAnchor.y - CPTFloat(0.5) ) * symbolSize.height); + CGContextTranslateCTM(context, center.x + (symbolAnchor.x - CPTFloat(0.5)) * symbolSize.width, center.y + (symbolAnchor.y - CPTFloat(0.5)) * symbolSize.height); CGContextScaleCTM(context, scale, scale); [myShadow setShadowInContext:context]; // redraw only symbol rectangle - CGSize halfSize = CPTSizeMake(symbolSize.width * CPTFloat(0.5), symbolSize.height * CPTFloat(0.5) ); + CGSize halfSize = CPTSizeMake(symbolSize.width * CPTFloat(0.5), symbolSize.height * CPTFloat(0.5)); CGRect bounds = CPTRectMake(-halfSize.width, -halfSize.height, symbolSize.width, symbolSize.height); CGRect symbolRect = bounds; @@ -612,7 +612,7 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context atPoint:(CGPoint)ce if ( myShadow ) { CGFloat shadowRadius = myShadow.shadowBlurRadius; CGSize shadowOffset = myShadow.shadowOffset; - symbolRect = CGRectInset(symbolRect, -(ABS(shadowOffset.width) + ABS(shadowRadius) ), -(ABS(shadowOffset.height) + ABS(shadowRadius) ) ); + symbolRect = CGRectInset(symbolRect, -(ABS(shadowOffset.width) + ABS(shadowRadius)), -(ABS(shadowOffset.height) + ABS(shadowRadius))); } if ( theLineStyle ) { CGFloat lineWidth = ABS(theLineStyle.lineWidth); @@ -626,7 +626,7 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context atPoint:(CGPoint)ce if ( theFill ) { // use fillRect instead of fillPath so that images and gradients are properly centered in the symbol CGContextSaveGState(context); - if ( !CGPathIsEmpty(theSymbolPath) ) { + if ( !CGPathIsEmpty(theSymbolPath)) { CGContextBeginPath(context); CGContextAddPath(context, theSymbolPath); if ( self.usesEvenOddClipRule ) { @@ -666,7 +666,7 @@ -(nonnull CGPathRef)newSymbolPath { CGFloat dx, dy; CGSize symbolSize = self.size; - CGSize halfSize = CPTSizeMake(symbolSize.width * CPTFloat(0.5), symbolSize.height * CPTFloat(0.5) ); + CGSize halfSize = CPTSizeMake(symbolSize.width * CPTFloat(0.5), symbolSize.height * CPTFloat(0.5)); CGMutablePathRef symbolPath = CGPathCreateMutable(); @@ -676,11 +676,11 @@ -(nonnull CGPathRef)newSymbolPath break; case CPTPlotSymbolTypeRectangle: - CGPathAddRect(symbolPath, NULL, CPTRectMake(-halfSize.width, -halfSize.height, symbolSize.width, symbolSize.height) ); + CGPathAddRect(symbolPath, NULL, CPTRectMake(-halfSize.width, -halfSize.height, symbolSize.width, symbolSize.height)); break; case CPTPlotSymbolTypeEllipse: - CGPathAddEllipseInRect(symbolPath, NULL, CPTRectMake(-halfSize.width, -halfSize.height, symbolSize.width, symbolSize.height) ); + CGPathAddEllipseInRect(symbolPath, NULL, CPTRectMake(-halfSize.width, -halfSize.height, symbolSize.width, symbolSize.height)); break; case CPTPlotSymbolTypeCross: @@ -693,38 +693,38 @@ -(nonnull CGPathRef)newSymbolPath case CPTPlotSymbolTypePlus: CGPathMoveToPoint(symbolPath, NULL, CPTFloat(0.0), halfSize.height); CGPathAddLineToPoint(symbolPath, NULL, CPTFloat(0.0), -halfSize.height); - CGPathMoveToPoint(symbolPath, NULL, -halfSize.width, CPTFloat(0.0) ); - CGPathAddLineToPoint(symbolPath, NULL, halfSize.width, CPTFloat(0.0) ); + CGPathMoveToPoint(symbolPath, NULL, -halfSize.width, CPTFloat(0.0)); + CGPathAddLineToPoint(symbolPath, NULL, halfSize.width, CPTFloat(0.0)); break; case CPTPlotSymbolTypePentagon: CGPathMoveToPoint(symbolPath, NULL, CPTFloat(0.0), halfSize.height); - CGPathAddLineToPoint(symbolPath, NULL, halfSize.width * CPTFloat(0.95105651630), halfSize.height * CPTFloat(0.30901699437) ); - CGPathAddLineToPoint(symbolPath, NULL, halfSize.width * CPTFloat(0.58778525229), -halfSize.height * CPTFloat(0.80901699437) ); - CGPathAddLineToPoint(symbolPath, NULL, -halfSize.width * CPTFloat(0.58778525229), -halfSize.height * CPTFloat(0.80901699437) ); - CGPathAddLineToPoint(symbolPath, NULL, -halfSize.width * CPTFloat(0.95105651630), halfSize.height * CPTFloat(0.30901699437) ); + CGPathAddLineToPoint(symbolPath, NULL, halfSize.width * CPTFloat(0.95105651630), halfSize.height * CPTFloat(0.30901699437)); + CGPathAddLineToPoint(symbolPath, NULL, halfSize.width * CPTFloat(0.58778525229), -halfSize.height * CPTFloat(0.80901699437)); + CGPathAddLineToPoint(symbolPath, NULL, -halfSize.width * CPTFloat(0.58778525229), -halfSize.height * CPTFloat(0.80901699437)); + CGPathAddLineToPoint(symbolPath, NULL, -halfSize.width * CPTFloat(0.95105651630), halfSize.height * CPTFloat(0.30901699437)); CGPathCloseSubpath(symbolPath); break; case CPTPlotSymbolTypeStar: CGPathMoveToPoint(symbolPath, NULL, CPTFloat(0.0), halfSize.height); - CGPathAddLineToPoint(symbolPath, NULL, halfSize.width * CPTFloat(0.22451398829), halfSize.height * CPTFloat(0.30901699437) ); - CGPathAddLineToPoint(symbolPath, NULL, halfSize.width * CPTFloat(0.95105651630), halfSize.height * CPTFloat(0.30901699437) ); - CGPathAddLineToPoint(symbolPath, NULL, halfSize.width * CPTFloat(0.36327126400), -halfSize.height * CPTFloat(0.11803398875) ); - CGPathAddLineToPoint(symbolPath, NULL, halfSize.width * CPTFloat(0.58778525229), -halfSize.height * CPTFloat(0.80901699437) ); - CGPathAddLineToPoint(symbolPath, NULL, CPTFloat(0.0), -halfSize.height * CPTFloat(0.38196601125) ); - CGPathAddLineToPoint(symbolPath, NULL, -halfSize.width * CPTFloat(0.58778525229), -halfSize.height * CPTFloat(0.80901699437) ); - CGPathAddLineToPoint(symbolPath, NULL, -halfSize.width * CPTFloat(0.36327126400), -halfSize.height * CPTFloat(0.11803398875) ); - CGPathAddLineToPoint(symbolPath, NULL, -halfSize.width * CPTFloat(0.95105651630), halfSize.height * CPTFloat(0.30901699437) ); - CGPathAddLineToPoint(symbolPath, NULL, -halfSize.width * CPTFloat(0.22451398829), halfSize.height * CPTFloat(0.30901699437) ); + CGPathAddLineToPoint(symbolPath, NULL, halfSize.width * CPTFloat(0.22451398829), halfSize.height * CPTFloat(0.30901699437)); + CGPathAddLineToPoint(symbolPath, NULL, halfSize.width * CPTFloat(0.95105651630), halfSize.height * CPTFloat(0.30901699437)); + CGPathAddLineToPoint(symbolPath, NULL, halfSize.width * CPTFloat(0.36327126400), -halfSize.height * CPTFloat(0.11803398875)); + CGPathAddLineToPoint(symbolPath, NULL, halfSize.width * CPTFloat(0.58778525229), -halfSize.height * CPTFloat(0.80901699437)); + CGPathAddLineToPoint(symbolPath, NULL, CPTFloat(0.0), -halfSize.height * CPTFloat(0.38196601125)); + CGPathAddLineToPoint(symbolPath, NULL, -halfSize.width * CPTFloat(0.58778525229), -halfSize.height * CPTFloat(0.80901699437)); + CGPathAddLineToPoint(symbolPath, NULL, -halfSize.width * CPTFloat(0.36327126400), -halfSize.height * CPTFloat(0.11803398875)); + CGPathAddLineToPoint(symbolPath, NULL, -halfSize.width * CPTFloat(0.95105651630), halfSize.height * CPTFloat(0.30901699437)); + CGPathAddLineToPoint(symbolPath, NULL, -halfSize.width * CPTFloat(0.22451398829), halfSize.height * CPTFloat(0.30901699437)); CGPathCloseSubpath(symbolPath); break; case CPTPlotSymbolTypeDiamond: CGPathMoveToPoint(symbolPath, NULL, CPTFloat(0.0), halfSize.height); - CGPathAddLineToPoint(symbolPath, NULL, halfSize.width, CPTFloat(0.0) ); + CGPathAddLineToPoint(symbolPath, NULL, halfSize.width, CPTFloat(0.0)); CGPathAddLineToPoint(symbolPath, NULL, CPTFloat(0.0), -halfSize.height); - CGPathAddLineToPoint(symbolPath, NULL, -halfSize.width, CPTFloat(0.0) ); + CGPathAddLineToPoint(symbolPath, NULL, -halfSize.width, CPTFloat(0.0)); CGPathCloseSubpath(symbolPath); break; @@ -739,8 +739,8 @@ -(nonnull CGPathRef)newSymbolPath break; case CPTPlotSymbolTypeDash: - CGPathMoveToPoint(symbolPath, NULL, halfSize.width, CPTFloat(0.0) ); - CGPathAddLineToPoint(symbolPath, NULL, -halfSize.width, CPTFloat(0.0) ); + CGPathMoveToPoint(symbolPath, NULL, halfSize.width, CPTFloat(0.0)); + CGPathAddLineToPoint(symbolPath, NULL, -halfSize.width, CPTFloat(0.0)); break; case CPTPlotSymbolTypeHexagon: @@ -778,7 +778,7 @@ -(nonnull CGPathRef)newSymbolPath CGAffineTransform scaleTransform = CGAffineTransformScale(CGAffineTransformIdentity, dx1, dy1); scaleTransform = CGAffineTransformConcat(scaleTransform, - CGAffineTransformMakeTranslation(-halfSize.width, -halfSize.height) ); + CGAffineTransformMakeTranslation(-halfSize.width, -halfSize.height)); CGPathAddPath(symbolPath, &scaleTransform, customPath); } } @@ -808,7 +808,7 @@ -(nullable id)debugQuickLookObject self.anchorPoint = CPTPointMake(0.5, 0.5); - [self renderAsVectorInContext:context atPoint:CGPointMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds) ) scale:scale]; + [self renderAsVectorInContext:context atPoint:CGPointMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds)) scale:scale]; self.anchorPoint = symbolAnchor; }); diff --git a/CorePlot/framework/Source/CPTRangePlot.h b/CorePlot/framework/Source/CPTRangePlot.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTRangePlot.m b/CorePlot/framework/Source/CPTRangePlot.m old mode 100755 new mode 100644 index 43ea065..60249e1 --- a/CorePlot/framework/Source/CPTRangePlot.m +++ b/CorePlot/framework/Source/CPTRangePlot.m @@ -172,7 +172,7 @@ +(void)initialize **/ -(nonnull instancetype)initWithFrame:(CGRect)newFrame { - if ( (self = [super initWithFrame:newFrame]) ) { + if ((self = [super initWithFrame:newFrame])) { barLineStyle = [[CPTLineStyle alloc] init]; areaFill = nil; areaBorderLineStyle = nil; @@ -190,7 +190,7 @@ -(nonnull instancetype)initWithFrame:(CGRect)newFrame -(nonnull instancetype)initWithLayer:(nonnull id)layer { - if ( (self = [super initWithLayer:layer]) ) { + if ((self = [super initWithLayer:layer])) { CPTRangePlot *theLayer = (CPTRangePlot *)layer; barLineStyle = theLayer->barLineStyle; @@ -226,7 +226,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super initWithCoder:coder]) ) { + if ((self = [super initWithCoder:coder])) { barLineStyle = [[coder decodeObjectOfClass:[CPTLineStyle class] forKey:@"CPTRangePlot.barLineStyle"] copy]; barWidth = [coder decodeCGFloatForKey:@"CPTRangePlot.barWidth"]; @@ -274,9 +274,9 @@ -(void)calculatePointsToDraw:(nonnull BOOL *)pointDrawFlags numberOfPoints:(NSUI } } else { - CPTPlotRangeComparisonResult *xRangeFlags = calloc(dataCount, sizeof(CPTPlotRangeComparisonResult) ); - CPTPlotRangeComparisonResult *yRangeFlags = calloc(dataCount, sizeof(CPTPlotRangeComparisonResult) ); - BOOL *nanFlags = calloc(dataCount, sizeof(BOOL) ); + CPTPlotRangeComparisonResult *xRangeFlags = calloc(dataCount, sizeof(CPTPlotRangeComparisonResult)); + CPTPlotRangeComparisonResult *yRangeFlags = calloc(dataCount, sizeof(CPTPlotRangeComparisonResult)); + BOOL *nanFlags = calloc(dataCount, sizeof(BOOL)); CPTPlotRange *xRange = xyPlotSpace.xRange; CPTPlotRange *yRange = xyPlotSpace.yRange; @@ -343,7 +343,7 @@ -(void)calculateViewPoints:(nonnull CGPointError *)viewPoints withDrawPointFlags const double low = lowBytes[i]; const double left = leftBytes[i]; const double right = rightBytes[i]; - if ( !drawPointFlags[i] || isnan(x) || isnan(y) ) { + if ( !drawPointFlags[i] || isnan(x) || isnan(y)) { viewPoints[i].x = CPTNAN; // depending coordinates viewPoints[i].y = CPTNAN; } @@ -393,7 +393,7 @@ -(void)calculateViewPoints:(nonnull CGPointError *)viewPoints withDrawPointFlags const NSDecimal left = leftBytes[i]; const NSDecimal right = rightBytes[i]; - if ( !drawPointFlags[i] || NSDecimalIsNotANumber(&x) || NSDecimalIsNotANumber(&y) ) { + if ( !drawPointFlags[i] || NSDecimalIsNotANumber(&x) || NSDecimalIsNotANumber(&y)) { viewPoints[i].x = CPTNAN; // depending coordinates viewPoints[i].y = CPTNAN; } @@ -405,7 +405,7 @@ -(void)calculateViewPoints:(nonnull CGPointError *)viewPoints withDrawPointFlags viewPoints[i].x = pos.x; viewPoints[i].y = pos.y; - if ( !NSDecimalIsNotANumber(&high) ) { + if ( !NSDecimalIsNotANumber(&high)) { plotPoint[CPTCoordinateX] = x; NSDecimal yh; NSDecimalAdd(&yh, &y, &high, NSRoundPlain); @@ -417,7 +417,7 @@ -(void)calculateViewPoints:(nonnull CGPointError *)viewPoints withDrawPointFlags viewPoints[i].high = CPTNAN; } - if ( !NSDecimalIsNotANumber(&low) ) { + if ( !NSDecimalIsNotANumber(&low)) { plotPoint[CPTCoordinateX] = x; NSDecimal yl; NSDecimalSubtract(&yl, &y, &low, NSRoundPlain); @@ -429,7 +429,7 @@ -(void)calculateViewPoints:(nonnull CGPointError *)viewPoints withDrawPointFlags viewPoints[i].low = CPTNAN; } - if ( !NSDecimalIsNotANumber(&left) ) { + if ( !NSDecimalIsNotANumber(&left)) { NSDecimal xl; NSDecimalSubtract(&xl, &x, &left, NSRoundPlain); plotPoint[CPTCoordinateX] = xl; @@ -440,7 +440,7 @@ -(void)calculateViewPoints:(nonnull CGPointError *)viewPoints withDrawPointFlags else { viewPoints[i].left = CPTNAN; } - if ( !NSDecimalIsNotANumber(&right) ) { + if ( !NSDecimalIsNotANumber(&right)) { NSDecimal xr; NSDecimalAdd(&xr, &x, &right, NSRoundPlain); plotPoint[CPTCoordinateX] = xr; @@ -460,22 +460,22 @@ -(void)alignViewPointsToUserSpace:(nonnull CGPointError *)viewPoints withContext { // Align to device pixels if there is a data line. // Otherwise, align to view space, so fills are sharp at edges. - if ( self.barLineStyle.lineWidth > CPTFloat(0.0) ) { + if ( self.barLineStyle.lineWidth > CPTFloat(0.0)) { dispatch_apply(dataCount, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(size_t i) { if ( drawPointFlags[i] ) { CGFloat x = viewPoints[i].x; CGFloat y = viewPoints[i].y; - CGPoint pos = CPTAlignPointToUserSpace(context, CPTPointMake(viewPoints[i].x, viewPoints[i].y) ); + CGPoint pos = CPTAlignPointToUserSpace(context, CPTPointMake(viewPoints[i].x, viewPoints[i].y)); viewPoints[i].x = pos.x; viewPoints[i].y = pos.y; - pos = CPTAlignPointToUserSpace(context, CPTPointMake(x, viewPoints[i].high) ); + pos = CPTAlignPointToUserSpace(context, CPTPointMake(x, viewPoints[i].high)); viewPoints[i].high = pos.y; - pos = CPTAlignPointToUserSpace(context, CPTPointMake(x, viewPoints[i].low) ); + pos = CPTAlignPointToUserSpace(context, CPTPointMake(x, viewPoints[i].low)); viewPoints[i].low = pos.y; - pos = CPTAlignPointToUserSpace(context, CPTPointMake(viewPoints[i].left, y) ); + pos = CPTAlignPointToUserSpace(context, CPTPointMake(viewPoints[i].left, y)); viewPoints[i].left = pos.x; - pos = CPTAlignPointToUserSpace(context, CPTPointMake(viewPoints[i].right, y) ); + pos = CPTAlignPointToUserSpace(context, CPTPointMake(viewPoints[i].right, y)); viewPoints[i].right = pos.x; } }); @@ -485,17 +485,17 @@ -(void)alignViewPointsToUserSpace:(nonnull CGPointError *)viewPoints withContext if ( drawPointFlags[i] ) { CGFloat x = viewPoints[i].x; CGFloat y = viewPoints[i].y; - CGPoint pos = CPTAlignIntegralPointToUserSpace(context, CPTPointMake(viewPoints[i].x, viewPoints[i].y) ); + CGPoint pos = CPTAlignIntegralPointToUserSpace(context, CPTPointMake(viewPoints[i].x, viewPoints[i].y)); viewPoints[i].x = pos.x; viewPoints[i].y = pos.y; - pos = CPTAlignIntegralPointToUserSpace(context, CPTPointMake(x, viewPoints[i].high) ); + pos = CPTAlignIntegralPointToUserSpace(context, CPTPointMake(x, viewPoints[i].high)); viewPoints[i].high = pos.y; - pos = CPTAlignIntegralPointToUserSpace(context, CPTPointMake(x, viewPoints[i].low) ); + pos = CPTAlignIntegralPointToUserSpace(context, CPTPointMake(x, viewPoints[i].low)); viewPoints[i].low = pos.y; - pos = CPTAlignIntegralPointToUserSpace(context, CPTPointMake(viewPoints[i].left, y) ); + pos = CPTAlignIntegralPointToUserSpace(context, CPTPointMake(viewPoints[i].left, y)); viewPoints[i].left = pos.x; - pos = CPTAlignIntegralPointToUserSpace(context, CPTPointMake(viewPoints[i].right, y) ); + pos = CPTAlignIntegralPointToUserSpace(context, CPTPointMake(viewPoints[i].right, y)); viewPoints[i].right = pos.x; } }); @@ -514,7 +514,7 @@ -(NSInteger)extremeDrawnPointIndexForFlags:(nonnull BOOL *)pointDrawFlags number result = i; break; } - if ( (delta < 0) && (i == 0) ) { + if ((delta < 0) && (i == 0)) { break; } } @@ -637,7 +637,7 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context CPTMutableNumericData *xValueData = [self cachedNumbersForField:CPTRangePlotFieldX]; CPTMutableNumericData *yValueData = [self cachedNumbersForField:CPTRangePlotFieldY]; - if ( (xValueData == nil) || (yValueData == nil) ) { + if ((xValueData == nil) || (yValueData == nil)) { return; } NSUInteger dataCount = self.cachedDataCount; @@ -651,8 +651,8 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context [super renderAsVectorInContext:context]; // Calculate view points, and align to user space - CGPointError *viewPoints = calloc(dataCount, sizeof(CGPointError) ); - BOOL *drawPointFlags = calloc(dataCount, sizeof(BOOL) ); + CGPointError *viewPoints = calloc(dataCount, sizeof(CGPointError)); + BOOL *drawPointFlags = calloc(dataCount, sizeof(BOOL)); CPTXYPlotSpace *thePlotSpace = (CPTXYPlotSpace *)self.plotSpace; [self calculatePointsToDraw:drawPointFlags numberOfPoints:dataCount forPlotSpace:thePlotSpace includeVisiblePointsOnly:NO]; @@ -673,11 +673,11 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context for ( NSUInteger i = (NSUInteger)firstDrawnPointIndex; i <= (NSUInteger)lastDrawnPointIndex; i++ ) { CGFloat x = viewPoints[i].x; CGFloat y = viewPoints[i].high; - if ( isnan(y) ) { + if ( isnan(y)) { y = viewPoints[i].y; } - if ( !isnan(x) && !isnan(y) ) { + if ( !isnan(x) && !isnan(y)) { if ( i == (NSUInteger)firstDrawnPointIndex ) { CGPathMoveToPoint(fillPath, NULL, x, y); } @@ -691,11 +691,11 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context for ( NSUInteger j = (NSUInteger)lastDrawnPointIndex; j >= (NSUInteger)firstDrawnPointIndex; j-- ) { CGFloat x = viewPoints[j].x; CGFloat y = viewPoints[j].low; - if ( isnan(y) ) { + if ( isnan(y)) { y = viewPoints[j].y; } - if ( !isnan(x) && !isnan(y) ) { + if ( !isnan(x) && !isnan(y)) { CGPathAddLineToPoint(fillPath, NULL, x, y); } if ( j == (NSUInteger)firstDrawnPointIndex ) { @@ -724,7 +724,7 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context CGPathRelease(fillPath); } - CGSize halfGapSize = CPTSizeMake(self.gapWidth * CPTFloat(0.5), self.gapHeight * CPTFloat(0.5) ); + CGSize halfGapSize = CPTSizeMake(self.gapWidth * CPTFloat(0.5), self.gapHeight * CPTFloat(0.5)); CGFloat halfBarWidth = self.barWidth * CPTFloat(0.5); BOOL alignPoints = self.alignsPointsToPixels; @@ -749,18 +749,18 @@ -(void)drawRangeInContext:(nonnull CGContextRef)context halfBarWidth:(CGFloat)halfBarWidth alignPoints:(BOOL)alignPoints { - if ( [lineStyle isKindOfClass:[CPTLineStyle class]] && !isnan(viewPoint->x) && !isnan(viewPoint->y) ) { + if ( [lineStyle isKindOfClass:[CPTLineStyle class]] && !isnan(viewPoint->x) && !isnan(viewPoint->y)) { CPTAlignPointFunction alignmentFunction = CPTAlignPointToUserSpace; CGFloat lineWidth = lineStyle.lineWidth; - if ( (self.contentsScale > CPTFloat(1.0) ) && (round(lineWidth) == lineWidth) ) { + if ((self.contentsScale > CPTFloat(1.0)) && (round(lineWidth) == lineWidth)) { alignmentFunction = CPTAlignIntegralPointToUserSpace; } CGMutablePathRef path = CGPathCreateMutable(); // centre-high - if ( !isnan(viewPoint->high) ) { + if ( !isnan(viewPoint->high)) { CGPoint alignedHighPoint = CPTPointMake(viewPoint->x, viewPoint->y + halfGapSize.height); CGPoint alignedLowPoint = CPTPointMake(viewPoint->x, viewPoint->high); if ( alignPoints ) { @@ -772,7 +772,7 @@ -(void)drawRangeInContext:(nonnull CGContextRef)context } // centre-low - if ( !isnan(viewPoint->low) ) { + if ( !isnan(viewPoint->low)) { CGPoint alignedHighPoint = CPTPointMake(viewPoint->x, viewPoint->y - halfGapSize.height); CGPoint alignedLowPoint = CPTPointMake(viewPoint->x, viewPoint->low); if ( alignPoints ) { @@ -784,7 +784,7 @@ -(void)drawRangeInContext:(nonnull CGContextRef)context } // top bar - if ( !isnan(viewPoint->high) ) { + if ( !isnan(viewPoint->high)) { CGPoint alignedHighPoint = CPTPointMake(viewPoint->x - halfBarWidth, viewPoint->high); CGPoint alignedLowPoint = CPTPointMake(viewPoint->x + halfBarWidth, viewPoint->high); if ( alignPoints ) { @@ -796,7 +796,7 @@ -(void)drawRangeInContext:(nonnull CGContextRef)context } // bottom bar - if ( !isnan(viewPoint->low) ) { + if ( !isnan(viewPoint->low)) { CGPoint alignedHighPoint = CPTPointMake(viewPoint->x - halfBarWidth, viewPoint->low); CGPoint alignedLowPoint = CPTPointMake(viewPoint->x + halfBarWidth, viewPoint->low); if ( alignPoints ) { @@ -808,7 +808,7 @@ -(void)drawRangeInContext:(nonnull CGContextRef)context } // centre-left - if ( !isnan(viewPoint->left) ) { + if ( !isnan(viewPoint->left)) { CGPoint alignedHighPoint = CPTPointMake(viewPoint->x - halfGapSize.width, viewPoint->y); CGPoint alignedLowPoint = CPTPointMake(viewPoint->left, viewPoint->y); if ( alignPoints ) { @@ -820,7 +820,7 @@ -(void)drawRangeInContext:(nonnull CGContextRef)context } // centre-right - if ( !isnan(viewPoint->right) ) { + if ( !isnan(viewPoint->right)) { CGPoint alignedHighPoint = CPTPointMake(viewPoint->x + halfGapSize.width, viewPoint->y); CGPoint alignedLowPoint = CPTPointMake(viewPoint->right, viewPoint->y); if ( alignPoints ) { @@ -832,7 +832,7 @@ -(void)drawRangeInContext:(nonnull CGContextRef)context } // left bar - if ( !isnan(viewPoint->left) ) { + if ( !isnan(viewPoint->left)) { CGPoint alignedHighPoint = CPTPointMake(viewPoint->left, viewPoint->y - halfBarWidth); CGPoint alignedLowPoint = CPTPointMake(viewPoint->left, viewPoint->y + halfBarWidth); if ( alignPoints ) { @@ -844,7 +844,7 @@ -(void)drawRangeInContext:(nonnull CGContextRef)context } // right bar - if ( !isnan(viewPoint->right) ) { + if ( !isnan(viewPoint->right)) { CGPoint alignedHighPoint = CPTPointMake(viewPoint->right, viewPoint->y - halfBarWidth); CGPoint alignedLowPoint = CPTPointMake(viewPoint->right, viewPoint->y + halfBarWidth); if ( alignPoints ) { @@ -898,7 +898,7 @@ -(void)drawSwatchForLegend:(nonnull CPTLegend *)legend atIndex:(NSUInteger)idx i [self drawRangeInContext:context lineStyle:theBarLineStyle viewPoint:&viewPoint - halfGapSize:CPTSizeMake(MIN(self.gapWidth, rect.size.width / CPTFloat(2.0) ) * CPTFloat(0.5), MIN(self.gapHeight, rect.size.height / CPTFloat(2.0) ) * CPTFloat(0.5) ) + halfGapSize:CPTSizeMake(MIN(self.gapWidth, rect.size.width / CPTFloat(2.0)) * CPTFloat(0.5), MIN(self.gapHeight, rect.size.height / CPTFloat(2.0)) * CPTFloat(0.5)) halfBarWidth:MIN(MIN(self.barWidth, rect.size.width), rect.size.height) * CPTFloat(0.5) alignPoints:YES]; } @@ -909,7 +909,7 @@ -(nullable CPTLineStyle *)barLineStyleForIndex:(NSUInteger)idx { CPTLineStyle *theBarLineStyle = [self cachedValueForKey:CPTRangePlotBindingBarLineStyles recordIndex:idx]; - if ( (theBarLineStyle == nil) || (theBarLineStyle == [CPTPlot nilData]) ) { + if ((theBarLineStyle == nil) || (theBarLineStyle == [CPTPlot nilData])) { theBarLineStyle = self.barLineStyle; } @@ -1023,7 +1023,7 @@ -(void)positionLabelAnnotation:(nonnull CPTPlotSpaceAnnotation *)label forIndex: BOOL positiveDirection = YES; CPTPlotRange *yRange = [self.plotSpace plotRangeForCoordinate:CPTCoordinateY]; - if ( CPTDecimalLessThan(yRange.lengthDecimal, CPTDecimalFromInteger(0) ) ) { + if ( CPTDecimalLessThan(yRange.lengthDecimal, CPTDecimalFromInteger(0))) { positiveDirection = !positiveDirection; } @@ -1048,8 +1048,8 @@ -(void)positionLabelAnnotation:(nonnull CPTPlotSpaceAnnotation *)label forIndex: -(NSUInteger)dataIndexFromInteractionPoint:(CGPoint)point { NSUInteger dataCount = self.cachedDataCount; - CGPointError *viewPoints = calloc(dataCount, sizeof(CGPointError) ); - BOOL *drawPointFlags = calloc(dataCount, sizeof(BOOL) ); + CGPointError *viewPoints = calloc(dataCount, sizeof(CGPointError)); + BOOL *drawPointFlags = calloc(dataCount, sizeof(BOOL)); [self calculatePointsToDraw:drawPointFlags numberOfPoints:dataCount forPlotSpace:(id)self.plotSpace includeVisiblePointsOnly:YES]; [self calculateViewPoints:viewPoints withDrawPointFlags:drawPointFlags numberOfPoints:dataCount]; @@ -1063,7 +1063,7 @@ -(NSUInteger)dataIndexFromInteractionPoint:(CGPoint)point lastViewPoint = viewPoints[i]; CGPoint lastPoint = CPTPointMake(lastViewPoint.x, lastViewPoint.y); CGFloat distanceSquared = squareOfDistanceBetweenPoints(point, lastPoint); - if ( isnan(minimumDistanceSquared) || (distanceSquared < minimumDistanceSquared) ) { + if ( isnan(minimumDistanceSquared) || (distanceSquared < minimumDistanceSquared)) { minimumDistanceSquared = distanceSquared; result = (NSInteger)i; } @@ -1072,16 +1072,16 @@ -(NSUInteger)dataIndexFromInteractionPoint:(CGPoint)point if ( result != NSNotFound ) { lastViewPoint = viewPoints[result]; - if ( !isnan(lastViewPoint.left) && (point.x < lastViewPoint.left) ) { + if ( !isnan(lastViewPoint.left) && (point.x < lastViewPoint.left)) { result = NSNotFound; } - if ( !isnan(lastViewPoint.right) && (point.x > lastViewPoint.right) ) { + if ( !isnan(lastViewPoint.right) && (point.x > lastViewPoint.right)) { result = NSNotFound; } - if ( !isnan(lastViewPoint.high) && (point.y > lastViewPoint.high) ) { + if ( !isnan(lastViewPoint.high) && (point.y > lastViewPoint.high)) { result = NSNotFound; } - if ( !isnan(lastViewPoint.low) && (point.y < lastViewPoint.low) ) { + if ( !isnan(lastViewPoint.low) && (point.y < lastViewPoint.low)) { result = NSNotFound; } } diff --git a/CorePlot/framework/Source/CPTResponder.h b/CorePlot/framework/Source/CPTResponder.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTScatterPlot.h b/CorePlot/framework/Source/CPTScatterPlot.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTScatterPlot.m b/CorePlot/framework/Source/CPTScatterPlot.m old mode 100755 new mode 100644 index be517ab..b686c1d --- a/CorePlot/framework/Source/CPTScatterPlot.m +++ b/CorePlot/framework/Source/CPTScatterPlot.m @@ -237,7 +237,7 @@ +(void)initialize **/ -(nonnull instancetype)initWithFrame:(CGRect)newFrame { - if ( (self = [super initWithFrame:newFrame]) ) { + if ((self = [super initWithFrame:newFrame])) { dataLineStyle = [[CPTLineStyle alloc] init]; plotSymbol = nil; areaFill = nil; @@ -264,7 +264,7 @@ -(nonnull instancetype)initWithFrame:(CGRect)newFrame -(nonnull instancetype)initWithLayer:(nonnull id)layer { - if ( (self = [super initWithLayer:layer]) ) { + if ((self = [super initWithLayer:layer])) { CPTScatterPlot *theLayer = (CPTScatterPlot *)layer; dataLineStyle = theLayer->dataLineStyle; @@ -320,7 +320,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super initWithCoder:coder]) ) { + if ((self = [super initWithCoder:coder])) { interpolation = (CPTScatterPlotInterpolation)[coder decodeIntegerForKey:@"CPTScatterPlot.interpolation"]; histogramOption = (CPTScatterPlotHistogramOption)[coder decodeIntegerForKey:@"CPTScatterPlot.histogramOption"]; curvedInterpolationOption = (CPTScatterPlotCurvedInterpolationOption)[coder decodeIntegerForKey:@"CPTScatterPlot.curvedInterpolationOption"]; @@ -456,7 +456,7 @@ -(nullable CPTPlotSymbol *)plotSymbolForRecordIndex:(NSUInteger)idx { CPTPlotSymbol *symbol = [self cachedValueForKey:CPTScatterPlotBindingPlotSymbols recordIndex:idx]; - if ( (symbol == nil) || (symbol == [CPTPlot nilData]) ) { + if ((symbol == nil) || (symbol == [CPTPlot nilData])) { symbol = self.plotSymbol; } @@ -476,16 +476,16 @@ -(void)calculatePointsToDraw:(nonnull BOOL *)pointDrawFlags forPlotSpace:(nonnul CPTLineStyle *lineStyle = self.dataLineStyle; - if ( self.areaFill || self.areaFill2 || lineStyle.dashPattern || lineStyle.lineFill || (self.interpolation == CPTScatterPlotInterpolationCurved) ) { + if ( self.areaFill || self.areaFill2 || lineStyle.dashPattern || lineStyle.lineFill || (self.interpolation == CPTScatterPlotInterpolationCurved)) { // show all points to preserve the line dash and area fills for ( NSUInteger i = 0; i < dataCount; i++ ) { pointDrawFlags[i] = YES; } } else { - CPTPlotRangeComparisonResult *xRangeFlags = calloc(dataCount, sizeof(CPTPlotRangeComparisonResult) ); - CPTPlotRangeComparisonResult *yRangeFlags = calloc(dataCount, sizeof(CPTPlotRangeComparisonResult) ); - BOOL *nanFlags = calloc(dataCount, sizeof(BOOL) ); + CPTPlotRangeComparisonResult *xRangeFlags = calloc(dataCount, sizeof(CPTPlotRangeComparisonResult)); + CPTPlotRangeComparisonResult *yRangeFlags = calloc(dataCount, sizeof(CPTPlotRangeComparisonResult)); + BOOL *nanFlags = calloc(dataCount, sizeof(BOOL)); CPTPlotRange *xRange = xyPlotSpace.xRange; CPTPlotRange *yRange = xyPlotSpace.yRange; @@ -536,7 +536,7 @@ -(void)calculatePointsToDraw:(nonnull BOOL *)pointDrawFlags forPlotSpace:(nonnul // are included. This ensures no lines are left out that shouldn't be. CPTScatterPlotInterpolation theInterpolation = self.interpolation; - memset(pointDrawFlags, NO, dataCount * sizeof(BOOL) ); + memset(pointDrawFlags, NO, dataCount * sizeof(BOOL)); if ( dataCount > 0 ) { pointDrawFlags[0] = (xRangeFlags[0] == CPTPlotRangeComparisonResultNumberInRange && yRangeFlags[0] == CPTPlotRangeComparisonResultNumberInRange && @@ -544,9 +544,9 @@ -(void)calculatePointsToDraw:(nonnull BOOL *)pointDrawFlags forPlotSpace:(nonnul } if ( visibleOnly ) { for ( NSUInteger i = 1; i < dataCount; i++ ) { - if ( (xRangeFlags[i] == CPTPlotRangeComparisonResultNumberInRange) && - (yRangeFlags[i] == CPTPlotRangeComparisonResultNumberInRange) && - !nanFlags[i] ) { + if ((xRangeFlags[i] == CPTPlotRangeComparisonResultNumberInRange) && + (yRangeFlags[i] == CPTPlotRangeComparisonResultNumberInRange) && + !nanFlags[i] ) { pointDrawFlags[i] = YES; } } @@ -556,13 +556,13 @@ -(void)calculatePointsToDraw:(nonnull BOOL *)pointDrawFlags forPlotSpace:(nonnul case CPTScatterPlotInterpolationCurved: // Keep 2 points outside of the visible area on each side to maintain the correct curvature of the line if ( dataCount > 1 ) { - if ( !nanFlags[0] && !nanFlags[1] && ( (xRangeFlags[0] != xRangeFlags[1]) || (yRangeFlags[0] != yRangeFlags[1]) ) ) { + if ( !nanFlags[0] && !nanFlags[1] && ((xRangeFlags[0] != xRangeFlags[1]) || (yRangeFlags[0] != yRangeFlags[1]))) { pointDrawFlags[0] = YES; pointDrawFlags[1] = YES; } - else if ( (xRangeFlags[1] == CPTPlotRangeComparisonResultNumberInRange) && - (yRangeFlags[1] == CPTPlotRangeComparisonResultNumberInRange) && - !nanFlags[1] ) { + else if ((xRangeFlags[1] == CPTPlotRangeComparisonResultNumberInRange) && + (yRangeFlags[1] == CPTPlotRangeComparisonResultNumberInRange) && + !nanFlags[1] ) { pointDrawFlags[1] = YES; } } @@ -573,14 +573,14 @@ -(void)calculatePointsToDraw:(nonnull BOOL *)pointDrawFlags forPlotSpace:(nonnul pointDrawFlags[i - 1] = YES; pointDrawFlags[i] = YES; } - else if ( !nanFlags[i - 1] && !nanFlags[i] && ( (xRangeFlags[i - 1] != xRangeFlags[i]) || (yRangeFlags[i - 1] != yRangeFlags[i]) ) ) { + else if ( !nanFlags[i - 1] && !nanFlags[i] && ((xRangeFlags[i - 1] != xRangeFlags[i]) || (yRangeFlags[i - 1] != yRangeFlags[i]))) { pointDrawFlags[i - 2] = YES; pointDrawFlags[i - 1] = YES; pointDrawFlags[i] = YES; } - else if ( (xRangeFlags[i] == CPTPlotRangeComparisonResultNumberInRange) && - (yRangeFlags[i] == CPTPlotRangeComparisonResultNumberInRange) && - !nanFlags[i] ) { + else if ((xRangeFlags[i] == CPTPlotRangeComparisonResultNumberInRange) && + (yRangeFlags[i] == CPTPlotRangeComparisonResultNumberInRange) && + !nanFlags[i] ) { pointDrawFlags[i] = YES; } } @@ -589,13 +589,13 @@ -(void)calculatePointsToDraw:(nonnull BOOL *)pointDrawFlags forPlotSpace:(nonnul default: // Keep 1 point outside of the visible area on each side for ( NSUInteger i = 1; i < dataCount; i++ ) { - if ( !nanFlags[i - 1] && !nanFlags[i] && ( (xRangeFlags[i - 1] != xRangeFlags[i]) || (yRangeFlags[i - 1] != yRangeFlags[i]) ) ) { + if ( !nanFlags[i - 1] && !nanFlags[i] && ((xRangeFlags[i - 1] != xRangeFlags[i]) || (yRangeFlags[i - 1] != yRangeFlags[i]))) { pointDrawFlags[i - 1] = YES; pointDrawFlags[i] = YES; } - else if ( (xRangeFlags[i] == CPTPlotRangeComparisonResultNumberInRange) && - (yRangeFlags[i] == CPTPlotRangeComparisonResultNumberInRange) && - !nanFlags[i] ) { + else if ((xRangeFlags[i] == CPTPlotRangeComparisonResultNumberInRange) && + (yRangeFlags[i] == CPTPlotRangeComparisonResultNumberInRange) && + !nanFlags[i] ) { pointDrawFlags[i] = YES; } } @@ -621,7 +621,7 @@ -(void)calculateViewPoints:(nonnull CGPoint *)viewPoints withDrawPointFlags:(non dispatch_apply(dataCount, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(size_t i) { const double x = xBytes[i]; const double y = yBytes[i]; - if ( !drawPointFlags[i] || isnan(x) || isnan(y) ) { + if ( !drawPointFlags[i] || isnan(x) || isnan(y)) { viewPoints[i] = CPTPointMake(NAN, NAN); } else { @@ -643,7 +643,7 @@ -(void)calculateViewPoints:(nonnull CGPoint *)viewPoints withDrawPointFlags:(non dispatch_apply(dataCount, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(size_t i) { const NSDecimal x = xBytes[i]; const NSDecimal y = yBytes[i]; - if ( !drawPointFlags[i] || NSDecimalIsNotANumber(&x) || NSDecimalIsNotANumber(&y) ) { + if ( !drawPointFlags[i] || NSDecimalIsNotANumber(&x) || NSDecimalIsNotANumber(&y)) { viewPoints[i] = CPTPointMake(NAN, NAN); } else { @@ -661,7 +661,7 @@ -(void)alignViewPointsToUserSpace:(nonnull CGPoint *)viewPoints withContext:(non { // Align to device pixels if there is a data line. // Otherwise, align to view space, so fills are sharp at edges. - if ( self.dataLineStyle.lineWidth > CPTFloat(0.0) ) { + if ( self.dataLineStyle.lineWidth > CPTFloat(0.0)) { dispatch_apply(dataCount, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(size_t i) { if ( drawPointFlags[i] ) { viewPoints[i] = CPTAlignPointToUserSpace(context, viewPoints[i]); @@ -689,7 +689,7 @@ -(NSInteger)extremeDrawnPointIndexForFlags:(nonnull BOOL *)pointDrawFlags number result = i; break; } - if ( (delta < 0) && (i == 0) ) { + if ((delta < 0) && (i == 0)) { break; } } @@ -718,8 +718,8 @@ -(NSUInteger)dataIndexFromInteractionPoint:(CGPoint)point -(NSUInteger)indexOfVisiblePointClosestToPlotAreaPoint:(CGPoint)viewPoint { NSUInteger dataCount = self.cachedDataCount; - CGPoint *viewPoints = calloc(dataCount, sizeof(CGPoint) ); - BOOL *drawPointFlags = calloc(dataCount, sizeof(BOOL) ); + CGPoint *viewPoints = calloc(dataCount, sizeof(CGPoint)); + BOOL *drawPointFlags = calloc(dataCount, sizeof(BOOL)); [self calculatePointsToDraw:drawPointFlags forPlotSpace:(id)self.plotSpace includeVisiblePointsOnly:YES numberOfPoints:dataCount]; [self calculateViewPoints:viewPoints withDrawPointFlags:drawPointFlags numberOfPoints:dataCount]; @@ -730,7 +730,7 @@ -(NSUInteger)indexOfVisiblePointClosestToPlotAreaPoint:(CGPoint)viewPoint for ( NSUInteger i = (NSUInteger)result; i < dataCount; ++i ) { if ( drawPointFlags[i] ) { CGFloat distanceSquared = squareOfDistanceBetweenPoints(viewPoint, viewPoints[i]); - if ( isnan(minimumDistanceSquared) || (distanceSquared < minimumDistanceSquared) ) { + if ( isnan(minimumDistanceSquared) || (distanceSquared < minimumDistanceSquared)) { minimumDistanceSquared = distanceSquared; result = (NSInteger)i; } @@ -787,14 +787,14 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context CPTMutableNumericData *xValueData = [self cachedNumbersForField:CPTScatterPlotFieldX]; CPTMutableNumericData *yValueData = [self cachedNumbersForField:CPTScatterPlotFieldY]; - if ( (xValueData == nil) || (yValueData == nil) ) { + if ((xValueData == nil) || (yValueData == nil)) { return; } NSUInteger dataCount = self.cachedDataCount; if ( dataCount == 0 ) { return; } - if ( !(self.dataLineStyle || self.areaFill || self.areaFill2 || self.plotSymbol || self.plotSymbols.count) ) { + if ( !(self.dataLineStyle || self.areaFill || self.areaFill2 || self.plotSymbol || self.plotSymbols.count)) { return; } if ( xValueData.numberOfSamples != yValueData.numberOfSamples ) { @@ -804,8 +804,8 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context [super renderAsVectorInContext:context]; // Calculate view points, and align to user space - CGPoint *viewPoints = calloc(dataCount, sizeof(CGPoint) ); - BOOL *drawPointFlags = calloc(dataCount, sizeof(BOOL) ); + CGPoint *viewPoints = calloc(dataCount, sizeof(CGPoint)); + BOOL *drawPointFlags = calloc(dataCount, sizeof(BOOL)); CPTXYPlotSpace *thePlotSpace = (CPTXYPlotSpace *)self.plotSpace; [self calculatePointsToDraw:drawPointFlags forPlotSpace:thePlotSpace includeVisiblePointsOnly:NO numberOfPoints:dataCount]; @@ -821,7 +821,7 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context NSInteger firstDrawnPointIndex = [self extremeDrawnPointIndexForFlags:drawPointFlags numberOfPoints:dataCount extremeNumIsLowerBound:YES]; if ( firstDrawnPointIndex != NSNotFound ) { - NSRange viewIndexRange = NSMakeRange( (NSUInteger)firstDrawnPointIndex, (NSUInteger)(lastDrawnPointIndex - firstDrawnPointIndex + 1) ); + NSRange viewIndexRange = NSMakeRange((NSUInteger)firstDrawnPointIndex, (NSUInteger)(lastDrawnPointIndex - firstDrawnPointIndex + 1)); CPTPlotArea *thePlotArea = self.plotArea; CPTLineStyle *theLineStyle = self.dataLineStyle; @@ -847,8 +847,8 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context theAreaBaseValue = CPTDecimalNaN(); break; } - if ( !NSDecimalIsNotANumber(&theAreaBaseValue) ) { - if ( theFill || ( (i == 0) && fillBands ) ) { + if ( !NSDecimalIsNotANumber(&theAreaBaseValue)) { + if ( theFill || ((i == 0) && fillBands)) { // clear the plot shadow if any--not needed for fills when the plot has a data line if ( theLineStyle ) { CGContextSaveGState(context); @@ -873,8 +873,8 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context } // Draw fill bands - if ( (i == 0) && fillBands ) { - CGFloat height = CPTFloat(CGBitmapContextGetHeight(context) ); + if ((i == 0) && fillBands ) { + CGFloat height = CPTFloat(CGBitmapContextGetHeight(context)); for ( CPTLimitBand *band in fillBands ) { CGContextSaveGState(context); @@ -892,7 +892,7 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context maxPoint = CPTAlignIntegralPointToUserSpace(context, maxPoint); } - CGContextClipToRect(context, CGRectMake(minPoint.x, 0.0, maxPoint.x - minPoint.x, height) ); + CGContextClipToRect(context, CGRectMake(minPoint.x, 0.0, maxPoint.x - minPoint.x, height)); CGContextBeginPath(context); CGContextAddPath(context, dataLinePath); @@ -984,9 +984,9 @@ -(nonnull CGPathRef)newDataLinePathForViewPoints:(nonnull CGPoint *)viewPoints i for ( NSUInteger i = indexRange.location; i <= lastDrawnPointIndex; i++ ) { CGPoint viewPoint = viewPoints[i]; - if ( isnan(viewPoint.x) || isnan(viewPoint.y) ) { + if ( isnan(viewPoint.x) || isnan(viewPoint.y)) { if ( !lastPointSkipped ) { - if ( !isnan(baselineYValue) ) { + if ( !isnan(baselineYValue)) { CGPathAddLineToPoint(dataLinePath, NULL, lastPoint.x, baselineYValue); CGPathAddLineToPoint(dataLinePath, NULL, firstPoint.x, baselineYValue); CGPathCloseSubpath(dataLinePath); @@ -1033,7 +1033,7 @@ -(nonnull CGPathRef)newDataLinePathForViewPoints:(nonnull CGPoint *)viewPoints i } } - if ( !lastPointSkipped && !isnan(baselineYValue) ) { + if ( !lastPointSkipped && !isnan(baselineYValue)) { CGPathAddLineToPoint(dataLinePath, NULL, lastPoint.x, baselineYValue); CGPathAddLineToPoint(dataLinePath, NULL, firstPoint.x, baselineYValue); CGPathCloseSubpath(dataLinePath); @@ -1054,8 +1054,8 @@ -(nonnull CGPathRef)newCurvedDataLinePathForViewPoints:(nonnull CGPoint *)viewPo CPTScatterPlotCurvedInterpolationOption interpolationOption = self.curvedInterpolationOption; if ( lastDrawnPointIndex > 0 ) { - CGPoint *controlPoints1 = calloc(lastDrawnPointIndex, sizeof(CGPoint) ); - CGPoint *controlPoints2 = calloc(lastDrawnPointIndex, sizeof(CGPoint) ); + CGPoint *controlPoints1 = calloc(lastDrawnPointIndex, sizeof(CGPoint)); + CGPoint *controlPoints2 = calloc(lastDrawnPointIndex, sizeof(CGPoint)); lastDrawnPointIndex--; @@ -1063,7 +1063,7 @@ -(nonnull CGPathRef)newCurvedDataLinePathForViewPoints:(nonnull CGPoint *)viewPo for ( NSUInteger i = indexRange.location; i <= lastDrawnPointIndex; i++ ) { CGPoint viewPoint = viewPoints[i]; - if ( isnan(viewPoint.x) || isnan(viewPoint.y) ) { + if ( isnan(viewPoint.x) || isnan(viewPoint.y)) { if ( !lastPointSkipped ) { switch ( interpolationOption ) { case CPTScatterPlotCurvedInterpolationNormal: @@ -1182,9 +1182,9 @@ -(nonnull CGPathRef)newCurvedDataLinePathForViewPoints:(nonnull CGPoint *)viewPo for ( NSUInteger i = indexRange.location; i <= lastDrawnPointIndex; i++ ) { CGPoint viewPoint = viewPoints[i]; - if ( isnan(viewPoint.x) || isnan(viewPoint.y) ) { + if ( isnan(viewPoint.x) || isnan(viewPoint.y)) { if ( !lastPointSkipped ) { - if ( !isnan(baselineYValue) ) { + if ( !isnan(baselineYValue)) { CGPathAddLineToPoint(dataLinePath, NULL, lastPoint.x, baselineYValue); CGPathAddLineToPoint(dataLinePath, NULL, firstPoint.x, baselineYValue); CGPathCloseSubpath(dataLinePath); @@ -1208,13 +1208,13 @@ -(nonnull CGPathRef)newCurvedDataLinePathForViewPoints:(nonnull CGPoint *)viewPo // add the control points CGPathMoveToPoint(dataLinePath, NULL, cp1.x - CPTFloat(5.0), cp1.y); CGPathAddLineToPoint(dataLinePath, NULL, cp1.x + CPTFloat(5.0), cp1.y); - CGPathMoveToPoint(dataLinePath, NULL, cp1.x, cp1.y - CPTFloat(5.0) ); - CGPathAddLineToPoint(dataLinePath, NULL, cp1.x, cp1.y + CPTFloat(5.0) ); + CGPathMoveToPoint(dataLinePath, NULL, cp1.x, cp1.y - CPTFloat(5.0)); + CGPathAddLineToPoint(dataLinePath, NULL, cp1.x, cp1.y + CPTFloat(5.0)); - CGPathMoveToPoint(dataLinePath, NULL, cp2.x - CPTFloat(3.5), cp2.y - CPTFloat(3.5) ); - CGPathAddLineToPoint(dataLinePath, NULL, cp2.x + CPTFloat(3.5), cp2.y + CPTFloat(3.5) ); - CGPathMoveToPoint(dataLinePath, NULL, cp2.x + CPTFloat(3.5), cp2.y - CPTFloat(3.5) ); - CGPathAddLineToPoint(dataLinePath, NULL, cp2.x - CPTFloat(3.5), cp2.y + CPTFloat(3.5) ); + CGPathMoveToPoint(dataLinePath, NULL, cp2.x - CPTFloat(3.5), cp2.y - CPTFloat(3.5)); + CGPathAddLineToPoint(dataLinePath, NULL, cp2.x + CPTFloat(3.5), cp2.y + CPTFloat(3.5)); + CGPathMoveToPoint(dataLinePath, NULL, cp2.x + CPTFloat(3.5), cp2.y - CPTFloat(3.5)); + CGPathAddLineToPoint(dataLinePath, NULL, cp2.x - CPTFloat(3.5), cp2.y + CPTFloat(3.5)); // add a line connecting the control points CGPathMoveToPoint(dataLinePath, NULL, cp1.x, cp1.y); @@ -1229,7 +1229,7 @@ -(nonnull CGPathRef)newCurvedDataLinePathForViewPoints:(nonnull CGPoint *)viewPo } } - if ( !lastPointSkipped && !isnan(baselineYValue) ) { + if ( !lastPointSkipped && !isnan(baselineYValue)) { CGPathAddLineToPoint(dataLinePath, NULL, lastPoint.x, baselineYValue); CGPathAddLineToPoint(dataLinePath, NULL, firstPoint.x, baselineYValue); CGPathCloseSubpath(dataLinePath); @@ -1285,12 +1285,12 @@ -(void)computeCatmullRomControlPoints:(nonnull CGPoint *)points points2:(nonnull CGFloat d2 = hypot(p2.x - p1.x, p2.y - p1.y); CGFloat d3 = hypot(p3.x - p2.x, p3.y - p2.y); // constants - CGFloat d1_a = pow(d1, alpha); // d1^alpha - CGFloat d2_a = pow(d2, alpha); // d2^alpha - CGFloat d3_a = pow(d3, alpha); // d3^alpha - CGFloat d1_2a = pow(d1_a, CPTFloat(2.0) ); // d1^alpha^2 = d1^2*alpha - CGFloat d2_2a = pow(d2_a, CPTFloat(2.0) ); // d2^alpha^2 = d2^2*alpha - CGFloat d3_2a = pow(d3_a, CPTFloat(2.0) ); // d3^alpha^2 = d3^2*alpha + CGFloat d1_a = pow(d1, alpha); // d1^alpha + CGFloat d2_a = pow(d2, alpha); // d2^alpha + CGFloat d3_a = pow(d3, alpha); // d3^alpha + CGFloat d1_2a = pow(d1_a, CPTFloat(2.0)); // d1^alpha^2 = d1^2*alpha + CGFloat d2_2a = pow(d2_a, CPTFloat(2.0)); // d2^alpha^2 = d2^2*alpha + CGFloat d3_2a = pow(d3_a, CPTFloat(2.0)); // d3^alpha^2 = d3^2*alpha // calculate the control points // see : http://www.cemyuksel.com/research/catmullrom_param/catmullrom.pdf under point 3. @@ -1300,9 +1300,9 @@ -(void)computeCatmullRomControlPoints:(nonnull CGPoint *)points points2:(nonnull } else { CGFloat divisor = CPTFloat(3.0) * d1_a * (d1_a + d2_a); - cp1 = CPTPointMake( (p2.x * d1_2a - p0.x * d2_2a + (2 * d1_2a + 3 * d1_a * d2_a + d2_2a) * p1.x) / divisor, - (p2.y * d1_2a - p0.y * d2_2a + (2 * d1_2a + 3 * d1_a * d2_a + d2_2a) * p1.y) / divisor - ); + cp1 = CPTPointMake((p2.x * d1_2a - p0.x * d2_2a + (2 * d1_2a + 3 * d1_a * d2_a + d2_2a) * p1.x) / divisor, + (p2.y * d1_2a - p0.y * d2_2a + (2 * d1_2a + 3 * d1_a * d2_a + d2_2a) * p1.y) / divisor + ); } if ( fabs(d3) <= epsilon ) { @@ -1310,8 +1310,8 @@ -(void)computeCatmullRomControlPoints:(nonnull CGPoint *)points points2:(nonnull } else { CGFloat divisor = 3 * d3_a * (d3_a + d2_a); - cp2 = CPTPointMake( (d3_2a * p1.x - d2_2a * p3.x + (2 * d3_2a + 3 * d3_a * d2_a + d2_2a) * p2.x) / divisor, - (d3_2a * p1.y - d2_2a * p3.y + (2 * d3_2a + 3 * d3_a * d2_a + d2_2a) * p2.y) / divisor ); + cp2 = CPTPointMake((d3_2a * p1.x - d2_2a * p3.x + (2 * d3_2a + 3 * d3_a * d2_a + d2_2a) * p2.x) / divisor, + (d3_2a * p1.y - d2_2a * p3.y + (2 * d3_2a + 3 * d3_a * d2_a + d2_2a) * p2.y) / divisor); } points[index + 1] = cp1; @@ -1364,17 +1364,17 @@ -(void)computeHermiteControlPoints:(nonnull CGPoint *)points points2:(nonnull CG m.dy = p2.y - p0.y; if ( monotonic ) { - if ( m.dx > CPTFloat(0.0) ) { + if ( m.dx > CPTFloat(0.0)) { m.dx = MIN(p2.x - p1.x, p1.x - p0.x); } - else if ( m.dx < CPTFloat(0.0) ) { + else if ( m.dx < CPTFloat(0.0)) { m.dx = MAX(p2.x - p1.x, p1.x - p0.x); } - if ( m.dy > CPTFloat(0.0) ) { + if ( m.dy > CPTFloat(0.0)) { m.dy = MIN(p2.y - p1.y, p1.y - p0.y); } - else if ( m.dy < CPTFloat(0.0) ) { + else if ( m.dy < CPTFloat(0.0)) { m.dy = MAX(p2.y - p1.y, p1.y - p0.y); } } @@ -1484,10 +1484,10 @@ -(void)computeBezierControlPoints:(nonnull CGPoint *)cp1 points2:(nonnull CGPoin NSUInteger n = indexRange.length - 1; // rhs vector - CGPoint *a = calloc(n, sizeof(CGPoint) ); - CGPoint *b = calloc(n, sizeof(CGPoint) ); - CGPoint *c = calloc(n, sizeof(CGPoint) ); - CGPoint *r = calloc(n, sizeof(CGPoint) ); + CGPoint *a = calloc(n, sizeof(CGPoint)); + CGPoint *b = calloc(n, sizeof(CGPoint)); + CGPoint *c = calloc(n, sizeof(CGPoint)); + CGPoint *r = calloc(n, sizeof(CGPoint)); // left most segment a[0] = CGPointZero; @@ -1534,11 +1534,11 @@ -(void)computeBezierControlPoints:(nonnull CGPoint *)cp1 points2:(nonnull CGPoin cp1[indexRange.location + n] = CGPointMake(r[n - 1].x / b[n - 1].x, r[n - 1].y / b[n - 1].y); for ( NSUInteger i = n - 2; i > 0; i-- ) { - cp1[indexRange.location + i + 1] = CGPointMake( (r[i].x - c[i].x * cp1[indexRange.location + i + 2].x) / b[i].x, - (r[i].y - c[i].y * cp1[indexRange.location + i + 2].y) / b[i].y ); + cp1[indexRange.location + i + 1] = CGPointMake((r[i].x - c[i].x * cp1[indexRange.location + i + 2].x) / b[i].x, + (r[i].y - c[i].y * cp1[indexRange.location + i + 2].y) / b[i].y); } - cp1[indexRange.location + 1] = CGPointMake( (r[0].x - c[0].x * cp1[indexRange.location + 2].x) / b[0].x, - (r[0].y - c[0].y * cp1[indexRange.location + 2].y) / b[0].y ); + cp1[indexRange.location + 1] = CGPointMake((r[0].x - c[0].x * cp1[indexRange.location + 2].x) / b[0].x, + (r[0].y - c[0].y * cp1[indexRange.location + 2].y) / b[0].y); // we have p1, now compute p2 NSUInteger rangeEnd = NSMaxRange(indexRange) - 1; @@ -1548,7 +1548,7 @@ -(void)computeBezierControlPoints:(nonnull CGPoint *)cp1 points2:(nonnull CGPoin } cp2[rangeEnd] = CGPointMake(CPTFloat(0.5) * (viewPoints[rangeEnd].x + cp1[rangeEnd].x), - CPTFloat(0.5) * (viewPoints[rangeEnd].y + cp1[rangeEnd].y) ); + CPTFloat(0.5) * (viewPoints[rangeEnd].y + cp1[rangeEnd].y)); // clean up free(a); @@ -1568,8 +1568,8 @@ -(void)drawSwatchForLegend:(nonnull CPTLegend *)legend atIndex:(NSUInteger)idx i if ( theLineStyle ) { [theLineStyle setLineStyleInContext:context]; - CGPoint alignedStartPoint = CPTAlignPointToUserSpace(context, CPTPointMake(CGRectGetMinX(rect), CGRectGetMidY(rect) ) ); - CGPoint alignedEndPoint = CPTAlignPointToUserSpace(context, CPTPointMake(CGRectGetMaxX(rect), CGRectGetMidY(rect) ) ); + CGPoint alignedStartPoint = CPTAlignPointToUserSpace(context, CPTPointMake(CGRectGetMinX(rect), CGRectGetMidY(rect))); + CGPoint alignedEndPoint = CPTAlignPointToUserSpace(context, CPTPointMake(CGRectGetMaxX(rect), CGRectGetMidY(rect))); CGContextMoveToPoint(context, alignedStartPoint.x, alignedStartPoint.y); CGContextAddLineToPoint(context, alignedEndPoint.x, alignedEndPoint.y); @@ -1580,7 +1580,7 @@ -(void)drawSwatchForLegend:(nonnull CPTLegend *)legend atIndex:(NSUInteger)idx i if ( thePlotSymbol ) { [thePlotSymbol renderInContext:context - atPoint:CPTPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect) ) + atPoint:CPTPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect)) scale:self.contentsScale alignToPixels:YES]; } @@ -1608,13 +1608,13 @@ -(void)drawSwatchForLegend:(nonnull CPTLegend *)legend atIndex:(NSUInteger)idx i CGContextAddPath(context, swatchPath); CGContextClip(context); - if ( CPTDecimalGreaterThanOrEqualTo(self.areaBaseValue2.decimalValue, self.areaBaseValue.decimalValue) ) { - [fill1 fillRect:CPTRectMake(CGRectGetMinX(rect), CGRectGetMinY(rect), rect.size.width, rect.size.height / CPTFloat(2.0) ) inContext:context]; - [fill2 fillRect:CPTRectMake(CGRectGetMinX(rect), CGRectGetMidY(rect), rect.size.width, rect.size.height / CPTFloat(2.0) ) inContext:context]; + if ( CPTDecimalGreaterThanOrEqualTo(self.areaBaseValue2.decimalValue, self.areaBaseValue.decimalValue)) { + [fill1 fillRect:CPTRectMake(CGRectGetMinX(rect), CGRectGetMinY(rect), rect.size.width, rect.size.height / CPTFloat(2.0)) inContext:context]; + [fill2 fillRect:CPTRectMake(CGRectGetMinX(rect), CGRectGetMidY(rect), rect.size.width, rect.size.height / CPTFloat(2.0)) inContext:context]; } else { - [fill2 fillRect:CPTRectMake(CGRectGetMinX(rect), CGRectGetMinY(rect), rect.size.width, rect.size.height / CPTFloat(2.0) ) inContext:context]; - [fill1 fillRect:CPTRectMake(CGRectGetMinX(rect), CGRectGetMidY(rect), rect.size.width, rect.size.height / CPTFloat(2.0) ) inContext:context]; + [fill2 fillRect:CPTRectMake(CGRectGetMinX(rect), CGRectGetMinY(rect), rect.size.width, rect.size.height / CPTFloat(2.0)) inContext:context]; + [fill1 fillRect:CPTRectMake(CGRectGetMinX(rect), CGRectGetMidY(rect), rect.size.width, rect.size.height / CPTFloat(2.0)) inContext:context]; } CGContextRestoreGState(context); @@ -1636,8 +1636,8 @@ -(nonnull CGPathRef)newDataLinePath } // Calculate view points - CGPoint *viewPoints = calloc(dataCount, sizeof(CGPoint) ); - BOOL *drawPointFlags = calloc(dataCount, sizeof(BOOL) ); + CGPoint *viewPoints = calloc(dataCount, sizeof(CGPoint)); + BOOL *drawPointFlags = calloc(dataCount, sizeof(BOOL)); for ( NSUInteger i = 0; i < dataCount; i++ ) { drawPointFlags[i] = YES; @@ -1704,7 +1704,7 @@ -(nullable CPTPlotRange *)plotRangeEnclosingField:(NSUInteger)fieldEnum CPTNumberArray *lowerLeft = [space plotPointForPlotAreaViewPoint:boundingBox.origin]; CPTNumberArray *upperRight = [space plotPointForPlotAreaViewPoint:CGPointMake(CGRectGetMaxX(boundingBox), - CGRectGetMaxY(boundingBox) )]; + CGRectGetMaxY(boundingBox))]; switch ( fieldEnum ) { case CPTScatterPlotFieldX: @@ -1808,7 +1808,7 @@ -(void)positionLabelAnnotation:(nonnull CPTPlotSpaceAnnotation *)label forIndex: BOOL positiveDirection = YES; CPTPlotRange *yRange = [self.plotSpace plotRangeForCoordinate:CPTCoordinateY]; - if ( CPTDecimalLessThan(yRange.lengthDecimal, CPTDecimalFromInteger(0) ) ) { + if ( CPTDecimalLessThan(yRange.lengthDecimal, CPTDecimalFromInteger(0))) { positiveDirection = !positiveDirection; } @@ -1939,9 +1939,9 @@ -(BOOL)pointingDeviceDownEvent:(nonnull CPTNativeEvent *)event atPoint:(CGPoint) CGFloat margin = self.plotSymbolMarginForHitDetection * CPTFloat(2.0); symbolRect.size.width += margin; symbolRect.size.height += margin; - symbolRect.origin = CPTPointMake(center.x - CPTFloat(0.5) * CGRectGetWidth(symbolRect), center.y - CPTFloat(0.5) * CGRectGetHeight(symbolRect) ); + symbolRect.origin = CPTPointMake(center.x - CPTFloat(0.5) * CGRectGetWidth(symbolRect), center.y - CPTFloat(0.5) * CGRectGetHeight(symbolRect)); - if ( CGRectContainsPoint(symbolRect, plotAreaPoint) ) { + if ( CGRectContainsPoint(symbolRect, plotAreaPoint)) { self.pointingDeviceDownIndex = idx; if ( [theDelegate respondsToSelector:@selector(scatterPlot:plotSymbolTouchDownAtRecordIndex:)] ) { @@ -1964,7 +1964,7 @@ -(BOOL)pointingDeviceDownEvent:(nonnull CPTNativeEvent *)event atPoint:(CGPoint) ([theDelegate respondsToSelector:@selector(scatterPlotDataLineTouchDown:)] || [theDelegate respondsToSelector:@selector(scatterPlot:dataLineTouchDownWithEvent:)] || [theDelegate respondsToSelector:@selector(scatterPlotDataLineWasSelected:)] || - [theDelegate respondsToSelector:@selector(scatterPlot:dataLineWasSelectedWithEvent:)]) ) { + [theDelegate respondsToSelector:@selector(scatterPlot:dataLineWasSelectedWithEvent:)])) { plotSelected = [self plotWasLineHitByInteractionPoint:interactionPoint]; if ( plotSelected ) { // Let the delegate know that the plot was selected. @@ -2056,9 +2056,9 @@ -(BOOL)pointingDeviceUpEvent:(nonnull CPTNativeEvent *)event atPoint:(CGPoint)in CGFloat margin = self.plotSymbolMarginForHitDetection * CPTFloat(2.0); symbolRect.size.width += margin; symbolRect.size.height += margin; - symbolRect.origin = CPTPointMake(center.x - CPTFloat(0.5) * CGRectGetWidth(symbolRect), center.y - CPTFloat(0.5) * CGRectGetHeight(symbolRect) ); + symbolRect.origin = CPTPointMake(center.x - CPTFloat(0.5) * CGRectGetWidth(symbolRect), center.y - CPTFloat(0.5) * CGRectGetHeight(symbolRect)); - if ( CGRectContainsPoint(symbolRect, plotAreaPoint) ) { + if ( CGRectContainsPoint(symbolRect, plotAreaPoint)) { self.pointingDeviceDownIndex = idx; if ( [theDelegate respondsToSelector:@selector(scatterPlot:plotSymbolTouchUpAtRecordIndex:)] ) { @@ -2093,7 +2093,7 @@ -(BOOL)pointingDeviceUpEvent:(nonnull CPTNativeEvent *)event atPoint:(CGPoint)in ([theDelegate respondsToSelector:@selector(scatterPlotDataLineTouchUp:)] || [theDelegate respondsToSelector:@selector(scatterPlot:dataLineTouchUpWithEvent:)] || [theDelegate respondsToSelector:@selector(scatterPlotDataLineWasSelected:)] || - [theDelegate respondsToSelector:@selector(scatterPlot:dataLineWasSelectedWithEvent:)]) ) { + [theDelegate respondsToSelector:@selector(scatterPlot:dataLineWasSelectedWithEvent:)])) { plotSelected = [self plotWasLineHitByInteractionPoint:interactionPoint]; if ( plotSelected ) { @@ -2137,8 +2137,8 @@ -(BOOL)plotWasLineHitByInteractionPoint:(CGPoint)interactionPoint NSUInteger dataCount = self.cachedDataCount; if ( theGraph && thePlotArea && !self.hidden && dataCount ) { - CGPoint *viewPoints = calloc(dataCount, sizeof(CGPoint) ); - BOOL *drawPointFlags = calloc(dataCount, sizeof(BOOL) ); + CGPoint *viewPoints = calloc(dataCount, sizeof(CGPoint)); + BOOL *drawPointFlags = calloc(dataCount, sizeof(BOOL)); CPTXYPlotSpace *thePlotSpace = (CPTXYPlotSpace *)self.plotSpace; [self calculatePointsToDraw:drawPointFlags forPlotSpace:thePlotSpace includeVisiblePointsOnly:NO numberOfPoints:dataCount]; @@ -2148,14 +2148,14 @@ -(BOOL)plotWasLineHitByInteractionPoint:(CGPoint)interactionPoint if ( firstDrawnPointIndex != NSNotFound ) { NSInteger lastDrawnPointIndex = [self extremeDrawnPointIndexForFlags:drawPointFlags numberOfPoints:dataCount extremeNumIsLowerBound:NO]; - NSRange viewIndexRange = NSMakeRange( (NSUInteger)firstDrawnPointIndex, (NSUInteger)(lastDrawnPointIndex - firstDrawnPointIndex + 1) ); + NSRange viewIndexRange = NSMakeRange((NSUInteger)firstDrawnPointIndex, (NSUInteger)(lastDrawnPointIndex - firstDrawnPointIndex + 1)); CGPathRef dataLinePath = [self newDataLinePathForViewPoints:viewPoints indexRange:viewIndexRange baselineYValue:CPTNAN]; CGPathRef path = CGPathCreateCopyByStrokingPath(dataLinePath, NULL, self.plotLineMarginForHitDetection * CPTFloat(2.0), kCGLineCapRound, kCGLineJoinRound, - CPTFloat(3.0) ); + CPTFloat(3.0)); CGPoint plotAreaPoint = [theGraph convertPoint:interactionPoint toLayer:thePlotArea]; @@ -2204,10 +2204,10 @@ -(void)setCurvedInterpolationOption:(CPTScatterPlotCurvedInterpolationOption)new -(void)setCurvedInterpolationCustomAlpha:(CGFloat)newCurvedInterpolationCustomAlpha { - if ( newCurvedInterpolationCustomAlpha > CPTFloat(1.0) ) { + if ( newCurvedInterpolationCustomAlpha > CPTFloat(1.0)) { newCurvedInterpolationCustomAlpha = CPTFloat(1.0); } - if ( newCurvedInterpolationCustomAlpha < CPTFloat(0.0) ) { + if ( newCurvedInterpolationCustomAlpha < CPTFloat(0.0)) { newCurvedInterpolationCustomAlpha = CPTFloat(0.0); } diff --git a/CorePlot/framework/Source/CPTScatterPlotTests.h b/CorePlot/framework/Source/CPTScatterPlotTests.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTScatterPlotTests.m b/CorePlot/framework/Source/CPTScatterPlotTests.m old mode 100755 new mode 100644 index 468bb2a..5cecafe --- a/CorePlot/framework/Source/CPTScatterPlotTests.m +++ b/CorePlot/framework/Source/CPTScatterPlotTests.m @@ -42,7 +42,7 @@ -(void)testCalculatePointsToDrawAllInRange { CPTNumberArray *inRangeValues = @[@0.1, @0.2, @0.15, @0.6, @0.9]; - BOOL *drawFlags = calloc(inRangeValues.count, sizeof(BOOL) ); + BOOL *drawFlags = calloc(inRangeValues.count, sizeof(BOOL)); CPTXYPlotSpace *thePlotSpace = self.plotSpace; @@ -60,7 +60,7 @@ -(void)testCalculatePointsToDrawAllInRangeVisibleOnly { CPTNumberArray *inRangeValues = @[@0.1, @0.2, @0.15, @0.6, @0.9]; - BOOL *drawFlags = calloc(inRangeValues.count, sizeof(BOOL) ); + BOOL *drawFlags = calloc(inRangeValues.count, sizeof(BOOL)); CPTXYPlotSpace *thePlotSpace = self.plotSpace; @@ -78,7 +78,7 @@ -(void)testCalculatePointsToDrawNoneInRange { CPTNumberArray *inRangeValues = @[@(-0.1), @(-0.2), @(-0.15), @(-0.6), @(-0.9)]; - BOOL *drawFlags = calloc(inRangeValues.count, sizeof(BOOL) ); + BOOL *drawFlags = calloc(inRangeValues.count, sizeof(BOOL)); CPTXYPlotSpace *thePlotSpace = self.plotSpace; @@ -96,7 +96,7 @@ -(void)testCalculatePointsToDrawNoneInRangeVisibleOnly { CPTNumberArray *inRangeValues = @[@(-0.1), @(-0.2), @(-0.15), @(-0.6), @(-0.9)]; - BOOL *drawFlags = calloc(inRangeValues.count, sizeof(BOOL) ); + BOOL *drawFlags = calloc(inRangeValues.count, sizeof(BOOL)); CPTXYPlotSpace *thePlotSpace = self.plotSpace; @@ -114,7 +114,7 @@ -(void)testCalculatePointsToDrawNoneInRangeDifferentRegions { CPTNumberArray *inRangeValues = @[@(-0.1), @2, @(-0.15), @3, @(-0.9)]; - BOOL *drawFlags = calloc(inRangeValues.count, sizeof(BOOL) ); + BOOL *drawFlags = calloc(inRangeValues.count, sizeof(BOOL)); CPTXYPlotSpace *thePlotSpace = self.plotSpace; @@ -132,7 +132,7 @@ -(void)testCalculatePointsToDrawNoneInRangeDifferentRegionsVisibleOnly { CPTNumberArray *inRangeValues = @[@(-0.1), @2, @(-0.15), @3, @(-0.9)]; - BOOL *drawFlags = calloc(inRangeValues.count, sizeof(BOOL) ); + BOOL *drawFlags = calloc(inRangeValues.count, sizeof(BOOL)); CPTXYPlotSpace *thePlotSpace = self.plotSpace; @@ -151,7 +151,7 @@ -(void)testCalculatePointsToDrawSomeInRange CPTNumberArray *inRangeValues = @[@(-0.1), @0.1, @0.2, @1.2, @1.5]; BOOL expected[5] = { YES, YES, YES, YES, NO }; - BOOL *drawFlags = calloc(inRangeValues.count, sizeof(BOOL) ); + BOOL *drawFlags = calloc(inRangeValues.count, sizeof(BOOL)); CPTXYPlotSpace *thePlotSpace = self.plotSpace; @@ -173,7 +173,7 @@ -(void)testCalculatePointsToDrawSomeInRangeVisibleOnly { CPTNumberArray *inRangeValues = @[@(-0.1), @0.1, @0.2, @1.2, @1.5]; - BOOL *drawFlags = calloc(inRangeValues.count, sizeof(BOOL) ); + BOOL *drawFlags = calloc(inRangeValues.count, sizeof(BOOL)); CPTXYPlotSpace *thePlotSpace = self.plotSpace; @@ -196,8 +196,8 @@ -(void)testCalculatePointsToDrawSomeInRangeCrossing { CPTNumberArray *inRangeValues = @[@(-0.1), @1.1, @0.9, @(-0.1), @(-0.2)]; - BOOL *drawFlags = calloc(inRangeValues.count, sizeof(BOOL) ); - BOOL *expected = calloc(inRangeValues.count, sizeof(BOOL) ); + BOOL *drawFlags = calloc(inRangeValues.count, sizeof(BOOL)); + BOOL *expected = calloc(inRangeValues.count, sizeof(BOOL)); for ( NSUInteger i = 0; i < inRangeValues.count - 1; i++ ) { expected[i] = YES; @@ -226,7 +226,7 @@ -(void)testCalculatePointsToDrawSomeInRangeCrossingVisibleOnly { CPTNumberArray *inRangeValues = @[@(-0.1), @1.1, @0.9, @(-0.1), @(-0.2)]; - BOOL *drawFlags = calloc(inRangeValues.count, sizeof(BOOL) ); + BOOL *drawFlags = calloc(inRangeValues.count, sizeof(BOOL)); CPTXYPlotSpace *thePlotSpace = self.plotSpace; diff --git a/CorePlot/framework/Source/CPTShadow.h b/CorePlot/framework/Source/CPTShadow.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTShadow.m b/CorePlot/framework/Source/CPTShadow.m old mode 100755 new mode 100644 index cf42dc2..6204c39 --- a/CorePlot/framework/Source/CPTShadow.m +++ b/CorePlot/framework/Source/CPTShadow.m @@ -70,7 +70,7 @@ +(nonnull instancetype)shadow **/ -(nonnull instancetype)init { - if ( (self = [super init]) ) { + if ((self = [super init])) { shadowOffset = CGSizeZero; shadowBlurRadius = CPTFloat(0.0); shadowColor = nil; @@ -94,7 +94,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super init]) ) { + if ((self = [super init])) { shadowOffset = [coder decodeCPTSizeForKey:@"CPTShadow.shadowOffset"]; shadowBlurRadius = [coder decodeCGFloatForKey:@"CPTShadow.shadowBlurRadius"]; shadowColor = [coder decodeObjectOfClass:[CPTColor class] @@ -174,7 +174,7 @@ -(nonnull id)mutableCopyWithZone:(nullable NSZone *)zone -(void)setShadowBlurRadius:(CGFloat)newShadowBlurRadius { - NSParameterAssert(newShadowBlurRadius >= CPTFloat(0.0) ); + NSParameterAssert(newShadowBlurRadius >= CPTFloat(0.0)); if ( newShadowBlurRadius != shadowBlurRadius ) { shadowBlurRadius = newShadowBlurRadius; diff --git a/CorePlot/framework/Source/CPTTestCase.h b/CorePlot/framework/Source/CPTTestCase.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTTestCase.m b/CorePlot/framework/Source/CPTTestCase.m old mode 100755 new mode 100644 index 9ad27ca..effe3ad --- a/CorePlot/framework/Source/CPTTestCase.m +++ b/CorePlot/framework/Source/CPTTestCase.m @@ -2,12 +2,12 @@ @implementation CPTTestCase --(id)archiveRoundTrip:(id)object +-(nullable id)archiveRoundTrip:(nonnull id)object { return [self archiveRoundTrip:object toClass:[object class]]; } --(nullable id)archiveRoundTrip:(nonnull id)object toClass:(Class)archiveClass +-(nullable id)archiveRoundTrip:(nonnull id)object toClass:(nonnull Class)archiveClass { const BOOL secure = ![archiveClass isSubclassOfClass:[NSNumberFormatter class]]; diff --git a/CorePlot/framework/Source/CPTTextLayer.h b/CorePlot/framework/Source/CPTTextLayer.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTTextLayer.m b/CorePlot/framework/Source/CPTTextLayer.m old mode 100755 new mode 100644 index 50073d8..995afbe --- a/CorePlot/framework/Source/CPTTextLayer.m +++ b/CorePlot/framework/Source/CPTTextLayer.m @@ -71,7 +71,7 @@ @implementation CPTTextLayer **/ -(nonnull instancetype)initWithText:(nullable NSString *)newText style:(nullable CPTTextStyle *)newStyle { - if ( (self = [super initWithFrame:CGRectZero]) ) { + if ((self = [super initWithFrame:CGRectZero])) { textStyle = newStyle; text = [newText copy]; attributedText = nil; @@ -102,7 +102,7 @@ -(nonnull instancetype)initWithAttributedText:(nullable NSAttributedString *)new { CPTTextStyle *newStyle = [CPTTextStyle textStyleWithAttributes:[newText attributesAtIndex:0 effectiveRange:NULL]]; - if ( (self = [self initWithText:newText.string style:newStyle]) ) { + if ((self = [self initWithText:newText.string style:newStyle])) { attributedText = [newText copy]; [self sizeToFit]; @@ -115,7 +115,7 @@ -(nonnull instancetype)initWithAttributedText:(nullable NSAttributedString *)new -(nonnull instancetype)initWithLayer:(nonnull id)layer { - if ( (self = [super initWithLayer:layer]) ) { + if ((self = [super initWithLayer:layer])) { CPTTextLayer *theLayer = (CPTTextLayer *)layer; textStyle = theLayer->textStyle; @@ -167,7 +167,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super initWithCoder:coder]) ) { + if ((self = [super initWithCoder:coder])) { textStyle = [coder decodeObjectOfClass:[CPTTextStyle class] forKey:@"CPTTextLayer.textStyle"]; text = [[coder decodeObjectOfClass:[NSString class] @@ -255,7 +255,7 @@ -(void)setAttributedText:(nullable NSAttributedString *)newValue -(void)setMaximumSize:(CGSize)newSize { - if ( !CGSizeEqualToSize(maximumSize, newSize) ) { + if ( !CGSizeEqualToSize(maximumSize, newSize)) { maximumSize = newSize; [self sizeToFit]; } @@ -347,10 +347,10 @@ -(void)sizeToFit newBounds.size.height += self.paddingTop + self.paddingBottom; CGSize myMaxSize = self.maximumSize; - if ( myMaxSize.width > CPTFloat(0.0) ) { + if ( myMaxSize.width > CPTFloat(0.0)) { newBounds.size.width = MIN(newBounds.size.width, myMaxSize.width); } - if ( myMaxSize.height > CPTFloat(0.0) ) { + if ( myMaxSize.height > CPTFloat(0.0)) { newBounds.size.height = MIN(newBounds.size.height, myMaxSize.height); } @@ -381,7 +381,7 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context #if TARGET_OS_SIMULATOR || TARGET_OS_IPHONE CGContextSaveGState(context); CGContextTranslateCTM(context, CPTFloat(0.0), self.bounds.size.height); - CGContextScaleCTM(context, CPTFloat(1.0), CPTFloat(-1.0) ); + CGContextScaleCTM(context, CPTFloat(1.0), CPTFloat(-1.0)); #endif CGRect newBounds = CGRectInset(self.bounds, kCPTTextLayerMarginWidth, kCPTTextLayerMarginWidth); @@ -395,7 +395,7 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context newBounds.size.height -= self.paddingTop + self.paddingBottom; NSAttributedString *styledText = self.attributedText; - if ( (styledText.length > 0) && [styledText respondsToSelector:@selector(drawInRect:)] ) { + if ((styledText.length > 0) && [styledText respondsToSelector:@selector(drawInRect:)] ) { [styledText drawInRect:newBounds inContext:context]; } diff --git a/CorePlot/framework/Source/CPTTextStyle.h b/CorePlot/framework/Source/CPTTextStyle.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTTextStyle.m b/CorePlot/framework/Source/CPTTextStyle.m old mode 100755 new mode 100644 index 61e6b28..f1b7452 --- a/CorePlot/framework/Source/CPTTextStyle.m +++ b/CorePlot/framework/Source/CPTTextStyle.m @@ -101,7 +101,7 @@ +(nonnull instancetype)textStyleWithStyle:(nullable CPTTextStyle *)textStyle **/ -(nonnull instancetype)init { - if ( (self = [super init]) ) { + if ((self = [super init])) { fontName = @"Helvetica"; fontSize = CPTFloat(12.0); color = [CPTColor blackColor]; @@ -129,7 +129,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super init]) ) { + if ((self = [super init])) { fontName = [[coder decodeObjectOfClass:[NSString class] forKey:@"CPTTextStyle.fontName"] copy]; fontSize = [coder decodeCGFloatForKey:@"CPTTextStyle.fontSize"]; diff --git a/CorePlot/framework/Source/CPTTextStyleTests.h b/CorePlot/framework/Source/CPTTextStyleTests.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTTextStyleTests.m b/CorePlot/framework/Source/CPTTextStyleTests.m old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTTheme.h b/CorePlot/framework/Source/CPTTheme.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTTheme.m b/CorePlot/framework/Source/CPTTheme.m old mode 100755 new mode 100644 index 0fc513f..b4b06de --- a/CorePlot/framework/Source/CPTTheme.m +++ b/CorePlot/framework/Source/CPTTheme.m @@ -40,7 +40,7 @@ @implementation CPTTheme **/ -(nonnull instancetype)init { - if ( (self = [super init]) ) { + if ((self = [super init])) { graphClass = Nil; } return self; diff --git a/CorePlot/framework/Source/CPTThemeTests.h b/CorePlot/framework/Source/CPTThemeTests.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTThemeTests.m b/CorePlot/framework/Source/CPTThemeTests.m old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTTimeFormatter.h b/CorePlot/framework/Source/CPTTimeFormatter.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTTimeFormatter.m b/CorePlot/framework/Source/CPTTimeFormatter.m old mode 100755 new mode 100644 index 4abfd39..8d0ad4b --- a/CorePlot/framework/Source/CPTTimeFormatter.m +++ b/CorePlot/framework/Source/CPTTimeFormatter.m @@ -49,7 +49,7 @@ -(nonnull instancetype)init **/ -(nonnull instancetype)initWithDateFormatter:(nullable NSDateFormatter *)aDateFormatter { - if ( (self = [super init]) ) { + if ((self = [super init])) { dateFormatter = aDateFormatter; referenceDate = nil; } @@ -77,7 +77,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder */ -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super init]) ) { + if ((self = [super init])) { dateFormatter = [coder decodeObjectForKey:@"CPTTimeFormatter.dateFormatter"]; referenceDate = [[coder decodeObjectForKey:@"CPTTimeFormatter.referenceDate"] copy]; } diff --git a/CorePlot/framework/Source/CPTTimeFormatterTests.h b/CorePlot/framework/Source/CPTTimeFormatterTests.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTTimeFormatterTests.m b/CorePlot/framework/Source/CPTTimeFormatterTests.m old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTTradingRangePlot.h b/CorePlot/framework/Source/CPTTradingRangePlot.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTTradingRangePlot.m b/CorePlot/framework/Source/CPTTradingRangePlot.m old mode 100755 new mode 100644 index 75d592a..6d07649 --- a/CorePlot/framework/Source/CPTTradingRangePlot.m +++ b/CorePlot/framework/Source/CPTTradingRangePlot.m @@ -204,7 +204,7 @@ +(void)initialize **/ -(nonnull instancetype)initWithFrame:(CGRect)newFrame { - if ( (self = [super initWithFrame:newFrame]) ) { + if ((self = [super initWithFrame:newFrame])) { plotStyle = CPTTradingRangePlotStyleOHLC; lineStyle = [[CPTLineStyle alloc] init]; increaseLineStyle = nil; @@ -229,7 +229,7 @@ -(nonnull instancetype)initWithFrame:(CGRect)newFrame -(nonnull instancetype)initWithLayer:(nonnull id)layer { - if ( (self = [super initWithLayer:layer]) ) { + if ((self = [super initWithLayer:layer])) { CPTTradingRangePlot *theLayer = (CPTTradingRangePlot *)layer; plotStyle = theLayer->plotStyle; @@ -276,7 +276,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super initWithCoder:coder]) ) { + if ((self = [super initWithCoder:coder])) { lineStyle = [[coder decodeObjectOfClass:[CPTLineStyle class] forKey:@"CPTTradingRangePlot.lineStyle"] copy]; increaseLineStyle = [[coder decodeObjectOfClass:[CPTLineStyle class] @@ -570,11 +570,11 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context if ( sampleCount == 0 ) { return; } - if ( (opens == nil) || (highs == nil) || (lows == nil) || (closes == nil) ) { + if ((opens == nil) || (highs == nil) || (lows == nil) || (closes == nil)) { return; } - if ( (opens.numberOfSamples != sampleCount) || (highs.numberOfSamples != sampleCount) || (lows.numberOfSamples != sampleCount) || (closes.numberOfSamples != sampleCount) ) { + if ((opens.numberOfSamples != sampleCount) || (highs.numberOfSamples != sampleCount) || (lows.numberOfSamples != sampleCount) || (closes.numberOfSamples != sampleCount)) { [NSException raise:CPTException format:@"Mismatching number of data values in trading range plot"]; } @@ -598,7 +598,7 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context for ( NSUInteger i = 0; i < sampleCount; i++ ) { double plotPoint[2]; plotPoint[independentCoord] = *locationBytes++; - if ( isnan(plotPoint[independentCoord]) ) { + if ( isnan(plotPoint[independentCoord])) { openBytes++; highBytes++; lowBytes++; @@ -608,7 +608,7 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context // open point plotPoint[dependentCoord] = *openBytes++; - if ( isnan(plotPoint[dependentCoord]) ) { + if ( isnan(plotPoint[dependentCoord])) { openPoint = CPTPointMake(NAN, NAN); } else { @@ -617,7 +617,7 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context // high point plotPoint[dependentCoord] = *highBytes++; - if ( isnan(plotPoint[dependentCoord]) ) { + if ( isnan(plotPoint[dependentCoord])) { highPoint = CPTPointMake(NAN, NAN); } else { @@ -626,7 +626,7 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context // low point plotPoint[dependentCoord] = *lowBytes++; - if ( isnan(plotPoint[dependentCoord]) ) { + if ( isnan(plotPoint[dependentCoord])) { lowPoint = CPTPointMake(NAN, NAN); } else { @@ -635,7 +635,7 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context // close point plotPoint[dependentCoord] = *closeBytes++; - if ( isnan(plotPoint[dependentCoord]) ) { + if ( isnan(plotPoint[dependentCoord])) { closePoint = CPTPointMake(NAN, NAN); } else { @@ -643,17 +643,17 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context } CGFloat xCoord = openPoint.x; - if ( isnan(xCoord) ) { + if ( isnan(xCoord)) { xCoord = highPoint.x; } - else if ( isnan(xCoord) ) { + else if ( isnan(xCoord)) { xCoord = lowPoint.x; } - else if ( isnan(xCoord) ) { + else if ( isnan(xCoord)) { xCoord = closePoint.x; } - if ( !isnan(xCoord) ) { + if ( !isnan(xCoord)) { // Draw switch ( thePlotStyle ) { case CPTTradingRangePlotStyleOHLC: @@ -691,7 +691,7 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context for ( NSUInteger i = 0; i < sampleCount; i++ ) { NSDecimal plotPoint[2]; plotPoint[independentCoord] = *locationBytes++; - if ( NSDecimalIsNotANumber(&plotPoint[independentCoord]) ) { + if ( NSDecimalIsNotANumber(&plotPoint[independentCoord])) { openBytes++; highBytes++; lowBytes++; @@ -701,7 +701,7 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context // open point plotPoint[dependentCoord] = *openBytes++; - if ( NSDecimalIsNotANumber(&plotPoint[dependentCoord]) ) { + if ( NSDecimalIsNotANumber(&plotPoint[dependentCoord])) { openPoint = CPTPointMake(NAN, NAN); } else { @@ -710,7 +710,7 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context // high point plotPoint[dependentCoord] = *highBytes++; - if ( NSDecimalIsNotANumber(&plotPoint[dependentCoord]) ) { + if ( NSDecimalIsNotANumber(&plotPoint[dependentCoord])) { highPoint = CPTPointMake(NAN, NAN); } else { @@ -719,7 +719,7 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context // low point plotPoint[dependentCoord] = *lowBytes++; - if ( NSDecimalIsNotANumber(&plotPoint[dependentCoord]) ) { + if ( NSDecimalIsNotANumber(&plotPoint[dependentCoord])) { lowPoint = CPTPointMake(NAN, NAN); } else { @@ -728,7 +728,7 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context // close point plotPoint[dependentCoord] = *closeBytes++; - if ( NSDecimalIsNotANumber(&plotPoint[dependentCoord]) ) { + if ( NSDecimalIsNotANumber(&plotPoint[dependentCoord])) { closePoint = CPTPointMake(NAN, NAN); } else { @@ -736,17 +736,17 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context } CGFloat xCoord = openPoint.x; - if ( isnan(xCoord) ) { + if ( isnan(xCoord)) { xCoord = highPoint.x; } - else if ( isnan(xCoord) ) { + else if ( isnan(xCoord)) { xCoord = lowPoint.x; } - else if ( isnan(xCoord) ) { + else if ( isnan(xCoord)) { xCoord = closePoint.x; } - if ( !isnan(xCoord) ) { + if ( !isnan(xCoord)) { // Draw switch ( thePlotStyle ) { case CPTTradingRangePlotStyleOHLC: @@ -791,7 +791,7 @@ -(void)drawCandleStickInContext:(nonnull CGContextRef)context CPTFill *currentBarFill = nil; CPTLineStyle *theBorderLineStyle = nil; - if ( !isnan(openValue) && !isnan(closeValue) ) { + if ( !isnan(openValue) && !isnan(closeValue)) { if ( openValue < closeValue ) { theBorderLineStyle = [self increaseLineStyleForIndex:idx]; currentBarFill = [self increaseFillForIndex:idx]; @@ -816,13 +816,13 @@ -(void)drawCandleStickInContext:(nonnull CGContextRef)context [theBorderLineStyle setLineStyleInContext:context]; CGFloat lineWidth = theBorderLineStyle.lineWidth; - if ( (self.contentsScale > CPTFloat(1.0) ) && (round(lineWidth) == lineWidth) ) { + if ((self.contentsScale > CPTFloat(1.0)) && (round(lineWidth) == lineWidth)) { alignmentFunction = CPTAlignIntegralPointToUserSpace; } } // high - low only - if ( hasLineStyle && !isnan(highValue) && !isnan(lowValue) && (isnan(openValue) || isnan(closeValue) ) ) { + if ( hasLineStyle && !isnan(highValue) && !isnan(lowValue) && (isnan(openValue) || isnan(closeValue))) { CGPoint alignedHighPoint = CPTPointMake(x, highValue); CGPoint alignedLowPoint = CPTPointMake(x, lowValue); if ( alignPoints ) { @@ -842,10 +842,10 @@ -(void)drawCandleStickInContext:(nonnull CGContextRef)context } // open-close - if ( !isnan(openValue) && !isnan(closeValue) ) { + if ( !isnan(openValue) && !isnan(closeValue)) { if ( currentBarFill || hasLineStyle ) { CGFloat radius = MIN(self.barCornerRadius, halfBarWidth); - radius = MIN(radius, ABS(closeValue - openValue) ); + radius = MIN(radius, ABS(closeValue - openValue)); CGPoint alignedPoint1 = CPTPointMake(x + halfBarWidth, openValue); CGPoint alignedPoint2 = CPTPointMake(x + halfBarWidth, closeValue); @@ -869,7 +869,7 @@ -(void)drawCandleStickInContext:(nonnull CGContextRef)context } } - if ( hasLineStyle && (openValue == closeValue) ) { + if ( hasLineStyle && (openValue == closeValue)) { // #285 Draw a cross with open/close values marked const CGFloat halfLineWidth = CPTFloat(0.5) * theBorderLineStyle.lineWidth; @@ -899,9 +899,9 @@ -(void)drawCandleStickInContext:(nonnull CGContextRef)context path = CGPathCreateMutable(); } - if ( !isnan(lowValue) ) { - if ( lowValue < MIN(openValue, closeValue) ) { - CGPoint alignedStartPoint = CPTPointMake(x, MIN(openValue, closeValue) ); + if ( !isnan(lowValue)) { + if ( lowValue < MIN(openValue, closeValue)) { + CGPoint alignedStartPoint = CPTPointMake(x, MIN(openValue, closeValue)); CGPoint alignedLowPoint = CPTPointMake(x, lowValue); if ( alignPoints ) { alignedStartPoint = alignmentFunction(context, alignedStartPoint); @@ -912,9 +912,9 @@ -(void)drawCandleStickInContext:(nonnull CGContextRef)context CGPathAddLineToPoint(path, NULL, alignedLowPoint.x, alignedLowPoint.y); } } - if ( !isnan(highValue) ) { - if ( highValue > MAX(openValue, closeValue) ) { - CGPoint alignedStartPoint = CPTPointMake(x, MAX(openValue, closeValue) ); + if ( !isnan(highValue)) { + if ( highValue > MAX(openValue, closeValue)) { + CGPoint alignedStartPoint = CPTPointMake(x, MAX(openValue, closeValue)); CGPoint alignedHighPoint = CPTPointMake(x, highValue); if ( alignPoints ) { alignedStartPoint = alignmentFunction(context, alignedStartPoint); @@ -946,7 +946,7 @@ -(void)drawOHLCInContext:(nonnull CGContextRef)context { CPTLineStyle *theLineStyle = [self lineStyleForIndex:idx]; - if ( !isnan(openValue) && !isnan(closeValue) ) { + if ( !isnan(openValue) && !isnan(closeValue)) { if ( openValue < closeValue ) { CPTLineStyle *lineStyleForIncrease = [self increaseLineStyleForIndex:idx]; if ( [lineStyleForIncrease isKindOfClass:[CPTLineStyle class]] ) { @@ -968,12 +968,12 @@ -(void)drawOHLCInContext:(nonnull CGContextRef)context CPTAlignPointFunction alignmentFunction = CPTAlignPointToUserSpace; CGFloat lineWidth = theLineStyle.lineWidth; - if ( (self.contentsScale > CPTFloat(1.0) ) && (round(lineWidth) == lineWidth) ) { + if ((self.contentsScale > CPTFloat(1.0)) && (round(lineWidth) == lineWidth)) { alignmentFunction = CPTAlignIntegralPointToUserSpace; } // high-low - if ( !isnan(highValue) && !isnan(lowValue) ) { + if ( !isnan(highValue) && !isnan(lowValue)) { CGPoint alignedHighPoint = CPTPointMake(x, highValue); CGPoint alignedLowPoint = CPTPointMake(x, lowValue); if ( alignPoints ) { @@ -985,7 +985,7 @@ -(void)drawOHLCInContext:(nonnull CGContextRef)context } // open - if ( !isnan(openValue) ) { + if ( !isnan(openValue)) { CGPoint alignedOpenStartPoint = CPTPointMake(x, openValue); CGPoint alignedOpenEndPoint = CPTPointMake(x - theStickLength, openValue); // left side if ( alignPoints ) { @@ -997,7 +997,7 @@ -(void)drawOHLCInContext:(nonnull CGContextRef)context } // close - if ( !isnan(closeValue) ) { + if ( !isnan(closeValue)) { CGPoint alignedCloseStartPoint = CPTPointMake(x, closeValue); CGPoint alignedCloseEndPoint = CPTPointMake(x + theStickLength, closeValue); // right side if ( alignPoints ) { @@ -1053,7 +1053,7 @@ -(nullable CPTFill *)increaseFillForIndex:(NSUInteger)idx { CPTFill *theFill = [self cachedValueForKey:CPTTradingRangePlotBindingIncreaseFills recordIndex:idx]; - if ( (theFill == nil) || (theFill == [CPTPlot nilData]) ) { + if ((theFill == nil) || (theFill == [CPTPlot nilData])) { theFill = self.increaseFill; } @@ -1064,7 +1064,7 @@ -(nullable CPTFill *)decreaseFillForIndex:(NSUInteger)idx { CPTFill *theFill = [self cachedValueForKey:CPTTradingRangePlotBindingDecreaseFills recordIndex:idx]; - if ( (theFill == nil) || (theFill == [CPTPlot nilData]) ) { + if ((theFill == nil) || (theFill == [CPTPlot nilData])) { theFill = self.decreaseFill; } @@ -1075,7 +1075,7 @@ -(nullable CPTLineStyle *)lineStyleForIndex:(NSUInteger)idx { CPTLineStyle *theLineStyle = [self cachedValueForKey:CPTTradingRangePlotBindingLineStyles recordIndex:idx]; - if ( (theLineStyle == nil) || (theLineStyle == [CPTPlot nilData]) ) { + if ((theLineStyle == nil) || (theLineStyle == [CPTPlot nilData])) { theLineStyle = self.lineStyle; } @@ -1086,7 +1086,7 @@ -(nullable CPTLineStyle *)increaseLineStyleForIndex:(NSUInteger)idx { CPTLineStyle *theLineStyle = [self cachedValueForKey:CPTTradingRangePlotBindingIncreaseLineStyles recordIndex:idx]; - if ( (theLineStyle == nil) || (theLineStyle == [CPTPlot nilData]) ) { + if ((theLineStyle == nil) || (theLineStyle == [CPTPlot nilData])) { theLineStyle = self.increaseLineStyle; } @@ -1101,7 +1101,7 @@ -(nullable CPTLineStyle *)decreaseLineStyleForIndex:(NSUInteger)idx { CPTLineStyle *theLineStyle = [self cachedValueForKey:CPTTradingRangePlotBindingDecreaseLineStyles recordIndex:idx]; - if ( (theLineStyle == nil) || (theLineStyle == [CPTPlot nilData]) ) { + if ((theLineStyle == nil) || (theLineStyle == [CPTPlot nilData])) { theLineStyle = self.decreaseLineStyle; } @@ -1218,7 +1218,7 @@ -(void)positionLabelAnnotation:(nonnull CPTPlotSpaceAnnotation *)label forIndex: BOOL positiveDirection = YES; CPTPlotRange *yRange = [self.plotSpace plotRangeForCoordinate:CPTCoordinateY]; - if ( CPTDecimalLessThan(yRange.lengthDecimal, CPTDecimalFromInteger(0) ) ) { + if ( CPTDecimalLessThan(yRange.lengthDecimal, CPTDecimalFromInteger(0))) { positiveDirection = !positiveDirection; } @@ -1307,7 +1307,7 @@ -(NSUInteger)dataIndexFromInteractionPoint:(CGPoint)point if ( !isnan(plotPoint[dependentCoord]) && [yRange containsDouble:plotPoint[dependentCoord]] ) { openPoint = [thePlotSpace plotAreaViewPointForDoublePrecisionPlotPoint:plotPoint numberOfCoordinates:2]; CGFloat distanceSquared = squareOfDistanceBetweenPoints(point, openPoint); - if ( isnan(minimumDistanceSquared) || (distanceSquared < minimumDistanceSquared) ) { + if ( isnan(minimumDistanceSquared) || (distanceSquared < minimumDistanceSquared)) { minimumDistanceSquared = distanceSquared; result = i; } @@ -1321,7 +1321,7 @@ -(NSUInteger)dataIndexFromInteractionPoint:(CGPoint)point if ( !isnan(plotPoint[dependentCoord]) && [yRange containsDouble:plotPoint[dependentCoord]] ) { highPoint = [thePlotSpace plotAreaViewPointForDoublePrecisionPlotPoint:plotPoint numberOfCoordinates:2]; CGFloat distanceSquared = squareOfDistanceBetweenPoints(point, highPoint); - if ( isnan(minimumDistanceSquared) || (distanceSquared < minimumDistanceSquared) ) { + if ( isnan(minimumDistanceSquared) || (distanceSquared < minimumDistanceSquared)) { minimumDistanceSquared = distanceSquared; result = i; } @@ -1335,7 +1335,7 @@ -(NSUInteger)dataIndexFromInteractionPoint:(CGPoint)point if ( !isnan(plotPoint[dependentCoord]) && [yRange containsDouble:plotPoint[dependentCoord]] ) { lowPoint = [thePlotSpace plotAreaViewPointForDoublePrecisionPlotPoint:plotPoint numberOfCoordinates:2]; CGFloat distanceSquared = squareOfDistanceBetweenPoints(point, lowPoint); - if ( isnan(minimumDistanceSquared) || (distanceSquared < minimumDistanceSquared) ) { + if ( isnan(minimumDistanceSquared) || (distanceSquared < minimumDistanceSquared)) { minimumDistanceSquared = distanceSquared; result = i; } @@ -1349,7 +1349,7 @@ -(NSUInteger)dataIndexFromInteractionPoint:(CGPoint)point if ( !isnan(plotPoint[dependentCoord]) && [yRange containsDouble:plotPoint[dependentCoord]] ) { closePoint = [thePlotSpace plotAreaViewPointForDoublePrecisionPlotPoint:plotPoint numberOfCoordinates:2]; CGFloat distanceSquared = squareOfDistanceBetweenPoints(point, closePoint); - if ( isnan(minimumDistanceSquared) || (distanceSquared < minimumDistanceSquared) ) { + if ( isnan(minimumDistanceSquared) || (distanceSquared < minimumDistanceSquared)) { minimumDistanceSquared = distanceSquared; result = i; } @@ -1360,18 +1360,18 @@ -(NSUInteger)dataIndexFromInteractionPoint:(CGPoint)point if ( result == i ) { lastViewX = openPoint.x; - if ( isnan(lastViewX) ) { + if ( isnan(lastViewX)) { lastViewX = highPoint.x; } - else if ( isnan(lastViewX) ) { + else if ( isnan(lastViewX)) { lastViewX = lowPoint.x; } - else if ( isnan(lastViewX) ) { + else if ( isnan(lastViewX)) { lastViewX = closePoint.x; } - lastViewMin = MIN(MIN(openPoint.y, closePoint.y), MIN(highPoint.y, lowPoint.y) ); - lastViewMax = MAX(MAX(openPoint.y, closePoint.y), MAX(highPoint.y, lowPoint.y) ); + lastViewMin = MIN(MIN(openPoint.y, closePoint.y), MIN(highPoint.y, lowPoint.y)); + lastViewMax = MAX(MAX(openPoint.y, closePoint.y), MAX(highPoint.y, lowPoint.y)); } } } @@ -1400,7 +1400,7 @@ -(NSUInteger)dataIndexFromInteractionPoint:(CGPoint)point if ( !NSDecimalIsNotANumber(&plotPoint[dependentCoord]) && [yRange contains:plotPoint[dependentCoord]] ) { openPoint = [thePlotSpace plotAreaViewPointForPlotPoint:plotPoint numberOfCoordinates:2]; CGFloat distanceSquared = squareOfDistanceBetweenPoints(point, openPoint); - if ( isnan(minimumDistanceSquared) || (distanceSquared < minimumDistanceSquared) ) { + if ( isnan(minimumDistanceSquared) || (distanceSquared < minimumDistanceSquared)) { minimumDistanceSquared = distanceSquared; result = i; } @@ -1414,7 +1414,7 @@ -(NSUInteger)dataIndexFromInteractionPoint:(CGPoint)point if ( !NSDecimalIsNotANumber(&plotPoint[dependentCoord]) && [yRange contains:plotPoint[dependentCoord]] ) { highPoint = [thePlotSpace plotAreaViewPointForPlotPoint:plotPoint numberOfCoordinates:2]; CGFloat distanceSquared = squareOfDistanceBetweenPoints(point, highPoint); - if ( isnan(minimumDistanceSquared) || (distanceSquared < minimumDistanceSquared) ) { + if ( isnan(minimumDistanceSquared) || (distanceSquared < minimumDistanceSquared)) { minimumDistanceSquared = distanceSquared; result = i; } @@ -1428,7 +1428,7 @@ -(NSUInteger)dataIndexFromInteractionPoint:(CGPoint)point if ( !NSDecimalIsNotANumber(&plotPoint[dependentCoord]) && [yRange contains:plotPoint[dependentCoord]] ) { lowPoint = [thePlotSpace plotAreaViewPointForPlotPoint:plotPoint numberOfCoordinates:2]; CGFloat distanceSquared = squareOfDistanceBetweenPoints(point, lowPoint); - if ( isnan(minimumDistanceSquared) || (distanceSquared < minimumDistanceSquared) ) { + if ( isnan(minimumDistanceSquared) || (distanceSquared < minimumDistanceSquared)) { minimumDistanceSquared = distanceSquared; result = i; } @@ -1442,7 +1442,7 @@ -(NSUInteger)dataIndexFromInteractionPoint:(CGPoint)point if ( !NSDecimalIsNotANumber(&plotPoint[dependentCoord]) && [yRange contains:plotPoint[dependentCoord]] ) { closePoint = [thePlotSpace plotAreaViewPointForPlotPoint:plotPoint numberOfCoordinates:2]; CGFloat distanceSquared = squareOfDistanceBetweenPoints(point, closePoint); - if ( isnan(minimumDistanceSquared) || (distanceSquared < minimumDistanceSquared) ) { + if ( isnan(minimumDistanceSquared) || (distanceSquared < minimumDistanceSquared)) { minimumDistanceSquared = distanceSquared; result = i; } @@ -1453,18 +1453,18 @@ -(NSUInteger)dataIndexFromInteractionPoint:(CGPoint)point if ( result == i ) { lastViewX = openPoint.x; - if ( isnan(lastViewX) ) { + if ( isnan(lastViewX)) { lastViewX = highPoint.x; } - else if ( isnan(lastViewX) ) { + else if ( isnan(lastViewX)) { lastViewX = lowPoint.x; } - else if ( isnan(lastViewX) ) { + else if ( isnan(lastViewX)) { lastViewX = closePoint.x; } - lastViewMin = MIN(MIN(openPoint.y, closePoint.y), MIN(highPoint.y, lowPoint.y) ); - lastViewMax = MAX(MAX(openPoint.y, closePoint.y), MAX(highPoint.y, lowPoint.y) ); + lastViewMin = MIN(MIN(openPoint.y, closePoint.y), MIN(highPoint.y, lowPoint.y)); + lastViewMax = MAX(MAX(openPoint.y, closePoint.y), MAX(highPoint.y, lowPoint.y)); } } } @@ -1482,10 +1482,10 @@ -(NSUInteger)dataIndexFromInteractionPoint:(CGPoint)point break; } - if ( (point.x < (lastViewX - offset) ) || (point.x > (lastViewX + offset) ) ) { + if ((point.x < (lastViewX - offset)) || (point.x > (lastViewX + offset))) { result = NSNotFound; } - if ( (point.y < lastViewMin) || (point.y > lastViewMax) ) { + if ((point.y < lastViewMin) || (point.y > lastViewMax)) { result = NSNotFound; } } diff --git a/CorePlot/framework/Source/CPTUtilities.h b/CorePlot/framework/Source/CPTUtilities.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTUtilities.m b/CorePlot/framework/Source/CPTUtilities.m old mode 100755 new mode 100644 index a2ee90b..1a4641d --- a/CorePlot/framework/Source/CPTUtilities.m +++ b/CorePlot/framework/Source/CPTUtilities.m @@ -247,7 +247,7 @@ CGFloat CPTDecimalCGFloatValue(NSDecimal decimalNumber) **/ NSDecimal CPTDecimalFromChar(int8_t anInt) { - if ( (anInt >= 0) && (anInt < kCacheSize) ) { + if ((anInt >= 0) && (anInt < kCacheSize)) { if ( !cacheValueInitialized[anInt] ) { NSString *stringValue = [[NSString alloc] initWithFormat:@"%hhd", anInt]; cache[anInt] = CPTDecimalFromString(stringValue); @@ -270,7 +270,7 @@ NSDecimal CPTDecimalFromChar(int8_t anInt) **/ NSDecimal CPTDecimalFromShort(int16_t anInt) { - if ( (anInt >= 0) && (anInt < kCacheSize) ) { + if ((anInt >= 0) && (anInt < kCacheSize)) { if ( !cacheValueInitialized[anInt] ) { NSString *stringValue = [[NSString alloc] initWithFormat:@"%hd", anInt]; cache[anInt] = CPTDecimalFromString(stringValue); @@ -293,7 +293,7 @@ NSDecimal CPTDecimalFromShort(int16_t anInt) **/ NSDecimal CPTDecimalFromLong(int32_t anInt) { - if ( (anInt >= 0) && (anInt < kCacheSize) ) { + if ((anInt >= 0) && (anInt < kCacheSize)) { if ( !cacheValueInitialized[anInt] ) { NSString *stringValue = [[NSString alloc] initWithFormat:@"%d", anInt]; cache[anInt] = CPTDecimalFromString(stringValue); @@ -316,7 +316,7 @@ NSDecimal CPTDecimalFromLong(int32_t anInt) **/ NSDecimal CPTDecimalFromLongLong(int64_t anInt) { - if ( (anInt >= 0) && (anInt < kCacheSize) ) { + if ((anInt >= 0) && (anInt < kCacheSize)) { if ( !cacheValueInitialized[anInt] ) { NSString *stringValue = [[NSString alloc] initWithFormat:@"%lld", anInt]; cache[anInt] = CPTDecimalFromString(stringValue); @@ -339,7 +339,7 @@ NSDecimal CPTDecimalFromLongLong(int64_t anInt) **/ NSDecimal CPTDecimalFromInt(int anInt) { - if ( (anInt >= 0) && (anInt < kCacheSize) ) { + if ((anInt >= 0) && (anInt < kCacheSize)) { if ( !cacheValueInitialized[anInt] ) { NSString *stringValue = [[NSString alloc] initWithFormat:@"%d", anInt]; cache[anInt] = CPTDecimalFromString(stringValue); @@ -362,7 +362,7 @@ NSDecimal CPTDecimalFromInt(int anInt) **/ NSDecimal CPTDecimalFromInteger(NSInteger anInt) { - if ( (anInt >= 0) && (anInt < kCacheSize) ) { + if ((anInt >= 0) && (anInt < kCacheSize)) { if ( !cacheValueInitialized[anInt] ) { NSString *stringValue = [[NSString alloc] initWithFormat:@"%ld", (long)anInt]; cache[anInt] = CPTDecimalFromString(stringValue); @@ -523,7 +523,7 @@ NSDecimal CPTDecimalFromUnsignedInteger(NSUInteger anInt) **/ NSDecimal CPTDecimalFromFloat(float aFloat) { - if ( isnan(aFloat) ) { + if ( isnan(aFloat) || isinf(aFloat)) { return CPTDecimalNaN(); } else { @@ -541,7 +541,7 @@ NSDecimal CPTDecimalFromFloat(float aFloat) **/ NSDecimal CPTDecimalFromDouble(double aDouble) { - if ( isnan(aDouble) ) { + if ( isnan(aDouble) || isinf(aDouble)) { return CPTDecimalNaN(); } else { @@ -559,7 +559,7 @@ NSDecimal CPTDecimalFromDouble(double aDouble) **/ NSDecimal CPTDecimalFromCGFloat(CGFloat aCGFloat) { - if ( isnan(aCGFloat) ) { + if ( isnan(aCGFloat) || isinf(aCGFloat)) { return CPTDecimalNaN(); } else { @@ -743,7 +743,13 @@ NSDecimal CPTDecimalNaN(void) **/ NSDecimal CPTDecimalMin(NSDecimal leftOperand, NSDecimal rightOperand) { - if ( NSDecimalCompare(&leftOperand, &rightOperand) == NSOrderedAscending ) { + if ( NSDecimalIsNotANumber(&leftOperand)) { + return rightOperand; + } + else if ( NSDecimalIsNotANumber(&rightOperand)) { + return leftOperand; + } + else if ( NSDecimalCompare(&leftOperand, &rightOperand) == NSOrderedAscending ) { return leftOperand; } else { @@ -759,7 +765,13 @@ NSDecimal CPTDecimalMin(NSDecimal leftOperand, NSDecimal rightOperand) **/ NSDecimal CPTDecimalMax(NSDecimal leftOperand, NSDecimal rightOperand) { - if ( NSDecimalCompare(&leftOperand, &rightOperand) == NSOrderedDescending ) { + if ( NSDecimalIsNotANumber(&leftOperand)) { + return rightOperand; + } + else if ( NSDecimalIsNotANumber(&rightOperand)) { + return leftOperand; + } + else if ( NSDecimalCompare(&leftOperand, &rightOperand) == NSOrderedDescending ) { return leftOperand; } else { @@ -774,11 +786,11 @@ NSDecimal CPTDecimalMax(NSDecimal leftOperand, NSDecimal rightOperand) **/ NSDecimal CPTDecimalAbs(NSDecimal value) { - if ( CPTDecimalGreaterThanOrEqualTo(value, CPTDecimalFromInteger(0) ) ) { + if ( CPTDecimalGreaterThanOrEqualTo(value, CPTDecimalFromInteger(0))) { return value; } else { - return CPTDecimalMultiply(value, CPTDecimalFromInteger(-1) ); + return CPTDecimalMultiply(value, CPTDecimalFromInteger(-1)); } } @@ -800,7 +812,7 @@ NSRange CPTExpandedRange(NSRange range, NSInteger expandBy) NSInteger lowerExpansion = (NSInteger)range.location - loc; NSInteger length = MAX(0, (NSInteger)range.length + lowerExpansion + expandBy); - return NSMakeRange( (NSUInteger)loc, (NSUInteger)length ); + return NSMakeRange((NSUInteger)loc, (NSUInteger)length); } #pragma mark - @@ -875,7 +887,7 @@ CGPoint CPTAlignPointToUserSpace(__nonnull CGContextRef context, CGPoint point) // Ensure that coordinates are at exactly the corner // of a device pixel. - point.x = round(point.x - CPTFloat(0.5) ) + CPTFloat(0.5); + point.x = round(point.x - CPTFloat(0.5)) + CPTFloat(0.5); point.y = ceil(point.y) - CPTFloat(0.5); // Convert the device aligned coordinate back to user space. @@ -922,11 +934,11 @@ CGRect CPTAlignRectToUserSpace(__nonnull CGContextRef context, CGRect rect) CGPoint oldOrigin = rect.origin; - rect.origin.x = round(rect.origin.x - CPTFloat(0.5) ); - rect.size.width = round(oldOrigin.x + rect.size.width - CPTFloat(0.5) ) - rect.origin.x; + rect.origin.x = round(rect.origin.x - CPTFloat(0.5)); + rect.size.width = round(oldOrigin.x + rect.size.width - CPTFloat(0.5)) - rect.origin.x; rect.origin.x += CPTFloat(0.5); - rect.origin.y = ceil(CGRectGetMaxY(rect) ) - CPTFloat(0.5); + rect.origin.y = ceil(CGRectGetMaxY(rect)) - CPTFloat(0.5); rect.size.height = ceil(oldOrigin.y - CPTFloat(0.5) - rect.origin.y); return CGContextConvertRectToUserSpace(context, rect); @@ -949,7 +961,7 @@ CGPoint CPTAlignIntegralPointToUserSpace(__nonnull CGContextRef context, CGPoint point = CGContextConvertPointToDeviceSpace(context, point); point.x = round(point.x); - point.y = ceil(point.y - CPTFloat(0.5) ); + point.y = ceil(point.y - CPTFloat(0.5)); return CGContextConvertPointToUserSpace(context, point); } @@ -973,7 +985,7 @@ CGRect CPTAlignIntegralRectToUserSpace(__nonnull CGContextRef context, CGRect re rect.origin.x = round(rect.origin.x); rect.size.width = round(oldOrigin.x + rect.size.width) - rect.origin.x; - rect.origin.y = ceil(CGRectGetMaxY(rect) - CPTFloat(0.5) ); + rect.origin.y = ceil(CGRectGetMaxY(rect) - CPTFloat(0.5)); rect.size.height = ceil(oldOrigin.y - CPTFloat(0.5) - rect.origin.y); return CGContextConvertRectToUserSpace(context, rect); @@ -984,14 +996,14 @@ CGRect CPTAlignBorderedRectToUserSpace(__nonnull CGContextRef context, CGRect re CGRect borderRect; CGFloat contextScale = CPTFloat(1.0); - if ( rect.size.height != CPTFloat(0.0) ) { + if ( rect.size.height != CPTFloat(0.0)) { CGRect deviceRect = CGContextConvertRectToDeviceSpace(context, rect); contextScale = deviceRect.size.height / rect.size.height; } - if ( contextScale != CPTFloat(1.0) ) { + if ( contextScale != CPTFloat(1.0)) { CGFloat borderWidth = borderLineStyle.lineWidth; - if ( (borderWidth > CPTFloat(0.0) ) && (borderWidth == round(borderWidth) ) ) { + if ((borderWidth > CPTFloat(0.0)) && (borderWidth == round(borderWidth))) { borderRect = CPTAlignIntegralRectToUserSpace(context, rect); } else { @@ -1125,7 +1137,7 @@ BOOL CPTEdgeInsetsEqualToEdgeInsets(CPTEdgeInsets insets1, CPTEdgeInsets insets2 if ( value != 0.0 ) { double sign = (signbit(value) ? -1.0 : +1.0); - return sign * (pow(10.0, fabs(value) ) - 1.0); + return sign * (pow(10.0, fabs(value)) - 1.0); } else { return 0.0; diff --git a/CorePlot/framework/Source/CPTUtilitiesTests.h b/CorePlot/framework/Source/CPTUtilitiesTests.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTUtilitiesTests.m b/CorePlot/framework/Source/CPTUtilitiesTests.m old mode 100755 new mode 100644 index 7d2bf28..c8335a1 --- a/CorePlot/framework/Source/CPTUtilitiesTests.m +++ b/CorePlot/framework/Source/CPTUtilitiesTests.m @@ -50,7 +50,7 @@ -(void)testCPTDecimalIntegerValue XCTAssertEqual(CPTDecimalIntegerValue([d decimalValue]), (NSInteger)42, @"Result incorrect"); d = [NSDecimalNumber decimalNumberWithString:@"42.1"]; - XCTAssertEqual( (NSInteger)CPTDecimalIntegerValue([d decimalValue]), (NSInteger)42, @"Result incorrect" ); + XCTAssertEqual((NSInteger)CPTDecimalIntegerValue([d decimalValue]), (NSInteger)42, @"Result incorrect"); } -(void)testCPTDecimalFloatValue @@ -122,6 +122,91 @@ -(void)testConvertNegativeOne XCTAssertTrue(NSDecimalCompare(&testValue, &negativeOne) == NSOrderedSame, @"%@", errMessage); } +#pragma mark - +#pragma mark Decimal utilities + +-(void)testDecimalMax +{ + NSDecimal zero = CPTDecimalFromInteger(0); + NSDecimal one = CPTDecimalFromInteger(1); + NSDecimal dNAN = CPTDecimalNaN(); + + NSDecimal testValue; + NSString *errMessage; + + testValue = CPTDecimalMin(zero, one); + errMessage = [NSString stringWithFormat:@"test min(0, 1), expected %@", NSDecimalString(&zero, nil)]; + XCTAssertTrue(NSDecimalCompare(&testValue, &zero) == NSOrderedSame, @"%@", errMessage); + + testValue = CPTDecimalMin(one, zero); + errMessage = [NSString stringWithFormat:@"test min(1, 0), expected %@", NSDecimalString(&zero, nil)]; + XCTAssertTrue(NSDecimalCompare(&testValue, &zero) == NSOrderedSame, @"%@", errMessage); + + testValue = CPTDecimalMin(one, dNAN); + errMessage = [NSString stringWithFormat:@"test min(1, NAN), expected %@", NSDecimalString(&one, nil)]; + XCTAssertTrue(NSDecimalCompare(&testValue, &one) == NSOrderedSame, @"%@", errMessage); + + testValue = CPTDecimalMin(dNAN, one); + errMessage = [NSString stringWithFormat:@"test min(NAN, 1), expected %@", NSDecimalString(&one, nil)]; + XCTAssertTrue(NSDecimalCompare(&testValue, &one) == NSOrderedSame, @"%@", errMessage); + + testValue = CPTDecimalMin(dNAN, dNAN); + errMessage = [NSString stringWithFormat:@"test min(NAN, NAN), expected %@", NSDecimalString(&dNAN, nil)]; + XCTAssertTrue(NSDecimalCompare(&testValue, &dNAN) == NSOrderedSame, @"%@", errMessage); +} + +-(void)testDecimalMin +{ + NSDecimal zero = CPTDecimalFromInteger(0); + NSDecimal one = CPTDecimalFromInteger(1); + NSDecimal dNAN = CPTDecimalNaN(); + + NSDecimal testValue; + NSString *errMessage; + + testValue = CPTDecimalMax(zero, one); + errMessage = [NSString stringWithFormat:@"test min(0, 1), expected %@", NSDecimalString(&one, nil)]; + XCTAssertTrue(NSDecimalCompare(&testValue, &one) == NSOrderedSame, @"%@", errMessage); + + testValue = CPTDecimalMax(one, zero); + errMessage = [NSString stringWithFormat:@"test min(1, 0), expected %@", NSDecimalString(&one, nil)]; + XCTAssertTrue(NSDecimalCompare(&testValue, &one) == NSOrderedSame, @"%@", errMessage); + + testValue = CPTDecimalMax(one, dNAN); + errMessage = [NSString stringWithFormat:@"test min(1, NAN), expected %@", NSDecimalString(&one, nil)]; + XCTAssertTrue(NSDecimalCompare(&testValue, &one) == NSOrderedSame, @"%@", errMessage); + + testValue = CPTDecimalMax(dNAN, one); + errMessage = [NSString stringWithFormat:@"test min(NAN, 1), expected %@", NSDecimalString(&one, nil)]; + XCTAssertTrue(NSDecimalCompare(&testValue, &one) == NSOrderedSame, @"%@", errMessage); + + testValue = CPTDecimalMin(dNAN, dNAN); + errMessage = [NSString stringWithFormat:@"test min(NAN, NAN), expected %@", NSDecimalString(&dNAN, nil)]; + XCTAssertTrue(NSDecimalCompare(&testValue, &dNAN) == NSOrderedSame, @"%@", errMessage); +} + +-(void)testDecimalAbs +{ + NSDecimal zero = CPTDecimalFromInteger(0); + NSDecimal one = CPTDecimalFromInteger(1); + NSDecimal negativeOne = CPTDecimalFromInteger(-1); + + NSDecimal testValue; + NSString *errMessage; + + testValue = CPTDecimalAbs(one); + errMessage = [NSString stringWithFormat:@"test value was %@, expected %@", NSDecimalString(&testValue, nil), NSDecimalString(&one, nil)]; + XCTAssertTrue(NSDecimalCompare(&testValue, &one) == NSOrderedSame, @"%@", errMessage); + + testValue = CPTDecimalAbs(zero); + errMessage = [NSString stringWithFormat:@"test value was %@, expected %@", NSDecimalString(&testValue, nil), NSDecimalString(&zero, nil)]; + XCTAssertTrue(NSDecimalCompare(&testValue, &zero) == NSOrderedSame, @"%@", errMessage); + + testValue = CPTDecimalAbs(negativeOne); + errMessage = [NSString stringWithFormat:@"test value was %@, expected %@", NSDecimalString(&testValue, nil), NSDecimalString(&one, nil)]; + XCTAssertTrue(NSDecimalCompare(&testValue, &one) == NSOrderedSame, @"%@", errMessage); +} + #pragma mark - #pragma mark NSDecimalNumber tests @@ -634,11 +719,11 @@ -(void)testInverseLogModulus { XCTAssertEqual(CPTInverseLogModulus(0.0), 0.0, @"CPTInverseLogModulus(0.0)"); - XCTAssertEqualWithAccuracy(CPTInverseLogModulus(log10(11.0) ), 10.0, 1.0e-7, @"CPTInverseLogModulus(log10(11.0))"); - XCTAssertEqualWithAccuracy(CPTInverseLogModulus(-log10(11.0) ), -10.0, 1.0e-7, @"CPTInverseLogModulus(-log10(11.0))"); + XCTAssertEqualWithAccuracy(CPTInverseLogModulus(log10(11.0)), 10.0, 1.0e-7, @"CPTInverseLogModulus(log10(11.0))"); + XCTAssertEqualWithAccuracy(CPTInverseLogModulus(-log10(11.0)), -10.0, 1.0e-7, @"CPTInverseLogModulus(-log10(11.0))"); - XCTAssertEqualWithAccuracy(CPTInverseLogModulus(log10(101.0) ), 100.0, 1.0e-7, @"CPTInverseLogModulus(log10(101.0))"); - XCTAssertEqualWithAccuracy(CPTInverseLogModulus(-log10(101.0) ), -100.0, 1.0e-7, @"CPTInverseLogModulus(-log10(101.0))"); + XCTAssertEqualWithAccuracy(CPTInverseLogModulus(log10(101.0)), 100.0, 1.0e-7, @"CPTInverseLogModulus(log10(101.0))"); + XCTAssertEqualWithAccuracy(CPTInverseLogModulus(-log10(101.0)), -100.0, 1.0e-7, @"CPTInverseLogModulus(-log10(101.0))"); } /// @endcond diff --git a/CorePlot/framework/Source/CPTXYAxis.h b/CorePlot/framework/Source/CPTXYAxis.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTXYAxis.m b/CorePlot/framework/Source/CPTXYAxis.m old mode 100755 new mode 100644 index 42a055c..9b0c117 --- a/CorePlot/framework/Source/CPTXYAxis.m +++ b/CorePlot/framework/Source/CPTXYAxis.m @@ -67,7 +67,7 @@ @implementation CPTXYAxis **/ -(nonnull instancetype)initWithFrame:(CGRect)newFrame { - if ( (self = [super initWithFrame:newFrame]) ) { + if ((self = [super initWithFrame:newFrame])) { orthogonalPosition = @0.0; axisConstraints = nil; self.tickDirection = CPTSignNone; @@ -81,7 +81,7 @@ -(nonnull instancetype)initWithFrame:(CGRect)newFrame -(nonnull instancetype)initWithLayer:(nonnull id)layer { - if ( (self = [super initWithLayer:layer]) ) { + if ((self = [super initWithLayer:layer])) { CPTXYAxis *theLayer = (CPTXYAxis *)layer; orthogonalPosition = theLayer->orthogonalPosition; @@ -107,7 +107,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super initWithCoder:coder]) ) { + if ((self = [super initWithCoder:coder])) { orthogonalPosition = [coder decodeObjectOfClass:[NSNumber class] forKey:@"CPTXYAxis.orthogonalPosition"]; axisConstraints = [coder decodeObjectOfClass:[CPTConstraints class] @@ -205,13 +205,13 @@ -(CGPoint)viewPointForCoordinateValue:(nullable NSNumber *)coordinateValue } } - if ( isnan(point.x) || isnan(point.y) ) { - NSLog(@"[CPTXYAxis viewPointForCoordinateValue:%@] was %@", coordinateValue, CPTStringFromPoint(point) ); + if ( isnan(point.x) || isnan(point.y)) { + NSLog(@"[CPTXYAxis viewPointForCoordinateValue:%@] was %@", coordinateValue, CPTStringFromPoint(point)); - if ( isnan(point.x) ) { + if ( isnan(point.x)) { point.x = CPTFloat(0.0); } - if ( isnan(point.y) ) { + if ( isnan(point.y)) { point.y = CPTFloat(0.0); } } @@ -237,7 +237,7 @@ -(void)drawTicksInContext:(nonnull CGContextRef)context atLocations:(nullable CP CGFloat lineWidth = lineStyle.lineWidth; CPTAlignPointFunction alignmentFunction = NULL; - if ( (self.contentsScale > CPTFloat(1.0) ) && (round(lineWidth) == lineWidth) ) { + if ((self.contentsScale > CPTFloat(1.0)) && (round(lineWidth) == lineWidth)) { alignmentFunction = CPTAlignIntegralPointToUserSpace; } else { @@ -348,7 +348,7 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context CPTAlignPointFunction alignmentFunction = CPTAlignPointToUserSpace; if ( theLineStyle ) { CGFloat lineWidth = theLineStyle.lineWidth; - if ( (self.contentsScale > CPTFloat(1.0) ) && (round(lineWidth) == lineWidth) ) { + if ((self.contentsScale > CPTFloat(1.0)) && (round(lineWidth) == lineWidth)) { alignmentFunction = CPTAlignIntegralPointToUserSpace; } @@ -443,7 +443,7 @@ -(void)drawGridLinesInContext:(nonnull CGContextRef)context isMajor:(BOOL)major CGFloat lineWidth = lineStyle.lineWidth; CPTAlignPointFunction alignmentFunction = NULL; - if ( (self.contentsScale > CPTFloat(1.0) ) && (round(lineWidth) == lineWidth) ) { + if ((self.contentsScale > CPTFloat(1.0)) && (round(lineWidth) == lineWidth)) { alignmentFunction = CPTAlignIntegralPointToUserSpace; } else { @@ -501,7 +501,7 @@ -(NSUInteger)initialBandIndexForSortedLocations:(CPTNumberArray *)sortedLocation NSNumber *bandAnchor = self.alternatingBandAnchor; NSUInteger bandCount = self.alternatingBandFills.count; - if ( bandAnchor && (bandCount > 0) ) { + if ( bandAnchor && (bandCount > 0)) { NSDecimal anchor = bandAnchor.decimalValue; CPTPlotRange *theVisibleRange = self.visibleRange; @@ -552,7 +552,7 @@ -(NSUInteger)initialBandIndexForSortedLocations:(CPTNumberArray *)sortedLocation // user provided tick locations; they're not guaranteed to be evenly spaced, but band drawing always starts with the first location if ( range.lengthDouble >= 0.0 ) { for ( NSNumber *location in sortedLocations ) { - if ( CPTDecimalLessThan(anchor, location.decimalValue) ) { + if ( CPTDecimalLessThan(anchor, location.decimalValue)) { break; } @@ -561,7 +561,7 @@ -(NSUInteger)initialBandIndexForSortedLocations:(CPTNumberArray *)sortedLocation } else { for ( NSNumber *location in sortedLocations ) { - if ( CPTDecimalGreaterThanOrEqualTo(anchor, location.decimalValue) ) { + if ( CPTDecimalGreaterThanOrEqualTo(anchor, location.decimalValue)) { break; } @@ -574,7 +574,7 @@ -(NSUInteger)initialBandIndexForSortedLocations:(CPTNumberArray *)sortedLocation break; } - if ( !CPTDecimalEquals(majorInterval, zero) ) { + if ( !CPTDecimalEquals(majorInterval, zero)) { coord = CPTDecimalDivide(CPTDecimalSubtract(rangeStart, origin), majorInterval); NSDecimalRound(&coord, &coord, 0, NSRoundUp); NSInteger stepCount = CPTDecimalIntegerValue(coord) + CPTDecimalIntegerValue(offset) + 1; @@ -622,7 +622,7 @@ -(void)drawBackgroundBandsInContext:(nonnull CGContextRef)context const NSDecimal zero = CPTDecimalFromInteger(0); NSSortDescriptor *sortDescriptor = nil; if ( range ) { - if ( CPTDecimalGreaterThanOrEqualTo(range.lengthDecimal, zero) ) { + if ( CPTDecimalGreaterThanOrEqualTo(range.lengthDecimal, zero)) { sortDescriptor = [[NSSortDescriptor alloc] initWithKey:nil ascending:YES]; } else { @@ -659,7 +659,7 @@ -(void)drawBackgroundBandsInContext:(nonnull CGContextRef)context for ( NSDecimalNumber *location in locations ) { NSDecimal currentLocation = location.decimalValue; - if ( !CPTDecimalEquals(CPTDecimalSubtract(currentLocation, lastLocation), zero) ) { + if ( !CPTDecimalEquals(CPTDecimalSubtract(currentLocation, lastLocation), zero)) { CPTFill *bandFill = bandArray[bandIndex++]; bandIndex %= bandCount; @@ -676,7 +676,7 @@ -(void)drawBackgroundBandsInContext:(nonnull CGContextRef)context CGRect fillRect = CPTRectMake(MIN(startViewPoint.x, endViewPoint.x), MIN(startViewPoint.y, endViewPoint.y), ABS(endViewPoint.x - startViewPoint.x), - ABS(endViewPoint.y - startViewPoint.y) ); + ABS(endViewPoint.y - startViewPoint.y)); [bandFill fillRect:CPTAlignIntegralRectToUserSpace(context, fillRect) inContext:context]; } } @@ -692,7 +692,7 @@ -(void)drawBackgroundBandsInContext:(nonnull CGContextRef)context else { endLocation = CPTDecimalNaN(); } - if ( !CPTDecimalEquals(lastLocation, endLocation) ) { + if ( !CPTDecimalEquals(lastLocation, endLocation)) { CPTFill *bandFill = bandArray[bandIndex]; if ( bandFill != null ) { @@ -708,7 +708,7 @@ -(void)drawBackgroundBandsInContext:(nonnull CGContextRef)context CGRect fillRect = CPTRectMake(MIN(startViewPoint.x, endViewPoint.x), MIN(startViewPoint.y, endViewPoint.y), ABS(endViewPoint.x - startViewPoint.x), - ABS(endViewPoint.y - startViewPoint.y) ); + ABS(endViewPoint.y - startViewPoint.y)); [bandFill fillRect:CPTAlignIntegralRectToUserSpace(context, fillRect) inContext:context]; } } @@ -766,7 +766,7 @@ -(void)drawBackgroundLimitsInContext:(nonnull CGContextRef)context CGRect fillRect = CPTRectMake(MIN(startViewPoint.x, endViewPoint.x), MIN(startViewPoint.y, endViewPoint.y), ABS(endViewPoint.x - startViewPoint.x), - ABS(endViewPoint.y - startViewPoint.y) ); + ABS(endViewPoint.y - startViewPoint.y)); [bandFill fillRect:CPTAlignIntegralRectToUserSpace(context, fillRect) inContext:context]; } } @@ -824,8 +824,8 @@ -(nonnull NSNumber *)defaultTitleLocation double loc = axisRange.locationDouble; double end = axisRange.endDouble; - if ( (loc > 0.0) && (end >= 0.0) ) { - location = @(pow(10.0, (log10(loc) + log10(end) ) / 2.0) ); + if ((loc > 0.0) && (end >= 0.0)) { + location = @(pow(10.0, (log10(loc) + log10(end)) / 2.0)); } else { location = axisRange.midPoint; @@ -838,7 +838,7 @@ -(nonnull NSNumber *)defaultTitleLocation double loc = axisRange.locationDouble; double end = axisRange.endDouble; - location = @(CPTInverseLogModulus( (CPTLogModulus(loc) + CPTLogModulus(end) ) / 2.0 ) ); + location = @(CPTInverseLogModulus((CPTLogModulus(loc) + CPTLogModulus(end)) / 2.0)); } break; diff --git a/CorePlot/framework/Source/CPTXYAxisSet.h b/CorePlot/framework/Source/CPTXYAxisSet.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTXYAxisSet.m b/CorePlot/framework/Source/CPTXYAxisSet.m old mode 100755 new mode 100644 index 8f14af2..70c48c5 --- a/CorePlot/framework/Source/CPTXYAxisSet.m +++ b/CorePlot/framework/Source/CPTXYAxisSet.m @@ -42,7 +42,7 @@ @implementation CPTXYAxisSet **/ -(nonnull instancetype)initWithFrame:(CGRect)newFrame { - if ( (self = [super initWithFrame:newFrame]) ) { + if ((self = [super initWithFrame:newFrame])) { CPTXYAxis *xAxis = [[CPTXYAxis alloc] initWithFrame:newFrame]; xAxis.coordinate = CPTCoordinateX; xAxis.tickDirection = CPTSignNegative; @@ -80,7 +80,7 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context CGFloat radius = superlayer.cornerRadius; - if ( radius > CPTFloat(0.0) ) { + if ( radius > CPTFloat(0.0)) { CGContextBeginPath(context); CPTAddRoundedRectPath(context, borderRect, radius); diff --git a/CorePlot/framework/Source/CPTXYGraph.h b/CorePlot/framework/Source/CPTXYGraph.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTXYGraph.m b/CorePlot/framework/Source/CPTXYGraph.m old mode 100755 new mode 100644 index 4f4ab0c..480c28b --- a/CorePlot/framework/Source/CPTXYGraph.m +++ b/CorePlot/framework/Source/CPTXYGraph.m @@ -47,7 +47,7 @@ @implementation CPTXYGraph **/ -(nonnull instancetype)initWithFrame:(CGRect)newFrame xScaleType:(CPTScaleType)newXScaleType yScaleType:(CPTScaleType)newYScaleType { - if ( (self = [super initWithFrame:newFrame]) ) { + if ((self = [super initWithFrame:newFrame])) { xScaleType = newXScaleType; yScaleType = newYScaleType; } @@ -78,7 +78,7 @@ -(nonnull instancetype)initWithFrame:(CGRect)newFrame -(nonnull instancetype)initWithLayer:(nonnull id)layer { - if ( (self = [super initWithLayer:layer]) ) { + if ((self = [super initWithLayer:layer])) { CPTXYGraph *theLayer = (CPTXYGraph *)layer; xScaleType = theLayer->xScaleType; @@ -104,7 +104,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super initWithCoder:coder]) ) { + if ((self = [super initWithCoder:coder])) { xScaleType = (CPTScaleType)[coder decodeIntegerForKey:@"CPTXYGraph.xScaleType"]; yScaleType = (CPTScaleType)[coder decodeIntegerForKey:@"CPTXYGraph.yScaleType"]; } diff --git a/CorePlot/framework/Source/CPTXYPlotSpace.h b/CorePlot/framework/Source/CPTXYPlotSpace.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTXYPlotSpace.m b/CorePlot/framework/Source/CPTXYPlotSpace.m old mode 100755 new mode 100644 index c759074..3b27504 --- a/CorePlot/framework/Source/CPTXYPlotSpace.m +++ b/CorePlot/framework/Source/CPTXYPlotSpace.m @@ -198,7 +198,7 @@ @implementation CPTXYPlotSpace **/ -(nonnull instancetype)init { - if ( (self = [super init]) ) { + if ((self = [super init])) { xRange = [[CPTPlotRange alloc] initWithLocation:@0.0 length:@1.0]; yRange = [[CPTPlotRange alloc] initWithLocation:@0.0 length:@1.0]; globalXRange = nil; @@ -241,8 +241,8 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder [coder encodeInteger:self.yScaleType forKey:@"CPTXYPlotSpace.yScaleType"]; [coder encodeBool:self.allowsMomentumX forKey:@"CPTXYPlotSpace.allowsMomentumX"]; [coder encodeBool:self.allowsMomentumY forKey:@"CPTXYPlotSpace.allowsMomentumY"]; - [coder encodeInt:self.momentumAnimationCurve forKey:@"CPTXYPlotSpace.momentumAnimationCurve"]; - [coder encodeInt:self.bounceAnimationCurve forKey:@"CPTXYPlotSpace.bounceAnimationCurve"]; + [coder encodeInteger:self.momentumAnimationCurve forKey:@"CPTXYPlotSpace.momentumAnimationCurve"]; + [coder encodeInteger:self.bounceAnimationCurve forKey:@"CPTXYPlotSpace.bounceAnimationCurve"]; [coder encodeCGFloat:self.momentumAcceleration forKey:@"CPTXYPlotSpace.momentumAcceleration"]; [coder encodeCGFloat:self.bounceAcceleration forKey:@"CPTXYPlotSpace.bounceAcceleration"]; [coder encodeCGFloat:self.minimumDisplacementToDrag forKey:@"CPTXYPlotSpace.minimumDisplacementToDrag"]; @@ -257,7 +257,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super initWithCoder:coder]) ) { + if ((self = [super initWithCoder:coder])) { CPTPlotRange *range = [coder decodeObjectOfClass:[CPTPlotRange class] forKey:@"CPTXYPlotSpace.xRange"]; if ( range ) { @@ -282,8 +282,8 @@ -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder allowsMomentumX = [coder decodeBoolForKey:@"CPTXYPlotSpace.allowsMomentumX"]; allowsMomentumY = [coder decodeBoolForKey:@"CPTXYPlotSpace.allowsMomentumY"]; } - momentumAnimationCurve = (CPTAnimationCurve)[coder decodeIntForKey:@"CPTXYPlotSpace.momentumAnimationCurve"]; - bounceAnimationCurve = (CPTAnimationCurve)[coder decodeIntForKey:@"CPTXYPlotSpace.bounceAnimationCurve"]; + momentumAnimationCurve = (CPTAnimationCurve)[coder decodeIntegerForKey:@"CPTXYPlotSpace.momentumAnimationCurve"]; + bounceAnimationCurve = (CPTAnimationCurve)[coder decodeIntegerForKey:@"CPTXYPlotSpace.bounceAnimationCurve"]; momentumAcceleration = [coder decodeCGFloatForKey:@"CPTXYPlotSpace.momentumAcceleration"]; bounceAcceleration = [coder decodeCGFloatForKey:@"CPTXYPlotSpace.bounceAcceleration"]; minimumDisplacementToDrag = [coder decodeCGFloatForKey:@"CPTXYPlotSpace.minimumDisplacementToDrag"]; @@ -418,14 +418,14 @@ -(void)setXRange:(nonnull CPTPlotRange *)range if ( xRange && constrainedRange ) { isScrolling = !CPTDecimalEquals(constrainedRange.locationDecimal, xRange.locationDecimal) && CPTDecimalEquals(constrainedRange.lengthDecimal, xRange.lengthDecimal); - if ( isScrolling && (displacement == CPTFloat(0.0) ) ) { + if ( isScrolling && (displacement == CPTFloat(0.0))) { CPTGraph *theGraph = self.graph; CPTPlotArea *plotArea = theGraph.plotAreaFrame.plotArea; if ( plotArea ) { NSDecimal rangeLength = constrainedRange.lengthDecimal; - if ( !CPTDecimalEquals(rangeLength, CPTDecimalFromInteger(0) ) ) { + if ( !CPTDecimalEquals(rangeLength, CPTDecimalFromInteger(0))) { NSDecimal diff = CPTDecimalDivide(CPTDecimalSubtract(constrainedRange.locationDecimal, xRange.locationDecimal), rangeLength); displacement = plotArea.bounds.size.width * CPTDecimalCGFloatValue(diff); @@ -482,14 +482,14 @@ -(void)setYRange:(nonnull CPTPlotRange *)range if ( yRange && constrainedRange ) { isScrolling = !CPTDecimalEquals(constrainedRange.locationDecimal, yRange.locationDecimal) && CPTDecimalEquals(constrainedRange.lengthDecimal, yRange.lengthDecimal); - if ( isScrolling && (displacement == CPTFloat(0.0) ) ) { + if ( isScrolling && (displacement == CPTFloat(0.0))) { CPTGraph *theGraph = self.graph; CPTPlotArea *plotArea = theGraph.plotAreaFrame.plotArea; if ( plotArea ) { NSDecimal rangeLength = constrainedRange.lengthDecimal; - if ( !CPTDecimalEquals(rangeLength, CPTDecimalFromInteger(0) ) ) { + if ( !CPTDecimalEquals(rangeLength, CPTDecimalFromInteger(0))) { NSDecimal diff = CPTDecimalDivide(CPTDecimalSubtract(constrainedRange.locationDecimal, yRange.locationDecimal), rangeLength); displacement = plotArea.bounds.size.height * CPTDecimalCGFloatValue(diff); @@ -531,7 +531,7 @@ -(nonnull CPTPlotRange *)constrainRange:(nonnull CPTPlotRange *)existingRange to CPTPlotRange *theGlobalRange = globalRange; - if ( CPTDecimalGreaterThanOrEqualTo(existingRange.lengthDecimal, theGlobalRange.lengthDecimal) ) { + if ( CPTDecimalGreaterThanOrEqualTo(existingRange.lengthDecimal, theGlobalRange.lengthDecimal)) { return [theGlobalRange copy]; } else { @@ -595,8 +595,8 @@ -(void)animateRangeForCoordinate:(CPTCoordinate)coordinate shift:(NSDecimal)shif CPTPlotRange *constrainedRange = [self constrainRange:newRange toGlobalRange:globalRange]; if ( ![newRange isEqualToRange:constrainedRange] && ![globalRange containsRange:newRange] ) { - BOOL direction = (CPTDecimalGreaterThan(shift, zero) && CPTDecimalGreaterThan(oldRange.lengthDecimal, zero) ) || - (CPTDecimalLessThan(shift, zero) && CPTDecimalLessThan(oldRange.lengthDecimal, zero) ); + BOOL direction = (CPTDecimalGreaterThan(shift, zero) && CPTDecimalGreaterThan(oldRange.lengthDecimal, zero)) || + (CPTDecimalLessThan(shift, zero) && CPTDecimalLessThan(oldRange.lengthDecimal, zero)); // decelerate at the global range if ( hasShift ) { @@ -610,11 +610,11 @@ -(void)animateRangeForCoordinate:(CPTCoordinate)coordinate shift:(NSDecimal)shif CGFloat brakingOffset = globalPoint - oldPoint; brakingDelay = CPTFirstPositiveRoot(acceleration, speed, brakingOffset); - if ( !isnan(brakingDelay) ) { + if ( !isnan(brakingDelay)) { speed -= brakingDelay * acceleration; // slow down quickly - while ( momentumTime > CPTFloat(0.1) ) { + while ( momentumTime > CPTFloat(0.1)) { acceleration *= CPTFloat(2.0); momentumTime = speed / (CPTFloat(2.0) * acceleration); } @@ -651,10 +651,10 @@ -(void)animateRangeForCoordinate:(CPTCoordinate)coordinate shift:(NSDecimal)shif brakingDelay = CPTFloat(0.0); // slow down quickly - while ( momentumTime > CPTFloat(0.1) ) { + while ( momentumTime > CPTFloat(0.1)) { momentumTime *= CPTFloat(0.5); - shift = CPTDecimalDivide(shift, CPTDecimalFromInteger(2) ); + shift = CPTDecimalDivide(shift, CPTDecimalFromInteger(2)); } newRange = [oldRange mutableCopy]; @@ -662,7 +662,7 @@ -(void)animateRangeForCoordinate:(CPTCoordinate)coordinate shift:(NSDecimal)shif newRange.locationDecimal = CPTDecimalAdd(newRange.locationDecimal, shift); } - if ( !isnan(brakingDelay) ) { + if ( !isnan(brakingDelay)) { op = [CPTAnimation animate:self property:property fromPlotRange:constrainedRange @@ -736,11 +736,11 @@ CGFloat CPTFirstPositiveRoot(CGFloat a, CGFloat b, CGFloat c) CGFloat root1 = (-b + discriminant) / (CPTFloat(2.0) * a); CGFloat root2 = (-b - discriminant) / (CPTFloat(2.0) * a); - if ( !isnan(root1) && !isnan(root2) ) { - if ( root1 >= CPTFloat(0.0) ) { + if ( !isnan(root1) && !isnan(root2)) { + if ( root1 >= CPTFloat(0.0)) { root = root1; } - if ( (root2 >= CPTFloat(0.0) ) && (isnan(root) || (root2 < root) ) ) { + if ((root2 >= CPTFloat(0.0)) && (isnan(root) || (root2 < root))) { root = root2; } } @@ -789,13 +789,13 @@ -(void)scaleToFitPlots:(nullable CPTPlotArray *)plots // Set range NSDecimal zero = CPTDecimalFromInteger(0); if ( unionXRange ) { - if ( CPTDecimalEquals(unionXRange.lengthDecimal, zero) ) { + if ( CPTDecimalEquals(unionXRange.lengthDecimal, zero)) { [unionXRange unionPlotRange:self.xRange]; } self.xRange = unionXRange; } if ( unionYRange ) { - if ( CPTDecimalEquals(unionYRange.lengthDecimal, zero) ) { + if ( CPTDecimalEquals(unionYRange.lengthDecimal, zero)) { [unionYRange unionPlotRange:self.yRange]; } self.yRange = unionYRange; @@ -827,13 +827,13 @@ -(void)scaleToFitEntirePlots:(nullable CPTPlotArray *)plots // Set range NSDecimal zero = CPTDecimalFromInteger(0); if ( unionXRange ) { - if ( CPTDecimalEquals(unionXRange.lengthDecimal, zero) ) { + if ( CPTDecimalEquals(unionXRange.lengthDecimal, zero)) { [unionXRange unionPlotRange:self.xRange]; } self.xRange = unionXRange; } if ( unionYRange ) { - if ( CPTDecimalEquals(unionYRange.lengthDecimal, zero) ) { + if ( CPTDecimalEquals(unionYRange.lengthDecimal, zero)) { [unionYRange unionPlotRange:self.yRange]; } self.yRange = unionYRange; @@ -891,7 +891,7 @@ -(CGFloat)viewCoordinateForViewLength:(NSDecimal)viewLength linearPlotRange:(non } NSDecimal factor = CPTDecimalDivide(CPTDecimalSubtract(plotCoord, range.locationDecimal), range.lengthDecimal); - if ( NSDecimalIsNotANumber(&factor) ) { + if ( NSDecimalIsNotANumber(&factor)) { factor = CPTDecimalFromInteger(0); } @@ -902,17 +902,17 @@ -(CGFloat)viewCoordinateForViewLength:(NSDecimal)viewLength linearPlotRange:(non -(CGFloat)viewCoordinateForViewLength:(CGFloat)viewLength linearPlotRange:(nonnull CPTPlotRange *)range doublePrecisionPlotCoordinateValue:(double)plotCoord { - if ( !range || (range.lengthDouble == 0.0) ) { + if ( !range || (range.lengthDouble == 0.0)) { return CPTFloat(0.0); } - return viewLength * (CGFloat)( (plotCoord - range.locationDouble) / range.lengthDouble ); + return viewLength * (CGFloat)((plotCoord - range.locationDouble) / range.lengthDouble); } -(NSDecimal)plotCoordinateForViewLength:(NSDecimal)viewLength linearPlotRange:(nonnull CPTPlotRange *)range boundsLength:(NSDecimal)boundsLength { const NSDecimal zero = CPTDecimalFromInteger(0); - if ( CPTDecimalEquals(boundsLength, zero) ) { + if ( CPTDecimalEquals(boundsLength, zero)) { return zero; } @@ -929,7 +929,7 @@ -(NSDecimal)plotCoordinateForViewLength:(NSDecimal)viewLength linearPlotRange:(n -(double)doublePrecisionPlotCoordinateForViewLength:(CGFloat)viewLength linearPlotRange:(nonnull CPTPlotRange *)range boundsLength:(CGFloat)boundsLength { - if ( boundsLength == CPTFloat(0.0) ) { + if ( boundsLength == CPTFloat(0.0)) { return 0.0; } @@ -943,7 +943,7 @@ -(double)doublePrecisionPlotCoordinateForViewLength:(CGFloat)viewLength linearPl // Log (only one version since there are no transcendental functions for NSDecimal) -(CGFloat)viewCoordinateForViewLength:(CGFloat)viewLength logPlotRange:(nonnull CPTPlotRange *)range doublePrecisionPlotCoordinateValue:(double)plotCoord { - if ( (range.minLimitDouble <= 0.0) || (range.maxLimitDouble <= 0.0) || (plotCoord <= 0.0) ) { + if ((range.minLimitDouble <= 0.0) || (range.maxLimitDouble <= 0.0) || (plotCoord <= 0.0)) { return CPTFloat(0.0); } @@ -951,12 +951,12 @@ -(CGFloat)viewCoordinateForViewLength:(CGFloat)viewLength logPlotRange:(nonnull double logCoord = log10(plotCoord); double logEnd = log10(range.endDouble); - return viewLength * (CGFloat)( (logCoord - logLoc) / (logEnd - logLoc) ); + return viewLength * (CGFloat)((logCoord - logLoc) / (logEnd - logLoc)); } -(double)doublePrecisionPlotCoordinateForViewLength:(CGFloat)viewLength logPlotRange:(nonnull CPTPlotRange *)range boundsLength:(CGFloat)boundsLength { - if ( boundsLength == CPTFloat(0.0) ) { + if ( boundsLength == CPTFloat(0.0)) { return 0.0; } @@ -979,12 +979,12 @@ -(CGFloat)viewCoordinateForViewLength:(CGFloat)viewLength logModulusPlotRange:(n double logCoord = CPTLogModulus(plotCoord); double logEnd = CPTLogModulus(range.endDouble); - return viewLength * (CGFloat)( (logCoord - logLoc) / (logEnd - logLoc) ); + return viewLength * (CGFloat)((logCoord - logLoc) / (logEnd - logLoc)); } -(double)doublePrecisionPlotCoordinateForViewLength:(CGFloat)viewLength logModulusPlotRange:(nonnull CPTPlotRange *)range boundsLength:(CGFloat)boundsLength { - if ( boundsLength == CPTFloat(0.0) ) { + if ( boundsLength == CPTFloat(0.0)) { return 0.0; } @@ -1418,7 +1418,7 @@ -(void)scaleBy:(CGFloat)interactionScale aboutPoint:(CGPoint)plotAreaPoint CPTGraph *theGraph = self.graph; CPTPlotArea *plotArea = theGraph.plotAreaFrame.plotArea; - if ( !plotArea || (interactionScale <= CPTFloat(1.e-6) ) ) { + if ( !plotArea || (interactionScale <= CPTFloat(1.e-6))) { return; } if ( ![plotArea containsPoint:plotAreaPoint] ) { @@ -1451,7 +1451,7 @@ -(void)scaleBy:(CGFloat)interactionScale aboutPoint:(CGPoint)plotAreaPoint // New locations NSDecimal newLocationX; - if ( CPTDecimalGreaterThanOrEqualTo(oldRangeX.lengthDecimal, CPTDecimalFromInteger(0) ) ) { + if ( CPTDecimalGreaterThanOrEqualTo(oldRangeX.lengthDecimal, CPTDecimalFromInteger(0))) { NSDecimal oldFirstLengthX = CPTDecimalSubtract(plotInteractionPoint[CPTCoordinateX], oldRangeX.minLimitDecimal); // x - minX NSDecimal newFirstLengthX = CPTDecimalDivide(oldFirstLengthX, decimalScale); // (x - minX) / scale newLocationX = CPTDecimalSubtract(plotInteractionPoint[CPTCoordinateX], newFirstLengthX); @@ -1463,7 +1463,7 @@ -(void)scaleBy:(CGFloat)interactionScale aboutPoint:(CGPoint)plotAreaPoint } NSDecimal newLocationY; - if ( CPTDecimalGreaterThanOrEqualTo(oldRangeY.lengthDecimal, CPTDecimalFromInteger(0) ) ) { + if ( CPTDecimalGreaterThanOrEqualTo(oldRangeY.lengthDecimal, CPTDecimalFromInteger(0))) { NSDecimal oldFirstLengthY = CPTDecimalSubtract(plotInteractionPoint[CPTCoordinateY], oldRangeY.minLimitDecimal); // y - minY NSDecimal newFirstLengthY = CPTDecimalDivide(oldFirstLengthY, decimalScale); // (y - minY) / scale newLocationY = CPTDecimalSubtract(plotInteractionPoint[CPTCoordinateY], newFirstLengthY); @@ -1601,7 +1601,7 @@ -(BOOL)pointingDeviceUpEvent:(nonnull CPTNativeEvent *)event atPoint:(CGPoint)in NSTimeInterval deltaT = event.timestamp - self.lastDragTime; NSTimeInterval lastDeltaT = self.lastDeltaTime; - if ( (deltaT > 0.0) && (deltaT < 0.05) && (lastDeltaT > 0.0) ) { + if ((deltaT > 0.0) && (deltaT < 0.05) && (lastDeltaT > 0.0)) { CGPoint pointInPlotArea = [theGraph convertPoint:interactionPoint toLayer:plotArea]; CGPoint displacement = self.lastDisplacement; @@ -1609,7 +1609,7 @@ -(BOOL)pointingDeviceUpEvent:(nonnull CPTNativeEvent *)event atPoint:(CGPoint)in speed = sqrt(displacement.x * displacement.x + displacement.y * displacement.y) / CPTFloat(lastDeltaT); momentumTime = speed / (CPTFloat(2.0) * acceleration); CGFloat distanceTraveled = speed * momentumTime - CPTFloat(0.5) * acceleration * momentumTime * momentumTime; - distanceTraveled = MAX(distanceTraveled, CPTFloat(0.0) ); + distanceTraveled = MAX(distanceTraveled, CPTFloat(0.0)); CGFloat theta = atan2(displacement.y, displacement.x); scaleX = cos(theta); @@ -1755,13 +1755,13 @@ -(nullable CPTPlotRange *)shiftRange:(nonnull CPTPlotRange *)oldRange by:(NSDeci // reduce the shift as we get farther outside the global range NSDecimal rangeLength = newRange.lengthDecimal; - if ( !CPTDecimalEquals(rangeLength, CPTDecimalFromInteger(0) ) ) { + if ( !CPTDecimalEquals(rangeLength, CPTDecimalFromInteger(0))) { NSDecimal diff = CPTDecimalDivide(CPTDecimalSubtract(constrainedRange.locationDecimal, newRange.locationDecimal), rangeLength); - diff = CPTDecimalMax(CPTDecimalMin(CPTDecimalMultiply(diff, CPTDecimalFromDouble(2.5) ), CPTDecimalFromInteger(1) ), CPTDecimalFromInteger(-1) ); + diff = CPTDecimalMax(CPTDecimalMin(CPTDecimalMultiply(diff, CPTDecimalFromDouble(2.5)), CPTDecimalFromInteger(1)), CPTDecimalFromInteger(-1)); - newRange.locationDecimal = CPTDecimalSubtract(newRange.locationDecimal, CPTDecimalMultiply(shift, CPTDecimalAbs(diff) ) ); + newRange.locationDecimal = CPTDecimalSubtract(newRange.locationDecimal, CPTDecimalMultiply(shift, CPTDecimalAbs(diff))); - *displacement = *displacement * (CPTFloat(1.0) - ABS(CPTDecimalCGFloatValue(diff) ) ); + *displacement = *displacement * (CPTFloat(1.0) - ABS(CPTDecimalCGFloatValue(diff))); } } } diff --git a/CorePlot/framework/Source/CPTXYPlotSpaceTests.h b/CorePlot/framework/Source/CPTXYPlotSpaceTests.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/CPTXYPlotSpaceTests.m b/CorePlot/framework/Source/CPTXYPlotSpaceTests.m old mode 100755 new mode 100644 index ec2a206..888b604 --- a/CorePlot/framework/Source/CPTXYPlotSpaceTests.m +++ b/CorePlot/framework/Source/CPTXYPlotSpaceTests.m @@ -146,7 +146,7 @@ -(void)testViewPointForPlotPointArrayLog plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:@1.0 length:@9.0]; - CPTNumberArray *plotPoint = @[@(sqrt(10.0) ), @(sqrt(10.0) )]; + CPTNumberArray *plotPoint = @[@(sqrt(10.0)), @(sqrt(10.0))]; CGPoint viewPoint = [plotSpace plotAreaViewPointForPlotPoint:plotPoint]; @@ -177,8 +177,8 @@ -(void)testViewPointForPlotPointLog length:@9.0]; NSDecimal plotPoint[2]; - plotPoint[CPTCoordinateX] = CPTDecimalFromDouble(sqrt(10.0) ); - plotPoint[CPTCoordinateY] = CPTDecimalFromDouble(sqrt(10.0) ); + plotPoint[CPTCoordinateX] = CPTDecimalFromDouble(sqrt(10.0)); + plotPoint[CPTCoordinateY] = CPTDecimalFromDouble(sqrt(10.0)); CGPoint viewPoint = [plotSpace plotAreaViewPointForPlotPoint:plotPoint numberOfCoordinates:2]; @@ -315,9 +315,9 @@ -(void)testPlotPointArrayForViewPointLinear NSString *errMessage; errMessage = [NSString stringWithFormat:@"plotPoint[CPTCoordinateX] was %@", plotPoint[CPTCoordinateX]]; - XCTAssertTrue(CPTDecimalEquals([plotPoint[CPTCoordinateX] decimalValue], CPTDecimalFromDouble(5.0) ), @"%@", errMessage); + XCTAssertTrue(CPTDecimalEquals([plotPoint[CPTCoordinateX] decimalValue], CPTDecimalFromDouble(5.0)), @"%@", errMessage); errMessage = [NSString stringWithFormat:@"plotPoint[CPTCoordinateY] was %@", plotPoint[CPTCoordinateY]]; - XCTAssertTrue(CPTDecimalEquals([plotPoint[CPTCoordinateY] decimalValue], CPTDecimalFromDouble(5.0) ), @"%@", errMessage); + XCTAssertTrue(CPTDecimalEquals([plotPoint[CPTCoordinateY] decimalValue], CPTDecimalFromDouble(5.0)), @"%@", errMessage); } -(void)testPlotPointForViewPointLinear @@ -339,9 +339,9 @@ -(void)testPlotPointForViewPointLinear [plotSpace plotPoint:plotPoint numberOfCoordinates:2 forPlotAreaViewPoint:viewPoint]; errMessage = [NSString stringWithFormat:@"plotPoint[CPTCoordinateX] was %@", NSDecimalString(&plotPoint[CPTCoordinateX], nil)]; - XCTAssertTrue(CPTDecimalEquals(plotPoint[CPTCoordinateX], CPTDecimalFromDouble(5.0) ), @"%@", errMessage); + XCTAssertTrue(CPTDecimalEquals(plotPoint[CPTCoordinateX], CPTDecimalFromDouble(5.0)), @"%@", errMessage); errMessage = [NSString stringWithFormat:@"plotPoint[CPTCoordinateY] was %@", NSDecimalString(&plotPoint[CPTCoordinateY], nil)]; - XCTAssertTrue(CPTDecimalEquals(plotPoint[CPTCoordinateY], CPTDecimalFromDouble(5.0) ), @"%@", errMessage); + XCTAssertTrue(CPTDecimalEquals(plotPoint[CPTCoordinateY], CPTDecimalFromDouble(5.0)), @"%@", errMessage); } -(void)testDoublePrecisionPlotPointForViewPointLinear @@ -414,9 +414,9 @@ -(void)testPlotPointForViewPointLog [plotSpace plotPoint:plotPoint numberOfCoordinates:2 forPlotAreaViewPoint:viewPoint]; errMessage = [NSString stringWithFormat:@"plotPoint[CPTCoordinateX] was %@", NSDecimalString(&plotPoint[CPTCoordinateX], nil)]; - XCTAssertTrue(CPTDecimalEquals(plotPoint[CPTCoordinateX], CPTDecimalFromDouble(sqrt(10.0) ) ), @"%@", errMessage); + XCTAssertTrue(CPTDecimalEquals(plotPoint[CPTCoordinateX], CPTDecimalFromDouble(sqrt(10.0))), @"%@", errMessage); errMessage = [NSString stringWithFormat:@"plotPoint[CPTCoordinateY] was %@", NSDecimalString(&plotPoint[CPTCoordinateY], nil)]; - XCTAssertTrue(CPTDecimalEquals(plotPoint[CPTCoordinateY], CPTDecimalFromDouble(sqrt(10.0) ) ), @"%@", errMessage); + XCTAssertTrue(CPTDecimalEquals(plotPoint[CPTCoordinateY], CPTDecimalFromDouble(sqrt(10.0))), @"%@", errMessage); } -(void)testDoublePrecisionPlotPointForViewPointLog @@ -489,9 +489,9 @@ -(void)testPlotPointForViewPointLogModulus [plotSpace plotPoint:plotPoint numberOfCoordinates:2 forPlotAreaViewPoint:viewPoint]; errMessage = [NSString stringWithFormat:@"plotPoint[CPTCoordinateX] was %@", NSDecimalString(&plotPoint[CPTCoordinateX], nil)]; - XCTAssertTrue(CPTDecimalEquals(plotPoint[CPTCoordinateX], CPTDecimalFromInteger(0) ), @"%@", errMessage); + XCTAssertTrue(CPTDecimalEquals(plotPoint[CPTCoordinateX], CPTDecimalFromInteger(0)), @"%@", errMessage); errMessage = [NSString stringWithFormat:@"plotPoint[CPTCoordinateY] was %@", NSDecimalString(&plotPoint[CPTCoordinateY], nil)]; - XCTAssertTrue(CPTDecimalEquals(plotPoint[CPTCoordinateY], CPTDecimalFromInteger(0) ), @"%@", errMessage); + XCTAssertTrue(CPTDecimalEquals(plotPoint[CPTCoordinateY], CPTDecimalFromInteger(0)), @"%@", errMessage); } -(void)testDoublePrecisionPlotPointForViewPointLogModulus @@ -610,7 +610,7 @@ -(void)testScaleByAboutPoint1 CGRect myBounds = self.graph.bounds; - [plotSpace scaleBy:0.5 aboutPoint:CGPointMake(CGRectGetMidX(myBounds), CGRectGetMidY(myBounds) )]; + [plotSpace scaleBy:0.5 aboutPoint:CGPointMake(CGRectGetMidX(myBounds), CGRectGetMidY(myBounds))]; CPTPlotRange *expectedRangeX = [CPTPlotRange plotRangeWithLocation:@(-5.0) length:@20.0]; @@ -637,7 +637,7 @@ -(void)testScaleByAboutPoint2 CGRect myBounds = self.graph.bounds; - [plotSpace scaleBy:2.0 aboutPoint:CGPointMake(CGRectGetMidX(myBounds), CGRectGetMidY(myBounds) )]; + [plotSpace scaleBy:2.0 aboutPoint:CGPointMake(CGRectGetMidX(myBounds), CGRectGetMidY(myBounds))]; CPTPlotRange *expectedRangeX = [CPTPlotRange plotRangeWithLocation:@2.5 length:@5.0]; diff --git a/CorePlot/framework/Source/NSCoderExtensions.h b/CorePlot/framework/Source/NSCoderExtensions.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/NSCoderExtensions.m b/CorePlot/framework/Source/NSCoderExtensions.m old mode 100755 new mode 100644 index 844089a..6884d24 --- a/CorePlot/framework/Source/NSCoderExtensions.m +++ b/CorePlot/framework/Source/NSCoderExtensions.m @@ -78,7 +78,16 @@ -(void)encodeCGColorSpace:(nullable CGColorSpaceRef)colorSpace forKey:(nonnull N NSLog(@"Color space encoding is not supported on iOS. Decoding will return a generic RGB color space."); #else if ( colorSpace ) { - CFDataRef iccProfile = CGColorSpaceCopyICCProfile(colorSpace); + CFDataRef iccProfile = NULL; + + // CGColorSpaceCopyICCProfile() is deprecated as of macOS 10.13 + if ( CGColorSpaceCopyICCData ) { + iccProfile = CGColorSpaceCopyICCData(colorSpace); + } + else { + iccProfile = CGColorSpaceCopyICCProfile(colorSpace); + } + [self encodeObject:(__bridge NSData *)iccProfile forKey:key]; CFRelease(iccProfile); } @@ -228,7 +237,7 @@ -(void)encodeCGImage:(nullable CGImageRef)image forKey:(nonnull NSString *)key [self encodeBool:CGImageGetShouldInterpolate(image) forKey:newKey]; newKey = [[NSString alloc] initWithFormat:@"%@.renderingIntent", key]; - [self encodeInt:CGImageGetRenderingIntent(image) forKey:newKey]; + [self encodeInt32:CGImageGetRenderingIntent(image) forKey:newKey]; } /** @brief Encodes an @ref NSDecimal and associates it with the string @par{key}. @@ -336,7 +345,13 @@ -(nullable CGColorSpaceRef)newCGColorSpaceDecodeForKey:(nonnull NSString *)key NSData *iccProfile = [self decodeObjectOfClass:[NSData class] forKey:key]; if ( iccProfile ) { - colorSpace = CGColorSpaceCreateWithICCProfile( (__bridge CFDataRef)iccProfile ); + // CGColorSpaceCreateWithICCProfile() is deprecated as of macOS 10.13 + if ( CGColorSpaceCreateWithICCData ) { + colorSpace = CGColorSpaceCreateWithICCData((__bridge CFDataRef)iccProfile); + } + else { + colorSpace = CGColorSpaceCreateWithICCProfile((__bridge CFDataRef)iccProfile); + } } else { NSLog(@"Color space not available for key '%@'. Using generic RGB color space.", key); @@ -446,15 +461,15 @@ -(nullable CGImageRef)newCGImageDecodeForKey:(nonnull NSString *)key const CGBitmapInfo *bitmapInfo = (const void *)[self decodeBytesForKey:newKey returnedLength:&length]; newKey = [[NSString alloc] initWithFormat:@"%@.provider", key]; - CGDataProviderRef provider = CGDataProviderCreateWithCFData( (__bridge CFDataRef)[self decodeObjectOfClass:[NSData class] - forKey:newKey] ); + CGDataProviderRef provider = CGDataProviderCreateWithCFData((__bridge CFDataRef)[self decodeObjectOfClass:[NSData class] + forKey:newKey]); newKey = [[NSString alloc] initWithFormat:@"%@.numberOfComponents", key]; size_t numberOfComponents = (size_t)[self decodeInt64ForKey:newKey]; CGFloat *decodeArray = NULL; if ( numberOfComponents ) { - decodeArray = calloc( (numberOfComponents * 2), sizeof(CGFloat) ); + decodeArray = calloc((numberOfComponents * 2), sizeof(CGFloat)); for ( size_t i = 0; i < numberOfComponents; i++ ) { newKey = [[NSString alloc] initWithFormat:@"%@.decode[%zu].lower", key, i]; @@ -469,7 +484,7 @@ -(nullable CGImageRef)newCGImageDecodeForKey:(nonnull NSString *)key bool shouldInterpolate = [self decodeBoolForKey:newKey]; newKey = [[NSString alloc] initWithFormat:@"%@.renderingIntent", key]; - CGColorRenderingIntent intent = (CGColorRenderingIntent)[self decodeIntForKey:newKey]; + CGColorRenderingIntent intent = (CGColorRenderingIntent)[self decodeInt32ForKey:newKey]; CGImageRef newImage = CGImageCreate(width, height, diff --git a/CorePlot/framework/Source/NSDecimalNumberExtensions.h b/CorePlot/framework/Source/NSDecimalNumberExtensions.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/NSDecimalNumberExtensions.m b/CorePlot/framework/Source/NSDecimalNumberExtensions.m old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/NSNumberExtensions.h b/CorePlot/framework/Source/NSNumberExtensions.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/NSNumberExtensions.m b/CorePlot/framework/Source/NSNumberExtensions.m old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/_CPTAnimationCGFloatPeriod.h b/CorePlot/framework/Source/_CPTAnimationCGFloatPeriod.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/_CPTAnimationCGFloatPeriod.m b/CorePlot/framework/Source/_CPTAnimationCGFloatPeriod.m old mode 100755 new mode 100644 index bab4e9e..1bcf82c --- a/CorePlot/framework/Source/_CPTAnimationCGFloatPeriod.m +++ b/CorePlot/framework/Source/_CPTAnimationCGFloatPeriod.m @@ -31,7 +31,7 @@ CGFloat CPTCurrentFloatValue(id __nonnull boundObject, SEL __nonnull boundGetter -(void)setStartValueFromObject:(nonnull id)boundObject propertyGetter:(nonnull SEL)boundGetter { - self.startValue = @(CPTCurrentFloatValue(boundObject, boundGetter) ); + self.startValue = @(CPTCurrentFloatValue(boundObject, boundGetter)); } -(BOOL)canStartWithValueFromObject:(nonnull id)boundObject propertyGetter:(nonnull SEL)boundGetter @@ -47,7 +47,7 @@ -(BOOL)canStartWithValueFromObject:(nonnull id)boundObject propertyGetter:(nonnu [self.startValue getValue:&start]; [self.endValue getValue:&end]; - return ( (current >= start) && (current <= end) ) || ( (current >= end) && (current <= start) ); + return ((current >= start) && (current <= end)) || ((current >= end) && (current <= start)); } -(nonnull NSValue *)tweenedValueForProgress:(CGFloat)progress diff --git a/CorePlot/framework/Source/_CPTAnimationCGPointPeriod.h b/CorePlot/framework/Source/_CPTAnimationCGPointPeriod.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/_CPTAnimationCGPointPeriod.m b/CorePlot/framework/Source/_CPTAnimationCGPointPeriod.m old mode 100755 new mode 100644 index 62a8255..bb62463 --- a/CorePlot/framework/Source/_CPTAnimationCGPointPeriod.m +++ b/CorePlot/framework/Source/_CPTAnimationCGPointPeriod.m @@ -47,8 +47,8 @@ -(BOOL)canStartWithValueFromObject:(nonnull id)boundObject propertyGetter:(nonnu [self.startValue getValue:&start]; [self.endValue getValue:&end]; - return ( ( (current.x >= start.x) && (current.x <= end.x) ) || ( (current.x >= end.x) && (current.x <= start.x) ) ) && - ( ( (current.y >= start.y) && (current.y <= end.y) ) || ( (current.y >= end.y) && (current.y <= start.y) ) ); + return (((current.x >= start.x) && (current.x <= end.x)) || ((current.x >= end.x) && (current.x <= start.x))) && + (((current.y >= start.y) && (current.y <= end.y)) || ((current.y >= end.y) && (current.y <= start.y))); } -(nonnull NSValue *)tweenedValueForProgress:(CGFloat)progress diff --git a/CorePlot/framework/Source/_CPTAnimationCGRectPeriod.h b/CorePlot/framework/Source/_CPTAnimationCGRectPeriod.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/_CPTAnimationCGRectPeriod.m b/CorePlot/framework/Source/_CPTAnimationCGRectPeriod.m old mode 100755 new mode 100644 index 2ab3fde..1e05bf9 --- a/CorePlot/framework/Source/_CPTAnimationCGRectPeriod.m +++ b/CorePlot/framework/Source/_CPTAnimationCGRectPeriod.m @@ -47,10 +47,10 @@ -(BOOL)canStartWithValueFromObject:(nonnull id)boundObject propertyGetter:(nonnu [self.startValue getValue:&start]; [self.endValue getValue:&end]; - return ( ( (current.origin.x >= start.origin.x) && (current.origin.x <= end.origin.x) ) || ( (current.origin.x >= end.origin.x) && (current.origin.x <= start.origin.x) ) ) && - ( ( (current.origin.y >= start.origin.y) && (current.origin.y <= end.origin.y) ) || ( (current.origin.y >= end.origin.y) && (current.origin.y <= start.origin.y) ) ) && - ( ( (current.size.width >= start.size.width) && (current.size.width <= end.size.width) ) || ( (current.size.width >= end.size.width) && (current.size.width <= start.size.width) ) ) && - ( ( (current.size.height >= start.size.height) && (current.size.height <= end.size.height) ) || ( (current.size.height >= end.size.height) && (current.size.height <= start.size.height) ) ); + return (((current.origin.x >= start.origin.x) && (current.origin.x <= end.origin.x)) || ((current.origin.x >= end.origin.x) && (current.origin.x <= start.origin.x))) && + (((current.origin.y >= start.origin.y) && (current.origin.y <= end.origin.y)) || ((current.origin.y >= end.origin.y) && (current.origin.y <= start.origin.y))) && + (((current.size.width >= start.size.width) && (current.size.width <= end.size.width)) || ((current.size.width >= end.size.width) && (current.size.width <= start.size.width))) && + (((current.size.height >= start.size.height) && (current.size.height <= end.size.height)) || ((current.size.height >= end.size.height) && (current.size.height <= start.size.height))); } -(nonnull NSValue *)tweenedValueForProgress:(CGFloat)progress diff --git a/CorePlot/framework/Source/_CPTAnimationCGSizePeriod.h b/CorePlot/framework/Source/_CPTAnimationCGSizePeriod.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/_CPTAnimationCGSizePeriod.m b/CorePlot/framework/Source/_CPTAnimationCGSizePeriod.m old mode 100755 new mode 100644 index 89499b6..e0b54f4 --- a/CorePlot/framework/Source/_CPTAnimationCGSizePeriod.m +++ b/CorePlot/framework/Source/_CPTAnimationCGSizePeriod.m @@ -47,8 +47,8 @@ -(BOOL)canStartWithValueFromObject:(nonnull id)boundObject propertyGetter:(nonnu [self.startValue getValue:&start]; [self.endValue getValue:&end]; - return ( ( (current.width >= start.width) && (current.width <= end.width) ) || ( (current.width >= end.width) && (current.width <= start.width) ) ) && - ( ( (current.height >= start.height) && (current.height <= end.height) ) || ( (current.height >= end.height) && (current.height <= start.height) ) ); + return (((current.width >= start.width) && (current.width <= end.width)) || ((current.width >= end.width) && (current.width <= start.width))) && + (((current.height >= start.height) && (current.height <= end.height)) || ((current.height >= end.height) && (current.height <= start.height))); } -(nonnull NSValue *)tweenedValueForProgress:(CGFloat)progress diff --git a/CorePlot/framework/Source/_CPTAnimationNSDecimalPeriod.h b/CorePlot/framework/Source/_CPTAnimationNSDecimalPeriod.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/_CPTAnimationNSDecimalPeriod.m b/CorePlot/framework/Source/_CPTAnimationNSDecimalPeriod.m old mode 100755 new mode 100644 index 78541ab..bcf36e6 --- a/CorePlot/framework/Source/_CPTAnimationNSDecimalPeriod.m +++ b/CorePlot/framework/Source/_CPTAnimationNSDecimalPeriod.m @@ -43,20 +43,20 @@ -(BOOL)canStartWithValueFromObject:(nonnull id)boundObject propertyGetter:(nonnu } NSDecimal current = CPTCurrentDecimalValue(boundObject, boundGetter); - NSDecimal start = ( (NSDecimalNumber *)self.startValue ).decimalValue; - NSDecimal end = ( (NSDecimalNumber *)self.endValue ).decimalValue; + NSDecimal start = ((NSDecimalNumber *)self.startValue).decimalValue; + NSDecimal end = ((NSDecimalNumber *)self.endValue).decimalValue; - return (CPTDecimalGreaterThanOrEqualTo(current, start) && CPTDecimalLessThanOrEqualTo(current, end) ) || - (CPTDecimalGreaterThanOrEqualTo(current, end) && CPTDecimalLessThanOrEqualTo(current, start) ); + return (CPTDecimalGreaterThanOrEqualTo(current, start) && CPTDecimalLessThanOrEqualTo(current, end)) || + (CPTDecimalGreaterThanOrEqualTo(current, end) && CPTDecimalLessThanOrEqualTo(current, start)); } -(nonnull NSValue *)tweenedValueForProgress:(CGFloat)progress { - NSDecimal start = ( (NSDecimalNumber *)self.startValue ).decimalValue; - NSDecimal end = ( (NSDecimalNumber *)self.endValue ).decimalValue; + NSDecimal start = ((NSDecimalNumber *)self.startValue).decimalValue; + NSDecimal end = ((NSDecimalNumber *)self.endValue).decimalValue; NSDecimal length = CPTDecimalSubtract(end, start); - NSDecimal tweenedValue = CPTDecimalAdd(start, CPTDecimalMultiply(CPTDecimalFromCGFloat(progress), length) ); + NSDecimal tweenedValue = CPTDecimalAdd(start, CPTDecimalMultiply(CPTDecimalFromCGFloat(progress), length)); return [NSDecimalNumber decimalNumberWithDecimal:tweenedValue]; } diff --git a/CorePlot/framework/Source/_CPTAnimationNSNumberPeriod.h b/CorePlot/framework/Source/_CPTAnimationNSNumberPeriod.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/_CPTAnimationNSNumberPeriod.m b/CorePlot/framework/Source/_CPTAnimationNSNumberPeriod.m old mode 100755 new mode 100644 index 75f437b..e4692f0 --- a/CorePlot/framework/Source/_CPTAnimationNSNumberPeriod.m +++ b/CorePlot/framework/Source/_CPTAnimationNSNumberPeriod.m @@ -32,16 +32,16 @@ -(BOOL)canStartWithValueFromObject:(id)boundObject propertyGetter:(SEL)boundGett NSDecimal startDecimal = start.decimalValue; NSDecimal endDecimal = end.decimalValue; - return (CPTDecimalGreaterThanOrEqualTo(currentDecimal, startDecimal) && CPTDecimalLessThanOrEqualTo(currentDecimal, endDecimal) ) || - (CPTDecimalGreaterThanOrEqualTo(currentDecimal, endDecimal) && CPTDecimalLessThanOrEqualTo(currentDecimal, startDecimal) ); + return (CPTDecimalGreaterThanOrEqualTo(currentDecimal, startDecimal) && CPTDecimalLessThanOrEqualTo(currentDecimal, endDecimal)) || + (CPTDecimalGreaterThanOrEqualTo(currentDecimal, endDecimal) && CPTDecimalLessThanOrEqualTo(currentDecimal, startDecimal)); } else { double currentDouble = current.doubleValue; double startDouble = start.doubleValue; double endDouble = end.doubleValue; - return ( (currentDouble >= startDouble) && (currentDouble <= endDouble) ) || - ( (currentDouble >= endDouble) && (currentDouble <= startDouble) ); + return ((currentDouble >= startDouble) && (currentDouble <= endDouble)) || + ((currentDouble >= endDouble) && (currentDouble <= startDouble)); } } @@ -57,7 +57,7 @@ -(NSValue *)tweenedValueForProgress:(CGFloat)progress NSDecimal endDecimal = end.decimalValue; NSDecimal length = CPTDecimalSubtract(endDecimal, startDecimal); - NSDecimal tweenedValue = CPTDecimalAdd(startDecimal, CPTDecimalMultiply(CPTDecimalFromCGFloat(progress), length) ); + NSDecimal tweenedValue = CPTDecimalAdd(startDecimal, CPTDecimalMultiply(CPTDecimalFromCGFloat(progress), length)); return [NSDecimalNumber decimalNumberWithDecimal:tweenedValue]; } diff --git a/CorePlot/framework/Source/_CPTAnimationPlotRangePeriod.h b/CorePlot/framework/Source/_CPTAnimationPlotRangePeriod.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/_CPTAnimationPlotRangePeriod.m b/CorePlot/framework/Source/_CPTAnimationPlotRangePeriod.m old mode 100755 new mode 100644 index 4bcf492..857d655 --- a/CorePlot/framework/Source/_CPTAnimationPlotRangePeriod.m +++ b/CorePlot/framework/Source/_CPTAnimationPlotRangePeriod.m @@ -30,8 +30,8 @@ -(BOOL)canStartWithValueFromObject:(nonnull id)boundObject propertyGetter:(nonnu NSDecimal startLoc = start.locationDecimal; NSDecimal endLoc = end.locationDecimal; - return (CPTDecimalGreaterThanOrEqualTo(currentLoc, startLoc) && CPTDecimalLessThanOrEqualTo(currentLoc, endLoc) ) || - (CPTDecimalGreaterThanOrEqualTo(currentLoc, endLoc) && CPTDecimalLessThanOrEqualTo(currentLoc, startLoc) ); + return (CPTDecimalGreaterThanOrEqualTo(currentLoc, startLoc) && CPTDecimalLessThanOrEqualTo(currentLoc, endLoc)) || + (CPTDecimalGreaterThanOrEqualTo(currentLoc, endLoc) && CPTDecimalLessThanOrEqualTo(currentLoc, startLoc)); } -(nonnull NSValue *)tweenedValueForProgress:(CGFloat)progress @@ -42,10 +42,10 @@ -(nonnull NSValue *)tweenedValueForProgress:(CGFloat)progress NSDecimal progressDecimal = CPTDecimalFromCGFloat(progress); NSDecimal locationDiff = CPTDecimalSubtract(end.locationDecimal, start.locationDecimal); - NSDecimal tweenedLocation = CPTDecimalAdd(start.locationDecimal, CPTDecimalMultiply(progressDecimal, locationDiff) ); + NSDecimal tweenedLocation = CPTDecimalAdd(start.locationDecimal, CPTDecimalMultiply(progressDecimal, locationDiff)); NSDecimal lengthDiff = CPTDecimalSubtract(end.lengthDecimal, start.lengthDecimal); - NSDecimal tweenedLength = CPTDecimalAdd(start.lengthDecimal, CPTDecimalMultiply(progressDecimal, lengthDiff) ); + NSDecimal tweenedLength = CPTDecimalAdd(start.lengthDecimal, CPTDecimalMultiply(progressDecimal, lengthDiff)); return (NSValue *)[CPTPlotRange plotRangeWithLocationDecimal:tweenedLocation lengthDecimal:tweenedLength]; } diff --git a/CorePlot/framework/Source/_CPTAnimationTimingFunctions.h b/CorePlot/framework/Source/_CPTAnimationTimingFunctions.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/_CPTAnimationTimingFunctions.m b/CorePlot/framework/Source/_CPTAnimationTimingFunctions.m old mode 100755 new mode 100644 index a01d533..36b20aa --- a/CorePlot/framework/Source/_CPTAnimationTimingFunctions.m +++ b/CorePlot/framework/Source/_CPTAnimationTimingFunctions.m @@ -15,13 +15,13 @@ **/ CGFloat CPTAnimationTimingFunctionLinear(CGFloat elapsedTime, CGFloat duration) { - if ( elapsedTime <= CPTFloat(0.0) ) { + if ( elapsedTime <= CPTFloat(0.0)) { return CPTFloat(0.0); } elapsedTime /= duration; - if ( elapsedTime >= CPTFloat(1.0) ) { + if ( elapsedTime >= CPTFloat(1.0)) { return CPTFloat(1.0); } @@ -41,17 +41,17 @@ CGFloat CPTAnimationTimingFunctionBackIn(CGFloat elapsedTime, CGFloat duration) { const CGFloat s = CPTFloat(1.70158); - if ( elapsedTime <= CPTFloat(0.0) ) { + if ( elapsedTime <= CPTFloat(0.0)) { return CPTFloat(0.0); } elapsedTime /= duration; - if ( elapsedTime >= CPTFloat(1.0) ) { + if ( elapsedTime >= CPTFloat(1.0)) { return CPTFloat(1.0); } - return elapsedTime * elapsedTime * ( (s + CPTFloat(1.0) ) * elapsedTime - s ); + return elapsedTime * elapsedTime * ((s + CPTFloat(1.0)) * elapsedTime - s); } /** @@ -64,17 +64,17 @@ CGFloat CPTAnimationTimingFunctionBackOut(CGFloat elapsedTime, CGFloat duration) { const CGFloat s = CPTFloat(1.70158); - if ( elapsedTime <= CPTFloat(0.0) ) { + if ( elapsedTime <= CPTFloat(0.0)) { return CPTFloat(0.0); } elapsedTime = elapsedTime / duration - CPTFloat(1.0); - if ( elapsedTime >= CPTFloat(0.0) ) { + if ( elapsedTime >= CPTFloat(0.0)) { return CPTFloat(1.0); } - return elapsedTime * elapsedTime * ( (s + CPTFloat(1.0) ) * elapsedTime + s ) + CPTFloat(1.0); + return elapsedTime * elapsedTime * ((s + CPTFloat(1.0)) * elapsedTime + s) + CPTFloat(1.0); } /** @@ -87,23 +87,23 @@ CGFloat CPTAnimationTimingFunctionBackInOut(CGFloat elapsedTime, CGFloat duratio { const CGFloat s = CPTFloat(1.70158 * 1.525); - if ( elapsedTime <= CPTFloat(0.0) ) { + if ( elapsedTime <= CPTFloat(0.0)) { return CPTFloat(0.0); } elapsedTime /= duration * CPTFloat(0.5); - if ( elapsedTime >= CPTFloat(2.0) ) { + if ( elapsedTime >= CPTFloat(2.0)) { return CPTFloat(1.0); } - if ( elapsedTime < CPTFloat(1.0) ) { - return CPTFloat(0.5) * (elapsedTime * elapsedTime * ( (s + CPTFloat(1.0) ) * elapsedTime - s ) ); + if ( elapsedTime < CPTFloat(1.0)) { + return CPTFloat(0.5) * (elapsedTime * elapsedTime * ((s + CPTFloat(1.0)) * elapsedTime - s)); } else { elapsedTime -= CPTFloat(2.0); - return CPTFloat(0.5) * (elapsedTime * elapsedTime * ( (s + CPTFloat(1.0) ) * elapsedTime + s ) + CPTFloat(2.0) ); + return CPTFloat(0.5) * (elapsedTime * elapsedTime * ((s + CPTFloat(1.0)) * elapsedTime + s) + CPTFloat(2.0)); } } @@ -129,25 +129,25 @@ CGFloat CPTAnimationTimingFunctionBounceIn(CGFloat elapsedTime, CGFloat duration **/ CGFloat CPTAnimationTimingFunctionBounceOut(CGFloat elapsedTime, CGFloat duration) { - if ( elapsedTime <= CPTFloat(0.0) ) { + if ( elapsedTime <= CPTFloat(0.0)) { return CPTFloat(0.0); } elapsedTime /= duration; - if ( elapsedTime >= CPTFloat(1.0) ) { + if ( elapsedTime >= CPTFloat(1.0)) { return CPTFloat(1.0); } - if ( elapsedTime < CPTFloat(1.0 / 2.75) ) { + if ( elapsedTime < CPTFloat(1.0 / 2.75)) { return CPTFloat(7.5625) * elapsedTime * elapsedTime; } - else if ( elapsedTime < CPTFloat(2.0 / 2.75) ) { + else if ( elapsedTime < CPTFloat(2.0 / 2.75)) { elapsedTime -= CPTFloat(1.5 / 2.75); return CPTFloat(7.5625) * elapsedTime * elapsedTime + CPTFloat(0.75); } - else if ( elapsedTime < CPTFloat(2.5 / 2.75) ) { + else if ( elapsedTime < CPTFloat(2.5 / 2.75)) { elapsedTime -= CPTFloat(2.25 / 2.75); return CPTFloat(7.5625) * elapsedTime * elapsedTime + CPTFloat(0.9375); @@ -167,7 +167,7 @@ CGFloat CPTAnimationTimingFunctionBounceOut(CGFloat elapsedTime, CGFloat duratio **/ CGFloat CPTAnimationTimingFunctionBounceInOut(CGFloat elapsedTime, CGFloat duration) { - if ( elapsedTime < duration * CPTFloat(0.5) ) { + if ( elapsedTime < duration * CPTFloat(0.5)) { return CPTAnimationTimingFunctionBounceIn(elapsedTime * CPTFloat(2.0), duration) * CPTFloat(0.5); } else { @@ -187,17 +187,17 @@ CGFloat CPTAnimationTimingFunctionBounceInOut(CGFloat elapsedTime, CGFloat durat **/ CGFloat CPTAnimationTimingFunctionCircularIn(CGFloat elapsedTime, CGFloat duration) { - if ( elapsedTime <= CPTFloat(0.0) ) { + if ( elapsedTime <= CPTFloat(0.0)) { return CPTFloat(0.0); } elapsedTime /= duration; - if ( elapsedTime >= CPTFloat(1.0) ) { + if ( elapsedTime >= CPTFloat(1.0)) { return CPTFloat(1.0); } - return -(sqrt(CPTFloat(1.0) - elapsedTime * elapsedTime) - CPTFloat(1.0) ); + return -(sqrt(CPTFloat(1.0) - elapsedTime * elapsedTime) - CPTFloat(1.0)); } /** @@ -208,13 +208,13 @@ CGFloat CPTAnimationTimingFunctionCircularIn(CGFloat elapsedTime, CGFloat durati **/ CGFloat CPTAnimationTimingFunctionCircularOut(CGFloat elapsedTime, CGFloat duration) { - if ( elapsedTime <= CPTFloat(0.0) ) { + if ( elapsedTime <= CPTFloat(0.0)) { return CPTFloat(0.0); } elapsedTime = elapsedTime / duration - CPTFloat(1.0); - if ( elapsedTime >= CPTFloat(0.0) ) { + if ( elapsedTime >= CPTFloat(0.0)) { return CPTFloat(1.0); } @@ -229,23 +229,23 @@ CGFloat CPTAnimationTimingFunctionCircularOut(CGFloat elapsedTime, CGFloat durat **/ CGFloat CPTAnimationTimingFunctionCircularInOut(CGFloat elapsedTime, CGFloat duration) { - if ( elapsedTime <= CPTFloat(0.0) ) { + if ( elapsedTime <= CPTFloat(0.0)) { return CPTFloat(0.0); } elapsedTime /= duration * CPTFloat(0.5); - if ( elapsedTime >= CPTFloat(2.0) ) { + if ( elapsedTime >= CPTFloat(2.0)) { return CPTFloat(1.0); } - if ( elapsedTime < CPTFloat(1.0) ) { - return CPTFloat(-0.5) * (sqrt(CPTFloat(1.0) - elapsedTime * elapsedTime) - CPTFloat(1.0) ); + if ( elapsedTime < CPTFloat(1.0)) { + return CPTFloat(-0.5) * (sqrt(CPTFloat(1.0) - elapsedTime * elapsedTime) - CPTFloat(1.0)); } else { elapsedTime -= CPTFloat(2.0); - return CPTFloat(0.5) * (sqrt(CPTFloat(1.0) - elapsedTime * elapsedTime) + CPTFloat(1.0) ); + return CPTFloat(0.5) * (sqrt(CPTFloat(1.0) - elapsedTime * elapsedTime) + CPTFloat(1.0)); } } @@ -260,13 +260,13 @@ CGFloat CPTAnimationTimingFunctionCircularInOut(CGFloat elapsedTime, CGFloat dur **/ CGFloat CPTAnimationTimingFunctionElasticIn(CGFloat elapsedTime, CGFloat duration) { - if ( elapsedTime <= CPTFloat(0.0) ) { + if ( elapsedTime <= CPTFloat(0.0)) { return CPTFloat(0.0); } elapsedTime /= duration; - if ( elapsedTime >= CPTFloat(1.0) ) { + if ( elapsedTime >= CPTFloat(1.0)) { return CPTFloat(1.0); } @@ -275,7 +275,7 @@ CGFloat CPTAnimationTimingFunctionElasticIn(CGFloat elapsedTime, CGFloat duratio elapsedTime -= CPTFloat(1.0); - return -(pow(CPTFloat(2.0), CPTFloat(10.0) * elapsedTime) * sin( (elapsedTime * duration - s) * CPTFloat(2.0 * M_PI) / period ) ); + return -(pow(CPTFloat(2.0), CPTFloat(10.0) * elapsedTime) * sin((elapsedTime * duration - s) * CPTFloat(2.0 * M_PI) / period)); } /** @@ -286,20 +286,20 @@ CGFloat CPTAnimationTimingFunctionElasticIn(CGFloat elapsedTime, CGFloat duratio **/ CGFloat CPTAnimationTimingFunctionElasticOut(CGFloat elapsedTime, CGFloat duration) { - if ( elapsedTime <= CPTFloat(0.0) ) { + if ( elapsedTime <= CPTFloat(0.0)) { return CPTFloat(0.0); } elapsedTime /= duration; - if ( elapsedTime >= CPTFloat(1.0) ) { + if ( elapsedTime >= CPTFloat(1.0)) { return CPTFloat(1.0); } CGFloat period = duration * CPTFloat(0.3); CGFloat s = period * CPTFloat(0.25); - return pow(CPTFloat(2.0), CPTFloat(-10.0) * elapsedTime) * sin( (elapsedTime * duration - s) * CPTFloat(2.0 * M_PI) / period ) + CPTFloat(1.0); + return pow(CPTFloat(2.0), CPTFloat(-10.0) * elapsedTime) * sin((elapsedTime * duration - s) * CPTFloat(2.0 * M_PI) / period) + CPTFloat(1.0); } /** @@ -310,13 +310,13 @@ CGFloat CPTAnimationTimingFunctionElasticOut(CGFloat elapsedTime, CGFloat durati **/ CGFloat CPTAnimationTimingFunctionElasticInOut(CGFloat elapsedTime, CGFloat duration) { - if ( elapsedTime <= CPTFloat(0.0) ) { + if ( elapsedTime <= CPTFloat(0.0)) { return CPTFloat(0.0); } elapsedTime /= duration * CPTFloat(0.5); - if ( elapsedTime >= CPTFloat(2.0) ) { + if ( elapsedTime >= CPTFloat(2.0)) { return CPTFloat(1.0); } @@ -325,11 +325,11 @@ CGFloat CPTAnimationTimingFunctionElasticInOut(CGFloat elapsedTime, CGFloat dura elapsedTime -= CPTFloat(1.0); - if ( elapsedTime < CPTFloat(0.0) ) { - return CPTFloat(-0.5) * (pow(CPTFloat(2.0), CPTFloat(10.0) * elapsedTime) * sin( (elapsedTime * duration - s) * CPTFloat(2.0 * M_PI) / period ) ); + if ( elapsedTime < CPTFloat(0.0)) { + return CPTFloat(-0.5) * (pow(CPTFloat(2.0), CPTFloat(10.0) * elapsedTime) * sin((elapsedTime * duration - s) * CPTFloat(2.0 * M_PI) / period)); } else { - return pow(CPTFloat(2.0), CPTFloat(-10.0) * elapsedTime) * sin( (elapsedTime * duration - s) * CPTFloat(2.0 * M_PI) / period ) * CPTFloat(0.5) + CPTFloat(1.0); + return pow(CPTFloat(2.0), CPTFloat(-10.0) * elapsedTime) * sin((elapsedTime * duration - s) * CPTFloat(2.0 * M_PI) / period) * CPTFloat(0.5) + CPTFloat(1.0); } } @@ -344,17 +344,17 @@ CGFloat CPTAnimationTimingFunctionElasticInOut(CGFloat elapsedTime, CGFloat dura **/ CGFloat CPTAnimationTimingFunctionExponentialIn(CGFloat elapsedTime, CGFloat duration) { - if ( elapsedTime <= CPTFloat(0.0) ) { + if ( elapsedTime <= CPTFloat(0.0)) { return CPTFloat(0.0); } elapsedTime /= duration; - if ( elapsedTime >= CPTFloat(1.0) ) { + if ( elapsedTime >= CPTFloat(1.0)) { return CPTFloat(1.0); } - return pow(CPTFloat(2.0), CPTFloat(10.0) * (elapsedTime - CPTFloat(1.0) ) ); + return pow(CPTFloat(2.0), CPTFloat(10.0) * (elapsedTime - CPTFloat(1.0))); } /** @@ -365,13 +365,13 @@ CGFloat CPTAnimationTimingFunctionExponentialIn(CGFloat elapsedTime, CGFloat dur **/ CGFloat CPTAnimationTimingFunctionExponentialOut(CGFloat elapsedTime, CGFloat duration) { - if ( elapsedTime <= CPTFloat(0.0) ) { + if ( elapsedTime <= CPTFloat(0.0)) { return CPTFloat(0.0); } elapsedTime /= duration; - if ( elapsedTime >= CPTFloat(1.0) ) { + if ( elapsedTime >= CPTFloat(1.0)) { return CPTFloat(1.0); } @@ -386,22 +386,22 @@ CGFloat CPTAnimationTimingFunctionExponentialOut(CGFloat elapsedTime, CGFloat du **/ CGFloat CPTAnimationTimingFunctionExponentialInOut(CGFloat elapsedTime, CGFloat duration) { - if ( elapsedTime <= CPTFloat(0.0) ) { + if ( elapsedTime <= CPTFloat(0.0)) { return CPTFloat(0.0); } elapsedTime /= duration * CPTFloat(0.5); elapsedTime -= CPTFloat(1.0); - if ( elapsedTime >= CPTFloat(1.0) ) { + if ( elapsedTime >= CPTFloat(1.0)) { return CPTFloat(1.0); } - if ( elapsedTime < CPTFloat(0.0) ) { + if ( elapsedTime < CPTFloat(0.0)) { return CPTFloat(0.5) * pow(CPTFloat(2.0), CPTFloat(10.0) * elapsedTime); } else { - return CPTFloat(0.5) * (-pow(CPTFloat(2.0), CPTFloat(-10.0) * elapsedTime) + CPTFloat(2.0) ); + return CPTFloat(0.5) * (-pow(CPTFloat(2.0), CPTFloat(-10.0) * elapsedTime) + CPTFloat(2.0)); } } @@ -416,17 +416,17 @@ CGFloat CPTAnimationTimingFunctionExponentialInOut(CGFloat elapsedTime, CGFloat **/ CGFloat CPTAnimationTimingFunctionSinusoidalIn(CGFloat elapsedTime, CGFloat duration) { - if ( elapsedTime <= CPTFloat(0.0) ) { + if ( elapsedTime <= CPTFloat(0.0)) { return CPTFloat(0.0); } elapsedTime /= duration; - if ( elapsedTime >= CPTFloat(1.0) ) { + if ( elapsedTime >= CPTFloat(1.0)) { return CPTFloat(1.0); } - return -cos(elapsedTime * CPTFloat(M_PI_2) ) + CPTFloat(1.0); + return -cos(elapsedTime * CPTFloat(M_PI_2)) + CPTFloat(1.0); } /** @@ -437,17 +437,17 @@ CGFloat CPTAnimationTimingFunctionSinusoidalIn(CGFloat elapsedTime, CGFloat dura **/ CGFloat CPTAnimationTimingFunctionSinusoidalOut(CGFloat elapsedTime, CGFloat duration) { - if ( elapsedTime <= CPTFloat(0.0) ) { + if ( elapsedTime <= CPTFloat(0.0)) { return CPTFloat(0.0); } elapsedTime /= duration; - if ( elapsedTime >= CPTFloat(1.0) ) { + if ( elapsedTime >= CPTFloat(1.0)) { return CPTFloat(1.0); } - return sin(elapsedTime * CPTFloat(M_PI_2) ); + return sin(elapsedTime * CPTFloat(M_PI_2)); } /** @@ -458,17 +458,17 @@ CGFloat CPTAnimationTimingFunctionSinusoidalOut(CGFloat elapsedTime, CGFloat dur **/ CGFloat CPTAnimationTimingFunctionSinusoidalInOut(CGFloat elapsedTime, CGFloat duration) { - if ( elapsedTime <= CPTFloat(0.0) ) { + if ( elapsedTime <= CPTFloat(0.0)) { return CPTFloat(0.0); } elapsedTime /= duration; - if ( elapsedTime >= CPTFloat(1.0) ) { + if ( elapsedTime >= CPTFloat(1.0)) { return CPTFloat(1.0); } - return CPTFloat(-0.5) * (cos(CPTFloat(M_PI) * elapsedTime) - CPTFloat(1.0) ); + return CPTFloat(-0.5) * (cos(CPTFloat(M_PI) * elapsedTime) - CPTFloat(1.0)); } #pragma mark - @@ -482,13 +482,13 @@ CGFloat CPTAnimationTimingFunctionSinusoidalInOut(CGFloat elapsedTime, CGFloat d **/ CGFloat CPTAnimationTimingFunctionCubicIn(CGFloat elapsedTime, CGFloat duration) { - if ( elapsedTime <= CPTFloat(0.0) ) { + if ( elapsedTime <= CPTFloat(0.0)) { return CPTFloat(0.0); } elapsedTime /= duration; - if ( elapsedTime >= CPTFloat(1.0) ) { + if ( elapsedTime >= CPTFloat(1.0)) { return CPTFloat(1.0); } @@ -503,13 +503,13 @@ CGFloat CPTAnimationTimingFunctionCubicIn(CGFloat elapsedTime, CGFloat duration) **/ CGFloat CPTAnimationTimingFunctionCubicOut(CGFloat elapsedTime, CGFloat duration) { - if ( elapsedTime <= CPTFloat(0.0) ) { + if ( elapsedTime <= CPTFloat(0.0)) { return CPTFloat(0.0); } elapsedTime = elapsedTime / duration - CPTFloat(1.0); - if ( elapsedTime >= CPTFloat(0.0) ) { + if ( elapsedTime >= CPTFloat(0.0)) { return CPTFloat(1.0); } @@ -524,23 +524,23 @@ CGFloat CPTAnimationTimingFunctionCubicOut(CGFloat elapsedTime, CGFloat duration **/ CGFloat CPTAnimationTimingFunctionCubicInOut(CGFloat elapsedTime, CGFloat duration) { - if ( elapsedTime <= CPTFloat(0.0) ) { + if ( elapsedTime <= CPTFloat(0.0)) { return CPTFloat(0.0); } elapsedTime /= duration * CPTFloat(0.5); - if ( elapsedTime >= CPTFloat(2.0) ) { + if ( elapsedTime >= CPTFloat(2.0)) { return CPTFloat(1.0); } - if ( elapsedTime < CPTFloat(1.0) ) { + if ( elapsedTime < CPTFloat(1.0)) { return CPTFloat(0.5) * elapsedTime * elapsedTime * elapsedTime; } else { elapsedTime -= CPTFloat(2.0); - return CPTFloat(0.5) * (elapsedTime * elapsedTime * elapsedTime + CPTFloat(2.0) ); + return CPTFloat(0.5) * (elapsedTime * elapsedTime * elapsedTime + CPTFloat(2.0)); } } @@ -555,13 +555,13 @@ CGFloat CPTAnimationTimingFunctionCubicInOut(CGFloat elapsedTime, CGFloat durati **/ CGFloat CPTAnimationTimingFunctionQuadraticIn(CGFloat elapsedTime, CGFloat duration) { - if ( elapsedTime <= CPTFloat(0.0) ) { + if ( elapsedTime <= CPTFloat(0.0)) { return CPTFloat(0.0); } elapsedTime /= duration; - if ( elapsedTime >= CPTFloat(1.0) ) { + if ( elapsedTime >= CPTFloat(1.0)) { return CPTFloat(1.0); } @@ -576,17 +576,17 @@ CGFloat CPTAnimationTimingFunctionQuadraticIn(CGFloat elapsedTime, CGFloat durat **/ CGFloat CPTAnimationTimingFunctionQuadraticOut(CGFloat elapsedTime, CGFloat duration) { - if ( elapsedTime <= CPTFloat(0.0) ) { + if ( elapsedTime <= CPTFloat(0.0)) { return CPTFloat(0.0); } elapsedTime /= duration; - if ( elapsedTime >= CPTFloat(1.0) ) { + if ( elapsedTime >= CPTFloat(1.0)) { return CPTFloat(1.0); } - return -elapsedTime * (elapsedTime - CPTFloat(2.0) ); + return -elapsedTime * (elapsedTime - CPTFloat(2.0)); } /** @@ -597,23 +597,23 @@ CGFloat CPTAnimationTimingFunctionQuadraticOut(CGFloat elapsedTime, CGFloat dura **/ CGFloat CPTAnimationTimingFunctionQuadraticInOut(CGFloat elapsedTime, CGFloat duration) { - if ( elapsedTime <= CPTFloat(0.0) ) { + if ( elapsedTime <= CPTFloat(0.0)) { return CPTFloat(0.0); } elapsedTime /= duration * CPTFloat(0.5); - if ( elapsedTime >= CPTFloat(2.0) ) { + if ( elapsedTime >= CPTFloat(2.0)) { return CPTFloat(1.0); } - if ( elapsedTime < CPTFloat(1.0) ) { + if ( elapsedTime < CPTFloat(1.0)) { return CPTFloat(0.5) * elapsedTime * elapsedTime; } else { elapsedTime -= CPTFloat(1.0); - return CPTFloat(-0.5) * (elapsedTime * (elapsedTime - CPTFloat(2.0) ) - CPTFloat(1.0) ); + return CPTFloat(-0.5) * (elapsedTime * (elapsedTime - CPTFloat(2.0)) - CPTFloat(1.0)); } } @@ -628,13 +628,13 @@ CGFloat CPTAnimationTimingFunctionQuadraticInOut(CGFloat elapsedTime, CGFloat du **/ CGFloat CPTAnimationTimingFunctionQuarticIn(CGFloat elapsedTime, CGFloat duration) { - if ( elapsedTime <= CPTFloat(0.0) ) { + if ( elapsedTime <= CPTFloat(0.0)) { return CPTFloat(0.0); } elapsedTime /= duration; - if ( elapsedTime >= CPTFloat(1.0) ) { + if ( elapsedTime >= CPTFloat(1.0)) { return CPTFloat(1.0); } @@ -649,17 +649,17 @@ CGFloat CPTAnimationTimingFunctionQuarticIn(CGFloat elapsedTime, CGFloat duratio **/ CGFloat CPTAnimationTimingFunctionQuarticOut(CGFloat elapsedTime, CGFloat duration) { - if ( elapsedTime <= CPTFloat(0.0) ) { + if ( elapsedTime <= CPTFloat(0.0)) { return CPTFloat(0.0); } elapsedTime = elapsedTime / duration - CPTFloat(1.0); - if ( elapsedTime >= CPTFloat(0.0) ) { + if ( elapsedTime >= CPTFloat(0.0)) { return CPTFloat(1.0); } - return -(elapsedTime * elapsedTime * elapsedTime * elapsedTime - CPTFloat(1.0) ); + return -(elapsedTime * elapsedTime * elapsedTime * elapsedTime - CPTFloat(1.0)); } /** @@ -670,23 +670,23 @@ CGFloat CPTAnimationTimingFunctionQuarticOut(CGFloat elapsedTime, CGFloat durati **/ CGFloat CPTAnimationTimingFunctionQuarticInOut(CGFloat elapsedTime, CGFloat duration) { - if ( elapsedTime <= CPTFloat(0.0) ) { + if ( elapsedTime <= CPTFloat(0.0)) { return CPTFloat(0.0); } elapsedTime /= duration * CPTFloat(0.5); - if ( elapsedTime >= CPTFloat(2.0) ) { + if ( elapsedTime >= CPTFloat(2.0)) { return CPTFloat(1.0); } - if ( elapsedTime < CPTFloat(1.0) ) { + if ( elapsedTime < CPTFloat(1.0)) { return CPTFloat(0.5) * elapsedTime * elapsedTime * elapsedTime * elapsedTime; } else { elapsedTime -= CPTFloat(2.0); - return CPTFloat(-0.5) * (elapsedTime * elapsedTime * elapsedTime * elapsedTime - CPTFloat(2.0) ); + return CPTFloat(-0.5) * (elapsedTime * elapsedTime * elapsedTime * elapsedTime - CPTFloat(2.0)); } } @@ -701,13 +701,13 @@ CGFloat CPTAnimationTimingFunctionQuarticInOut(CGFloat elapsedTime, CGFloat dura **/ CGFloat CPTAnimationTimingFunctionQuinticIn(CGFloat elapsedTime, CGFloat duration) { - if ( elapsedTime <= CPTFloat(0.0) ) { + if ( elapsedTime <= CPTFloat(0.0)) { return CPTFloat(0.0); } elapsedTime /= duration; - if ( elapsedTime >= CPTFloat(1.0) ) { + if ( elapsedTime >= CPTFloat(1.0)) { return CPTFloat(1.0); } @@ -722,13 +722,13 @@ CGFloat CPTAnimationTimingFunctionQuinticIn(CGFloat elapsedTime, CGFloat duratio **/ CGFloat CPTAnimationTimingFunctionQuinticOut(CGFloat elapsedTime, CGFloat duration) { - if ( elapsedTime <= CPTFloat(0.0) ) { + if ( elapsedTime <= CPTFloat(0.0)) { return CPTFloat(0.0); } elapsedTime = elapsedTime / duration - CPTFloat(1.0); - if ( elapsedTime >= CPTFloat(0.0) ) { + if ( elapsedTime >= CPTFloat(0.0)) { return CPTFloat(1.0); } @@ -743,22 +743,22 @@ CGFloat CPTAnimationTimingFunctionQuinticOut(CGFloat elapsedTime, CGFloat durati **/ CGFloat CPTAnimationTimingFunctionQuinticInOut(CGFloat elapsedTime, CGFloat duration) { - if ( elapsedTime <= CPTFloat(0.0) ) { + if ( elapsedTime <= CPTFloat(0.0)) { return CPTFloat(0.0); } elapsedTime /= duration * CPTFloat(0.5); - if ( elapsedTime >= CPTFloat(2.0) ) { + if ( elapsedTime >= CPTFloat(2.0)) { return CPTFloat(1.0); } - if ( elapsedTime < CPTFloat(1.0) ) { + if ( elapsedTime < CPTFloat(1.0)) { return CPTFloat(0.5) * elapsedTime * elapsedTime * elapsedTime * elapsedTime * elapsedTime; } else { elapsedTime -= CPTFloat(2.0); - return CPTFloat(0.5) * (elapsedTime * elapsedTime * elapsedTime * elapsedTime * elapsedTime + CPTFloat(2.0) ); + return CPTFloat(0.5) * (elapsedTime * elapsedTime * elapsedTime * elapsedTime * elapsedTime + CPTFloat(2.0)); } } diff --git a/CorePlot/framework/Source/_CPTBorderLayer.h b/CorePlot/framework/Source/_CPTBorderLayer.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/_CPTBorderLayer.m b/CorePlot/framework/Source/_CPTBorderLayer.m old mode 100755 new mode 100644 index 05930cb..009fa48 --- a/CorePlot/framework/Source/_CPTBorderLayer.m +++ b/CorePlot/framework/Source/_CPTBorderLayer.m @@ -33,7 +33,7 @@ @implementation CPTBorderLayer **/ -(nonnull instancetype)initWithFrame:(CGRect)newFrame { - if ( (self = [super initWithFrame:newFrame]) ) { + if ((self = [super initWithFrame:newFrame])) { maskedLayer = nil; self.needsDisplayOnBoundsChange = YES; @@ -47,7 +47,7 @@ -(nonnull instancetype)initWithFrame:(CGRect)newFrame -(nonnull instancetype)initWithLayer:(nonnull id)layer { - if ( (self = [super initWithLayer:layer]) ) { + if ((self = [super initWithLayer:layer])) { CPTBorderLayer *theLayer = (CPTBorderLayer *)layer; maskedLayer = theLayer->maskedLayer; @@ -71,7 +71,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super initWithCoder:coder]) ) { + if ((self = [super initWithCoder:coder])) { maskedLayer = [coder decodeObjectOfClass:[CPTBorderedLayer class] forKey:@"CPTBorderLayer.maskedLayer"]; } @@ -177,7 +177,7 @@ -(void)setMaskedLayer:(nullable CPTBorderedLayer *)newLayer -(void)setBounds:(CGRect)newBounds { - if ( !CGRectEqualToRect(newBounds, self.bounds) ) { + if ( !CGRectEqualToRect(newBounds, self.bounds)) { super.bounds = newBounds; [self setNeedsLayout]; } diff --git a/CorePlot/framework/Source/_CPTConstraintsFixed.h b/CorePlot/framework/Source/_CPTConstraintsFixed.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/_CPTConstraintsFixed.m b/CorePlot/framework/Source/_CPTConstraintsFixed.m old mode 100755 new mode 100644 index d00c306..7cef014 --- a/CorePlot/framework/Source/_CPTConstraintsFixed.m +++ b/CorePlot/framework/Source/_CPTConstraintsFixed.m @@ -32,7 +32,7 @@ @implementation _CPTConstraintsFixed **/ -(nonnull instancetype)initWithLowerOffset:(CGFloat)newOffset { - if ( (self = [super init]) ) { + if ((self = [super init])) { offset = newOffset; isFixedToLower = YES; } @@ -46,7 +46,7 @@ -(nonnull instancetype)initWithLowerOffset:(CGFloat)newOffset **/ -(nonnull instancetype)initWithUpperOffset:(CGFloat)newOffset { - if ( (self = [super init]) ) { + if ((self = [super init])) { offset = newOffset; isFixedToLower = NO; } @@ -62,8 +62,8 @@ -(BOOL)isEqualToConstraint:(nullable CPTConstraints *)otherConstraint if ( [self class] != [otherConstraint class] ) { return NO; } - return (self.offset == ( (_CPTConstraintsFixed *)otherConstraint ).offset) && - (self.isFixedToLower == ( (_CPTConstraintsFixed *)otherConstraint ).isFixedToLower); + return (self.offset == ((_CPTConstraintsFixed *)otherConstraint).offset) && + (self.isFixedToLower == ((_CPTConstraintsFixed *)otherConstraint).isFixedToLower); } #pragma mark - @@ -131,7 +131,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder */ -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super init]) ) { + if ((self = [super init])) { offset = [coder decodeCGFloatForKey:@"_CPTConstraintsFixed.offset"]; isFixedToLower = [coder decodeBoolForKey:@"_CPTConstraintsFixed.isFixedToLower"]; } diff --git a/CorePlot/framework/Source/_CPTConstraintsRelative.h b/CorePlot/framework/Source/_CPTConstraintsRelative.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/_CPTConstraintsRelative.m b/CorePlot/framework/Source/_CPTConstraintsRelative.m old mode 100755 new mode 100644 index 4edf533..533e204 --- a/CorePlot/framework/Source/_CPTConstraintsRelative.m +++ b/CorePlot/framework/Source/_CPTConstraintsRelative.m @@ -35,7 +35,7 @@ @implementation _CPTConstraintsRelative **/ -(nonnull instancetype)initWithRelativeOffset:(CGFloat)newOffset { - if ( (self = [super init]) ) { + if ((self = [super init])) { offset = newOffset; } @@ -50,7 +50,7 @@ -(BOOL)isEqualToConstraint:(nullable CPTConstraints *)otherConstraint if ( [self class] != [otherConstraint class] ) { return NO; } - return self.offset == ( (_CPTConstraintsRelative *)otherConstraint ).offset; + return self.offset == ((_CPTConstraintsRelative *)otherConstraint).offset; } #pragma mark - @@ -109,7 +109,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder */ -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super init]) ) { + if ((self = [super init])) { offset = [coder decodeCGFloatForKey:@"_CPTConstraintsRelative.offset"]; } return self; diff --git a/CorePlot/framework/Source/_CPTDarkGradientTheme.h b/CorePlot/framework/Source/_CPTDarkGradientTheme.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/_CPTDarkGradientTheme.m b/CorePlot/framework/Source/_CPTDarkGradientTheme.m old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/_CPTFillColor.h b/CorePlot/framework/Source/_CPTFillColor.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/_CPTFillColor.m b/CorePlot/framework/Source/_CPTFillColor.m old mode 100755 new mode 100644 index ed4df6c..628f5b6 --- a/CorePlot/framework/Source/_CPTFillColor.m +++ b/CorePlot/framework/Source/_CPTFillColor.m @@ -32,7 +32,7 @@ @implementation _CPTFillColor **/ -(nonnull instancetype)initWithColor:(nonnull CPTColor *)aColor { - if ( (self = [super init]) ) { + if ((self = [super init])) { fillColor = aColor; } return self; @@ -119,7 +119,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder */ -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super init]) ) { + if ((self = [super init])) { CPTColor *color = [coder decodeObjectOfClass:[CPTColor class] forKey:@"_CPTFillColor.fillColor"]; diff --git a/CorePlot/framework/Source/_CPTFillGradient.h b/CorePlot/framework/Source/_CPTFillGradient.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/_CPTFillGradient.m b/CorePlot/framework/Source/_CPTFillGradient.m old mode 100755 new mode 100644 index 4f088d3..c7d0aa7 --- a/CorePlot/framework/Source/_CPTFillGradient.m +++ b/CorePlot/framework/Source/_CPTFillGradient.m @@ -32,7 +32,7 @@ @implementation _CPTFillGradient **/ -(nonnull instancetype)initWithGradient:(nonnull CPTGradient *)aGradient { - if ( (self = [super init]) ) { + if ((self = [super init])) { fillGradient = aGradient; } return self; @@ -105,7 +105,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder */ -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super init]) ) { + if ((self = [super init])) { CPTGradient *gradient = [coder decodeObjectOfClass:[CPTGradient class] forKey:@"_CPTFillGradient.fillGradient"]; diff --git a/CorePlot/framework/Source/_CPTFillImage.h b/CorePlot/framework/Source/_CPTFillImage.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/_CPTFillImage.m b/CorePlot/framework/Source/_CPTFillImage.m old mode 100755 new mode 100644 index a79793a..48614de --- a/CorePlot/framework/Source/_CPTFillImage.m +++ b/CorePlot/framework/Source/_CPTFillImage.m @@ -32,7 +32,7 @@ @implementation _CPTFillImage **/ -(nonnull instancetype)initWithImage:(nonnull CPTImage *)anImage { - if ( (self = [super init]) ) { + if ((self = [super init])) { fillImage = anImage; } return self; @@ -111,7 +111,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder */ -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super init]) ) { + if ((self = [super init])) { CPTImage *image = [coder decodeObjectOfClass:[CPTImage class] forKey:@"_CPTFillImage.fillImage"]; diff --git a/CorePlot/framework/Source/_CPTMaskLayer.h b/CorePlot/framework/Source/_CPTMaskLayer.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/_CPTMaskLayer.m b/CorePlot/framework/Source/_CPTMaskLayer.m old mode 100755 new mode 100644 index b712e53..14e3dc6 --- a/CorePlot/framework/Source/_CPTMaskLayer.m +++ b/CorePlot/framework/Source/_CPTMaskLayer.m @@ -18,7 +18,7 @@ @implementation CPTMaskLayer **/ -(nonnull instancetype)initWithFrame:(CGRect)newFrame { - if ( (self = [super initWithFrame:newFrame]) ) { + if ((self = [super initWithFrame:newFrame])) { self.needsDisplayOnBoundsChange = YES; } return self; @@ -36,7 +36,7 @@ -(void)renderAsVectorInContext:(nonnull CGContextRef)context CPTLayer *theMaskedLayer = (CPTLayer *)self.superlayer; if ( theMaskedLayer ) { - CGContextSetRGBFillColor(context, CPTFloat(0.0), CPTFloat(0.0), CPTFloat(0.0), CPTFloat(1.0) ); + CGContextSetRGBFillColor(context, CPTFloat(0.0), CPTFloat(0.0), CPTFloat(0.0), CPTFloat(1.0)); if ( [theMaskedLayer isKindOfClass:[CPTLayer class]] ) { CGPathRef maskingPath = theMaskedLayer.sublayerMaskingPath; diff --git a/CorePlot/framework/Source/_CPTPlainBlackTheme.h b/CorePlot/framework/Source/_CPTPlainBlackTheme.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/_CPTPlainBlackTheme.m b/CorePlot/framework/Source/_CPTPlainBlackTheme.m old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/_CPTPlainWhiteTheme.h b/CorePlot/framework/Source/_CPTPlainWhiteTheme.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/_CPTPlainWhiteTheme.m b/CorePlot/framework/Source/_CPTPlainWhiteTheme.m old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/_CPTSlateTheme.h b/CorePlot/framework/Source/_CPTSlateTheme.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/_CPTSlateTheme.m b/CorePlot/framework/Source/_CPTSlateTheme.m old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/_CPTStocksTheme.h b/CorePlot/framework/Source/_CPTStocksTheme.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/_CPTStocksTheme.m b/CorePlot/framework/Source/_CPTStocksTheme.m old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/_CPTXYTheme.h b/CorePlot/framework/Source/_CPTXYTheme.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/_CPTXYTheme.m b/CorePlot/framework/Source/_CPTXYTheme.m old mode 100755 new mode 100644 index 9bb2675..129d137 --- a/CorePlot/framework/Source/_CPTXYTheme.m +++ b/CorePlot/framework/Source/_CPTXYTheme.m @@ -15,7 +15,7 @@ @implementation _CPTXYTheme -(nonnull instancetype)init { - if ( (self = [super init]) ) { + if ((self = [super init])) { self.graphClass = [CPTXYGraph class]; } return self; diff --git a/CorePlot/framework/Source/license.txt b/CorePlot/framework/Source/license.txt old mode 100755 new mode 100644 diff --git a/CorePlot/framework/Source/mainpage.h b/CorePlot/framework/Source/mainpage.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/TestResources/checkformisalignedlayers.d b/CorePlot/framework/TestResources/checkformisalignedlayers.d old mode 100755 new mode 100644 diff --git a/CorePlot/framework/en.lproj/InfoPlist.strings b/CorePlot/framework/en.lproj/InfoPlist.strings old mode 100755 new mode 100644 diff --git a/CorePlot/framework/iPhoneOnly/CPTGraphHostingView.h b/CorePlot/framework/iPhoneOnly/CPTGraphHostingView.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/iPhoneOnly/CPTGraphHostingView.m b/CorePlot/framework/iPhoneOnly/CPTGraphHostingView.m old mode 100755 new mode 100644 index 25bf0b0..0efa093 --- a/CorePlot/framework/iPhoneOnly/CPTGraphHostingView.m +++ b/CorePlot/framework/iPhoneOnly/CPTGraphHostingView.m @@ -79,17 +79,24 @@ -(void)commonInit self.allowPinchScaling = YES; // This undoes the normal coordinate space inversion that UIViews apply to their layers - self.layer.sublayerTransform = CATransform3DMakeScale(CPTFloat(1.0), CPTFloat(-1.0), CPTFloat(1.0) ); + self.layer.sublayerTransform = CATransform3DMakeScale(CPTFloat(1.0), CPTFloat(-1.0), CPTFloat(1.0)); } -(nonnull instancetype)initWithFrame:(CGRect)frame { - if ( (self = [super initWithFrame:frame]) ) { + if ((self = [super initWithFrame:frame])) { [self commonInit]; } return self; } +-(void)awakeFromNib +{ + [super awakeFromNib]; + + [self commonInit]; +} + -(void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; @@ -116,7 +123,7 @@ -(void)encodeWithCoder:(nonnull NSCoder *)coder -(nullable instancetype)initWithCoder:(nonnull NSCoder *)coder { - if ( (self = [super initWithCoder:coder]) ) { + if ((self = [super initWithCoder:coder])) { [self commonInit]; collapsesLayers = [coder decodeBoolForKey:@"CPTGraphHostingView.collapsesLayers"]; @@ -354,7 +361,7 @@ -(void)graphNeedsRedraw:(nonnull NSNotification *)notification -(void)setHostedGraph:(nullable CPTGraph *)newLayer { - NSParameterAssert( (newLayer == nil) || [newLayer isKindOfClass:[CPTGraph class]] ); + NSParameterAssert((newLayer == nil) || [newLayer isKindOfClass:[CPTGraph class]]); if ( newLayer == hostedGraph ) { return; diff --git a/CorePlot/framework/iPhoneOnly/CPTImagePlatformSpecific.m b/CorePlot/framework/iPhoneOnly/CPTImagePlatformSpecific.m old mode 100755 new mode 100644 index 21ad7a5..20c73f0 --- a/CorePlot/framework/iPhoneOnly/CPTImagePlatformSpecific.m +++ b/CorePlot/framework/iPhoneOnly/CPTImagePlatformSpecific.m @@ -14,7 +14,7 @@ @implementation CPTImage(CPTPlatformSpecificImageExtensions) **/ -(nonnull instancetype)initWithNativeImage:(nullable CPTNativeImage *)anImage { - if ( (self = [self initWithCGImage:NULL scale:anImage.scale]) ) { + if ((self = [self initWithCGImage:NULL scale:anImage.scale])) { self.nativeImage = anImage; UIEdgeInsets insets = anImage.capInsets; @@ -45,7 +45,7 @@ -(nonnull instancetype)initForPNGFile:(nonnull NSString *)path imageScale = MAX(imageScale, screen.scale); } - if ( imageScale > CPTFloat(1.0) ) { + if ( imageScale > CPTFloat(1.0)) { NSMutableString *hiDpiPath = [path mutableCopy]; NSUInteger replaceCount = [hiDpiPath replaceOccurrencesOfString:@".png" withString:[NSString stringWithFormat:@"@%dx.png", (int)imageScale] diff --git a/CorePlot/framework/iPhoneOnly/CPTPlatformSpecificCategories.h b/CorePlot/framework/iPhoneOnly/CPTPlatformSpecificCategories.h old mode 100755 new mode 100644 index 9132da0..efa9fff --- a/CorePlot/framework/iPhoneOnly/CPTPlatformSpecificCategories.h +++ b/CorePlot/framework/iPhoneOnly/CPTPlatformSpecificCategories.h @@ -2,17 +2,6 @@ #import "CPTLayer.h" #import "CPTPlatformSpecificDefines.h" -#pragma mark CPTColor - -/** @category CPTColor(CPTPlatformSpecificColorExtensions) - * @brief Platform-specific extensions to CPTColor. - **/ -@interface CPTColor(CPTPlatformSpecificColorExtensions) - -@property (nonatomic, readonly, nonnull) UIColor *uiColor; - -@end - #pragma mark - CPTLayer /** @category CPTLayer(CPTPlatformSpecificLayerExtensions) diff --git a/CorePlot/framework/iPhoneOnly/CPTPlatformSpecificCategories.m b/CorePlot/framework/iPhoneOnly/CPTPlatformSpecificCategories.m old mode 100755 new mode 100644 index 7798382..cad04a6 --- a/CorePlot/framework/iPhoneOnly/CPTPlatformSpecificCategories.m +++ b/CorePlot/framework/iPhoneOnly/CPTPlatformSpecificCategories.m @@ -3,22 +3,6 @@ #import "CPTPlatformSpecificFunctions.h" #import "tgmath.h" -#pragma mark CPTColor - -@implementation CPTColor(CPTPlatformSpecificColorExtensions) - -/** @property uiColor - * @brief Gets the color value as a UIColor. - **/ -@dynamic uiColor; - --(nonnull UIColor *)uiColor -{ - return [UIColor colorWithCGColor:self.cgColor]; -} - -@end - #pragma mark - CPTLayer @implementation CPTLayer(CPTPlatformSpecificLayerExtensions) @@ -30,14 +14,14 @@ -(nullable CPTNativeImage *)imageOfLayer { CGSize boundsSize = self.bounds.size; - UIGraphicsBeginImageContextWithOptions(boundsSize, self.opaque, CPTFloat(0.0) ); + UIGraphicsBeginImageContextWithOptions(boundsSize, self.opaque, CPTFloat(0.0)); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSaveGState(context); CGContextSetAllowsAntialiasing(context, true); CGContextTranslateCTM(context, CPTFloat(0.0), boundsSize.height); - CGContextScaleCTM(context, CPTFloat(1.0), CPTFloat(-1.0) ); + CGContextScaleCTM(context, CPTFloat(1.0), CPTFloat(-1.0)); [self layoutAndRenderInContext:context]; CPTNativeImage *layerImage = UIGraphicsGetImageFromCurrentImageContext(); diff --git a/CorePlot/framework/iPhoneOnly/CPTPlatformSpecificDefines.h b/CorePlot/framework/iPhoneOnly/CPTPlatformSpecificDefines.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/iPhoneOnly/CPTPlatformSpecificDefines.m b/CorePlot/framework/iPhoneOnly/CPTPlatformSpecificDefines.m old mode 100755 new mode 100644 diff --git a/CorePlot/framework/iPhoneOnly/CPTPlatformSpecificFunctions.h b/CorePlot/framework/iPhoneOnly/CPTPlatformSpecificFunctions.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/iPhoneOnly/CPTPlatformSpecificFunctions.m b/CorePlot/framework/iPhoneOnly/CPTPlatformSpecificFunctions.m old mode 100755 new mode 100644 diff --git a/CorePlot/framework/iPhoneOnly/CPTTextStylePlatformSpecific.h b/CorePlot/framework/iPhoneOnly/CPTTextStylePlatformSpecific.h old mode 100755 new mode 100644 diff --git a/CorePlot/framework/iPhoneOnly/CPTTextStylePlatformSpecific.m b/CorePlot/framework/iPhoneOnly/CPTTextStylePlatformSpecific.m old mode 100755 new mode 100644 diff --git a/CorePlot/framework/xcconfig/CorePlot.xcconfig b/CorePlot/framework/xcconfig/CorePlot.xcconfig old mode 100755 new mode 100644 index e0d2957..cb645b6 --- a/CorePlot/framework/xcconfig/CorePlot.xcconfig +++ b/CorePlot/framework/xcconfig/CorePlot.xcconfig @@ -1,7 +1,7 @@ #include "CorePlotWarnings.xcconfig" ARCHS = $(ARCHS_STANDARD) -VALID_ARCHS[sdk=iphoneos*] = arm64 armv7 armv7s +VALID_ARCHS[sdk=iphoneos*] = arm64 arm64e armv7 armv7s VALID_ARCHS[sdk=iphonesimulator*] = i386 x86_64 VALID_ARCHS[sdk=macosx*] = i386 x86_64 VALID_ARCHS[sdk=appletvos*] = arm64 diff --git a/CorePlot/framework/xcconfig/CorePlotDebug.xcconfig b/CorePlot/framework/xcconfig/CorePlotDebug.xcconfig old mode 100755 new mode 100644 diff --git a/CorePlot/framework/xcconfig/CorePlotRelease.xcconfig b/CorePlot/framework/xcconfig/CorePlotRelease.xcconfig old mode 100755 new mode 100644 diff --git a/CorePlot/framework/xcconfig/CorePlotWarnings.xcconfig b/CorePlot/framework/xcconfig/CorePlotWarnings.xcconfig old mode 100755 new mode 100644 diff --git a/Info.plist b/Info.plist index c013bd5..68fb9e2 100755 --- a/Info.plist +++ b/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.5 + $(MARKETING_VERSION) CFBundleSignature ???? CFBundleVersion diff --git a/RombergLab.xcodeproj/project.pbxproj b/RombergLab.xcodeproj/project.pbxproj index ac50d8e..5a0fd7c 100755 --- a/RombergLab.xcodeproj/project.pbxproj +++ b/RombergLab.xcodeproj/project.pbxproj @@ -564,6 +564,7 @@ INSTALL_PATH = "$(LOCAL_APPS_DIR)"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.11; + MARKETING_VERSION = 1.5.1; PRODUCT_BUNDLE_IDENTIFIER = ARK.RombergLab; PRODUCT_NAME = RombergLab; PROVISIONING_PROFILE = ""; @@ -607,6 +608,7 @@ INSTALL_PATH = "$(LOCAL_APPS_DIR)"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.11; + MARKETING_VERSION = 1.5.1; PRODUCT_BUNDLE_IDENTIFIER = ARK.RombergLab; PRODUCT_NAME = RombergLab; PROVISIONING_PROFILE = ""; diff --git a/RombergLab.xcodeproj/project.xcworkspace/xcuserdata/Jorge.xcuserdatad/UserInterfaceState.xcuserstate b/RombergLab.xcodeproj/project.xcworkspace/xcuserdata/Jorge.xcuserdatad/UserInterfaceState.xcuserstate index edc8250..e1a1ba2 100755 Binary files a/RombergLab.xcodeproj/project.xcworkspace/xcuserdata/Jorge.xcuserdatad/UserInterfaceState.xcuserstate and b/RombergLab.xcodeproj/project.xcworkspace/xcuserdata/Jorge.xcuserdatad/UserInterfaceState.xcuserstate differ