FIx: Fixed Coverage Screenshots And htmlRepot.
This commit is contained in:
@@ -0,0 +1,346 @@
|
||||
|
||||
|
||||
|
||||
<!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"> package it.polimi.ingsw.gc14.View.GUI;
|
||||
|
||||
import it.polimi.ingsw.gc14.Controller.ClientController;
|
||||
import it.polimi.ingsw.gc14.Model.Totems;
|
||||
import javafx.animation.*;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.geometry.Rectangle2D;
|
||||
import javafx.scene.Cursor;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.stage.Screen;
|
||||
import javafx.util.Duration;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* FXML controller for the totem selection scene.
|
||||
*
|
||||
* <p>Displays the available totems and lets the current player choose one;
|
||||
* other players see a waiting banner.
|
||||
*/
|
||||
<b class="nc"> public class TotemFXMLController {</b>
|
||||
/** Background image displayed behind the totem selection grid. */
|
||||
@FXML private ImageView backgroundImage;
|
||||
/** HBox containing the totem card widgets. */
|
||||
@FXML private HBox mainHBox;
|
||||
/** Banner label showing whose turn it is to choose a totem. */
|
||||
@FXML private Label turnBanner;
|
||||
/** Button that submits the selected totem to the server. */
|
||||
@FXML private Button confirmButton;
|
||||
|
||||
/** Client controller for sending the totem choice. */
|
||||
private ClientController controller;
|
||||
/** Index of the currently selected totem, or {@code -1} if none selected. */
|
||||
<b class="nc"> private int selectedIndex = -1;</b>
|
||||
/** The {@link StackPane} frame of the currently selected totem card, or {@code null}. */
|
||||
<b class="nc"> private StackPane selectedFrame = null;</b>
|
||||
|
||||
/**
|
||||
* Injects the client controller into this FXML controller.
|
||||
*
|
||||
* @param controller the client controller to use.
|
||||
*/
|
||||
public void setController(ClientController controller) {
|
||||
<b class="nc"> this.controller = controller;</b>
|
||||
}
|
||||
|
||||
/** Initializes the scene: sets the background image to fill the screen. */
|
||||
@FXML
|
||||
public void initialize() {
|
||||
<b class="nc"> Image img = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/GUIImages/Background.png")));</b>
|
||||
<b class="nc"> backgroundImage.setImage(img);</b>
|
||||
<b class="nc"> Rectangle2D screenBounds = Screen.getPrimary().getBounds();</b>
|
||||
<b class="nc"> backgroundImage.setFitWidth(screenBounds.getWidth());</b>
|
||||
<b class="nc"> backgroundImage.setFitHeight(screenBounds.getHeight());</b>
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the totem selection cards with entry animations.
|
||||
* Disables interaction for players who are not the current chooser.
|
||||
*/
|
||||
public void render() {
|
||||
<b class="nc"> mainHBox.getChildren().clear();</b>
|
||||
<b class="nc"> selectedIndex = -1;</b>
|
||||
<b class="nc"> selectedFrame = null;</b>
|
||||
|
||||
<b class="nc"> if (controller.getMiniModel().currentState.getCurrentPlayer() == null) return;</b>
|
||||
<b class="nc"> String chooser = controller.getMiniModel().currentState.getCurrentPlayer().getUserName();</b>
|
||||
<b class="nc"> boolean myTurn = chooser.equals(controller.getMyUsername());</b>
|
||||
|
||||
<b class="nc"> updateBanner(chooser, myTurn);</b>
|
||||
<b class="nc"> updateConfirmButton(false);</b>
|
||||
|
||||
<b class="nc"> for (int i = 0; i < controller.getMiniModel().availableTotems.size(); i++) {</b>
|
||||
<b class="nc"> Totems totem = controller.getMiniModel().availableTotems.get(i);</b>
|
||||
<b class="nc"> VBox card = buildCard(totem, i, myTurn);</b>
|
||||
<b class="nc"> mainHBox.getChildren().add(card);</b>
|
||||
|
||||
<b class="nc"> card.setOpacity(0);</b>
|
||||
<b class="nc"> card.setTranslateY(14);</b>
|
||||
<b class="nc"> PauseTransition delay = new PauseTransition(Duration.millis(80 + i * 65));</b>
|
||||
<b class="nc"> delay.setOnFinished(e -> {</b>
|
||||
<b class="nc"> FadeTransition ft = new FadeTransition(Duration.millis(320), card);</b>
|
||||
<b class="nc"> ft.setToValue(1);</b>
|
||||
<b class="nc"> TranslateTransition tt = new TranslateTransition(Duration.millis(320), card);</b>
|
||||
<b class="nc"> tt.setToY(0);</b>
|
||||
<b class="nc"> new ParallelTransition(ft, tt).play();</b>
|
||||
});
|
||||
<b class="nc"> delay.play();</b>
|
||||
}
|
||||
}
|
||||
|
||||
/** Updates the turn banner text and style based on whether it is the local player's turn. */
|
||||
private void updateBanner(String chooser, boolean myTurn) {
|
||||
<b class="nc"> if (myTurn) {</b>
|
||||
<b class="nc"> turnBanner.setText("✦ It's your turn to choose ✦");</b>
|
||||
<b class="nc"> turnBanner.setStyle(</b>
|
||||
"-fx-font-family: 'Cinzel'; -fx-font-size: 13; -fx-font-weight: 'bold'; -fx-letter-spacing: 3;" +
|
||||
"-fx-text-fill: #000000;" +
|
||||
"-fx-background-color: linear-gradient(to right, #f4c05a, #c8791a, #f4c05a);" +
|
||||
"-fx-border-color: #000000; -fx-border-width: 1;" +
|
||||
"-fx-border-radius: 3; -fx-background-radius: 3;" +
|
||||
"-fx-padding: 10 28 10 28;" +
|
||||
"-fx-effect: dropshadow(gaussian, rgba(244,192,90,0.3), 18, 0, 0, 0);"
|
||||
);
|
||||
} else {
|
||||
<b class="nc"> turnBanner.setText("Waiting for " + chooser + " to choose his totem…");</b>
|
||||
<b class="nc"> turnBanner.setStyle(</b>
|
||||
"-fx-font-family: 'Cinzel'; -fx-font-size: 11; -fx-letter-spacing: 2;" +
|
||||
"-fx-text-fill: #000000;" +
|
||||
"-fx-background-color: linear-gradient(to right, #f4c05a, #c8791a, #f4c05a);" +
|
||||
"-fx-border-color: #000000; -fx-border-width: 1;" +
|
||||
"-fx-border-radius: 3; -fx-background-radius: 3;" +
|
||||
"-fx-padding: 10 28 10 28;"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/** Builds a totem card widget; if {@code interactive}, wires click/hover handlers and selection logic. */
|
||||
private VBox buildCard(Totems totem, int idx, boolean interactive) {
|
||||
<b class="nc"> ImageView img = new ImageView(new Image(Objects.requireNonNull(getClass().getResourceAsStream("/GUIImages/Totems/totem_" + String.valueOf(totem).toLowerCase(Locale.ROOT) + ".png"))));</b>
|
||||
<b class="nc"> img.setFitHeight(150);</b>
|
||||
<b class="nc"> img.setPreserveRatio(true);</b>
|
||||
|
||||
<b class="nc"> StackPane frame = new StackPane(img);</b>
|
||||
<b class="nc"> frame.setPrefSize(100, 145);</b>
|
||||
<b class="nc"> frame.setBackground(Background.EMPTY);</b>
|
||||
<b class="nc"> img.setStyle(frameStyle(false));</b>
|
||||
|
||||
<b class="nc"> Region base = new Region();</b>
|
||||
<b class="nc"> base.setPrefSize(100, 10);</b>
|
||||
|
||||
<b class="nc"> Label name = new Label(capitalize(totem));</b>
|
||||
<b class="nc"> name.setStyle(nameStyle(false));</b>
|
||||
|
||||
<b class="nc"> VBox card = new VBox(4, frame, base, name);</b>
|
||||
<b class="nc"> card.setAlignment(Pos.CENTER);</b>
|
||||
|
||||
<b class="nc"> if (!interactive) {</b>
|
||||
<b class="nc"> card.setOpacity(0.35);</b>
|
||||
<b class="nc"> card.setCursor(Cursor.DEFAULT);</b>
|
||||
<b class="nc"> return card;</b>
|
||||
}
|
||||
|
||||
<b class="nc"> card.setCursor(Cursor.HAND);</b>
|
||||
|
||||
<b class="nc"> card.setOnMouseEntered(e -> {</b>
|
||||
<b class="nc"> if (frame != selectedFrame) {</b>
|
||||
<b class="nc"> ScaleTransition st = new ScaleTransition(Duration.millis(140), card);</b>
|
||||
<b class="nc"> st.setToX(1.06); st.setToY(1.06); st.play();</b>
|
||||
}
|
||||
});
|
||||
<b class="nc"> card.setOnMouseExited(e -> {</b>
|
||||
<b class="nc"> if (frame != selectedFrame) {</b>
|
||||
<b class="nc"> ScaleTransition st = new ScaleTransition(Duration.millis(140), card);</b>
|
||||
<b class="nc"> st.setToX(1.0); st.setToY(1.0); st.play();</b>
|
||||
}
|
||||
});
|
||||
|
||||
<b class="nc"> card.setOnMouseClicked(e -> {</b>
|
||||
<b class="nc"> mainHBox.getChildren().forEach(n -> {</b>
|
||||
<b class="nc"> if (n instanceof VBox v) {</b>
|
||||
<b class="nc"> StackPane f = (StackPane) v.getChildren().get(0);</b>
|
||||
<b class="nc"> Label l = (Label) v.getChildren().get(2);</b>
|
||||
<b class="nc"> f.setStyle(frameStyle(false));</b>
|
||||
<b class="nc"> l.setStyle(nameStyle(false));</b>
|
||||
<b class="nc"> ScaleTransition st = new ScaleTransition(Duration.millis(130), v);</b>
|
||||
<b class="nc"> st.setToX(1.0); st.setToY(1.0); st.play();</b>
|
||||
}
|
||||
});
|
||||
|
||||
<b class="nc"> frame.setStyle(frameStyle(true));</b>
|
||||
<b class="nc"> name.setStyle(nameStyle(true));</b>
|
||||
<b class="nc"> selectedFrame = frame;</b>
|
||||
<b class="nc"> selectedIndex = idx;</b>
|
||||
|
||||
<b class="nc"> ScaleTransition pop = new ScaleTransition(Duration.millis(160), card);</b>
|
||||
<b class="nc"> pop.setToX(1.08); pop.setToY(1.08);</b>
|
||||
<b class="nc"> pop.setAutoReverse(true); pop.setCycleCount(2); pop.play();</b>
|
||||
|
||||
<b class="nc"> updateConfirmButton(true);</b>
|
||||
});
|
||||
|
||||
<b class="nc"> return card;</b>
|
||||
}
|
||||
|
||||
/** Enables or disables the confirm button and updates its visual opacity to reflect the state. */
|
||||
private void updateConfirmButton(boolean enabled) {
|
||||
<b class="nc"> confirmButton.setDisable(!enabled);</b>
|
||||
<b class="nc"> confirmButton.setStyle(</b>
|
||||
"-fx-font-family: 'Cinzel'; -fx-font-size: 12; -fx-font-weight: bold;" +
|
||||
"-fx-letter-spacing: 4; -fx-text-fill: #0c0601;" +
|
||||
"-fx-background-color: linear-gradient(to right, #f4c05a, #c8791a, #f4c05a);" +
|
||||
"-fx-padding: 12 48 12 48; -fx-background-radius: 2;" +
|
||||
<b class="nc"> "-fx-opacity: " + (enabled ? "1.0" : "0.3") + ";" +</b>
|
||||
<b class="nc"> "-fx-cursor: " + (enabled ? "hand" : "default") + ";"</b>
|
||||
);
|
||||
}
|
||||
|
||||
/** Returns the CSS style string for the totem card frame, highlighting it when {@code selected}. */
|
||||
private String frameStyle(boolean selected) {
|
||||
<b class="nc"> return selected ? "-fx-effect: dropshadow(gaussian, #ffffff, 20, 0.33, 0, 0);" : "";</b>
|
||||
}
|
||||
|
||||
/** Returns the CSS style string for the totem name label, brightening it when {@code selected}. */
|
||||
private String nameStyle(boolean selected) {
|
||||
return "-fx-font-family: 'Cinzel'; -fx-font-size: 10; -fx-letter-spacing: 2;" +
|
||||
<b class="nc"> "-fx-text-fill: " + (selected ? "#FFD700" : "#ffffff") + ";";</b>
|
||||
}
|
||||
|
||||
/** Returns the totem name with only the first letter capitalized. */
|
||||
private String capitalize(Totems t) {
|
||||
<b class="nc"> String s = t.name().toLowerCase(Locale.ROOT);</b>
|
||||
<b class="nc"> return Character.toUpperCase(s.charAt(0)) + s.substring(1);</b>
|
||||
}
|
||||
|
||||
|
||||
/** Submits the selected totem index to the controller when the confirm button is clicked. */
|
||||
@FXML
|
||||
private void onConfirm() {
|
||||
<b class="nc"> if (selectedIndex >= 0) {</b>
|
||||
<b class="nc"> controller.totemChoice(selectedIndex);</b>
|
||||
}
|
||||
}
|
||||
}
|
||||
</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-19 22:53</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user