Package org.mt4j.components.visibleComponents.font

Examples of org.mt4j.components.visibleComponents.font.IFontCharacter


    tabContours.add(tabVerts);
    VectorFontCharacter tab = new VectorFontCharacter(tabContours, pa);
//    VectorFontCharacter tab = new VectorFontCharacter(new Vertex[]{new Vertex(0,0,0), new Vertex(defaultTabWidth,0,0),new Vertex(defaultTabWidth,100,0),new Vertex(0,100,0)}, new ArrayList<Vertex[]>(), pa);
    tab.setPickable(false);
    try {
      IFontCharacter space = svgFont.getFontCharacterByUnicode(" ");
      int tabWidth = 4*space.getHorizontalDist();
      tab.setHorizontalDist(tabWidth);
      tab.setVertices(new Vertex[]{new Vertex(0,0,0), new Vertex(tabWidth,0,0),new Vertex(tabWidth,100,0) /*,new Vertex(0,100,0)*/} );
    } catch (Exception e) {
      tab.setHorizontalDist(defaultTabWidth);
    }
View Full Code Here


    else{ //P3D rendering
      g.pushMatrix(); //FIXME TEST text scrolling - but IMHO better done with parent list/scroll container
      g.translate(totalScrollTextX, totalScrollTextY + font.getFontMaxAscent(), 0);
     
      for (int i = 0; i < charListSize; i++) {
        IFontCharacter character = characterList.get(i);
        //Step to the right by the amount of the last characters x advancement
        pa.translate(lastXAdvancement, 0, 0); //original
        //Save total amount gone to the right in this line
        thisLineTotalXAdvancement += lastXAdvancement;
        lastXAdvancement = 0;
       
        //Draw the letter
        character.drawComponent(g);
       
        //Check if newLine occurs, goto start at new line
        if (character.getUnicode().equals("\n")){
          pa.translate(-thisLineTotalXAdvancement, fontHeight, 0);
          thisLineTotalXAdvancement = 0;
          lastXAdvancement = innerPaddingLeft;
        }else{
          //If caret is showing and we are at index one before caret calc the advancement
          if (enableCaret && showCaret && i == charListSize - 2){
            if (character.getUnicode().equals("\t")){
              lastXAdvancement = character.getHorizontalDist() - character.getHorizontalDist( ) / 20;
            }else{
              //approximated value, cant get the real one
              lastXAdvancement = 2 + character.getHorizontalDist() - (character.getHorizontalDist() / 3);
            }
          }else{
            lastXAdvancement = character.getHorizontalDist();
          }
        }
      }
      g.popMatrix();//FIXME TEST text scrolling - but IMHO better done with parent list/scroll container
    }
View Full Code Here

 
  private void drawCharactersGL(GL gl, List<IFontCharacter> characterList, int charListSize, int lastXAdv, int lineTotalAdv){
    int lastXAdvancement = lastXAdv;
    int thisLineTotalXAdvancement = lineTotalAdv;
    for (int i = 0; i < charListSize; i++) {
      IFontCharacter character = characterList.get(i);
      //Step to the right by the amount of the last characters x advancement
      gl.glTranslatef(lastXAdvancement, 0, 0);
      //Save total amount gone to the right in this line
      thisLineTotalXAdvancement += lastXAdvancement;
      lastXAdvancement = 0;

      //Draw the letter
      character.drawComponent(gl);

      //Check if newLine occurs, goto start at new line
      if (character.getUnicode().equals("\n")){
        gl.glTranslatef(-thisLineTotalXAdvancement, fontHeight, 0);
        thisLineTotalXAdvancement = 0;
        lastXAdvancement = innerPaddingLeft;
      }else{
        //If caret is showing and we are at index one before caret calc the advancement to include the caret in the text area
        if (enableCaret && showCaret && i == charListSize-2){
          if (character.getUnicode().equals("\t")){
            lastXAdvancement = character.getHorizontalDist() - character.getHorizontalDist() / 20;
          }else{
            //approximated value, cant get the real one
            lastXAdvancement = 2 + character.getHorizontalDist() - (character.getHorizontalDist() / 3);
          }
        }else{
          lastXAdvancement = character.getHorizontalDist();
        }
      }
    }
  }
View Full Code Here

  public void setBitmapFontTextureFiltered(boolean scalable){
    if (MT4jSettings.getInstance().isOpenGlMode() && this.getFont() instanceof BitmapFont){
      BitmapFont font = (BitmapFont)this.getFont();
      IFontCharacter[] characters = font.getCharacters();
      for (int i = 0; i < characters.length; i++) {
        IFontCharacter fontCharacter = characters[i];
        if (fontCharacter instanceof BitmapFontCharacter) {
          BitmapFontCharacter bChar = (BitmapFontCharacter) fontCharacter;
          bChar.setTextureFiltered(scalable);
        }
      }
View Full Code Here

   * @see org.mt4j.components.visibleComponents.widgets.keyboard.ITextInputListener#getText()
   */
  public String getText(){
    String returnString = "";
    for (Iterator<IFontCharacter> iter = this.characterList.iterator(); iter.hasNext();) {
      IFontCharacter character = (IFontCharacter) iter.next();
      String unicode = character.getUnicode();
      if (!character.equals(MTTextArea.artificialLineBreak)){
        returnString += unicode;
      }
    }
    return returnString;
  }
View Full Code Here

   * Append char by name.
   * @param characterName the character name
   */
  synchronized public void appendCharByName(String characterName){
    //Get the character from the font
    IFontCharacter character = font.getFontCharacterByName(characterName);
    if (character == null){
      System.err.println("Error adding character with name '" + characterName + "' to the textarea. The font couldnt find the character. -> Trying to use 'missing glyph'");
      character = font.getFontCharacterByName("missing-glyph");
      if (character != null)
        addCharacter(character);
View Full Code Here

  /* (non-Javadoc)
   * @see org.mt4j.components.visibleComponents.widgets.keyboard.ITextInputListener#appendCharByUnicode(java.lang.String)
   */
  synchronized public void appendCharByUnicode(String unicode){
    //Get the character from the font
    IFontCharacter character = font.getFontCharacterByUnicode(unicode);
    if (character == null){
//      System.err.println("Error adding character with unicode '" + unicode + "' to the textarea. The font couldnt find the character. ->Trying to use 'missing glyph'");
      character = font.getFontCharacterByUnicode("missing-glyph");
      if (character != null)
        addCharacter(character);
View Full Code Here

  }
 
 
  private int getLastWhiteSpace(){
    for (int i = this.characterList.size()-1; i > 0; i--) {
      IFontCharacter character = this.characterList.get(i);
      if (character.getUnicode().equals(" ")){
        return i;
      }else if (character.getUnicode().equals("\n")){// stop search when newline found before first whitespace
        return -1;
      }
    }
    return -1;
  }
View Full Code Here

  synchronized public void removeLastCharacter(){
    if (this.characterList.isEmpty())
      return;
   
    //REMOVE THE CHARACTER
    IFontCharacter lastCharacter = this.characterList.get(this.characterList.size()-1);
    this.characterList.remove(this.characterList.size()-1);
   
    this.characterRemoved(lastCharacter);
   
    this.setContentDisplayListDirty(true);
View Full Code Here

   * @return the last line width
   */
  protected float getLastLineWidth(){
    float currentLineWidth = 2 * this.getInnerPaddingLeft() + caretWidth;
    for (int i = 0; i < this.characterList.size(); i++) {
      IFontCharacter character = this.characterList.get(i);
      if (character.getUnicode().equals("\n")){
        currentLineWidth = 2 * this.getInnerPaddingLeft() + caretWidth;;
      }else{
        currentLineWidth += character.getHorizontalDist();
      }
    }
    return currentLineWidth;
  }
View Full Code Here

TOP

Related Classes of org.mt4j.components.visibleComponents.font.IFontCharacter

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.