If you do not want to use the WebFigure JSP tag to display the figure, or want a servlet to display it directly, use this method to get a snippet of HTML that will embed an iFrame containing the figure in another page.
Create an instance of the WebFigureHtmlGenerator class
using either a scriptlet or a servlet. The constructor for this class
has three overloads:
//The import statement needed to invoke this class
import com.mathworks.toolbox.javabuilder.webfigures.WebFigureHtmlGenerator;
//WebFigureHtmlGenerator(HttpServletRequest servletRequest)
//This overload just takes the ServletRequest and will map the
// embed string to the same server and assumes that the
// WebFiguresService was mapped to "WebFigures"
WebFigureHtmlGenerator htmlGenerator =
WebFigureHtmlGenerator(servletRequest);
//OR
//WebFigureHtmlGenerator(String webFigureServletNameMapping, HttpServletRequest
// servletRequest)
//This overload takes the ServletRequest and the name that
// the WebFigureServlet was mapped to.
//It will reference this servlet on the same server
WebFigureHtmlGenerator htmlGenerator =
WebFigureHtmlGenerator("SomeServletMappingName", servletRequest);
//OR
//WebFigureHtmlGenerator(String absolutePathName)
//This overload takes the absolute URL path to a server that has
// WebFiguresService running.
//This would be used if you have a cluster of servers that are all running
// WebFigureService
// a load balancer (all sharing cache state). Use
// this parameter to reference that base load balancer URL.
WebFigureHtmlGenerator htmlGenerator =
WebFigureHtmlGenerator("http://someLoadBalancer/someWebApplication/
WebFigureServletNameMapping");
Call the method to get the embedded string (getFigureEmbedString).
Use this table to specify appropriate attributes:
| Attribute Name | Attribute Type | Description | Optional | Default Value |
|---|---|---|---|---|
figure | WebFigure | WebFigure for which you want to create the embedded string. | Yes | This is used to determine the figure's default height and width if no other is provided . |
name | String | Name used when attaching your figure to a cache. Case sensitive. | No | Not optional |
scope | String | Scope that figure has been saved to (application or session). | No | Not optional |
style | String | Embedded attribute you want attached to the iFrame. | Yes | If this is not passed, a basic iFrame is used. |
height | String | Height of the iFrame that will be embedded. | Yes | If this is not passed, the height of the WebFigure is retrieved
from cache. If the WebFigure cannot be found, the MATLAB® default
height for a figure (420) is used. |
width | String | Width of the iFrame that will be embedded. | Yes | If this is not passed, the width of the WebFigure is retrieved
from cache. If the WebFigure cannot be found, the MATLAB default
width for a figure (560) is used. |