Package trams.data

Examples of trams.data.RouteSchedule


            return allVehicleDisplayPanel;
        }
        //Otherwise add a label with the route schedule number for each potential vehicle.
        for ( int i = 0; i < theInterface.getNumCurrentDisplaySchedules(); i++ ) {
            //Get the schedule id and vehicle position.
            RouteSchedule rs = theInterface.getDisplaySchedule(theRouteList.getSelectedValue().toString().split(":")[0], i);
            String schedId = rs.toString();
            String[] vehiclePos =  rs.getCurrentStop(theSimulator.getCurrentSimTime(), theSimulator);
            String thisVehiclePos = vehiclePos[0];
            long timeSecs = Long.parseLong(vehiclePos[1]);
            logger.debug(schedId + " is at " + thisVehiclePos + " in " + timeSecs + " seconds with delay " + rs.getDelay() + " minutes.");
            /*if ( rs.hasDelay() ) {
                theInterface.addMessage(theSimulator.getMessageDisplaySimTime() + ": Vehicle " + schedId + " is running " + rs.getDelay() + " minutes late.");
            }*/
            //Get direction first of all we are travelling in!
            LinkedList<String> outwardStops = new LinkedList<String>();
            for ( int j = 0; j < theStopPanels.size(); j++ ) {
                outwardStops.add(((JLabel) theStopPanels.get(j).getComponent(0)).getText());
            }
            int direction = DrawingPanel.RIGHTTOLEFT;
            if ( rs.getCurrentService(theSimulator.getCurrentSimTime()) == null ) {
                continue; //Don't print if the vehicle is at a terminus.
            }
            if ( rs.getCurrentService(theSimulator.getCurrentSimTime()).isOutwardService(outwardStops) ) {
                direction = DrawingPanel.LEFTTORIGHT;
            }
            //Now we want to find the position where we draw the triangle i.e. position of JLabel.
            int xPos = 0;
            String previousStop = "N/A";
            for ( int j = 0; j < theStopPanels.size(); j++ ) {
                //Each stopPanel has one component which is JLabel.
                JLabel myLabel = (JLabel) theStopPanels.get(j).getComponent(0);
                //Now check where this stop is and get its position.
                //logger.debug("Comparing " + myLabel.getText() + " against " + thisVehiclePos);
                if ( myLabel.getText().equalsIgnoreCase(thisVehiclePos) ) {
                    int panelSize = 800 / theStopPanels.size();
                    int startPos = 0 + ( panelSize * j);
                    int endPos = (panelSize * (j+1))-1;
                    if ( j == (theStopPanels.size()-1) ) {
                        endPos = (panelSize * (j+1))-(panelSize/2);
                    }
                    //Debug.
                    logger.debug("This is stop " + myLabel.getText() + " - range is from " + startPos + " to " + endPos);
                    //xPos = startPos + (panelSize/2 - (panelSize/4));
                    if ( previousStop.equalsIgnoreCase("N/A") ) {
                        xPos = startPos;
                    } else {
                        long maxTimeDiff = Math.abs(rs.getCurrentService(theSimulator.getCurrentSimTime()).getStopMaxTimeDiff(previousStop, myLabel.getText()));
                        if ( maxTimeDiff == Integer.MAX_VALUE ) {
                            xPos = startPos;
                        }
                        double percent = (double)timeSecs/(double)maxTimeDiff;
                        logger.debug("Percentage is " + percent + "% for positioning! - timeSecs = " + timeSecs + " and maxTimeDiff = " + maxTimeDiff);
                        //If inward, then low percentage means close, high means far away.
                        if ( direction == DrawingPanel.RIGHTTOLEFT ) {
                            xPos = (int) Math.round((percent * (endPos - startPos))) + startPos;
                            logger.debug("Recommeding xPos of " + xPos);
                        } else {
                            double invertPercent = 1 - percent;
                            xPos = (int) Math.round((invertPercent * (endPos - startPos))) + startPos;
                            logger.debug("Recommeding xPos of " + xPos);
                        }
                        //xPos = startPos + (panelSize/2 - (panelSize/4));
                    }
                } else {
                    previousStop = myLabel.getText();
                }
            }
            logger.debug("I'm drawing route schedule " + rs.toString());
            JPanel drawPanel = new DrawingPanel(xPos, direction, rs.hasDelay() );
            drawPanel.addMouseListener(new BusMouseListener(theInterface.getDisplaySchedule(theRouteList.getSelectedValue().toString().split(":")[0], i), theInterface));
            vehiclePanel.add(drawPanel);
            allVehicleDisplayPanel.add(vehiclePanel, BorderLayout.CENTER);
            allVehicleDisplayPanel.add(makeVehicleInfoPanel(), BorderLayout.SOUTH);
            /*JPanel busPanel = new JPanel();
View Full Code Here


        logger.debug("Number of possible display schedules: " +  theOperations.getSimulator().getScenario().getRoute(routeNumber).getNumRouteSchedules());
        if ( theOperations.getSimulator().getScenario().getRoute(routeNumber).getNumRouteSchedules() < max ) { max = theOperations.getSimulator().getScenario().getRoute(routeNumber).getNumRouteSchedules(); }
        //logger.debug("Max vehicles starts at " + max + " - routeDetails size is " + routeDetails.size());
        logger.debug("Min is " + min + " & Max is " + max);
        if ( min == max ) {
            RouteSchedule rs = theOperations.getSimulator().getScenario().getRoute(routeNumber).getRouteSchedule(min);
            logger.debug("Getting route schedule " + rs.toString() + " from loop being equal!");
            if ( theOperations.getSimulator().getScenario().getRoute(routeNumber).getAssignedVehicle(rs.toString()) == null ) {
                logger.debug("A schedule was null");
            }
            if ( rs.getCurrentStop(currentTime, theOperations.getSimulator())[0].equalsIgnoreCase("Depot") ) {
                logger.debug("Vehicle in depot!");
            }
            if ( theOperations.getSimulator().getScenario().getRoute(routeNumber).getAssignedVehicle(rs.toString()) != null && !rs.getCurrentStop(currentTime, theOperations.getSimulator())[0].equalsIgnoreCase("Depot") ) {
                //logger.debug("Adding Route Detail " + routeDetails.get(i).getId());
                theRouteDetailPos.add(0);
            } else {
                max++;
                //logger.debug("Max is now " + max + " - routeDetails size is: " + routeDetails.size());
                if ( theOperations.getSimulator().getScenario().getRoute(routeNumber).getNumRouteSchedules() < max ) { max = theOperations.getSimulator().getScenario().getRoute(routeNumber).getNumRouteSchedules(); }
                //logger.debug("Route Detail " + routeDetails.get(i).getId() + " was null - maxVehicles is now " + max);
            }
        }
        for ( int i = min; i < max; i++ ) { //Changed from i = 0; i < routeDetails.size().
            RouteSchedule rs = theOperations.getSimulator().getScenario().getRoute(routeNumber).getRouteSchedule(i);
            logger.debug("Getting route schedule " + rs.toString() + " from for loop!");
            if ( theOperations.getSimulator().getScenario().getRoute(routeNumber).getAssignedVehicle(rs.toString()) == null ) {
                logger.debug("A schedule was null");
            }
            if ( rs.getCurrentStop(currentTime, theOperations.getSimulator())[0].equalsIgnoreCase("Depot") ) {
                logger.debug("Vehicle in depot!");
            }
            if ( theOperations.getSimulator().getScenario().getRoute(routeNumber).getAssignedVehicle(rs.toString()) != null && !rs.getCurrentStop(currentTime, theOperations.getSimulator())[0].equalsIgnoreCase("Depot") ) {
                //logger.debug("Adding Route Detail " + routeDetails.get(i).getId());
                theRouteDetailPos.add(i);
            } else {
                max++;
                //logger.debug("Max is now " + max + " - routeDetails size is: " + routeDetails.size());
View Full Code Here

        Service theService = new Service();
        theService.addStop(new Stop("Rathaus Pankow", Calendar.getInstance()));
        theService.addStop(new Stop("Pankow Kirche", Calendar.getInstance()));
        theService.addStop(new Stop("S + U Pankow", Calendar.getInstance()));
        RouteSchedule theRouteSchedule = new RouteSchedule();
        theRouteSchedule.addService(theService);
        theRouteSchedule.setRouteNumber(routeNumber);
        theRouteSchedule.setScheduleNumber(scheduleNumber);
        theRouteSchedule.setDelayInMins(delayInMins);
        return theRouteSchedule;
        //session.save(theRouteSchedule);

        //session.getTransaction().commit();
    }
View Full Code Here

        Service theService = new Service();
        theService.addStop(new Stop("Rathaus Pankow", Calendar.getInstance()));
        theService.addStop(new Stop("Pankow Kirche", Calendar.getInstance()));
        theService.addStop(new Stop("S + U Pankow", Calendar.getInstance()));
        RouteSchedule theRouteSchedule = new RouteSchedule();
        theRouteSchedule.addService(theService);
        theRouteSchedule.setRouteNumber("2A");
        theRouteSchedule.setScheduleNumber(1);
        theRouteSchedule.setDelayInMins(5);
        //session.save(theRouteSchedule);
       
        Vehicle theVehicle = new Vehicle();
        theVehicle.setRegistrationNumber(registrationNumber);
        theVehicle.setAssignedSchedule(theRouteSchedule);
View Full Code Here

TOP

Related Classes of trams.data.RouteSchedule

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.