pax_global_header00006660000000000000000000000064126621022000014501gustar00rootroot0000000000000052 comment=1c578ed9de55b4a32a5555e2ed0f3b85f31d7d56 jiconfont-swing-1.0.1/000077500000000000000000000000001266210220000146165ustar00rootroot00000000000000jiconfont-swing-1.0.1/.gitignore000066400000000000000000000002671266210220000166130ustar00rootroot00000000000000target/ pom.xml.tag pom.xml.releaseBackup pom.xml.versionsBackup pom.xml.next release.properties dependency-reduced-pom.xml buildNumber.properties .mvn/timing.properties *.iml .idea/ jiconfont-swing-1.0.1/LICENSE000066400000000000000000000020641266210220000156250ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2016 jIconFont Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. jiconfont-swing-1.0.1/README.md000066400000000000000000000001131266210220000160700ustar00rootroot00000000000000Visit [http://jiconfont.github.io/swing](http://jiconfont.github.io/swing) jiconfont-swing-1.0.1/pom.xml000066400000000000000000000101551266210220000161350ustar00rootroot00000000000000 4.0.0 UTF-8 com.github.jiconfont jiconfont-swing 1.0.1 jar jIconFont - Swing jIconFont-Swing is a API to provide icons generated from any IconFont. These icons can be used in Swing. https://github.com/jIconFont/jiconfont-swing The MIT License (MIT) http://opensource.org/licenses/mit-license.html repo scm:git:git@github.com:jIconFont/jiconfont-swing.git scm:git:git@github.com:jIconFont/jiconfont-swing.git scm:git:git@github.com:jIconFont/jiconfont-swing.git HEAD caduandrade Cadu Andrade cadu@caduandrade.net sonatype-nexus-staging Sonatype Repository https://oss.sonatype.org/service/local/staging/deploy/maven2 sonatype-nexus-snapshots Sonatype Repository https://oss.sonatype.org/content/repositories/snapshots com.github.jiconfont jiconfont 1.0.0 org.apache.maven.plugins maven-compiler-plugin 3.1 1.7 1.7 org.apache.maven.plugins maven-source-plugin 2.4 attach-sources jar org.apache.maven.plugins maven-javadoc-plugin 2.10.1 attach-javadocs jar org.apache.maven.plugins maven-gpg-plugin 1.5 sign-artifacts package sign jiconfont-swing-1.0.1/src/000077500000000000000000000000001266210220000154055ustar00rootroot00000000000000jiconfont-swing-1.0.1/src/main/000077500000000000000000000000001266210220000163315ustar00rootroot00000000000000jiconfont-swing-1.0.1/src/main/java/000077500000000000000000000000001266210220000172525ustar00rootroot00000000000000jiconfont-swing-1.0.1/src/main/java/jiconfont/000077500000000000000000000000001266210220000212435ustar00rootroot00000000000000jiconfont-swing-1.0.1/src/main/java/jiconfont/swing/000077500000000000000000000000001266210220000223725ustar00rootroot00000000000000jiconfont-swing-1.0.1/src/main/java/jiconfont/swing/IconFontSwing.java000066400000000000000000000117371266210220000257750ustar00rootroot00000000000000package jiconfont.swing; import jiconfont.IconCode; import jiconfont.IconFont; import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JLabel; import java.awt.*; import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; /** * Copyright (c) 2016 jIconFont
*
* Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ public final class IconFontSwing { private static List fonts = new ArrayList<>(); /** * Register an icon font. * * @param iconFont the icon font. */ public static synchronized void register(IconFont iconFont) { if (IconFontSwing.fonts.contains(iconFont) == false) { IconFontSwing.fonts.add(iconFont); } } /** * Builds a font. * * @param fontFamily the font family. * @return the font. */ public static synchronized final Font buildFont(String fontFamily) { try { for (IconFont iconFont : IconFontSwing.fonts) { if (iconFont.getFontFamily().equals(fontFamily)) { return Font.createFont(Font.TRUETYPE_FONT, iconFont.getFontInputStream()); } } } catch (Exception ex) { Logger.getLogger(IconFontSwing.class.getName()).log(Level.SEVERE, "Font load failure", ex); } Logger.getLogger(IconFontSwing.class.getName()).log(Level.SEVERE, "Font not found: " + fontFamily); throw new IllegalArgumentException("Font not found: " + fontFamily); } private IconFontSwing() { } /** * Builds an image. * * @param iconCode the icon code. * @param size the size. * @return the image. */ public static Image buildImage(IconCode iconCode, float size) { return buildImage(iconCode, size, Color.BLACK); } /** * Builds an image. * * @param iconCode the icon code. * @param size the size. * @param color the size. * @return the image. */ public static Image buildImage(IconCode iconCode, float size, Color color) { Font font = buildFont(iconCode, size); String text = Character.toString(iconCode.getUnicode()); return buildImage(text, font, color); } /** * Builds an icon. * * @param iconCode the icon code. * @param size the size. * @return the icon. */ public static Icon buildIcon(IconCode iconCode, float size) { return buildIcon(iconCode, size, Color.BLACK); } /** * Builds an icon. * * @param iconCode the icon code. * @param size the size. * @param color the size. * @return the icon. */ public static Icon buildIcon(IconCode iconCode, float size, Color color) { return new ImageIcon(buildImage(iconCode, size, color)); } private static BufferedImage buildImage(String text, Font font, Color color) { JLabel label = new JLabel(text); label.setForeground(color); label.setFont(font); Dimension dim = label.getPreferredSize(); int width = dim.width + 1; int height = dim.height + 1; label.setSize(width, height); BufferedImage bufImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D g2d = bufImage.createGraphics(); g2d.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); g2d.setRenderingHint( RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); label.print(g2d); g2d.dispose(); return bufImage; } private static Font buildFont(IconCode iconCode, float size) { Font font = IconFontSwing.buildFont(iconCode.getFontFamily()); return font.deriveFont(size); } }