Skip to content
Snippets Groups Projects
Commit 25dde848 authored by Lemmer, Jan's avatar Lemmer, Jan
Browse files

Add identifier class, add IdentfierObjects

parent d304128d
No related tags found
No related merge requests found
Pipeline #587106 passed
File moved
File moved
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
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
......
{
"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
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment