Search in sources :

Example 6 with Block

use of trackmodel.model.Block in project on-track by michaelplazek.

the class CentralTrafficControlController method updateMaintenance.

private void updateMaintenance() {
    String line = maintenanceTracks.getSelectionModel().getSelectedItem();
    if (line.equals("Select track")) {
        statusLight.setFill(Paint.valueOf("Grey"));
        occupiedLight.setFill(Paint.valueOf("Grey"));
        maintenanceBlocks.setDisable(true);
        maintenanceActions.setDisable(true);
        submitMaintenance.setDisable(true);
    } else {
        maintenanceBlocks.setDisable(false);
        maintenanceActions.setDisable(false);
        submitMaintenance.setDisable(false);
        int blockId = extractBlock();
        Block block = Track.getListOfTracks().get(line).getBlock(blockId);
        if (block.isClosedForMaintenance()) {
            statusLight.setFill(Paint.valueOf("Red"));
        } else {
            statusLight.setFill(Paint.valueOf("#24c51b"));
        }
        if (block.isOccupied()) {
            occupiedLight.setFill(Paint.valueOf("#24c51b"));
        } else {
            occupiedLight.setFill(Paint.valueOf("Red"));
        }
        if (block.isSwitch()) {
            Switch sw = (Switch) block;
            if (sw.getSwitchState()) {
                stateOne.setOpacity(100);
                stateTwo.setOpacity(0);
                stateZero.setOpacity(0);
            } else {
                stateOne.setOpacity(0);
                stateTwo.setOpacity(100);
                stateZero.setOpacity(0);
            }
        } else {
            stateOne.setOpacity(0);
            stateTwo.setOpacity(0);
            stateZero.setOpacity(100);
        }
    }
}
Also used : Switch(trackmodel.model.Switch) Block(trackmodel.model.Block) Paint(javafx.scene.paint.Paint)

Example 7 with Block

use of trackmodel.model.Block in project on-track by michaelplazek.

the class Runner method sampleTrackMaker.

// TODO: replace this awful function with a real one
private void sampleTrackMaker() {
    Track test = new Track("blue");
    for (int i = 0; i < 20; i++) {
        if (i == 10 || i == 15) {
            Switch block = new Switch();
            block.setNumber(i);
            block.setSection("V");
            block.setLine("blue");
            test.addBlock(block);
        } else {
            Block block = new Block();
            block.setNumber(i);
            block.setSection("V");
            block.setLine("blue");
            test.addBlock(block);
        }
    }
    test.getBlock(10).setSwitchHere(true);
    test.getBlock(15).setSwitchHere(true);
    test.getBlock(11).setLeftStation(true);
    test.getBlock(11).setStationName("SOME STATION");
    test.getBlock(16).setRightStation(true);
    test.getBlock(16).setStationName("ANOTHER STATION");
    Track test2 = new Track("yellow");
    for (int i = 0; i < 20; i++) {
        if (i == 10 || i == 15) {
            Switch block = new Switch();
            block.setNumber(i);
            block.setSection("A");
            block.setLine("yellow");
            test2.addBlock(block);
        } else {
            Block block = new Block();
            block.setNumber(i);
            block.setSection("A");
            block.setLine("yellow");
            test2.addBlock(block);
        }
    }
    test2.getBlock(10).setSwitchHere(true);
    test2.getBlock(15).setSwitchHere(true);
    test2.getBlock(11).setLeftStation(true);
    test2.getBlock(11).setStationName("yellow station");
    test2.getBlock(16).setRightStation(true);
    test2.getBlock(16).setStationName("Another yellow station");
}
Also used : Switch(trackmodel.model.Switch) Block(trackmodel.model.Block) Track(trackmodel.model.Track)

Aggregations

Block (trackmodel.model.Block)7 Switch (trackmodel.model.Switch)3 Paint (javafx.scene.paint.Paint)2 Track (trackmodel.model.Track)2 ScheduleRow (ctc.model.ScheduleRow)1 TrainTracker (ctc.model.TrainTracker)1 BufferedReader (java.io.BufferedReader)1 FileNotFoundException (java.io.FileNotFoundException)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 RadioButton (javafx.scene.control.RadioButton)1 TableView (javafx.scene.control.TableView)1 Toggle (javafx.scene.control.Toggle)1 DefaultStringConverter (javafx.util.converter.DefaultStringConverter)1