public void drawTextEdge(ModelImpl objectModel) {
      Renderable renderable = objectModel.getObj();
      TextDataImpl textData = (TextDataImpl) renderable.getTextData();
      if (textData != null) {
        model.colorMode.textColor(this, textData, objectModel);
        model.sizeMode.setSizeFactor2d(model.edgeSizeFactor, textData, objectModel);
        if (edgeRefresh) {
          builder.buildEdgeText((EdgeData) renderable, textData, model, currentTimeInterval);
        }
        if (textData.getSizeFactor() * renderer.getCharWidth('a') < PIXEL_LIMIT) {
          return;
        }
        String txt = textData.getLine().getText();
        Rectangle2D r = renderer.getBounds(txt);
        float posX =
            renderable.getModel().getViewportX()
                + (float) r.getWidth() / -2 * textData.getSizeFactor();
        float posY =
            renderable.getModel().getViewportY()
                + (float) r.getHeight() / -2 * textData.getSizeFactor();
        r.setRect(
            0,
            0,
            r.getWidth() / drawable.getDraggingMarkerX(),
            r.getHeight() / drawable.getDraggingMarkerY());
        textData.getLine().setBounds(r);

        renderer.draw3D(txt, posX, posY, 0, textData.getSizeFactor());
      }
    }
 private void display(GLAutoDrawable drawable, Point p) {
   if (renderer == null) {
     renderer = new TextRenderer(new Font("SansSerif", Font.PLAIN, 10), true, true);
   }
   Neuron[] n = cells[p.x][p.y];
   renderer.begin3DRendering();
   renderer.setColor(0, 0, 1, 0.8f);
   float s1 = n[0].getState(), s2 = n[1].getState();
   float avg = (s1 + s2) / 2;
   String s = String.format("%5.3f", avg);
   Rectangle2D rect = renderer.getBounds(s);
   renderer.draw3D(s, p.x, p.y, 0, .7f); // TODO fix string n lines
   renderer.end3DRendering();
   GL gl = drawable.getGL();
   gl.glRectf(p.x, p.y - 2, p.x + (float) rect.getWidth() * avg * .7f, p.y - 1);
 }
    public void drawTextNode(ModelImpl objectModel) {
      Renderable renderable = objectModel.getObj();
      TextDataImpl textData = (TextDataImpl) renderable.getTextData();
      if (textData != null) {
        model.colorMode.textColor(this, textData, objectModel);
        model.sizeMode.setSizeFactor3d(model.nodeSizeFactor, textData, objectModel);
        if (nodeRefresh) {
          builder.buildNodeText((NodeData) renderable, textData, model, currentTimeInterval);
        }
        String txt = textData.getLine().getText();
        Rectangle2D r = renderer.getBounds(txt);
        textData.getLine().setBounds(r);
        float posX = renderable.x() + (float) r.getWidth() / -2 * textData.getSizeFactor();
        float posY = renderable.y() + (float) r.getHeight() / -2 * textData.getSizeFactor();
        float posZ = renderable.getRadius();

        renderer.draw3D(txt, posX, posY, posZ, textData.getSizeFactor());
      }
    }
Ejemplo n.º 4
0
  protected void drawMultiLineText(TextRenderer textRenderer, int x, int y) {
    if (this.lines == null) {
      String msg = Logging.getMessage("nullValue.StringIsNull");
      Logging.logger().severe(msg);
      throw new IllegalArgumentException(msg);
    }

    for (int i = 0; i < this.lines.length; i++) {
      String line = this.lines[i];
      Rectangle2D bounds = this.lineBounds[i];

      int xAligned = x;
      if (this.textAlign.equals(AVKey.CENTER)) xAligned = x - (int) (bounds.getWidth() / 2);
      else if (this.textAlign.equals(AVKey.RIGHT)) xAligned = x - (int) (bounds.getWidth());

      y -= this.lineHeight;
      textRenderer.draw3D(line, xAligned, y, 0, 1);
      y -= this.lineSpacing;
    }
  }
Ejemplo n.º 5
0
  public void drawText(String text, double x, double y) {
    if (textRenderer == null) throw new RuntimeException();

    // gl.glDisable(GL.GL_DEPTH_TEST);

    // Uses 3D rendering so it can take advantage of the glTranslate
    // function
    textRenderer.begin3DRendering();
    textRenderer.setColor(currentColor);
    textRenderer.draw3D(
        text,
        (float) (scaleX * (brushPos.getX() + x)),
        (float) (scaleY * (brushPos.getY() + y)),
        0,
        1);
    textRenderer.end3DRendering();

    textRenderer.flush();

    // gl.glEnable(GL.GL_DEPTH_TEST);
  }