/** * If the font is set to null, then the font used to display today's date as text will default to * the L&F's Label default font. * * <p>Otherwise, the font used to display today's date is set as given. * * @param font The font to set. */ public void setTodayFont(Font font) { if (font == null && todayFont != null || !font.equals(todayFont)) { todayFont = font; if (isDisplayable()) setupTodayFont(); } }
/** * If the font is set to null, then the title font (for the Month Year title) will default to the * L&F's Label default font. * * <p>Otherwise, the title font is set as given. * * @param font The font to set. */ public void setTitleFont(Font font) { if (font == null && titleFont != null || !font.equals(titleFont)) { titleFont = font; if (isDisplayable()) setupTitleFont(); } }
/** * If the font is set to null, then the day font will default to 9/11th's of the L&F's Button * default font. * * <p>Otherwise, the day font is set as given. * * @param font The font to set. */ public void setDayFont(Font font) { if (font == null && dayFont != null || !font.equals(dayFont)) { dayFont = font; if (isDisplayable()) setupDayFonts(); } }
private static void addFragments( BidiRun run, char[] text, int start, int end, int fontStyle, FontPreferences fontPreferences, FontRenderContext fontRenderContext, @Nullable TabFragment tabFragment) { Font currentFont = null; int currentIndex = start; for (int i = start; i < end; i++) { char c = text[i]; if (c == '\t' && tabFragment != null) { assert run.level == 0; addTextFragmentIfNeeded( run, text, currentIndex, i, currentFont, fontRenderContext, run.isRtl()); run.fragments.add(tabFragment); currentFont = null; currentIndex = i + 1; } else { Font font = ComplementaryFontsRegistry.getFontAbleToDisplay(c, fontStyle, fontPreferences) .getFont(); if (!font.equals(currentFont)) { addTextFragmentIfNeeded( run, text, currentIndex, i, currentFont, fontRenderContext, run.isRtl()); currentFont = font; currentIndex = i; } } } addTextFragmentIfNeeded( run, text, currentIndex, end, currentFont, fontRenderContext, run.isRtl()); }
/** * Set the default contour label font. <br> * <B>Property Change:</B> <code>labelFont</code>. */ public void setLabelFont(Font font) { if (labelFont_ == null || !labelFont_.equals(font)) { Font tempOld = labelFont_; labelFont_ = font; changes_.firePropertyChange("labelFont", tempOld, labelFont_); } }
/** * Compares the argument to the receiver, and returns true if they represent the <em>same</em> * object using a class specific comparison. * * @param object the object to compare with this object * @return <code>true</code> if the object is the same as this object and <code>false</code> * otherwise * @see #hashCode() */ public boolean equals(Object object) { if (object == this) return true; if (object == null) return false; if (!(object instanceof TextStyle)) return false; TextStyle style = (TextStyle) object; if (foreground != null) { if (!foreground.equals(style.foreground)) return false; } else if (style.foreground != null) return false; if (background != null) { if (!background.equals(style.background)) return false; } else if (style.background != null) return false; if (font != null) { if (!font.equals(style.font)) return false; } else if (style.font != null) return false; if (metrics != null || style.metrics != null) return false; if (underline != style.underline) return false; if (underlineStyle != style.underlineStyle) return false; if (borderStyle != style.borderStyle) return false; if (strikeout != style.strikeout) return false; if (rise != style.rise) return false; if (underlineColor != null) { if (!underlineColor.equals(style.underlineColor)) return false; } else if (style.underlineColor != null) return false; if (strikeoutColor != null) { if (!strikeoutColor.equals(style.strikeoutColor)) return false; } else if (style.strikeoutColor != null) return false; if (underlineStyle != style.underlineStyle) return false; if (borderColor != null) { if (!borderColor.equals(style.borderColor)) return false; } else if (style.borderColor != null) return false; if (data != null) { if (!data.equals(style.data)) return false; } else if (style.data != null) return false; return true; }
@Nullable Font getFontAbleToDisplay(LookupElementPresentation p) { String sampleString = p.getItemText() + p.getTailText() + p.getTypeText(); // assume a single font can display all lookup item chars Set<Font> fonts = ContainerUtil.newHashSet(); for (int i = 0; i < sampleString.length(); i++) { fonts.add( EditorUtil.fontForChar(sampleString.charAt(i), Font.PLAIN, myLookup.getEditor()) .getFont()); } eachFont: for (Font font : fonts) { if (font.equals(myNormalFont)) continue; for (int i = 0; i < sampleString.length(); i++) { if (!font.canDisplay(sampleString.charAt(i))) { continue eachFont; } } return font; } return null; }
/** * Sets the font that the receiver will use to paint textual information for the specified cell in * this item to the font specified by the argument, or to the default font for that kind of * control if the argument is null. * * @param index the column index * @param font the new font (or null) * @exception IllegalArgumentException * <ul> * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed * </ul> * * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver * </ul> * * @since 3.0 */ public void setFont(int index, Font font) { checkWidget(); if (font != null && font.isDisposed()) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); } int count = Math.max(1, parent.getColumnCount()); if (0 > index || index > count - 1) return; if (cellFont == null) { if (font == null) return; cellFont = new Font[count]; } Font oldFont = cellFont[index]; if (oldFont == font) return; cellFont[index] = font; if (oldFont != null && oldFont.equals(font)) return; int modelIndex = parent.columnCount == 0 ? Table.FIRST_COLUMN : parent.columns[index].modelIndex; int /*long*/ fontHandle = font != null ? font.handle : 0; OS.gtk_list_store_set(parent.modelHandle, handle, modelIndex + Table.CELL_FONT, fontHandle, -1); /* * Bug in GTK. When using fixed-height-mode, * row changes do not cause the row to be repainted. The fix is to * invalidate the row when it is cleared. */ if ((parent.style & SWT.VIRTUAL) != 0) { if (OS.GTK_VERSION >= OS.VERSION(2, 3, 2) && OS.GTK_VERSION < OS.VERSION(2, 6, 3)) { redraw(); } } cached = true; if (font != null) { boolean customDraw = (parent.columnCount == 0) ? parent.firstCustomDraw : parent.columns[index].customDraw; if (!customDraw) { if ((parent.style & SWT.VIRTUAL) == 0) { int /*long*/ parentHandle = parent.handle; int /*long*/ column = 0; if (parent.columnCount > 0) { column = parent.columns[index].handle; } else { column = OS.gtk_tree_view_get_column(parentHandle, index); } if (column == 0) return; int /*long*/ textRenderer = parent.getTextRenderer(column); int /*long*/ imageRenderer = parent.getPixbufRenderer(column); OS.gtk_tree_view_column_set_cell_data_func( column, textRenderer, display.cellDataProc, parentHandle, 0); OS.gtk_tree_view_column_set_cell_data_func( column, imageRenderer, display.cellDataProc, parentHandle, 0); } if (parent.columnCount == 0) { parent.firstCustomDraw = true; } else { parent.columns[index].customDraw = true; } } } }
@SuppressWarnings("deprecation") void sync(GlyphView v) { Font f = v.getFont(); if ((metrics == null) || (!f.equals(metrics.getFont()))) { // fetch a new FontMetrics Container c = v.getContainer(); metrics = (c != null) ? c.getFontMetrics(f) : Toolkit.getDefaultToolkit().getFontMetrics(f); } }
/** Returns the specified font, but with the style's bold, underline and italic flags applied. */ public Font getStyledFont(Font font) { if (font == null) throw new NullPointerException("font param must not" + " be null"); if (font.equals(lastFont)) return lastStyledFont; lastFont = font; lastStyledFont = new Font( font.getFamily(), (bold ? Font.BOLD : 0) | (italic ? Font.ITALIC : 0), font.getSize()); if (underlined) { Map<TextAttribute, Object> attr = new Hashtable<TextAttribute, Object>(); attr.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON); lastStyledFont = lastStyledFont.deriveFont(attr); } return lastStyledFont; }
/** Returns the font metrics for the styled font. */ public FontMetrics getFontMetrics(Font font, JComponent comp) { if (font == null) throw new NullPointerException("font param must not" + " be null"); if (font.equals(lastFont) && fontMetrics != null) return fontMetrics; lastFont = font; lastStyledFont = new Font( font.getFamily(), (bold ? Font.BOLD : 0) | (italic ? Font.ITALIC : 0), font.getSize()); if (underlined) { Map<TextAttribute, Object> attr = new Hashtable<TextAttribute, Object>(); attr.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON); lastStyledFont = lastStyledFont.deriveFont(attr); } // fontMetrics = Toolkit.getDefaultToolkit().getFontMetrics(lastStyledFont); fontMetrics = comp.getFontMetrics(lastStyledFont); return fontMetrics; }
/** * Sets the font that the receiver will use to paint textual information for this item to the font * specified by the argument, or to the default font for that kind of control if the argument is * null. * * @param font the new font (or null) * @exception IllegalArgumentException * <ul> * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed * </ul> * * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver * </ul> * * @since 3.0 */ public void setFont(Font font) { checkWidget(); if (font != null && font.isDisposed()) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); } Font oldFont = this.font; if (oldFont == font) return; this.font = font; if (oldFont != null && oldFont.equals(font)) return; int /*long*/ fontHandle = font != null ? font.handle : 0; OS.gtk_list_store_set(parent.modelHandle, handle, Table.FONT_COLUMN, fontHandle, -1); /* * Bug in GTK. When using fixed-height-mode, * row changes do not cause the row to be repainted. The fix is to * invalidate the row when it is cleared. */ if ((parent.style & SWT.VIRTUAL) != 0) { if (OS.GTK_VERSION >= OS.VERSION(2, 3, 2) && OS.GTK_VERSION < OS.VERSION(2, 6, 3)) { redraw(); } } cached = true; }
public boolean equals(Object obj) { if (obj == null || !(CellStyle.class.equals(obj.getClass()))) return false; final CellStyle other = (CellStyle) obj; return id == other.id && alignment == other.alignment && borderBottom == other.borderBottom && borderLeft == other.borderLeft && borderRight == other.borderRight && borderTop == other.borderTop && (bottomBorderColor != null ? bottomBorderColor.equals(other.bottomBorderColor) : other.bottomBorderColor == null) && (dataFormat != null ? dataFormat.equals(other.dataFormat) : other.dataFormat == null) && (fillBackgroundColor != null ? fillBackgroundColor.equals(other.fillBackgroundColor) : other.fillBackgroundColor == null) && (fillForegroundColor != null ? fillForegroundColor.equals(other.fillForegroundColor) : other.fillForegroundColor == null) && fillPattern == other.fillPattern && (font != null ? font.equals(other.font) : other.font == null) && hidden == other.hidden && indention == other.indention && (leftBorderColor != null ? leftBorderColor.equals(other.leftBorderColor) : other.leftBorderColor == null) && (rightBorderColor != null ? rightBorderColor.equals(other.rightBorderColor) : other.rightBorderColor == null) && rotation == other.rotation && (topBorderColor != null ? topBorderColor.equals(other.topBorderColor) : other.topBorderColor == null) && verticalAlignment == other.verticalAlignment && wrapText == other.wrapText; }