首页 \ 问答 \ 为什么JFreeChart中没有文字?(Why is there no text in JFreeChart?)

为什么JFreeChart中没有文字?(Why is there no text in JFreeChart?)

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)

ThanksJFreeChart

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
更新时间:2022-06-19 13:06

最满意答案

我有与zope.interface和朋友(zope.component,等)相同的问题。 特别是py2exe如何搜索和发现软件包以及zope软件包的安装方式是一个问题。

zope是一个名称空间包,因此依赖于它的.pth文件中的一些时髦的导入逻辑(参见zope.interface-3.*.*-py2.*-nspkg.pth ),以便将它的子包添加到python路径。 看看它在site-packages ,你会明白我的意思。

py2exe有问题“发现”这种包。

最后,我所做的是手动将我使用的各种zope软件包重新打包到site-packages的stardard模块设置中,然后reran py2exe - 然后发现一切都没有问题。 这是一个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 how py2exe searches and discovers packages AND how the zope packages are installed.

zope is a namespace package and as a result relies on some funky import logic in it's .pth files (see zope.interface-3.*.*-py2.*-nspkg.pth) in order to add it's sub-packages to python's path. Have a look at it in site-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 in site-packages and then reran py2exe - which then discovered everything no problem. It's a PITA, but until py2exe is able to handle packaging edge cases and/or the zope packages are packaged in a py2exe friendly fashion, it's about the best you can do.

相关问答

更多
  • 几个星期后(甚至之前有这个问题)我很高兴地说我解决了这个问题! :) 问题的第一部分 ( 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__方法(作为一个实例方法)。 所以接口描述你得到的是什么样的实例,而不是你如何得到它们。 现在,接口可以用来描述实例提供的功 ...
  • 由于我确实清楚地重新安装了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_ ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)