Package trams.data

Examples of trams.data.ServicePattern


        });
        servicePatternButtonPanel.add(theCreateServicePatternButton);
        theModifyServicePatternButton = new JButton("Modify");
        theModifyServicePatternButton.addActionListener( new ActionListener() {
            public void actionPerformed ( ActionEvent e ) {
                ServicePattern sp = theSelectedRoute.getTimetable(theTimetableNameField.getText()).getServicePattern(theServicePatternList.getSelectedValue().toString());
                //Process the stops.
                ArrayList<String> stops = new ArrayList<String>();
                for ( int i = 0; i < theStopModel.getSize(); i++ ) {
                  stops.add(theStopModel.get(i).toString());
                }
View Full Code Here


                //Create + add service pattern.
                if ( theSelectedServicePattern != null ) {
                    theSelectedRoute.getTimetable(theSelectedTimetableName).getServicePattern(theSelectedServicePattern.getName()).editServicePattern(theServicePatternNameField.getText(), operatingDays, theTerminus1Box.getSelectedItem().toString(), theTerminus2Box.getSelectedItem().toString(), timeFrom, timeTo, Integer.parseInt(theEveryMinuteSpinner.getValue().toString()), getCurrentRouteDuration(Integer.parseInt(theEveryMinuteSpinner.getValue().toString())));
                } else {
                    logger.debug("I am calling add method with timetable name " + theSelectedTimetableName + "!");
                    ServicePattern sp = new ServicePattern(theServicePatternNameField.getText(), operatingDays, theTerminus1Box.getSelectedItem().toString(), theTerminus2Box.getSelectedItem().toString(), timeFrom, timeTo, Integer.parseInt(theEveryMinuteSpinner.getValue().toString()), getCurrentRouteDuration(Integer.parseInt(theEveryMinuteSpinner.getValue().toString())) );
                    theSelectedRoute.getTimetable(theSelectedTimetableName).addServicePattern(theServicePatternNameField.getText(), sp);
                }
                //Now return to the timetable screen.
                theControlScreen.redrawManagement(ManagePanel.this.makeCreateTimetablePanel(theSelectedTimetableName));
            }
View Full Code Here

   
    private void createAndStoreServicePattern(String name, String daysOfOperation, String returnTerminus, String outgoingTerminus, Calendar startTime, Calendar endTime, int frequency, int routeDuration) {
        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();

        ServicePattern theServicePattern = new ServicePattern();
        theServicePattern.setName(name);
        theServicePattern.setDaysOfOperation(daysOfOperation);
        theServicePattern.setReturnTerminus(returnTerminus);
        theServicePattern.setOutgoingTerminus(outgoingTerminus);
        theServicePattern.setStartTime(startTime);
        theServicePattern.setEndTime(endTime);
        theServicePattern.setFrequency(frequency);
        theServicePattern.setRouteDuration(routeDuration);
        session.save(theServicePattern);

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

        theRoute.addStop("Rathaus Pankow", Route.RETURNSTOPS);
        List<RouteSchedule> theRouteSchedulesList = new ArrayList<RouteSchedule>();
        theRouteSchedulesList.add(createAndStoreRouteSchedule("155", 1, 0));
        theRoute.setRouteSchedules(theRouteSchedulesList);
        theRoute.addAllocation(theRouteSchedulesList.get(0).toString(), createAndStoreVehicle("CV58 2XD", Calendar.getInstance(), DEPRECIATION_FACTOR, "image.png", "Mercedes", 40, 60, 200.99));
        ServicePattern sp = new ServicePattern("Mon-Fri","2,3,4,5,6","Rathaus Pankow","S + U Pankow",Calendar.getInstance(),Calendar.getInstance(),FREQUENCY,3);
        theRoute.addTimetable("myTimetable", createAndStoreTimetable("myTimetable", Calendar.getInstance(), Calendar.getInstance(), sp));
       
        //session.save(theRoute);
        //session.getTransaction().commit();
        return theRoute;
View Full Code Here

                int vtDateNum = validToDate.get(Calendar.DATE); String vtDate = "" + vtDateNum; if ( vtDateNum < MAX_SINGLE_DIGIT ) { vtDate = "0" + vtDateNum; }
                timetable.setAttribute("validTo", validToDate.get(Calendar.YEAR) + "-" + vtMonth + "-" + vtDate );
                //Now for all service patterns.
                Iterator<String> servicePatternNames = myTimetable.getServicePatternNames().iterator();
                while ( servicePatternNames.hasNext() ) {
                    ServicePattern myServicePattern = myTimetable.getServicePattern(servicePatternNames.next());
                    //Create element with appropriate attributes.
                    Element servicePattern = doc.createElement("servicePattern");
                    servicePattern.setAttribute("name", myServicePattern.getName());
                    servicePattern.setAttribute("days", myServicePattern.getDaysOfOperation());
                    servicePattern.setAttribute("returnTerminus", myServicePattern.getReturnTerminus());
                    servicePattern.setAttribute("outgoingTerminus", myServicePattern.getOutgoingTerminus());
                    servicePattern.setAttribute("startTime", MyCalendarUtils.getTimeInfo(myServicePattern.getStartTime(), false));
                    servicePattern.setAttribute("endTime", MyCalendarUtils.getTimeInfo(myServicePattern.getEndTime(), false));
                    servicePattern.setAttribute("frequency", "" + myServicePattern.getFrequency());
                    servicePattern.setAttribute("duration", "" + myServicePattern.getDuration());
                    timetable.appendChild(servicePattern);
                }
                route.appendChild(timetable);
            }
            //Finally, add route to scenario.
View Full Code Here

                        String[] timeFrom = serviceElement.getAttribute("startTime").split(":");
                        Calendar startTime = new GregorianCalendar(2009,Calendar.AUGUST,5,Integer.parseInt(timeFrom[0]),Integer.parseInt(timeFrom[1]));
                        String[] timeTo = serviceElement.getAttribute("endTime").split(":");
                        Calendar endTime = new GregorianCalendar(2009,Calendar.AUGUST,5,Integer.parseInt(timeTo[0]),Integer.parseInt(timeTo[1]));
                        //Create service object.
                        ServicePattern myService = new ServicePattern(serviceElement.getAttribute("name"), daysOfOperation, serviceElement.getAttribute("returnTerminus"), serviceElement.getAttribute("outgoingTerminus"), startTime, endTime, Integer.parseInt(serviceElement.getAttribute("frequency")), Integer.parseInt(serviceElement.getAttribute("duration")));
                        //Add to timetable.
                        myTimetable.addServicePattern(serviceElement.getAttribute("name"), myService);
                    }
                    //Finally add this timetable to the route.
                    logger.debug("Adding " + myTimetable.getName() + " to " + route.getRouteNumber());
View Full Code Here

TOP

Related Classes of trams.data.ServicePattern

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.