Global Position of Docked Figures window

I am having difficulty accessing the global position of the docked "Figures" window. I have the units of the figures inside of the window set to pixels and when accessing the 'Position' property of one of those windows I get [1 1 L W], which means that it is somehow parented I guess (it is not at the bottom left of my monitors). However, there is no handle that I can find to the docked "Figures" window to access the global position. I am not sure if it makes a difference, but I have UI elements in each of the figures. Here's a really simple sample:
fig=figure
set(fig,'WindowStyle','docked')
get(fig,'Position')
The output no matter where the figures window is globally located is:
ans =
1 1 some_length some_width
Any help on this would be appreciated.

 채택된 답변

Orion
Orion 2014년 11월 13일

0 개 추천

Hi,
When you dock some figures, they go in the Figure Editor, which is not a classic matlab figure. This is a java component.
You can access it but it becomes messy (and dangerous) really fast.
you need to use code looking like :
% create a dock figure
fig = figure;
set(fig,'WindowStyle','docked')
get(fig,'Position')
% get the Figure editor
desktop = com.mathworks.mde.desk.MLDesktop.getInstance;
container = desktop.getGroupContainer('Figures').getTopLevelAncestor;
% get the dimensions
width = get(container.getSize,'width');
height = get(container.getSize,'height');
% get the origin
Location = get(container.getAccessibleContext,'Location');
Xorigin = get(Location,'X');
Yorigin = get(Location,'Y');
% display
disp([Xorigin Yorigin width height])
if you really need to manipulate this kind of element, take a look at undocumentedmatlab.com of Yair Altman.

댓글 수: 1

Thomas
Thomas 2014년 11월 17일
Thank you. This works up until the Xorigin line, however, in the Location variable it has the 4 element array I'm looking for. Much appreciated.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Environment and Settings에 대해 자세히 알아보기

질문:

2014년 11월 12일

댓글:

2014년 11월 17일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by