Package de.yaams.extensions.basemap.tiled.core

Examples of de.yaams.extensions.basemap.tiled.core.TileLayer


      MapLayerEdit transEdit;
      transEdit = new MapLayerEdit(currentLayer, createLayerCopy(currentLayer));

      if (marqueeSelection != null) {
        if (currentLayer instanceof TileLayer) {
          layer = new TileLayer(marqueeSelection.getSelectedAreaBounds());
        } else if (currentLayer instanceof ObjectGroup) {
          layer = new ObjectGroup(marqueeSelection.getSelectedAreaBounds());
        }
        layer.setMap(currentMap);
        layer.maskedCopyFrom(currentLayer, marqueeSelection.getSelectedArea());
View Full Code Here


    @Override
    public void actionPerformed(ActionEvent evt) {
      if (currentMap != null && marqueeSelection != null) {
        if (getCurrentLayer() instanceof TileLayer) {
          clipboardLayer = new TileLayer(marqueeSelection.getSelectedAreaBounds());
        } else if (getCurrentLayer() instanceof ObjectGroup) {
          clipboardLayer = new ObjectGroup(marqueeSelection.getSelectedAreaBounds());
        }
        clipboardLayer.maskedCopyFrom(getCurrentLayer(), marqueeSelection.getSelectedArea());
      }
View Full Code Here

    @Override
    public void actionPerformed(ActionEvent evt) {
      // FIXME: only works for TileLayers
      if (currentMap != null && marqueeSelection != null) {
        clipboardLayer = new TileLayer(marqueeSelection.getSelectedAreaBounds());
        ListIterator<?> itr = currentMap.getLayers();
        while (itr.hasNext()) {
          MapLayer layer = (MapLayer) itr.next();
          if (layer instanceof TileLayer) {
            clipboardLayer.maskedMergeOnto(layer, marqueeSelection.getSelectedArea());
View Full Code Here

    public void actionPerformed(ActionEvent evt) {
      if (currentMap != null && marqueeSelection != null) {
        MapLayer ml = getCurrentLayer();

        if (getCurrentLayer() instanceof TileLayer) {
          clipboardLayer = new TileLayer(marqueeSelection.getSelectedAreaBounds());
        } else if (getCurrentLayer() instanceof ObjectGroup) {
          clipboardLayer = new ObjectGroup(marqueeSelection.getSelectedAreaBounds());
        }
        clipboardLayer.maskedCopyFrom(ml, marqueeSelection.getSelectedArea());

        Rectangle area = marqueeSelection.getSelectedAreaBounds();
        Area mask = marqueeSelection.getSelectedArea();
        if (ml instanceof TileLayer) {
          TileLayer tl = (TileLayer) ml;
          for (int i = area.y; i < area.height + area.y; i++) {
            for (int j = area.x; j < area.width + area.x; j++) {
              if (mask.contains(j, i)) {
                tl.setTileAt(j, i, null);
              }
            }
          }
        }
        mapView.repaintRegion(area);
View Full Code Here

    // build layers
    // load map data

    for (int z = 0, n = map.getLayer(); z < n; z++) {
      final TileLayer l = (TileLayer) m.addLayer();
      l.setName(z == 0 ? "Base" : z == 1 ? "Objects" : Integer.toString(z));
      // set tiles
      for (int x = 0, u = m.getWidth(); x < u; x++) {
        for (int y = 0, v = m.getHeight(); y < v; y++) {
          if (map.get(x, y, z) >= 0) {
            l.setTileAt(x, y, tileset.getTile(map.get(x, y, z)));
          }
        }
      }
    }
    return m;
View Full Code Here

    cm.setHeight(map.getHeight());
    cm.setLayer(map.getLayerVector().size());

    // create data
    for (int z = 0, n = map.getLayerVector().size(); z < n; z++) {
      TileLayer layer = (TileLayer) map.getLayer(z);
      for (int x = 0, l = layer.getWidth(); x < l; x++) {
        for (int y = 0, m = layer.getHeight(); y < m; y++) {
          Tile t = layer.getTileAt(x, y);

          // is empty?
          if (t == null) {
            cm.set(x, y, z, -1);
            continue;
View Full Code Here

    myTs.setName("Merged Set");
  }

  public TileLayer merge(int start, int len, boolean all) {
    Rectangle r = myMap.getBounds();
    TileLayer mergedLayer = new TileLayer(r);

    for (int i = 0; i < r.height; i++) {
      for (int j = 0; j < r.width; j++) {
        mergedLayer.setTileAt(j, i, createCell(j, i, start, len, all));
      }
    }

    return mergedLayer;
  }
View Full Code Here

    writeProperties(l.getProperties(), w);

    if (l instanceof ObjectGroup) {
      writeObjectGroup((ObjectGroup) l, w, wp);
    } else if (l instanceof TileLayer) {
      final TileLayer tl = (TileLayer) l;
      w.startElement("data");
      if (encodeLayerData) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        OutputStream out;

        w.writeAttribute("encoding", "base64");

        if (compressLayerData) {
          w.writeAttribute("compression", "gzip");
          out = new GZIPOutputStream(baos);
        } else {
          out = baos;
        }

        for (int y = 0; y < l.getHeight(); y++) {
          for (int x = 0; x < l.getWidth(); x++) {
            Tile tile = tl.getTileAt(x + bounds.x, y + bounds.y);
            int gid = 0;

            if (tile != null) {
              gid = tile.getGid();
            }

            out.write(gid & LAST_BYTE);
            out.write(gid >> 8 & LAST_BYTE);
            out.write(gid >> 16 & LAST_BYTE);
            out.write(gid >> 24 & LAST_BYTE);
          }
        }

        if (compressLayerData) {
          ((GZIPOutputStream) out).finish();
        }

        w.writeCDATA(new String(Base64.encode(baos.toByteArray())));
      } else {
        for (int y = 0; y < l.getHeight(); y++) {
          for (int x = 0; x < l.getWidth(); x++) {
            Tile tile = tl.getTileAt(x + bounds.x, y + bounds.y);
            int gid = 0;

            if (tile != null) {
              gid = tile.getGid();
            }

            w.startElement("tile");
            w.writeAttribute("gid", gid);
            w.endElement();
          }
        }
      }
      w.endElement();

      boolean tilePropertiesElementStarted = false;

      for (int y = 0; y < l.getHeight(); y++) {
        for (int x = 0; x < l.getWidth(); x++) {
          Properties tip = tl.getTileInstancePropertiesAt(x, y);

          if (tip != null && !tip.isEmpty()) {
            if (!tilePropertiesElementStarted) {
              w.startElement("tileproperties");
              tilePropertiesElementStarted = true;
View Full Code Here

        }
        break;
      case PS_POUR:
        paintEdit = null;
        if (layer instanceof TileLayer) {
          TileLayer tileLayer = (TileLayer) layer;
          Tile oldTile = tileLayer.getTileAt(tile.x, tile.y);
          pour(tileLayer, tile.x, tile.y, currentTile, oldTile);
          mapView.repaint();
        }
        break;
      case PS_EYED:
        if (layer instanceof TileLayer) {
          TileLayer tileLayer = (TileLayer) layer;
          Tile newTile = tileLayer.getTileAt(tile.x, tile.y);
          setCurrentTile(newTile);
        }
        break;
      case PS_MOVE: {
        Point translation = new Point(tile.x - mousePressLocation.x, tile.y - mousePressLocation.y);
View Full Code Here

      Rectangle bounds = new Rectangle(minx, miny, Math.max(limp.x, tile.x) - minx + 1, Math.max(limp.y, tile.y) - miny + 1);

      // STAMP
      if (mouseButton == MouseEvent.BUTTON3 && layer instanceof TileLayer) {
        // Right mouse button dragged: create and set custom brush
        TileLayer brushLayer = new TileLayer(bounds);
        brushLayer.copyFrom(getCurrentLayer());
        brushLayer.setOffset(tile.x - (int) bounds.getWidth() / 2, tile.y - (int) bounds.getHeight() / 2);

        // Do a quick check to make sure the selection is not empty
        if (brushLayer.isEmpty()) {
          JOptionPane.showMessageDialog(appFrame, Resources.getString("dialog.selection.empty"),
              Resources.getString("dialog.selection.empty"), JOptionPane.WARNING_MESSAGE);
        } else {
          setBrush(new CustomBrush(brushLayer));
          cursorHighlight.setOffset(tile.x - (int) bounds.getWidth() / 2, tile.y - (int) bounds.getHeight() / 2);
View Full Code Here

TOP

Related Classes of de.yaams.extensions.basemap.tiled.core.TileLayer

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.