@Override public void paint(Graphics g) { try { // translate location Point srcLocation = new Point(0, 0); Point dstLocation = SwingUtilities.convertPoint(scrollPane, srcLocation, this); Graphics2D g2 = (Graphics2D) g.create(); g2.translate(dstLocation.x, dstLocation.y); // enable AntiAliasing if (!g2.getFontRenderContext().isAntiAliased()) { g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); } // draw marker for (Marker marker : markers) { drawMarker(g2, marker.location, String.valueOf(Character.toChars(marker.title))); } g2.dispose(); } catch (Exception e) { System.out.println(e.getMessage()); } }
private void assureGlyphVector () { Font font = getFont (); FontRenderContext fontRenderContext = getGraphics ().getFontRenderContext (); if (cacheGlyphVector != null && cacheFont == font && cacheLabel == label) return; cacheFont = font; cacheLabel = label; cacheGlyphVector = font.createGlyphVector (new FontRenderContext (new AffineTransform (), fontRenderContext.isAntiAliased (), fontRenderContext.usesFractionalMetrics ()), cacheLabel); }
private void assureGlyphVector () { Font font = getFont (); FontRenderContext fontRenderContext = getGraphics ().getFontRenderContext (); if (cacheGlyphVector != null && cacheFont == font && cacheLabel == label) return; cacheFont = font; cacheLabel = label; cacheGlyphVector = font.createGlyphVector (new FontRenderContext (new AffineTransform (), fontRenderContext.isAntiAliased (), fontRenderContext.usesFractionalMetrics ()), cacheLabel); }
frc.isAntiAliased(), frc.usesFractionalMetrics());
frc.isAntiAliased(), frc.usesFractionalMetrics());
protected Shape getGlyph(int i) { // This one-line implementation produces different results under JDK 1.3 // and 1.4 // return glyphs.getGlyphOutline(i); // The substitute code attempts to work around this by using defensive // programming // See code marked FONTHACK elsewhere in this file // Create a GlyphVector for this single character. FontRenderContext orig = getContext(); FontRenderContext frc = new FontRenderContext(null, orig .isAntiAliased(), orig.usesFractionalMetrics()); Shape shape = font.createGlyphVector(frc, new char[] { getUnicode(i) }) .getGlyphOutline(0); return orig.getTransform().createTransformedShape(shape); }
protected Shape getGlyph(int i) { // This one-line implementation produces different results under JDK 1.3 // and 1.4 // return glyphs.getGlyphOutline(i); // The substitute code attempts to work around this by using defensive // programming // See code marked FONTHACK elsewhere in this file // Create a GlyphVector for this single character. FontRenderContext orig = getContext(); FontRenderContext frc = new FontRenderContext(null, orig .isAntiAliased(), orig.usesFractionalMetrics()); Shape shape = font.createGlyphVector(frc, new char[] { getUnicode(i) }) .getGlyphOutline(0); return orig.getTransform().createTransformedShape(shape); }