| 1 | package tmcsim.client.cadscreens; |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | import javax.swing.text.Document; |
|---|
| 5 | |
|---|
| 6 | import tmcsim.cadmodels.CADRoutedMessage; |
|---|
| 7 | import tmcsim.cadmodels.RoutedMessageModel; |
|---|
| 8 | import tmcsim.client.cadscreens.view.CADMainView; |
|---|
| 9 | import tmcsim.common.CADEnums.TEXT_STYLES; |
|---|
| 10 | |
|---|
| 11 | /** |
|---|
| 12 | * TO_RoutedMessage is the view component to the RoutedMessageModel |
|---|
| 13 | * model object. The screen is shown when the user views a queued message. |
|---|
| 14 | * When the class is instantiated with reference to the model data and |
|---|
| 15 | * document, string and style pairs are added to the view document. |
|---|
| 16 | * This class extends from the CADMainView object, which |
|---|
| 17 | * contains the common methods and data needed for display and user |
|---|
| 18 | * interaction. |
|---|
| 19 | * |
|---|
| 20 | * @see RoutedMessageModel |
|---|
| 21 | * @author Matthew Cechini |
|---|
| 22 | * @version $Revision: 1.4 $ $Date: 2009/04/17 16:27:45 $ |
|---|
| 23 | */ |
|---|
| 24 | public class TO_RoutedMessage extends CADMainView { |
|---|
| 25 | |
|---|
| 26 | /** Instance of the model, containing the message data for this view class. */ |
|---|
| 27 | private RoutedMessageModel theModel; |
|---|
| 28 | |
|---|
| 29 | /** |
|---|
| 30 | * Constructor. Initializes the screen with the appropriate formatted text. |
|---|
| 31 | * |
|---|
| 32 | * @param newModel The model data object. |
|---|
| 33 | * @param viewdoc The Document object used for displaying the model data. |
|---|
| 34 | */ |
|---|
| 35 | public TO_RoutedMessage(RoutedMessageModel newModel, Document viewDoc) { |
|---|
| 36 | super(viewDoc); |
|---|
| 37 | |
|---|
| 38 | theModel = newModel; |
|---|
| 39 | |
|---|
| 40 | initialize(); |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | |
|---|
| 44 | /** |
|---|
| 45 | * This method initializes the screen's Document object with |
|---|
| 46 | * text and style pairs to create the correct screen format. |
|---|
| 47 | */ |
|---|
| 48 | private void initialize() { |
|---|
| 49 | |
|---|
| 50 | CADRoutedMessage displayMessage = theModel.getCurrentMessage(); |
|---|
| 51 | |
|---|
| 52 | addDocElement("FROM POS " + displayMessage.fromPosition |
|---|
| 53 | + " MESSAGE " + "TO POS " |
|---|
| 54 | + displayMessage.toPosition + "\n", TEXT_STYLES.CYAN); |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | addDocElement(displayMessage.message + "\n", |
|---|
| 58 | TEXT_STYLES.CYAN); |
|---|
| 59 | |
|---|
| 60 | } |
|---|
| 61 | } |
|---|