/* * [NumericLiteralHigh.java] * * Summary: Used to give alternate colour to groups of three or four digits. * * Copyright: (c) 2009-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 com.mindprod.jtokens.NumericLiteral; import java.awt.Color; import static com.mindprod.jtokens.TokenColourScheme.*; /** * Used to give alternate colour to groups of three or four digits. * * @author Roedy Green, Canadian Mind Products * @version 2.0 2009-04-19 tidy comments, more accurate colour names * @since 2009 */ public final class NumericLiteralHigh extends NumericLiteral { /** * version number for the class */ static final long serialVersionUID = 2L; private final int base; /** * Constructor * * @param c char representation of the literal. * @param base radix of the numeric literal */ public NumericLiteralHigh( char c, int base ) { super( c ); this.base = base; } /** * @param s string to display * @param base radix of the numeric literal */ public NumericLiteralHigh( String s, int base ) { super( s ); this.base = base; } /** * foreground colour to render this token. * * @return Color object. */ public Color getForeground() { switch ( base ) { case 2: return JAVA_FOREGROUND_FOR_BINARY_HIGH; case 8: return JAVA_FOREGROUND_FOR_OCTAL_HIGH; case 10: return JAVA_FOREGROUND_FOR_DECIMAL_HIGH; case 16: return JAVA_FOREGROUND_FOR_HEX_HIGH; default: return JAVA_FOREGROUND_FOR_NUMERIC_HIGH; } } /** * get the text surrounded by CSS html * * @return text to render this token in html */ public String getHTML() { final String baseword; switch ( base ) { case 2: baseword = "binary"; break; case 8: baseword = "octal"; break; case 10: baseword = "decimal"; break; case 16: baseword = "hex"; break; default: baseword = "numeric"; break; } return "" + getRawHTML() + ""; } }