forked from Bram-Hub/LEGUP
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Started Exported and added to ThermometerBoard access to row and col …
…values
- Loading branch information
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/main/java/edu/rpi/legup/puzzle/thermometer/ThermometerExporter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package edu.rpi.legup.puzzle.thermometer; | ||
|
||
import java.util.ArrayList; | ||
|
||
import edu.rpi.legup.model.PuzzleExporter; | ||
import org.w3c.dom.Document; | ||
import edu.rpi.legup.puzzle.thermometer.elements.Vial; | ||
|
||
public class ThermometerExporter extends PuzzleExporter { | ||
|
||
public ThermometerExporter(Thermometer thermometer) { | ||
super(thermometer); | ||
} | ||
|
||
@Override | ||
protected org.w3c.dom.Element createBoardElement(Document newDocument) { | ||
ThermometerBoard board = (ThermometerBoard) puzzle.getTree().getRootNode().getBoard(); | ||
|
||
// Creating the XML section for the board | ||
org.w3c.dom.Element boardElement = newDocument.createElement("board"); | ||
boardElement.setAttribute("width", String.valueOf(board.getWidth())); | ||
boardElement.setAttribute("height", String.valueOf(board.getHeight())); | ||
|
||
// Creating the XML section for the vials and appending to the board | ||
org.w3c.dom.Element vialsElement = newDocument.createElement("vials"); | ||
ArrayList<Vial> vials = board.getVials(); | ||
for (Vial vial : vials) { | ||
org.w3c.dom.Element vialElement = newDocument.createElement("vial"); | ||
// Temp for now, waiting on final implementation of vial | ||
// vialElement.setAttribute("headx", vial.getHeadX()); | ||
// vialElement.setAttribute("heady", vial.getHeadY()); | ||
// vialElement.setAttribute("tailx", vial.getTailX()); | ||
// vialElement.setAttribute("taily", vial.getTailY()); | ||
vialsElement.appendChild(vialElement); | ||
} | ||
boardElement.appendChild(vialsElement); | ||
|
||
// Creating the XML section for the row numbers and appending to the board | ||
org.w3c.dom.Element rowNumbersElement = newDocument.createElement("rowNumbers"); | ||
ArrayList<Integer> rowNumbers = board.getRowNumbers(); | ||
for (int number : rowNumbers) { | ||
org.w3c.dom.Element rowNumberElement = newDocument.createElement("row"); | ||
rowNumberElement.setAttribute("value", String.valueOf(number)); | ||
rowNumbersElement.appendChild(rowNumberElement); | ||
} | ||
boardElement.appendChild(rowNumbersElement); | ||
|
||
// Creating the XML section for the col numbers and appending ot the board | ||
org.w3c.dom.Element colNumbersElement = newDocument.createElement("colNumbers"); | ||
ArrayList<Integer> colNumbers = board.getColNumbers(); | ||
for (int number : colNumbers) { | ||
org.w3c.dom.Element colNumberElement = newDocument.createElement("col"); | ||
colNumberElement.setAttribute("value", String.valueOf(number)); | ||
colNumbersElement.appendChild(colNumberElement); | ||
} | ||
boardElement.appendChild(colNumbersElement); | ||
|
||
return boardElement; | ||
} | ||
} |