/** Changes the current color of this TextRenderer to the supplied one, where each component ranges from 0.0f - 1.0f. The alpha component, if used, does not need to be premultiplied into the color channels as described in the documentation for {@link Texture Texture}, although premultiplied colors are used internally. The default color is opaque white. @param r the red component of the new color @param g the green component of the new color @param b the blue component of the new color @param a the alpha component of the new color, 0.0f = completely transparent, 1.0f = completely opaque @throws GLException If an OpenGL context is not current when this method is called */ public void setColor(float r, float g, float b, float a) throws GLException { renderer.setColor(r, g, b, a); }
/** Changes the current color of this TextRenderer to the supplied one, where each component ranges from 0.0f - 1.0f. The alpha component, if used, does not need to be premultiplied into the color channels as described in the documentation for {@link Texture Texture}, although premultiplied colors are used internally. The default color is opaque white. @param r the red component of the new color @param g the green component of the new color @param b the blue component of the new color @param a the alpha component of the new color, 0.0f = completely transparent, 1.0f = completely opaque @throws GLException If an OpenGL context is not current when this method is called */ public void setColor(float r, float g, float b, float a) throws GLException { renderer.setColor(r, g, b, a); }
@Override public void drawString(float x, float y, String s, Color3f color) { text.beginRendering(panel.getWidth(), panel.getHeight()); text.setColor(color.x, color.y, color.z, 1); text.draw(s, (int) x, panel.getHeight() - (int) y); text.endRendering(); } }
@Override public void setColor(float r, float g, float b, float a) { renderer.setColor(r, g, b, a); }
public void draw(TextRenderer renderer, GLAutoDrawable drawable, Rect rect) { int width = (int) (rect.maxX - rect.minX); int height = (int) (rect.maxY - rect.minY); int screenWidth = drawable.getSurfaceWidth(); float widthRatio = (float) screenWidth / (float) width; int screenHeight = drawable.getSurfaceHeight(); float heightRatio = (float) screenHeight / (float) height; renderer.beginRendering(screenWidth, screenHeight); renderer.setColor(color.getRed()/255.f, color.getGreen()/255.f, color.getBlue()/255.f, color.getAlpha()/255.f); renderer.draw(text, (int) ((x - rect.minX) * widthRatio) , (int) ((y - rect.minY) * heightRatio)); renderer.endRendering(); }
/** * Sets the font color, respecting the AlphaComposite if it wants to * pre-multiply an alpha. */ protected void setTextColorRespectComposite(TextRenderer renderer) { Color color = g2d.getColor(); if (g2d.getComposite() instanceof AlphaComposite) { float alpha = ((AlphaComposite) g2d.getComposite()).getAlpha(); if (alpha < 1) { float[] rgba = color.getRGBComponents(null); color = new Color(rgba[0], rgba[1], rgba[2], alpha * rgba[3]); } } renderer.setColor(color); }
/** * Sets the font color, respecting the AlphaComposite if it wants to * pre-multiply an alpha. */ protected void setTextColorRespectComposite(TextRenderer renderer) { Color color = g2d.getColor(); if (g2d.getComposite() instanceof AlphaComposite) { float alpha = ((AlphaComposite) g2d.getComposite()).getAlpha(); if (alpha < 1) { float[] rgba = color.getRGBComponents(null); color = new Color(rgba[0], rgba[1], rgba[2], alpha * rgba[3]); } } renderer.setColor(color); }
@Override void renderContents(GL2 gl) { // Get text bounds. Rectangle2D bounds = renderer.getBounds(getMessage()); // Render message background: final float bx1 = .45f * (float) (width - bounds.getWidth()); final float bx2 = .55f * (float) (width + bounds.getWidth()); final float by1 = .45f * (float) (height - bounds.getHeight()); final float by2 = .55f * (float) (height + bounds.getHeight()); gl.glBegin(GL2.GL_QUADS); gl.glColor4f(0f, 0f, 0f, .75f); gl.glVertex2f(bx1, by1); gl.glVertex2f(bx1, by2); gl.glVertex2f(bx2, by2); gl.glVertex2f(bx2, by1); gl.glEnd(); // Render message renderer.beginRendering(width, height); renderer.setColor(1f, 1f, 1f, 1f); renderer.setColor(1f, 1f, 1f, 1f); renderer.draw(getMessage(), (width - (int) bounds.getWidth()) >> 1, (height - (int) bounds.getHeight()) >> 1); renderer.endRendering(); }
@Override public void draw(OTFOGLDrawer drawer) { if (textRenderer == null) { textRenderer = new TextRenderer(new Font("SansSerif", Font.PLAIN, 32), true, false); textRenderer.setColor(new Color(50, 50, 128, 255)); } GL2 gl = OTFGLAbstractDrawable.getGl(); if (vert != null) { drawPlanPolyLine(gl); } drawActivityTexts(); Point2D.Double agentCoords = drawer.getCurrentSceneGraph().getAgentPointLayer().getAgentCoords(this.agentId.toCharArray()); if (agentCoords != null) { // We know where the agent is, so we draw stuff around them. drawArrowFromAgentToTextLabel(agentCoords, gl); drawCircleAroundAgent(agentCoords, gl); drawLabelText(drawer, agentCoords); } }
private void drawFrameRate(GLAutoDrawable drawable, int now) { if (this.statusWidth == 0) { // Place it at a fixed offset wrt the upper right corner this.statusWidth = (int) this.textRenderer.getBounds("FPS: 10000.00").getWidth(); } // Calculate text location and color int x = drawable.getSurfaceWidth() - this.statusWidth - 5; int y = drawable.getSurfaceHeight() - 30; // Render the text this.textRenderer.setColor(Color.DARK_GRAY); this.textRenderer.beginRendering(drawable.getSurfaceWidth(), drawable.getSurfaceHeight()); this.textRenderer.draw(Time.writeTime(now, ':'), x, y); this.textRenderer.endRendering(); }
sin = FastMath.sin(shared.camera.getRotationZ()); shared.textrenderer.setColor(0.0f, 0.0f, 0.0f, 1.0f); float defaultscale = .01f / (float) FastMath.sqrt(shared.dim); final float targetwidth = .2f; // TODO: div depth? shared.textrenderer.setColor(1f, 0f, 0f, 1f); for(IntIntPair pair : edgesort) { Layout.Edge edge = shared.layout.edges.get(pair.second);
_renderer.setColor(_color); int x,y; switch(_alignment) {
this.textRenderer.setColor( 1.0f, 0.2f, 0.2f, 0.8f ); final float scale = 0.003f;
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); }
tr.setColor(new java.awt.Color(argb, true)); gl.glEnable(gl.GL_SCISSOR_TEST); gl.glScissor(clipX, clipY, clipW, clipH);
float width = (float) this.textRenderer.getBounds(text).getWidth() * fl[8]; this.textRenderer.setColor(c, c, c, 1.f); this.textRenderer.draw3D(text, fl[2] - width / 2.f, fl[9], 0f, fl[8]);