## Ex09 Task 1: getSize-Methods

GS-812
Windoof-User
Beiträge: 30
Registriert: 25. Apr 2015 12:47

### Ex09 Task 1: getSize-Methods

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) ?

Thanks in Advance

meichholz
Endlosschleifenbastler
Beiträge: 167
Registriert: 30. Mär 2016 08:28

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

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

LorenzB
Windoof-User
Beiträge: 28
Registriert: 1. Sep 2015 12:27

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

And whats's the height of a Node? 1?

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

meichholz
Endlosschleifenbastler
Beiträge: 167
Registriert: 30. Mär 2016 08:28

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

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