src.gov.nasa.worldwind.render.TextRendererCache Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of worldwindx Show documentation
Show all versions of worldwindx Show documentation
World Wind is a collection of components that interactively display 3D geographic information within Java applications or applets.
/*
* Copyright (C) 2012 United States Government as represented by the Administrator of the
* National Aeronautics and Space Administration.
* All Rights Reserved.
*/
package gov.nasa.worldwind.render;
import com.jogamp.opengl.util.awt.TextRenderer;
import gov.nasa.worldwind.Disposable;
import gov.nasa.worldwind.util.Logging;
/**
* http://java.sun.com/products/java-media/2D/reference/faqs/index.html#Q_What_are_fractional_metrics_Wh
*
* @author tag
* @version $Id: TextRendererCache.java 1171 2013-02-11 21:45:02Z dcollins $
*/
public class TextRendererCache implements Disposable
{
public static class CacheKey
{
private final java.awt.Font font;
private final boolean antialiased;
private final boolean useFractionalMetrics;
private final boolean mipmap;
public CacheKey(java.awt.Font font, boolean antialiased, boolean useFractionalMetrics, boolean mipmap)
{
if (font == null)
{
String message = Logging.getMessage("nullValue.FontIsNull");
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
this.font = font;
this.antialiased = antialiased;
this.useFractionalMetrics = useFractionalMetrics;
this.mipmap = mipmap;
}
public final java.awt.Font getFont()
{
return this.font;
}
public final boolean isAntialiased()
{
return this.antialiased;
}
public final boolean isUseFractionalMetrics()
{
return this.useFractionalMetrics;
}
public final boolean isMipmap()
{
return this.mipmap;
}
public boolean equals(Object o)
{
if (this == o)
return true;
if (o == null || this.getClass() != o.getClass())
return false;
CacheKey that = (CacheKey) o;
return (this.antialiased == that.antialiased)
&& (this.useFractionalMetrics == that.useFractionalMetrics)
&& (this.mipmap == that.mipmap)
&& (this.font.equals(that.font));
}
public int hashCode()
{
int result = this.font.hashCode();
result = 31 * result + (this.antialiased ? 1 : 0);
result = 31 * result + (this.useFractionalMetrics ? 1 : 0);
result = 31 * result + (this.mipmap ? 1 : 0);
return result;
}
}
protected java.util.concurrent.ConcurrentHashMap