protected FontMetrics pickFont(Graphics2D g2, Tree tree, Dimension space) { Font font = g2.getFont(); String fontName = font.getName(); int style = font.getStyle(); for (int size = maxFontSize; size > minFontSize; size--) { font = new Font(fontName, style, size); g2.setFont(font); FontMetrics fontMetrics = g2.getFontMetrics(); if (height(tree, fontMetrics) > space.getHeight()) { continue; } if (width(tree, fontMetrics) > space.getWidth()) { continue; } //System.out.println("Chose: "+size+" for space: "+space.getWidth()); return fontMetrics; } font = new Font(fontName, style, minFontSize); g2.setFont(font); return g2.getFontMetrics(); }
@Getter protected Font getFont() { return gc.getFont(); }
Font font = graphics.getFont();
public static void drawCenteredShadowText(Graphics2D g2, String s, int x, int y, Color shadowColor) { FontRenderContext frc = g2.getFontRenderContext(); Rectangle2D bounds = g2.getFont().getStringBounds(s, frc); int leftX = (int) (x - (float) bounds.getWidth() / 2); drawShadowText(g2, s, leftX, y, shadowColor, 1); }
Font font; if ("".equals(fontName)) { font = g2.getFont(); fontName = font.getName(); style = font.getStyle();
protected void drawText(XDGFShape shape) { XDGFText text = shape.getText(); if (text != null) { if (text.getTextContent().equals("Header")) text.getTextBounds(); Font oldFont = _graphics.getFont(); _graphics.setFont(oldFont.deriveFont(shape.getFontSize() .floatValue())); _graphics.setColor(shape.getFontColor()); text.draw(_graphics); _graphics.setFont(oldFont); } }
final List<Rectangle2D> bounds = new ArrayList<Rectangle2D>(); final int length = message.length(); final Font font = graphics.getFont(); final FontRenderContext context = graphics.getFontRenderContext(); for (int i = 0; i < length; ) {
g.drawImage(europaBackground.getImage(), 0, 0, translator.getImageWidth(), translator.getImageHeight(), this); g.setFont(g.getFont().deriveFont((float) LOCATION_NAME_TEXT_SIZE)); g.setColor(TangoColorFactory.PLUM_2); List<Visit> visitList = tspSolution.getVisitList(); if (score != null) { String distanceString = tspSolution.getDistanceString(NUMBER_FORMAT); g.setFont(g.getFont().deriveFont(Font.BOLD, (float) TEXT_SIZE * 2)); g.drawString(distanceString, (int) width - g.getFontMetrics().stringWidth(distanceString) - 10, (int) height - 15 - 2 * TEXT_SIZE);
@Override protected Path2D drawPath(XDGFShape shape) { Path2D path = super.drawPath(shape); if (_debugAcceptor == null || _debugAcceptor.accept(shape)) { // show numbers to associate shapes with ids.. doesn't always work Font f = _graphics.getFont(); _graphics.scale(1, -1); _graphics.setFont(f.deriveFont(0.05F)); String shapeId = "" + shape.getID(); float shapeOffset = -0.1F; if (shape.hasMasterShape()) { shapeId += " MS:" + shape.getMasterShape().getID(); shapeOffset -= 0.15F; } _graphics.drawString(shapeId, shapeOffset, 0); _graphics.setFont(f); _graphics.scale(1, -1); } return path; }
g.setFont(g.getFont().deriveFont((float) TEXT_SIZE)); g.setStroke(TangoColorFactory.NORMAL_STROKE); for (Customer customer : solution.getCustomerList()) { distanceString = solution.getDistanceString(NUMBER_FORMAT); g.setFont(g.getFont().deriveFont(Font.BOLD, (float) TEXT_SIZE * 2)); g.drawString(distanceString, (int) width - g.getFontMetrics().stringWidth(distanceString) - 10, (int) height - 10 - TEXT_SIZE);
@Override protected void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; if (isEnabled()) { g2.setColor(Theme.TEXT_NORMAL_COLOR); } else { g2.setColor(Theme.TEXT_DISABLED_COLOR); } g2.setFont(Theme.SMALL_BOLD_FONT); int textX = Theme.LABEL_WIDTH - g2.getFontMetrics().stringWidth(getText()) - 10; // Add some padding to align it to 30px high components. int textY = (getHeight() - g2.getFont().getSize()) / 2 + 10; SwingUtils.drawShadowText(g2, getText(), textX, textY, Theme.DEFAULT_SHADOW_COLOR, 1); } }
@Override public Font getFont() { return groupG2D.getFont(); }
public Font getFont() { return delegate.getFont(); }
void setTextFace(final int face) { int style = 0; if ((face & QuickDraw.TX_BOLD_MASK) > 0) { style |= Font.BOLD; } if ((face & QuickDraw.TX_ITALIC_MASK) > 0) { style |= Font.ITALIC; } // TODO: Other face options, like underline, shadow, etc... graphics.setFont(graphics.getFont().deriveFont(style)); }
public void setTextSize(int pSize) { graphics.setFont(graphics.getFont().deriveFont((float) pSize)); }
g.setFont(g.getFont().deriveFont((float) LOCATION_NAME_TEXT_SIZE)); for (Bus bus : busList) { RoadLocation location = bus.getLocation();
public void setTextFont(final String fontName) { // TODO: Need mapping between known QD font names and Java font names? Font current = graphics.getFont(); graphics.setFont(Font.decode(fontName).deriveFont(current.getStyle(), (float) current.getSize())); }
private void setup(Graphics2D graphics) { originalColor = graphics.getColor(); originalStroke = graphics.getStroke(); originalFont = graphics.getFont(); graphics.setFont(new Font(FontGlyphReader.FONT_SANSSERIF, Font.PLAIN, 14)); graphics.setColor(bandColor); graphics.setXORMode(Color.white); }