本文整理汇总了Java中org.pushingpixels.substance.api.painter.border.SubstanceBorderPainter.paintBorder方法的典型用法代码示例。如果您正苦于以下问题:Java SubstanceBorderPainter.paintBorder方法的具体用法?Java SubstanceBorderPainter.paintBorder怎么用?Java SubstanceBorderPainter.paintBorder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pushingpixels.substance.api.painter.border.SubstanceBorderPainter
的用法示例。
在下文中一共展示了SubstanceBorderPainter.paintBorder方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createBackgroundImage
import org.pushingpixels.substance.api.painter.border.SubstanceBorderPainter; //导入方法依赖的package包/类
private static BufferedImage createBackgroundImage(JComboBox combo,
SubstanceButtonShaper shaper, SubstanceFillPainter fillPainter,
SubstanceBorderPainter borderPainter, int width, int height,
SubstanceColorScheme fillScheme, SubstanceColorScheme borderScheme,
float radius) {
int comboFontSize = SubstanceSizeUtils.getComponentFontSize(combo);
int borderDelta = (int) Math.floor(SubstanceSizeUtils
.getBorderStrokeWidth(comboFontSize) / 2.0);
Shape contour = SubstanceOutlineUtilities.getBaseOutline(width, height,
radius, null, borderDelta);
BufferedImage newBackground = SubstanceCoreUtilities.getBlankImage(
width, height);
Graphics2D finalGraphics = (Graphics2D) newBackground.getGraphics();
fillPainter.paintContourBackground(finalGraphics, combo, width, height,
contour, false, fillScheme, true);
int borderThickness = (int) SubstanceSizeUtils
.getBorderStrokeWidth(comboFontSize);
Shape contourInner = borderPainter.isPaintingInnerContour() ? SubstanceOutlineUtilities
.getBaseOutline(width, height, radius - borderThickness, null,
borderDelta + borderThickness)
: null;
borderPainter.paintBorder(finalGraphics, combo, width, height, contour,
contourInner, borderScheme);
return newBackground;
}
示例2: getSingleLayer
import org.pushingpixels.substance.api.painter.border.SubstanceBorderPainter; //导入方法依赖的package包/类
private Icon getSingleLayer(JSlider slider, int width, int delta,
SubstanceFillPainter fillPainter,
SubstanceBorderPainter borderPainter,
SubstanceColorScheme fillScheme,
SubstanceColorScheme borderScheme) {
int borderDelta = (int) Math.floor(SubstanceSizeUtils
.getBorderStrokeWidth(SubstanceSizeUtils
.getComponentFontSize(slider)) / 2.0);
Shape contour = SubstanceOutlineUtilities.getTriangleButtonOutline(
width, this.size - 1, 2, borderDelta);
BufferedImage stateImage = SubstanceCoreUtilities.getBlankImage(
this.size - 1, this.size - 1);
Graphics2D g2d = stateImage.createGraphics();
g2d.translate(delta, 0);
fillPainter.paintContourBackground(g2d, slider, width,
this.size - 1, contour, false, fillScheme, true);
int borderThickness = (int) SubstanceSizeUtils
.getBorderStrokeWidth(SubstanceSizeUtils
.getComponentFontSize(slider));
GeneralPath contourInner = SubstanceOutlineUtilities
.getTriangleButtonOutline(width, this.size - 1, 2,
borderThickness + borderDelta);
borderPainter.paintBorder(g2d, slider, width, this.size - 1,
contour, contourInner, borderScheme);
g2d.translate(-delta, 0);
if (this.isMirrorred)
stateImage = SubstanceImageCreator.getRotated(stateImage, 2);
return new ImageIcon(stateImage);
}
示例3: paintBorder
import org.pushingpixels.substance.api.painter.border.SubstanceBorderPainter; //导入方法依赖的package包/类
/**
* Paints border instance of specified dimensions and status.
*
* @param c
* Component.
* @param graphics
* Graphics context.
* @param x
* Component left X (in graphics context).
* @param y
* Component top Y (in graphics context).
* @param width
* Border width.
* @param height
* Border height.
* @param radius
* Border radius.
* @param borderScheme1
* First border color scheme.
* @param borderScheme2
* Second border color scheme.
* @param cyclePos
* Cycle position for interpolating the border color schemes.
*/
public static void paintBorder(Component c, Graphics2D graphics, int x,
int y, int width, int height, float radius,
SubstanceColorScheme borderScheme) {
SubstanceBorderPainter borderPainter = SubstanceCoreUtilities
.getBorderPainter(c);
graphics.translate(x, y);
int componentFontSize = SubstanceSizeUtils.getComponentFontSize(c);
int borderDelta = (int) Math.floor(SubstanceSizeUtils
.getBorderStrokeWidth(componentFontSize) / 2.0);
Shape contour = SubstanceOutlineUtilities.getBaseOutline(width, height,
radius, null, borderDelta);
int borderThickness = (int) SubstanceSizeUtils
.getBorderStrokeWidth(componentFontSize);
boolean skipInnerBorder = (c instanceof JTextComponent)
|| ((SwingUtilities.getAncestorOfClass(CellRendererPane.class,
c) != null) && (SwingUtilities.getAncestorOfClass(
JFileChooser.class, c) != null));
GeneralPath contourInner = skipInnerBorder ? null
: SubstanceOutlineUtilities.getBaseOutline(width, height,
radius - borderThickness, null, borderThickness
+ borderDelta);
borderPainter.paintBorder(graphics, c, width, height, contour,
contourInner, borderScheme);
graphics.translate(-x, -y);
}
示例4: getThumbHorizontal
import org.pushingpixels.substance.api.painter.border.SubstanceBorderPainter; //导入方法依赖的package包/类
/**
* Retrieves image for horizontal thumb.
*
* @param scrollBar
* Scroll bar.
* @param width
* Thumb width.
* @param height
* Thumb height.
* @param kind
* Color scheme kind.
* @param cyclePos
* Cycle position.
* @param scheme
* The first color scheme.
* @param scheme2
* The second color scheme.
* @param borderScheme
* The first border color scheme.
* @param borderScheme2
* The second border color scheme.
* @return Image for horizontal thumb.
*/
private static BufferedImage getThumbHorizontal(JScrollBar scrollBar,
int width, int height, SubstanceColorScheme scheme,
SubstanceColorScheme borderScheme) {
SubstanceFillPainter painter = SubstanceCoreUtilities
.getFillPainter(scrollBar);
SubstanceButtonShaper shaper = SubstanceCoreUtilities
.getButtonShaper(scrollBar);
SubstanceBorderPainter borderPainter = SubstanceCoreUtilities
.getBorderPainter(scrollBar);
HashMapKey key = SubstanceCoreUtilities.getHashKey(width, height,
scheme.getDisplayName(), borderScheme.getDisplayName(), painter
.getDisplayName(), shaper.getDisplayName(),
borderPainter.getDisplayName());
float radius = height / 2;
if (shaper instanceof ClassicButtonShaper)
radius = SubstanceSizeUtils
.getClassicButtonCornerRadius(SubstanceSizeUtils
.getComponentFontSize(scrollBar));
int borderDelta = (int) Math.floor(SubstanceSizeUtils
.getBorderStrokeWidth(SubstanceSizeUtils
.getComponentFontSize(scrollBar)) / 2.0);
GeneralPath contour = SubstanceOutlineUtilities.getBaseOutline(width,
height, radius, null, borderDelta);
BufferedImage opaque = SubstanceScrollBarUI.thumbHorizontalMap.get(key);
if (opaque == null) {
// System.out.println("New image for horizontal thumb");
opaque = SubstanceCoreUtilities.getBlankImage(width, height);
painter.paintContourBackground(opaque.createGraphics(), scrollBar,
width, height, contour, false, scheme, true);
borderPainter.paintBorder(opaque.getGraphics(), scrollBar, width,
height, contour, null, borderScheme);
SubstanceScrollBarUI.thumbHorizontalMap.put(key, opaque);
}
return opaque;
}
示例5: createBackgroundImage
import org.pushingpixels.substance.api.painter.border.SubstanceBorderPainter; //导入方法依赖的package包/类
private static BufferedImage createBackgroundImage(AbstractButton button,
SubstanceButtonShaper shaper, SubstanceFillPainter fillPainter,
SubstanceBorderPainter borderPainter, int width, int height,
SubstanceColorScheme colorScheme,
SubstanceColorScheme borderScheme, Set<Side> openSides,
boolean isContentAreaFilled, boolean isBorderPainted) {
int openDelta = (int) (Math.ceil(3.0 * SubstanceSizeUtils
.getBorderStrokeWidth(SubstanceSizeUtils
.getComponentFontSize(button))));
int deltaLeft = ((openSides != null) && openSides.contains(Side.LEFT)) ? openDelta
: 0;
int deltaRight = ((openSides != null) && openSides.contains(Side.RIGHT)) ? openDelta
: 0;
int deltaTop = ((openSides != null) && openSides.contains(Side.TOP)) ? openDelta
: 0;
int deltaBottom = ((openSides != null) && openSides
.contains(Side.BOTTOM)) ? openDelta : 0;
// System.err.println(key);
int borderDelta = (int) Math.floor(SubstanceSizeUtils
.getBorderStrokeWidth(SubstanceSizeUtils
.getComponentFontSize(button)) / 2.0);
Shape contour = shaper.getButtonOutline(button, new Insets(borderDelta,
borderDelta, borderDelta, borderDelta), width + deltaLeft
+ deltaRight, height + deltaTop + deltaBottom, false);
BufferedImage newBackground = SubstanceCoreUtilities.getBlankImage(
width, height);
Graphics2D finalGraphics = (Graphics2D) newBackground.getGraphics();
finalGraphics.translate(-deltaLeft, -deltaTop);
if (isContentAreaFilled) {
fillPainter.paintContourBackground(finalGraphics, button, width
+ deltaLeft + deltaRight, height + deltaTop + deltaBottom,
contour, false, colorScheme, true);
}
if (isBorderPainted) {
int borderThickness = (int) SubstanceSizeUtils
.getBorderStrokeWidth(SubstanceSizeUtils
.getComponentFontSize(button));
Shape contourInner = borderPainter.isPaintingInnerContour() ? shaper
.getButtonOutline(button, new Insets(borderDelta
+ borderThickness, borderDelta + borderThickness,
borderDelta + borderThickness, borderDelta
+ borderThickness), width + deltaLeft
+ deltaRight, height + deltaTop + deltaBottom, true)
: null;
borderPainter.paintBorder(finalGraphics, button, width + deltaLeft
+ deltaRight, height + deltaTop + deltaBottom, contour,
contourInner, borderScheme);
}
return newBackground;
}
示例6: paintSplitDividerBumpImage
import org.pushingpixels.substance.api.painter.border.SubstanceBorderPainter; //导入方法依赖的package包/类
/**
* Paints the bump dots on the split pane dividers.
*
* @param g
* Graphics context.
* @param divider
* Split pane divider.
* @param x
* X coordinate of the bump dots.
* @param y
* Y coordinate of the bump dots.
* @param width
* Width of the bump dots area.
* @param height
* Height of the bump dots area.
* @param isHorizontal
* Indicates whether the dots are horizontal.
* @param componentState
* Split pane divider state.
* @param colorScheme1
* First color scheme.
* @param colorScheme2
* Second color scheme.
* @param interpolationCyclePos
* Interpolation cycle.
*/
public static void paintSplitDividerBumpImage(Graphics g,
SubstanceSplitPaneDivider divider, int x, int y, int width,
int height, boolean isHorizontal, SubstanceColorScheme colorScheme) {
Graphics2D graphics = (Graphics2D) g.create();
graphics.translate(x, y);
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
int componentFontSize = SubstanceSizeUtils
.getComponentFontSize(divider);
int bumpDotDiameter = SubstanceSizeUtils
.getBigDragBumpDiameter(componentFontSize);
int bumpCellSize = (int) (1.5 * bumpDotDiameter + 1);
int bumpRows = isHorizontal ? 1 : Math
.max(1, height / bumpCellSize - 1);
int bumpColumns = isHorizontal ? Math
.max(1, (width - 2) / bumpCellSize) : 1;
int bumpRowOffset = (height - bumpCellSize * bumpRows) / 2;
int bumpColOffset = 1 + (width - bumpCellSize * bumpColumns) / 2;
BufferedImage singleDot = SubstanceCoreUtilities.getBlankImage(
bumpDotDiameter, bumpDotDiameter);
Graphics2D dotGraphics = (Graphics2D) singleDot.getGraphics();
dotGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
Color markColor = SubstanceColorUtilities.getMarkColor(colorScheme,
divider.isEnabled());
dotGraphics.setColor(markColor);
dotGraphics.fillOval(0, 0, bumpDotDiameter, bumpDotDiameter);
dotGraphics.setComposite(AlphaComposite.getInstance(
AlphaComposite.SRC_OVER, 0.4f));
SubstanceBorderPainter borderPainter = SubstanceCoreUtilities
.getBorderPainter(divider);
borderPainter.paintBorder(dotGraphics, divider, width, height,
new Ellipse2D.Float(0, 0, bumpDotDiameter - 1,
bumpDotDiameter - 1), null, colorScheme);
graphics.setComposite(LafWidgetUtilities.getAlphaComposite(divider,
0.8f, g));
for (int col = 0; col < bumpColumns; col++) {
int cx = bumpColOffset + col * bumpCellSize;
for (int row = 0; row < bumpRows; row++) {
int cy = bumpRowOffset + row * bumpCellSize
+ (bumpCellSize - bumpDotDiameter) / 2;
graphics.drawImage(singleDot, cx, cy, null);
}
}
graphics.dispose();
}
示例7: getCloseButtonImage
import org.pushingpixels.substance.api.painter.border.SubstanceBorderPainter; //导入方法依赖的package包/类
/**
* Retrieves the image of the close button.
*
* @param tabPane
* Tabbed pane.
* @param width
* Close button width.
* @param height
* Close button height.
* @param cyclePos
* Tab cycle position (for rollover effects).
* @param toPaintBorder
* Indication whether the button background (including contour)
* needs to be painted.
* @param fillScheme
* Color scheme for coloring the background.
* @param fillScheme2
* Second color scheme for coloring the background.
* @param markScheme
* Color scheme for painting the close mark.
* @param markScheme2
* Second color scheme for painting the close mark.
* @return Image of the close button of specified parameters.
*/
private static BufferedImage getCloseButtonImage(JTabbedPane tabPane,
int width, int height, boolean toPaintBorder,
SubstanceColorScheme fillScheme, SubstanceColorScheme markScheme) {
SubstanceFillPainter fillPainter = SubstanceCoreUtilities
.getFillPainter(tabPane);
if (fillPainter == null)
return null;
HashMapKey key = SubstanceCoreUtilities.getHashKey(width, height,
toPaintBorder, fillPainter.getDisplayName(), fillScheme
.getDisplayName(), markScheme.getDisplayName());
BufferedImage result = SubstanceTabbedPaneUI.closeButtonMap.get(key);
if (result == null) {
result = SubstanceCoreUtilities.getBlankImage(width, height);
Graphics2D finalGraphics = (Graphics2D) result.getGraphics();
if (toPaintBorder) {
GeneralPath contour = SubstanceOutlineUtilities.getBaseOutline(
width, height, 1, null);
fillPainter.paintContourBackground(finalGraphics, tabPane,
width, height, contour, false, fillScheme, true);
// finalGraphics.drawImage(background, 0, 0, null);
SubstanceBorderPainter borderPainter = SubstanceCoreUtilities
.getBorderPainter(tabPane);
finalGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
borderPainter.paintBorder(finalGraphics, tabPane, width,
height, contour, null, markScheme);
}
finalGraphics.setStroke(new BasicStroke(SubstanceSizeUtils
.getTabCloseButtonStrokeWidth(SubstanceSizeUtils
.getComponentFontSize(tabPane))));
int delta = (int) (Math.floor(SubstanceSizeUtils
.getBorderStrokeWidth(SubstanceSizeUtils
.getComponentFontSize(tabPane))));
if (delta % 2 != 0)
delta--;
int iconSize = width - delta;
Icon closeIcon = SubstanceImageCreator.getCloseIcon(iconSize,
markScheme, markScheme);
closeIcon.paintIcon(tabPane, finalGraphics, delta / 2, delta / 2);
SubstanceTabbedPaneUI.closeButtonMap.put(key, result);
}
return result;
}
示例8: paintSliderTrack
import org.pushingpixels.substance.api.painter.border.SubstanceBorderPainter; //导入方法依赖的package包/类
/**
* Paints the slider track.
*
* @param graphics
* Graphics.
* @param drawInverted
* Indicates whether the value-range shown for the slider is
* reversed.
* @param fillColorScheme
* Fill color scheme.
* @param borderScheme
* Border color scheme.
* @param width
* Track width.
* @param height
* Track height.
*/
private void paintSliderTrack(Graphics2D graphics, boolean drawInverted,
SubstanceColorScheme fillColorScheme,
SubstanceColorScheme borderScheme, int width, int height) {
Graphics2D g2d = (Graphics2D) graphics.create();
SubstanceFillPainter fillPainter = ClassicFillPainter.INSTANCE;
SubstanceBorderPainter borderPainter = SubstanceCoreUtilities
.getBorderPainter(this.slider);
int componentFontSize = SubstanceSizeUtils
.getComponentFontSize(this.slider);
int borderDelta = (int) Math.floor(SubstanceSizeUtils
.getBorderStrokeWidth(componentFontSize) / 2.0);
float radius = SubstanceSizeUtils
.getClassicButtonCornerRadius(componentFontSize) / 2.0f;
int borderThickness = (int) SubstanceSizeUtils
.getBorderStrokeWidth(componentFontSize);
HashMapKey key = SubstanceCoreUtilities.getHashKey(width, height,
radius, borderDelta, borderThickness, fillColorScheme
.getDisplayName(), borderScheme.getDisplayName());
BufferedImage trackImage = trackCache.get(key);
if (trackImage == null) {
trackImage = SubstanceCoreUtilities.getBlankImage(width + 1,
height + 1);
Graphics2D cacheGraphics = trackImage.createGraphics();
Shape contour = SubstanceOutlineUtilities.getBaseOutline(width + 1,
height + 1, radius, null, borderDelta);
fillPainter.paintContourBackground(cacheGraphics, slider, width,
height, contour, false, fillColorScheme, false);
GeneralPath contourInner = SubstanceOutlineUtilities
.getBaseOutline(width + 1, height + 1, radius
- borderThickness, null, borderThickness
+ borderDelta);
borderPainter.paintBorder(cacheGraphics, slider, width + 1,
height + 1, contour, contourInner, borderScheme);
trackCache.put(key, trackImage);
cacheGraphics.dispose();
}
g2d.drawImage(trackImage, 0, 0, null);
g2d.dispose();
}
示例9: getTrackHorizontal
import org.pushingpixels.substance.api.painter.border.SubstanceBorderPainter; //导入方法依赖的package包/类
/**
* Returns the image for a horizontal track.
*
* @param scrollBar
* Scroll bar.
* @param trackBounds
* Track bounds.
* @param compLeftState
* The state of the left button in the scroll bar.
* @param compRightState
* The state of the closest right button in the scroll bar.
* @param width
* Scroll track width.
* @param height
* Scroll track height.
* @param graphicsComposite
* Composite to apply before painting the track.
* @return Horizontal track image.
*/
private static BufferedImage getTrackHorizontal(JScrollBar scrollBar,
int width, int height) {
SubstanceButtonShaper shaper = SubstanceCoreUtilities
.getButtonShaper(scrollBar);
SubstanceColorScheme mainScheme = SubstanceColorSchemeUtilities
.getColorScheme(scrollBar,
scrollBar.isEnabled() ? ComponentState.ENABLED
: ComponentState.DISABLED_UNSELECTED);
SubstanceColorScheme mainBorderScheme = SubstanceColorSchemeUtilities
.getColorScheme(scrollBar, ColorSchemeAssociationKind.BORDER,
scrollBar.isEnabled() ? ComponentState.ENABLED
: ComponentState.DISABLED_UNSELECTED);
HashMapKey key = SubstanceCoreUtilities.getHashKey(mainScheme
.getDisplayName(), mainBorderScheme.getDisplayName(), width,
height, shaper.getDisplayName());
float radius = height / 2;
if (shaper instanceof ClassicButtonShaper)
radius = SubstanceSizeUtils
.getClassicButtonCornerRadius(SubstanceSizeUtils
.getComponentFontSize(scrollBar));
int borderDelta = (int) Math.floor(SubstanceSizeUtils
.getBorderStrokeWidth(SubstanceSizeUtils
.getComponentFontSize(scrollBar)) / 2.0);
Shape contour = SubstanceOutlineUtilities.getBaseOutline(width, height,
radius, null, borderDelta);
BufferedImage result = SubstanceScrollBarUI.trackHorizontalMap.get(key);
if (result == null) {
result = SubstanceCoreUtilities.getBlankImage(width, height);
SimplisticFillPainter.INSTANCE.paintContourBackground(result
.createGraphics(), scrollBar, width, height, contour,
false, mainScheme, true);
SubstanceBorderPainter borderPainter = new SimplisticSoftBorderPainter();
borderPainter.paintBorder(result.getGraphics(), scrollBar, width,
height, contour, null, mainBorderScheme);
SubstanceScrollBarUI.trackHorizontalMap.put(key, result);
}
return result;
}
示例10: getTrackVertical
import org.pushingpixels.substance.api.painter.border.SubstanceBorderPainter; //导入方法依赖的package包/类
/**
* Returns the image for a vertical track.
*
* @param trackBounds
* Track bounds.
* @param scrollBar
* Scroll bar.
* @param compTopState
* The state of the top button in the scroll bar.
* @param compBottomState
* The state of the closest bottom button in the scroll bar.
* @param width
* Scroll track width.
* @param height
* Scroll track height.
* @param graphicsComposite
* Composite to apply before painting the track.
* @return Vertical track image.
*/
private static BufferedImage getTrackVertical(JScrollBar scrollBar,
int width, int height) {
SubstanceButtonShaper shaper = SubstanceCoreUtilities
.getButtonShaper(scrollBar);
SubstanceColorScheme mainScheme = SubstanceColorSchemeUtilities
.getColorScheme(scrollBar,
scrollBar.isEnabled() ? ComponentState.ENABLED
: ComponentState.DISABLED_UNSELECTED);
SubstanceColorScheme mainBorderScheme = SubstanceColorSchemeUtilities
.getColorScheme(scrollBar, ColorSchemeAssociationKind.BORDER,
scrollBar.isEnabled() ? ComponentState.ENABLED
: ComponentState.DISABLED_UNSELECTED);
HashMapKey key = SubstanceCoreUtilities.getHashKey(mainScheme
.getDisplayName(), mainBorderScheme.getDisplayName(), width,
height, shaper.getDisplayName());
BufferedImage result = SubstanceScrollBarUI.trackVerticalMap.get(key);
if (result == null) {
float radius = width / 2;
if (shaper instanceof ClassicButtonShaper)
radius = SubstanceSizeUtils
.getClassicButtonCornerRadius(SubstanceSizeUtils
.getComponentFontSize(scrollBar));
int borderDelta = (int) Math.floor(SubstanceSizeUtils
.getBorderStrokeWidth(SubstanceSizeUtils
.getComponentFontSize(scrollBar)) / 2.0);
Shape contour = SubstanceOutlineUtilities.getBaseOutline(height,
width, radius, null, borderDelta);
result = SubstanceCoreUtilities.getBlankImage(height, width);
SimplisticFillPainter.INSTANCE.paintContourBackground(result
.createGraphics(), scrollBar, height, width, contour,
false, mainScheme, true);
SubstanceBorderPainter borderPainter = new SimplisticSoftBorderPainter();
borderPainter.paintBorder(result.getGraphics(), scrollBar, height,
width, contour, null, mainBorderScheme);
result = SubstanceImageCreator.getRotated(result, 3);
SubstanceScrollBarUI.trackVerticalMap.put(key, result);
}
return result;
}
示例11: getThumbVertical
import org.pushingpixels.substance.api.painter.border.SubstanceBorderPainter; //导入方法依赖的package包/类
/**
* Retrieves image for vertical thumb.
*
* @param scrollBar
* Scroll bar.
* @param width
* Thumb width.
* @param height
* Thumb height.
* @param kind
* Color scheme kind.
* @param cyclePos
* Cycle position.
* @param scheme
* The first color scheme.
* @param scheme2
* The second color scheme.
* @param borderScheme
* The first border color scheme.
* @param borderScheme2
* The second border color scheme.
* @return Image for vertical thumb.
*/
private static BufferedImage getThumbVertical(JScrollBar scrollBar,
int width, int height, SubstanceColorScheme scheme,
SubstanceColorScheme borderScheme) {
SubstanceFillPainter painter = SubstanceCoreUtilities
.getFillPainter(scrollBar);
SubstanceButtonShaper shaper = SubstanceCoreUtilities
.getButtonShaper(scrollBar);
SubstanceBorderPainter borderPainter = SubstanceCoreUtilities
.getBorderPainter(scrollBar);
HashMapKey key = SubstanceCoreUtilities.getHashKey(width, height,
scheme.getDisplayName(), borderScheme.getDisplayName(), painter
.getDisplayName(), shaper.getDisplayName(),
borderPainter.getDisplayName());
BufferedImage result = SubstanceScrollBarUI.thumbVerticalMap.get(key);
if (result == null) {
// System.out.println("Cache miss - computing");
// System.out.println("New image for vertical thumb");
float radius = width / 2;
if (shaper instanceof ClassicButtonShaper)
radius = SubstanceSizeUtils
.getClassicButtonCornerRadius(SubstanceSizeUtils
.getComponentFontSize(scrollBar));
int borderDelta = (int) Math.floor(SubstanceSizeUtils
.getBorderStrokeWidth(SubstanceSizeUtils
.getComponentFontSize(scrollBar)) / 2.0);
GeneralPath contour = SubstanceOutlineUtilities.getBaseOutline(
height, width, radius, null, borderDelta);
result = SubstanceCoreUtilities.getBlankImage(height, width);
painter.paintContourBackground(result.createGraphics(), scrollBar,
height, width, contour, false, scheme, true);
// int borderThickness = (int) SubstanceSizeUtils
// .getBorderStrokeWidth(SubstanceSizeUtils
// .getComponentFontSize(scrollBar));
// GeneralPath contourInner = SubstanceOutlineUtilities
// .getBaseOutline(height, width, radius, null,
// borderThickness + borderDelta);
borderPainter.paintBorder(result.getGraphics(), scrollBar, height,
width, contour, null, borderScheme);
result = SubstanceImageCreator.getRotated(result, 3);
// System.out.println(key);
SubstanceScrollBarUI.thumbVerticalMap.put(key, result);
}
return result;
}
示例12: paintHighlightBorder
import org.pushingpixels.substance.api.painter.border.SubstanceBorderPainter; //导入方法依赖的package包/类
/**
* Paints the highlight border for the specified component.
*
* @param graphics
* Graphic context.
* @param comp
* Component.
* @param width
* Border width.
* @param height
* Border width.
* @param borderAlpha
* Border alpha.
* @param openSides
* The sides specified in this set will not be painted. Can be
* <code>null</code> or empty.
* @param highlightBorderPainter
* Border painter for the highlights.
* @param borderColorScheme
* The border color scheme.
*/
private static void paintHighlightBorder(Graphics2D graphics,
Component comp, int width, int height, float borderAlpha,
Set<Side> openSides, SubstanceBorderPainter highlightBorderPainter,
SubstanceColorScheme borderColorScheme) {
if (borderAlpha <= 0.0f)
return;
int openDelta = 3 + (int) (Math.ceil(3.0 * SubstanceSizeUtils
.getBorderStrokeWidth(SubstanceSizeUtils
.getComponentFontSize(comp))));
int deltaLeft = openSides.contains(Side.LEFT) ? openDelta : 0;
int deltaRight = openSides.contains(Side.RIGHT) ? openDelta : 0;
int deltaTop = openSides.contains(Side.TOP) ? openDelta : 0;
int deltaBottom = openSides.contains(Side.BOTTOM) ? openDelta : 0;
int borderDelta = (int) Math.floor(SubstanceSizeUtils
.getBorderStrokeWidth(SubstanceSizeUtils
.getComponentFontSize(comp)) / 2.0);
Shape contour = new Rectangle(borderDelta, borderDelta, width
+ deltaLeft + deltaRight - 2 * borderDelta - 1, height
+ deltaTop + deltaBottom - 2 * borderDelta - 1);
Graphics2D g2d = (Graphics2D) graphics.create();
g2d.translate(-deltaLeft, -deltaTop);
g2d.setComposite(LafWidgetUtilities.getAlphaComposite(null,
borderAlpha, graphics));
int borderThickness = (int) SubstanceSizeUtils
.getBorderStrokeWidth(SubstanceSizeUtils
.getComponentFontSize(comp));
Shape contourInner = new Rectangle(borderDelta + borderThickness,
borderDelta + borderThickness, width + deltaLeft + deltaRight
- 2 * borderDelta - 2 * borderThickness - 1, height
+ deltaTop + deltaBottom - 2 * borderDelta - 2
* borderThickness - 1);
highlightBorderPainter.paintBorder(g2d, comp, width + deltaLeft
+ deltaRight, height + deltaTop + deltaBottom, contour,
contourInner, borderColorScheme);
g2d.dispose();
}