我尝试将简化版的Altman MATLAB 2013极地雷达系统code集成到MATLAB 2016b Polarxes实现中的代码,因为我希望工具栏具有黑色背景,而水平滚动条具有缩放功能。
前一个代码基本上使用具有javax.swing.JSlidercontinuous-movement callback
当前的错误来自行'StateChangedCallback',{@cbSlider,fp,imax});,其中轴imax的行为不符合预期

close all; clear all; clc;
% http://stackoverflow.com/q/40030096/54964
fp=figure('Name', 'Test', ...
    'Position',[200 200 851 404],'Resize','off'); % only half circle in polaraxes although warp can do eclipses
ThetaTicks = 0*pi:pi/10:1*pi;
pax = polaraxes( 'ThetaAxisUnits', 'radians', ...
    'ThetaLim',[min(ThetaTicks) max(ThetaTicks)],...
    'Color','none',...
    'GridAlpha',1,...
    'GridColor',[1 1 1],...
    'ThetaTick', ThetaTicks, ...
    'ThetaDir', 'counterclockwise', ...
    'Parent', fp);

af = figure('Name', 'Do Not Touch');

testImage = 'peppers.png';
imax = axes('Parent', fp, 'Visible', 'off');
I = imread(testImage);
angleRadians=-pi;
[x, y, z]=makePolar(I, angleRadians);
fp=figure(fp);
imax.Children = warp(x, y, z, I);
set(imax,'view',[-180 -90],'Visible','off');
axis(imax,'tight')
pause(1);

%% Change toolbar bakcgrounds black like radar systems
% http://undocumentedmatlab.com/blog/customizing-figure-toolbar-background
[jSlider,hSlider] = javacomponent('javax.swing.JSlider',[0,0,.01,0.1],fp);
set(hSlider, 'Units','norm','pos',[.15,0,.7,.05]);
set(jSlider, 'Background',java.awt.Color.black, ...
    'Value',0, 'Maximum',duration, ...
    'StateChangedCallback',{@cbSlider,fp,imax});

hToolbar = findall(fp,'tag','FigureToolBar');

% required to programmatically alter the figure
delete(findall(hToolbar,'tag','Plottools.PlottoolsOn'))
delete(findall(hToolbar,'tag','Plottools.PlottoolsOff'))
delete(findall(hToolbar,'tag','Annotation.InsertColorbar'))
delete(findall(hToolbar,'tag','DataManager.Linking'))
delete(findall(hToolbar,'tag','Standard.EditPlot'))

% ensure the toolbar is visible onscreen
drawnow;

% Get the underlying JToolBar component
jToolbar = get(get(hToolbar,'JavaContainer'),'ComponentPeer');

% Set the bgcolor to black
color = java.awt.Color.black;
jToolbar.setBackground(color);
jToolbar.getParent.getParent.setBackground(color);


输出我不确定它是关于哪个数组的

Error using javahandle_withcallbacks.javax.swing.JSlider/set
Array must be numeric or logical.

Error in test_polar_radar_system (line 33)
set(jSlider, 'Background',java.awt.Color.black, ...


图1:水平滚动条起作用但没有成功绑定动作的当前输出,
图2预期输出= Altman输出的半个圆,但测试图像和轴起点如图1所示,但其他一切都可以像Altman输出

java - 如何将Java Swing黑色背景工具栏集成到Polaraxes中?-LMLPHP
java - 如何将Java Swing黑色背景工具栏集成到Polaraxes中?-LMLPHP

尝试2失败

% https://se.mathworks.com/matlabcentral/newsreader/view_thread/164766
color = java.awt.Color.blue;
color = java.awt.Color(0,0,0.9); % alternative declaration
hToolbar=findall(gcf,'tag','FigureToolBar');
jToolbar=get(get(hToolbar,'JavaContainer'),'ComponentPeer');
jToolbar.setBackground(color)


输出量

Struct contents reference from a non-struct array object.

Error in make_sample (line 822)
                jToolbar.setBackground(color)


MATLAB:2016年
操作系统:Debian 8.5 64 bit
硬件:华硕Zenbook UX303UA
Linux内核:4.6向后移植

最佳答案

您的错误可能不是设置StateChangedCallback而是设置Maximum,即不是提供简单的数字,您的duration变量中可能还有其他内容。因此,整个set()命令失败,并且未分配StateChangedCallback

关于java - 如何将Java Swing黑色背景工具栏集成到Polaraxes中?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40086038/

10-10 15:20