Core Plot (macOS)
Cocoa plotting framework for macOS, iOS, and tvOS
CPTLayer Class Reference

Base class for all Core Animation layers in Core Plot. More...

#import <CPTLayer.h>

+ Inheritance diagram for CPTLayer:
+ Collaboration diagram for CPTLayer:

Public Instance Methods

Initialization
(nonnull instancetype) - initWithFrame:
 Initializes a newly allocated CPTLayer object with the provided frame rectangle. More...
 
(nullable instancetype) - initWithCoder:
 Returns an object initialized from data in a given unarchiver. More...
 
(nonnull instancetype) - initWithLayer:
 Override to copy or initialize custom fields of the specified layer. More...
 
(nonnull instancetype) - init [implementation]
 Initializes a newly allocated CPTLayer object with an empty frame rectangle. More...
 
Information
(void) - logLayers
 Logs this layer and all of its sublayers. More...
 
User Interaction
(BOOL- pointingDeviceDownEvent:atPoint: [implementation]
 
(BOOL- pointingDeviceUpEvent:atPoint: [implementation]
 
(BOOL- pointingDeviceDraggedEvent:atPoint: [implementation]
 
(BOOL- pointingDeviceCancelledEvent: [implementation]
 
(BOOL- scrollWheelEvent:fromPoint:toPoint: [implementation]
 
Images
(nonnull CPTNativeImage *) - imageOfLayer
 Gets an image of the layer contents. More...
 
- Public Instance Methods inherited from CALayer
(BOOL- containsPoint:
 
(void) - drawInContext:
 
(id- init
 
(id- initWithLayer
 
(void) - layoutSublayers
 
(void) - setNeedsDisplay
 
(void) - setNeedsDisplayInRect:
 
(void) - setNeedsLayout
 
- Public Instance Methods inherited from NSObject
(Class- classForCoder
 
(id- copy
 
(void) - dealloc
 
(void) - finalize
 
(id- init
 
(id- mutableCopy
 
- Public Instance Methods inherited from <NSObject>
(NSString *) - description
 
(NSUInteger- hash
 
(BOOL- isEqual:
 
- Public Instance Methods inherited from <NSKeyValueBindingCreation>
(NSArray *) - exposedBindings
 
(Class- valueClassForBinding:
 
(void) - bind:toObject:withKeyPath:options:
 
(NSArray *) - optionDescriptionsForBinding:
 
(NSDictionary *) - infoForBinding:
 
(void) - unbind:
 
- Public Instance Methods inherited from <NSCoding>
(id- initWithCoder:
 
(void) - encodeWithCoder:
 
- Public Instance Methods inherited from <CPTResponder>
(BOOL- pointingDeviceDownEvent:atPoint:
 (Required) Informs the receiver that the user has pressed the mouse button. More...
 
(BOOL- pointingDeviceUpEvent:atPoint:
 (Required) Informs the receiver that the user has released the mouse button. More...
 
(BOOL- pointingDeviceDraggedEvent:atPoint:
 (Required) Informs the receiver that the user has moved the mouse with the button pressed. More...
 
(BOOL- pointingDeviceCancelledEvent:
 (Required) Informs the receiver that tracking of mouse moves has been cancelled for any reason. More...
 
(BOOL- scrollWheelEvent:fromPoint:toPoint:
 (Required) Informs the receiver that the user has moved the scroll wheel. More...
 

Properties

Graph
CPTGraphgraph
 The graph for the layer. More...
 
Padding
CGFloat paddingLeft
 Amount to inset the left side of each sublayer. More...
 
CGFloat paddingTop
 Amount to inset the top of each sublayer. More...
 
CGFloat paddingRight
 Amount to inset the right side of each sublayer. More...
 
CGFloat paddingBottom
 Amount to inset the bottom of each sublayer. More...
 
Identification
id< NSCopying, NSCoding, NSObjectidentifier
 An object used to identify the layer in collections. More...
 
- Properties inherited from CALayer
CGPoint anchorPoint
 
CGRect bounds
 
CGFloat contentsScale
 
CGFloat cornerRadius
 
id delegate
 
CGRect frame
 
BOOL masksToBounds
 
BOOL needsDisplayOnBoundsChange
 
BOOL opacity
 
BOOL opaque
 
- Properties inherited from <CAMediaTiming>
BOOL autoreverses
 
CFTimeInterval beginTime
 
CFTimeInterval duration
 
NSStringfillMode
 
float repeatCount
 
id repeatDuration
 
float speed
 
CFTimeInterval timeOffset
 

Drawing

CGFloat contentsScale
 The scale factor applied to the layer. More...
 
BOOL useFastRendering
 If YES, subclasses should optimize their drawing for speed over precision. More...
 
CPTShadowshadow
 The shadow drawn under the layer content. If nil (the default), no shadow is drawn. More...
 
CGSize shadowMargin
 The maximum margin size needed to fully enclose the layer shadow. More...
 
(void) - setNeedsDisplayAllLayers
 Recursively marks this layer and all sublayers as needing to be redrawn. More...
 
(void) - renderAsVectorInContext:
 Draws layer content into the provided graphics context. More...
 
(void) - recursivelyRenderInContext:
 Draws layer content and the content of all sublayers into the provided graphics context. More...
 
(void) - layoutAndRenderInContext:
 Updates the layer layout if needed and then draws layer content and the content of all sublayers into the provided graphics context. More...
 
(nonnull NSData *) - dataForPDFRepresentationOfLayer
 Draws layer content and the content of all sublayers into a PDF document. More...
 

Masking

BOOL masksToBorder
 If YES, a sublayer mask is applied to clip sublayer content to the inside of the border. More...
 
CGPathRef outerBorderPath
 A drawing path that encompasses the outer boundary of the layer border. More...
 
CGPathRef innerBorderPath
 A drawing path that encompasses the inner boundary of the layer border. More...
 
CGPathRef maskingPath
 A drawing path that encompasses the layer content including any borders. Set to NULL when no masking is desired. More...
 
CGPathRef sublayerMaskingPath
 A drawing path that encompasses the layer content excluding any borders. Set to NULL when no masking is desired. More...
 
(void) - applySublayerMaskToContext:forSublayer:withOffset:
 Recursively sets the clipping path of the given graphics context to the sublayer masking paths of its superlayers. More...
 
(void) - applyMaskToContext:
 Sets the clipping path of the given graphics context to mask the content. More...
 

Layout

CPTSublayerSetsublayersExcludedFromAutomaticLayout
 A set of sublayers that should be excluded from the automatic sublayer layout. More...
 
(void) - pixelAlign
 Align the receiver’s position with pixel boundaries. More...
 
(void) - sublayerMarginLeft:top:right:bottom:
 Returns the margins that should be left between the bounds of the receiver and all sublayers. More...
 
(void) - layoutSublayers [implementation]
 Updates the layout of all sublayers. Sublayers fill the super layer’s bounds minus any padding. More...
 

Additional Inherited Members

- Public Class Methods inherited from CALayer
(id+ layer
 
- Public Class Methods inherited from NSObject
(id+ alloc
 
(Class+ class
 
(void) + initialize
 
(void) + load
 
(id+ new
 
- Public Class Methods inherited from <NSKeyValueBindingCreation>
(void) + exposeBinding:
 
- Public Class Methods inherited from <NSSecureCoding>
(BOOL+ supportsSecureCoding:
 

Detailed Description

Base class for all Core Animation layers in Core Plot.

Unless useFastRendering is YES, all drawing is done in a way that preserves the drawing vectors. Sublayers are arranged automatically to fill the layer’s bounds, minus any padding. Default animations for changes in position, bounds, and sublayers are turned off. The default layer is not opaque and does not mask to bounds.

Method Documentation

◆ applyMaskToContext:

- (void) applyMaskToContext: (nonnull CGContextRef context

Sets the clipping path of the given graphics context to mask the content.

The clipping path is built by recursively climbing the layer tree and combining the sublayer masks from each super layer. The tree traversal stops when a layer is encountered that is not a CPTLayer.

Parameters
contextThe graphics context to clip.

◆ applySublayerMaskToContext:forSublayer:withOffset:

- (void) applySublayerMaskToContext: (nonnull CGContextRef context
forSublayer: (nonnull CPTLayer *)  sublayer
withOffset: (CGPoint offset 

Recursively sets the clipping path of the given graphics context to the sublayer masking paths of its superlayers.

The clipping path is built by recursively climbing the layer tree and combining the sublayer masks from each super layer. The tree traversal stops when a layer is encountered that is not a CPTLayer.

Parameters
contextThe graphics context to clip.
sublayerThe sublayer that called this method.
offsetThe cumulative position offset between the receiver and the first layer in the recursive calling chain.

◆ dataForPDFRepresentationOfLayer

- (nonnull NSData *) dataForPDFRepresentationOfLayer

Draws layer content and the content of all sublayers into a PDF document.

Returns
PDF representation of the layer content.

◆ imageOfLayer

- (nonnull CPTNativeImage *) imageOfLayer

Gets an image of the layer contents.

Returns
A native image representation of the layer content.

Provided by category CPTLayer(CPTPlatformSpecificLayerExtensions).

◆ init

- (nonnull instancetype) init
implementation

Initializes a newly allocated CPTLayer object with an empty frame rectangle.

Returns
The initialized object.

◆ initWithCoder:

- (nullable instancetype) initWithCoder: (nonnull NSCoder *)  coder

Returns an object initialized from data in a given unarchiver.

Parameters
coderAn unarchiver object.
Returns
An object initialized from data in a given unarchiver.

Reimplemented in CPTTextLayer, and CPTXYGraph.

◆ initWithFrame:

- (nonnull instancetype) initWithFrame: (CGRect newFrame

Initializes a newly allocated CPTLayer object with the provided frame rectangle.

This is the designated initializer. The initialized layer will have the following properties:

Parameters
newFrameThe frame rectangle.
Returns
The initialized object.

Reimplemented in CPTPieChart, CPTPlot, CPTTradingRangePlot, CPTRangePlot, CPTBarPlot, CPTScatterPlot, CPTGraph, CPTLegend, CPTPlotArea, CPTAnnotationHostLayer, CPTAxis, CPTAxisSet, CPTBorderedLayer, CPTGridLineGroup, CPTGridLines, CPTPlotAreaFrame, CPTXYAxis, CPTXYAxisSet, and CPTXYGraph.

◆ initWithLayer:

- (nonnull instancetype) initWithLayer: (nonnull id layer

Override to copy or initialize custom fields of the specified layer.

Parameters
layerThe layer from which custom fields should be copied.
Returns
A layer instance with any custom instance variables copied from layer.

Reimplemented in CPTTextLayer, and CPTXYGraph.

◆ layoutAndRenderInContext:

- (void) layoutAndRenderInContext: (nonnull CGContextRef context

Updates the layer layout if needed and then draws layer content and the content of all sublayers into the provided graphics context.

Parameters
contextThe graphics context to draw into.

◆ layoutSublayers

- (void) layoutSublayers
implementation

Updates the layout of all sublayers. Sublayers fill the super layer’s bounds minus any padding.

This is where we do our custom replacement for the Mac-only layout manager and autoresizing mask. Subclasses should override this method to provide a different layout of their own sublayers.

Reimplemented in CPTPlotArea, CPTAxis, CPTAxisLabelGroup, and CPTXYAxisSet.

◆ logLayers

- (void) logLayers

Logs this layer and all of its sublayers.

◆ pixelAlign

- (void) pixelAlign

Align the receiver’s position with pixel boundaries.

◆ pointingDeviceCancelledEvent:

- (BOOL) pointingDeviceCancelledEvent: (nonnull CPTNativeEvent *__unused)  event
implementation

◆ pointingDeviceDownEvent:atPoint:

- (BOOL) pointingDeviceDownEvent: (nonnull CPTNativeEvent *__unused)  event
atPoint: (CGPoint __unused)  interactionPoint 
implementation

◆ pointingDeviceDraggedEvent:atPoint:

- (BOOL) pointingDeviceDraggedEvent: (nonnull CPTNativeEvent *__unused)  event
atPoint: (CGPoint __unused)  interactionPoint 
implementation

◆ pointingDeviceUpEvent:atPoint:

- (BOOL) pointingDeviceUpEvent: (nonnull CPTNativeEvent *__unused)  event
atPoint: (CGPoint __unused)  interactionPoint 
implementation

◆ recursivelyRenderInContext:

- (void) recursivelyRenderInContext: (nonnull CGContextRef context

Draws layer content and the content of all sublayers into the provided graphics context.

Parameters
contextThe graphics context to draw into.

◆ renderAsVectorInContext:

- (void) renderAsVectorInContext: (nonnull CGContextRef context

Draws layer content into the provided graphics context.

This method replaces the CALayer -drawInContext: method to ensure that layer content is always drawn as vectors and objects rather than as a cached bit-mapped image representation. Subclasses should do all drawing here and must call super to set up the clipping path.

Parameters
contextThe graphics context to draw into.

◆ scrollWheelEvent:fromPoint:toPoint:

- (BOOL) scrollWheelEvent: (nonnull CPTNativeEvent *__unused)  event
fromPoint: (CGPoint __unused)  fromPoint
toPoint: (CGPoint __unused)  toPoint 
implementation

◆ setNeedsDisplayAllLayers

- (void) setNeedsDisplayAllLayers

Recursively marks this layer and all sublayers as needing to be redrawn.

◆ sublayerMarginLeft:top:right:bottom:

- (void) sublayerMarginLeft: (nonnull CGFloat *)  left
top: (nonnull CGFloat *)  top
right: (nonnull CGFloat *)  right
bottom: (nonnull CGFloat *)  bottom 

Returns the margins that should be left between the bounds of the receiver and all sublayers.

Parameters
leftThe left margin.
topThe top margin.
rightThe right margin.
bottomThe bottom margin.

Reimplemented in CPTBorderedLayer.

Property Documentation

◆ contentsScale

- (CGFloat) contentsScale
readwriteatomicassign

The scale factor applied to the layer.

◆ graph

- (nullable CPTGraph *) graph
readwritenonatomicweak

The graph for the layer.

◆ identifier

- (nullable id< NSCopying, NSCoding, NSObject >) identifier
readwritenonatomiccopy

An object used to identify the layer in collections.

◆ innerBorderPath

- (nullable CGPathRef) innerBorderPath
readwritenonatomicassign

A drawing path that encompasses the inner boundary of the layer border.

◆ maskingPath

- (nullable CGPathRef) maskingPath
readnonatomicassign

A drawing path that encompasses the layer content including any borders. Set to NULL when no masking is desired.

This path defines the outline of the layer and is used to mask all drawing. Set to NULL when no masking is desired. The caller must not release the path returned by this property.

◆ masksToBorder

- (BOOL) masksToBorder
readwritenonatomicassign

If YES, a sublayer mask is applied to clip sublayer content to the inside of the border.

◆ outerBorderPath

- (nullable CGPathRef) outerBorderPath
readwritenonatomicassign

A drawing path that encompasses the outer boundary of the layer border.

◆ paddingBottom

- (CGFloat) paddingBottom
readwritenonatomicassign

Amount to inset the bottom of each sublayer.

◆ paddingLeft

- (CGFloat) paddingLeft
readwritenonatomicassign

Amount to inset the left side of each sublayer.

◆ paddingRight

- (CGFloat) paddingRight
readwritenonatomicassign

Amount to inset the right side of each sublayer.

◆ paddingTop

- (CGFloat) paddingTop
readwritenonatomicassign

Amount to inset the top of each sublayer.

◆ shadow

- (CPTShadow *) shadow
readwritenonatomiccopy

The shadow drawn under the layer content. If nil (the default), no shadow is drawn.

◆ shadowMargin

- (CGSize) shadowMargin
readnonatomicassign

The maximum margin size needed to fully enclose the layer shadow.

◆ sublayerMaskingPath

- (nullable CGPathRef) sublayerMaskingPath
readnonatomicassign

A drawing path that encompasses the layer content excluding any borders. Set to NULL when no masking is desired.

This path defines the outline of the part of the layer where sublayers should draw and is used to mask all sublayer drawing. Set to NULL when no masking is desired. The caller must not release the path returned by this property.

◆ sublayersExcludedFromAutomaticLayout

- (nullable CPTSublayerSet *) sublayersExcludedFromAutomaticLayout
readnonatomicassign

A set of sublayers that should be excluded from the automatic sublayer layout.

◆ useFastRendering

- (BOOL) useFastRendering
readnonatomicassign

If YES, subclasses should optimize their drawing for speed over precision.


The documentation for this class was generated from the following files: