简体   繁体   English

如何正确显示Prefuse(Java)表?

[英]How to visualize a Prefuse (Java) Table correctly?

I want to visualize some data about cars in a table via Prefuse Java. 我想通过Prefuse Java可视化表中汽车的一些数据。 Three kinds of important data objects are used: 使用了三种重要的数据对象:

  1. PIT (Point in Time) PIT(时间点)
  2. Value (contains the consumption of gas as a Double) 价值(包含双重燃气消耗量)
  3. Car (the class that represents a Car) 汽车(代表汽车的类)

So first I put them into a table like this: 所以首先我把它们放到这样的表中:

car1 | pit1 | value11
car1 | pit2 | value12
car1 | pit3 | value13
car2 | pit1 | value21
car2 | pit2 | value22
car2 | pit3 | value23
car3 | pit1 | value31
car3 | pit2 | value32
car3 | pit3 | value33

Using the examples in the Prefuse project I was able to create a visualization of a table with the x-axis labeled with pit1, pit2 and pit3 and the y-axis with the different values in correct order. 使用Prefuse项目中的示例,我能够创建一个表格的可视化,其中x轴标记为pit1,pit2和pit3,y轴具有正确顺序的不同值。

But what I've tried for hours is to somehow draw little squares at the corresponding spots (like a red square for car1 where pit1 and value11 "meet"). 但是我几个小时试过的是以某种方式在相应的位置绘制小方块(如car1的红色方块,其中pit1和value11“相遇”)。

How do I do this? 我该怎么做呢?

PS: I also would like to know how to improve the y-axis in the following way: PS:我也想知道如何通过以下方式改善y轴:

Imagine the lowest value is 2.6 and the highest is 32.0. 想象一下,最低值是2.6,最高值是32.0。 Right now the y-axis would start with 2.6 and just label every value (with the same space between the labels regardless of the actual difference) up to 32.0. 现在,y轴将从2.6开始,只标记每个值(标签之间的空格相同,无论实际差异),最高为32.0。 What I would prefer is that the labels would start with 0.0 (or 2.0) and then use steps of 5 or so till 35. 我更喜欢的是标签从0.0(或2.0)开始,然后使用5左右的步骤直到35。

You want to visualize your table in a scatter plot with PIT on the x-axis, Value on the y-axis, and Car as the color of the marks (= rectangles). 您希望在散点图中可视化表格,其中x轴为PIT,y轴为值,Car为标记的颜色(=矩形)。

If I understood you correctly, you see the axis labels but no marks. 如果我理解正确,您会看到轴标签,但没有标记。

You need to add a ColorAction to your action list in order to see the marks. 您需要将ColorAction添加到操作列表中才能查看标记。 For example: 例如:

ColorAction color = new ColorAction("data", VisualItem.STROKECOLOR,
                ColorLib.rgb(100, 100, 255));

Or use a DataColorAction , which allows you to visualize marks in different color depending on Car: 或者使用DataColorAction ,它允许您根据Car显示不同颜色的标记:

ColorAction color = new DataColorAction("data", "Car", 
                Constants.NOMINAL, VisualItem.FILLCOLOR);

Regarding the y-axis: prefuse draws every label and ignores actual difference, if it cannot read the variable (here: Value) as a double. 关于y轴:prefuse绘制每个标签并忽略实际差异,如果它不能将变量(此处:值)读取为double。 Please check if it is stored as Double or String . 请检查它是否存储为DoubleString If you want to start at 0.0 you you can set a range model: 如果您想从0.0开始,您可以设置范围模型:

y_axis.setRangeModel(new NumberRangeModel(0, 40, 0, 40)); 

PS: I have written a tutorial for prefuse scatter plots: http://www.ifs.tuwien.ac.at/~rind/w/doku.php/java/prefuse-scatterplot PS:我已经为prefuse散点图编写了一个教程: http ://www.ifs.tuwien.ac.at/~rind/w/doku.php/java/prefuse-scatterplot

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

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