cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • DownloadSemiconductor Toolkit: Tools to create wafer maps, add wafer geometry to graphics, explore die defects & compare wafers.
  • Discovery Summit 2026: Early User Edition - September 23-24.Register. It's free.
  • JMP multivariate capabilities let you understand relationships between multiple variables simultaneously. See how. Friday, Aug. 14, 2 pm US ET.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
EOwl
Level II

How to stretch a picturebox to a window while maintaining an aspect ratio?

I'm writing a script that will generate a GUI for displaying images, using a rowstate handler to pass the images over to the window.

Is there a way to set a picture box object to:

  1. Stretch with window size (with a minimum and maximum size defined)
  2. Maintain it's original aspect ratio (e.g. square) (see script 2)
  3. Forbid direct user re-sizing.

Here's some JSL that uses the sample table of images.

Clear Globals();
Names Default To Here(1);

dt = Open( "$SAMPLE_DATA/Big Class Families.jmp" );

//Set the picture equal to selected row
rs_updateviewer = Expr(
	
	SelectedRows = (dt << Get Selected Rows());
	i = If(N Items(SelectedRows) == 0, 1, SelectedRows[1]);
	
	img = column(dt, "pet")[i];
	pb << Set Image(img);
);

//Viewer Window
Viewer = New Window(
	"Viewer",
	Show Menu( 0 ),
	<< On Close(Clear Globals(rs);
	),
	<< Size Window( 1000, 700),
	
	vb = V List Box("Center",
	H Center Box( Text Box( "Viewer" ) ),
	H List Box(
//	tb = dt << New Data Box(),
	tb = Data Grid Box(),
	pb = Picture Box()
	)
	)
	,
	pb << Set Stretch( "Fill", "Fill" );
	pb << Border( 1 );
	
	tb << Set Stretch( "Off", "Off" );
	tb << Set Data Table( dt );
	tb << Close Side Panels( 1 );
	
);

//Initiate image
rs_updateviewer;

// Define the handler function
f = Function( {a},
	rs_updateviewer
);

// Register the row state handler to the table
set_rowstate = Expr(
	rs = dt << Make Row State Handler( f );
);

set_rowstate;

Here's an script index example of a graph with it's aspect ratio fixed, the behaviour I'd like on the picture

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = Graph Builder( Show Control Panel( 0 ), Variables( X( :height ), Y( :weight ) ), Elements( Points( X, Y ), Smoother( X, Y ) ) );
gb << Fit to Window( "Maintain Aspect Ratio" );
0 REPLIES 0

Recommended Articles