Package tiled.core

Examples of tiled.core.Map


   * @throws Exception */
  public void convert(final String tmxFile) throws Exception {
    final File file = new File(tmxFile);

    final String filename = file.getAbsolutePath();
    final Map map = new XMLMapTransformer().readMap(filename);
    saveImageMap(map, tmxFile);
  }
View Full Code Here


   * @throws Exception */
  public void convert(final String tmxFile) throws Exception {
    final File file = new File(tmxFile);

    final String filename = file.getAbsolutePath();
    final Map map = new XMLMapTransformer().readMap(filename);
    removeUnusedTilesets(map);
    new XMLMapWriter().writeMap(map, filename);
  }
View Full Code Here

   */
  private void convert(final String tmxFile) throws Exception {
    final File file = new File(tmxFile);

    final String filename = file.getAbsolutePath();
    final Map map = new XMLMapTransformer().readMap(filename);
    addNewTilesets(map);
    translateMap(map);
    removeUnusedTilesets(map);
    new XMLMapWriter().writeMap(map, filename);
  }
View Full Code Here

        // Get the map dimensions and create the map
        int mapWidth = getAttribute(mapNode, "width", 0);
        int mapHeight = getAttribute(mapNode, "height", 0);

        if (mapWidth > 0 && mapHeight > 0) {
            map = new Map(mapWidth, mapHeight);
        } else {
            // Maybe this map is still using the dimensions element
            NodeList l = doc.getElementsByTagName("dimensions");
            for (int i = 0; (item = l.item(i)) != null; i++) {
                if (item.getParentNode() == mapNode) {
                    mapWidth = getAttribute(item, "width", 0);
                    mapHeight = getAttribute(item, "height", 0);

                    if (mapWidth > 0 && mapHeight > 0) {
                        map = new Map(mapWidth, mapHeight);
                    }
                }
            }
        }
View Full Code Here

        // Wrap with GZIP decoder for .tmx.gz files
        if (filename.endsWith(".gz")) {
            is = new GZIPInputStream(is);
        }

        Map unmarshalledMap = unmarshal(is);
        unmarshalledMap.setFilename(filename);

        map = null;

        return unmarshalledMap;
    }
View Full Code Here

    }

    public Map readMap(InputStream in) throws Exception {
        xmlPath = makeUrl(".");

        Map unmarshalledMap = unmarshal(in);

        //unmarshalledMap.setFilename(xmlFile)
        //
        return unmarshalledMap;
    }
View Full Code Here

        if (fileToOpen == null) {
            printHelpMessage();
            return;
        }

        Map map;
        try {
            TMXMapReader mapReader = new TMXMapReader();
            map = mapReader.readMap(fileToOpen);
        } catch (Exception e) {
            System.out.println("Error while reading the map:\n" + e.getMessage());
            return;
        }

        System.out.println(map.toString() + " loaded");

        JScrollPane scrollPane = new JScrollPane(new MapView(map));
        scrollPane.setBorder(null);
        scrollPane.setPreferredSize(new Dimension(800, 600));
View Full Code Here

    public void testReadingExampleMap() throws Exception {
        // Arrange
        File mapFile = getFileFromResources("resources/sewers.tmx");

        // Act
        Map map = new TMXMapReader().readMap(mapFile.getAbsolutePath());

        // Assert
        assertEquals(Map.ORIENTATION_ORTHOGONAL, map.getOrientation());
        assertEquals(50, map.getHeight());
        assertEquals(50, map.getHeight());
        assertEquals(24, map.getTileWidth());
        assertEquals(24, map.getTileHeight());
        assertEquals(3, map.getLayerCount());
        assertNotNull(((TileLayer)map.getLayer(0)).getTileAt(0, 0));
    }
View Full Code Here

    public void testReadingExampleCsvMap() throws Exception {
        // Arrange
        File mapFile = getFileFromResources("resources/csvmap.tmx");
       
        // Act
        Map map = new TMXMapReader().readMap(mapFile.getAbsolutePath());
       
        // Assert
        assertEquals(Map.ORIENTATION_ORTHOGONAL, map.getOrientation());
        assertEquals(100, map.getHeight());
        assertEquals(100, map.getHeight());
        assertEquals(32, map.getTileWidth());
        assertEquals(32, map.getTileHeight());
        assertEquals(1, map.getLayerCount());
        assertNotNull(((TileLayer)map.getLayer(0)).getTileAt(0, 0));
    }
View Full Code Here

        putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke("shift PAGE_UP"));
    }

    protected void doPerformAction() {
        Map map = editor.getCurrentMap();
        int layerIndex = editor.getCurrentLayerIndex();
        int totalLayers = map.getTotalLayers();

        if (layerIndex < totalLayers - 1) {
            map.swapLayerUp(layerIndex);
            editor.setCurrentLayer(layerIndex + 1);
        }
    }
View Full Code Here

TOP

Related Classes of tiled.core.Map

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.