@Override public Insets getBorderInsets(Component c) { float borderStrokeWidth = SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(c)); int ins = (int) borderStrokeWidth; return new Insets(ins, ins, ins, ins); }
@Override protected Dimension getPreferredInnerHorizontal() { int size = SubstanceSizeUtils.getComponentFontSize(this.progressBar); size += 2 * SubstanceSizeUtils.getAdjustedSize(size, 1, 4, 1, false); return new Dimension(146 + SubstanceSizeUtils.getAdjustedSize(size, 0, 1, 10, false), size); }
/** * 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 shorter dimension of the track. * * @return Shorter dimension of the track. */ protected int getTrackWidth() { return SubstanceSizeUtils.getSliderTrackSize(SubstanceSizeUtils .getComponentFontSize(this.slider)); }
/** * Returns the height of spinner arrow icons under the specified font size. * * @param fontSize * Font size. * @return Height of spinner arrow icons under the specified font size. */ public static float getSpinnerArrowIconHeight(int fontSize) { float result = SubstanceSizeUtils.getArrowIconHeight(fontSize) + SubstanceSizeUtils .getAdjustedSize(fontSize + 1, 0, 1, -0.25f); return result; }
/** * Returns the width of spinner arrow icons under the specified font size. * * @param fontSize * Font size. * @return Width of spinner arrow icons under the specified font size. */ public static float getSpinnerArrowIconWidth(int fontSize) { int result = (int) (SubstanceSizeUtils.getArrowIconWidth(fontSize) + SubstanceSizeUtils .getAdjustedSize(fontSize, 1, 1, -0.15f)); if (result % 2 == 0) result--; return result; }
@Override public boolean isInside(MouseEvent me) { if (!SubstanceLookAndFeel.isCurrentLookAndFeel()) { return false; } Shape contour = SubstanceOutlineUtilities.getBaseOutline( this.textField, 2.0f * SubstanceSizeUtils .getClassicButtonCornerRadius(SubstanceSizeUtils .getComponentFontSize(this.textField)), null); return contour.contains(me.getPoint()); }
@Override public void paint(Graphics g, JComponent c) { Graphics2D graphics = (Graphics2D) g.create(); int componentFontSize = SubstanceSizeUtils .getComponentFontSize(this.datePicker); int borderDelta = (int) Math.floor(SubstanceSizeUtils .getBorderStrokeWidth(componentFontSize)); Shape contour = SubstanceOutlineUtilities.getBaseOutline(datePicker .getWidth(), datePicker.getHeight(), Math.max(0, 2.0f * SubstanceSizeUtils .getClassicButtonCornerRadius(componentFontSize) - borderDelta), null, borderDelta); graphics.setColor(SubstanceTextUtilities .getTextBackgroundFillColor(this.datePicker)); graphics.fill(contour); super.paint(g, c); }
@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); }
/** * 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); }
/** * Paints the focus indication. * * @param g * Graphics. * @param bounds * Bounds for text. */ protected void paintFocus(Graphics g, Rectangle bounds) { int fontSize = SubstanceSizeUtils.getComponentFontSize(this.comboBox); int focusRingPadding = SubstanceSizeUtils.getFocusRingPadding(fontSize) / 2; int x = bounds.x; int y = bounds.y; Graphics2D g2d = (Graphics2D) g.create(); g2d.translate(x, y); SubstanceCoreUtilities.paintFocus(g2d, this.comboBox, this.comboBox, this, SubstanceOutlineUtilities.getBaseOutline(bounds.width, bounds.height, SubstanceSizeUtils .getClassicButtonCornerRadius(fontSize), null, 0), bounds, 1.0f, focusRingPadding); g2d.dispose(); }
@Override protected void configureEditor() { super.configureEditor(); // This for Mustang - setting Substance once again adds a border on // the text field in the combo editor. if (this.editor instanceof JComponent) { Insets ins = SubstanceSizeUtils .getComboTextBorderInsets(SubstanceSizeUtils .getComponentFontSize(this.editor)); ((JComponent) this.editor).setBorder(new EmptyBorder(ins.top, ins.left, ins.bottom, ins.right)); this.editor.setBackground(this.comboBox.getBackground()); // ((JComponent) this.editor).setBorder(new LineBorder(Color.red)); } }
@Override public int getLookupIconSize() { int result = 2 + SubstanceSizeUtils.getControlFontSize(); if (result % 2 != 0) result++; return result; }
/** * Returns the slider track size under the specified font size. * * @param fontSize * Font size. * @return Slider track size under the specified font size. */ public static int getSliderTrackSize(int fontSize) { return SubstanceSizeUtils.getAdjustedSize(fontSize, 5, 4, 1, false); }
@Override public Object createValue(UIDefaults table) { return new SubstanceBorder(SubstanceSizeUtils .getComboBorderInsets(SubstanceSizeUtils .getControlFontSize())); } };
/** * Returns arrow icon for the specified parameters. * * @param fontSize * Font size. * @param direction * Arrow direction. * @param colorScheme * Arrow icon color scheme. * @return Arrow icon. */ public static Icon getArrowIcon(int fontSize, int direction, SubstanceColorScheme colorScheme) { float width = SubstanceSizeUtils.getArrowIconWidth(fontSize); float height = SubstanceSizeUtils.getArrowIconHeight(fontSize); if (direction == SwingConstants.CENTER) height *= 2; float strokeWidth = SubstanceSizeUtils.getArrowStrokeWidth(fontSize); return new ImageIcon(getArrow(width, height, strokeWidth, direction, colorScheme)); }
/** * Returns double arrow icon for the specified parameters. * * @param fontSize * Font size. * @param deltaWidth * Arrow width delta. * @param deltaHeight * Arrow height delta. * @param deltaStrokeWidth * Arrow stroke width delta. * @param direction * Arrow direction. * @param colorScheme * Color scheme for the arrow. * @return Double arrow icon. */ public static Icon getDoubleArrowIconDelta(int fontSize, float deltaWidth, float deltaHeight, float deltaStrokeWidth, int direction, SubstanceColorScheme colorScheme) { float arrowWidth = SubstanceSizeUtils.getArrowIconWidth(fontSize) + deltaWidth; float arrowHeight = SubstanceSizeUtils.getArrowIconHeight(fontSize) + deltaHeight; float arrowStrokeWidth = SubstanceSizeUtils .getDoubleArrowStrokeWidth(fontSize) + deltaStrokeWidth; return getDoubleArrowIcon(fontSize, arrowWidth, arrowHeight, arrowStrokeWidth, direction, colorScheme); }
@Override public void paintFocus(Graphics g) { SubstanceCoreUtilities.paintFocus(g, this.slider, this.slider, this, null, null, 1.0f, (int) Math.ceil(SubstanceSizeUtils .getFocusStrokeWidth(SubstanceSizeUtils .getComponentFontSize(this.slider))) / 2); }
@Override public Object createValue(UIDefaults table) { return SubstanceIconFactory .getSliderVerticalIcon( SubstanceSizeUtils .getSliderIconSize(SubstanceSizeUtils .getControlFontSize()) - 2, true); } },
@Override public Object createValue(UIDefaults table) { return new SubstanceBorder(SubstanceSizeUtils .getToolTipBorderInsets(SubstanceSizeUtils .getControlFontSize())); } };