主要内容

超链接图片

这个示例演示了如何将图像中的区域定义为超链接。您可以定义超链接,以便它们链接到目标网页或导航到同一报告中的另一个位置。

导入DOM和Report API包,这样就不必使用长且完全限定的类名。

进口mlreportgen.dom。*进口mlreportgen.report。*

创建并打开一个报告。

要创建一个HTML报告,将“pdf”改为“HTML”或“HTML -file”%多文件或单文件报告,分别。rpt =报告(“myreport”“pdf”);打开(rpt);

给报告添加一段。

内容="点击子图导航到相应的"+...“三角函数文档。”;添加(rpt,段落(内容));

为不同的三角函数创建一个带有多个子图的图形。

figH =图;x = linspace (0, 10);sinePlot =次要情节(3、2、1,“单位”“像素”);情节(x, sin (x));标题(“sin: sin (x)”);cosinePlot =次要情节(3 2 2“单位”“像素”);情节(x), cos (x));标题(“余弦:cos (x)”);secantPlot =次要情节(2、3、“单位”“像素”);情节(x, sec (x));标题(“sec: sec (x)”);cosecantPlot =次要情节(3 2 4“单位”“像素”);情节(x, csc (x));标题(“csc: csc (x)”);tangentPlot =次要情节(3 2 5“单位”“像素”);情节(x,谭(x));标题(“切:棕褐色(x)”);cotangentPlot =次要情节(3 2 6“单位”“像素”);情节(x,床(x));标题(“余切:床(x)”);

使用数字记者得到的数字快照。使用DOM图像将快照包含在报告中。

figReporter =图(“源”figH,“SnapshotFormat”“jpg”);imgPath = getSnapshotImage (figReporter rpt);figImg =图像(imgPath);

在快照上创建一个图像映射,为每个子图创建一个图像区域。的getCoords函数(在本示例的最后定义)获取每个子图的坐标。子绘图图像区域的目标被设置为用于创建该子绘图的三角函数的文档网页。然后,将快照添加到报告中。

地图= ImageMap;sinePlotCoords = getCoords (sinePlot);sinePlotArea = ImageArea (“//www.tianjin-qmedu.com/help/matlab/ref/sin.html”...“正弦”, sinePlotCoords);追加(地图,sinePlotArea);cosinePlotCoords = getCoords (cosinePlot);cosinePlotArea = ImageArea (“//www.tianjin-qmedu.com/help/matlab/ref/cos.html”...“余弦”, cosinePlotCoords);追加(地图,cosinePlotArea);secantPlotCoords = getCoords (secantPlot);secantPlotArea = ImageArea (“//www.tianjin-qmedu.com/help/matlab/ref/sec.html”...“sec”, secantPlotCoords);追加(地图,secantPlotArea);cosecantPlotCoords = getCoords (cosecantPlot);cosecantPlotArea = ImageArea (“//www.tianjin-qmedu.com/help/matlab/ref/csc.html”...“csc”, cosecantPlotCoords);追加(地图,cosecantPlotArea);tangentPlotCoords = getCoords (tangentPlot);tangentPlotArea = ImageArea (“//www.tianjin-qmedu.com/help/matlab/ref/tan.html”...“切”, tangentPlotCoords);追加(地图,tangentPlotArea);cotangentPlotCoords = getCoords (cotangentPlot);cotangentPlotArea = ImageArea (“//www.tianjin-qmedu.com/help/matlab/ref/cot.html”...“余切”, cotangentPlotCoords);追加(地图,cotangentPlotArea);figImg。地图=地图;add (rpt, figImg);

删除图形窗口。关闭并查看报告。

关闭(rpt);删除(figH);rptview (rpt);

下面的函数计算并返回父图中指定子图的左上和右下坐标。这些坐标是通过将子图轴坐标转换为DOM来计算的,子图轴坐标基于图形坐标系,其参考点位于左下角ImageArea坐标系统,其参考点是图像的左上角。

函数subplot. position (3) = subplot. position (3);subplotHeight = subplot.Position (4);无花果= subplot.Parent;figHeight = fig.Position (4);x1 = subplot.Position (1);y1 = * * * (subplot.Position(2) + subplotHeight);x2 = x1 + subplotWidth;y2 = y1 + subplotHeight;坐标= [x1, y1, x2, y2];结束