Skip to content

Commit

Permalink
added jvm and colormap visualziation help functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Treder committed Sep 7, 2012
1 parent 13fd828 commit c932979
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
11 changes: 11 additions & 0 deletions visualization/private/jvm_hideFig.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function jvm= jvm_hideFig

a= sscanf(getfield(ver('MATLAB'), 'Release'), '(R%d)');
v= version('-java');
if isempty(strfind(v, 'not enabled')) % && a>=2009,
jvm.fig= gcf;
jvm.visible= get(jvm.fig, 'Visible');
set(jvm.fig, 'Visible','off');
else
jvm= [];
end
9 changes: 9 additions & 0 deletions visualization/private/jvm_restoreFig.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function jvm_restoreFig(jvm, varargin)

% opt= propertylist2struct(varargin{:});
opt = opt_proplistToStruct(varargin{:});
opt= opt_setDefaults(opt, {'fig_hidden', 0});

if ~isempty(jvm) && ~opt.fig_hidden,
set(jvm.fig, 'Visible',jvm.visible);
end
47 changes: 47 additions & 0 deletions visualization/utils/visutil_isColormapUsed.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
function yesorno= visutil_isColormapUsed(hf)
%ISCOLORMAPUSED - Determines whether the figure's colormap is in use
%
%Description:
% This function determines whether there is some child of the specified
% figure that uses the figure's colormap. Since all subplots of one
% figure all share a common colormap (figure property), this information
% is important when one wants to add a new image with a local colormap
% without destroying other subplots on the figure. In this case the
% function image_local_cmap can be used.
%
%Usage:
%YESORNO= iscolormapused(<HF>);
%
%Input:
% HF: Handle of the figure. If none is specified the current figure
% is inspected, i.e., default gcf.
%
%Example:
% clf; subplot(1,3,1); plot(randn(100,2));
% iscolormapused
% subplot(1,3,2);
% patch([0 1 1 0],[0 0 1 1], [1 0.1 0.7]); %% specify color directly
% iscolormapused
% subplot(1,3,3);
% patch([0 1 1 0],[0 0 1 1], 2); %% specify color by indexing into colormap
% iscolormapused
%
%See also image_local_cmap.

if nargin==0,
hf= gcf;
end

if isfield(get(hf),'CData') && ~isempty(get(hf,'CData')),
yesorno= 1;
return;
end

hc= get(hf, 'children');
yesorno= 0;

ii= 0;
while ~yesorno && ii<length(hc),
ii= ii+1;
yesorno= visutil_isColormapUsed(hc(ii));
end

0 comments on commit c932979

Please sign in to comment.