我如何在 Java 中将形状的 ArrayList 拆分为分区/列表(仅供参考) [英] How can i split an ArrayList of Shapes into partitions/lists in Java (Just advice)

查看:29
本文介绍了我如何在 Java 中将形状的 ArrayList 拆分为分区/列表(仅供参考)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想要一个关于如何做的建议或建议.我已经考虑了几个小时,但找不到解决方案.

I just want an advice or suggestions of how i can do it. i've been thinking about it for hours now and can't find a solution.

我的目标是将此 ER 图表转换为表格.

My aim is to convert this ER Diagram to tables.

所以我有一个链接到椭圆(属性)的矩形(实体).我已经解决了线条将检索链接到它的对象的形状的碰撞.见下图:

So i have a Rectangle(Entity) that is linked to an ellipse(Attribute). I've already worked out on the collisions of the shapes where the line will retrieve the object that is linked to it. See the picture below:

绘制上图的结果如下:

LINE(1) 与矩形的 INDEX(0) 碰撞

LINE(1) COLLIDES WITH ELLIPSE OF INDEX(2)

我的形状被存储在一个形状的 ArrayList 中,我想要实现的是:

My Shapes are being stored in an ArrayList of shapes and what am trying to achieve is :

1- 我希望能够在形状内输入文本.该文本(例如学生")稍后当我想将 ER 图转换为表格时也需要它.我已经在使用一个形状数组列表,是否可以添加指向这个形状数组列表的每个索引的指针,说明这个索引(0)(它是一个矩形)被命名为学生"?(见下图)

1- I want to be able to enter text inside the shapes. That text(e.g "Student") i will also need it later on when i want to make the conversion of ER Diagram to tables. I'm already using an Array List of Shapes, is it possible to add pointers to each index of this Array List of Shapes, stating that this index(0) (which is a rectangle) is named "Student"? (See picture below)

文本应该存储在哪里,以便我以后可以使用该矩形的特定索引检索文本Student".如果我的方法不好,我会很感激其他关于我如何做到的建议.我可以使用分区吗?

Where should the text be stored so that i can later on retrieve the text "Student" using a specific index of that rectangle. If my approach is not good, i will appreciate other suggestions of how i can do it. Can i use partitions?

建议!

请帮忙?

推荐答案

最简单的方法是使用您的 shape 和 text 属性创建一个新对象,并覆盖 equals 方法.因此,您可以检索形状和形状内的文本.

The easiest way to do it is to create a new object with your shape and text attribute, and override the equals method. So you could be able to retrieve the shape and the text inside the shape.

您还可以使用文本管理第二个数组列表,并具有匹配的索引,例如 0 中的形状在文本列表中的文本属性为 0,但我不推荐它,因为它真的很容易创建新问题.

You can also manage a second arraylist with your text, with matching index, like the shape in 0 have the text attribute in your text list in 0, but i do not recommand it, because it is really easy to create new issues.

这篇关于我如何在 Java 中将形状的 ArrayList 拆分为分区/列表(仅供参考)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆