diff --git a/Required packages/Cursorbar/+graphics/+internal/CursorbarContainer.m b/Required packages/Cursorbar/+graphics/+internal/CursorbarContainer.m deleted file mode 100644 index 5aa1483..0000000 --- a/Required packages/Cursorbar/+graphics/+internal/CursorbarContainer.m +++ /dev/null @@ -1,261 +0,0 @@ -classdef (ConstructOnLoad=true) CursorbarContainer < handle - % CursorbarContainer Container class for a graphics.Cursorbar objects. - % - % Container class for graphics.Cursorbar objects, where de-serialization - % restores the links. - % - % MCOS graphics cannot rely on custom machinery in load to restore - % Cursorbar listeners. Instead, create a CursorbarContainer to wrap the - % Cursorbar, which will restore the listeners when it is de-serialized. - % - % CursorbarContainer requires the new MATLAB graphics system that was - % introduced in R2014b - % - % Usage: - % CursorbarContainer() - Creates a CursorbarContainer - % without linked Cursorbar handle. - % CursorbarContainer(hCursorbar) - Creates a CursorbarContainer for - % the specified Cursorbar handle. - % - % CursorbarContainer Constructor: - % CursorbarContainer - CursorbarContainer constructor. - % - % CursorbarContainer Properties: - % Key - The key to the stored application data - % Target - Targets of the Cursorbar - % PropertyValues - Property-value pairs of the Cursorbar - % CursorbarHandle - The Cursorbar handle - % - % CursorbarContainer Methods: - % saveobj - Serialize the Target and PropertyValues. - % hasCursorbar - Checks if the CursorbarContainer contains - % the current cursorbar. - % - % CursorbarContainer Static Methods: - % loadobj - Restore the Cursorbar listeners on - % de-serialization. - % getCursorbars - Get all the cursorbars from the current - % figure. - % getContainers - Get all the containers from the current - % figure. - % - % Inherited handle Methods: - % addlistener - Add listener for event. - % delete - Delete a handle object. - % eq - Test handle equality. - % findobj - Find objects with specified property - % values. - % findprop - Find property of MATLAB handle object. - % ge - Greater than or equal relation. - % gt - Greater than relation. - % isvalid - Test handle validity. - % le - Less than or equal relation for handles. - % lt - Less than relation for handles. - % ne - Not equal relation for handles. - % notify - Notify listeners of event. - % - % Inherited handle Events: - % ObjectBeingDestroyed - Notifies listeners that a particular - % object has been destroyed. - % Web: - % Undocumented Matlab: Undocumented cursorbar object. - % - % See also: Cursorbar. - % - % Thanks to Yaroslav Don for his assistance in updating cursorbar for - % MATLAB Graphics and for his contribution of new functionality. - - % This class is based on linkaxes and matlab.graphics.internal.LinkAxes. - - % Copyright 2016 The MathWorks, Inc. - - - %% Properties - properties (Constant) - Key = 'GraphicsCursorbarContainer' % The key to the stored application data - end - - % -------------------------------------- - - properties (SetAccess = 'protected') - Target@handle % Targets of the Cursorbar - PropertyValues % Property-value pairs of the Cursorbar - end - - % -------------------------------------- - - properties (Transient) - CursorbarHandle@graphics.Cursorbar scalar % The Cursorbar handle - end - - properties (SetAccess = 'protected', Hidden) - PeerContainer@graphics.internal.CursorbarContainer % A handle to a container's Peer, if Cursorbar also has one - end - - %% Main Methods - - methods - - function hThis = CursorbarContainer(hCursorbar) - % CURSORBARCONTAINER A CursorbarContainer constructor. - % - % See also: CursorbarContainer. - - % Check MATLAB Graphics system version - if verLessThan('matlab','8.4.0') - error('graphics:internal:CursorbarContainer:CursorbarContainer:oldVersion', ... - 'CursorbarContainer requires the new MATLAB graphics system that was introduced in R2014b.'); - end - - % call handle constructor - hThis = hThis@handle; - - % set up the Cursorbar handles - % each container can hold only a single Cursorbar - if nargin==1 - validateattributes(hCursorbar,{'graphics.Cursorbar'},{'nonempty'}); - % - for i=numel(hCursorbar):-1:1 - hThis(i).CursorbarHandle = hCursorbar(i); - end - reshape(hThis,size(hCursorbar)); - end - end - - % -------------------------------------- - - function hThis = saveobj(hThis) - % SAVEOBJ Serialize the Target and PropertyValues. - - % set the target and the property values right before serialization; - if ~isempty(hThis.CursorbarHandle) - hThis.Target = hThis.CursorbarHandle.Target; - hThis.PropertyValues = { ... - 'BottomMarker', hThis.CursorbarHandle.BottomMarker, ... - 'CreateFcn', hThis.CursorbarHandle.CreateFcn, ... - 'CursorLineColor', hThis.CursorbarHandle.CursorLineColor, ... - 'CursorLineStyle', hThis.CursorbarHandle.CursorLineStyle, ... - 'CursorLineWidth', hThis.CursorbarHandle.CursorLineWidth, ... - 'DeleteFcn', hThis.CursorbarHandle.DeleteFcn, ... - 'DisplayName', hThis.CursorbarHandle.DisplayName, ... - 'FigureCallbacks', hThis.CursorbarHandle.FigureCallbacks, ... - 'HitTest', hThis.CursorbarHandle.HitTest, ... - 'Interruptible', hThis.CursorbarHandle.Interruptible, ... - 'Location', hThis.CursorbarHandle.Location, ... - 'Orientation', hThis.CursorbarHandle.Orientation, ... - 'Parent', hThis.CursorbarHandle.Parent, ... - 'Position', hThis.CursorbarHandle.Position, ... - 'SelectionHighlight', hThis.CursorbarHandle.SelectionHighlight, ... - 'ShowText', hThis.CursorbarHandle.ShowText, ... - 'Tag', hThis.CursorbarHandle.Tag, ... - 'TargetIntersections', hThis.CursorbarHandle.TargetIntersections, ... - 'TargetMarkerEdgeColor', hThis.CursorbarHandle.TargetMarkerEdgeColor, ... - 'TargetMarkerFaceColor', hThis.CursorbarHandle.TargetMarkerFaceColor, ... - 'TargetMarkerSize', hThis.CursorbarHandle.TargetMarkerSize, ... - 'TargetMarkerStyle', hThis.CursorbarHandle.TargetMarkerStyle, ... - 'TextDescription', hThis.CursorbarHandle.TextDescription, ... - 'TopMarker', hThis.CursorbarHandle.TopMarker, ... - 'UserData', hThis.CursorbarHandle.UserData, ... - 'Visible', hThis.CursorbarHandle.Visible ... - }; - end - end - - end - - % -------------------------------------- - - methods (Static = true) - function hThis = loadobj(hThis) - % LOADOBJ Restore the Cursorbar listeners on de-serialization. - - % create a new cursorbar if the target is valid - if ~isempty(hThis.Target) && all(isgraphics(hThis.Target)) && ~isempty(hThis.PropertyValues) - - % construct a new Cursorbar - hThat = hThis.PeerContainer; - if ~isempty(hThat) && ~isempty(hThat.CursorbarHandle) - % there is a valid Peer: create a Crossbar and set its values - hThis.CursorbarHandle = drawCrossbar(hThat.CursorbarHandle, hThis.PropertyValues{:}); - else - % create a new Cursorbar and set its values - hThis.CursorbarHandle = graphics.Cursorbar(hThis.Target, hThis.PropertyValues{:}); - end - end - - end - end - - %% Auxiliary Methods - - methods - - function tf = hasCursorbar(hThis,hCursorbar) - % HASCURSORBAR Checks if the CursorbarContainer contains the current cursorbar. - validateattributes(hCursorbar,{'graphics.Cursorbar'},{'scalar'}); - - % compare - tf = [hThis.CursorbarHandle]==hCursorbar; - tf = reshape(tf,size(hThis)); - end - - end - % -------------------------------------- - - methods (Static) - function hCursorbars = getCursorbars(hFig) - % GETCURSORBARS Get all the cursorbars from the current figure. - assert(ishghandle(hFig) && strcmp(hFig.Type,'figure'), ... - 'graphics:internal:CursorbarContainer:getCursorbars:notAFigure', ... - 'Input must be a valid figure handle.'); - % - hContainers = CursorbarContainer.getContainers(hFig); - if ~isempty(hContainers) - hCursorbars = [hContainers.CursorbarHandle]; - else - hCursorbars = graphics.GraphicsPlaceholder.empty; - end - end - - % -------------------------------------- - - function hContainers = getContainers(hFig) - % GETCONTAINERS Get all the containers from the current figure. - assert(ishghandle(hFig) && strcmp(hFig.Type,'figure'), ... - 'graphics:internal:CursorbarContainer:getContainers:notAFigure', ... - 'Input must be a valid figure handle.'); - % - hContainers = getappdata(hFig, graphics.internal.CursorbarContainer.Key); - end - end - - %% Protected Methods - - methods (Access = {?graphics.Cursorbar, ?graphics.internal.CursorbarContainer}) - - function setPeer(hThis,hThat) - % SETPEER Sets peer container handle. - - % set only the handle links - % Cursorbar is responsible for all the listener mechanisms - validateattributes(hThis,{'graphics.internal.CursorbarContainer'},{'scalar'}); - validateattributes(hThat,{'graphics.internal.CursorbarContainer'},{'scalar'}); - hThis.PeerContainer = hThat; - hThat.PeerContainer = hThis; - end - - % -------------------------------------- - - function removePeer(hThis) - % REMOVEPEER Removes peer container handle. - - % remove only the handle links - % Cursorbar is responsible for all the listener mechanisms - hThis.PeerContainer.PeerContainer = graphics.internal.CursorbarContainer.empty; - hThis.PeerContainer = graphics.internal.CursorbarContainer.empty; - end - - end - - -end diff --git a/Required packages/Cursorbar/+graphics/@Cursorbar/Cursorbar.m b/Required packages/Cursorbar/+graphics/@Cursorbar/Cursorbar.m deleted file mode 100644 index 6707ac4..0000000 --- a/Required packages/Cursorbar/+graphics/@Cursorbar/Cursorbar.m +++ /dev/null @@ -1,1677 +0,0 @@ -classdef Cursorbar < graphics.Graphics & matlab.mixin.SetGet - % CURSORBAR Creates a cursor line attached to an axes or lines. - % - % The Cursorbar can be dragged interactively across the axes. If - % attached to a plot, the cursor points are updated as well. The - % Cursorbar can be either horizontal or vertical. - % - % Cursorbar requires the new MATLAB graphics system that was - % introduced in R2014b - % - % Usage: - % graphics.Cursorbar(hTarget) - Creates a Cursorbar on a target - % Axes or Chart. - % graphics.Cursorbar(hTarget, ...) - Creates a Cursorbar on a target - % Axes or Chart with additional - % property-value pairs. - % Example: - % x = linspace(0,20,101); - % y = sin(x); - % % - % h = plot(x,y); - % graphics.Cursorbar(h); - % - % Cursorbar Constructor: - % Cursorbar - Cursorbar constructor - % - % Cursorbar Properties: - % Annotation - Legend icon display style - % BeingDeleted - Deletion status of group - % BottomHandle - Handle to the bottom (left) edge marker - % BottomMarker - Top (right) edge marker shape - % BusyAction - Callback queuing - % ButtonDownFcn - Mouse-click callback - % Children - Children of Cursorbar - % CreateFcn - Creation callback - % CursorLineColor - Cursor line's color - % CursorLineStyle - Cursor line's style - % CursorLineWidth - Cursor line's width - % CursorbarOrientation - Permitted Cursorbar Orientation options - % CursorbarShowText - Permitted Cursorbar ShowText options - % DataCursorHandle - Handle to the Data Cursor - % DeleteFcn - Deletion callback - % DisplayHandle - Display text handle - % DisplayName - Text used by the legend - % FigureCallbacks - Additional Figure callbacks - % HandleVisibility - Visibility of object handle {'on','off'} - % HitTest - Response to mouse clicks captured by - % children - % Interruptible - Callback interruption - % Location - Location is a single value which is used - % to set the Position, based on the - % Orientation - % Orientation - Orientation of Cursorbar - % {'vertical','horizontal'} - % Parent - Parent of Cursorbar - % PermittedChartTargets - Classes of permitted targets - % PickableParts - Children that can capture mouse clicks - % Position - Position is used to set the location of - % main marker for the intersection - % Selected - Selection state - % SelectionHighlight - Display of selection handles when - % selected - % ShowText - Showing the Cursorbar Text {'on','off'} - % Tag - Tag to associate with the Cursorbar - % Target - Handle to the Target - % TargetIntersections - How many intersections are plotted - % {'multiple','single'} - % TargetMarkerEdgeColor - Target's marker outline color - % TargetMarkerFaceColor - Target's marker fill color - % TargetMarkerSize - Target's marker size - % TargetMarkerStyle - Target's marker style - % TextDescription - Type of text description - % {'short','long'} - % TopHandle - Handle to the top (right) edge marker - % TopMarker - Top (right) edge marker shape - % Type - Type of graphics object - % UIContextMenu - Context menu - % UpdateFcn - Update callback - % UserData - Data to associate with the Cursorbar - % object - % Visible - Visibility of Cursorbar {'on','off'} - % - % Cursorbar Methods: - % drawCrossbar - Draws a linked perpendicular bar - % duplicate - Duplicate the cursorbar to an identical - % one - % getCursorInfo - Get DataCursor info from Cursorbar - % getMarkerLocations - Return x,y position of the Cursorbar's - % intersection markers - % ishandle - Checks on self if valid handle - % isTargetAxes - Is the Target an axes - % isTargetChart - Is the Target a permitted chart object - % - % Inherited matlab.mixin.SetGet Methods: - % set - Set MATLAB object property values. - % get - Get MATLAB object properties. - % setdisp - Specialized MATLAB object property - % display. - % getdisp - Specialized MATLAB object property - % display. - % - % Inherited handle Methods: - % addlistener - Add listener for event. - % delete - Delete a handle object. - % eq - Test handle equality. - % findobj - Find objects with specified property - % values. - % findprop - Find property of MATLAB handle object. - % ge - Greater than or equal relation. - % gt - Greater than relation. - % isvalid - Test handle validity. - % le - Less than or equal relation for handles. - % lt - Less than relation for handles. - % ne - Not equal relation for handles. - % notify - Notify listeners of event. - % - % Inherited matlab.mixin.CustomDisplay Methods: - % details - Fully detailed formal object display. - % disp - Simple informal object display. - % display - Print variable name and display object. - % - % Inherited matlab.mixin.Heterogeneous Methods: - % cat - Concatenation for heterogeneous arrays. - % horzcat - Horizontal concatenation for - % heterogeneous arrays. - % vertcat - Vertical concatenation for - % heterogeneous arrays. - % - % Cursorbar Events: - % BeginDrag - Notifies listeners that the dragging of - % the Cursorbar has begun. - % EndDrag - Notifies listeners that the dragging of - % the Cursorbar has ended. - % UpdateCursorBar - Notifies listeners that the Cursorbar - % has been updated. - % - % Inherited handle Events: - % ObjectBeingDestroyed - Notifies listeners that a particular - % object has been destroyed. - % Web: - % Undocumented Matlab: Undocumented cursorbar object. - % - % See also: graphics.Cursorbar.Cursorbar, - % graphics.Cursorbar.getCursorInfo, - % graphics.Cursorbar.getMarkerLocations, - % graphics.Cursorbar.isTargetAxes, - % graphics.Cursorbar.isTargetChart, - % . - % cursorbar, crossbar, - % graphics.Cursorbar.duplicate, - % graphics.Cursorbar.drawCrossbar, - % . - % hobjects, - % graphics.Graphics, - % graphics.GraphicsPlaceholder, - % graphics.internal.CursorbarContainer. - % - % Thanks to Yaroslav Don for his assistance in updating cursorbar for - % MATLAB Graphics and for his contribution of new functionality. - - % Copyright 2003-2016 The MathWorks, Inc. - - % Change Log: - % 13 Feb 2015: First version posted on the MathWorks file exchange: - % Cursorbar - File Exchange - MATLAB Central. - % 14 May 2015: Added a custom display; added logarithmic scale support; minor bug fixes. - % XX Jan 2016: Added saving and loading functionality; added empty allocation; - % improved construction time; improved stability; minor bug fixes. - - %% Public Properties - - properties - Parent@handle % Parent of Cursorbar - - % Line objects used to create larger drag surfaces for cursor line - - DisplayHandle@handle % Display text handle - TopHandle@handle % Handle to the top (right) edge marker - BottomHandle@handle % Handle to the bottom (left) edge marker - - % Callbacks - - CreateFcn = '' % Creation callback - DeleteFcn = '' % Deletion callback - UpdateFcn = '' % Update callback - FigureCallbacks % Additional Figure callbacks - - % Identifiers - - Tag@char = '' % Tag to associate with the Cursorbar - UserData % Data to associate with the Cursorbar object - end - % -------------------------------------- - properties (Dependent) - - % Identifiers - - Annotation % Legend icon display style - DisplayName % Text used by the legend - - % Parent/Child - - Children % Children of Cursorbar - HandleVisibility % Visibility of object handle - - % Interactive Control - - Selected % Selection state - SelectionHighlight % Display of selection handles when selected - - % Callback Execution Control - - PickableParts % Children that can capture mouse clicks - HitTest % Response to mouse clicks captured by children - Interruptible % Callback interruption - BusyAction % Callback queuing - - % Creation and Deletion Control - - BeingDeleted % Deletion status of group - end - % -------------------------------------- - properties (SetObservable) - Location@double = 0 % Location is a single value which is used to set the Position, based on the Orientation - Position@double % Position is used to set the location of main marker for the intersection - - % Handles - - Target@handle % Handle to the Target - DataCursorHandle@handle % Handle to the Data Cursor - UIContextMenu@handle % Context menu - - % Cursor styles - - CursorLineColor@double = [0 0 0] % Cursor line's color - CursorLineStyle@char = '-' % Cursor line's style - CursorLineWidth@double = 2 % Cursor line's width - - % Marker styles - - TopMarker@char = 'v' % Top (right) edge marker shape - BottomMarker@char = '^' % Top (right) edge marker shape - TargetMarkerStyle@char = 'square' % Target's marker style - TargetMarkerSize@double= 8 % Target's marker size - TargetMarkerEdgeColor = [0 0 0] % Target's marker outline color - TargetMarkerFaceColor = 'none' % Target's marker fill color - end - % -------------------------------------- - properties (SetAccess=protected, SetObservable) - ButtonDownFcn % Mouse-click callback - end - % -------------------------------------- - properties (SetAccess=immutable) - Type = 'Cursorbar' % Type of graphics object - end - - % ============================================================= % - - %% Enumeration Properties - - properties (Constant) - CursorbarShowText = {'on','off'} % Permitted Cursorbar ShowText options - CursorbarOrientation = {'vertical','horizontal'} % Permitted Cursorbar Orientation options - CursorbarTargetIntersections = {'multiple','single'} % Permitted Cursorbar TargetIntersections options - CursorbarTextDescription = {'short','long'} % Permitted Cursorbar TextDescription options - - % Classes of permitted targets - PermittedChartTargets = { - 'matlab.graphics.chart.primitive.Line' - 'matlab.graphics.chart.primitive.Surface' - 'matlab.graphics.chart.primitive.Area' - 'matlab.graphics.chart.primitive.Bar' - 'matlab.graphics.chart.primitive.Contour' - 'matlab.graphics.chart.primitive.Histogram' - 'matlab.graphics.chart.primitive.Scatter' - 'matlab.graphics.chart.primitive.Stair' - 'matlab.graphics.chart.primitive.Stem' - 'matlab.graphics.primitive.Image' - 'matlab.graphics.primitive.Line' - 'matlab.graphics.primitive.Patch' - 'matlab.graphics.primitive.Surface' - } - end - % -------------------------------------- - properties (SetObservable) - ShowText@char = 'on' % Showing the Cursorbar Text {'on','off'} - Orientation@char = 'vertical' % Orientation of Cursorbar {'vertical','horizontal'} - Visible@char = 'on' % Visibility of Cursorbar {'on','off'} - TargetIntersections@char = 'multiple' % How many intersections are plotted {'multiple','single'} - TextDescription@char = 'short' % Type of text description {'short','long'} - end - - % ============================================================= % - - %% Hidden Properties - - properties (Hidden) - TargetXData@double % XData of Target - TargetYData@double % YData of Target - TargetZData@double % ZData of Target - TargetNData@double % NData of Target (which Target number out of several) - - CursorLineHandle@handle % Line object used to represent the cursor bar - TargetMarkerHandle@handle % Line objects used to represent the intersection points with the Target - end - % -------------------------------------- - properties (Hidden, SetAccess=protected) - DataCursorDummyTargetHandle@handle % Line object placeholder for the DataCursor - - SelfListenerHandles@handle % Self listeners - TargetListenerHandles@handle % Store listeners for Target - ExternalListenerHandles@handle % Store other external listeners - - PeerHandle@graphics.Cursorbar % Handle to another Cursorbar object - Container@graphics.internal.CursorbarContainer % Handle to the Cursorbar's container - end - % -------------------------------------- - properties (Hidden, GetAccess=public, SetAccess=immutable) - GroupHandle % The group containing all the objects - end - properties (GetAccess=protected, SetAccess=immutable) - ObjectBeingCreated = true % is the object being created - end - % -------------------------------------- - properties (Hidden, Constant) - % Classes of permitted 2D targets - Permitted2DTargets = { - 'matlab.graphics.chart.primitive.Surface' - 'matlab.graphics.chart.primitive.Area' - 'matlab.graphics.chart.primitive.Contour' - 'matlab.graphics.primitive.Image' - 'matlab.graphics.primitive.Patch' - 'matlab.graphics.primitive.Surface' - } - end - - % ============================================================= % - - %% Events - - events - BeginDrag % Notifies listeners that the dragging of the Cursorbar has begun. - EndDrag % Notifies listeners that the dragging of the Cursorbar has ended. - UpdateCursorBar % Notifies listeners that the Cursorbar has been updated. - end - - % ============================================================= % - - %% Public methods - - % constructor - methods - function hThis = Cursorbar(hTarget,varargin) - % CURSORBAR A Cursorbar constructor - % - % See also: Cursorbar. - - % Check MATLAB Graphics system version - if verLessThan('matlab','8.4.0') - error('graphics:Cursorbar:Cursorbar:oldVersion', ... - 'Cursorbar requires the new MATLAB graphics system that was introduced in R2014b.'); - end - - % input error check - narginchk(1,Inf); - - % validate correct property-value pair arguments - assert( mod(length(varargin),2)==0 && iscellstr(varargin(1:2:end)), ... - 'graphics:Cursorbar:BadParamValuePairs', ... - 'Invalid parameter/value pair arguments.') - - % Initialize Cursorbar - - % force hTarget to column vector of handles - hTarget = handle(hTarget(:)); - - % get Cursorbar Parent and Target - % don't set yet: this is to prevent creation of an empty - % figure when its HandleVisibility is off. - if numel(hTarget) == 1 - if all(hThis.isTargetChart(hTarget)) - hParent = handle(ancestor(hTarget,'axes')); - elseif isa(hTarget,'matlab.graphics.axis.Axes') - hParent = handle(hTarget); - else - % delete Cursorbar and error if Target isn't a line or axes - delete(hThis); - error(message('MATLAB:cursorbar:InvalidTarget')); - end - else - if all(hThis.isTargetChart(hTarget)) - hParent = handle(ancestor(hTarget(1),'axes')); - else - % delete Cursorbar if Target isn't a line or axes - delete(hThis); - error(message('MATLAB:cursorbar:InvalidTarget')); - end - end - - % set the parent & target property - set(hThis,'Parent',hParent,'Target',hTarget); - - % set GroupHandle - hThis.GroupHandle = hggroup('Parent',hParent); - hThis.GroupHandle.Visible = 'on'; - hThis.GroupHandle.PickableParts = 'visible'; - hThis.GroupHandle.HandleVisibility = 'off'; - hThis.GroupHandle.Tag = 'CursorbarGroup'; - hThis.GroupHandle.DisplayName = 'Cursorbar'; - hThis.GroupHandle.DeleteFcn = @(~,~)delete(hThis); - hThis.GroupHandle.Serializable = 'off'; % assert that none of the child handles is saved - - % add self property listeners - localAddSelfListeners(hThis); - - % add listeners for the target and its ancestors - localAddTargetListeners(hThis); - - % create Cursorbar and marker line - hLines = localCreateNewCursorBarLines(hThis); - set(hLines,'Parent',hThis.GroupHandle) - - % create context menu - hCtxtMenu = localCreateUIContextMenu(hThis); - set(hThis, 'UIContextMenu',hCtxtMenu) - set(hLines,'UIContextMenu',hCtxtMenu) - - % set up the cursorbar containers for saving and loading - localAddContainer(hThis,hParent); - - % set Position and Visible later, if they are specified as inputs - visiblepropval = ''; - positionpropval = []; - locationpropval = []; - orientationpropval = ''; - - % Loop through and set specified properties - if nargin>1 - for n = 1:2:length(varargin) - propname = varargin{n}; - propval = varargin{n+1}; - % - switch lower(propname) - case 'visible' - % Set the visible property at the end of this constructor - % since the visible listener requires the DataTip to - % be fully initialized. - visiblepropval = validatestring(propval,{'on','off'}); - case 'position' - % set the Position property just before setting Visible property - % force to a row vector - if numel(propval) > 3 || numel(propval) < 2 || ~isnumeric(propval) || ~all(isfinite(propval)) - error(message('MATLAB:graphics:cursorbar:invalidPosition')) - end - positionpropval = propval(:).'; - case 'location' - locationpropval = propval; - case 'orientation' - orientationpropval = validatestring(propval,hThis.CursorbarOrientation); - otherwise - set(hThis,propname,propval); - end - end - end - - % store vectors of Targets' XData and YData, sorted by Orientation - [x,y,z,n] = getTargetXYData(hThis,orientationpropval); - hThis.TargetXData = x; - hThis.TargetYData = y; - hThis.TargetZData = z; - hThis.TargetNData = n; - - % create new DataCursor - createNewDataCursor(hThis); - - % set Position - if ~isempty(positionpropval) - pos = positionpropval; - pos(3) = 0; % ensure 1-by-3 vector - % check Location - if ~isempty(locationpropval) - switch lower(orientationpropval) - case 'vertical', pos(1) = locationpropval; - case 'horizontal', pos(2) = locationpropval; - otherwise, pos(1) = locationpropval; % default vertical - end - end - % set Position for DataCursor from input - if isTargetAxes(hThis) - % if the Target is an axes, use the Position directly - set(hThis.DataCursorHandle.DataSource,'XData',pos(1),'YData',pos(2)); - else - % not an axes - [x,y] = closestvertex(hThis,pos,orientationpropval); - pos = [x y 0]; - hThis.DataCursorHandle.Position = pos; - end - else % Position not set - % set default Position - hAxes = get(hThis,'Parent'); - xLim = get(hAxes,'XLim'); - yLim = get(hAxes,'YLim'); - pos = [mean(xLim) mean(yLim) 0]; - % check Location - if ~isempty(locationpropval) - switch lower(orientationpropval) - case 'vertical', pos(1) = locationpropval; - case 'horizontal', pos(2) = locationpropval; - otherwise, pos(1) = locationpropval; % default vertical - end - end - % set Position for DataCursor - if isTargetAxes(hThis) - % set the DataCursor's Position to the middle of the axes - % use the 'pos' we already have - set(hThis.DataCursorHandle.DataSource,'XData',pos(1),'YData',pos(2)); - else - % choose the closest vertex to 'pos' - [x,y] = closestvertex(hThis,pos,orientationpropval); - pos = [x y 0]; - hThis.DataCursorHandle.Position = pos; - end - end - - % set Orientation - if ~isempty(orientationpropval) - set(hThis,'Orientation',orientationpropval); - end - - % set Position and Location - % set.Position silently sets Location - hThis.Position = pos; - - % Set the visible property if it was passed into the constructor - if ~isempty(visiblepropval) - set(hThis,'Visible',visiblepropval) - end - - % update - % release ObjectBeingCreated constraint - hThis.ObjectBeingCreated = false; - % update Cursorbar - update(hThis,[],[],'-nomove'); - - % apply user's CreateFcn - hThis.localApplyCreateFcn(hThis,[]); - end - end - - % ---------------------------------------- - - %% Set Methods - - methods - function s = setdisp(hThis) - % SETDISP Customize set method display. - s = set(hThis); - - % update - s.ShowText = graphics.Cursorbar.CursorbarShowText; - s.Orientation = graphics.Cursorbar.CursorbarOrientation; - s.TargetIntersections = graphics.Cursorbar.CursorbarTargetIntersections; - s.TextDescription = graphics.Cursorbar.CursorbarTextDescription; - % - s.CursorLineStyle = {'-','--',':','-.','none'}; - s.TopMarker = {'+','o','*','.','x','square','diamond','v','^','>','<','pentagram','hexagram','none'}; - s.BottomMarker = {'+','o','*','.','x','square','diamond','v','^','>','<','pentagram','hexagram','none'}; - s.TargetMarkerStyle = {'+','o','*','.','x','square','diamond','v','^','>','<','pentagram','hexagram','none'}; - s.TargetMarkerEdgeColor = {'none','flat','auto'}; - s.TargetMarkerFaceColor = {'none','flat','auto'}; - % - s.BusyAction = {'queue','cancel'}; - s.HandleVisibility = {'on','callback','off'}; - s.Interruptible = {'on','off'}; - s.HitTest = {'on','off'}; - s.Visible = {'on','off'}; - s.Selected = {'on','off'}; - s.SelectionHighlight = {'on','off'}; - s.PickableParts = {'visible','none','all'}; - - % show - if nargout==0 - disp(s); - end - end - % ---------------------------------------- - function set.ShowText(hThis,show) - try - show = validatestring(show,hThis.CursorbarShowText); - catch ME, - throwAsCaller(setmessage(ME,'ShowText')); - end - hThis.ShowText = show; - end - % ---------------------------------------- - function set.Orientation(hThis,orient) - try - orient = validatestring(orient,hThis.CursorbarOrientation); - catch ME, - throwAsCaller(setmessage(ME,'Orientation')); - end - hThis.Orientation = orient; - end - % ---------------------------------------- - function set.Visible(hThis,vis) - try - vis = validatestring(vis,{'on','off'}); - catch ME, - throwAsCaller(setmessage(ME,'Visible')); - end - hThis.Visible = vis; - end - % ---------------------------------------- - function set.TargetIntersections(hThis,tin) - try - tin = validatestring(tin,hThis.CursorbarTargetIntersections); - catch ME, - throwAsCaller(setmessage(ME,'TargetIntersections')); - end - hThis.TargetIntersections = tin; - end - % ---------------------------------------- - function set.TextDescription(hThis,des) - try - des = validatestring(des,hThis.CursorbarTextDescription); - catch ME, - throwAsCaller(setmessage(ME,'TextDescription')); - end - hThis.TextDescription = des; - end - % ---------------------------------------- - function set.Location(hThis,loc) - try - validateattributes(loc,{'double'},{'scalar','real','finite'}); - catch ME, - throwAsCaller(setmessage(ME,'Location')); - end - hThis.Location = loc; - end - % ---------------------------------------- - function set.Position(hThis,pos) - try - if numel(pos)==2, pos(3)=0; end % ensure a 3 element vector - validateattributes(pos,{'double'},{'row','numel',3,'real','finite'}); - catch ME, - throwAsCaller(setmessage(ME,'Position')); - end - hThis.Position = pos; - end - % ---------------------------------------- - function set.CreateFcn(hThis,fcn) - if ischar(fcn) || isa(fcn,'function_handle') ... - || ( iscell(fcn) && (ischar(fcn{1}) || isa(fcn{1},'function_handle')) ) - hThis.CreateFcn = fcn; - else - ME = MException('MATLAB:datatypes:callback:CreateCallback', ... - 'Callback value must be a string, a function handle, or a cell array containing string or function handle'); - throwAsCaller(setmessage(ME,'CreateFcn')); - end - end - % ---------------------------------------- - function set.DeleteFcn(hThis,fcn) - if ischar(fcn) || isa(fcn,'function_handle') ... - || ( iscell(fcn) && (ischar(fcn{1}) || isa(fcn{1},'function_handle')) ) - hThis.DeleteFcn = fcn; - else - ME = MException('MATLAB:datatypes:callback:DeleteCallback', ... - 'Callback value must be a string, a function handle, or a cell array containing string or function handle'); - throwAsCaller(setmessage(ME,'DeleteFcn')); - end - end - % ---------------------------------------- - function set.UpdateFcn(hThis,fcn) - if ischar(fcn) || isa(fcn,'function_handle') ... - || ( iscell(fcn) && (ischar(fcn{1}) || isa(fcn{1},'function_handle')) ) - hThis.UpdateFcn = fcn; - else - ME = MException('MATLAB:datatypes:callback:UpdateCallback', ... - 'Callback value must be a string, a function handle, or a cell array containing string or function handle'); - throwAsCaller(setmessage(ME,'UpdateFcn')); - end - end - end - - % ============================================================= % - - %% Dependent Methods - - methods - function set.Annotation(hThis,val) - try - hThis.GroupHandle.Annotation = val; - catch ME, - throwAsCaller(setmessage(ME,'Annotation')); - end - end - function val = get.Annotation(hThis) - val = hThis.GroupHandle.Annotation; - end - % ---------------------------------------- - function set.DisplayName(hThis,val) - try - hThis.GroupHandle.DisplayName = val; - catch ME, - throwAsCaller(setmessage(ME,'DisplayName')); - end - end - function val = get.DisplayName(hThis) - val = hThis.GroupHandle.DisplayName; - end - % ---------------------------------------- - function set.Children(~,~) - ME = MException('MATLAB:class:SetProhibited','You cannot set the read-only property ''Children'' of Class.'); - throwAsCaller(setmessage(ME,'Children')); - end - function val = get.Children(hThis) - val = hThis.GroupHandle.Children; - end - % ---------------------------------------- - function set.HandleVisibility(hThis,val) - try - hThis.GroupHandle.HandleVisibility = val; - catch ME, - throwAsCaller(setmessage(ME,'HandleVisibility')); - end - end - function val = get.HandleVisibility(hThis) - val = hThis.GroupHandle.HandleVisibility; - end - % ---------------------------------------- - function set.Selected(hThis,val) - try - hThis.GroupHandle.Selected = val; - catch ME, - throwAsCaller(setmessage(ME,'Selected')); - end - end - function val = get.Selected(hThis) - val = hThis.GroupHandle.Selected; - end - % ---------------------------------------- - function set.SelectionHighlight(hThis,val) - try - hThis.GroupHandle.SelectionHighlight = val; - catch ME, - throwAsCaller(setmessage(ME,'SelectionHighlight')); - end - end - function val = get.SelectionHighlight(hThis) - val = hThis.GroupHandle.SelectionHighlight; - end - % ---------------------------------------- - function set.PickableParts(~,~) - ME = MException('MATLAB:class:SetProhibited','You cannot set the read-only property ''PickableParts'' of Class.'); - throwAsCaller(setmessage(ME,'PickableParts')); - end - function val = get.PickableParts(hThis) - val = hThis.GroupHandle.PickableParts; - end - % ---------------------------------------- - function set.HitTest(hThis,val) - try - hThis.GroupHandle.HitTest = val; - catch ME, - throwAsCaller(setmessage(ME,'HitTest')); - end - end - function val = get.HitTest(hThis) - val = hThis.GroupHandle.HitTest; - end - % ---------------------------------------- - function set.Interruptible(hThis,val) - try - hThis.GroupHandle.Interruptible = val; - catch ME, - throwAsCaller(setmessage(ME,'Interruptible')); - end - end - function val = get.Interruptible(hThis) - val = hThis.GroupHandle.Interruptible; - end - % ---------------------------------------- - function set.BusyAction(hThis,val) - try - hThis.GroupHandle.BusyAction = val; - catch ME, - throwAsCaller(setmessage(ME,'BusyAction')); - end - end - function val = get.BusyAction(hThis) - val = hThis.GroupHandle.BusyAction; - end - % ---------------------------------------- - function set.BeingDeleted(hThis,val) - try - hThis.GroupHandle.BeingDeleted = val; - catch ME, - throwAsCaller(setmessage(ME,'BeingDeleted')); - end - end - function val = get.BeingDeleted(hThis) - val = hThis.GroupHandle.BeingDeleted; - end - end - - % ============================================================= % - - %% Sealed Methods - - methods (Sealed) - function tf = ishandle(hThis) - % ISHANDLE Checks on self if valid handle - % - % See also ishandle, graphics.Cursorbar. - tf = isvalid(hThis); - end - end - - % ============================================================= % - - %% Local (Protected Hidden) Methods - - methods (Access=protected, Hidden) - - function localApplyCreateFcn(hThis,obj,evd) - % LOCALAPPLYCREATEFCN Apply the create function. - localApplyCallbackFcn(hThis,obj,evd,'CreateFcn'); - end - - % -------------------------------------- - function localApplyDeleteFcn(hThis,obj,evd) - % LOCALAPPLYDELETEFCN Apply the delete function. - localApplyCallbackFcn(hThis,obj,evd,'DeleteFcn'); - end - - % -------------------------------------- - function localApplyUpdateFcn(hThis,obj,evd) - % LOCALAPPLYDELETEFCN Apply the delete function. - localApplyCallbackFcn(hThis,obj,evd,'UpdateFcn'); - end - - % -------------------------------------- - function localApplyCallbackFcn(hThis,obj,evd,callbackname) - % LOCALAPPLYCALLBACKFCN Apply some callback function. - func = hThis.(callbackname); - try % to apply delete function - switch class(func) - case 'char', eval(func); - case 'function_handle', feval(func,obj,evd); - case 'cell', feval(hThis.func{1},obj,evd,hThis.func{2:end}); - end - catch ME, % warn quietly - wME = setmessage(ME,callbackname); - warning(wME.identifier, wME.message); - end - end - - % -------------------------------------- - function hLines = localCreateNewCursorBarLines(hThis,~,~) - % LOCALCREATENEWCURSORBARLINES create lines for Cursorbar, and line for markers - - % Get axes and figure - hAxes = get(hThis,'Parent'); - hGroup = hThis.GroupHandle; - - % white line on dark axes, black line on light axes - AXCOLOR = get(hAxes,'Color'); - - % --------- cursor line --------- - lineprops = struct; - lineprops.Tag = 'DataCursorLine'; - lineprops.Parent = hGroup; - lineprops.XData = [NaN NaN]; - lineprops.YData = [NaN NaN]; - lineprops.Color = hThis.CursorLineColor; - % - % light colored axes - if sum(AXCOLOR) < 1.5 - lineprops.Color = [1 1 1]; - end - % - lineprops.Marker = 'none'; - lineprops.LineStyle = '-'; - lineprops.LineWidth = 2; - % - lineprops.Clipping = 'on'; - lineprops.XLimInclude = 'off'; % don't interfere with axes zooming - lineprops.YLimInclude = 'off'; % don't interfere with axes zooming - % - lineprops.HandleVisibility = 'off'; - lineprops.Visible = hThis.Visible; - lineprops.ButtonDownFcn = @hThis.localCursorButtonDownFcn; - lineprops.Serializable = 'off'; % don't save to file - - cursorline = line(lineprops); - hThis.CursorLineHandle = handle(cursorline); - hThis.ButtonDownFcn = lineprops.ButtonDownFcn; - - % --------- top,bottom affordances --------- - lineprops.XData = NaN; - lineprops.YData = NaN; - lineprops.MarkerFaceColor = hThis.CursorLineColor; - lineprops.LineStyle = 'none'; - % - % top - lineprops.Tag = 'DataCursorLineTop'; - lineprops.Marker = hThis.TopMarker; - % - topdragline = line(lineprops); - hThis.TopHandle = handle(topdragline); - % - % bottom - lineprops.Tag = 'DataCursorLineBottom'; - lineprops.Marker = hThis.BottomMarker; - % - bottomdragline = line(lineprops); - hThis.BottomHandle = handle(bottomdragline); - - % --------- marker line --------- - lineprops.Tag = 'DataCursorTargetMarker'; - lineprops.Marker = hThis.TargetMarkerStyle; - lineprops.MarkerSize = hThis.TargetMarkerSize; - lineprops.MarkerEdgeColor = hThis.TargetMarkerEdgeColor; - lineprops.MarkerFaceColor = hThis.TargetMarkerFaceColor; - lineprops.LineStyle = 'none'; - % - markerline = line(lineprops); - hThis.TargetMarkerHandle = handle(markerline); - - % combine handles - hLines = handle([ ... - cursorline; - topdragline; - bottomdragline; - markerline ]); - end - - % -------------------------------------- - function hCtxtMenu = localCreateUIContextMenu(hThis,~,~) - % LOCALCREATEUICONTEXTMENU - - if ismethod(hThis,'createUIContextMenu') - hCtxtMenu = hThis.createUIContextMenu(); - else - hCtxtMenu = hThis.defaultUIContextMenu(); - end - end - - % -------------------------------------- - function localAddTargetListeners(hThis,~,~) - % LOCALADDTARGETLISTENERS add listeners for Target and its parent axes - - % check Target - hTarget = hThis.Target; - if ~ishandle(hTarget) - return; - end - - % get handles for axes - hAxes = handle(get(hThis,'Parent')); - - % listen for changes to axes' Limits - axesLimProps = [ ... - findprop(hAxes,'XLim'); - findprop(hAxes,'YLim'); - findprop(hAxes,'ZLim')]; - l = event.proplistener(hAxes,axesLimProps,'PostSet',@hThis.localAxesLimUpdate); - - % Update if Target is line(s) and any target ...Data property changes - if ~isTargetAxes(hThis) - for n = 1:length(hTarget) - target_prop = [ ... - findprop(hTarget(n),'XData'); - findprop(hTarget(n),'YData'); - findprop(hTarget(n),'ZData')]; - l(end+1) = event.proplistener(hTarget(n),target_prop,'PostSet',... - @hThis.localTargetDataUpdate); %#ok - end - end - - % Listen to axes pixel bound resize events - axes_prop = findprop(hAxes,'PixelBound'); - l(end+1) = event.proplistener(hAxes,axes_prop, 'PostSet',... - @hThis.localAxesPixelBoundUpdate); - - % Clean up if Cursorbar or its Target is deleted - l(end+1) = event.listener(hThis.Target,'ObjectBeingDestroyed',... - @hThis.localTargetDestroy); - - % Store listeners - hThis.TargetListenerHandles = l; - end - - % -------------------------------------- - function localAddSelfListeners(hThis,~,~) - % LOCALADDSELFLISTENERS add listeners to Cursorbar's properties - - % Visible - l( 1 ) = event.proplistener(hThis,findprop(hThis,'Visible'),... - 'PostSet',@hThis.localSetVisible); - - % ShowText - l(end+1) = event.proplistener(hThis,findprop(hThis,'ShowText'),... - 'PostSet',@hThis.localSetShowText); - - % TargetIntersections - l(end+1) = event.proplistener(hThis,findprop(hThis,'TargetIntersections'),... - 'PostSet',@hThis.localSetTargetIntersections); - - % TextDescription - l(end+1) = event.proplistener(hThis,findprop(hThis,'TextDescription'),... - 'PostSet',@hThis.localSetTextDescription); - - % Orientation - l(end+1) = event.proplistener(hThis,findprop(hThis,'Orientation'),... - 'PostSet',@hThis.localSetOrientation); - - % Location - l(end+1) = event.proplistener(hThis,findprop(hThis,'Location'),... - 'PostSet',@hThis.localSetLocation); - - % Position - l(end+1) = event.proplistener(hThis,findprop(hThis,'Position'),... - 'PostSet',@hThis.localSetPosition); - - % UIContextMenu - l(end+1) = event.proplistener(hThis,findprop(hThis,'UIContextMenu'),... - 'PostSet',@hThis.localSetUIContextMenu); - - % ButtonDownFcn - l(end+1) = event.proplistener(hThis,findprop(hThis,'ButtonDownFcn'),... - 'PostSet', @hThis.localSetButtonDownFcn); - - % Target - l(end+1) = event.proplistener(hThis,findprop(hThis,'Target'),... - 'PreSet', @hThis.localPreSetTarget); - l(end+1) = event.proplistener(hThis,findprop(hThis,'Target'),... - 'PostSet', @hThis.localPostSetTarget); - l(end+1) = event.proplistener(hThis,findprop(hThis,'Target'),... - 'PostSet', @hThis.localAddTargetListeners); - - % Cursorbar appearance properties - p = [ ... - findprop(hThis,'CursorLineColor'); - findprop(hThis,'CursorLineStyle'); - findprop(hThis,'CursorLineWidth'); - findprop(hThis,'TopMarker'); - findprop(hThis,'BottomMarker')]; - l(end+1) = event.proplistener(hThis,p,'PostSet', @hThis.localSetCursorProps); - - % Marker properties - p = [ ... - findprop(hThis,'TargetMarkerStyle');... - findprop(hThis,'TargetMarkerSize'); ... - findprop(hThis,'TargetMarkerEdgeColor'); ... % YD - findprop(hThis,'TargetMarkerFaceColor'); ... % YD - ]; - l(end+1) = event.proplistener(hThis,p,'PostSet',@hThis.localSetMarkerProps); - - % Listen for update event - l(end+1) = event.listener(hThis,'UpdateCursorBar',@hThis.updateDisplay); - - % Clean up if Cursorbar is deleted - l(end+1) = event.listener(hThis,'ObjectBeingDestroyed',... - @hThis.localCursorBarDestroy); - - % Store listeners - hThis.SelfListenerHandles = l; - - end - - % -------------------------------------- - function localAxesPixelBoundUpdate(hThis,~,~) - % LOCALAXESPIXELBOUNDUPDATE - - update(hThis); - end - - % -------------------------------------- - function localSetOrientation(hThis,~,evd) - % LOCALSETORIENTATION - - % get new Orientation value - newval = evd.AffectedObject.Orientation; - - % get DataCursor's Position - pos = hThis.DataCursorHandle.Position; - x = pos(1); - y = pos(2); - - hAxes = get(hThis,'Parent'); - - % get axes' limits - xlimits = get(hAxes,'XLim'); - ylimits = get(hAxes,'YLim'); - - % get axes' directions - xdir = get(hAxes,'XDir'); - ydir = get(hAxes,'YDir'); - - % setting Marker for 'affordances' at ends of Cursorbar - switch newval - case 'vertical' - set(hThis.CursorLineHandle,'XData',[x x],'YData',ylimits); - switch ydir - case 'normal' - set(hThis.BottomHandle,'Marker','^') - set(hThis.TopHandle,'Marker','v') - case 'reverse' - set(hThis.BottomHandle,'Marker','v') - set(hThis.TopHandle,'Marker','^') - end - case 'horizontal' - set(hThis.CursorLineHandle,'XData',xlimits,'YData',[y y]); - switch xdir - case 'normal' - set(hThis.BottomHandle,'Marker','<') - set(hThis.TopHandle,'Marker','>') - case 'reverse' - set(hThis.BottomHandle,'Marker','>') - set(hThis.TopHandle,'Marker','<') - end - otherwise - error(message('MATLAB:graphics:cursorbar:invalidOrientation')) - end - - % update Cursorbar - if ~isempty(hThis.Position) - hThis.Position = hThis.Position; % silently update Location and Position - end - % update(hThis) - - end - - % -------------------------------------- - function localSetLocation(hThis,~,evd) - % LOCALSETLOCATION - - loc = evd.AffectedObject.Location; - - pos = get(hThis,'Position'); - - % during initialization (duplication) the position may not be set yet; - % assert proper length (=3) - if length(pos)<3 - pos(1,3) = 0; - end - - switch get(hThis,'Orientation') - case 'vertical' - pos(1) = loc; - case 'horizontal' - pos(2) = loc; - otherwise % default vertical - pos(1) = loc; - end - - % set(hThis.DataCursorHandle,'Position',pos) - set(hThis,'Position',pos) - - % update(hThis); % set.Position already updates Cursorbar - end - - % -------------------------------------- - function localSetPosition(hThis,~,evd) - % LOCALSETPOSITION - - % return early if not a handle - if ~ishandle(hThis) - return; - end - - % get new Position - pos = evd.AffectedObject.Position; - - % Position should be [X Y] or [X Y Z] - if numel(pos) ~= 2 && numel(pos) ~= 3 - return - end - - x = pos(1); - y = pos(2); - - hCursorLine = hThis.CursorLineHandle; - hTopLine = hThis.TopHandle; - hBottomLine = hThis.BottomHandle; - hAxes = get(hThis,'Parent'); - - switch get(hThis,'Orientation') - case 'vertical' - if isempty(hThis.Location) || hThis.Location ~= x - set(hThis,'Location',x); - end - - yLim = get(hAxes,'YLim'); - set(hCursorLine,'XData',[x x],'YData',yLim); - set(hBottomLine,'XData',x, 'YData',yLim(1)); - set(hTopLine, 'XData',x, 'YData',yLim(2)); - case 'horizontal' - if isempty(hThis.Location) || hThis.Location ~= y - set(hThis,'Location',y); - end - xLim = get(hAxes,'XLim'); - set(hCursorLine,'XData',xLim, 'YData',[y y]); - set(hBottomLine,'XData',xLim(2),'YData',y); - set(hTopLine, 'XData',xLim(1),'YData',y); - end - - % silently update - updateMarkers(hThis); - updateDisplay(hThis); - % defaultUpdateFcn(hThis,obj,evd); - - end - - % -------------------------------------- - function localSetShowText(hThis,obj,evd) - % LOCALSETSHOWTEXT - - validhandles = ishandle(hThis.DisplayHandle); - visibility = evd.AffectedObject.ShowText; - set(hThis.DisplayHandle(validhandles),'Visible',visibility); - % - hThis.updateDisplay(obj,evd); % update display - end - - % -------------------------------------- - function localSetTargetIntersections(hThis,obj,evd) - % LOCALSETTARGETINTERSECTION - - hThis.updateMarkers(); % update markers - hThis.updateDisplay(obj,evd); % update display - end - - % -------------------------------------- - function localSetTextDescription(hThis,obj,evd) - % LOCALSETTEXTDESCRIPTION - - hThis.updateMarkers(); % update markers - hThis.updateDisplay(obj,evd); % update display - end - - % -------------------------------------- - function localSetUIContextMenu(hThis,~,evd) - % LOCALSETUICONTEXTMENU - - contextmenu = evd.AffectedObject.UIContextMenu; - - hndls = [ - hThis.CursorLineHandle; - hThis.TargetMarkerHandle; - hThis.TopHandle; - hThis.BottomHandle; - hThis.GroupHandle]; - - set(hndls,'UIContextMenu',contextmenu); - end - - % -------------------------------------- - function localSetButtonDownFcn(hThis,~,evd) - % LOCALSETBUTTONDOWNFCN - - newVal = evd.AffectedObject.ButtonDownFcn; - - hLines = [ - hThis.CursorLineHandle; - hThis.TargetMarkerHandle; - hThis.TopHandle - hThis.BottomHandle - hThis.GroupHandle]; - - set(hLines,'ButtonDownFcn',newVal); - end - - % -------------------------------------- - function localSetCursorProps(hThis,~,evd) - % LOCALSETCURSORPROPS - - propname = evd.Source.Name; - propval = evd.AffectedObject.(propname); - - switch propname - case 'CursorLineColor' - newpropname = 'Color'; - hLine = [hThis.CursorLineHandle; hThis.TopHandle; hThis.BottomHandle]; - case 'CursorLineStyle' - newpropname = 'LineStyle'; - hLine = hThis.CursorLineHandle; - case 'CursorLineWidth' - newpropname = 'LineWidth'; - hLine = hThis.CursorLineHandle; - case 'TopMarker' - newpropname = 'Marker'; - hLine = hThis.TopHandle; - case 'BottomMarker' - newpropname = 'Marker'; - hLine = hThis.BottomHandle; - end - - set(hLine,newpropname,propval); - end - - % -------------------------------------- - function localSetMarkerProps(hThis,~,evd) - % LOCALSETMARKERPROPS - - propname = evd.Source.Name; - propval = evd.AffectedObject.(propname); - - switch propname - case 'TargetMarkerStyle' - newpropname = 'Marker'; - case 'TargetMarkerSize' - newpropname = 'MarkerSize'; - case 'TargetMarkerEdgeColor' % YD - newpropname = 'MarkerEdgeColor'; - case 'TargetMarkerFaceColor' % YD - newpropname = 'MarkerFaceColor'; - end - - set(hThis.TargetMarkerHandle,newpropname,propval) - end - - % -------------------------------------- - function localPreSetTarget(hThis,~,evd) - % LOCALPRESETTARGET - - % check new Target value - newTarget = evd.AffectedObject.Target; - if ~all(isTargetChart(hThis)) && ~isa(newTarget,'matlab.graphics.axis.Axes') - error(message('MATLAB:cursorbar:InvalidTarget')); - end - - % remove the old container - localRemoveContainer(hThis); - end - - % -------------------------------------- - function localPostSetTarget(hThis,~,~) - % LOCALPOSTSETTARGET - - % set up the container - localAddContainer(hThis); - - % if it's a line, set it close to the current location of the Cursorbar - if isTargetAxes(hThis) - % do nothing for axes, no need to change Position - return - end - - % update the Target...Data - [x,y,z,n] = getTargetXYData(hThis); - hThis.TargetXData = x; - hThis.TargetYData = y; - hThis.TargetZData = z; - hThis.TargetNData = n; - - % update Cursorbar - hThis.update([],[],'-nomove'); - end - - % -------------------------------------- - function localSetVisible(hThis,obj,evd) - % LOCALSETVISIBLE - - % Return early if no DataCursor - if ~isvalid(hThis.DataCursorHandle) || isempty(hThis.DataCursorHandle.Position) - hThis.Visible = 'off'; - hThis.GroupHandle.Visible = 'off'; - hThis.updateDisplay(obj,evd); - return; - end - - newvalue = evd.AffectedObject.Visible; - hThis.GroupHandle.Visible = newvalue; - hThis.updateDisplay(obj,evd); - end - - % -------------------------------------- - function localAddContainer(hThis,hParent) - % LOCALADDCONTAINER Add a CursorbarContainer to the parent - - % inputs - if nargin<2 - hParent = hThis.Parent; % default parent - end - hFig = ancestor(hParent,'figure'); % figure handle - - % store the application data in the parent axes for serialization reasons - key = graphics.internal.CursorbarContainer.Key; % application data key - containers = getappdata(hFig,key); % retrieve Cursorbar containers - % - if isempty(containers) || ~any(containers.hasCursorbar(hThis)) - % create a new container and store - newContainer = graphics.internal.CursorbarContainer(hThis);% container of the current object - containers = [containers newContainer]; % add the current container - % - setappdata(hFig,key,containers); % store all the containers in the parent - hThis.Container = newContainer; % store the new container - end - end - - % -------------------------------------- - function localRemoveContainer(hThis,hParent) - % LOCALREMOVECONTAINER Remove the CursorbarContainer from the parent - - % inputs - if nargin<2 - hParent = hThis.Parent; % default parent - end - hFig = ancestor(hParent,'figure'); % figure handle - - % remove the application data in the parent axes - key = graphics.internal.CursorbarContainer.Key; % application data key - containers = getappdata(hFig,key); % retrieve Cursorbar containers - % - if ~isempty(containers) && any(containers.hasCursorbar(hThis)) - % remove containers from the application data - current = containers.hasCursorbar(hThis); % containers for the current object - setappdata(hFig,key,containers(~current)); % leave only the non-current containers - end - - % delete the old container handle - if isvalid(hThis.Container) - delete(hThis.Container); - end - end - - % -------------------------------------- - function localCursorBarDestroy(hThis,~,~,varargin) - % LOCALCURSORBARDESTROY called when the Cursorbar is destroyed - - % user defined delete function - hThis.localApplyDeleteFcn(hThis,[]); - - % remove cursorbar containers - if ishandle(hThis.Parent) - localRemoveContainer(hThis,hThis.Parent); - end - - % delete all child objects - if ishandle(hThis.CursorLineHandle) - delete(hThis.CursorLineHandle); - end - if ishandle(hThis.TargetMarkerHandle) - delete(hThis.TargetMarkerHandle); - end - if ishandle(hThis.TopHandle) - delete(hThis.TopHandle); - end - if ishandle(hThis.BottomHandle) - delete(hThis.BottomHandle); - end - if isvalid(hThis.DataCursorHandle) - delete(hThis.DataCursorHandle) - end - validhandles = ishandle(hThis.DisplayHandle); - if any(validhandles) && all(isa(hThis.DisplayHandle(validhandles),'matlab.graphics.primitive.Text')) - delete(hThis.DisplayHandle(validhandles)) - end - if ishandle(hThis.GroupHandle) - delete(hThis.GroupHandle) - end - end - - % -------------------------------------- - function localTargetDestroy(hThis,~,evd,varargin) - % LOCALTARGETDESTROY called when the any of the Cursorbar's Target objects are destroyed - - % if there is a single Target, then Cursorbar should be destroyed when it is - % destroyed - if length(hThis.Target) == 1 - delete(hThis); - return - else - % determine which Target was deleted - deletedTarget = evd.Source; - - % remove from Target list - hTargets = handle(hThis.Target); - hTargets(hTargets == deletedTarget) = []; - set(hThis,'Target',hTargets); - - % update the Target_Data - [x,y,z,n] = getTargetXYData(hThis); - hThis.TargetXData = x; - hThis.TargetYData = y; - hThis.TargetZData = z; - hThis.TargetNData = n; - end - - update(hThis,[],[],'-nomove'); - end - - % -------------------------------------- - function localAxesLimUpdate(hThis,~,~) - % LOCALAXESLIMUPDATE update cursor line after limits change - - % get the Cursorbar's orientation - orient = get(hThis,'Orientation'); - - hAxes = handle(get(hThis,'Parent')); - hCursorLine = get(hThis,'CursorLineHandle'); - - switch orient - case 'vertical' - ylim = get(hAxes,'YLim'); - set(hCursorLine,'YData',ylim) - case 'horizontal' - xlim = get(hAxes,'XLim'); - set(hCursorLine,'XData',xlim) - end - end - - % -------------------------------------- - function localTargetDataUpdate(hThis,~,~,varargin) - % LOCALTARGETDATAUPDATE - - hDataCursor = hThis.DataCursorHandle; - - oldpos = hDataCursor.Position; - - % use the old position to determine the new position - [x,y] = closestvertex(hThis,oldpos); - pos = [x y 0]; - hDataCursor.Position = pos; - update(hThis); - end - - % -------------------------------------- - function localCursorButtonDownFcn(hThis,~,~) - % LOCALCURSORBUTTONDOWNFCN click on Cursorbar - - hFig = ancestor(hThis,'Figure'); - - % swap out the WindowButton...Fcns - uistate = struct; - uistate.WindowButtonUpFcn = get(hFig,'WindowButtonUpFcn'); - uistate.WindowButtonMotionFcn = get(hFig,'WindowButtonMotionFcn'); - uistate.Pointer = get(hFig,'Pointer'); - - % save figure's current state - setappdata(hFig,'CursorBarOriginalFigureCallbacks',uistate); - - % modify uistate - uistate.WindowButtonUpFcn = @hThis.localWindowButtonUpFcn; - uistate.WindowButtonMotionFcn = @hThis.localWindowButtonMotionFcn; - uistate.Pointer = 'fleur'; - - % set new state - set(hFig,uistate); - - % send BeginDrag event - notify(hThis,'BeginDrag'); - end - - % -------------------------------------- - function localWindowButtonMotionFcn(hThis,~,~) - % LOCALWINDOWBUTTONMOTIONFCN move Cursorbar - - % update the Cursorbar while moving - update(hThis); - end - - % -------------------------------------- - function localWindowButtonUpFcn(hThis,hFig,~) - % LOCALWINDOWBUTTONUPFCN restore original figure callbacks and pointer - - % get stored callbacks - uistate = getappdata(hFig,'CursorBarOriginalFigureCallbacks'); - - if ~isempty(uistate) - set(hFig,uistate); - end - - % send EndDrag event - notify(hThis,'EndDrag'); - end - - % -------------------------------------- - function localTestUpdate(~,~,evd) - % LOCALTESTUPDATE test for property listeners - - disp(get(evd)) - - end - end - - % ============================================================= % - - %% Folder (Protected Hidden) Methods - methods (Access=protected, Hidden) - % -------------------------------------- - uictxtmenu = defaultUIContextMenu(hThis); - % -------------------------------------- - defaultUpdateFcn(hThis,obj,evd); - % -------------------------------------- - [xIntersect,yIntersect,hIntersect] = getIntersections(hThis,hLines); - % -------------------------------------- - pixperdata = getPixelsPerData(hThis); - % -------------------------------------- - [x,y,z,n] = getTargetXYData(hThis,orient); - % -------------------------------------- - move(hThis,dir); - % -------------------------------------- - moveDataCursor(hThis,hDataCursor,direc); - % -------------------------------------- - update(hThis,obj,evd,varargin) - % -------------------------------------- - updateDataCursor(hThis,hNewDataCursor,target) - % -------------------------------------- - updateDisplay(hThis,obj,evd) - % -------------------------------------- - updateMarkers(hThis) - % -------------------------------------- - updatePosition(hThis,hNewDataCursor) - % -------------------------------------- - hNewDataCursor = createNewDataCursor(hThis,hTarget) - % -------------------------------------- - [x,y,n] = closestvertex(hThis,pos,orient) - end - - % ============================================================= % - - %% Custom Display Methods - - methods(Access = protected) - - % -------------------------------------- - function groups = getScalarPropertyGroups(hThis) %#ok - % GETSCALARPROPERTYGROUPS Construct array of property groups for display of scalar case. - - % Scalar case: change order - propList = { ... - 'Location', ... - 'Position', ... - 'Orientation', ... - ... - 'CursorLineColor', ... - 'CursorLineStyle', ... - 'CursorLineWidth', ... - 'TopMarker', ... - 'BottomMarker', ... - ... - 'TargetMarkerStyle', ... - 'TargetMarkerSize', ... - 'TargetMarkerEdgeColor', ... - 'TargetMarkerFaceColor', ... - ... - 'ShowText', ... - 'TargetIntersections', ... - 'TextDescription' ... - }; - groups = matlab.mixin.util.PropertyGroup(propList); - end - end - - % ============================================================= % - -end - -% ============================================================= % - -%% Subfunctions - -function newME = setmessage(ME,prop) -% SETMESSAGE Sets the error message for set.Property functions. -classLink = sprintf('Cursorbar',mfilename('class')); -% -firstLine = sprintf('While setting the ''%s'' property of %s:',prop,classLink); -messageStr = regexprep(ME.message,'Class',classLink); -identifier = regexprep(ME.identifier,{'\','\.'},{mfilename('class'),':'},'ignorecase'); -% -newME = MException(identifier,'%s\n%s',firstLine,messageStr); -end - -%% EOF diff --git a/Required packages/Cursorbar/+graphics/@Cursorbar/closestvertex.m b/Required packages/Cursorbar/+graphics/@Cursorbar/closestvertex.m deleted file mode 100644 index eab58e4..0000000 --- a/Required packages/Cursorbar/+graphics/@Cursorbar/closestvertex.m +++ /dev/null @@ -1,99 +0,0 @@ -function [x,y,n] = closestvertex(hThis,pos,orient) -% CLOSESTVERTEX Return X,Y location of closest Target vertex -% -% Thanks to Yaroslav Don for his assistance in updating cursorbar for -% MATLAB Graphics and for his contribution of new functionality. - -% Copyright 2003-2016 The MathWorks, Inc. - -% Change Log: -% 13 Feb 2015: First version posted on the MathWorks file exchange. -% 14 May 2015: Added logarithmic scale support. - -% input check -if nargin<3 || isempty(orient) - orient = hThis.Orientation; -end - -% initialize -hTarget = hThis.Target; -hAxes = hThis.Parent; -% -x = []; -y = []; - -% don't need to find closest vertex if the Target is an axes -if isTargetAxes(hThis) - return -end - -% get XData and YData -x = hThis.TargetXData; -y = hThis.TargetYData; -n = hThis.TargetNData; - -% logarithmic scale requires a logarithmic distance -switch hAxes.XScale - case 'linear' - pos_dist(1) = pos(1); - x_dist = x; - case 'log' - pos_dist(1) = log10(pos(1)); - x_dist = log10(x); -end -% -switch hAxes.YScale - case 'linear' - pos_dist(2) = pos(2); - y_dist = y; - case 'log' - pos_dist(2) = log10(pos(2)); - y_dist = log10(y); -end - -% translate to pixels -pixperdata = getPixelsPerData(hThis); -% -pos_dist = pos_dist .* pixperdata; -x_dist = x_dist * pixperdata(1); -y_dist = y_dist * pixperdata(2); - -% determine distance -is_2D_target = any( strcmp(class(hTarget),graphics.Cursorbar.Permitted2DTargets) ) ... - || strcmp(hThis.TargetIntersections,'single'); -is_single_target = isscalar(hTarget); - -if is_2D_target - % determine distance to the closest target - dist = hypot(pos_dist(1) - x_dist, pos_dist(2) - y_dist); - -elseif is_single_target - % determine distance in a single dimension, dependent on Orientation - switch orient - case 'vertical' - dist = abs(pos_dist(1) - x_dist); - case 'horizontal' - dist = abs(pos_dist(2) - y_dist); - end -else - % determine distance to the closest target, dependent on Orientation - distX = abs(pos_dist(1) - x_dist); - distY = abs(pos_dist(2) - y_dist); - % punish the secondary distance if the primary distance is too large - pixoffset = 3; % the error range - switch orient - case 'vertical' - distY(distX-min(distX)>pixoffset) = Inf; - case 'horizontal' - distX(distY-min(distY)>pixoffset) = Inf; - end - dist = hypot(distX, distY); -end - -% get index for minimum distance -[~,ind] = min(dist); - -% set output variables -x = x(ind); -y = y(ind); -n = n(ind); diff --git a/Required packages/Cursorbar/+graphics/@Cursorbar/createNewDataCursor.m b/Required packages/Cursorbar/+graphics/@Cursorbar/createNewDataCursor.m deleted file mode 100644 index 64c4de8..0000000 --- a/Required packages/Cursorbar/+graphics/@Cursorbar/createNewDataCursor.m +++ /dev/null @@ -1,53 +0,0 @@ -function hNewDataCursor = createNewDataCursor(hThis,hTarget) -% CREATENEWDATACURSOR Creates a new data cursor -% -% Thanks to Yaroslav Don for his assistance in updating cursorbar for -% MATLAB Graphics and for his contribution of new functionality. - -% Copyright 2015-2016 The MathWorks, Inc. - -% set source -if nargin<2 - hTarget = hThis.Target(1); -end - -% create a Data Cursor -if isTargetAxes(hThis) - % target is an axes: create a dummy line handle - hDummyLineHandle = line(0,0, 'Parent', hThis.GroupHandle, ... - 'Visible','off', 'HandleVisibility','off', 'Clipping','off',... - 'PickableParts','none', 'HitTest','off', 'Interruptible','off'); - hThis.DataCursorDummyTargetHandle = matlab.graphics.chart.primitive.Line(hDummyLineHandle); - % - hNewDataCursor = matlab.graphics.shape.internal.PointDataCursor(hThis.DataCursorDummyTargetHandle); - -elseif isTargetChart(hThis) - % target is a chart: create a direct point data cursor - try % create directly - hNewDataCursor = matlab.graphics.shape.internal.PointDataCursor( hTarget ); - catch % probably, not a DataAnnotatable (matlab.graphics.chart.interaction.DataAnnotatable) - try % create via datacursormode - hDataCursorMode = datacursormode(); - hDataTip = hDataCursorMode.createDatatip( hTarget ); - % - hNewDataCursor = hDataTip.Cursor; - % - delete(hDataTip); % it's services are no longer required - hDataCursorMode.Enable = 'off'; % disable data cursor mode - catch % throw error - error(message('MATLAB:cursorbar:InvalidTarget')); - end - end - -else - % throw error - error(message('MATLAB:cursorbar:InvalidTarget')); -end - -% delete old handle -hOldDataCursor = hThis.DataCursorHandle; -delete(hOldDataCursor); - -% update old handle -hThis.DataCursorHandle = hNewDataCursor; - diff --git a/Required packages/Cursorbar/+graphics/@Cursorbar/defaultUIContextMenu.m b/Required packages/Cursorbar/+graphics/@Cursorbar/defaultUIContextMenu.m deleted file mode 100644 index 24141b8..0000000 --- a/Required packages/Cursorbar/+graphics/@Cursorbar/defaultUIContextMenu.m +++ /dev/null @@ -1,122 +0,0 @@ -function uictxtmenu = defaultUIContextMenu(hThis) -% DEFAULTUICONTEXTMENU Default Cursorbar UIContextMenu. -% -% Thanks to Yaroslav Don for his assistance in updating cursorbar for -% MATLAB Graphics and for his contribution of new functionality. - -% Copyright 2003-2016 The MathWorks, Inc. - -% check the figure -hFig = ancestor(hThis,'figure'); -% -if isempty(hFig) || ~ishghandle(hFig) - % probably, happens during loading process - % exit to prevent MATLAB from crushing - uictxtmenu = gobjects(0); - return -end - -% set context menu -uictxtmenu = uicontextmenu('Parent',hFig); -uictxtmenu.Serializable = 'off'; % don't save to file - -% define menu properties -menuprops = struct; -menuprops.Parent = uictxtmenu; -menuprops.Serializable = 'off'; % don't save to file - -% first menu -menuprops.Label = 'Show Text'; -menuprops.Checked = hThis.ShowText; -menuprops.Callback = {@localSetShowText,hThis}; -% -u(1) = uimenu(menuprops); -l(1) = event.proplistener(hThis,findprop(hThis,'ShowText'), ... - 'PostSet',@(obj,evd)localGetShowText(u(1),evd,hThis)); - -% second menu -menuprops.Label = 'Multiple Intersections'; -switch hThis.TargetIntersections - case 'multiple', menuprops.Checked = 'on'; - case 'single', menuprops.Checked = 'off'; -end -menuprops.Callback = {@localSetTargetIntersections,hThis}; -% -u(2) = uimenu(menuprops); -l(2) = event.proplistener(hThis,findprop(hThis,'TargetIntersections'), ... - 'PostSet',@(obj,evd)localGetTargetIntersections(u(2),evd,hThis)); - -% third menu -menuprops.Label = 'Short Description'; -switch hThis.TextDescription - case 'short', menuprops.Checked = 'on'; - case 'long', menuprops.Checked = 'off'; -end -menuprops.Callback = {@localSetTextDescription,hThis}; -% -u(3) = uimenu(menuprops); -l(3) = event.proplistener(hThis,findprop(hThis,'TextDescription'), ... - 'PostSet',@(obj,evd)localGetTextDescription(u(3),evd,hThis)); - -% store listeners -hThis.SelfListenerHandles = [hThis.SelfListenerHandles, l]; - -%% Subfunctions - -function localGetShowText(hMenu,~,hThis) -% LOCALGETSHOWTEXT Get ShowText property. -switch hThis.ShowText - case 'on', hMenu.Checked = 'on'; - case 'off', hMenu.Checked = 'off'; -end - -function localSetShowText(hMenu,~,hThis) -% LOCALSETSHOWTEXT SetShowText Property -switch get(hMenu,'Checked') - case 'on' - set(hMenu,'Checked','off') - set(hThis,'ShowText','off') - case 'off' - set(hMenu,'Checked','on') - set(hThis,'ShowText','on') -end - -% -------------------------------------- - -function localGetTargetIntersections(hMenu,~,hThis) -% LOCALGETTARGETINTERSECTIONS Get TargetIntersections Property -switch hThis.TargetIntersections - case 'multiple', hMenu.Checked = 'on'; - case 'single', hMenu.Checked = 'off'; -end - -function localSetTargetIntersections(hMenu,~,hThis) -% LOCALSETTARGETINTERSECTIONS Set TargetIntersections Property -switch get(hMenu,'Checked') - case 'on' - set(hMenu,'Checked','off') - set(hThis,'TargetIntersections','single') - case 'off' - set(hMenu,'Checked','on') - set(hThis,'TargetIntersections','multiple') -end - -% -------------------------------------- - -function localGetTextDescription(hMenu,~,hThis) -% LOCALGETTEXTDESCRIPTION Get TextDescription Property -switch hThis.TextDescription - case 'short', hMenu.Checked = 'on'; - case 'long', hMenu.Checked = 'off'; -end - -function localSetTextDescription(hMenu,~,hThis) -% LOCALSETTEXTDESCRIPTION Set TextDescription Property -switch get(hMenu,'Checked') - case 'on' - set(hMenu,'Checked','off') - set(hThis,'TextDescription','long') - case 'off' - set(hMenu,'Checked','on') - set(hThis,'TextDescription','short') -end diff --git a/Required packages/Cursorbar/+graphics/@Cursorbar/defaultUpdateFcn.m b/Required packages/Cursorbar/+graphics/@Cursorbar/defaultUpdateFcn.m deleted file mode 100644 index 2e2973a..0000000 --- a/Required packages/Cursorbar/+graphics/@Cursorbar/defaultUpdateFcn.m +++ /dev/null @@ -1,193 +0,0 @@ -function defaultUpdateFcn(hThis,~,~) -% DEFAULTUPDATEFCN Default cursorbar UpdateFcn. -% -% Thanks to Yaroslav Don for his assistance in updating cursorbar for -% MATLAB Graphics and for his contribution of new functionality. - -% Copyright 2003-2016 The MathWorks, Inc. - -% Change Log: -% 13 Feb 2015: First version posted on the MathWorks file exchange. -% 14 May 2015: Added logarithmic scale support. - -hText = get(hThis,'DisplayHandle'); - -if strcmp(hThis.ShowText,'off') || strcmp(hThis.Visible,'off') - if ~isempty(hText) - delete(hText); - hThis.DisplayHandle = gobjects(0); - return - end - return -end - -% get the locations of the markers -if ~all(isvalid(hThis.TargetMarkerHandle)) - return; -end -xData = get(hThis.TargetMarkerHandle,'XData'); -yData = get(hThis.TargetMarkerHandle,'YData'); - -numIntersections = length(xData); - -% get the handles for the text objects, corresponding to each intersection -hAxes = get(hThis,'Parent'); - -%%%%%%%%%%%%% - -AXCOLOR = get(hAxes,'Color'); - -if ischar(AXCOLOR), AXCOLOR = get(hAxes,'Color'); end - -% light colored axes -if sum(AXCOLOR)>1.5 - TEXTCOLOR = [0,0,0]; FACECOLOR = [1 1 238/255]; EDGECOLOR = [.8 .8 .8]; - % dark colored axes (i.e. simulink scopes) -else - TEXTCOLOR = [.8 .8 .6]; FACECOLOR = 48/255*[1 1 1]; EDGECOLOR = [.8 .8 .6]; -end - -%%%%%%%%%%%%% - -% create text objects if necessary -if isempty(hText) || any(~ishandle(hText)) - hText = gobjects(numIntersections,1); - for n = 1:numIntersections - hText(n) = text(xData(n),yData(n),'',... - 'Parent',hThis.GroupHandle, ... % 'Parent',hAxes,... - 'Color',TEXTCOLOR,... - 'EdgeColor',EDGECOLOR,... - 'BackgroundColor',FACECOLOR,... - 'Visible','off'); - end - numText = numIntersections; -else - % if the number of intersections isn't equal to the number of text objects, - % add/delete them as necessary - - set(hText,'Visible','off'); - - numText = length(hText); - - if numText ~= numIntersections - % unequal number of text objects and intersections - delete(hText) - - hText = gobjects(numIntersections,1); - - for n = numIntersections: -1 : 1 - hText(n) = text(xData(n),yData(n),'',... - 'Parent',hThis.GroupHandle, ... % 'Parent',hAxes,... - 'Color',TEXTCOLOR,... - 'EdgeColor',EDGECOLOR,... - 'BackgroundColor',FACECOLOR,... - 'Visible','off'); - end - numText = numIntersections; - end - -end - -% now update the text objects - -set(hText,'Visible','off','Units','data') - -xl = get(hAxes,'XLim'); -yl = get(hAxes,'YLim'); - -xdir = get(hAxes,'XDir'); -ydir = get(hAxes,'YDir'); - -pixperdata = getPixelsPerData(hThis); -pixoffset = 12; - -for n = 1:numText - x = xData(n); - y = yData(n); - - if x >= mean(xl) - if strcmp(xdir,'normal') - halign = 'right'; - xoffset = -pixoffset * 1/pixperdata(1); - else - halign = 'left'; - xoffset = pixoffset * 1/pixperdata(1); - end - else - if strcmp(xdir,'normal') - halign = 'left'; - xoffset = pixoffset * 1/pixperdata(1); - else - halign = 'right'; - xoffset = -pixoffset * 1/pixperdata(1); - end - end - - if y >= mean(yl) - if strcmp(ydir,'normal') - valign = 'top'; - yoffset = -pixoffset * 1/pixperdata(2); - else - valign = 'bottom'; - yoffset = pixoffset * 1/pixperdata(2); - end - else - if strcmp(ydir,'normal') - valign = 'bottom'; - yoffset = pixoffset * 1/pixperdata(2); - else - valign = 'top'; - yoffset = -pixoffset * 1/pixperdata(2); - end - end - - if ~isempty( hThis.TargetZData ) - [~,ind] = min( hypot(hThis.TargetXData-x, hThis.TargetYData-y) ); - ind = ind(1); - z = hThis.TargetZData(ind); - else - z = []; - end - - % assert proper scale - switch [hAxes.XScale '-' hAxes.YScale] - case 'linear-linear' - posoffset = [x+xoffset, y+yoffset, 0]; - case 'log-linear' - posoffset = [x*10^xoffset, y+yoffset, 0]; - case 'linear-log' - posoffset = [x+xoffset, y*10^yoffset, 0]; - case 'log-log' - posoffset = [x*10^xoffset, y*10^yoffset, 0]; - end - - set(hText(n),'Position',posoffset,... - 'String',makeString(x,y,z,hThis.Orientation,hThis.TextDescription),... - 'HorizontalAlignment',halign,... - 'VerticalAlignment',valign); -end - - -set(hThis,'DisplayHandle',hText); - -set(hText,'Visible','on'); - -% -------------------------------------- -function str = makeString(x,y,z,orient,desc) -% MAKESTRING Make the text description string -frmt = '%.3g'; -switch desc - case 'short' - switch orient - case 'vertical' - str = ['Y: ' sprintf(frmt,y)]; - case 'horizontal' - str = ['X: ' sprintf(frmt,x)]; - end - case 'long' - if isempty(z) - str = { ['X: ' sprintf(frmt,x)] , ['Y: ' sprintf(frmt,y)]}; - else - str = { ['X: ' sprintf(frmt,x)] , ['Y: ' sprintf(frmt,y)] , ['Z: ' sprintf(frmt,z)]}; - end -end diff --git a/Required packages/Cursorbar/+graphics/@Cursorbar/drawCrossbar.m b/Required packages/Cursorbar/+graphics/@Cursorbar/drawCrossbar.m deleted file mode 100644 index 0ac66d5..0000000 --- a/Required packages/Cursorbar/+graphics/@Cursorbar/drawCrossbar.m +++ /dev/null @@ -1,109 +0,0 @@ -function hThat = drawCrossbar(hThis,varargin) -% DRAWCROSSBAR Draws a linked perpendicular bar. -% -% See also: graphics.Cursorbar.duplicate, graphics.Cursorbar. -% -% Thanks to Yaroslav Don for his assistance in updating cursorbar for -% MATLAB Graphics and for his contribution of new functionality. - -% Copyright 2015-2016 The MathWorks, Inc. - -% draw crossbar depending on situation: -if isempty(hThis) - % empty Cursorbar: return empty array - hThat = graphics.Cursorbar.empty(size(hThis)); - return - -elseif ~isscalar(hThis) - % an array of Cursorbars: recursively draw crossbar to each - hThat = arrayfun(@(h)drawCrossbar(h,varargin{:}),hThis,'UniformOutput',0); - hThat = reshape([hThat{:}],size(hThis)); - return - -elseif ~isvalid(hThis) - % deleted Cursorbar: create default deleted object - hThat = graphics.GraphicsPlaceholder; - delete(hThat); - return -end - -% error check -assert( isempty(hThis.PeerHandle) || ~isvalid(hThis.PeerHandle), ... - 'graphics:Cursorbar:drawCrossbar:existingCrossbar', ... - 'A crossbar to this cursorbar already exists!'); - -% duplicate -newOrient = theOtherOrientation(hThis); -hThat = duplicate(hThis,varargin{:},'Orientation',newOrient); - -% set peers -hThat.PeerHandle = hThis; -hThis.PeerHandle = hThat; - -% reset position -hThis.Position = theOtherPosition(hThis); -hThat.Position = theOtherPosition(hThis); - -% set container peers -thisContainer = hThis.Container; -thatContainer = hThat.Container; -% -setPeer( thisContainer, thatContainer ); - -% link -localLinkCrossbarProps(hThis); -localLinkCrossbarProps(hThat); - -end - -% -------------------------------------- -function l = localLinkCrossbarProps(hCB) -% LOCALLINKCROSSBARPROPS Set the property linking - -% set listeners -l( 1 ) = addlistener(hCB,'Position', 'PostSet', ... - @(~,~)set(hCB.PeerHandle, 'Position', hCB.Position)); - -l(end+1) = addlistener(hCB,'Orientation','PostSet', ... - @(~,~)set(hCB.PeerHandle, 'Orientation',theOtherOrientation(hCB))); - -l(end+1) = addlistener(hCB,'ObjectBeingDestroyed', ... - @(~,~)localRemoveContainerPeers(hCB)); - -l(end+1) = addlistener(hCB,'ObjectBeingDestroyed', ... - @(~,~)delete(hCB.PeerHandle.ExternalListenerHandles)); - -% store listeners -hCB.ExternalListenerHandles = l; -end - -% -------------------------------------- -function localRemoveContainerPeers(hThis) -% LOCALREMOVECONTAINERPEERS Removes the peers from the containers -key = graphics.internal.CursorbarContainer.Key; -% -hFig = ancestor(hThis.Parent,'figure'); -thisContainers = getappdata(hFig,key); -thisCurrent = thisContainers( thisContainers.hasCursorbar(hThis) ); -% -removePeer(thisCurrent); -end - -% -------------------------------------- -function orient = theOtherOrientation(hCB) -% THEOTHERORIENTATION Returns the other orientation -switch hCB.Orientation - case 'horizontal', orient='vertical'; - case 'vertical', orient='horizontal'; -end -end - -% -------------------------------------- -function pos = theOtherPosition(hCB) -% THEOTHERPOSITION Returns the other position -pos = hCB.Position; -switch hCB.Orientation - case 'horizontal', pos(1)=hCB.PeerHandle.Location; - case 'vertical', pos(2)=hCB.PeerHandle.Location; -end -end diff --git a/Required packages/Cursorbar/+graphics/@Cursorbar/duplicate.m b/Required packages/Cursorbar/+graphics/@Cursorbar/duplicate.m deleted file mode 100644 index c2425ce..0000000 --- a/Required packages/Cursorbar/+graphics/@Cursorbar/duplicate.m +++ /dev/null @@ -1,64 +0,0 @@ -function hThat = duplicate(hThis,varargin) -% DUPLICATE Duplicate the cursorbar to an identical one. -% -% Duplicate created an identical Cursorbar to the desired by directly -% calling the Cursorbar constructor. Cursorbar has no copy method and does -% not subclass matlab.mixin.Copyable, since the copying procedure in handle -% graphics may result in unexpected behavior. Instead, it uses duplicate as -% a hard-copy method. -% -% See also: graphics.Cursorbar.drawCrossbar, graphics.Cursorbar. -% -% Thanks to Yaroslav Don for his assistance in updating cursorbar for -% MATLAB Graphics and for his contribution of new functionality. - -% Copyright 2015-2016 The MathWorks, Inc. - -% duplicate depending on situation: -if isempty(hThis) - % empty Cursorbar: return empty array - hThat = graphics.Cursorbar.empty(size(hThis)); - -elseif ~isscalar(hThis) - % an array of Cursorbars: recursively duplicate each - hThat = arrayfun(@(h)duplicate(h,varargin{:}),hThis,'UniformOutput',0); - hThat = reshape([hThat{:}],size(hThis)); - -elseif ~isvalid(hThis) - % deleted Cursorbar: create default deleted object - hThat = graphics.GraphicsPlaceholder; - delete(hThat); - -else - % everything is okay: duplicate the Cursorbar - hThat = graphics.Cursorbar( hThis.Target, ... - 'BottomMarker', hThis.BottomMarker, ... - 'CreateFcn', hThis.CreateFcn, ... - 'CursorLineColor', hThis.CursorLineColor, ... - 'CursorLineStyle', hThis.CursorLineStyle, ... - 'CursorLineWidth', hThis.CursorLineWidth, ... - 'DeleteFcn', hThis.DeleteFcn, ... - 'DisplayName', hThis.DisplayName, ... - 'FigureCallbacks', hThis.FigureCallbacks, ... - 'HitTest', hThis.HitTest, ... - 'Interruptible', hThis.Interruptible, ... - 'Location', hThis.Location, ... - 'Orientation', hThis.Orientation, ... - 'Parent', hThis.Parent, ... - 'Position', hThis.Position, ... - 'SelectionHighlight', hThis.SelectionHighlight, ... - 'ShowText', hThis.ShowText, ... - 'Tag', hThis.Tag, ... - 'TargetIntersections', hThis.TargetIntersections, ... - 'TargetMarkerEdgeColor', hThis.TargetMarkerEdgeColor, ... - 'TargetMarkerFaceColor', hThis.TargetMarkerFaceColor, ... - 'TargetMarkerSize', hThis.TargetMarkerSize, ... - 'TargetMarkerStyle', hThis.TargetMarkerStyle, ... - 'TextDescription', hThis.TextDescription, ... - 'TopMarker', hThis.TopMarker, ... - 'UserData', hThis.UserData, ... - 'Visible', hThis.Visible, ... - varargin{:}); -end - -end diff --git a/Required packages/Cursorbar/+graphics/@Cursorbar/getCursorInfo.m b/Required packages/Cursorbar/+graphics/@Cursorbar/getCursorInfo.m deleted file mode 100644 index 7269e5f..0000000 --- a/Required packages/Cursorbar/+graphics/@Cursorbar/getCursorInfo.m +++ /dev/null @@ -1,15 +0,0 @@ -function info = getCursorInfo(hThis) -% GETCURSORINFO Get datacursor info from cursorbar -% -% See also: graphics.Cursorbar.getMarkerLocations, graphics.Cursorbar. -% -% Thanks to Yaroslav Don for his assistance in updating cursorbar for -% MATLAB Graphics and for his contribution of new functionality. - -% Copyright 2003-2016 The MathWorks, Inc. - -info = struct; - -hDC = hThis.DataCursorHandle; - -info.Position = hDC.Position; diff --git a/Required packages/Cursorbar/+graphics/@Cursorbar/getIntersections.m b/Required packages/Cursorbar/+graphics/@Cursorbar/getIntersections.m deleted file mode 100644 index 533ad7d..0000000 --- a/Required packages/Cursorbar/+graphics/@Cursorbar/getIntersections.m +++ /dev/null @@ -1,108 +0,0 @@ -function [xIntersect,yIntersect,hIntersect] = getIntersections(hThis,hLines) -% GETINTERSECTIONS Return intersection information -% -% Thanks to Yaroslav Don for his assistance in updating cursorbar for -% MATLAB Graphics and for his contribution of new functionality. - -% Copyright 2003-2016 The MathWorks, Inc. - -% check inputs -if nargin > 1 - hLines = handle(hLines); - if ~all(isTargetChart(hThis)) - error(message('MATLAB:graphics:cursorbar:invalidInput')); - end -else - hLines = hThis.Target; -end - -xIntersect = []; -yIntersect = []; -hIntersect = []; - -if isTargetAxes(hThis) && nargin < 2 - % Target is an axes, no additional line handles as input, return early - return -end - -% get lines' XData and YData -xData = get(hLines,'XData'); -yData = get(hLines,'YData'); - -numLines = numel(hLines); - -if numLines == 1 - xData = xData(:); - yData = yData(:); - hData = repmat(hLines,size(xData)); -else - xSizes = cellfun('prodofsize',xData); - - % determine new length for NaN separated data vectors - newLength = sum(xSizes) + numLines - 1; - - new_xData = zeros(newLength,1); - new_yData = zeros(newLength,1); - hData = zeros(newLength,1); - - startIndex = 1; - for n = 1:numLines - finishIndex = startIndex + xSizes(n) - 1; - new_xData(startIndex:finishIndex) = xData{n}; - new_yData(startIndex:finishIndex) = yData{n}; - hData(startIndex:finishIndex) = hLines(n); - - if n < numLines - new_xData(finishIndex + 1) = NaN; - new_yData(finishIndex + 1) = NaN; - hData(finishIndex + 1) = NaN; - end - startIndex = finishIndex + 2; - end - xData = new_xData; - yData = new_yData; -end - -xSegs = zeros(length(xData)-1,2); -ySegs = zeros(length(yData)-1,2); - -xSegs(:,1) = xData(1:end-1); -xSegs(:,2) = xData(2:end); - -ySegs(:,1) = yData(1:end-1); -ySegs(:,2) = yData(2:end); - -loc = hThis.Location; - -switch hThis.Orientation - case 'vertical' - btwn = (xSegs(:,1) < loc & loc <= xSegs(:,2)) | (xSegs(:,2) < loc & loc <= xSegs(:,1)); - case 'horizontal' - btwn = (ySegs(:,1) < loc & loc <= ySegs(:,2)) | (ySegs(:,2) < loc & loc <= ySegs(:,1)); -end - -new_xSegs = xSegs(btwn,:); -new_ySegs = ySegs(btwn,:); - -numIntersect = length(find(btwn)); -xIntersect = zeros(numIntersect,1); -yIntersect = zeros(numIntersect,1); - -if numIntersect == 0 - return -end - -switch hThis.Orientation - case 'vertical' - for n = 1:numIntersect - xIntersect(n) = loc; - yIntersect(n) = interp1(new_xSegs(n,:),new_ySegs(n,:),loc); - end - case 'horizontal' - for n = 1:numIntersect - yIntersect(n) = loc; - xIntersect(n) = interp1(new_ySegs(n,:),new_xSegs(n,:),loc); - end -end - -hIntersect = hData(btwn); diff --git a/Required packages/Cursorbar/+graphics/@Cursorbar/getMarkerLocations.m b/Required packages/Cursorbar/+graphics/@Cursorbar/getMarkerLocations.m deleted file mode 100644 index e53c7b7..0000000 --- a/Required packages/Cursorbar/+graphics/@Cursorbar/getMarkerLocations.m +++ /dev/null @@ -1,14 +0,0 @@ -function [x,y] = getMarkerLocations(hThis) -% GETMARKERLOCATIONS Return x,y position of the Cursorbar's intersection markers -% -% See also: graphics.Cursorbar.getCursorInfo, graphics.Cursorbar. -% -% Thanks to Yaroslav Don for his assistance in updating cursorbar for -% MATLAB Graphics and for his contribution of new functionality. - -% Copyright 2003-2016 The MathWorks, Inc. - -hMarker = hThis.TargetMarkerHandle; - -x = get(hMarker,'XData'); -y = get(hMarker,'YData'); diff --git a/Required packages/Cursorbar/+graphics/@Cursorbar/getPixelsPerData.m b/Required packages/Cursorbar/+graphics/@Cursorbar/getPixelsPerData.m deleted file mode 100644 index 729f26f..0000000 --- a/Required packages/Cursorbar/+graphics/@Cursorbar/getPixelsPerData.m +++ /dev/null @@ -1,32 +0,0 @@ -function pixperdata = getPixelsPerData(hThis) -% GETPIXELSPERDATA Return pixel-per-data ratio -% -% Thanks to Yaroslav Don for his assistance in updating cursorbar for -% MATLAB Graphics and for his contribution of new functionality. - -% Copyright 2003-2016 The MathWorks, Inc. - -% Change Log: -% 13 Feb 2015: First version posted on the MathWorks file exchange. -% 14 May 2015: Added logarithmic scale support. - -hAxes = get(hThis,'Parent'); - -% get axes' limits -xl = get(hAxes,'XLim'); -yl = get(hAxes,'YLim'); - -% get Axes' pixel position -pixpos = getpixelposition(hAxes); - -% assert proper scale -switch [hAxes.XScale '-' hAxes.YScale] - case 'linear-linear' - pixperdata = [ pixpos(3) / (xl(2)-xl(1)), pixpos(4) / (yl(2)-yl(1))]; - case 'log-linear' - pixperdata = [ pixpos(3) / log10(xl(2)/xl(1)), pixpos(4) / (yl(2)-yl(1))]; - case 'linear-log' - pixperdata = [ pixpos(3) / (xl(2)-xl(1)), pixpos(4) / log10(yl(2)/yl(1))]; - case 'log-log' - pixperdata = [ pixpos(3) / log10(xl(2)/xl(1)), pixpos(4) / log10(yl(2)/yl(1))]; -end diff --git a/Required packages/Cursorbar/+graphics/@Cursorbar/getTargetXYData.m b/Required packages/Cursorbar/+graphics/@Cursorbar/getTargetXYData.m deleted file mode 100644 index bd6581c..0000000 --- a/Required packages/Cursorbar/+graphics/@Cursorbar/getTargetXYData.m +++ /dev/null @@ -1,103 +0,0 @@ -function [x,y,z,n] = getTargetXYData(hThis,orient) -% GETTARGETXYDATA Create vectors of Target XData and YData -% -% Thanks to Yaroslav Don for his assistance in updating cursorbar for -% MATLAB Graphics and for his contribution of new functionality. - -% Copyright 2003-2016 The MathWorks, Inc. - -% set inputs -if nargin<2 || isempty(orient) - orient = hThis.Orientation; -end -hTarget = hThis.Target; - -x = []; -y = []; -z = []; -n = []; - -% set data -if isTargetAxes(hThis) - return -else - if isa(hTarget,'matlab.graphics.chart.primitive.Histogram') - xDataName = 'BinEdges'; - yDataName = 'Values'; - else - xDataName = 'XData'; - yDataName = 'YData'; - end - % - if numel(hTarget) == 1 - xData = {get(hTarget,xDataName)}; - yData = {get(hTarget,yDataName)}; - else % should all be lines - xData = get(hTarget, xDataName); - yData = get(hTarget, yDataName); - end - % - if isa(hTarget,'matlab.graphics.chart.primitive.Histogram') - xData = cellfun(@(x)x(2:end)-diff(x)/2, xData, 'UniformOutput', 0); % transform to BinCenters - end -end - -% check if CData exists -try - try - zData = {hTarget.ZData}; - catch - zData = {hTarget.CData}; - end - isZData = sum(cellfun('prodofsize',zData))>0; - % - if isZData && ~isequal( cellfun(@numel,xData), cellfun(@numel,zData) ) - [xData, yData] = cellfun( @meshgrid, xData, yData, 'UniformOutput', 0); - xData = cellfun( @(a)a(:).', xData, 'UniformOutput', 0); - yData = cellfun( @(a)a(:).', yData, 'UniformOutput', 0); - end -catch % never mind ... - zData = {}; - isZData = false; -end - -% determine how many vertices each line has -numLineVertices = cellfun('prodofsize',xData); - -% determine the total number of vertices -numAllVertices = sum(numLineVertices); - -% create vectors to hold locations for all vertices -xVertices = zeros(1,numAllVertices); -yVertices = zeros(1,numAllVertices); -zVertices = zeros(1,numAllVertices); -nVertices = zeros(1,numAllVertices); - -% initialize variable to hold the last entered data position -lastDataPos = 0; -for n = 1:length(hTarget) - lenData = length(xData{n}); - xVertices(lastDataPos+1:lastDataPos+lenData) = xData{n}; - yVertices(lastDataPos+1:lastDataPos+lenData) = yData{n}; - if isZData - zVertices(lastDataPos+1:lastDataPos+lenData) = zData{n}; - end - nVertices(lastDataPos+1:lastDataPos+lenData) = n; - lastDataPos = lastDataPos + lenData; -end - -% sort the Target's XData and YData based on the Orientation -switch orient - case 'vertical' - [x,ind] = sort(xVertices); - y = yVertices(ind); - case 'horizontal' - [y,ind] = sort(yVertices); - x = xVertices(ind); -end - -if isZData - z = zVertices(ind); -end - -n = nVertices(ind); diff --git a/Required packages/Cursorbar/+graphics/@Cursorbar/isTargetAxes.m b/Required packages/Cursorbar/+graphics/@Cursorbar/isTargetAxes.m deleted file mode 100644 index a5be47f..0000000 --- a/Required packages/Cursorbar/+graphics/@Cursorbar/isTargetAxes.m +++ /dev/null @@ -1,21 +0,0 @@ -function tf = isTargetAxes(hThis) -% ISTARGETAXES Is the Target an axes -% -% See also: graphics.Cursorbar.isTargetChart, graphics.Cursorbar. -% -% Thanks to Yaroslav Don for his assistance in updating cursorbar for -% MATLAB Graphics and for his contribution of new functionality. - -% Copyright 2003-2016 The MathWorks, Inc. - -tf = false; - -% return empty if there is no Target -if isempty(hThis.Target) - tf = []; - return -end - -if (length(hThis.Target) == 1) && ishandle(hThis.Target) && isa(hThis.Target,'matlab.graphics.axis.Axes') - tf = true; -end diff --git a/Required packages/Cursorbar/+graphics/@Cursorbar/isTargetChart.m b/Required packages/Cursorbar/+graphics/@Cursorbar/isTargetChart.m deleted file mode 100644 index c212f29..0000000 --- a/Required packages/Cursorbar/+graphics/@Cursorbar/isTargetChart.m +++ /dev/null @@ -1,36 +0,0 @@ -function tf = isTargetChart(hThis,hTarget) -% ISTARGETCHART Is the Target a permitted chart object -% -% See also: graphics.Cursorbar.isTargetAxes, graphics.Cursorbar. -% -% Thanks to Yaroslav Don for his assistance in updating cursorbar for -% MATLAB Graphics and for his contribution of new functionality. - -% Copyright 2015-2016 The MathWorks, Inc. - -% set the target -if nargin<2 - hTarget = hThis.Target; -end - -% return empty if there is no Target -if isempty(hTarget) - tf = []; - return -end -% -if ~all(ishandle(hTarget)) - tf = false(size(hTarget)); - return -end - -% check -tf = arrayfun(@isChart,hTarget); - -function tf = isChart(hTarget) -switch class(hTarget) % fastest comparison with switch - case graphics.Cursorbar.PermittedChartTargets - tf = true; - otherwise - tf = false; -end diff --git a/Required packages/Cursorbar/+graphics/@Cursorbar/move.m b/Required packages/Cursorbar/+graphics/@Cursorbar/move.m deleted file mode 100644 index 504173a..0000000 --- a/Required packages/Cursorbar/+graphics/@Cursorbar/move.m +++ /dev/null @@ -1,16 +0,0 @@ -function move(hThis,dir) -% MOVE Move the data cursor and update cursorbar -% -% Thanks to Yaroslav Don for his assistance in updating cursorbar for -% MATLAB Graphics and for his contribution of new functionality. - -% Copyright 2003-2016 The MathWorks, Inc. - -% Update cursor based on direction -moveDataCursor(hThis.DataCursorHandle,hThis,hThis.DataCursorHandle,dir); - -pos = get(hThis.DataCursorHandle,'Position'); -set(hThis,'Position',pos); - -% throw event indicating that the cursorbar was updated -notify(hThis,'UpdateCursorBar'); diff --git a/Required packages/Cursorbar/+graphics/@Cursorbar/moveDataCursor.m b/Required packages/Cursorbar/+graphics/@Cursorbar/moveDataCursor.m deleted file mode 100644 index 5afab4e..0000000 --- a/Required packages/Cursorbar/+graphics/@Cursorbar/moveDataCursor.m +++ /dev/null @@ -1,187 +0,0 @@ -function moveDataCursor(hThis,hDataCursor,direc) -% MOVEDATACURSOR Move the data cursor -% -% Thanks to Yaroslav Don for his assistance in updating cursorbar for -% MATLAB Graphics and for his contribution of new functionality. - -% Copyright 2003-2016 The MathWorks, Inc. - -% Change Log: -% 13 Feb 2015: First version posted on the MathWorks file exchange. -% 14 May 2015: Added logarithmic scale support. - -pos = hDataCursor.Position; - -hTarget = hThis.Target; -hAxes = get(hThis,'Parent'); - -xdir = get(hAxes,'XDir'); -ydir = get(hAxes,'YDir'); - -if all(isTargetChart(hThis)) - % determine next vertex - x = pos(1); - y = pos(2); - - XData = hThis.TargetXData; - YData = hThis.TargetYData; - - switch hThis.Orientation - case 'vertical' - % determine what the next possible X value is - switch xdir - case 'normal' - switch direc - case 'right' - % find next largest x value - ind = localNextIndex(x,XData,'greater'); - pos(1) = XData(ind); - pos(2) = YData(ind); - case 'left' - % find next smallest x value - ind = localNextIndex(x,XData,'less'); - pos(1) = XData(ind); - pos(2) = YData(ind); - otherwise - % do nothing - end - case 'reverse' - switch direc - case 'right' - % find next smallest x value - ind = localNextIndex(x,XData,'less'); - pos(1) = XData(ind); - pos(2) = YData(ind); - case 'left' - % find next largest x value - ind = localNextIndex(x,XData,'greater'); - pos(1) = XData(ind); - pos(2) = YData(ind); - otherwise - % do nothing - end - end - case 'horizontal' - % determine what the next possible Y value is - switch ydir - case 'normal' - switch direc - case 'up' - % find next largest x value - ind = localNextIndex(y,YData,'greater'); - pos(1) = XData(ind); - pos(2) = YData(ind); - case 'down' - % find next smallest x value - ind = localNextIndex(y,YData,'less'); - pos(1) = XData(ind); - pos(2) = YData(ind); - otherwise - % do nothing - end - case 'reverse' - switch direc - case 'up' - % find next smallest x value - ind = localNextIndex(y,YData,'less'); - pos(1) = XData(ind); - pos(2) = YData(ind); - case 'down' - % find next largest x value - ind = localNextIndex(y,YData,'greater'); - pos(1) = XData(ind); - pos(2) = YData(ind); - otherwise - % do nothing - end - end - end -elseif numel(hTarget) == 1 && isa(hTarget,'matlab.graphics.axis.Axes') - pixperdata = getPixelsPerData(hThis); - switch hThis.Orientation - case 'vertical' - switch xdir - case 'normal' - switch direc - case 'right' - xoffset = + 1/pixperdata(1); - case 'left' - xoffset = - 1/pixperdata(1); - otherwise - % do nothing - end - case 'reverse' - switch direc - case 'right' - xoffset = - 1/pixperdata(1); - case 'left' - xoffset = + 1/pixperdata(1); - otherwise - % do nothing - end - end - case 'horizontal' - switch ydir - case 'normal' - switch direc - case 'up' - yoffset = + 1/pixperdata(2); - case 'down' - yoffset = - 1/pixperdata(2); - otherwise - % do nothing - end - case 'reverse' - switch direc - case 'up' - yoffset = - 1/pixperdata(2); - case 'down' - yoffset = + 1/pixperdata(2); - otherwise - % do nothing - end - end - otherwise - % not vertical or horizontal - end - - % assert proper scale - x = pos(1); - y = pos(2); - % - switch [hAxes.XScale '-' hAxes.YScale] - case 'linear-linear' - pos = [x+xoffset, y+yoffset, 0]; - case 'log-linear' - pos = [x*10^xoffset, y+yoffset, 0]; - case 'linear-log' - pos = [x+xoffset, y*10^yoffset, 0]; - case 'log-log' - pos = [x*10^xoffset, y*10^yoffset, 0]; - end - -else - % not lines or an axes -end - - -hDataCursor.Position = pos; - -function ind = localNextIndex(d,Data,cmp) - -switch cmp - case 'greater' - ind = find(Data > d); - if isempty(ind) - ind = length(Data); - return - end - ind = min(ind); - case 'less' - ind = find(Data < d); - if isempty(ind) - ind = 1; - return - end - ind = max(ind); -end diff --git a/Required packages/Cursorbar/+graphics/@Cursorbar/update.m b/Required packages/Cursorbar/+graphics/@Cursorbar/update.m deleted file mode 100644 index 1a79b84..0000000 --- a/Required packages/Cursorbar/+graphics/@Cursorbar/update.m +++ /dev/null @@ -1,41 +0,0 @@ -function update(hThis,~,~,varargin) -% UPDATE Update cursorbar position and string -% -% Thanks to Yaroslav Don for his assistance in updating cursorbar for -% MATLAB Graphics and for his contribution of new functionality. - -% Copyright 2003-2016 The MathWorks, Inc. - - -% Exit during construction -if hThis.ObjectBeingCreated - return -end - -% Check input -movecb = true; -if nargin >= 4 && ischar(varargin{1}) && strcmp(varargin{1},'-nomove') - movecb = false; -end - -% Create new data cursor -if isvalid(hThis.DataCursorHandle) - hNewDataCursor = hThis.DataCursorHandle; -else - hNewDataCursor = createNewDataCursor(hThis); -end - -% Update cursor based on target -if movecb - updateDataCursor(hThis,hNewDataCursor); - hNewDataCursor = hThis.DataCursorHandle; % in the case it has changed -end - -% Update cursorbar based on cursor -updatePosition(hThis,hNewDataCursor); - -% Update markers -updateMarkers(hThis); - -% Send event indicating that the cursorbar was updated -notify(hThis,'UpdateCursorBar'); diff --git a/Required packages/Cursorbar/+graphics/@Cursorbar/updateDataCursor.m b/Required packages/Cursorbar/+graphics/@Cursorbar/updateDataCursor.m deleted file mode 100644 index f80e5e1..0000000 --- a/Required packages/Cursorbar/+graphics/@Cursorbar/updateDataCursor.m +++ /dev/null @@ -1,43 +0,0 @@ -function updateDataCursor(hThis,hNewDataCursor,~) -%UPDATEDATACURSOR Updates DataCursor's position. -% -% Thanks to Yaroslav Don for his assistance in updating cursorbar for -% MATLAB Graphics and for his contribution of new functionality. - -% Copyright 2003-2016 The MathWorks, Inc. - -hAxes = get(hThis,'Parent'); -cp = get(hAxes,'CurrentPoint'); -pos = [cp(1,1) cp(1,2) 0]; -hTarget = hThis.Target; - -if isTargetAxes(hThis) - % axes: ignore interpolation, just use the axes' CurrentPoint - hNewDataCursor.DataSource.XData = pos(1); - hNewDataCursor.DataSource.YData = pos(2); - -else - % put the DataCursor in a correct place - [x,y,n] = closestvertex(hThis,pos); - if ~isscalar(hTarget) - if isa(hTarget,'matlab.graphics.chart.interaction.DataAnnotatable') - hNewDataCursor.DataSource = hTarget(n); - else - hNewDataCursor = createNewDataCursor(hThis,hTarget(n)); - end - end - - % update the DataCursor - if strcmp(hAxes.Parent.Type,'figure') - % update directly - hNewDataCursor.Position = [x y 0]; - else - % if the parent is not a figure (e.g., panel), the position of the - % DataCursor is not rendered correctly; thus, a change of parents - % is mandatory - axesPar = hAxes.Parent; - hAxes.Parent = ancestor(hAxes,'figure'); - hNewDataCursor.Position = [x y 0]; - hAxes.Parent = axesPar; - end -end diff --git a/Required packages/Cursorbar/+graphics/@Cursorbar/updateDisplay.m b/Required packages/Cursorbar/+graphics/@Cursorbar/updateDisplay.m deleted file mode 100644 index 9e4cbe7..0000000 --- a/Required packages/Cursorbar/+graphics/@Cursorbar/updateDisplay.m +++ /dev/null @@ -1,33 +0,0 @@ -function updateDisplay(hThis,~,~) -% UPDATEDISPLAY Updates DisplayHandle. -% -% Thanks to Yaroslav Don for his assistance in updating cursorbar for -% MATLAB Graphics and for his contribution of new functionality. - -% Copyright 2003-2016 The MathWorks, Inc. - -% exit during construction -if hThis.ObjectBeingCreated - return -end - -% update text handles -hText = get(hThis,'DisplayHandle'); -% -if strcmp(hThis.ShowText,'off') || strcmp(hThis.Visible,'off') - if ~isempty(hText) - delete(hText); - hThis.DisplayHandle = gobjects(0); - return - end - return -end - -% update -defaultUpdateFcn(hThis); - -if ~isempty(hThis.UpdateFcn) - hThis.localApplyUpdateFcn(hThis,[]); -end - - diff --git a/Required packages/Cursorbar/+graphics/@Cursorbar/updateMarkers.m b/Required packages/Cursorbar/+graphics/@Cursorbar/updateMarkers.m deleted file mode 100644 index e2f127f..0000000 --- a/Required packages/Cursorbar/+graphics/@Cursorbar/updateMarkers.m +++ /dev/null @@ -1,55 +0,0 @@ -function updateMarkers(hThis) -% UPDATEMARKERS Updates data markers. -% -% Thanks to Yaroslav Don for his assistance in updating cursorbar for -% MATLAB Graphics and for his contribution of new functionality. - -% Copyright 2003-2016 The MathWorks, Inc. - -% exit during construction -if hThis.ObjectBeingCreated - return -end - -% get line handles -hTarget = hThis.Target; - -% get current position -pos = get(hThis,'Position'); -if isempty(pos), return; end % probably, at startup - -% determine which vertices will be intersected -switch hThis.TargetIntersections - case 'multiple' % find all intersection based on the Orientation - switch hThis.Orientation - case 'vertical' - ind = find(hThis.TargetXData == pos(1)); % find only the identical positions - if isempty(ind) - [~,ind] = min( abs(hThis.TargetXData - pos(1)) ); % find the closest ones - end - case 'horizontal' - ind = find(hThis.TargetYData == pos(2)); % find only the identical positions - if isempty(ind) - [~,ind] = min( abs(hThis.TargetYData - pos(2)) ); % find the closest ones - end - end - case 'single' % just the closest ones - [~,ind] = min( hypot(hThis.TargetXData-pos(1), hThis.TargetYData-pos(2)) ); - if ~isempty(ind) - ind = ind(1); - end -end - -% set the target markers -if all(isvalid(hThis.TargetMarkerHandle)) - if all(isvalid(hTarget)) && ~isa(hTarget,'matlab.graphics.axis.Axes') - set(hThis.TargetMarkerHandle,'Visible','on',... - 'XData',hThis.TargetXData(ind),... - 'YData',hThis.TargetYData(ind)); - else - % - set(hThis.TargetMarkerHandle,'Visible','off',... - 'XData',[],... - 'YData',[]); - end -end diff --git a/Required packages/Cursorbar/+graphics/@Cursorbar/updatePosition.m b/Required packages/Cursorbar/+graphics/@Cursorbar/updatePosition.m deleted file mode 100644 index b8cfe0c..0000000 --- a/Required packages/Cursorbar/+graphics/@Cursorbar/updatePosition.m +++ /dev/null @@ -1,36 +0,0 @@ -function updatePosition(hThis,hNewDataCursor) -% UPDATEPOSITION Update cursorbar position based on data cursor -% -% Thanks to Yaroslav Don for his assistance in updating cursorbar for -% MATLAB Graphics and for his contribution of new functionality. - -% Copyright 2003-2016 The MathWorks, Inc. - -% Set parameters -pos = hNewDataCursor.Position; -hAxes = hThis.Parent; -ok = false; - -% See if the cursor position is empty or outside the axis limits -xlm = get(hAxes,'XLim'); -ylm = get(hAxes,'YLim'); -zlm = get(hAxes,'ZLim'); -% -if ~isempty(pos) && ... - (pos(1) >= min([xlm Inf])) && (pos(1) <= max([xlm -Inf])) && ... - (pos(2) >= min([ylm Inf])) && (pos(2) <= max([ylm -Inf])) - if length(pos) > 2 - if pos(3) >= min([zlm Inf]) && pos(3) <= max([zlm -Inf]) - ok =true; - end - else - pos(3) = 0; - ok = true; - end -end - -% Update DataCursorHandle and Position -if ok - hThis.DataCursorHandle = hNewDataCursor; - hThis.Position = pos; -end diff --git a/Required packages/Cursorbar/+graphics/Graphics.m b/Required packages/Cursorbar/+graphics/Graphics.m deleted file mode 100644 index a653740..0000000 --- a/Required packages/Cursorbar/+graphics/Graphics.m +++ /dev/null @@ -1,187 +0,0 @@ -classdef (Abstract) Graphics < handle & matlab.mixin.Heterogeneous & matlab.mixin.CustomDisplay - % Graphics Common base class for graphics objects - % - % The graphics.Graphics class is the base class of all graphics objects. - % Because graphics objects are part of a heterogeneous hierarchy, you - % can create arrays of mixed classes (for example, an array can contain - % lines, surfaces, axes, and other graphics objects). - % - % The class of an array of mixed objects is graphics.Graphics because - % this class is common to all graphics objects. - % - % Graphics requires the new MATLAB graphics system that - % was introduced in R2014b - % - % Inherited matlab.mixin.CustomDisplay Methods: - % details - Fully detailed formal object display. - % disp - Simple informal object display. - % display - Print variable name and display object. - % - % Inherited matlab.mixin.Heterogeneous Methods: - % cat - Concatenation for heterogeneous arrays. - % horzcat - Horizontal concatenation for - % heterogeneous arrays. - % vertcat - Vertical concatenation for - % heterogeneous arrays. - % - % Protected Methods: - % getDefaultScalarElement - Define default element for array - % operations. - % - % Inherited handle Methods: - % addlistener - Add listener for event. - % delete - Delete a handle object. - % eq - Test handle equality. - % findobj - Find objects with specified property - % values. - % findprop - Find property of MATLAB handle object. - % ge - Greater than or equal relation. - % gt - Greater than relation. - % isvalid - Test handle validity. - % le - Less than or equal relation for handles. - % lt - Less than relation for handles. - % ne - Not equal relation for handles. - % notify - Notify listeners of event. - % - % Inherited handle Events: - % ObjectBeingDestroyed - Notifies listeners that a particular - % object has been destroyed. - % Web: - % Undocumented Matlab: Undocumented cursorbar object. - % - % See also: graphics.GraphicsPlaceholder, graphics.Cursorbar. - % - % Thanks to Yaroslav Don for his assistance in updating cursorbar for - % MATLAB Graphics and for his contribution of new functionality. - - % Copyright 2016 The MathWorks, Inc. - - %% Main methods - - methods - function hThis = Graphics() - % Graphics A Graphics constructor. - % - % See also: Graphics. - - % Check MATLAB Graphics system version - if verLessThan('matlab','8.4.0') - error('graphics:Graphics:Graphics:oldVersion', ... - 'Graphics requires the new MATLAB graphics system that was introduced in R2014b.'); - end - end - end - - %% Heterogeneous methods - - methods (Static, Sealed, Access = protected) - function defaultObject = getDefaultScalarElement - defaultObject = graphics.GraphicsPlaceholder; - end - end - - %% Custom Display Methods - - methods (Access = protected, Sealed) - - % -------------------------------------- - function header = getHeader(hThis) - if ~isscalar(hThis) - % Non-scalar case: call superclass method - headerStr = getHeader@matlab.mixin.CustomDisplay(hThis); - if ismatrix(hThis) && ~isempty(hThis) - header = regexprep(headerStr,' with( no)? properties[\.:]',':'); - else - header = regexprep(headerStr,' with( no)? properties[\.:]','.'); - end - header = regexprep(header,'heterogeneous |heterogeneous ',''); - else - % Scalar case: check if a new header is required - if isprop(hThis,'Tag') - tagStr = hThis.Tag; - else - tagStr = ''; - end - % - if isempty(tagStr) - % No tag: call superclass method - header = getHeader@matlab.mixin.CustomDisplay(hThis); - else - % Use the tag - headerStr = matlab.mixin.CustomDisplay.getClassNameForHeader(hThis); - header = sprintf(' %s (%s) with properties:\n',headerStr,tagStr); - end - end - end - - % -------------------------------------- - function groups = getPropertyGroups(hThis) - % GETPROPERTYGROUPS Construct array of property groups. - if isscalar(hThis) - % Scalar case: call unsealed getScalarPropertyGroups - groups = getScalarPropertyGroups(hThis); - else - % Non-scalar case: empty list - groups = matlab.mixin.util.PropertyGroup({}); - end - end - - % -------------------------------------- - function footer = getFooter(hThis) - % GETFOOTER Build and return display footer text. - - if isscalar(hThis) - % Scalar case: prompt to show all properties - % similarly to graphics objects - if isempty(properties(hThis)) - % No properties: call superclass method - footer = getFooter@matlab.mixin.CustomDisplay(hThis); - return; - end - % - iname = inputname(1); - if isempty(iname) - iname = 'ans'; % ans is the default input name - end - % - footer = sprintf(... - [' Show all properties\n'], ... - iname,iname,iname,class(hThis),iname); - elseif ismatrix(hThis) && ~isempty(hThis) - % Non-scalar matrix case: show object's classes - % extract naked class name - txt = arrayfun(@class,hThis,'Uni',0); - txt = regexprep(txt,'^.*\.',''); - % add spaces and end-of-line - len = max(cellfun(@length,txt(:))); - txt = cellfun(@(s)sprintf(' %-*s',len,s),txt,'Uni',0); - txt(:,end) = strcat(txt(:,end),{sprintf('\n')}); - % finalize - footer = cell2mat(txt)'; - else - % Non-scalar case: call superclass method - footer = getFooter@matlab.mixin.CustomDisplay(hThis); - end - end - end - - % ============================================================= % - - methods (Access = protected) - function groups = getScalarPropertyGroups(hThis) %#ok - % GETSCALARPROPERTYGROUPS Construct array of property groups for display of scalar case. - - % default is empty - groups = matlab.mixin.util.PropertyGroup({}); - end - - end - -end - diff --git a/Required packages/Cursorbar/+graphics/GraphicsPlaceholder.m b/Required packages/Cursorbar/+graphics/GraphicsPlaceholder.m deleted file mode 100644 index f0c4608..0000000 --- a/Required packages/Cursorbar/+graphics/GraphicsPlaceholder.m +++ /dev/null @@ -1,85 +0,0 @@ -classdef (ConstructOnLoad=true) GraphicsPlaceholder < graphics.Graphics - % GraphicsPlaceholder Default graphics object. - % - % The graphics.GraphicsPlaceholder class defines the default graphics - % object. Instances of this class appear as: - % - % * Elements of pre-allocated arrays created with hobjects. - % * Unassigned array element placeholders - % * Graphics object properties that hold object handles, but are set - % to empty values - % * Empty values returned by functions that return object handles (for - % example, findobj). - % - % Usage: - % graphics.GraphicsPlaceholder() - Creates a GraphicsPlaceholder. - % - % Example: - % x = linspace(0,20,101); - % y = sin(x); - % % - % hPlot = plot(x,y); - % hCBar(3) = cursorbar(hPlot); - % hGPHolder = hCBar(1) - % - % GraphicsPlaceholder Constructor: - % GraphicsPlaceholder - GraphicsPlaceholder constructor. - % - % Inherited matlab.mixin.CustomDisplay Methods: - % details - Fully detailed formal object display. - % disp - Simple informal object display. - % display - Print variable name and display object. - % - % Inherited matlab.mixin.Heterogeneous Methods: - % cat - Concatenation for heterogeneous arrays. - % horzcat - Horizontal concatenation for - % heterogeneous arrays. - % vertcat - Vertical concatenation for - % heterogeneous arrays. - % - % Inherited handle Methods: - % addlistener - Add listener for event. - % delete - Delete a handle object. - % eq - Test handle equality. - % findobj - Find objects with specified property - % values. - % findprop - Find property of MATLAB handle object. - % ge - Greater than or equal relation. - % gt - Greater than relation. - % isvalid - Test handle validity. - % le - Less than or equal relation for handles. - % lt - Less than relation for handles. - % ne - Not equal relation for handles. - % notify - Notify listeners of event. - % - % Inherited handle Events: - % ObjectBeingDestroyed - Notifies listeners that a particular - % object has been destroyed. - % Web: - % Undocumented Matlab: Undocumented cursorbar object. - % - % See also: graphics.Graphics, hobjects. - % - % Thanks to Yaroslav Don for his assistance in updating cursorbar for - % MATLAB Graphics and for his contribution of new functionality. - - % Copyright 2016 The MathWorks, Inc. - - %% Main methods - - methods - function hThis = GraphicsPlaceholder() - % GRAPHICSPLACEHOLDER A GraphicsPlaceholder constructor. - % - % See also: GraphicsPlaceholder. - - % Check MATLAB Graphics system version - if verLessThan('matlab','8.4.0') - error('graphics:GraphicsPlaceholder:GraphicsPlaceholder:oldVersion', ... - 'GraphicsPlaceholder requires the new MATLAB graphics system that was introduced in R2014b.'); - end - end - end - -end - diff --git a/Required packages/Cursorbar/crossbar.m b/Required packages/Cursorbar/crossbar.m deleted file mode 100644 index 7e13f29..0000000 --- a/Required packages/Cursorbar/crossbar.m +++ /dev/null @@ -1,96 +0,0 @@ -function [hCursorbar, hCrossbar] = crossbar(hTarget,varargin) -% CROSSBAR Creates two perpendicular linked cursorbars. -% -% The cursorbar can be dragged interactively across the axes. If -% attached to a plot, the cursor points are updated as well. The -% cursorbar can be either horizontal or vertical. -% -% The two crossed cursorbars are linked in position. Dragging one will -% update the position of the other to the cursor's location as well. -% -% Cursorbar requires the new MATLAB graphics system that was -% introduced in R2014b -% -% Usage: -% crossbar(hTarget) - Creates two perpendicular linked -% cursorbars on a target Axes or Chart. -% crossbar(hTarget, ...) - Creates two perpendicular linked -% cursorbars on a target Axes or Chart -% with additional property-value pairs. -% hCursorbars = crossbar(...) - Returns the handles to the two -% cursorbars. -% [hCo,hCross]= crossbar(...) - Returns the handles to the main -% cursorbar and to the crossed one. -% -% See graphics.Cursorbar for the full list of Cursorbar's properties. -% -% Example 1: Simple Crossbars -% x = linspace(-10,10,101); -% y = erf(x/5); -% % -% h = plot(x,y); -% crossbar(h); -% -% Example 2: Update Properties -% x = linspace(-10,10,49); -% M = peaks(length(x)); -% % -% h = imagesc(x,x,M); -% [cb,cr] = crossbar(h,'ShowText','off','TargetMarkerStyle','none'); -% % -% set(cr,'ShowText','on','TargetIntersections','single', ... -% 'TextDescription','long'); -% set([cb; cr], {'CursorLineColor'},{[1.0 0.8 0.8];[1.0 1.0 0.8];}); -% % -% cb.Position = [-7 3 0]; -% -% Example 3: Link Cursorbars -% t = linspace(0,12*pi,10001)'; -% x = 2*cos(t) + 2*cos(t/6); -% y = 2*sin(t) - 2*sin(t/6); -% % -% h = plot(x,y,'LineWidth',2); -% axis([-4 4 -4 4]); -% cb1 = crossbar(h,'CursorLineColor',[1 0 0],'Position',[-1 -1 0], ... -% 'TargetIntersections','single','CursorLineStyle','--'); -% cb2 = crossbar(h,'CursorLineColor',[1 0 1],'Position',[ 1 1 0], ... -% 'TargetIntersections','single','CursorLineStyle','--'); -% % -% l(1)=addlistener( cb1(1),'Location','PostSet', ... -% @(~,~) set ( cb2(1),'Location',cb1(1).Location+2)); -% l(2)=addlistener( cb1(2),'Location','PostSet', ... -% @(~,~) set ( cb2(2),'Location',cb1(2).Location+2)); -% l(3)=addlistener( cb2(1),'Location','PostSet', ... -% @(~,~) set ( cb1(1),'Location',cb2(1).Location-2)); -% l(4)=addlistener( cb2(2),'Location','PostSet', ... -% @(~,~) set ( cb1(2),'Location',cb2(2).Location-2)); -% -% See also: cursorbar, hobjects, graphics.Cursorbar. - -% Copyright 2016 The MathWorks, Inc. - -% Check MATLAB Graphics system version -if verLessThan('matlab','8.4.0') - error('crossbar:oldVersion', ... - 'Crossbar requires the new MATLAB graphics system that was introduced in R2014b.'); -end - -% error check -narginchk (1,Inf); -nargoutchk(0,2); - -% draw cursorbar -hTemp(1) = graphics.Cursorbar(hTarget,varargin{:}); -hTemp(2) = drawCrossbar(hTemp(1), varargin{:}); - -% output -switch nargout - case 0 - % never mind ... - case 1 - hCursorbar = hTemp; - case 2 - hCursorbar = hTemp(1); - hCrossbar = hTemp(2); -end - diff --git a/Required packages/Cursorbar/cursorbar.m b/Required packages/Cursorbar/cursorbar.m deleted file mode 100644 index e2bee3c..0000000 --- a/Required packages/Cursorbar/cursorbar.m +++ /dev/null @@ -1,174 +0,0 @@ -function hCursorbar = cursorbar(hTarget,varargin) -% CURSORBAR Creates a cursor line attached to an axes or lines. -% -% The cursorbar can be dragged interactively across the axes. If -% attached to a plot, the cursor points are updated as well. The -% cursorbar can be either horizontal or vertical. -% -% Cursorbar requires the new MATLAB graphics system that was -% introduced in R2014b -% -% Usage: -% cursorbar(hTarget) - Creates a cursorbar on a target Axes -% or Chart. -% cursorbar(hTarget, ...) - Creates a cursorbar on a target Axes -% or Chart with additional property- -% value pairs. -% hCursorbar = cursorbar(...) - Returns the handle to the Cursorbar. -% -% See graphics.Cursorbar for the full list of Cursorbar's properties. -% -% Example 1: Simple Cursorbar -% x = linspace(0,20,101); -% y = sin(x); -% % -% h = plot(x,y); -% cursorbar(h); -% -% Example 2: Target Axes -% x = linspace(-2,2,101)'; -% Y = [sin(x), 1-x.^2/2, erf(x), ones(size(x))]; -% % -% area(x,abs(Y)); -% cursorbar(gca,'CursorLineColor',[0.02 0.75 0.27]); -% set(gca,'Color','r') -% -% Example 3: Stem Plot -% x = 1:19; -% Y = interp1(1:5,magic(5),linspace(1,5,19),'pchip'); -% % -% h = stem(x,Y); -% cb = cursorbar(h); -% cb.TargetMarkerStyle = 'x'; -% -% Example 4: Logarithmic YScale -% x = linspace(0,4,41)'; -% Y = [exp(2*x)/4, exp(x/10)+1/160*exp(3*x), x.^2+1]; -% % -% h = stairs(x,Y,'LineWidth',2); -% % -% ax = gca; -% ax.YScale = 'log'; -% ax.YLim(2) = 1000; -% grid on; -% % -% cursorbar(h,'Location',2.7) -% -% Example 5: Crossbar -% x = linspace(-10,10,49); -% M = peaks(length(x)); -% % -% h = imagesc(x,x,M); -% cb = cursorbar(h,'ShowText','off','TargetMarkerStyle','none'); -% % -% cr = drawCrossbar(cb); -% set(cr,'ShowText','on','TargetIntersections','single', ... -% 'TextDescription','long'); -% set([cb; cr], {'CursorLineColor'},{[1.0 0.8 0.8];[1.0 1.0 0.8];}); -% % -% cb.Position = [-7 3 0]; -% -% Example 6: Preallocation -% x = linspace(-3,3,101); -% y = exp(-x.^2/2); -% % -% h = plot(x,y); -% for i=5:-1:1, -% cb(i) = cursorbar( h, 'Location',i-3, ... -% 'CursorLineColor',[(1-i/5) 0 i/5]); -% end -% -% Example 7: Listeners -% t = linspace(0,32*pi,10001)'; -% x = 2*cos(t) + 2*cos(t/16); -% y = 2*sin(t) - 2*sin(t/16); -% % -% ax= axes('XLim',[-4 4],'YLim',[-4 4],'NextPlot','add'); -% h = plot(x,y,'Color',[0.929 0.694 0.125]); -% % -% for i=5:-1:1, -% cb(i) = cursorbar( h, 'Location',i-3, 'ShowText','off', ... -% 'CursorLineColor',[(1-i/5) i/5 0]); -% end -% % -% % add listeners -% for i=1:5, -% j = mod(i,5)+1; -% addlistener ( cb(i),'Location','PostSet', ... -% @(~,~)set(cb(j),'Location',cb(i).Location+j-i)); -% end -% % -% addlistener(cb,'BeginDrag',@(~,~)set(ax,'Color',[.9 .8 .9])); -% addlistener(cb,'EndDrag' ,@(~,~)set(ax,'Color','w')); -% addlistener(cb,'UpdateCursorBar', ... -% @(~,~)set(h,'LineWidth',abs(cb(3).Location)+1)); -% -% Example 8: Save and Load -% % draw Cursorbars -% x = linspace(-4,4,101); -% y = cos(x); -% h = plot(x,y); -% % -% cb(1) = cursorbar(h,'Location',2.50,'CursorLineColor',[1 0 0]); -% cb(2) = cursorbar(h,'Location',-.25,'CursorLineColor',[0 1 0],... -% 'Orientation','horizontal'); -% cb(3) = drawCrossbar(cb(2)); -% % -% % save and load -% tempname = 'temp_cb.fig'; -% savefig(gcf,tempname); -% % -% open(tempname); -% -% Example 9: Marker Styles -% % create line plot -% x = linspace(0,14,201); -% y = sin(2*pi*x/3); -% % -% h = plot(x,y,':k','LineWidth',2); -% ylim([-1.2 1.2]); -% % -% % define colors -% topMarkers = 'x+*o.sdv^>0 - % create a full array - hCBar(nel) = graphics.GraphicsPlaceholder; - hCBar = reshape(hCBar,siz); -else - % create an empty array - hCBar = graphics.GraphicsPlaceholder.empty(siz); -end - -end