diff --git a/+PlotID/CreateID.m b/+PlotID/@identifier/CreateID.m similarity index 100% rename from +PlotID/CreateID.m rename to +PlotID/@identifier/CreateID.m diff --git a/+PlotID/friendlyID.m b/+PlotID/@identifier/friendlyID.m similarity index 100% rename from +PlotID/friendlyID.m rename to +PlotID/@identifier/friendlyID.m diff --git a/+PlotID/@identifier/identifier.m b/+PlotID/@identifier/identifier.m new file mode 100644 index 0000000000000000000000000000000000000000..c0e4af154442811200019685c61032f2d61a1c80 --- /dev/null +++ b/+PlotID/@identifier/identifier.m @@ -0,0 +1,39 @@ +classdef identifier + %IDENTIFIER Summary of this class goes here + % Detailed explanation goes here + + properties (SetAccess = protected) + ID + projectID + figure + %IDf + end + + methods + function obj = identifier(figure, TagPlotOptions) + %IDENTIFIER Construct an instance of this class + % Detailed explanation goes here + obj.ID = figure.Tag; + obj.figure = figure; + obj.projectID = TagPlotOptions.ProjectID; + end + + function disp(obj) + % displays the PlotID when object is called + fprintf([obj.ID, newline]); + end + +% function output = get.IDf(obj) +% [obj.IDf ,~, ~] = obj.friendlyID(obj.ID); +% output = obj.IDf; +% end + + + end + + methods (Static) + ID = CreateID(method) + [IDf, PrjID, Str] = friendlyID(ID) + end +end + diff --git a/+PlotID/TagPlot.m b/+PlotID/TagPlot.m index 439a20ec2b1a9a89648d85f760ca4e70a9cbae85..3ed58ccb63fc06bbc9a6a2deb13cab9627867d31 100644 --- a/+PlotID/TagPlot.m +++ b/+PlotID/TagPlot.m @@ -1,4 +1,4 @@ -function [figs, IDs] = TagPlot(figs, options) +function [figs, IDobjs] = TagPlot(figs, options) %TagPlot adds IDs to figures % The ID is placed visual on the figure window and as Tag (property of figure) % TagPlot can tag multiple figures at once. @@ -13,6 +13,7 @@ function [figs, IDs] = TagPlot(figs, options) % 'Position' (relative to your x- and y-axis limits) arguments figs (1,:) {mustBeFigure} + options.IDmethod (1,1){mustBeInteger} = 1 options.ProjectID (1,:) {mustBeText}= '' options.Fontsize (1,1) {mustBeInteger} = 8 options.Color (1,3) {mustBeNonnegative} = 0.65*[1 1 1] % grey @@ -27,7 +28,7 @@ if isempty(options.ProjectID) txt = fileread('config.json'); config = jsondecode(txt); catch - config =struct; + config = struct; config.ProjectID = ''; warning("No ProjectID was definded and no config.json could be found"); @@ -42,7 +43,7 @@ end switch options.Location case 'north' - y = 1 - options.DistanceToAxis + y = 1 - options.DistanceToAxis; options.Position = [0.4,y]; Rotation = 0; case 'east' @@ -76,28 +77,29 @@ if ~isnan(options.Rotation) Rotation = options.Rotation; end -IDs = cell(numel(figs),1); +IDs = cell(1,numel(figs)); -for n = 1:numel(figs) - IDs{n} = PlotID.CreateID; % Create ID +for n = 1:numel(figs) + IDs{n} = PlotID.identifier.CreateID(options.IDmethod); % Create ID IDs{n} = [options.ProjectID,'-',IDs{n}]; % add options.ProjectID axes = get(figs(n),'CurrentAxes'); % Axes object for text annotation % Limits for relative Positioning ylim =get(axes,'YLim'); xlim =get(axes,'XLim'); - %ID - + %Place ID position = [options.Position(1), options.Position(2)]; text(axes,position(1),position(2), IDs{n},'Fontsize',options.Fontsize,... 'Rotation',Rotation, 'VerticalAlignment','bottom','Color',... options.Color,'BackgroundColor','w', 'Units', 'normalized'); - set(figs(n),'Tag', IDs{n}); + set(figs(n),'Tag', IDs{n}); + % transfer it in an identifierobject + IDobjs(n) = PlotID.identifier(figs(n), options); end -if numel(figs) == 1 - % use char instead of a cell arry for a single ID - IDs = IDs{1}; -end +% if numel(figs) == 1 +% % use char instead of a cell arry for a single ID +% IDobjs = IDobjs{1}; +% end end diff --git a/_config.json b/_config.json new file mode 100644 index 0000000000000000000000000000000000000000..d313e2a03047e045e65052f41788bde562891333 --- /dev/null +++ b/_config.json @@ -0,0 +1,15 @@ +{ + "Author": "Jan Lemmer", + "ProjectID": "kkk", + "ServerPath": "\\\\FST-220\\Jans-50GB-SMB\\Lemmer", + "options": { + "Location": "local", + "Method": "individual", + "ParentFolder": "export", + "ConfigFileName": "config.json", + "CopyUserFCN": true, + "CSV": true, + "ShowMessages": true, + "ForcePublish": true + } +} \ No newline at end of file diff --git a/example.m b/example.m index 3f86ce5b8528dd67ac5fd78664ccd2a6265391e7..2f67ee71678c4515217111b7b8c98c5cfeb2d231 100644 --- a/example.m +++ b/example.m @@ -62,7 +62,7 @@ set(gca, 'TickDir', 'out', 'YLim', [0,4]); % PlotID Implementation starts here. % TagPlot adds a visible ID to the figure(s) and to the figures property % 'Tag' -[fig, ID] = PlotID.TagPlot(fig, 'ProjectID', ProjectID); +[fig, IDobj] = PlotID.TagPlot(fig, 'ProjectID', ProjectID); %% Publishing % Second part of plotID