Code covered by the BSD License  

Highlights from
Limit figure size

Be the first to rate this file! 19 Downloads (last 30 days) File Size: 3.84 KB File ID: #38527

Limit figure size

by

 

Set minimal or maximal size of a figure

| Watch this File

File Information
Description

LimitSizeFig - Set minimum and maximum figure size

Some dialogs become ugly, if their size is getting too small. Setting a minimal size in the figure's ResizeFcn leads to strange effects, when the left side of the figure is dragged. This function calls Java to limit the figure size.

LimitSizeFig(FigH, Prop, Ext)
INPUT:
  FigH: Handle of a Matlab figure.
  Prop: String, command:
        'min', 'max': Set minimum or maximum extent.
        'get': Reply the limits.
        'clear': Clear both limits.
  Ext: Extent as [1 x 2] vector, minimal width and height in pixels.

EXAMPLES:
  FigH = figure;
  LimitSizeFig(FigH, 'min', [200, 200])
  LimitSizeFig('max', [400, 400]) % Uses GCF
  Limit = LimitSizeFig(FigH, 'get')

Tested: Matlab 7.7, 7.8, 7.13, WinXP/32, Win7/64
Assumed compatibility: Matlab >= 7.0, Linux, MacOS
Run the unit-test uTest_LimitSizeFig to check the validity on your Matlab version.

MATLAB release MATLAB 7.13 (R2011b)
Other requirements Does not work under Matlab 6.5
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
16 Feb 2014 Jan Simon

Stephane: Thanks for your comment. I do not have R2013a to test or fix this.
Please feel free to send me suggestions for simplifications to the email address taken from the code.

31 Jan 2014 Stephane

Thanks this is nice job ... unfortunatly setting max size does not work (R2013a). As a test you can try:

h = figure();
LimitSizeFig(h, 'min', [100 100]);
LimitSizeFig(h, 'max', [200 200]);

You will see that min size is ok, but that figure can still grow by any amount ;(

NB1: It's seems to be a bug in swing for 'setMaximumSize'.

NB2: I have refactored your code here to be simpler to use:

Contact us