Search in sources :

Example 36 with World

use of mudmap2.backend.World in project mudmap2 by Neop.

the class WorldPanelTest method testIsPassive.

/**
 * Test of isPassive method, of class WorldPanel.
 */
@Test
public void testIsPassive() {
    System.out.println("isPassive");
    WorldPanel instance = new WorldPanel(null, new World(), false);
    assertFalse(instance.isPassive());
    instance = new WorldPanel(null, new World(), true);
    assertTrue(instance.isPassive());
}
Also used : World(mudmap2.backend.World) Test(org.junit.Test)

Example 37 with World

use of mudmap2.backend.World in project mudmap2 by Neop.

the class WorldPanelTest method testGetSelectedPlace.

/**
 * Test of getSelectedPlace method, of class WorldPanel.
 */
@Test
public void testGetSelectedPlace() {
    try {
        System.out.println("getSelectedPlace");
        World world = new World();
        Layer l = world.getNewLayer();
        Place pl1 = new Place("BLa", 4, 6, l);
        l.put(pl1);
        Place pl2 = new Place("Blub", 7, 1, l);
        l.put(pl2);
        WorldPanel instance = new WorldPanel(null, world, false);
        instance.pushPosition(new WorldCoordinate(l.getId(), 0, 0));
        instance.setCursor(2, 3);
        assertNull(instance.getSelectedPlace());
        instance.setCursor(pl1.getX(), pl1.getY());
        assertEquals(pl1, instance.getSelectedPlace());
        instance.setCursor(pl2.getX(), pl2.getY());
        assertEquals(pl2, instance.getSelectedPlace());
    } catch (Layer.PlaceNotInsertedException ex) {
        Logger.getLogger(WorldPanelTest.class.getName()).log(Level.SEVERE, null, ex);
    }
}
Also used : WorldCoordinate(mudmap2.backend.WorldCoordinate) World(mudmap2.backend.World) Layer(mudmap2.backend.Layer) Place(mudmap2.backend.Place) Test(org.junit.Test)

Example 38 with World

use of mudmap2.backend.World in project mudmap2 by Neop.

the class WorldTabTest method testGetWorldPanel.

/**
 * Test of getWorldPanel method, of class WorldTab.
 */
@Test
public void testGetWorldPanel() {
    System.out.println("getWorldPanel");
    WorldTab instance = new WorldTab(null, new World(), false);
    assertNotNull(instance.getWorldPanel());
    instance = new WorldTab(null, new World(), true);
    assertNotNull(instance.getWorldPanel());
    instance = new WorldTab(null, new World(), "", false);
    assertNotNull(instance.getWorldPanel());
    instance = new WorldTab(null, new World(), "", true);
    assertNotNull(instance.getWorldPanel());
    instance = new WorldTab(instance);
    assertNotNull(instance.getWorldPanel());
}
Also used : World(mudmap2.backend.World) Test(org.junit.Test)

Example 39 with World

use of mudmap2.backend.World in project mudmap2 by Neop.

the class WorldTabTest method testGetFilename.

/**
 * Test of get/seFilename methods, of class WorldTab.
 */
@Test
public void testGetFilename() {
    System.out.println("getFilename");
    WorldTab instance = new WorldTab(null, new World(), false);
    String filename = "/tmp/foobar/baz";
    instance.setFilename(filename);
    assertEquals(filename, instance.getFilename());
}
Also used : World(mudmap2.backend.World) Test(org.junit.Test)

Example 40 with World

use of mudmap2.backend.World in project mudmap2 by Neop.

the class WorldFileList method readDirectory.

/**
 * Get available worlds from filesystem
 */
public static void readDirectory() {
    // get file list
    File dir = new File(Environment.getWorldsDir());
    File[] fileList = dir.listFiles();
    if (fileList != null) {
        // find world files in file list
        for (File file : fileList) {
            // exclude meta and backup files
            if (!file.getName().equals("worlds") && !file.getName().endsWith("_meta") && !file.getName().endsWith(".backup") && !file.getName().endsWith(".bak") && file.isFile() && file.canRead()) {
                // check if file is world file
                WorldFileDefault worldFile = new WorldFileDefault(file.getPath());
                try {
                    if (worldFile.canRead()) {
                        // is world file
                        String name = worldFile.readWorldName();
                        availableWorlds.put(file.getPath(), name);
                    }
                } catch (FileNotFoundException ex) {
                } catch (Exception ex) {
                    Logger.getLogger(WorldFileList.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
    }
}
Also used : FileNotFoundException(java.io.FileNotFoundException) File(java.io.File) WorldFileDefault(mudmap2.backend.WorldFileReader.current.WorldFileDefault) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

World (mudmap2.backend.World)31 Test (org.junit.Test)27 IOException (java.io.IOException)11 FileNotFoundException (java.io.FileNotFoundException)9 Place (mudmap2.backend.Place)9 File (java.io.File)7 WorldFileDefault (mudmap2.backend.WorldFileReader.current.WorldFileDefault)7 Layer (mudmap2.backend.Layer)6 Path (mudmap2.backend.Path)6 WorldCoordinate (mudmap2.backend.WorldCoordinate)6 Color (java.awt.Color)5 HashMap (java.util.HashMap)5 WorldFile (mudmap2.backend.WorldFileReader.WorldFile)5 PlaceGroup (mudmap2.backend.PlaceGroup)4 ActionEvent (java.awt.event.ActionEvent)3 ActionListener (java.awt.event.ActionListener)3 Map (java.util.Map)3 JLabel (javax.swing.JLabel)3 RiskLevel (mudmap2.backend.RiskLevel)3 BorderLayout (java.awt.BorderLayout)2