/** Draws the supplied CharSequence at the desired location using the renderer's current color. The baseline of the leftmost character is at position (x, y) specified in OpenGL coordinates, where the origin is at the lower-left of the drawable and the Y coordinate increases in the upward direction. @param str the string to draw @param x the x coordinate at which to draw @param y the y coordinate at which to draw @throws GLException If an OpenGL context is not current when this method is called */ public void draw(final CharSequence str, final int x, final int y) throws GLException { draw3D(str, x, y, 0, 1); }
/** Draws the supplied String at the desired location using the renderer's current color. See {@link #draw(CharSequence, int, int) draw(CharSequence, int, int)}. */ public void draw(final String str, final int x, final int y) throws GLException { draw3D(str, x, y, 0, 1); }
@Override public void drawString(String string, int x, int y) { Font font = getFont(); if (font == null) { System.err.println(this.getClass().getSimpleName()+": Font is NULL"); } else { TextRenderer renderer = getRenderer(font); begin(renderer); renderer.draw3D(string, x, g2d.getCanvasHeight() - y, 0, 1); end(renderer); } }
@Override public void drawSimpleText(GL gl, GLU glu, Camera cam, String s, Coord3d position, Color color) { renderer.begin3DRendering(); renderer.draw3D(s, position.x, position.y, position.z, 0.01f); renderer.flush(); renderer.end3DRendering(); }
/** * Draw txt at (x,y,z), with the text centered in the x-direction, facing * along the +z axis. * * @param gl * @param txt * @param x * @param y * @param z */ private void drawAxisText(GL2 gl, String txt, float x, float y, float z) { Rectangle2D dim = this.axisLabelRenderer.getBounds(txt); float width = (float) dim.getWidth() * SCALE_FACTOR; this.axisLabelRenderer.begin3DRendering(); this.axisLabelRenderer.draw3D(txt, x - width / 2, y, z, SCALE_FACTOR); this.axisLabelRenderer.end3DRendering(); } }
/** * Draw txt at (x,y,z), with the text centered in the x-direction, facing * along the +z axis. * * @param gl * @param txt * @param x * @param y * @param z */ private void drawAxisText(GL2 gl, String txt, double x, double y, double z) { Rectangle2D dim = this.axisLabelRenderer.getBounds(txt); float width = (float) dim.getWidth() * SCALE_FACTOR; this.axisLabelRenderer.begin3DRendering(); this.axisLabelRenderer.draw3D(txt, (float) x - width / 2, (float) y, (float) z, SCALE_FACTOR); this.axisLabelRenderer.end3DRendering(); } }
/** * Draw text at (x,y,z), with the text centered in the x-direction, facing * along the +z axis. * * @param gl * gl2 * @param text * text to draw * @param x * coordinate x * @param y * coordinate y * @param z * coordinate z */ private void drawAxisText(GL2 gl, String text, float x, float y, float z) { Rectangle2D dim = this.axisLabelRenderer.getBounds(text); float width = (float) dim.getWidth() * SCALE_FACTOR; this.axisLabelRenderer.begin3DRendering(); this.axisLabelRenderer.draw3D(text, x - width / 2, y, z, SCALE_FACTOR); this.axisLabelRenderer.end3DRendering(); }
@Override public void drawString(String string, int x, int y) { TextRenderer renderer = getRenderer(getFont()); begin(renderer); renderer.draw3D(string, x, g2d.getCanvasHeight() - y, 0, 1); end(renderer); }
@Override public BoundingBox3d drawText(GL gl, GLU glu, Camera cam, String s, Coord3d position, Halign halign, Valign valign, Color color, Coord2d screenOffset, Coord3d sceneOffset) { //gl.getGL2().glPushMatrix(); renderer.begin3DRendering(); if(LAYOUT){ // work in progress Rectangle2D d = style.getBounds(s, font, renderer.getFontRenderContext()); Coord3d left2d = cam.modelToScreen(gl, glu, position); Coord2d right2d = new Coord2d(left2d.x+(float)d.getWidth(), left2d.y+(float)d.getHeight()); Coord3d right3d = cam.screenToModel(gl, glu, new Coord3d(right2d,0)); Coord3d offset3d = right3d.sub(position).div(2);//.mul(0.1f); Coord3d real = position.add(sceneOffset).sub(offset3d); renderer.draw3D(s, real.x, real.y, real.z, 1);//0.005f); } else{ Coord3d real = position.add(sceneOffset); renderer.draw3D(s, real.x, real.y, real.z, 1);//0.005f); } renderer.flush(); renderer.end3DRendering(); //gl.getGL2().glPopMatrix(); return null; }
/** * Draw list of texts described by pText. Each text have (x,y,z), with the * text centered in the x-direction, facing along the +z axis. * * @param gl * gl2 * @param text * text to draw */ private void drawAxisText(GL2 gl, List<TextToRender> text) { this.axisLabelRenderer.begin3DRendering(); for (TextToRender textToRender : text) { Rectangle2D dim = this.axisLabelRenderer.getBounds(textToRender.getText()); float width = (float) dim.getWidth() * SCALE_FACTOR; this.axisLabelRenderer.draw3D(textToRender.getText(), textToRender.getX() - width / 2, textToRender.getY(), textToRender.getZ(), SCALE_FACTOR); } this.axisLabelRenderer.end3DRendering(); }
@Override public void drawTextNode(NodeModel objectModel) { Node node = objectModel.getNode(); TextProperties textData = (TextProperties) node.getTextProperties(); if (textData != null) { String txt = textData.getText(); float width, height, posX, posY; if (txt == null || txt.isEmpty()) { return; } float sizeFactor = drawable.getGlobalScale() * textData.getSize() * model.sizeMode.getSizeFactor3d(model.nodeSizeFactor, objectModel); if (nodeRefresh || (objectModel.getTextWidth() == 0f && objectModel.getTextHeight() == 0f)) { Rectangle2D r = renderer.getBounds(txt); width = (float) (sizeFactor * r.getWidth()); height = (float) (sizeFactor * r.getHeight()); posX = node.x() + (float) width / -2f; posY = node.y() + (float) height / -2f; textData.setDimensions(width, height); } else { width = textData.getWidth(); height = textData.getHeight(); posX = node.x() + (float) width / -2f; posY = node.y() + (float) height / -2f; } model.colorMode.textNodeColor(this, objectModel); renderer.draw3D(txt, posX, posY, (float) node.z(), sizeFactor); } }
this.textRenderer.draw3D( config.getName(), (float)(1-nameBounds.getWidth()*scale), (float)(-nameBounds.getHeight()*scale) *config.getRenderingConfig().getNameDirection(), 0.1f, scale );
void drawString(String text, int x, int y, java.awt.Color color, GL2 gl, com.jogamp.opengl.util.awt.TextRenderer tr) { //System.out.println("drawString "+ text + " x: "+x+" y: "+y); gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION); gl.glPushMatrix(); gl.glLoadIdentity(); //System.out.println("glOrtho(0,"+ c.getWidth() + ","+c.getHeight()+",0,-1.0,1.0)"); gl.glOrtho(0,c.getWidth(),0,c.getHeight(),-1.0,1.0); tr.begin3DRendering(); tr.setColor(color); tr.draw3D(text, x, c.getHeight()-y, 0, 1); tr.end3DRendering(); gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION); gl.glPopMatrix(); gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); }
float posZ = 0; renderer.draw3D(txt, posX, posY, posZ, sizeFactor);
gl.glScissor(clipX, clipY, clipW, clipH); tr.draw3D(text.toString(), x, RSurfHeight-y, 0, 1); gl.glDisable(gl.GL_SCISSOR_TEST); tr.end3DRendering();