pax_global_header 0000666 0000000 0000000 00000000064 12662102200 0014501 g ustar 00root root 0000000 0000000 52 comment=1c578ed9de55b4a32a5555e2ed0f3b85f31d7d56
jiconfont-swing-1.0.1/ 0000775 0000000 0000000 00000000000 12662102200 0014616 5 ustar 00root root 0000000 0000000 jiconfont-swing-1.0.1/.gitignore 0000664 0000000 0000000 00000000267 12662102200 0016613 0 ustar 00root root 0000000 0000000 target/
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/LICENSE 0000664 0000000 0000000 00000002064 12662102200 0015625 0 ustar 00root root 0000000 0000000 The 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.md 0000664 0000000 0000000 00000000113 12662102200 0016070 0 ustar 00root root 0000000 0000000 Visit [http://jiconfont.github.io/swing](http://jiconfont.github.io/swing)
jiconfont-swing-1.0.1/pom.xml 0000664 0000000 0000000 00000010155 12662102200 0016135 0 ustar 00root root 0000000 0000000
4.0.0UTF-8com.github.jiconfontjiconfont-swing1.0.1jarjIconFont - SwingjIconFont-Swing is a API to provide icons generated from any IconFont. These icons can be used in
Swing.
https://github.com/jIconFont/jiconfont-swingThe MIT License (MIT)http://opensource.org/licenses/mit-license.htmlreposcm:git:git@github.com:jIconFont/jiconfont-swing.gitscm:git:git@github.com:jIconFont/jiconfont-swing.gitscm:git:git@github.com:jIconFont/jiconfont-swing.gitHEADcaduandradeCadu Andradecadu@caduandrade.netsonatype-nexus-stagingSonatype Repositoryhttps://oss.sonatype.org/service/local/staging/deploy/maven2sonatype-nexus-snapshotsSonatype Repositoryhttps://oss.sonatype.org/content/repositories/snapshotscom.github.jiconfontjiconfont1.0.0org.apache.maven.pluginsmaven-compiler-plugin3.11.71.7org.apache.maven.pluginsmaven-source-plugin2.4attach-sourcesjarorg.apache.maven.pluginsmaven-javadoc-plugin2.10.1attach-javadocsjarorg.apache.maven.pluginsmaven-gpg-plugin1.5sign-artifactspackagesign
jiconfont-swing-1.0.1/src/ 0000775 0000000 0000000 00000000000 12662102200 0015405 5 ustar 00root root 0000000 0000000 jiconfont-swing-1.0.1/src/main/ 0000775 0000000 0000000 00000000000 12662102200 0016331 5 ustar 00root root 0000000 0000000 jiconfont-swing-1.0.1/src/main/java/ 0000775 0000000 0000000 00000000000 12662102200 0017252 5 ustar 00root root 0000000 0000000 jiconfont-swing-1.0.1/src/main/java/jiconfont/ 0000775 0000000 0000000 00000000000 12662102200 0021243 5 ustar 00root root 0000000 0000000 jiconfont-swing-1.0.1/src/main/java/jiconfont/swing/ 0000775 0000000 0000000 00000000000 12662102200 0022372 5 ustar 00root root 0000000 0000000 jiconfont-swing-1.0.1/src/main/java/jiconfont/swing/IconFontSwing.java 0000664 0000000 0000000 00000011737 12662102200 0025775 0 ustar 00root root 0000000 0000000 package 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);
}
}