Package org.iremake.common.model

Examples of org.iremake.common.model.Nation


                boolean adjusting = e.getValueIsAdjusting();
                if (!adjusting) {
                    XList<Nation> model = (XList<Nation>) nationsList.getModel();
                    int row = nationsList.getSelectedIndex();
                    if (row != -1) {
                        Nation nation = model.getElementAt(row);
                        XList<Province> provinces = nation.getProvinces();
                        // TODO tell the province panel all about it
                        provinceList.setModel(provinces);
                    }
                }
            }
        });

        // set button actions
        addnationButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String name = FrameManager.getInstance().showInputDialog("Enter new Nation's name:");
                if (name != null) {
                    // TODO test if already existing
                    XList<Nation> model = (XList<Nation>) nationsList.getModel();
                    Nation nation = new Nation();
                    nation.setProperty(Nation.KEY_NAME, name);
                    model.addElement(nation);
                }
            }
        });
        removenationButton.addActionListener(new ActionListener() {
View Full Code Here


        ServerScenario scenario = new ServerScenario();
        scenario.createEmptyMap(60, 100);
        scenario.setTitle("Test Scenario");

        // add a nation and a province
        Nation nation = new Nation();
        nation.setProperty(Nation.KEY_NAME, "Test Nation");
        scenario.getNations().addElement(nation);

        Province province = new Province(1, "Test province");
        nation.addProvince(province);

        nation.setProperty(Nation.KEY_CAPITAL, String.valueOf(province.getID()));

        IOManager.saveToXML(Places.None, "test-scenario.xml", scenario);
    }
View Full Code Here

        for (Integer i : uc) {
            String name = String.format("Nation %2d", id);
            if (id <= nationNames.length) {
                name = nationNames[id-1];
            }
            Nation nation = new Nation();
            nation.setProperty(Nation.KEY_NAME, name);
            if (id <= nationColors.length) {
                nation.setProperty(Nation.KEY_COLOR, nationColors[id-1]);
            }
            nmap.put(i, nation);
            nations.addElement(nation);
            id++;
        }

        // detect provinces
        Set<Integer> up = new HashSet<>(1_000);
        for (int i = 0; i < chunk; i++) {
            if (terrain_underlay[i] != 5) {
                up.add(provinces[i]);
            }
        }
        updateStatus(String.format("contains %d provinces", up.size()));

        // generate province names
        Map<Integer, String> pmap = new HashMap<>(Np);
        id = 1;
        for (Integer i : up) {
            // String name = String.format("Province %d", id);
            String name = pnames[i];
            pmap.put(i, name);
            id++;
        }

        // add provinces to scenario
        Map<Integer, Province> ppmap = new HashMap<>(1_000);
        Set<Integer> processed = new HashSet<>(1_000);
        for (int i = 0; i < chunk; i++) {
            if (terrain_underlay[i] != 5) {
                if (!processed.contains(provinces[i])) {
                    Nation nation = nmap.get(countries[i]);
                    String name = pmap.get(provinces[i]);
                    Province province = scenario.createProvince(name);
                    nation.addProvince(province);
                    ppmap.put(provinces[i], province);
                    processed.add(provinces[i]);
                }
            }
        }
View Full Code Here

                buffer = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
                for (int x = 0; x < size.width; x++) {
                    for (int y = 0; y < size.height; y++) {
                        int column = scenario.getNumberColumns() * x / size.width; // rounding down
                        int row = scenario.getNumberRows() * y / size.height;
                        Nation nation = scenario.getNationAt(new MapPosition(row, column));
                        if (nation != null) {
                            Color color = nation.getColor();
                            buffer.setRGB(x, y, color.getRGB());
                        } else {
                            // TODO ocean color?
                            buffer.setRGB(x, y, scenario.getTileGraphicsRepository().getTerrainTileColor(Settings.getDefaultTerrainID()).getRGB());
                        }
View Full Code Here

        colors = new int[numNations];

        // traverse nations by index and store names as well as index for each nation
        Map<Nation, Integer> nationIDs = new HashMap<>(numNations);
        for (int i = 0; i < numNations; i++) {
            Nation nation = nations.getElementAt(i);
            nationIDs.put(nation, i);
            names[i] = nation.getProperty(Nation.KEY_NAME);
            colors[i] = nation.getColor().getRGB();
        }

        // traverse map and store index for each nation or Max value if ther eis no nation (sea)
        for (int row = 0; row < rows; row++) {
            for (int column = 0; column < columns; column++) {
                Nation nation = scenario.getNationAt(new MapPosition(row, column));
                if (nation != null) {
                    // put the nations ID
                    politicalMap[row][column] = nationIDs.get(nation);
                } else {
                    // it's sea
View Full Code Here

TOP

Related Classes of org.iremake.common.model.Nation

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.