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


Java TextRenderer.getBounds方法代码示例

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


在下文中一共展示了TextRenderer.getBounds方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: createComponents

import com.jogamp.opengl.util.awt.TextRenderer; //导入方法依赖的package包/类
/**
 * Create the components.
 */
@Override
protected void createComponents(GL2 gl) {
	axisLabelRenderer = new TextRenderer(new Font("Helvetica", Font.PLAIN, 12));
	textRenderer = new TextRenderer(new Font("Helvetica", Font.PLAIN, 10));

	axesLabels = new String[2];
	axisLabelAreas = new Rectangle[axesLabels.length];
	for (int i = 0; i < axesLabels.length; i++) {
		StringBuilder buf = new StringBuilder();
		//            for(Category s : categories) {
		Category s = categories[0];
		buf.append(s.axes[i].title);
		if (s.axes[i].unit != null) {
			buf.append(" [" + s.axes[i].unit + "]");
		}
		buf.append('\n');
		//            }
		String str = buf.toString();
		axesLabels[i] = str.substring(0, str.length() - 1);
		Rectangle2D bounds = axisLabelRenderer.getBounds(axesLabels[i]);
		axisLabelAreas[i] = new Rectangle((int) bounds.getWidth(), (int) bounds.getHeight());
	}
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:27,代码来源:XYChart.java

示例4: init

import com.jogamp.opengl.util.awt.TextRenderer; //导入方法依赖的package包/类
/**
 * Initialize the view for OpenGL drawing.
 */
@Override
public void init(GLAutoDrawable drawable) {
	running = true;
	GL2 gl = drawable.getGL().getGL2();

	// background color
	float[] bg = new float[4];
	getBackground().getColorComponents(bg);
	gl.glClearColor(bg[0], bg[1], bg[2], bg[3]);

	// title
	titleRenderer = new TextRenderer(new Font("Helvetica", Font.PLAIN, 16));
	Rectangle2D bounds = titleRenderer.getBounds(title);
	titleArea = new Rectangle((int) bounds.getWidth(), (int) bounds.getHeight());

	/* create grid drawing routine */
	gridId = gl.glGenLists(1);
	gl.glNewList(gridId, GL2.GL_COMPILE);
	drawStaticBackground(gl);
	gl.glEndList();

	createComponents(drawable.getGL().getGL2());
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:27,代码来源:Chart.java

示例5: CochleaGenderClassifier

import com.jogamp.opengl.util.awt.TextRenderer; //导入方法依赖的package包/类
public CochleaGenderClassifier (AEChip chip){
    super(chip);
    setNBins(weights.length);
    setMaxIsiUs(9000);
    setMinIsiUs(3000);
    setDirection(Direction.XtimesYDirection);
    titleRenderer = new TextRenderer(new Font("Helvetica",Font.PLAIN,48));
    Rectangle2D bounds = titleRenderer.getBounds(Gender.Unknown.toString());
    titleArea = new Rectangle((int)bounds.getWidth(),(int)bounds.getHeight());
    setPropertyTooltip("Gender params","genderThreshold","threshold for abs(dot product) to classify as (female) speaker. If abs(dot)<genderThreshold then sex is Unknown.");
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:12,代码来源:CochleaGenderClassifier.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: 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

示例8: draw3dScale

import com.jogamp.opengl.util.awt.TextRenderer; //导入方法依赖的package包/类
/**
 * Computes the required scale used in TextRenderer.draw3D
 *
 * @param textRenderer the TextRenderer
 * @param string the rendered String
 * @param screenPixelsPerChipPixel the scaling of screen pixels per chip
 * pixel, e.g. chip.getCanvas().getScale()
 * @param pixelWidth the width (or height), generally in AEChip pixels if rendering onto AEViewer display
 * @param fractionToFill the fraction of pixelWidth to fill with string
 * @return the scale that should be passed to draw3D to render text
 *
 */
public static float draw3dScale(TextRenderer textRenderer, String string, float screenPixelsPerChipPixel, int pixelWidth, float fractionToFill) {
    FontRenderContext frc = textRenderer.getFontRenderContext();
    Rectangle2D r = textRenderer.getBounds(string);
    Rectangle2D rt = frc.getTransform().createTransformedShape(r).getBounds2D();
    float ps = screenPixelsPerChipPixel;
    float w = (float) rt.getWidth() * ps;
    float scale = fractionToFill * ps * pixelWidth / w;
    return scale;
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:22,代码来源:TextRendererScale.java


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