为什么JFreeChart中没有文字?(Why is there no text in JFreeChart?)
JFreeChart似乎正在工作,除了所有文本。 它根本没有出现,我不知道为什么。 我附上了一张带有饼图的窗口图片,这是我从教程网站获得的。 如您所见,文本不可见。 (对不起,我的推文很长)
谢谢
编辑:
以下是生成上图的代码:
package analyzer_main; import java.awt.Font; public class FloatChart extends Composite implements Screen { JFreeChart floatChart; public FloatChart(Composite parent, int style){ super(parent,style); createContents(); } private void createContents(){ this.setLayout(new FormLayout()); floatChart = createChart(createDataset()); ChartComposite chartComposite = new ChartComposite(this,SWT.NONE,floatChart, true); FormData fd_chartComposite = new FormData(); fd_chartComposite.left = new FormAttachment(0); fd_chartComposite.right = new FormAttachment(100,0); fd_chartComposite.top = new FormAttachment(0); fd_chartComposite.bottom= new FormAttachment(100,0); chartComposite.setLayoutData(fd_chartComposite); } /** * Creates the Dataset for the Pie chart */ private PieDataset createDataset() { DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("One", new Double(43.2)); dataset.setValue("Two", new Double(10.0)); dataset.setValue("Three", new Double(27.5)); dataset.setValue("Four", new Double(17.5)); dataset.setValue("Five", new Double(11.0)); dataset.setValue("Six", new Double(19.4)); return dataset; } private JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart("Pie Chart Demo 1", // chart // title dataset, // data true, // include legend true, false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionOutlinesVisible(false); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("No data available"); plot.setCircular(false); plot.setLabelGap(0.02); return chart; } @Override public void Load() { } }
正如您所看到的,它与教程中的几乎完全相同。
JFreeChart seems to be working, except for all the text. It just doesn't show up at all, and I've no idea why. I attached a picture of a window with a pie graph that I got from a tutorial site. As you can see, the text isn't visible. (sorry my twitter feed was really long)
Thanks
Edit:
Here is the code that generates the above graph:
package analyzer_main; import java.awt.Font; public class FloatChart extends Composite implements Screen { JFreeChart floatChart; public FloatChart(Composite parent, int style){ super(parent,style); createContents(); } private void createContents(){ this.setLayout(new FormLayout()); floatChart = createChart(createDataset()); ChartComposite chartComposite = new ChartComposite(this,SWT.NONE,floatChart, true); FormData fd_chartComposite = new FormData(); fd_chartComposite.left = new FormAttachment(0); fd_chartComposite.right = new FormAttachment(100,0); fd_chartComposite.top = new FormAttachment(0); fd_chartComposite.bottom= new FormAttachment(100,0); chartComposite.setLayoutData(fd_chartComposite); } /** * Creates the Dataset for the Pie chart */ private PieDataset createDataset() { DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("One", new Double(43.2)); dataset.setValue("Two", new Double(10.0)); dataset.setValue("Three", new Double(27.5)); dataset.setValue("Four", new Double(17.5)); dataset.setValue("Five", new Double(11.0)); dataset.setValue("Six", new Double(19.4)); return dataset; } private JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart("Pie Chart Demo 1", // chart // title dataset, // data true, // include legend true, false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionOutlinesVisible(false); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("No data available"); plot.setCircular(false); plot.setLabelGap(0.02); return chart; } @Override public void Load() { } }
As you can see, it's pretty much the same as from the tutorial.
原文:https://stackoverflow.com/questions/8577680
最满意答案
我有与
zope.interface
和朋友(zope.component,等)相同的问题。 特别是py2exe
如何搜索和发现软件包以及zope
软件包的安装方式是一个问题。
zope
是一个名称空间包,因此依赖于它的.pth
文件中的一些时髦的导入逻辑(参见zope.interface-3.*.*-py2.*-nspkg.pth
),以便将它的子包添加到python路径。 看看它在site-packages
,你会明白我的意思。
py2exe
有问题“发现”这种包。最后,我所做的是手动将我使用的各种
zope
软件包重新打包到site-packages
的stardard模块设置中,然后reranpy2exe
- 然后发现一切都没有问题。 这是一个PITA,但是在py2exe
能够处理包装边缘情况和/或zope
包以py2exe
友好的方式打包之前,这是关于您可以做的最好的。I've had this same problem with
zope.interface
and friends (zope.component, et al). Specifically it is a problem with howpy2exe
searches and discovers packages AND how thezope
packages are installed.
zope
is a namespace package and as a result relies on some funky import logic in it's.pth
files (seezope.interface-3.*.*-py2.*-nspkg.pth
) in order to add it's sub-packages to python's path. Have a look at it insite-packages
and you'll see what I mean.
py2exe
has problems "discovering" this kind of package.In the end what I did was manually repackage the various
zope
packages I was using into a stardard module setup insite-packages
and then reranpy2exe
- which then discovered everything no problem. It's a PITA, but untilpy2exe
is able to handle packaging edge cases and/or thezope
packages are packaged in apy2exe
friendly fashion, it's about the best you can do.
相关问答
更多-
Py2exe混淆错误(Py2exe confusing errors)[2024-02-16]
几个星期后(甚至之前有这个问题)我很高兴地说我解决了这个问题! :) 问题的第一部分 ( http://i.stack.imgur.com/WpkjR.png ):我通过编辑setup.py脚本并在其中添加“排除”部分来解决它。 这导致成功制作可执行文件! 修改后的setup.py脚本: from distutils.core import setup import py2exe setup(windows=['source_static.py'], options={ "py2exe" ... -
从你的编辑看来,问题似乎与访问一些打包的插件(而不是yapsy模块本身)有关。 为此,您可能需要检查以下两点: 当你调用self.manager.setPluginPlaces(["plugins"])注意路径“plugin”可能与您认为的目录无关。 您应该使用更具体的路径,使用py2exe的“where Am I”常见问题解答提示: http ://www.py2exe.org/index.cgi/WhereAmI 您也可以尝试将插件打包为data_files(就像您链接到的网页一样),我不确定py2ex ...
-
显然, verifyClass不能正确理解classmethod或staticmethod 。 问题是在Python 3中,如果在Python 3中执行getattr(MyObject, 'load_index_list') ,则会得到一个裸函数,而verifyClass认为它是另一个未绑定的方法 ,然后期望隐式self是第一个参数。 最简单的解决方法是在那里使用classmethod而不是staticmethod 。 我想有人也可以做一个bug报告。 Obviously the verifyClass d ...
-
首先: 提供和实现接口的概念之间有很大的区别。 基本上,类实现一个接口,这些类的实例提供该接口。 毕竟,类是实例的蓝图,详细介绍了它们的实现。 现在,一个接口描述了实例提供的实现,但__init__方法不是实例的一部分! 它是直接由类提供的接口的一部分(Python术语中的类方法)。 如果你要在你的接口中定义一个__init__方法,那么你声明你的实例也有( 提供 )一个__init__方法(作为一个实例方法)。 所以接口描述你得到的是什么样的实例,而不是你如何得到它们。 现在,接口可以用来描述实例提供的功 ...
-
程序不能超越py2exe(Program doesn't work beyond py2exe)[2022-03-13]
由于我确实清楚地重新安装了python 2.7(当然还有必要的模块),所以一切都在我的Windows 10上运行,但是在winpe 10上仍然没有! 我必须在winpe图像中添加wmi包,之前的winpe版本默认包含它! 现在它也适用于winpe。 (我无法理解。如果我知道的话,wmi是winpe上最常用的工具之一!) 有了这两行命令: Dism /Add-Package /Image:"C:\WinPE_amd64\mount" /PackagePath:"C:\Program Files\Windows ... -
那么它不会失败吗? 您希望msvcr71.dll与exe在同一目录中,以便库加载器能够找到并将其链接到应用程序的内存映射中。 它是基本操作所必需的,所以你不能让py2exe用其余的DLL解压缩它。 Wouldn't it fail to launch, then? You want msvcr71.dll in the same directory as the exe, so that the library loader will be able to find and link it into the ...
-
我有与zope.interface和朋友(zope.component,等)相同的问题。 特别是py2exe如何搜索和发现软件包以及zope软件包的安装方式是一个问题。 zope是一个名称空间包,因此依赖于它的.pth文件中的一些时髦的导入逻辑(参见zope.interface-3.*.*-py2.*-nspkg.pth ),以便将它的子包添加到python路径。 看看它在site-packages ,你会明白我的意思。 py2exe有问题“发现”这种包。 最后,我所做的是手动将我使用的各种zope软件包重 ...
-
关于为什么会发生这种情况并不是真正的答案 - 但是使用cx_Freeze而不是py2exe解决了这个问题。 Not a real answer as to why this occured - but using cx_Freeze instead of py2exe solved this problem.
-
我解决了这个问题! 我在新的Microsoft Surface上安装了最新版本的Anaconda,但没有意识到它是python 3.5特有的。 这个问题的原因是因为distutils for python 3.5会尝试在py2exe中查找与3.5相关的项目,即使py2exe是3.4特定的。 我卸载了v.3.5并安装了v3.4(我不想处理安装了多个版本的python)。 一旦重新安装,我关闭了我的防病毒软件,并使用pip install py2exe 。 我得到了一个警告,它是旧版本的pip,但它仍然有用。 ...
-
通过将代码更改为以下代码,它可以正常工作。 page = urllib.urlopen('http://www.westforts.com/%s/battles/page/%s' % (server, pagenum)) page_content = page.read() with open('battle_id_getter%s.txt' % (pagenum) , 'w') as textfile: textfile.write(page_content) with open('battle_ ...