简体   繁体   English

Java中的matlab openfig调用

[英]matlab openfig call from java

I'm using WebFigures in Matlab, and I have a simple function in matlab 我在Matlab中使用WebFigures,在matlab中有一个简单的功能

function df = getFig

  f = openfig('C:\test1.fig');

  figure('Visible','Off')

  df = webfigure(f);
  close(f);
end

I'm calling this function from my java servlet. 我从我的Java Servlet调用此函数。 However this just sits for a while then I get this error: 但是,这只是坐了一会儿,然后我得到这个错误:

{_Error using figure

UIJ_AreThereWindowShowsPending - timeout waiting for window to show up

Error in openfig (line 135)

Error in getFig (line 3)
}_ 

I have tried call the same function, except with a generated on the fly figure, like using plot or knot, and both work fine. 我试过调用相同的函数,除了使用动态图形生成的图形(例如使用plot或knot)外,它们都可以正常工作。

Also as a related question, is it possible to pass in a reference to a file to this function from java? 另外,作为一个相关问题,是否可以将对文件的引用从Java传递给此函数? like through a inputstream object? 像通过inputstream对象? This is because the files I need to retrieve are actually retrieved from a URL. 这是因为实际上我需要检索的文件是从URL检索的。

Any ideas? 有任何想法吗?

I'm not sure exactly what the problem is, but one issue might be that the command figure('Visible','off') is not modifying your figure f , but rather creating a new, separate figure that is invisible. 我不确定问题到底出在哪里,但是一个问题可能是该命令figure('Visible','off')并未修改您的图形f ,而是创建了一个新的,不可见的独立图形。

I'm also not sure why you want the figure to be invisible (I think this may be the real issue of why it's not showing up within the Java servlet). 我也不确定为什么要使该图不可见(我认为这可能是为什么它未在Java servlet中显示的真正问题)。

If you need it to be invisible you could try 如果您需要隐藏它,可以尝试

openfig('filename.fig','new','invisible')

or, since openfig is really intended for GUIs rather than figures containing just graphics, use hgload instead, and then set the visibility directly. 或者,因为openfig实际上是供GUI使用的,而不是只包含图形的图形,请改用hgload ,然后直接设置可见性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM