Package org.optaplanner.examples.dinnerparty.domain

Examples of org.optaplanner.examples.dinnerparty.domain.Guest


        }

    }

    private ImageIcon determineGuestIcon(SeatDesignation seatDesignation) {
        Guest guest = seatDesignation.getGuest();
        if (guest == null) {
            return null;
        }
        List<ImageIcon> imageIconList = guest.getGender() == Gender.MALE ? maleImageIconList : femaleImageIconList;
        return imageIconList.get(guest.getId().intValue() % imageIconList.size());
    }
View Full Code Here


            setSeatDesignation(dummySeatDesignation);
        }

        public void setSeatDesignation(SeatDesignation seatDesignation) {
            removeAll();
            Guest guest = seatDesignation.getGuest();
            if (guest == null) {
                add(new JLabel("Empty seat"), BorderLayout.CENTER);
                return;
            }
            JButton button = new JButton(new SeatDesignationAction(seatDesignation));
            button.setMargin(new Insets(0, 0, 0, 0));
            Seat seat = seatDesignation.getSeat();
            if (seat != null) {
                button.setToolTipText("Guest " + guest.getCode()
                        + " @ " + "Seat " + seat.getSeatIndexInTable());
            }
            add(button, BorderLayout.WEST);
            JPanel infoPanel = new JPanel(new GridLayout(0, 1));
            infoPanel.setOpaque(false);
            infoPanel.add(new JLabel(guest.getName()));
            JPanel jobPanel = new JPanel();
            jobPanel.setLayout(new BoxLayout(jobPanel, BoxLayout.Y_AXIS));
            jobPanel.setOpaque(false);
            jobPanel.add(new JLabel(guest.getJob().getJobType().getCode()));
            JLabel jobLabel = new JLabel("  " + guest.getJob().getName());
            jobLabel.setFont(jobLabel.getFont().deriveFont(jobLabel.getFont().getSize() - 2.0F));
            jobPanel.add(jobLabel);
            infoPanel.add(jobPanel);
            add(infoPanel, BorderLayout.CENTER);
            JPanel hobbyPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
            hobbyPanel.setOpaque(false);
            hobbyPanel.setAlignmentX(CENTER_ALIGNMENT);
            for (HobbyPractician hobbyPractician : guest.getHobbyPracticianList()) {
                Hobby hobby = hobbyPractician.getHobby();
                JLabel hobbyLabel = new JLabel(hobbyImageIconMap.get(hobby));
                hobbyLabel.setToolTipText(hobby.getLabel());
                hobbyPanel.add(hobbyLabel);
            }
View Full Code Here

            List<HobbyPractician> hobbyPracticianList = new ArrayList<HobbyPractician>(guestSize * 3);
            Map<String, Job> jobMap = new HashMap<String, Job>(JobType.values().length * 5);
            int jobNextId = 0;
            int hobbyPracticianJobId = 0;
            for (int i = 0; i < guestSize; i++) {
                Guest guest = new Guest();
                guest.setId((long) i);
                String[] lineTokens = splitByCommaAndTrim(bufferedReader.readLine(), 6, null);
                guest.setCode(lineTokens[0]);
                guest.setName(lineTokens[1]);
                JobType jobType = JobType.valueOfCode(lineTokens[2]);
                String jobName = lineTokens[3];
                String jobMapKey = jobType + "/" + jobName;
                Job job = jobMap.get(jobMapKey);
                if (job == null) {
                    job = new Job();
                    job.setId((long) jobNextId);
                    jobNextId++;
                    job.setJobType(jobType);
                    job.setName(jobName);
                    jobMap.put(jobMapKey, job);
                }
                guest.setJob(job);
                guest.setGender(Gender.valueOfCode(lineTokens[4]));
                List<HobbyPractician> hobbyPracticianOfGuestList = new ArrayList<HobbyPractician>(lineTokens.length - 5);
                for (int j = 5; j < lineTokens.length; j++) {
                    HobbyPractician hobbyPractician = new HobbyPractician();
                    hobbyPractician.setId((long) hobbyPracticianJobId);
                    hobbyPracticianJobId++;
                    hobbyPractician.setGuest(guest);
                    hobbyPractician.setHobby(Hobby.valueOfCode(lineTokens[j]));
                    hobbyPracticianOfGuestList.add(hobbyPractician);
                    hobbyPracticianList.add(hobbyPractician);
                }
                guest.setHobbyPracticianList(hobbyPracticianOfGuestList);
                guestList.add(guest);
            }
            dinnerParty.setJobList(new ArrayList<Job>(jobMap.values()));
            dinnerParty.setGuestList(guestList);
            dinnerParty.setHobbyPracticianList(hobbyPracticianList);
View Full Code Here

TOP

Related Classes of org.optaplanner.examples.dinnerparty.domain.Guest

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.