Refine search
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel renderer = (JLabel) defaultRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value instanceof String) { renderer.setText((String) value); renderer.setFont(new Font((String) value, DEFAULT_FONT.getStyle(), DEFAULT_FONT.getSize() + 2)); } else { renderer.setText(""); } return renderer; } });
/** * @noinspection ALL */ private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { if (currentFont == null) return null; String resultName; if (fontName == null) { resultName = currentFont.getName(); } else { Font testFont = new Font(fontName, Font.PLAIN, 10); if (testFont.canDisplay('a') && testFont.canDisplay('1')) { resultName = fontName; } else { resultName = currentFont.getName(); } } return new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); }
upButton.setMargin(new Insets(0, 0, 0, 0)); Font font = upButton.getFont(); upButton.setFont(new Font(font.getName(), font.getStyle(), font.getSize() - 2)); downButton.setMargin(new Insets(0, 0, 0, 0)); Font font = downButton.getFont(); downButton.setFont(new Font(font.getName(), font.getStyle(), font.getSize() - 2)); deleteButton.setMargin(new Insets(0, 0, 0, 0)); Font font = deleteButton.getFont(); deleteButton.setFont(new Font(font.getName(), font.getStyle(), font.getSize() - 2));
upButton.setMargin(new Insets(0, 0, 0, 0)); Font font = upButton.getFont(); upButton.setFont(new Font(font.getName(), font.getStyle(), font.getSize() - 2)); downButton.setMargin(new Insets(0, 0, 0, 0)); Font font = downButton.getFont(); downButton.setFont(new Font(font.getName(), font.getStyle(), font.getSize() - 2)); deleteButton.setMargin(new Insets(0, 0, 0, 0)); Font font = deleteButton.getFont(); deleteButton.setFont(new Font(font.getName(), font.getStyle(), font.getSize() - 2));
@Override public void drawString(String str, int x, int y) { if (str == null || str.isEmpty()) return; Font excelFont = font; if ( font.getName().equals( "SansSerif" ) ) { excelFont = new Font( "Arial", font.getStyle(), (int) ( font.getSize() / verticalPixelsPerPoint ) ); } else { excelFont = new Font( font.getName(), font.getStyle(), (int) ( font.getSize() / verticalPixelsPerPoint )); } FontDetails d = StaticFontMetrics.getFontDetails( excelFont ); int width = d.getStringWidth( str ) * 8 + 12; int height = (int) ( ( font.getSize() / verticalPixelsPerPoint ) + 6 ) * 2; y -= ( font.getSize() / verticalPixelsPerPoint ) + 2 * verticalPixelsPerPoint; // we want to draw the shape from the top-left HSSFTextbox textbox = escherGroup.createTextbox( new HSSFChildAnchor( x, y, x + width, y + height ) ); textbox.setNoFill( true ); textbox.setLineStyle( HSSFShape.LINESTYLE_NONE ); HSSFRichTextString s = new HSSFRichTextString( str ); HSSFFont hssfFont = matchFont( excelFont ); s.applyFont( hssfFont ); textbox.setString( s ); }
private HSSFFont matchFont( Font matchFont ) { HSSFColor hssfColor = workbook.getCustomPalette() .findColor((byte)foreground.getRed(), (byte)foreground.getGreen(), (byte)foreground.getBlue()); if (hssfColor == null) hssfColor = workbook.getCustomPalette().findSimilarColor((byte)foreground.getRed(), (byte)foreground.getGreen(), (byte)foreground.getBlue()); boolean bold = (matchFont.getStyle() & Font.BOLD) != 0; boolean italic = (matchFont.getStyle() & Font.ITALIC) != 0; HSSFFont hssfFont = workbook.findFont(bold, hssfColor.getIndex(), (short)(matchFont.getSize() * 20), matchFont.getName(), italic, false, (short)0, (byte)0); if (hssfFont == null) { hssfFont = workbook.createFont(); hssfFont.setBold(bold); hssfFont.setColor(hssfColor.getIndex()); hssfFont.setFontHeight((short)(matchFont.getSize() * 20)); hssfFont.setFontName(matchFont.getName()); hssfFont.setItalic(italic); hssfFont.setStrikeout(false); hssfFont.setTypeOffset((short) 0); hssfFont.setUnderline((byte) 0); } return hssfFont; }
/** * Changes the "base font" for this syntax scheme. This is called by * <code>RSyntaxTextArea</code> when its font changes via * <code>setFont()</code>. This looks for tokens that use a derivative of * the text area's old font (but bolded and/or italicized) and make them * use the new font with those stylings instead. This is desirable because * most programmers prefer a single font to be used in their text editor, * but might want bold (say for keywords) or italics. * * @param old The old font of the text area. * @param font The new font of the text area. */ void changeBaseFont(Font old, Font font) { for (int i=0; i<styles.length; i++) { Style style = styles[i]; if (style!=null && style.font!=null) { if (style.font.getFamily().equals(old.getFamily()) && style.font.getSize()==old.getSize()) { int s = style.font.getStyle(); // Keep bold or italic StyleContext sc = StyleContext.getDefaultStyleContext(); style.font= sc.getFont(font.getFamily(), s, font.getSize()); } } } }
/** * Writes <tag>value</tag> to output stream * * @param tag XML tag name * @param value value to be placed between <code><tag></code> and <code></tag></code> */ public void writeTag(String tag, Font value) { startTag(tag); writeTag("name", value.getName()); int style = value.getStyle(); if ((style & Font.BOLD) != 0 && (style & Font.ITALIC) != 0) { writeTag("style", "BOLDITALIC"); } else if ((style & Font.BOLD) != 0) { writeTag("style", "BOLD"); } else if ((style & Font.ITALIC) != 0) { writeTag("style", "ITALIC"); } else { writeTag("style", "PLAIN"); } writeTag("size", value.getSize()); closeTag(); }
/** Modify the given font according to the font-mode */ private Font modifyFont(Font f) { return new Font( ((fontMode & FONT_MODE_APPLY_NAME) != 0) ? font.getName() : f.getName(), ((fontMode & FONT_MODE_APPLY_STYLE) != 0) ? font.getStyle() : f.getStyle(), ((fontMode & FONT_MODE_APPLY_SIZE) != 0) ? font.getSize() : f.getSize() ); }