/** * Returns the text Font weight of the activator text */ public String getTextFontWeight() { if (StyleConstants.isBold(textAttribs)) { return "bold"; } return "plain"; }
public String getTextFontWeight() { if (isBold(textAttribs)) { return "bold"; } return "plain"; }
/** Return the font given the specified attributes * * @param attribute The font attributes * @return The font given the specified attributes */ protected Font getFontForAttribute(AttributeSet attribute) { Font f = DEFAULT_FONT; if(StyleConstants.isBold(attribute)) f = f.deriveFont(Font.BOLD); if(StyleConstants.isItalic(attribute)) f = f.deriveFont(Font.ITALIC); return f; }
/** * Fetch the font to use for a lexical token with the given scan value. * * @param style * the style. * * @return the font style */ public static int getFontStyle(Style style) { int fontStyle = Font.PLAIN; if (style != null) { if (StyleConstants.isItalic(style)) { fontStyle += Font.ITALIC; } if (StyleConstants.isBold(style)) { fontStyle += Font.BOLD; } } return fontStyle; } }
private static String color(String string, AttributeSet set) { if (set==null) { return string; } if (string.trim().length() == 0) { return string.replace(" ", " ").replace("\n", "<br>"); //NOI18N } StringBuffer buf = new StringBuffer(string); if (StyleConstants.isBold(set)) { buf.insert(0,"<b>"); //NOI18N buf.append("</b>"); //NOI18N } if (StyleConstants.isItalic(set)) { buf.insert(0,"<i>"); //NOI18N buf.append("</i>"); //NOI18N } if (StyleConstants.isStrikeThrough(set)) { buf.insert(0,"<s>"); // NOI18N buf.append("</s>"); // NOI18N } buf.insert(0,"<font color=" + getHTMLColor(StyleConstants.getForeground(set)) + ">"); //NOI18N buf.append("</font>"); //NOI18N return buf.toString(); }
public static String addHTMLColor(String string, AttributeSet set) { if (set == null) { return string; } if (string.trim().length() == 0) { return string.replace(" ", " ").replace("\n", "<br>"); //NOI18N } StringBuilder buf = new StringBuilder(string); if (StyleConstants.isBold(set)) { buf.insert(0, "<b>"); //NOI18N buf.append("</b>"); //NOI18N } if (StyleConstants.isItalic(set)) { buf.insert(0, "<i>"); //NOI18N buf.append("</i>"); //NOI18N } if (StyleConstants.isStrikeThrough(set)) { buf.insert(0, "<s>"); // NOI18N buf.append("</s>"); // NOI18N } buf.insert(0, "<font color=" + getHTMLColor(LFCustoms.getForeground(set)) + ">"); //NOI18N buf.append("</font>"); //NOI18N return buf.toString(); }
/** * A convience method to read a font from a style. * * @param style Style being modified * @return The font inside the passed style */ public static String getFontString(Style style) { String font = StyleConstants.getFontFamily(style) + "-"; if (StyleConstants.isBold(style)) font += "BOLD"; if (StyleConstants.isItalic(style)) font += "ITALIC"; if (!StyleConstants.isBold(style) && !StyleConstants.isItalic(style)) font += "PLAIN"; font += "-" + StyleConstants.getFontSize(style); return font; }
cssMap.put("font-weight", StyleConstants.isBold(style) ? "bold" : "normal");
map.put( TextAttribute.FAMILY, getFontFamily( attr ) ); map.put( TextAttribute.SIZE, (float)getFontSize() ); map.put( TextAttribute.WEIGHT, StyleConstants.isBold( attr ) ? TextAttribute.WEIGHT_BOLD : TextAttribute.WEIGHT_REGULAR ); map.put( TextAttribute.POSTURE, StyleConstants.isItalic( attr ) ? TextAttribute.POSTURE_OBLIQUE : TextAttribute.POSTURE_REGULAR ); if( bUnderline )
protected Collection<MessageFragmentStyle> colorizeStackTraceRegex(final Style style, String text, Pattern regex, int group) { ArrayList<MessageFragmentStyle> list = new ArrayList<>(); Matcher matcher = regex.matcher(text); Style styleToUse = style; while (matcher.find()) { LocationInfo locationInfo = LocationInfo.parse(matcher.group(0)); if (locationInfo != null) { String name = styleToUse.getName(); Style newStyle = styleContext.addStyle(name + "-" + locationInfo.toString(), styleToUse); newStyle.addAttribute(STYLE_ATTRIBUTE_LOCATION_INFO, locationInfo); StyleConstants.setForeground(newStyle, StyleConstants.getForeground(styleToUse)); StyleConstants.setBold(newStyle, StyleConstants.isBold(styleToUse)); StyleConstants.setItalic(newStyle, StyleConstants.isItalic(styleToUse)); styleToUse = newStyle; } int start = matcher.start(group); int end = matcher.end(group); if (end - start > 0) { MessageFragmentStyle messageFragmentStyle = new MessageFragmentStyle(start, end - start, styleToUse, false); list.add(messageFragmentStyle); } } return list; }
private Font getFont( AttributeSet attr, String strFamily ) { int iStyle = Font.PLAIN; if( StyleConstants.isBold( attr ) ) { iStyle |= Font.BOLD; } if( StyleConstants.isItalic( attr ) ) { iStyle |= Font.ITALIC; } int iSize = getFontSize(); // If either superscript or subscript is is set, we need to reduce the font // size by 2. if( StyleConstants.isSuperscript( attr ) || StyleConstants.isSubscript( attr ) ) { iSize -= 2; } return getFont( strFamily, iStyle, iSize ); }
private Font getFont( AttributeSet attr, String strFamily ) { int iStyle = Font.PLAIN; if( StyleConstants.isBold( attr ) ) { iStyle |= Font.BOLD; } if( StyleConstants.isItalic( attr ) ) { iStyle |= Font.ITALIC; } int iSize = getFontSize(); // If either superscript or subscript is is set, we need to reduce the font // size by 2. if( StyleConstants.isSuperscript( attr ) || StyleConstants.isSubscript( attr ) ) { iSize -= 2; } return getFont( strFamily, iStyle, iSize ); }
private Font getAttributeSetFont(AttributeSet attr) { int style = PLAIN; if (isBold(attr)) { style |= BOLD; } if (isItalic(attr)) { style |= ITALIC; } String family = StyleConstants.getFontFamily(attr); int size = getFontSize(attr); if (isSuperscript(attr) || isSubscript(attr)) { size -= 2; } return doc.getStyleSheet().getFont(family, style, size); }
if (StyleConstants.isBold(attr)) { style |= Font.BOLD;
@Test public void testColorize() throws BadLocationException { String message = "a55(a)a"; Collection<MessageFragmentStyle> colorize = colorizer.colorize(message); assertEquals(2, colorize.size()); ArrayList<MessageFragmentStyle> list = new ArrayList<>(colorize); MessageFragmentStyle messageFragmentStyle = list.get(0); MessageFragmentStyle messageFragmentStyle1 = list.get(1); assertEquals(messageFragmentStyle.isReplace(), false); assertEquals(messageFragmentStyle.getOffset(), 0); assertEquals(messageFragmentStyle.getLength(), message.length()); Style style = messageFragmentStyle.getStyle(); assertEquals(StyleConstants.getBackground(style), new Color(0, 255, 255)); assertEquals(StyleConstants.getForeground(style), new Color(255, 255, 0)); assertEquals((Boolean) StyleConstants.isBold(style), Boolean.FALSE); assertEquals((Boolean) StyleConstants.isItalic(style), Boolean.TRUE); assertEquals(messageFragmentStyle1.isReplace(), false); assertEquals(messageFragmentStyle1.getOffset(), 1); assertEquals(messageFragmentStyle1.getLength(), 5); Style style1 = messageFragmentStyle1.getStyle(); assertEquals(StyleConstants.getBackground(style1), new Color(0, 0, 255)); assertEquals(StyleConstants.getForeground(style1), new Color(255, 0, 0)); assertEquals((Boolean) StyleConstants.isBold(style1), Boolean.TRUE); assertEquals((Boolean) StyleConstants.isItalic(style1), Boolean.FALSE); } }
manager.setSelected("font-bold", StyleConstants.isBold(set)); manager.setSelected("font-italic", StyleConstants.isItalic(set)); manager.setSelected("font-underline", StyleConstants.isUnderline(set));
manager.setSelected("font-bold", StyleConstants.isBold(set)); manager.setSelected("font-italic", StyleConstants.isItalic(set)); manager.setSelected("font-underline", StyleConstants.isUnderline(set));
manager.setSelected("font-bold", StyleConstants.isBold(set)); manager.setSelected("font-italic", StyleConstants.isItalic(set)); manager.setSelected("font-underline", StyleConstants.isUnderline(set));
manager.setSelected("font-bold", StyleConstants.isBold(set)); manager.setSelected("font-italic", StyleConstants.isItalic(set)); manager.setSelected("font-underline", StyleConstants.isUnderline(set));
manager.setSelected("font-bold", StyleConstants.isBold(set)); manager.setSelected("font-italic", StyleConstants.isItalic(set)); manager.setSelected("font-underline", StyleConstants.isUnderline(set));