pushprop

버전 1.0.0.0 (1.73 KB) 작성자: Jerker Wagberg
Get, set and restore Handle Graphics objects
다운로드 수: 1.2K
업데이트 날짜: 2007/11/26

라이선스 없음

PUSHPROP is used to temporarily save and optionally set one or more properties of one or more Handle Graphics objects.

PUSHPROP is used in passages normally coded like this:

SavedProp = get(h, 'Property');
set(h, 'Property', newval);
% ... interact some more with object h
set(h, 'Property', SavedProp);

With PUSHPROP, the above segment can be written as

SavedProp = pushprop(h, 'Property', newval);
% ... interact some more with object h
SavedProp.pop();

Although it does save you one line of code, the real advantage is that the saved and restored property name(s) only need to be entered once, making the code easier to maintain and also makes the coder's intentions more transparent.

PUSHPROP closely mimics the syntax of SET, except for the output. Also, it behaves consistently for a structure array, in that it treats the elements in the array as individual setting for each handle. SET uses the last element of the struct for all objects.

Example:
% Set the current figure's background color to red for two seconds.
SavedColor=pushprop(gcf, 'Color', [1 0 0]);
pause(2);
SavedColor.pop();

인용 양식

Jerker Wagberg (2024). pushprop (https://www.mathworks.com/matlabcentral/fileexchange/17669-pushprop), MATLAB Central File Exchange. 검색 날짜: .

MATLAB 릴리스 호환 정보
개발 환경: R2007b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Graphics Object Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.0.0.0

Version 1.1: Now correctly handles properties that depend on the order that they are set.