Examples of PText


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

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

    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

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

          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

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

    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

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

   
    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

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

    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

Examples of org.piccolo2d.nodes.PText

    public static PCanvas createCanvas() {
        final PCanvas canvas = new PCanvas();
        final PCamera camera = canvas.getCamera();
       
        final PText tooltipNode = new PText();
        tooltipNode.setPickable(false);
        camera.addChild(tooltipNode);

        camera.addInputEventListener(new PBasicInputEventHandler() {
            public void mouseMoved(final PInputEvent event) {
                updateToolTip(event);
            }

            public void mouseDragged(final PInputEvent event) {
                updateToolTip(event);
            }

            public void updateToolTip(final PInputEvent event) {
                final PNode n = event.getPickedNode();
                final Object object = (Object) n.getAttribute("tooltip");
                if (object != null) {
                    final String tooltipString = object.toString();
                    final Point2D p = event.getCanvasPosition();

                    event.getPath().canvasToLocal(p, camera);

                    tooltipNode.setText(tooltipString);
                    tooltipNode.setOffset(p.getX() + 8, p.getY() - 8);
                } else {
                    tooltipNode.setText(null);
                }
            }
        });

        // uninstall default zoom event handler
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.