annotate _FullBNT/KPMtools/previewfig.m @ 9:4ea6619cb3f5 tip

removed log files
author matthiasm
date Fri, 11 Apr 2014 15:55:11 +0100
parents b5b38998ef3b
children
rev   line source
matthiasm@8 1 function f = previewfig(h,varargin)
matthiasm@8 2 %PREVIEWFIG Preview a figure to be exported using EXPORTFIG.
matthiasm@8 3 % F = PREVIEWFIG(H) creates a preview of H with the default
matthiasm@8 4 % EXPORTFIG options and returns the preview's figure handle in F.
matthiasm@8 5 % F = PREVIEWFIG(H,OPTIONS) creates a preview with OPTIONS as
matthiasm@8 6 % described in EXPORTFIG.
matthiasm@8 7 % PREVIEWFIG(...,PARAM1,VAL1,PARAM2,VAL2,...) creates a preview
matthiasm@8 8 % with the specified parameter-value pairs to H as described in
matthiasm@8 9 % EXPORTFIG.
matthiasm@8 10 %
matthiasm@8 11 % See also EXPORTFIG, APPLYTOFIG, RESTOREFIG.
matthiasm@8 12
matthiasm@8 13 % Copyright 2000 Ben Hinkle
matthiasm@8 14 % Email bug reports and comments to bhinkle@mathworks.com
matthiasm@8 15
matthiasm@8 16 filename = [tempname, '.png'];
matthiasm@8 17 args = {'resolution',0,'format','png'};
matthiasm@8 18 if nargin > 1
matthiasm@8 19 exportfig(h, filename, varargin{:}, args{:});
matthiasm@8 20 else
matthiasm@8 21 exportfig(h, filename, args{:});
matthiasm@8 22 end
matthiasm@8 23
matthiasm@8 24 X = imread(filename,'png');
matthiasm@8 25 height = size(X,1);
matthiasm@8 26 width = size(X,2);
matthiasm@8 27 delete(filename);
matthiasm@8 28 f = figure( 'Name', 'Preview', ...
matthiasm@8 29 'Menubar', 'none', ...
matthiasm@8 30 'NumberTitle', 'off', ...
matthiasm@8 31 'Visible', 'off');
matthiasm@8 32 image(X);
matthiasm@8 33 axis image;
matthiasm@8 34 ax = findobj(f, 'type', 'axes');
matthiasm@8 35 axesPos = [0 0 width height];
matthiasm@8 36 set(ax, 'Units', 'pixels', ...
matthiasm@8 37 'Position', axesPos, ...
matthiasm@8 38 'Visible', 'off');
matthiasm@8 39 figPos = get(f,'Position');
matthiasm@8 40 rootSize = get(0,'ScreenSize');
matthiasm@8 41 figPos(3:4) = axesPos(3:4);
matthiasm@8 42 if figPos(1) + figPos(3) > rootSize(3)
matthiasm@8 43 figPos(1) = rootSize(3) - figPos(3) - 50;
matthiasm@8 44 end
matthiasm@8 45 if figPos(2) + figPos(4) > rootSize(4)
matthiasm@8 46 figPos(2) = rootSize(4) - figPos(4) - 50;
matthiasm@8 47 end
matthiasm@8 48 set(f, 'Position',figPos, ...
matthiasm@8 49 'Visible', 'on');