BufferedImage bi = gc.createCompatibleImage(w, h); Graphics2D g2 = ge.createGraphics(bi); g2.setBackground(new Color(Math.abs(r++), Math.abs(g++), Math.abs(b++))); g2.clearRect(0, 0, w, h);
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); env.createGraphics(BufferedImage);
UIDefaults uidefs=UIManager.getLookAndFeelDefaults(); Font font=uidefs.getFont("ToolTip.font"); GraphicsEnvironment ge=GraphicsEnvironment.getLocalGraphicsEnvironment(); Graphics2D g2d=ge.createGraphics(new BufferedImage(1,1,1)); FontMetrics fontMetrics=g2d.getFontMetrics(); Top_Line_Width=fontMetrics.stringWidth("Toptip text");
public void setSize(int size) { if (size > 0) { this.size = size; font = MATERIALDESIGNICONFONT.deriveFont(Font.PLAIN, size); BufferedImage tmp = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = GraphicsEnvironment.getLocalGraphicsEnvironment().createGraphics(tmp); g2.setFont(font); this.width = g2.getFontMetrics().charWidth(materialDesignIconFont.getCode()); this.height = g2.getFontMetrics().getHeight(); g2.dispose(); synchronized (LOCK) { buffer = null; } } }
String text = "Hello world!"; Font font = new Font(Font.SERIF, Font.PLAIN, 12); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); BufferedImage bufferedImage = new BufferedImage(1,1,BufferedImage.TYPE_INT_RGB); Graphics2D g2d = ge.createGraphics(bufferedImage); FontRenderContext frc = g2d.getFontRenderContext(); GlyphVector glyphVector = font.createGlyphVector(frc, text); Rectangle2D rectangle2D = glyphVector.getLogicalBounds(); double w = rectangle2D.getWidth(); double h = rectangle2D.getHeight(); System.out.println("width = "+w+"\theight = "+h);
public void setSize(int size) { if (size > 0) { this.size = size; font = FONTELICO.deriveFont(Font.PLAIN, size); BufferedImage tmp = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = GraphicsEnvironment.getLocalGraphicsEnvironment().createGraphics(tmp); g2.setFont(font); this.width = g2.getFontMetrics().charWidth(fontelico.getCode()); this.height = g2.getFontMetrics().getHeight(); g2.dispose(); synchronized (LOCK) { buffer = null; } } }
public void setSize(int size) { if (size > 0) { this.size = size; font = TYPICONFONT.deriveFont(Font.PLAIN, size); BufferedImage tmp = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = GraphicsEnvironment.getLocalGraphicsEnvironment().createGraphics(tmp); g2.setFont(font); this.width = g2.getFontMetrics().charWidth(typIconFont.getCode()); this.height = g2.getFontMetrics().getHeight(); g2.dispose(); synchronized (LOCK) { buffer = null; } } }
public void setSize(int size) { if (size > 0) { this.size = size; font = FOUNDATION.deriveFont(Font.PLAIN, size); BufferedImage tmp = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = GraphicsEnvironment.getLocalGraphicsEnvironment().createGraphics(tmp); g2.setFont(font); this.width = g2.getFontMetrics().charWidth(foundation.getCode()); this.height = g2.getFontMetrics().getHeight(); g2.dispose(); synchronized (LOCK) { buffer = null; } } }
public SystemFontMetrics(String fontName) { BufferedImage img = new BufferedImage(40, 40, BufferedImage.TYPE_4BYTE_ABGR); Graphics2D graphics = GraphicsEnvironment.getLocalGraphicsEnvironment().createGraphics(img); FontRenderContext fontRenderContext = graphics.getFontRenderContext(); this.font = new Font(fontName, Font.PLAIN, 1000); double maxHeight = 0; for (int i = 0; i < 255; i++) { TextLayout layout = new TextLayout(Character.toString((char)i), font, fontRenderContext); maxHeight = Math.max(maxHeight, layout.getBounds().getHeight()); super.widths[i] = (int)layout.getAdvance(); } super.maxCharHeight = (int)Math.round(maxHeight); }
public void setSize(int size) { if (size > 0) { this.size = size; font = AWESOME.deriveFont(Font.PLAIN, size); BufferedImage tmp = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = GraphicsEnvironment.getLocalGraphicsEnvironment().createGraphics(tmp); g2.setFont(font); this.width = g2.getFontMetrics().charWidth(fontAwesome.getCode()); this.height = g2.getFontMetrics().getHeight(); g2.dispose(); synchronized (LOCK) { buffer = null; } } }
public void setSize(int size) { if (size > 0) { this.size = size; font = DEVICONFONT.deriveFont(Font.PLAIN, size); BufferedImage tmp = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = GraphicsEnvironment.getLocalGraphicsEnvironment().createGraphics(tmp); g2.setFont(font); this.width = g2.getFontMetrics().charWidth(devIconFont.getCode()); this.height = g2.getFontMetrics().getHeight(); g2.dispose(); synchronized (LOCK) { buffer = null; } } }
public void setSize(int size) { if (size > 0) { this.size = size; font = OCTICONFONT.deriveFont(Font.PLAIN, size); BufferedImage tmp = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = GraphicsEnvironment.getLocalGraphicsEnvironment().createGraphics(tmp); g2.setFont(font); this.width = g2.getFontMetrics().charWidth(octIconFont.getCode()); this.height = g2.getFontMetrics().getHeight(); g2.dispose(); synchronized (LOCK) { buffer = null; } } }
public void setSize(int size) { if (size > 0) { this.size = size; font = WEATHERICONFONT.deriveFont(Font.PLAIN, size); BufferedImage tmp = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = GraphicsEnvironment.getLocalGraphicsEnvironment().createGraphics(tmp); g2.setFont(font); this.width = g2.getFontMetrics().charWidth(weatherIconFont.getCode()); this.height = g2.getFontMetrics().getHeight(); g2.dispose(); synchronized (LOCK) { buffer = null; } } }
public SystemFontMetrics(String fontName) { BufferedImage img = new BufferedImage(40, 40, BufferedImage.TYPE_4BYTE_ABGR); Graphics2D graphics = GraphicsEnvironment.getLocalGraphicsEnvironment().createGraphics(img); FontRenderContext fontRenderContext = graphics.getFontRenderContext(); this.font = new Font(fontName, Font.PLAIN, 1000); double maxHeight = 0; for (int i = 0; i < 255; i++) { TextLayout layout = new TextLayout(Character.toString((char)i), font, fontRenderContext); maxHeight = Math.max(maxHeight, layout.getBounds().getHeight()); super.widths[i] = (int)layout.getAdvance(); } super.maxCharHeight = (int)Math.round(maxHeight); }
public SystemFontMetrics(String fontName) { BufferedImage img = new BufferedImage(40, 40, BufferedImage.TYPE_4BYTE_ABGR); Graphics2D graphics = GraphicsEnvironment.getLocalGraphicsEnvironment().createGraphics(img); FontRenderContext fontRenderContext = graphics.getFontRenderContext(); this.font = new Font(fontName, Font.PLAIN, 1000); double maxHeight = 0; for (int i = 0; i < 255; i++) { TextLayout layout = new TextLayout(Character.toString((char)i), font, fontRenderContext); maxHeight = Math.max(maxHeight, layout.getBounds().getHeight()); super.widths[i] = (int)layout.getAdvance(); } super.maxCharHeight = (int)Math.round(maxHeight); }
public SystemFontMetrics(String fontName) { BufferedImage img = new BufferedImage(40, 40, BufferedImage.TYPE_4BYTE_ABGR); Graphics2D graphics = GraphicsEnvironment.getLocalGraphicsEnvironment().createGraphics(img); FontRenderContext fontRenderContext = graphics.getFontRenderContext(); this.font = new Font(fontName, Font.PLAIN, 1000); double maxHeight = 0; for (int i = 0; i < 255; i++) { TextLayout layout = new TextLayout(Character.toString((char)i), font, fontRenderContext); maxHeight = Math.max(maxHeight, layout.getBounds().getHeight()); super.widths[i] = (int)layout.getAdvance(); } super.maxCharHeight = (int)Math.round(maxHeight); }
public SystemFontMetrics(String fontName) { BufferedImage img = new BufferedImage(40, 40, BufferedImage.TYPE_4BYTE_ABGR); Graphics2D graphics = GraphicsEnvironment.getLocalGraphicsEnvironment().createGraphics(img); FontRenderContext fontRenderContext = graphics.getFontRenderContext(); this.font = new Font(fontName, Font.PLAIN, 1000); double maxHeight = 0; for (int i = 0; i < 255; i++) { TextLayout layout = new TextLayout(Character.toString((char)i), font, fontRenderContext); maxHeight = Math.max(maxHeight, layout.getBounds().getHeight()); super.widths[i] = (int)layout.getAdvance(); } super.maxCharHeight = (int)Math.round(maxHeight); }
Graphics2D g = GraphicsEnvironment.getLocalGraphicsEnvironment().createGraphics(img); AffineTransform transform = g.getFontRenderContext() .getTransform();
protected void copyToClipBoard() { // Get image from mapBean int width = getMapBean().getWidth(); int height = getMapBean().getHeight(); BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); Graphics g = ge.createGraphics(image); g.setClip(0, 0, width, height); getMapBean().paintAll(g); ImageSelection imgSel = new ImageSelection(image); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(imgSel, null); if (log.isInfoEnabled()) { log.info("Copy current image to system clipboard"); } }