Add: Added Coverage Screenshots And htlmReport.

This commit is contained in:
GabrieleRadice
2026-06-19 21:50:38 +02:00
parent 6aca188aa3
commit d78b8bbd93
316 changed files with 86329 additions and 0 deletions
@@ -0,0 +1,345 @@
<!DOCTYPE html>
<html id="htmlId">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Coverage Report > TotemFXMLController</title>
<style type="text/css">
@import "../../css/coverage.css";
@import "../../css/idea.min.css";
</style>
<script type="text/javascript" src="../../js/highlight.min.js"></script>
<script type="text/javascript" src="../../js/highlightjs-line-numbers.min.js"></script>
</head>
<body>
<div class="content">
<div class="breadCrumbs">
Current scope: <a href="../../index.html">all classes</a>
<span class="separator">|</span>
<a href="../index.html">it.polimi.ingsw.gc14.View.GUI</a>
</div>
<h1>Coverage Summary for Class: TotemFXMLController (it.polimi.ingsw.gc14.View.GUI)</h1>
<table class="coverageStats">
<tr>
<th class="name">Class</th>
<th class="coverageStat
">
Class, %
</th>
<th class="coverageStat
">
Method, %
</th>
<th class="coverageStat
">
Branch, %
</th>
<th class="coverageStat
">
Line, %
</th>
</tr>
<tr>
<td class="name">TotemFXMLController</td>
<td class="coverageStat">
<span class="percent">
0%
</span>
<span class="absValue">
(0/1)
</span>
</td>
<td class="coverageStat">
<span class="percent">
0%
</span>
<span class="absValue">
(0/16)
</span>
</td>
<td class="coverageStat">
<span class="percent">
0%
</span>
<span class="absValue">
(0/24)
</span>
</td>
<td class="coverageStat">
<span class="percent">
0%
</span>
<span class="absValue">
(0/90)
</span>
</td>
</tr>
</table>
<br/>
<br/>
<pre>
<code class="sourceCode" id="sourceCode">&nbsp;package it.polimi.ingsw.gc14.View.GUI;
&nbsp;
&nbsp;import it.polimi.ingsw.gc14.Controller.ClientController;
&nbsp;import it.polimi.ingsw.gc14.Model.Totems;
&nbsp;import javafx.animation.*;
&nbsp;import javafx.fxml.FXML;
&nbsp;import javafx.geometry.Pos;
&nbsp;import javafx.geometry.Rectangle2D;
&nbsp;import javafx.scene.Cursor;
&nbsp;import javafx.scene.control.Button;
&nbsp;import javafx.scene.control.Label;
&nbsp;import javafx.scene.image.Image;
&nbsp;import javafx.scene.image.ImageView;
&nbsp;import javafx.scene.layout.*;
&nbsp;import javafx.stage.Screen;
&nbsp;import javafx.util.Duration;
&nbsp;
&nbsp;import java.util.Locale;
&nbsp;
&nbsp;/**
&nbsp; * FXML controller for the totem selection scene.
&nbsp; *
&nbsp; * &lt;p&gt;Displays the available totems and lets the current player choose one;
&nbsp; * other players see a waiting banner.
&nbsp; */
<b class="nc">&nbsp;public class TotemFXMLController {</b>
&nbsp; //TODO
&nbsp; @FXML private ImageView backgroundImage;
&nbsp; //TODO
&nbsp; @FXML private HBox mainHBox;
&nbsp; //TODO
&nbsp; @FXML private Label turnBanner;
&nbsp; //TODO
&nbsp; @FXML private Button confirmButton;
&nbsp;
&nbsp; //TODO
&nbsp; private ClientController controller;
&nbsp; //TODO
<b class="nc">&nbsp; private int selectedIndex = -1;</b>
&nbsp; //TODO
<b class="nc">&nbsp; private StackPane selectedFrame = null;</b>
&nbsp;
&nbsp; /**
&nbsp; * Injects the client controller into this FXML controller.
&nbsp; *
&nbsp; * @param controller the client controller to use.
&nbsp; */
&nbsp; public void setController(ClientController controller) {
<b class="nc">&nbsp; this.controller = controller;</b>
&nbsp; }
&nbsp;
&nbsp; /** Initializes the scene: sets the background image to fill the screen. */
&nbsp; @FXML
&nbsp; public void initialize() {
<b class="nc">&nbsp; Image img = new Image(getClass().getResourceAsStream(&quot;/GUIImages/Background.png&quot;));</b>
<b class="nc">&nbsp; backgroundImage.setImage(img);</b>
<b class="nc">&nbsp; Rectangle2D screenBounds = Screen.getPrimary().getBounds();</b>
<b class="nc">&nbsp; backgroundImage.setFitWidth(screenBounds.getWidth());</b>
<b class="nc">&nbsp; backgroundImage.setFitHeight(screenBounds.getHeight());</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Renders the totem selection cards with entry animations.
&nbsp; * Disables interaction for players who are not the current chooser.
&nbsp; */
&nbsp; public void render() {
<b class="nc">&nbsp; mainHBox.getChildren().clear();</b>
<b class="nc">&nbsp; selectedIndex = -1;</b>
<b class="nc">&nbsp; selectedFrame = null;</b>
&nbsp;
<b class="nc">&nbsp; if (controller.getMiniModel().currentState.getCurrentPlayer() == null) return;</b>
<b class="nc">&nbsp; String chooser = controller.getMiniModel().currentState.getCurrentPlayer().getUserName();</b>
<b class="nc">&nbsp; boolean myTurn = chooser.equals(controller.getMyUsername());</b>
&nbsp;
<b class="nc">&nbsp; updateBanner(chooser, myTurn);</b>
<b class="nc">&nbsp; updateConfirmButton(false);</b>
&nbsp;
<b class="nc">&nbsp; for (int i = 0; i &lt; controller.getMiniModel().availableTotems.size(); i++) {</b>
<b class="nc">&nbsp; Totems totem = controller.getMiniModel().availableTotems.get(i);</b>
<b class="nc">&nbsp; VBox card = buildCard(totem, i, myTurn);</b>
<b class="nc">&nbsp; mainHBox.getChildren().add(card);</b>
&nbsp;
<b class="nc">&nbsp; card.setOpacity(0);</b>
<b class="nc">&nbsp; card.setTranslateY(14);</b>
<b class="nc">&nbsp; PauseTransition delay = new PauseTransition(Duration.millis(80 + i * 65));</b>
<b class="nc">&nbsp; delay.setOnFinished(e -&gt; {</b>
<b class="nc">&nbsp; FadeTransition ft = new FadeTransition(Duration.millis(320), card);</b>
<b class="nc">&nbsp; ft.setToValue(1);</b>
<b class="nc">&nbsp; TranslateTransition tt = new TranslateTransition(Duration.millis(320), card);</b>
<b class="nc">&nbsp; tt.setToY(0);</b>
<b class="nc">&nbsp; new ParallelTransition(ft, tt).play();</b>
&nbsp; });
<b class="nc">&nbsp; delay.play();</b>
&nbsp; }
&nbsp; }
&nbsp;
&nbsp; /** Updates the turn banner text and style based on whether it is the local player&#39;s turn. */
&nbsp; private void updateBanner(String chooser, boolean myTurn) {
<b class="nc">&nbsp; if (myTurn) {</b>
<b class="nc">&nbsp; turnBanner.setText(&quot;✦ It&#39;s your turn to choose ✦&quot;);</b>
<b class="nc">&nbsp; turnBanner.setStyle(</b>
&nbsp; &quot;-fx-font-family: &#39;Cinzel&#39;; -fx-font-size: 13; -fx-font-weight: &#39;bold&#39;; -fx-letter-spacing: 3;&quot; +
&nbsp; &quot;-fx-text-fill: #000000;&quot; +
&nbsp; &quot;-fx-background-color: linear-gradient(to right, #f4c05a, #c8791a, #f4c05a);&quot; +
&nbsp; &quot;-fx-border-color: #000000; -fx-border-width: 1;&quot; +
&nbsp; &quot;-fx-border-radius: 3; -fx-background-radius: 3;&quot; +
&nbsp; &quot;-fx-padding: 10 28 10 28;&quot; +
&nbsp; &quot;-fx-effect: dropshadow(gaussian, rgba(244,192,90,0.3), 18, 0, 0, 0);&quot;
&nbsp; );
&nbsp; } else {
<b class="nc">&nbsp; turnBanner.setText(&quot;Waiting for &quot; + chooser + &quot; to choose his totem…&quot;);</b>
<b class="nc">&nbsp; turnBanner.setStyle(</b>
&nbsp; &quot;-fx-font-family: &#39;Cinzel&#39;; -fx-font-size: 11; -fx-letter-spacing: 2;&quot; +
&nbsp; &quot;-fx-text-fill: #000000;&quot; +
&nbsp; &quot;-fx-background-color: linear-gradient(to right, #f4c05a, #c8791a, #f4c05a);&quot; +
&nbsp; &quot;-fx-border-color: #000000; -fx-border-width: 1;&quot; +
&nbsp; &quot;-fx-border-radius: 3; -fx-background-radius: 3;&quot; +
&nbsp; &quot;-fx-padding: 10 28 10 28;&quot;
&nbsp; );
&nbsp; }
&nbsp; }
&nbsp;
&nbsp; /** Builds a totem card widget; if {@code interactive}, wires click/hover handlers and selection logic. */
&nbsp; private VBox buildCard(Totems totem, int idx, boolean interactive) {
<b class="nc">&nbsp; ImageView img = new ImageView(new Image(getClass().getResourceAsStream(&quot;/GUIImages/Totems/totem_&quot; + String.valueOf(totem).toLowerCase(Locale.ROOT) + &quot;.png&quot;)));</b>
<b class="nc">&nbsp; img.setFitHeight(150);</b>
<b class="nc">&nbsp; img.setPreserveRatio(true);</b>
&nbsp;
<b class="nc">&nbsp; StackPane frame = new StackPane(img);</b>
<b class="nc">&nbsp; frame.setPrefSize(100, 145);</b>
<b class="nc">&nbsp; frame.setBackground(Background.EMPTY);</b>
<b class="nc">&nbsp; img.setStyle(frameStyle(false));</b>
&nbsp;
<b class="nc">&nbsp; Region base = new Region();</b>
<b class="nc">&nbsp; base.setPrefSize(100, 10);</b>
&nbsp;
<b class="nc">&nbsp; Label name = new Label(capitalize(totem));</b>
<b class="nc">&nbsp; name.setStyle(nameStyle(false));</b>
&nbsp;
<b class="nc">&nbsp; VBox card = new VBox(4, frame, base, name);</b>
<b class="nc">&nbsp; card.setAlignment(Pos.CENTER);</b>
&nbsp;
<b class="nc">&nbsp; if (!interactive) {</b>
<b class="nc">&nbsp; card.setOpacity(0.35);</b>
<b class="nc">&nbsp; card.setCursor(Cursor.DEFAULT);</b>
<b class="nc">&nbsp; return card;</b>
&nbsp; }
&nbsp;
<b class="nc">&nbsp; card.setCursor(Cursor.HAND);</b>
&nbsp;
<b class="nc">&nbsp; card.setOnMouseEntered(e -&gt; {</b>
<b class="nc">&nbsp; if (frame != selectedFrame) {</b>
<b class="nc">&nbsp; ScaleTransition st = new ScaleTransition(Duration.millis(140), card);</b>
<b class="nc">&nbsp; st.setToX(1.06); st.setToY(1.06); st.play();</b>
&nbsp; }
&nbsp; });
<b class="nc">&nbsp; card.setOnMouseExited(e -&gt; {</b>
<b class="nc">&nbsp; if (frame != selectedFrame) {</b>
<b class="nc">&nbsp; ScaleTransition st = new ScaleTransition(Duration.millis(140), card);</b>
<b class="nc">&nbsp; st.setToX(1.0); st.setToY(1.0); st.play();</b>
&nbsp; }
&nbsp; });
&nbsp;
<b class="nc">&nbsp; card.setOnMouseClicked(e -&gt; {</b>
<b class="nc">&nbsp; mainHBox.getChildren().forEach(n -&gt; {</b>
<b class="nc">&nbsp; if (n instanceof VBox v) {</b>
<b class="nc">&nbsp; StackPane f = (StackPane) v.getChildren().get(0);</b>
<b class="nc">&nbsp; Label l = (Label) v.getChildren().get(2);</b>
<b class="nc">&nbsp; f.setStyle(frameStyle(false));</b>
<b class="nc">&nbsp; l.setStyle(nameStyle(false));</b>
<b class="nc">&nbsp; ScaleTransition st = new ScaleTransition(Duration.millis(130), v);</b>
<b class="nc">&nbsp; st.setToX(1.0); st.setToY(1.0); st.play();</b>
&nbsp; }
&nbsp; });
&nbsp;
<b class="nc">&nbsp; frame.setStyle(frameStyle(true));</b>
<b class="nc">&nbsp; name.setStyle(nameStyle(true));</b>
<b class="nc">&nbsp; selectedFrame = frame;</b>
<b class="nc">&nbsp; selectedIndex = idx;</b>
&nbsp;
<b class="nc">&nbsp; ScaleTransition pop = new ScaleTransition(Duration.millis(160), card);</b>
<b class="nc">&nbsp; pop.setToX(1.08); pop.setToY(1.08);</b>
<b class="nc">&nbsp; pop.setAutoReverse(true); pop.setCycleCount(2); pop.play();</b>
&nbsp;
<b class="nc">&nbsp; updateConfirmButton(true);</b>
&nbsp; });
&nbsp;
<b class="nc">&nbsp; return card;</b>
&nbsp; }
&nbsp;
&nbsp; /** Enables or disables the confirm button and updates its visual opacity to reflect the state. */
&nbsp; private void updateConfirmButton(boolean enabled) {
<b class="nc">&nbsp; confirmButton.setDisable(!enabled);</b>
<b class="nc">&nbsp; confirmButton.setStyle(</b>
&nbsp; &quot;-fx-font-family: &#39;Cinzel&#39;; -fx-font-size: 12; -fx-font-weight: bold;&quot; +
&nbsp; &quot;-fx-letter-spacing: 4; -fx-text-fill: #0c0601;&quot; +
&nbsp; &quot;-fx-background-color: linear-gradient(to right, #f4c05a, #c8791a, #f4c05a);&quot; +
&nbsp; &quot;-fx-padding: 12 48 12 48; -fx-background-radius: 2;&quot; +
<b class="nc">&nbsp; &quot;-fx-opacity: &quot; + (enabled ? &quot;1.0&quot; : &quot;0.3&quot;) + &quot;;&quot; +</b>
<b class="nc">&nbsp; &quot;-fx-cursor: &quot; + (enabled ? &quot;hand&quot; : &quot;default&quot;) + &quot;;&quot;</b>
&nbsp; );
&nbsp; }
&nbsp;
&nbsp; /** Returns the CSS style string for the totem card frame, highlighting it when {@code selected}. */
&nbsp; private String frameStyle(boolean selected) {
<b class="nc">&nbsp; return selected ? &quot;-fx-effect: dropshadow(gaussian, #ffffff, 20, 0.33, 0, 0);&quot; : &quot;&quot;;</b>
&nbsp; }
&nbsp;
&nbsp; /** Returns the CSS style string for the totem name label, brightening it when {@code selected}. */
&nbsp; private String nameStyle(boolean selected) {
&nbsp; return &quot;-fx-font-family: &#39;Cinzel&#39;; -fx-font-size: 10; -fx-letter-spacing: 2;&quot; +
<b class="nc">&nbsp; &quot;-fx-text-fill: &quot; + (selected ? &quot;#FFD700&quot; : &quot;#ffffff&quot;) + &quot;;&quot;;</b>
&nbsp; }
&nbsp;
&nbsp; /** Returns the totem name with only the first letter capitalised. */
&nbsp; private String capitalize(Totems t) {
<b class="nc">&nbsp; String s = t.name().toLowerCase(Locale.ROOT);</b>
<b class="nc">&nbsp; return Character.toUpperCase(s.charAt(0)) + s.substring(1);</b>
&nbsp; }
&nbsp;
&nbsp;
&nbsp; /** Submits the selected totem index to the controller when the confirm button is clicked. */
&nbsp; @FXML
&nbsp; private void onConfirm() {
<b class="nc">&nbsp; if (selectedIndex &gt;= 0) {</b>
<b class="nc">&nbsp; controller.totemChoice(selectedIndex);</b>
&nbsp; }
&nbsp; }
&nbsp;}
</code>
</pre>
</div>
<script type="text/javascript">
(function() {
var msie = false, msie9 = false;
/*@cc_on
msie = true;
@if (@_jscript_version >= 9)
msie9 = true;
@end
@*/
if (!msie || msie && msie9) {
hljs.highlightAll()
hljs.initLineNumbersOnLoad();
}
})();
</script>
<div class="footer">
<div style="float:right;">generated on 2026-06-14 21:53</div>
</div>
</body>
</html>