cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
lwx228
Level VIII

How do add text to a cell that has an image loaded?

Is it possible to add text to a cell that has already loaded images?

2022-06-20_17-48-10.png

 

Thanks!

2 ACCEPTED SOLUTIONS

Accepted Solutions
Craige_Hales
Super User

Re: How do add text to a cell that has an image loaded?

Add Text to a Picture 

Use a graphics frame box to add text and lines on top of a picture.Use a graphics frame box to add text and lines on top of a picture.

Craige

View solution in original post

Craige_Hales
Super User

Re: How do add text to a cell that has an image loaded?

dt = Open( "$SAMPLE_DATA/Big Class Families.jmp" );
For( iRow = 1, iRow <= N Rows( dt ), irow += 1, 
// open the original
	original = dt:picture[iRow];
	{xSize, ySize} = original << size;
// use a frame to do the drawing, make the original fit the frame exactly
	gb = Graph Box(
		<<backgroundcolor( "orange" ), // to see errors better
		FrameSize( xSize + 1, ySize + 1 ), // the +1 is required, 4 times
		X Scale( 0, xSize + 1 ),
		Y Scale( 0, ySize + 1 ), 
	// apparently x and y are different. this is correct in 17EA.
		<<Add Image( image( original ), bounds( top( 0 ), Left( 1 ), bottom( ySize ), Right( xSize + 1 ) ) ), 
	// draw something on top of the image
		Text( Center Justified, {xSize / 2, 10}, dt:name[irow] );
	);
// capture an updated image
	updated = gb[framebox( 1 )] << getpicture;
// crop added border. "updated" is the final image.
	updated << crop( Left( 1 ), top( 1 ), Right( xSize + 1 ), bottom( ySize + 1 ) );
	dt:picture[irow]=updated;
);

Mug shotsMug shots

Craige

View solution in original post

12 REPLIES 12
jthi
Super User

Re: How do add text to a cell that has an image loaded?

You could use set each value to re-create the image with text

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class Families.jmp");


Column(dt, "picture") << Set Each Value(
	H List Box(align("center"),
		Text box(:name),
		:picture
	) << Get Picture
);
-Jarmo
lwx228
Level VIII

Re: How do add text to a cell that has an image loaded?

If I want to add more than one cell of text, I try to add it left and right.

Can I add text below?It looks like this down here.

 

Column(dt, "picture") << Set Each Value(
	H List Box(align("center"),
		Text box(:name),
		:picture
	) << Get Picture
);
Column(dt, "picture") << Set Each Value(
	H List Box(align("center"),
		Text box(:sports),
		:picture
	) << Get Picture
);

2022-06-20_22-33-43.png

Thanks Experts!

jthi
Super User

Re: How do add text to a cell that has an image loaded?

Using proper display functions (h list box, v list box, lineup box...) and display boxes should help you to organize the elements

-Jarmo
lwx228
Level VIII

Re: How do add text to a cell that has an image loaded?

JSL can add text to a screenshot and then place it on the image.

Thanks!

 

dt = Open( "$SAMPLE_DATA/Big Class Families.jmp" );
rp = New Window( "", dt << Get As Report );
rp << Set Cell Height( 250 );
pic = rp << Get Picture;

2022-06-23_21-48-20.png

Craige_Hales
Super User

Re: How do add text to a cell that has an image loaded?

Add Text to a Picture 

Use a graphics frame box to add text and lines on top of a picture.Use a graphics frame box to add text and lines on top of a picture.

Craige
lwx228
Level VIII

Re: How do add text to a cell that has an image loaded?

Thank Craige!

 

I copied the following JSL, just to achieve the simplest function.
But I still don't know the code.Text is not added where it should be.
Consult experts to help modify, with the simplest code implementation.

Thanks Experts!

dt = Open( "$SAMPLE_DATA/Big Class Families.jmp" );
dt << delete columns( 3 :: N Col( dt ) );
dt << delete rows( 6 :: N Row( dt ) );
dt << Set Cell Height( 100 );
rp = New Window( "", dt << Get As Report );
original = rp << Get Picture;
{xSize, ySize} = original << size;

gb = Graph Box(
	<<backgroundcolor( "orange" ),
	FrameSize( xSize + 1, ySize + 1 ),
	X Scale( 0, xSize + 1 ),
	Y Scale( 0, ySize + 1 ),
	<<Add Image( image( original ), bounds( top( 0 ), Left( 1 ), bottom( ySize ), Right( xSize + 1 ) ) ),
	Text( Center Justified, { 50, 10}, "KATIE" )
);
updated = gb[framebox( 1 )] << getpicture;
updated << crop( Left( 1 ), top( 1 ), Right( xSize + 1 ), bottom( ySize + 1 ) );
originalMatrix = original << getpixels;
newMatrix = updated << getpixels;
diff = (originalMatrix - newMatrix != 0);
New Window( "bitmaps", V List Box( gb ) );

2022-06-24_21-03-11.png

 

lwx228
Level VIII

Re: How do add text to a cell that has an image loaded?

Text( Center Justified, { 50, 10}, "KATIE" )
  • How can this code be modified to fit inside the original image?

Craige_Hales
Super User

Re: How do add text to a cell that has an image loaded?

text size function; 5 points is a little too small for my eyes.text size function; 5 points is a little too small for my eyes.

Craige
Craige_Hales
Super User

Re: How do add text to a cell that has an image loaded?

Wait. You are using a picture of the whole data table, but I'm pretty sure you want to work on one picture at a time.

Just grab the image from dt:picture[iRow] rather than loading it from a file, then replace it when done. Approximately like this:

original = dt:picture[iRow];
...existing jsl...
dt:picture[iRow] = updated;
Craige