Seite 1 von 1

Verfasst: 21. Jan 2018 20:57
Hi,

does anyone know how getSize in Node, Edge and the "third class" should be implemented?

For example edge should it be only the line (What's its high?) or including containing content or even only its content?

Node may depend on the String-length, but also independend only on a fix value.
But how to translate a char to a pixle value? Or what is the fix value?

And the "third class" has no form so what should its size?
Zero or the sum of all its GraphElements or the biggest GraphElement?

I know, that the sample in 9.4 is using "1" as radius does that mean, Node should be size (2,2) ?

### Re: Ex09 Task 1: getSize-Methods

Verfasst: 22. Jan 2018 10:51
Hi,

for Node you can just use the length of the String. For the size of an edge, you can calculate a bounding box:

Code: Alles auswählen

``````val (x1, y1) = node1.getPosition
val (x2, y2) = node2.getPosition
val xSize = if (x1 < x2) x2 - x1 else x1 - x2
val ySize = if (y1 < y2) y2 - y1 else y1 - y2
(xSize, ySize)
``````
The size of the "third class" can be implemented by calculating a bounding box covering all contained elements.
GS-812 hat geschrieben:
21. Jan 2018 20:57
I know, that the sample in 9.4 is using "1" as radius does that mean, Node should be size (2,2) ?
No, see explanation above.

Best,
Matthias

### Re: Ex09 Task 1: getSize-Methods

Verfasst: 22. Jan 2018 13:58
And whats's the height of a Node? 1?

does the startpoints of a edge have to be centered on the nodes?

### Re: Ex09 Task 1: getSize-Methods

Verfasst: 22. Jan 2018 15:34
Hi,
LorenzB hat geschrieben:
22. Jan 2018 13:58
And whats's the height of a Node? 1?
Yes, you can use 1.
LorenzB hat geschrieben:
22. Jan 2018 13:58
does the startpoints of a edge have to be centered on the nodes?
It doesn't matter where the edge stards.

Best,
Matthias