/** * Returns the spinner border insets under the specified font size. * * @param fontSize * Font size. * @return Spinner border insets under the specified font size. */ public static Insets getSpinnerBorderInsets(int fontSize) { // make sure that spinners and combos have the same height and text // alignment under all font sizes. Insets comboInsets = getComboBorderInsets(fontSize); return new Insets(comboInsets.top + 1, comboInsets.left, comboInsets.bottom + 1, comboInsets.right); }
/** * Returns the spinner border insets under the specified font size. * * @param fontSize * Font size. * @return Spinner border insets under the specified font size. */ public static Insets getSpinnerBorderInsets(int fontSize) { // make sure that spinners and combos have the same height and text // alignment under all font sizes. Insets comboInsets = getComboBorderInsets(fontSize); return new Insets(comboInsets.top + 1, comboInsets.left, comboInsets.bottom + 1, comboInsets.right); }
@Override public Object createValue(UIDefaults table) { return new SubstanceBorder(SubstanceSizeUtils .getComboBorderInsets(SubstanceSizeUtils .getControlFontSize())); } };
@Override public Object createValue(UIDefaults table) { return new SubstanceBorder( SubstanceSizeUtils .getComboBorderInsets(SubstanceSizeUtils .getControlFontSize())); } };
/** * Returns the combo box text border insets under the specified font size. * * @param fontSize * Font size. * @return Combo box text border insets under the specified font size. */ public static Insets getComboTextBorderInsets(int fontSize) { // the following makes sure that the text components // and combos have the same height and text alignment // under all font sizes. Insets textInsets = getTextBorderInsets(fontSize); Insets comboInsets = getComboBorderInsets(fontSize); int topDelta = textInsets.top - comboInsets.top;// - 1; int bottomDelta = textInsets.bottom - comboInsets.bottom;// - 1; int lrInset = getAdjustedSize(fontSize, 3, 4, 1, false); return new Insets(topDelta, lrInset, bottomDelta, lrInset); }
/** * Returns the table cell renderer insets under the specified font size. * * @param fontSize * Font size. * @return Table cell renderer insets under the specified font size. */ public static Insets getTableCellRendererInsets(int fontSize) { Insets textInsets = getTextBorderInsets(fontSize); Insets comboInsets = getComboBorderInsets(fontSize); int topDelta = textInsets.top - comboInsets.top - 1; int bottomDelta = textInsets.bottom - comboInsets.bottom - 2; if (fontSize == 11) { bottomDelta++; } int lrInset = SubstanceSizeUtils.getAdjustedSize(fontSize, 2, 4, 1, false); return new Insets(topDelta, lrInset, bottomDelta, lrInset); }
/** * Returns the combo box text border insets under the specified font size. * * @param fontSize * Font size. * @return Combo box text border insets under the specified font size. */ public static Insets getComboTextBorderInsets(int fontSize) { // the following makes sure that the text components // and combos have the same height and text alignment // under all font sizes. Insets textInsets = getTextBorderInsets(fontSize); Insets comboInsets = getComboBorderInsets(fontSize); int topDelta = textInsets.top - comboInsets.top;// - 1; int bottomDelta = textInsets.bottom - comboInsets.bottom;// - 1; int lrInset = getAdjustedSize(fontSize, 3, 4, 1, false); return new Insets(topDelta, lrInset, bottomDelta, lrInset); }
/** * Returns the table cell renderer insets under the specified font size. * * @param fontSize * Font size. * @return Table cell renderer insets under the specified font size. */ public static Insets getTableCellRendererInsets(int fontSize) { Insets textInsets = getTextBorderInsets(fontSize); Insets comboInsets = getComboBorderInsets(fontSize); int topDelta = textInsets.top - comboInsets.top - 1; int bottomDelta = textInsets.bottom - comboInsets.bottom - 2; if (fontSize == 11) { bottomDelta++; } int lrInset = SubstanceSizeUtils.getAdjustedSize(fontSize, 2, 4, 1, false); return new Insets(topDelta, lrInset, bottomDelta, lrInset); }
/** * Returns the list cell renderer insets under the specified font size. * * @param fontSize * Font size. * @return List cell renderer insets under the specified font size. */ public static Insets getListCellRendererInsets(int fontSize) { // Special handling to make non-editable combo boxes // have the same height as text components. The combo box // uses list cell renderer, so to compute the top and // bottom insets of a list cell renderer, we subtract the // insets of combo box from the insets of text component. // We also subtract the border stroke width - since the new // text component border appearance has a lighter "halo" // around the darker inner border. Insets textInsets = getTextBorderInsets(fontSize); Insets comboInsets = getComboBorderInsets(fontSize); int borderStroke = (int) getBorderStrokeWidth(fontSize); int topDelta = textInsets.top - comboInsets.top - borderStroke; int bottomDelta = textInsets.bottom - comboInsets.bottom - borderStroke; int lrInset = SubstanceSizeUtils.getAdjustedSize(fontSize, 4, 4, 1, false); return new Insets(topDelta, lrInset, bottomDelta, lrInset); }
/** * Returns the list cell renderer insets under the specified font size. * * @param fontSize * Font size. * @return List cell renderer insets under the specified font size. */ public static Insets getListCellRendererInsets(int fontSize) { // Special handling to make non-editable combo boxes // have the same height as text components. The combo box // uses list cell renderer, so to compute the top and // bottom insets of a list cell renderer, we subtract the // insets of combo box from the insets of text component. // We also subtract the border stroke width - since the new // text component border appearance has a lighter "halo" // around the darker inner border. Insets textInsets = getTextBorderInsets(fontSize); Insets comboInsets = getComboBorderInsets(fontSize); int borderStroke = (int) getBorderStrokeWidth(fontSize); int topDelta = textInsets.top - comboInsets.top - borderStroke; int bottomDelta = textInsets.bottom - comboInsets.bottom - borderStroke; int lrInset = SubstanceSizeUtils.getAdjustedSize(fontSize, 4, 4, 1, false); return new Insets(topDelta, lrInset, bottomDelta, lrInset); }
@Override protected void installDefaults() { super.installDefaults(); Border b = this.datePicker.getBorder(); if (b == null || b instanceof UIResource) { int fontSize = SubstanceSizeUtils .getComponentFontSize(this.datePicker); Insets borderInsets = SubstanceSizeUtils .getComboBorderInsets(fontSize); this.datePicker.setBorder(new SubstanceTextComponentBorder( borderInsets)); this.layoutInsets = SubstanceSizeUtils .getComboLayoutInsets(fontSize); } this.datePicker.setOpaque(false); }
private void updateComboBoxBorder() { Border b = this.comboBox.getBorder(); if (b == null || b instanceof UIResource) { int comboFontSize = SubstanceSizeUtils .getComponentFontSize(this.comboBox); Insets comboBorderInsets = SubstanceSizeUtils .getComboBorderInsets(comboFontSize); if (this.comboBox.isEditable()) { this.comboBox.setBorder(new SubstanceTextComponentBorder( comboBorderInsets)); } else { this.comboBox .setBorder(new BorderUIResource.EmptyBorderUIResource( comboBorderInsets)); // BasicComboBoxUI does not invalidate display size when // combo becomes uneditable. However, this is not good // in Substance which has different preferred size for // editable and uneditable combos. Calling the method below // will trigger the path in BasicComboBoxUI.Handler that // will invalidate the cached sizes. this.comboBox.setPrototypeDisplayValue(this.comboBox .getPrototypeDisplayValue()); } this.layoutInsets = SubstanceSizeUtils .getComboLayoutInsets(comboFontSize); } else { this.layoutInsets = new Insets(0, 0, 0, 0); } }
private void updateComboBoxBorder() { Border b = this.comboBox.getBorder(); if (b == null || b instanceof UIResource) { int comboFontSize = SubstanceSizeUtils .getComponentFontSize(this.comboBox); Insets comboBorderInsets = SubstanceSizeUtils .getComboBorderInsets(comboFontSize); if (this.comboBox.isEditable()) { this.comboBox.setBorder(new SubstanceTextComponentBorder( comboBorderInsets)); } else { this.comboBox .setBorder(new BorderUIResource.EmptyBorderUIResource( comboBorderInsets)); // BasicComboBoxUI does not invalidate display size when // combo becomes uneditable. However, this is not good // in Substance which has different preferred size for // editable and uneditable combos. Calling the method below // will trigger the path in BasicComboBoxUI.Handler that // will invalidate the cached sizes. this.comboBox.setPrototypeDisplayValue(this.comboBox .getPrototypeDisplayValue()); } this.layoutInsets = SubstanceSizeUtils .getComboLayoutInsets(comboFontSize); } else { this.layoutInsets = new Insets(0, 0, 0, 0); } }