Package com.badlogic.gdx.graphics.g2d

Examples of com.badlogic.gdx.graphics.g2d.PixmapPacker$Node


      data.down = -data.down;
    }

    boolean ownsAtlas = false;

    PixmapPacker packer = parameter.packer;

    if (packer == null) {
      // generate the glyphs
      int maxGlyphHeight = (int)Math.ceil(data.lineHeight);
      int pageWidth = MathUtils
        .nextPowerOfTwo((int)Math.sqrt(maxGlyphHeight * maxGlyphHeight * parameter.characters.length()));

      if (maxTextureSize > 0) pageWidth = Math.min(pageWidth, maxTextureSize);

      ownsAtlas = true;
      packer = new PixmapPacker(pageWidth, pageWidth, Format.RGBA8888, 2, false);
    }

    // to minimize collisions we'll use this format : pathWithoutExtension_size[_flip]_glyph
    String packPrefix = ownsAtlas ? "" : (filePath + '_' + parameter.size + (parameter.flip ? "_flip_" : '_'));

    for (int i = 0; i < parameter.characters.length(); i++) {
      char c = parameter.characters.charAt(i);
      if (!FreeType.loadChar(face, c, FreeType.FT_LOAD_DEFAULT)) {
        Gdx.app.log("FreeTypeFontGenerator", "Couldn't load char '" + c + "'");
        continue;
      }
      if (!FreeType.renderGlyph(face.getGlyph(), FreeType.FT_RENDER_MODE_NORMAL)) {
        Gdx.app.log("FreeTypeFontGenerator", "Couldn't render char '" + c + "'");
        continue;
      }
      GlyphSlot slot = face.getGlyph();
      GlyphMetrics metrics = slot.getMetrics();
      Bitmap bitmap = slot.getBitmap();
      Pixmap pixmap = bitmap.getPixmap(Format.RGBA8888);
      Glyph glyph = new Glyph();
      glyph.id = (int)c;
      glyph.width = pixmap.getWidth();
      glyph.height = pixmap.getHeight();
      glyph.xoffset = slot.getBitmapLeft();
      glyph.yoffset = parameter.flip ? -slot.getBitmapTop() + (int)baseLine : -(glyph.height - slot.getBitmapTop())
        - (int)baseLine;
      glyph.xadvance = FreeType.toInt(metrics.getHoriAdvance());

      if (bitmapped) {
        pixmap.setColor(Color.CLEAR);
        pixmap.fill();
        ByteBuffer buf = bitmap.getBuffer();
        for (int h = 0; h < glyph.height; h++) {
          int idx = h * bitmap.getPitch();
          for (int w = 0; w < (glyph.width + glyph.xoffset); w++) {
            int bit = (buf.get(idx + (w / 8)) >>> (7 - (w % 8))) & 1;
            pixmap.drawPixel(w, h, ((bit == 1) ? Color.WHITE.toIntBits() : Color.CLEAR.toIntBits()));
          }
        }

      }

      String name = packPrefix + c;
      Rectangle rect = packer.pack(name, pixmap);

      // determine which page it was packed into
      int pIndex = packer.getPageIndex(name);
      if (pIndex == -1) // we should not get here
        throw new IllegalStateException("packer was not able to insert '" + name + "' into a page");

      glyph.page = pIndex;
      glyph.srcX = (int)rect.x;
      glyph.srcY = (int)rect.y;

      data.setGlyph(c, glyph);
      pixmap.dispose();
    }

    // generate kerning
    for (int i = 0; i < parameter.characters.length(); i++) {
      for (int j = 0; j < parameter.characters.length(); j++) {
        char firstChar = parameter.characters.charAt(i);
        Glyph first = data.getGlyph(firstChar);
        if (first == null) continue;
        char secondChar = parameter.characters.charAt(j);
        Glyph second = data.getGlyph(secondChar);
        if (second == null) continue;
        int kerning = FreeType.getKerning(face, FreeType.getCharIndex(face, firstChar),
          FreeType.getCharIndex(face, secondChar), 0);
        if (kerning == 0) continue;
        first.setKerning(secondChar, FreeType.toInt(kerning));
      }
    }

    if (ownsAtlas) {
      Array<Page> pages = packer.getPages();
      data.regions = new TextureRegion[pages.size];

      for (int i = 0; i < pages.size; i++) {
        Page p = pages.get(i);

View Full Code Here


     * @param fileName
     * @param parameter
     */
    @Override
    public SpritePack loadSync(AssetManager manager, String fileName, SpritePackParameter parameter) {
        PixmapPacker pixmapPacker = new PixmapPacker(512, 512, Pixmap.Format.RGBA8888, 1, true);
        for(FileHandle file : files) {
            Pixmap pixmap = manager.get(file.path(), Pixmap.class);
            pixmapPacker.pack(file.nameWithoutExtension(), pixmap);
        }
        return new SpritePack(pixmapPacker.generateTextureAtlas(Texture.TextureFilter.Nearest,
                                                                Texture.TextureFilter.Nearest,
                                                                false));
    }
View Full Code Here

       
      if (maxTextureSize > 0)
        pageWidth = Math.min(pageWidth, maxTextureSize);

      ownsAtlas = true;
      packer = new PixmapPacker(pageWidth, pageWidth, Format.RGBA8888, 2, false);
    }

    //to minimize collisions we'll use this format : pathWithoutExtension_size[_flip]_glyph
    String packPrefix = ownsAtlas ? "" : (filePath + '_' + size + (flip ? "_flip_" : '_') );
   
View Full Code Here

      data.down = -data.down;
    }

    boolean ownsAtlas = false;

    PixmapPacker packer = parameter.packer;

    if (packer == null) {
      // generate the glyphs
      int maxGlyphHeight = (int)Math.ceil(data.lineHeight);
      int pageWidth = MathUtils
        .nextPowerOfTwo((int)Math.sqrt(maxGlyphHeight * maxGlyphHeight * parameter.characters.length()));

      if (maxTextureSize > 0) pageWidth = Math.min(pageWidth, maxTextureSize);

      ownsAtlas = true;
      packer = new PixmapPacker(pageWidth, pageWidth, Format.RGBA8888, 2, false);
    }

    // to minimize collisions we'll use this format : pathWithoutExtension_size[_flip]_glyph
    String packPrefix = ownsAtlas ? "" : (filePath + '_' + parameter.size + (parameter.flip ? "_flip_" : '_'));

    for (int i = 0; i < parameter.characters.length(); i++) {
      char c = parameter.characters.charAt(i);
      if (!FreeType.loadChar(face, c, FreeType.FT_LOAD_DEFAULT)) {
        Gdx.app.log("FreeTypeFontGenerator", "Couldn't load char '" + c + "'");
        continue;
      }
      if (!FreeType.renderGlyph(face.getGlyph(), FreeType.FT_RENDER_MODE_NORMAL)) {
        Gdx.app.log("FreeTypeFontGenerator", "Couldn't render char '" + c + "'");
        continue;
      }
      GlyphSlot slot = face.getGlyph();
      GlyphMetrics metrics = slot.getMetrics();
      Bitmap bitmap = slot.getBitmap();
      Pixmap pixmap = bitmap.getPixmap(Format.RGBA8888);
      Glyph glyph = new Glyph();
      glyph.id = (int)c;
      glyph.width = pixmap.getWidth();
      glyph.height = pixmap.getHeight();
      glyph.xoffset = slot.getBitmapLeft();
      glyph.yoffset = parameter.flip ? -slot.getBitmapTop() + (int)baseLine : -(glyph.height - slot.getBitmapTop())
        - (int)baseLine;
      glyph.xadvance = FreeType.toInt(metrics.getHoriAdvance());

      if (bitmapped) {
        pixmap.setColor(Color.CLEAR);
        pixmap.fill();
        ByteBuffer buf = bitmap.getBuffer();
        for (int h = 0; h < glyph.height; h++) {
          int idx = h * bitmap.getPitch();
          for (int w = 0; w < (glyph.width + glyph.xoffset); w++) {
            int bit = (buf.get(idx + (w / 8)) >>> (7 - (w % 8))) & 1;
            pixmap.drawPixel(w, h, ((bit == 1) ? Color.WHITE.toIntBits() : Color.CLEAR.toIntBits()));
          }
        }

      }

      String name = packPrefix + c;
      Rectangle rect = packer.pack(name, pixmap);

      // determine which page it was packed into
      int pIndex = packer.getPageIndex(name);
      if (pIndex == -1) // we should not get here
        throw new IllegalStateException("packer was not able to insert '" + name + "' into a page");

      glyph.page = pIndex;
      glyph.srcX = (int)rect.x;
      glyph.srcY = (int)rect.y;

      data.setGlyph(c, glyph);
      pixmap.dispose();
    }

    // generate kerning
    for (int i = 0; i < parameter.characters.length(); i++) {
      for (int j = 0; j < parameter.characters.length(); j++) {
        char firstChar = parameter.characters.charAt(i);
        Glyph first = data.getGlyph(firstChar);
        if (first == null) continue;
        char secondChar = parameter.characters.charAt(j);
        Glyph second = data.getGlyph(secondChar);
        if (second == null) continue;
        int kerning = FreeType.getKerning(face, FreeType.getCharIndex(face, firstChar),
          FreeType.getCharIndex(face, secondChar), 0);
        if (kerning == 0) continue;
        first.setKerning(secondChar, FreeType.toInt(kerning));
      }
    }

    if (ownsAtlas) {
      Array<Page> pages = packer.getPages();
      data.regions = new TextureRegion[pages.size];

      for (int i = 0; i < pages.size; i++) {
        Page p = pages.get(i);

View Full Code Here

      data.down = -data.down;
    }

    boolean ownsAtlas = false;

    PixmapPacker packer = parameter.packer;

    if (packer == null) {
      // generate the glyphs
      int maxGlyphHeight = (int)Math.ceil(data.lineHeight);
      int pageWidth = MathUtils
        .nextPowerOfTwo((int)Math.sqrt(maxGlyphHeight * maxGlyphHeight * parameter.characters.length()));

      if (maxTextureSize > 0) pageWidth = Math.min(pageWidth, maxTextureSize);

      ownsAtlas = true;
      packer = new PixmapPacker(pageWidth, pageWidth, Format.RGBA8888, 2, false);
    }

    // to minimize collisions we'll use this format : pathWithoutExtension_size[_flip]_glyph
    String packPrefix = ownsAtlas ? "" : (filePath + '_' + parameter.size + (parameter.flip ? "_flip_" : '_'));

    for (int i = 0; i < parameter.characters.length(); i++) {
      char c = parameter.characters.charAt(i);
      if (!FreeType.loadChar(face, c, FreeType.FT_LOAD_DEFAULT)) {
        Gdx.app.log("FreeTypeFontGenerator", "Couldn't load char '" + c + "'");
        continue;
      }
      if (!FreeType.renderGlyph(face.getGlyph(), FreeType.FT_RENDER_MODE_NORMAL)) {
        Gdx.app.log("FreeTypeFontGenerator", "Couldn't render char '" + c + "'");
        continue;
      }
      GlyphSlot slot = face.getGlyph();
      GlyphMetrics metrics = slot.getMetrics();
      Bitmap bitmap = slot.getBitmap();
      Pixmap pixmap = bitmap.getPixmap(Format.RGBA8888);
      Glyph glyph = new Glyph();
      glyph.id = (int)c;
      glyph.width = pixmap.getWidth();
      glyph.height = pixmap.getHeight();
      glyph.xoffset = slot.getBitmapLeft();
      glyph.yoffset = parameter.flip ? -slot.getBitmapTop() + (int)baseLine : -(glyph.height - slot.getBitmapTop())
        - (int)baseLine;
      glyph.xadvance = FreeType.toInt(metrics.getHoriAdvance());

      if (bitmapped) {
        pixmap.setColor(Color.CLEAR);
        pixmap.fill();
        ByteBuffer buf = bitmap.getBuffer();
        for (int h = 0; h < glyph.height; h++) {
          int idx = h * bitmap.getPitch();
          for (int w = 0; w < (glyph.width + glyph.xoffset); w++) {
            int bit = (buf.get(idx + (w / 8)) >>> (7 - (w % 8))) & 1;
            pixmap.drawPixel(w, h, ((bit == 1) ? Color.WHITE.toIntBits() : Color.CLEAR.toIntBits()));
          }
        }

      }

      String name = packPrefix + c;
      Rectangle rect = packer.pack(name, pixmap);

      // determine which page it was packed into
      int pIndex = packer.getPageIndex(name);
      if (pIndex == -1) // we should not get here
        throw new IllegalStateException("packer was not able to insert '" + name + "' into a page");

      glyph.page = pIndex;
      glyph.srcX = (int)rect.x;
      glyph.srcY = (int)rect.y;

      data.setGlyph(c, glyph);
      pixmap.dispose();
    }

    // generate kerning
    if (parameter.kerning) {
      for (int i = 0; i < parameter.characters.length(); i++) {
        for (int j = 0; j < parameter.characters.length(); j++) {
          char firstChar = parameter.characters.charAt(i);
          Glyph first = data.getGlyph(firstChar);
          if (first == null) continue;
          char secondChar = parameter.characters.charAt(j);
          Glyph second = data.getGlyph(secondChar);
          if (second == null) continue;
          int kerning = FreeType.getKerning(face, FreeType.getCharIndex(face, firstChar),
            FreeType.getCharIndex(face, secondChar), 0);
          if (kerning == 0) continue;
          first.setKerning(secondChar, FreeType.toInt(kerning));
        }
      }
    }
    if (ownsAtlas) {
      Array<Page> pages = packer.getPages();
      data.regions = new TextureRegion[pages.size];

      for (int i = 0; i < pages.size; i++) {
        Page p = pages.get(i);

View Full Code Here

    // create list for SortContainers...
    final LinkedList<SortContainer> scl = new LinkedList<SortContainer>();

    // walk through children...
    for (int i = 0; i < node.jjtGetNumChildren(); ++i) {
      Node n = node.jjtGetChild(i); // get current child

      boolean desc = false; // set order ASC as default

      // current node is Order node...
      if (n instanceof ASTAscOrder || n instanceof ASTDescOrder) {
        if (n instanceof ASTDescOrder) // reset order value to DESC...
          desc = true;

        i++; // increase counter to get next child (which is sort
        // condition)
      }

      n = node.jjtGetChild(i); // get next child (which is sort condition)

      // parse node with the filter...
      final SPARQLParserVisitorImplementationDumper filterDumper = new SPARQLParserVisitorImplementationDumper();
      final String sortString = n.accept(filterDumper);

      try {
        final SortContainer sc = new SortContainer(this.prefix, desc,
            sortString); // create SortContainer
View Full Code Here

  @SuppressWarnings("unchecked")
  public Object visit(final ASTTripleSet node, final Object data) {
    final Item[] item = { null, null, null };

    for (int i = 0; i < 3; i++) {
      final Node n = node.jjtGetChild(i);
      item[i] = lupos.sparql1_1.operatorgraph.SPARQLCoreParserVisitorImplementation.getItem(n);
    }

    final HashMap<Item, QueryRDFTerm> rdfHash = (HashMap<Item, QueryRDFTerm>) data;
View Full Code Here

    // if AST exists...
    if (debugViewerCreator!=null && debugViewerCreator instanceof SPARQLDebugViewerCreator
        && ((SPARQLDebugViewerCreator) debugViewerCreator).getAST() != null) {

      final Node ast = ((SPARQLDebugViewerCreator) debugViewerCreator).getAST(); // get AST

      // walk through first level children of AST...
      for (int i = 0; i < ast.jjtGetNumChildren(); ++i) {
        final Node child = ast.jjtGetChild(i); // get current child

        if (child instanceof ASTSelectQuery) {
          final ASTSelectQuery selectChild = (ASTSelectQuery) child;

          // SELECT is not the wildcard *...
          if (!selectChild.isSelectAll()) {
            // walk through select children...
            for (int j = 0; j < selectChild.jjtGetNumChildren(); ++j) {
              final Node selectChildChild = selectChild
              .jjtGetChild(j);

              // child of select is variable...
              if (selectChildChild instanceof ASTVar) {
                final ASTVar var = (ASTVar) selectChildChild;

                // add name of variable to order...
                if (!resultOrder.contains(var.getName())) {
                  resultOrder.add(var.getName());
                }
              } else if (selectChildChild instanceof ASTAs) {
                for (int j1 = 0; j1 < selectChildChild
                .jjtGetNumChildren(); ++j1) {
                  final Node selectChildChildChild = selectChildChild
                  .jjtGetChild(j1);
                  if (selectChildChildChild instanceof ASTVar) {
                    final ASTVar var = (ASTVar) selectChildChildChild;

                    // add name of variable to order...
View Full Code Here

        ret += "\n";
        final String orderByClause = " ORDER BY "
          + toBeSorted.toString() + "\n";
        boolean ORDERBYADDED = false;
        while (i < node.jjtGetNumChildren()) {
          final Node child = node.jjtGetChild(i);
          if (!ORDERBYADDED
              && (child instanceof ASTOrderConditions
                  || child instanceof ASTLimit || child instanceof ASTOffset)) {
            ORDERBYADDED = true;
            ret += orderByClause;
View Full Code Here

  private static void determineVariables(final Node root,
      final Set<String> variables) {
    if (root instanceof ASTSelectQuery) {
      for (int i = 0; i < root.jjtGetNumChildren(); i++) {
        final Node node = root.jjtGetChild(i);
        if (node instanceof ASTGroupConstraint)
          determineVariables(node, variables);
      }
    } else {
      if (root instanceof ASTVar) {
View Full Code Here

TOP

Related Classes of com.badlogic.gdx.graphics.g2d.PixmapPacker$Node

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.