/* * [PackageName.java] * * Summary: Describes one package name token for display, no embedded dots. * * Copyright: (c) 2004-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 2.0 2009-04-19 tidy comments, more accurate colour names */ package com.mindprod.jtokens.java; import java.awt.Color; import java.awt.Font; import static com.mindprod.jtokens.TokenColourScheme.JAVA_FOREGROUND_FOR_PACKAGE; import static com.mindprod.jtokens.TokenFonts.MONO_FONTS; import static com.mindprod.jtokens.TokenFonts.NORMAL_FONT_SIZE_IN_POINTS; import static java.lang.System.*; /** * Describes one package name token for display, no embedded dots. * * @author Roedy Green, Canadian Mind Products * @version 2.0 2009-04-19 tidy comments, more accurate colour names * @since 2004-04-24 */ public final class PackageName extends Definable { /** * version number for this class */ static final long serialVersionUID = 1L; @SuppressWarnings( { "ConstantNamingConvention" } ) private static final Font fontDef = bestFont( MONO_FONTS, Font.BOLD, NORMAL_FONT_SIZE_IN_POINTS ); /** * Font to render this token */ @SuppressWarnings( { "ConstantNamingConvention" } ) private static final Font fontRef = bestFont( MONO_FONTS, Font.PLAIN, NORMAL_FONT_SIZE_IN_POINTS ); /** * Constructor * * @param packageFragment fragment of the package name, e.g. awt java. no embedded dots. * @param defining true if this where the package is defined. false if it is a reference to the package. */ public PackageName( String packageFragment, boolean defining ) { super( packageFragment, defining ); if ( !packageFragment.toLowerCase().equals( packageFragment ) ) { err.println( "\007Packages must be all lower case." ); } } /** * @inheritDoc */ public Font getFont() { return defining ? fontDef : fontRef; } /** * @inheritDoc */ public Color getForeground() { return JAVA_FOREGROUND_FOR_PACKAGE; } /** * @inheritDoc */ public String getHTML() { return ( defining ? "" : "" ) + getRawHTML() + ""; } }