Class GuiTreasureObserver
java.lang.Object
javafx.application.Application
eu.su.mas.dedale.mas.agents.observerAgent.guiComponents.GuiTreasureObserver
- All Implemented Interfaces:
java.io.Serializable
public class GuiTreasureObserver
extends javafx.application.Application
implements java.io.Serializable
JavaFx frame used to display the backPack's state of each observed agent.
Design pattern Singleton. One Unique frame for one platform
- Author:
- hc
- See Also:
- Serialized Form
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
Constructors Constructor Description GuiTreasureObserver()
-
Method Summary
Modifier and Type Method Description void
addObservedAgent(java.lang.String agentName)
Add the agent to the observerGui (do nothing if already present)static GuiTreasureObserver
getInstance()
Design pattern singletonstatic void
main(java.lang.String[] args)
void
removeObservedAgent(java.lang.String agentName)
Remove the agent from the observerGuivoid
start(javafx.stage.Stage stage)
Automatically called when App.launch() is triggeredjava.lang.String
toString()
boolean
updateAgentDiamondValue(java.lang.String agentName, java.lang.Integer diamondValue)
Set the diamond to its new valueboolean
updateAgentGoldValue(java.lang.String agentName, java.lang.Integer goldValue)
Set the gold to its new valueboolean
updateAgentTreasure(java.lang.String agentName, java.lang.Integer gold, java.lang.Integer diamond)
Set the new values for gold and diamonds.
-
Constructor Details
-
GuiTreasureObserver
public GuiTreasureObserver()
-
-
Method Details
-
main
public static void main(java.lang.String[] args) -
getInstance
Design pattern singleton- Returns:
- Get an instance of the Gui to call the associated update methods. If the instance does not already exist, this method creates it
-
start
public void start(javafx.stage.Stage stage)Automatically called when App.launch() is triggered- Specified by:
start
in classjavafx.application.Application
-
updateAgentTreasure
public boolean updateAgentTreasure(java.lang.String agentName, java.lang.Integer gold, java.lang.Integer diamond)Set the new values for gold and diamonds. If the agent does not exist, it creates it.- Parameters:
agentName
- localName of the agentgold
- quantity of gold the agent carriesdiamond
- quantity of diamond the agent carries- Returns:
- true is the agent has been updated, false if created
-
updateAgentGoldValue
public boolean updateAgentGoldValue(java.lang.String agentName, java.lang.Integer goldValue)Set the gold to its new value- Parameters:
agentName
- localName of the agentgoldValue
- new quantity of gold- Returns:
- true if the value has been updated, false otherwise
-
updateAgentDiamondValue
public boolean updateAgentDiamondValue(java.lang.String agentName, java.lang.Integer diamondValue)Set the diamond to its new value- Parameters:
agentName
- localNamediamondValue
- quantity of diamond to set- Returns:
- true if the value has been updated, false otherwise
-
addObservedAgent
public void addObservedAgent(java.lang.String agentName)Add the agent to the observerGui (do nothing if already present)- Parameters:
agentName
- (unique) name of the agent
-
removeObservedAgent
public void removeObservedAgent(java.lang.String agentName)Remove the agent from the observerGui- Parameters:
agentName
- localname of the agent
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-