当前位置: 首页>>代码示例>>Java>>正文


Java TextRenderer.setColor方法代码示例

本文整理汇总了Java中com.jogamp.opengl.util.awt.TextRenderer.setColor方法的典型用法代码示例。如果您正苦于以下问题:Java TextRenderer.setColor方法的具体用法?Java TextRenderer.setColor怎么用?Java TextRenderer.setColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jogamp.opengl.util.awt.TextRenderer的用法示例。


在下文中一共展示了TextRenderer.setColor方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: annotate

import com.jogamp.opengl.util.awt.TextRenderer; //导入方法依赖的package包/类
@Override
public void annotate(GLAutoDrawable drawable) {         //shows the class in the jAER window
    if ((drawable == null) || (chip.getCanvas() == null) || !classifyEvents || model == null) {
        return;
    }
    titleRenderer = new TextRenderer(new Font("Helvetica", Font.PLAIN, 40));
    Rectangle2D bounds = titleRenderer.getBounds("Unkown");
    titleArea = new Rectangle((int) bounds.getWidth(), (int) bounds.getHeight());
    GL2 gl = drawable.getGL().getGL2();
    gl.glColor3f(1, 1, 1);
    gl.glRasterPos3f(10, 10, 0);
    titleRenderer.beginRendering(drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
    titleRenderer.setColor(Color.WHITE);
    titleRenderer.draw(String.format("Class: %d", labeledClass), titleArea.x, titleArea.y);
    titleRenderer.endRendering();
    gl.glPushMatrix();
    gl.glLoadIdentity();
    gl.glTranslatef(drawable.getSurfaceWidth() / 2, drawable.getSurfaceHeight() / 2, 0);
    gl.glColor3f(1, 1, 1);
    float w = drawable.getSurfaceWidth() * lastdot * 5;
    gl.glRectf(0, -10, w, 10);
    gl.glPopMatrix();
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:24,代码来源:CochleaSVMTwoEars.java

示例2: annotate

import com.jogamp.opengl.util.awt.TextRenderer; //导入方法依赖的package包/类
@Override
    public void annotate(GLAutoDrawable drawable) {
        GL2 gl = drawable.getGL().getGL2();
//             if (textRenderer == null) {
        textRenderer = new TextRenderer(new Font("SansSerif", Font.PLAIN, 24), true, true);
        textRenderer.setColor(Color.blue);

//            }
        gl.glColor3f(0, 0, 1);
        gl.glLineWidth(2);
        final float x = chip.getSizeX() * .4f, y = (chip.getSizeY()) * .9f;
        textRenderer.begin3DRendering();
        String s = String.format("TimestampCalibrator: ts-wall: %6dms, ppmTsTooFast: %6.0f", driftTsMinusClockMs, ppmTimestampTooFastError);
        Rectangle2D r = textRenderer.getBounds(s); // width and height in pixels with scale=1
        // set scale so that width fills fraction of 
        final float scale = (float) (0.7f * (float) chip.getSizeX() / r.getWidth());
        textRenderer.draw3D(s, (float) (x - scale * r.getWidth() / 2), (float) (y - scale * r.getHeight() / 2), 0, scale);
        textRenderer.end3DRendering();
    }
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:20,代码来源:TimestampCalibrator.java

示例3: renderStarInfo

import com.jogamp.opengl.util.awt.TextRenderer; //导入方法依赖的package包/类
public void renderStarInfo(Star selectedStar, Observer obs, Rectangle2D window, GL2 gl){
    TextRenderer titleRenderer = new TextRenderer(new Font("SansSerif", Font.BOLD, 26));
    titleRenderer.setColor(0.051f, 0.596f, 0.729f, 1f);
    titleRenderer.beginRendering((int)window.getWidth(), (int)window.getHeight());
    titleRenderer.draw("HIP " + selectedStar.getHipparcos(), 0, (int)window.getHeight() - 30);
    titleRenderer.endRendering();

    TextRenderer infoRenderer = new TextRenderer(new Font("SansSerif", Font.BOLD, 15));
    infoRenderer.setColor(0.141f, 0.784f, 0.941f, 1f);
    infoRenderer.beginRendering((int)window.getWidth(), (int)window.getHeight());
    infoRenderer.draw("Magnitude: " + selectedStar.getMagnitude(), 0, (int)window.getHeight() - 55);

    String bvString = String.format("B-V Color Index %.2f", selectedStar.getBVMagnitude());
    infoRenderer.draw(bvString, 0, (int) (window.getHeight() - 75));

    EquatorialCoordinates eq = selectedStar.getEquatorialCoordinates();
    String raString = Utils.rad2String(eq.getRightAscension(), false, true);
    String decString = Utils.rad2String(eq.getDeclination(), false, false);
    infoRenderer.draw("RA/Dec(J2000): "  + raString + "/" + decString, 0, (int)window.getHeight() - 95);

    HorizontalCoordinates az = eq.toHorizontal(obs.getLongitude(), obs.getLatitude(), obs.getSideralTime());
    String azString = Utils.rad2String(az.getAzimuth() - Math.PI, true, false);
    String altString = Utils.rad2String(az.getAltitude(), false, false);
    infoRenderer.draw("Az/Alt: " + azString + " / " + altString, 0, (int)window.getHeight() - 115);
    infoRenderer.endRendering();
}
 
开发者ID:Haurentziu,项目名称:Java-Planetarium,代码行数:27,代码来源:TextInfo.java

示例4: drawText

import com.jogamp.opengl.util.awt.TextRenderer; //导入方法依赖的package包/类
public static void drawText(TextRenderer renderer, int width, int height,
                            int posX, int posY, String text, boolean outline)
{
    renderer.beginRendering(width, height);

    if (outline)
    {
        // draw text outline in black
        renderer.setColor(0.0f, 0.0f, 0.0f, 1.0f);
        renderer.draw(text, posX - 1, posY - 1);
        renderer.draw(text, posX - 1, posY);
        renderer.draw(text, posX - 1, posY + 1);

        renderer.draw(text, posX + 1, posY - 1);
        renderer.draw(text, posX + 1, posY);
        renderer.draw(text, posX + 1, posY + 1);
    }

    // draw the actual text in white
    renderer.setColor(1.0f, 1.0f, 1.0f, 1.0f);
    renderer.draw(text, posX, posY);
    renderer.endRendering();
}
 
开发者ID:vobject,项目名称:maru,代码行数:24,代码来源:GLUtils.java

示例5: paint

import com.jogamp.opengl.util.awt.TextRenderer; //导入方法依赖的package包/类
@Override
public void paint(){
	// Compute maximum width of text we're going to draw
	TextRenderer textRenderer = new TextRenderer(new Font(Font.SERIF,0 , 18));
	
    int maxTextWidth = (int) textRenderer.getBounds(this.text).getWidth();
    maxTextWidth = Math.min(maxTextWidth+10,size.width);
	
	GL2 gl=glContext.getGL2();
	gl.glClear(GL.GL_COLOR_BUFFER_BIT);
	gl.glPolygonMode (GL2.GL_FRONT, GL2.GL_LINE_STRIP);
    gl.glColor3f(0.5f, 0.5f, 0.5f);

    gl.glBegin(GL2.GL_LINE_STRIP);
    gl.glVertex2i( this.posx,this.posy);							//x1,y1
    gl.glVertex2i( this.posx+maxTextWidth,this.posy );				//x2,y1
    gl.glVertex2i( this.posx+maxTextWidth,this.posy +size.height); 	//x2,y2 
    gl.glVertex2i( this.posx,this.posy+size.height);				//x1,y2
    gl.glVertex2i( this.posx,this.posy);	
    gl.glEnd( );
    
    
    GLDrawable draw=gl.getGL().getContext().getGLDrawable();
	textRenderer.beginRendering(draw.getWidth(),draw.getHeight());
	textRenderer.setColor(Color.WHITE);
	textRenderer.setSmoothing(true);
	textRenderer.draw(this.text,(int)posx,(int)posy+5); //text and position
	textRenderer.flush();
	textRenderer.endRendering();
	
	gl.glFlush();
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:33,代码来源:GLButton.java

示例6: displayStatusChangeText

import com.jogamp.opengl.util.awt.TextRenderer; //导入方法依赖的package包/类
/** shows the status change display centered over the image
 * 
 * @param drawable the OpenGL context
 */
protected void displayStatusChangeText(GLAutoDrawable drawable) {
    if (statusChangeString == null) {
        return;
    }
    long now = System.currentTimeMillis();
    if ((now - statusChangeStartTimeMillis) > statusChangeDisplayTimeMillis) {
        statusChangeString = null;
        return;
    }
    GL2 gl = drawable.getGL().getGL2();
    TextRenderer renderer = new TextRenderer(new Font("SansSerif", Font.PLAIN, 24), true, true);
    renderer.setColor(Color.white);
    try {
        renderer.begin3DRendering();
        boolean first = true;

        Rectangle2D r = renderer.getBounds(statusChangeString);
        float scale = .5f;
        float ypos = (float) (chip.getSizeY()/2 - r.getHeight() * scale);
        float xpos = (float) (chip.getSizeX()/2 - r.getWidth()/2 * scale);
        renderer.draw3D(statusChangeString, xpos, ypos, 0, scale);
        renderer.end3DRendering();
    } catch (GLException e) {
        log.warning("caught " + e + " when trying to render text into the current OpenGL context");
    }
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:31,代码来源:DisplayMethod.java

示例7: renderTileID

import com.jogamp.opengl.util.awt.TextRenderer; //导入方法依赖的package包/类
protected void renderTileID(DrawContext dc, RectTile tile)
{
    java.awt.Rectangle viewport = dc.getView().getViewport();
    TextRenderer textRenderer = OGLTextRenderer.getOrCreateTextRenderer(dc.getTextRendererCache(),
        java.awt.Font.decode("Arial-Plain-15"));

    //GL gl = dc.getGL();
    GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
    OGLStackHandler ogsh = new OGLStackHandler();

    try
    {
        ogsh.pushAttrib(gl, GL2.GL_ENABLE_BIT);

        dc.getGL().glDisable(GL.GL_DEPTH_TEST);
        dc.getGL().glDisable(GL.GL_BLEND);

        textRenderer.beginRendering(viewport.width, viewport.height);
        textRenderer.setColor(Color.RED);
        String tileLabel = Integer.toString(tile.level);
        double[] elevs = this.globe.getMinAndMaxElevations(tile.getSector());
        if (elevs != null)
            tileLabel += ", " + (int) elevs[0] + "/" + (int) elevs[1];

        LatLon ll = tile.getSector().getCentroid();
        Vec4 pt = dc.getGlobe().computePointFromPosition(ll.getLatitude(), ll.getLongitude(),
            dc.getGlobe().getElevation(ll.getLatitude(), ll.getLongitude()));
        pt = dc.getView().project(pt);
        textRenderer.draw(tileLabel, (int) pt.x, (int) pt.y);
        textRenderer.setColor(Color.WHITE);
        textRenderer.endRendering();
    }
    finally
    {
        ogsh.pop(gl);
    }
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:38,代码来源:MYEBSRectangularTessellator.java

示例8: drawTileIDs

import com.jogamp.opengl.util.awt.TextRenderer; //导入方法依赖的package包/类
protected void drawTileIDs(DrawContext dc, ArrayList<TextureTile> tiles)
{
	java.awt.Rectangle viewport = dc.getView().getViewport();
	TextRenderer textRenderer = OGLTextRenderer.getOrCreateTextRenderer(dc.getTextRendererCache(),
		java.awt.Font.decode("Arial-Plain-13"));
	
	GL gl = dc.getGL();
	gl.glDisable(GL.GL_DEPTH_TEST);
	gl.glDisable(GL.GL_BLEND);
	gl.glDisable(GL.GL_TEXTURE_2D);

	textRenderer.beginRendering(viewport.width, viewport.height);
	textRenderer.setColor(java.awt.Color.YELLOW);
	for (TextureTile tile : tiles)
	{
		String tileLabel = tile.getLabel();

		if (tile.getFallbackTile() != null)
			tileLabel += "/" + tile.getFallbackTile().getLabel();

		LatLon ll = tile.getSector().getCentroid();
		Vec4 pt = dc.getGlobe().computePointFromPosition(ll.getLatitude(), ll.getLongitude(),
			dc.getGlobe().getElevation(ll.getLatitude(), ll.getLongitude()));
		pt = dc.getView().project(pt);
		textRenderer.draw(tileLabel, (int) pt.x, (int) pt.y);
	}
	textRenderer.setColor(java.awt.Color.WHITE);
	textRenderer.endRendering();
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:30,代码来源:ScalingTiledImageLayer.java

示例9: renderFloat

import com.jogamp.opengl.util.awt.TextRenderer; //导入方法依赖的package包/类
@Override
public void renderFloat(Camera camera, Viewport vp, GL2 gl) {
    if (!isVisible[vp.idx])
        return;

    String text = Movie.getTime().toString();
    if (Displayer.multiview) {
        ImageLayer im = ImageLayers.getImageLayerInViewport(vp.idx);
        if (im != null) {
            text = im.getTimeString() + ' ' + im.getName();
        }
    }

    int delta = (int) (vp.height * 0.01);
    int size = (int) (vp.height * (scale * 0.01 * 0.015));

    if (GLInfo.pixelScale[1] == 1) //! nasty
        size *= 2;

    TextRenderer renderer = GLText.getRenderer(size);
    renderer.beginRendering(vp.width, vp.height, true);
    renderer.setColor(Color.BLACK);
    renderer.draw(text, delta, delta);
    renderer.setColor(Color.WHITE);
    renderer.draw(text, delta + 1, delta + 1);
    renderer.endRendering();
}
 
开发者ID:Helioviewer-Project,项目名称:JHelioviewer-SWHV,代码行数:28,代码来源:TimestampLayer.java

示例10: perspectiveText

import com.jogamp.opengl.util.awt.TextRenderer; //导入方法依赖的package包/类
/**
 * Draws a string in perspective in the current color, with the given font, at the given position
 * 
 * @param string
 *            the string to draw
 * @param font
 *            the font to use
 * @param x,y,z
 *            the coordinates
 * @param scale
 *            the scale to apply
 */
public void perspectiveText(final String string, final Font font, final double x, final double y, final double z) {
	final TextRenderer r =
			textRendererCache.get(font.getName(), font.getSize() * (int) layerScalingFactor, font.getStyle());
	if (r == null) { return; }
	r.setUseVertexArrays(false);

	if (getCurrentColor() != null)
		r.setColor(getCurrentColor());
	final float scale = 1f / (float) (viewHeight / getWorldHeight());
	r.begin3DRendering();
	r.draw3D(string, (float) x, (float) y, (float) (z + currentZTranslation), scale);
	r.flush();
	r.end3DRendering();
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:27,代码来源:OpenGL.java

示例11: perspectiveOrthoText

import com.jogamp.opengl.util.awt.TextRenderer; //导入方法依赖的package包/类
public void perspectiveOrthoText(final String string, final Font font, final double x, final double y,
		final double z) {
	final TextRenderer r =
			textRendererCache.get(font.getName(), font.getSize() * (int) layerScalingFactor, font.getStyle());
	if (r == null) { return; }
	r.setUseVertexArrays(false);
	if (getCurrentColor() != null)
		r.setColor(getCurrentColor());
	final float scale = 1f / (float) (viewHeight / getWorldHeight());
	r.beginRendering(1, 1);
	r.draw3D(string, (float) x, (float) y, (float) z, scale);
	r.flush();
	r.endRendering();
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:15,代码来源:OpenGL.java

示例12: drawString

import com.jogamp.opengl.util.awt.TextRenderer; //导入方法依赖的package包/类
/**
 *
 * @todo Write documentation
 * @param string
 * @param position
 * @param font
 * @param color
 * @since 0.1
 */
public void drawString(String string, Vector2 position, Font font, Color color)
{
	if (game.getWindow().getCanvas().getGL().getGL2() != null)
	{
		TextRenderer renderer = new TextRenderer(font);
		renderer.setColor(color);
		renderer.beginRendering(game.getWindow().getCanvas().getWidth(), game.getWindow().getCanvas().getHeight());
		renderer.draw(string, (int) position.x, (int) (game.getWindow().getCanvas().getHeight() - position.y - renderer.getBounds(string).getHeight()));
		renderer.endRendering();
	}
}
 
开发者ID:TheAtlas,项目名称:Atlas-Game-Framework,代码行数:21,代码来源:SpriteBatch.java

示例13: doInit

import com.jogamp.opengl.util.awt.TextRenderer; //导入方法依赖的package包/类
@Override
protected boolean doInit(GL2ES2 gl) {
	program = CompassProgram.INSTANCE;
	program.init(gl);
	
	Astroid3f astroid = new Astroid3f(1, 8);
	
	vertices = Buffers.newDirectByteBuffer(astroid.triangles.length * 24);
	for (int i = 0; i < astroid.triangles.length; i++) {
		float[] point = astroid.points[astroid.triangles[i]];
		float[] normal = astroid.normals[astroid.triangles[i]];
		vertices.putFloat(point[0]);
		vertices.putFloat(point[1]);
		vertices.putFloat(point[2]);
		vertices.putFloat(normal[0]);
		vertices.putFloat(normal[1]);
		vertices.putFloat(normal[2]);
	}
	vertices.rewind();

	StaticRenderer.Options options = new StaticRenderer.Options(true, GL.GL_TRIANGLES);
	options.addAttribute(3, GL.GL_FLOAT, false);
	options.addAttribute(3, GL.GL_FLOAT, false);
	renderer = new StaticRenderer(vertices, options);
	renderer.init(gl);
	
	textRenderer = new TextRenderer(labelFont, true, true, null, false);
	textRenderer.init();
	textRenderer.setUseVertexArrays(true);
	textRenderer.setColor(Color.WHITE);

	return true;
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:34,代码来源:Compass.java

示例14: DrawNode

import com.jogamp.opengl.util.awt.TextRenderer; //导入方法依赖的package包/类
public void DrawNode(int base, HeatNode lum, GL2 gl) {
	
	double [] color = lum.getBGColor();
	double opacity = lum.getOpacity();

	// Draw the background
	gl.glColor4d (color[0], color[1], color[2], opacity);
	//Painter.DrawHexagon(GL2.GL_POLYGON, 0, 0, base, gl);

	// Draw the graphical hexagon
	if (lum.getSelected() == true)
		Painter.DrawImageHex(TexturePool.get("hexagon2"), GL2.GL_DECAL, 0.0, 0.0, 2 * base / 512.0, 0, opacity, gl);
	else
		Painter.DrawImageHex(TexturePool.get("hexagon1"), GL2.GL_DECAL, 0.0, 0.0, 2 * base / 512.0, 0, opacity, gl);

	// Draw the server image
	int imageSize = 200;
	gl.glColor4d (0.0, 0.0, 0.0, opacity);
	if (lum.getSelected() == true)
		Painter.DrawImageHex (TexturePool.get(lum.getTexture()), GL2.GL_BLEND, 0.0, 0.0, imageSize / 512.0, 90.0, opacity, gl);
	else
		Painter.DrawImageHex (TexturePool.get(lum.getTexture()), GL2.GL_BLEND, 0.0, 0.0, imageSize / 512.0, 0.0, opacity, gl);

	// Write the name of the node
	TextRenderer renderer = TextRendererPool.get("basic");
	renderer.begin3DRendering();
		renderer.setSmoothing(true);
		renderer.setUseVertexArrays(true);
		double [] bgcol = lum.getBGColor();
		if (bgcol[0] + bgcol[1] + bgcol[2] < 1.5)
			renderer.setColor (1.0f, 1.0f, 1.0f, (float) opacity);
		else
			renderer.setColor (0.0f, 0.0f, 0.0f, (float) opacity);
		
		Rectangle2D noob = renderer.getBounds(lum.GetName());
		
		float scale = 1.0f;
		
		if (noob.getWidth() > base)
			scale = 0.7f;
		
		int xx = (int) (-scale * noob.getWidth() / 2);
		int yy = (int) (-imageSize / 2 - scale * noob.getHeight() - 30);
		renderer.draw3D (lum.GetName(), xx, yy, 1.0f, scale);
		
		noob = renderer.getBounds(lum.maxProto);
		xx = (int) (-noob.getWidth() / 2);
		yy = (int) (+imageSize / 2 + 30);
		renderer.draw(lum.maxProto, xx, yy);

	renderer.end3DRendering();
}
 
开发者ID:ryft,项目名称:NetVis,代码行数:53,代码来源:MapPainter.java


注:本文中的com.jogamp.opengl.util.awt.TextRenderer.setColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。