id
stringlengths
36
36
text
stringlengths
1
1.25M
9c93c6fe-24ec-4296-912b-798150355028
public static void populateTree(DynamicTreePanel dynamicTree) { String p1Name = new String("Parent 1"); String p2Name = new String("Parent 2"); String c1Name = new String("Child 1"); String c2Name = new String("Child 2"); DefaultMutableTreeNode p1, p2; p1 = dynamicTree.addObject(null, p1Name); p2 = dyna...
d6680808-d0c8-4a5c-b84c-809ef74cbb21
public MainPanel(DynamicTreePanel dynamicTree) { super(new BorderLayout()); /** The add button's action. */ AbstractAction addButtonAction = new AbstractAction("Add") { /** Serial ID */ private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent event) { ...
726d0741-ffa5-4333-8cfc-1407931b508e
@Override public void actionPerformed(ActionEvent event) { /** The DynamicTree we are working on. */ DynamicTreePanel dynamicTree = (DynamicTreePanel) getValue(KEY_DYNAMIC_TREE); /** * In this demo we use a counter to give a unique name for each * node. */ Integer NodeId = (Integer) ...
d6439317-fb22-4547-b2fc-b15c173fed7f
@Override public void actionPerformed(ActionEvent event) { /** The DynamicTree we are working on. */ DynamicTreePanel dynamicTree = (DynamicTreePanel) getValue(KEY_DYNAMIC_TREE); dynamicTree.removeCurrentNode(); }
d57adbff-2d3f-4e57-b9bd-4a7b36a2f951
@Override public void actionPerformed(ActionEvent event) { /** The DynamicTree we are working on. */ DynamicTreePanel dynamicTree = (DynamicTreePanel) getValue(KEY_DYNAMIC_TREE); dynamicTree.clear(); }
56c9049e-ae0d-46fb-8143-3d0d5eda7585
TreePopulatorDelay(DynamicTreePanel dynamicTreePanel) { super(); this.dynamicTreePanel = dynamicTreePanel; }
4324a95d-06fc-47be-a089-9bd57e78ffac
@Override public void run() { LOGGER.info("Sleeper must awaken"); DefaultMutableTreeNode child1 = dynamicTreePanel.addObject(null, "child1 - remove by dynamicTreePanel", true); DefaultMutableTreeNode child2 = dynamicTreePanel.addObject(null, "child2 - remove from Parent Node", true); try { Thread.sleep(DELA...
be5f20f6-c804-4d4a-9f25-892c7dadea82
public FieldService() { this.raceTrack = new HashMap<Integer, Field>(); for (int i = 1; i <= 7; i++) { raceTrack.put(i, new Field(i)); } this.initRaceTrack(); }
ec0e1b31-1690-4b90-b0e1-6766edbdbf15
private void initRaceTrack() { this.initStart(); this.initFinish(); this.initEmptyFields(); this.initOilFields(); this.initCars(); }
0a9e41ea-3ac8-43aa-9028-cc14a0263b8b
private void initStart() { this.raceTrack.get(1).setStart(true); this.raceTrack.get(1).setBaseDescription( "Feld " + 1 + ": Start"); this.raceTrack.get(1).setImgPath("img/start_road.png"); this.raceTrack.get(1).setDescription("Feld " + 1 + ": Start"); }
0a31fa2e-f778-42bf-b626-42df38772e4a
private void initFinish() { this.raceTrack.get(7).setFinish(true); this.raceTrack.get(7).setBaseDescription( "Feld " + 7 + ": Zielfeld"); this.raceTrack.get(7).setImgPath("img/finish_road.png"); this.raceTrack.get(7).setDescription("Feld " + 7 + ": Zielfeld"); }
22b14844-931e-4f59-b47e-ab8f5cf17296
private void initEmptyFields() { this.raceTrack.get(2).setImgPath("img/empty_road.png"); this.raceTrack.get(2).setBaseDescription( "Feld " + 2 + ": Leere Strasse"); this.raceTrack.get(2).setDescription("Feld " + 2 + ": Leere Strasse"); this.raceTrack.get(4).setImgPath("...
023be501-0606-4d78-9fe1-307111923f07
private void initOilFields() { this.raceTrack.get(3).setOil(true); this.raceTrack.get(3).setImgPath("img/oil_road.png"); this.raceTrack.get(3).setBaseDescription( "Feld " + 3 + ": Oelfeld"); this.raceTrack.get(3).setDescription("Feld " + 3 + ": Oelfeld"); this.r...
109709fe-45a6-4716-8e74-9039a9c729bf
private void initCars() { this.player = new Car(1, 1); this.computer = new Car(1, 2); this.getStartField().setPlayerIdLeft(1); this.getStartField().setPlayerIdRight(2); }
3ec71485-52bd-411b-8a25-24437681605f
public boolean moveCar(int playerId, int distance) { if (playerId == 1) { //player moving int current = player.getFieldId(); int next = current + distance; Field currentField = this.raceTrack.get(current); Field nextField; if (next >= 7) { ...
e477df1e-92ac-4836-bc1e-b7c280579e84
public int getLeader() { int playerField = this.player.getFieldId(); int computerField = this.computer.getFieldId(); if (playerField > computerField) { return this.player.getUserId(); } else if (playerField < computerField) { return this.computer.getUserI...
ff84fdc8-bdbf-4692-83de-f4663a927fd8
public HashMap<Integer, Field> getRaceTrack() { return raceTrack; }
c67859b4-3193-43d7-aeea-3b5e0ad15e85
public void setRaceTrack(HashMap<Integer, Field> raceTrack) { this.raceTrack = raceTrack; }
d6038c6f-761d-460f-8bd9-50de5d83f2fc
public Car getPlayer() { return player; }
6649f26b-4f56-47cc-84ad-6f35814a8782
public void setPlayer(Car player) { this.player = player; }
710d17e2-bb16-432f-b8d1-b53180ae478a
public Car getComputer() { return computer; }
cca2d7d8-0d2e-4ebf-96fe-10e05e8eee8b
public void setComputer(Car computer) { this.computer = computer; }
2534772c-1807-44a3-8d30-741d58d80abd
public Field getStartField() { return this.raceTrack.get(1); }
2d569e8e-0db6-4a06-b467-a7fc030e4e52
public Field getFinishField() { return this.raceTrack.get(7); }
4a9d5215-6849-4e87-a1e7-8a84c964cb75
public TimerService() { }
55a38fbf-fecf-40fb-9001-99e1d450d777
public void startTimer() { this.startTime = new Date(); }
0a6848de-9b04-4fda-81ad-754f9465968b
private void updateDuration() { if (this.startTime != null) { this.duration = new Date().getTime() - this.startTime.getTime(); } }
0cc0a3bc-821b-4caf-b4d1-db34f0ff54f5
@Override public String toString() { if (this.startTime != null) { this.updateDuration(); long min = this.duration / 60000; long sec = (this.duration / 1000) % 60; return String.format("%s min, %s sec"); } return (this.duration / 60000) + " : " + ((this.duration / 1000) % 60); }
3f40cc58-f637-476c-a435-afa025b8c970
public long getDuration() { if (this.startTime != null) { this.updateDuration(); return duration / 1000; } return 0; }
ee55689b-e833-43f3-8725-7be68f143838
public void setDuration(long duration) { this.duration = duration; }
f0d47aa2-7936-494f-ac8d-704c89922631
public Date getStartTime() { return startTime; }
08dd591d-56ec-4e14-a7e5-4da504a34728
public void setStartTime(Date startTime) { this.startTime = startTime; }
825202ec-c1f5-434d-bd4d-b9c39fe0280b
public GameService() { }
a1c798c0-e296-4a93-8639-5733a790651c
public boolean init(ArrayList<User> users) { if (initialized) { return false; } this.users = users; this.playerCount = users.size(); this.time = new TimerService(); this.startGame(); this.setInitialized(true); return true; }
9b4a4825-00a0-4177-b1bc-8cedaaf05ca5
public void startGame() { this.time.startTimer(); this.setCurrentPlayer(this.users.get(0).getName()); }
52e62340-fd12-4722-a850-23ef939d5513
public void rollPlayerDice() { this.getDiceService().rollPlayerDice(); this.setPlayersTurn(!this.playersTurn); this.round++; if (this.getFieldService().moveCar(1, this.getDiceService().getPlayerDice().getRoll())) { // winner this.gameOv...
b094ed8f-2baf-421b-bc9b-64fb77bd360d
public void rollComputerDice() { this.getDiceService().rollComputerDice(); this.setPlayersTurn(true); if (this.getFieldService().moveCar(2, this.getDiceService().getComputerDice().getRoll())) { // winner this.gameOver = true; } if (this.fieldSer...
bc1f8303-1555-44e7-a896-e21a737e377e
public boolean isInitialized() { return initialized; }
65b614c5-935e-4fa4-8a36-62ef4a7b0254
public void setInitialized(boolean initialized) { this.initialized = initialized; }
dafad98d-3147-4b4f-9665-c5b135559e76
public boolean isPlayersTurn() { return playersTurn; }
9126a7bf-f3ba-49f0-bdc4-221ef05658b1
public void setPlayersTurn(boolean playersTurn) { this.playersTurn = playersTurn; }
b5925222-acf4-44e0-8a08-b6eaf8b2866e
public boolean isGameOver() { return gameOver; }
f404cbb5-682e-4366-88b8-3631db9b0b5b
public void setGameOver(boolean gameOver) { this.gameOver = gameOver; }
69c91167-1c90-4afd-a305-dc1daa0da1dc
public DiceService getDiceService() { if (this.diceService == null) { this.diceService = new DiceService(); } return diceService; }
dce0e52d-2ce7-4d5a-8502-5a3f671d7fba
public void setDiceService(DiceService diceService) { this.diceService = diceService; }
9c5d203b-0c9f-46be-bff6-24cc5db4c41b
public int getPlayerCount() { return playerCount; }
5dfcfc45-d00b-4480-a14b-00736c8704b3
public void setPlayerCount(int playerCount) { this.playerCount = playerCount; }
889c1083-84ee-429a-b471-567811719c66
public User getLeader() { return leader; }
44e6bb7f-32a9-4744-9eb3-5dd0d45a2317
public void setLeader(User leader) { this.leader = leader; }
db82a9ae-0b21-40ad-9d77-cfdba41f6262
public int getRound() { return round; }
9ec2d7ba-b5ea-42ef-8bf1-f997203ced76
public void setRound(int round) { this.round = round; }
68aadcf3-f8bb-4383-a32c-988b27af0680
public TimerService getTime() { if (this.time == null) { this.time = new TimerService(); } return time; }
75e69c2e-4ac0-40d1-a8bf-38af9eecc5e7
public void setTime(TimerService time) { this.time = time; }
bfac5232-41c8-4338-825a-cfb00a6bba2d
public String getCurrentPlayer() { return currentPlayer; }
9deead0a-8166-4ebd-84d4-3009df9106ef
public void setCurrentPlayer(String currentPlayer) { this.currentPlayer = currentPlayer; }
48533d0a-7d31-47cd-b692-f09845b4ac24
public ArrayList<User> getUsers() { return users; }
ee90619b-37ab-484a-b367-d36dd96c68e6
public void setUsers(ArrayList<User> users) { this.users = users; }
a915b021-5d5f-4bbc-b837-86700ecd4992
public FieldService getFieldService() { return fieldService; }
f3fbe94b-a591-43ac-b351-b43cddd57efe
public void setFieldService(FieldService fieldService) { this.fieldService = fieldService; }
8946ca15-e07b-4db8-89cd-9c9e74c7a186
public DiceService() { this.playerDice = new Dice(); this.computerDice = new Dice(); }
10e7eb7b-4283-476d-a74f-05dfbd58a916
public void rollPlayerDice() { this.getPlayerDice().rollDice(); }
92bf3e1f-440c-4219-bb13-78b97cb51103
public void rollComputerDice() { this.getComputerDice().rollDice(); }
669c6584-c625-48e7-93c7-cfd0ab2e9433
public Dice getPlayerDice() { return playerDice; }
334fccd2-3bc6-4633-83c3-35eaaf6df246
public void setPlayerDice(Dice playerDice) { this.playerDice = playerDice; }
db7a9304-b45c-4cd5-8044-c22094856070
public Dice getComputerDice() { return computerDice; }
b7cc4a77-7a3f-4159-b08d-71929dbcbad1
public void setComputerDice(Dice computerDice) { this.computerDice = computerDice; }
67c55cd4-eebe-4e65-b3b1-13a9aeff2889
public Dice() { this.imgPath.put(0, "img/wuerfel0.png"); this.imgPath.put(1, "img/wuerfel1.png"); this.imgPath.put(2, "img/wuerfel2.png"); this.imgPath.put(3, "img/wuerfel3.png"); }
acce392c-9688-4761-9cb2-b8ae9c3a1765
public void rollDice() { this.setRoll(new Random().nextInt(3) + 1); }
85c09d5b-6cc4-41ff-89ca-917067dffa16
public int getRoll() { return roll; }
8a709d87-f49d-4384-84de-af4b78fd63ca
public void setRoll(int roll) { this.setLastRoll(this.roll); this.roll = roll; }
34d24787-f04d-45ce-b5ab-674a402abb19
public int getLastRoll() { return lastRoll; }
be68750a-b894-41df-ab42-2e25d3e99482
public void setLastRoll(int lastRoll) { this.lastRoll = lastRoll; }
4877a153-a422-403b-99d8-266dd6232150
public String getImgPath() { return imgPath.get(this.roll); }
ff4e6c11-cce2-48fe-bfba-76df3a3d8a61
public Field(int fieldId) { this.fieldId = fieldId; this.start = false; this.finish = false; this.oil = false; this.playerIdLeft = 0; this.playerIdRight = 0; this.imgPath = "img/empty_road.png"; this.description = "Feld " + this.fieldId; this.baseD...
d55dbf33-a212-4169-b180-f8705e657497
public Field(int fieldId, boolean start, boolean finish, boolean oil, int playerIdLeft, int playerIdRight, String imgPath, String description, String baseDescription, User user) { this.fieldId = fieldId; this.start = start; this.finish = finish; this.oil = oil; this.p...
f6c75d7a-3cab-4645-b450-71de72db4642
public int getFieldId() { return fieldId; }
77831cd2-c275-4422-adbc-3cacdea2e08d
public void setFieldId(int fieldId) { this.fieldId = fieldId; }
11c19c52-c74c-4de3-af49-5eb949860039
public int getPlayerIdLeft() { return playerIdLeft; }
34ae72a4-8b6d-4e2f-a3cc-419bd1eecaa3
public void setPlayerIdLeft(int playerIdLeft) { this.playerIdLeft = playerIdLeft; }
22f1b3a7-7728-4a02-a2f1-1ad8b0e32650
public int getPlayerIdRight() { return playerIdRight; }
128e3b49-558e-4b6d-9996-009654364264
public void setPlayerIdRight(int playerIdRight) { this.playerIdRight = playerIdRight; }
fc7657c0-d030-4913-9732-57739291ddf6
public boolean isStart() { return start; }
4e9f9f94-828d-45e4-9459-20b0cfeb6e4c
public void setStart(boolean start) { this.start = start; }
02b0946c-cc33-4c5e-bdb9-963956f797f5
public boolean isFinish() { return finish; }
2393088b-7a59-48f3-9409-5c808c6b2302
public void setFinish(boolean finish) { this.finish = finish; }
86d5fd0c-9e79-4555-a73d-5d374961fc68
public boolean isOil() { return oil; }
2bd36baf-d408-4fba-a22a-040d6df993f6
public void setOil(boolean oil) { this.oil = oil; }
6fcbb618-8821-422a-b513-57b8e9aac5e5
public String getImgPath() { return imgPath; }
6a92da7c-2a37-44c6-988b-db209747b336
public void setImgPath(String imgPath) { this.imgPath = imgPath; }
228e06ff-f345-4b49-aa95-f1eca9111479
public String getDescription() { return description; }
748e5ad9-f592-4a92-ad9a-7061c5b39ddd
public void setDescription(String description) { this.description = description; }
8d2ba1a2-92ab-411b-914a-cce6c4ae9f15
public String getBaseDescription() { return baseDescription; }
2df0f009-daf9-4495-b2c6-d2048fc0931b
public void setBaseDescription(String baseDescription) { this.baseDescription = baseDescription; }
9b48a521-d5c8-4373-a514-7c75f29c723c
public User getUser() { return user; }
d714d2aa-9462-4987-bdb4-31f502a4be6a
public void setUser(User user) { this.user = user; }
0630e35a-2995-47f5-850b-208472ea374e
public int getId() { return id; }
f0f4d003-a189-493e-b5ba-db0b9c3d48dc
public void setId(int id) { this.id = id; }
ae62d644-9069-416b-935b-5bd7afc9a438
public String getName() { return name; }
4e1ad864-a326-487e-9e4b-73dc57119b11
public void setName(String name) { this.name = name; }
7e219244-9b63-4cd6-bc70-70df7baa7833
public Car(int fieldId, int userId) { this.fieldId = fieldId; this.userId = userId; }