private void recomputeFPSSize(float fps) { String fpsText; int magnitude; if (fps >= 10000) { fpsText = "10000.00"; magnitude = 5; } else if (fps >= 1000) { fpsText = "1000.00"; magnitude = 4; } else if (fps >= 100) { fpsText = "100.00"; magnitude = 3; } else if (fps >= 10) { fpsText = "10.00"; magnitude = 2; } else { fpsText = "9.00"; magnitude = 1; } if (magnitude > this.fpsMagnitude) { Rectangle2D bounds = renderer.getBounds("FPS: " + fpsText); fpsWidth = (int) bounds.getWidth(); fpsHeight = (int) bounds.getHeight(); fpsOffset = (int) (fpsHeight * 0.5f); this.fpsMagnitude = magnitude; } } }
Rectangle2D bounds = renderer.getBounds(text); int width = (int) bounds.getWidth(); int height = (int) bounds.getHeight();
/** Returns the bounding rectangle of the given String, assuming it was rendered at the origin. See {@link #getBounds(CharSequence) getBounds(CharSequence)}. */ public Rectangle2D getBounds(final String str) { return getBounds((CharSequence) str); }
protected BoundingSphere computeBoundingSphere(boolean finite) { Rectangle2D rect = _renderer.getBounds(_text); double w = rect.getWidth(); double h = rect.getHeight(); return new BoundingSphere(0.0,0.0,0.0,sqrt(w*w+h*h)); } }
/** * 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(); }
final String string = getOptions().get(i); if (string != null) { Rectangle2D bounds = renderer.getBounds(string); maxwidth = Math.max(bounds.getWidth(), maxwidth);
private void displayLinkIds(Map<Coord, String> linkIds, GLAutoDrawable glAutoDrawable, Rect rect) { TextRenderer textRenderer = new TextRenderer(new Font("SansSerif", Font.PLAIN, 32), true, false); String testText = "0000000"; Rectangle2D test = textRenderer.getBounds(testText); Map<Coord, Boolean> xymap = new HashMap<>(); // Why is here a Map used, and not a Set? double xRaster = test.getWidth(), yRaster = test.getHeight();
@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(); }
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(); }
final String string = getOptions().get(i); if (string != null) { bounds[i] = renderer.getBounds(string); maxwidth = Math.max(bounds[i].getWidth(), maxwidth);
/** * 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(); }
int h = dc.getViewCanvas().getHeight(); Rectangle2D rect = _renderer.getBounds(_text); double rw = rect.getWidth(); double rh = rect.getHeight();
for(int i = 0; i < shared.dim; i++) { if(shared.labels[i] != null) { Rectangle2D b = shared.textrenderer.getBounds(shared.labels[i]); float scale = defaultscale; if(Math.max(b.getWidth(), b.getHeight() * minratio) * scale > targetwidth) {
@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); } }
final float scale = 0.003f; final Rectangle2D nameBounds = this.textRenderer.getBounds( config.getName() ); this.textRenderer.draw3D( config.getName(), (float)(1-nameBounds.getWidth()*scale), (float)(-nameBounds.getHeight()*scale)
Rectangle2D textBounds = textRenderer.getBounds(activityEntry.name); textRenderer.end3DRendering();
Rectangle2D r = renderer.getBounds(txt);