public boolean isActual(Editor editor, String familyName, int size) { Font font = metrics.getFont(); if (!familyName.equals(font.getFamily()) || size != font.getSize()) return false; FontRenderContext currentContext = getCurrentContext(editor); return currentContext.equals(metrics.getFontRenderContext()); }
@Override public void paint(@NotNull Inlay inlay, @NotNull Graphics g, @NotNull Rectangle targetRegion, @NotNull TextAttributes textAttributes) { Editor editor = inlay.getEditor(); FontMetrics fontMetrics = getFontMetrics(editor).metrics; LineMetrics lineMetrics = fontMetrics.getLineMetrics(text, g); g.setColor(JBColor.GRAY); g.setFont(fontMetrics.getFont()); g.drawString(text, 0, targetRegion.y + (int)(lineMetrics.getHeight() - lineMetrics.getDescent())); g.setColor(JBColor.LIGHT_GRAY); g.drawRect(targetRegion.x, targetRegion.y, targetRegion.width, targetRegion.height); }
protected String paramString() { return "space, " + super.paramString() + ", " + (metrics == null ? "" : "font ascent=" + metrics.getAscent() + ", descent=" + metrics.getDescent() + ", height=" + metrics.getHeight() + ", " + "font=" + metrics.getFont()) + ", boffset=" + beginOffset + ", eoffset=" + endOffset; }
protected String paramString() { return super.paramString() + ", " + "font ascent=" + metrics.getAscent() + ", descent=" + metrics.getDescent() + ", height=" + metrics.getHeight() + ", " + "font=" + metrics.getFont(); }
public void drawInto(Graphics g) { if (!visible) return; Font font = g.getFont(); Color temp = g.getColor(); g.setColor(color); g.setFont(fm.getFont()); g.drawString(string, x, y); g.setColor(temp); g.setFont(font); }
public Font getFont() { checkInitialized(); return fontMetrics.getFont(); }
public Font getFont() { checkInitialized(); return fontMetrics.getFont(); }
@Override public void drawInto(Graphics g) { if (!visible) return; Font font = g.getFont(); Color temp = g.getColor(); g.setColor(color); g.setFont(fm.getFont()); int currentY = y; for(String s : labels) { g.drawString(s, x, currentY); currentY += fm.getHeight(); } g.setColor(temp); g.setFont(font); }
protected String paramString() { return "text=\"" + (contentChars == null ? null : getText()) + "\", " + super.paramString() + (metrics == null ? "" : ", font ascent=" + metrics.getAscent() + ", descent=" + metrics.getDescent() + ", height=" + metrics.getHeight() + ", font=" + metrics.getFont()) + ", boffset=" + beginOffset + ", eoffset=" + endOffset; }
/** * Internal method to add a line of text to this area. This is not intended * for public use, because it performs no checks whatsoever whether the line * will fit. * * @param text Text on the line. * @param fontMetrics Font including rendering information. * @param color Color of the text. */ protected void addLine( final String text, final FontMetrics fontMetrics, final Color color ) { if ( _closed ) { throw new IllegalStateException( "closed!" ); } _lines.add( new Line( text, fontMetrics.getFont(), color, _textHeight + fontMetrics.getAscent() ) ); _textHeight += fontMetrics.getHeight(); }
final private int drawFeatureName(IGVFeature feature, Track.DisplayMode mode, int pixelStart, int pixelEnd, int lastFeatureEndedAtPixelX, Graphics2D g2D, int textBaselineY) { String name = feature.getName(); if (name == null) { return lastFeatureEndedAtPixelX; } FontMetrics fm = g2D.getFontMetrics(); int fontSize = fm.getFont().getSize(); int nameWidth = fm.stringWidth(name); int nameStart = (pixelStart + pixelEnd - nameWidth) / 2; Rectangle2D sb = fm.getStringBounds(name, g2D); if (nameStart > (lastFeatureEndedAtPixelX + fontSize) && sb.getWidth() < g2D.getClipBounds().getWidth()) { // g2D.clearRect(xString2, textBaselineY, (int) stringBounds.getWidth(), (int) stringBounds.getHeight()); g2D.drawString(name, nameStart, textBaselineY); lastFeatureEndedAtPixelX = nameStart + nameWidth; drawnNames.add(name); } return lastFeatureEndedAtPixelX; }
public Word(final String word, final Color color, final FontMetrics fontMetrics, final CollisionChecker collisionChecker) { this.word = word; this.color = color; this.collisionChecker = collisionChecker; // get the height of a line of text in this font and render context final int maxDescent = fontMetrics.getMaxDescent(); // get the advance of my text in this font and render context final int width = fontMetrics.stringWidth(word); this.bufferedImage = new BufferedImage(width, fontMetrics.getHeight(), BufferedImage.TYPE_INT_ARGB); final Graphics2D graphics = (Graphics2D) this.bufferedImage.getGraphics(); graphics.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB); graphics.setColor(color); graphics.setFont(fontMetrics.getFont()); graphics.drawString(word, 0, fontMetrics.getHeight() - maxDescent); this.collisionRaster = new CollisionRaster(this.bufferedImage); }
protected int getWidthOfLine(String line) { initFontMetrics(); if (line == null || line.isEmpty()) { return 0; } TextLayout tl = new TextLayout( line, this.fm.getFont(), this.g.getFontRenderContext() ); int advance = (int) Math.ceil(tl.getAdvance()); return advance; }
protected int getWidthOfLine(String line) { initFontMetrics(); if (line == null || line.isEmpty()) { return 0; } TextLayout tl = new TextLayout( line, this.fm.getFont(), this.g.getFontRenderContext() ); int advance = (int) Math.ceil(tl.getAdvance()); return advance; }
public void drawStringExponentShadow(String text, String exponent, int x, int y) { this.drawStringShadow(text, x, y); FontMetrics fm = screen.getFontMetrics(); float lastSize = fm.getFont().getSize2D(); float h = lastSize * 0.7f; int w = fm.stringWidth(text); this.setFontSize(h); this.drawStringShadow(exponent, x + w, (int) (y - h * 0.5f)); this.setFontSize(lastSize); }
public void drawStringExponentShadow(String text, String exponent, int x, int y) { this.drawStringShadow(text, x, y); FontMetrics fm = screen.getFontMetrics(); float lastSize = fm.getFont().getSize2D(); float h = lastSize*0.7f; int w = fm.stringWidth(text); this.setFontSize(h); this.drawStringShadow(exponent, x+w, (int)(y-h*0.5f)); this.setFontSize(lastSize); }
/** * @param text * @param exponent * @param x * @param y */ public void drawStringExponent(String text, String exponent, int x, int y) { this.drawString(text, x, y); FontMetrics fm = screen.getFontMetrics(); float lastSize = fm.getFont().getSize2D(); float h = lastSize * 0.7f; int w = fm.stringWidth(text); this.setFontSize(h); this.drawString(exponent, x + w, (int) (y - h * 0.5f)); this.setFontSize(lastSize); }
protected void addGrayItalicText(CreateContext context, Element styleElement, String text) { FontMetrics metrics = null; if (styleElement != null) { // metrics = CssLookup.getFontMetrics(styleElement); // metrics = CssProvider.getValueService().getFontMetricsForElement(styleElement); metrics = CssUtilities.getDesignerFontMetricsForElement(styleElement, text, webform.getDefaultFontSize()); Font font = metrics.getFont(); font = font.deriveFont(Font.ITALIC); // metrics = Toolkit.getDefaultToolkit().getFontMetrics(font); metrics = DesignerUtils.getFontMetrics(font); } if (metrics == null) { metrics = context.metrics; } addText(text, styleElement, null, context, metrics, Color.GRAY, null, 0, true, false); }
/** * * @param text * @param exponent * @param x * @param y */ public void drawStringExponent(String text, String exponent, int x, int y) { this.drawString(text, x, y); FontMetrics fm = screen.getFontMetrics(); float lastSize = fm.getFont().getSize2D(); float h = lastSize*0.7f; int w = fm.stringWidth(text); this.setFontSize(h); this.drawString(exponent, x+w, (int)(y-h*0.5f)); this.setFontSize(lastSize); }
/** * Synchronize this painter with the current state of the view. * * @param v Sync to this view. */ @SuppressWarnings("deprecation") void sync(GlyphView v) { Font f = v.getFont(); if ((metrics == null) || (!f.equals(metrics.getFont()))) { // fetch a new FontMetrics Toolkit kit; Component c = v.getContainer(); if (c != null) { kit = c.getToolkit(); } else { kit = Toolkit.getDefaultToolkit(); } metrics = kit.getFontMetrics(f); } }