Package edu.umd.cs.piccolo.nodes

Examples of edu.umd.cs.piccolo.nodes.PText


   * to be crap, there is nothing we can do about it.
   */
  public void drawText(int x, int y, String text) {
    int unreadableCharAt = -1;
    char[] chars = text.toCharArray();
    PText pt = new PText(text);
    pt.setTextPaint(currentPenColor);
    pt.setFont(currentFont);

    // Check to see if every character can be displayed by the current font.
    for (int i = 0; i < chars.length; i++) {
      if (!currentFont.canDisplay(chars[i])) {
        // Set to the first not displayable character.
        unreadableCharAt = i;
        break;
      }
    }

    // Have to find some working font and use it for this text entry.
    if (unreadableCharAt != -1) {
      Font[] allfonts =
          GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
      for (int j = 0; j < allfonts.length; j++) {
        if (allfonts[j].canDisplay(chars[unreadableCharAt])) {
          Font tempFont =
              new Font(allfonts[j].getFontName(), currentFont.getStyle(),
                  currentFont.getSize());
          pt.setFont(tempFont);
          break;
        }
      }
    }

    pt.setX(x);
    pt.setY(y);
    layer.addChild(pt);
  }
View Full Code Here


    this.tooltipWidth = width;
    init();
  }

  private void init() {
    PText tag = new PText(tooltipBuilder.getName());
    tag.setConstrainWidthToTextWidth(false);
    tag.setTextPaint(NengoStyle.COLOR_FOREGROUND);
    tag.setFont(NengoStyle.FONT_LARGE);
    tag.setWidth(tooltipWidth);
    int layoutY = 0;
    getPiccolo().addChild(tag);

    layoutY += tag.getHeight() + 10;

    Collection<ITooltipPart> parts = tooltipBuilder.getParts();

    Iterator<ITooltipPart> it = parts.iterator();
View Full Code Here

          if (i == 0)
            p.setStrokePaint(Color.red);
          else
            p.setStrokePaint(Color.blue);
          p.setPaint(null);
          PText t = new PText("" + i);
          t.setOffset(r.getX(), r.getY());
          layer.addChild(p);
          layer.addChild(t);
        }
      }
    };
View Full Code Here

    textAttributes.put(TextAttribute.TRACKING, tracking);
    textAttributes.put(TextAttribute.FONT, f);
    textAttributes.put(TextAttribute.SIZE, size);
    f = f.deriveFont(textAttributes);

    PText p = new PText(text);
    p.setFont(f);
    return (BufferedImage) p.toImage();
  }
View Full Code Here

   
    return new PNode();
  }

  static public PNode createFrom(LabelElement element){
    final PText txt = new PText(element.text);
    txt.setTextPaint(Color.black);
    txt.setPaint(Color.yellow);
    txt.setTextPaint(element.color);
    txt.setFont(txt.getFont().deriveFont(element.fontSize));

    PNode labelNode = new PNode();
    labelNode.setPaint(Color.yellow);
    labelNode.addChild(txt);
    labelNode.setHeight(txt.getHeight()+2);
    labelNode.setWidth(txt.getWidth()+4);
    txt.setOffset(2,1);


    labelNode.setOffset(element.x, element.y);
    return addShadow(labelNode);
  }
View Full Code Here

    public LogImageRenderer(BufferedImage input) {
      super(input);
    }

    void addTextLabel(PNode parent, String txt, int x, int y){
      PText t = new PText(txt);
      t.setScale(1.5f);
      t.setPaint(Color.yellow);
      t.setOffset(x,y);
      addNodeWithShadow(parent, t);   
    }
View Full Code Here

TOP

Related Classes of edu.umd.cs.piccolo.nodes.PText

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.