From fd0ee5c776abaa50c09cf50fbff682824e808ab5 Mon Sep 17 00:00:00 2001 From: cemal Date: Thu, 22 Feb 2024 10:31:49 +0100 Subject: [PATCH] Added new diagram --- src/main/kotlin/main/Compare.kt | 94 ++++++++++++++++++++++++--------- 1 file changed, 69 insertions(+), 25 deletions(-) diff --git a/src/main/kotlin/main/Compare.kt b/src/main/kotlin/main/Compare.kt index ad652f0..04f5b23 100644 --- a/src/main/kotlin/main/Compare.kt +++ b/src/main/kotlin/main/Compare.kt @@ -27,6 +27,7 @@ import androidx.compose.ui.graphics.Paint import androidx.compose.ui.graphics.Path import androidx.compose.ui.graphics.drawscope.drawIntoCanvas import androidx.compose.ui.graphics.toArgb +import androidx.compose.ui.res.painterResource import androidx.compose.ui.text.* import androidx.compose.ui.unit.Constraints import androidx.compose.ui.unit.sp @@ -45,6 +46,8 @@ fun compareResults( val noFileSnackbarVisibleState = remember { mutableStateOf(false) } val scrollState = rememberLazyListState() val showTableAndLegend = remember { mutableStateOf(true) } // State to control the visibility of the table and legend + val showVennDiagram = remember { mutableStateOf(false) } // State to control the visibility of the Venn diagram + Column( modifier = Modifier.fillMaxSize(), @@ -59,7 +62,34 @@ fun compareResults( Spacer(modifier = Modifier.height(16.dp)) // Show the table and legend only if showTableAndLegend is true - if (showTableAndLegend.value) { + + + val intersectionWords = mutableListOf() + + Spacer(modifier = Modifier.height(16.dp)) + println("glossaryWords : $glossaryWordsSet") + + for (word in codeWords) { + if (word in glossaryWords.map { it.name }) { + intersectionWords.add(word) + println("inter : $word") + } + } + + // Show the Venn diagram only if showTableAndLegend is false + if (!showTableAndLegend.value && showVennDiagram.value) { + IntersectionCircles( + intersectionWords, + glossaryWords, + codeWords + ) + } else if (!showTableAndLegend.value && !showVennDiagram.value) { + Image( + painter = painterResource("code.png"), + contentDescription = "Venn diagram", + modifier = Modifier.size(500.dp) + ) + } else if (showTableAndLegend.value && !showVennDiagram.value) { commonWordsTable(glossaryWords, codeWords) Spacer(modifier = Modifier.height(16.dp)) @@ -76,36 +106,50 @@ fun compareResults( } } - val intersectionWords = mutableListOf() - Spacer(modifier = Modifier.height(16.dp)) - println("glossaryWords : $glossaryWordsSet") + Column { + Row( + horizontalArrangement = Arrangement.spacedBy(16.dp) + ) { + Button( + onClick = { + showTableAndLegend.value = false + showVennDiagram.value = true + }, // Toggle the value of showTableAndLegend when the button is clicked + colors = androidx.compose.material.ButtonDefaults.buttonColors( + backgroundColor = customRedColor, + contentColor = Color.White + ) + ) { + Text("Montrer le diagramme de Venn") // Change the button text based on the value of showTableAndLegend + } - for (word in codeWords) { - if (word in glossaryWords.map { it.name }) { - intersectionWords.add(word) - println("inter : $word") + Button( + onClick = { showTableAndLegend.value = true + showVennDiagram.value = false}, + colors = androidx.compose.material.ButtonDefaults.buttonColors( + backgroundColor = customRedColor, + contentColor = Color.White + ) + ) { + Text("Montrer le tableau") + } + + Button( + onClick = { showTableAndLegend.value = false + showVennDiagram.value = false}, + colors = androidx.compose.material.ButtonDefaults.buttonColors( + backgroundColor = customRedColor, + contentColor = Color.White + ) + ) { + Text("Montrer le diagramme") + } } } - // Show the Venn diagram only if showTableAndLegend is false - if (!showTableAndLegend.value) { - IntersectionCircles( - intersectionWords, - glossaryWords, - codeWords - ) - } - Button( - onClick = { showTableAndLegend.value = !showTableAndLegend.value }, // Toggle the value of showTableAndLegend when the button is clicked - colors = androidx.compose.material.ButtonDefaults.buttonColors( - backgroundColor = customRedColor, - contentColor = Color.White - ) - ) { - Text(if (showTableAndLegend.value) "Montrer le diagramme de Venn" else "Montrer le tableau") // Change the button text based on the value of showTableAndLegend - } + Button( onClick = onBackClick,