| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
package org.pushingpixels.substance.flamingo.ribbon.ui; |
| 31 |
|
| 32 |
import java.awt.*; |
| 33 |
|
| 34 |
import javax.swing.*; |
| 35 |
import javax.swing.plaf.ComponentUI; |
| 36 |
|
| 37 |
import org.pushingpixels.flamingo.api.common.JCommandButton; |
| 38 |
import org.pushingpixels.flamingo.api.common.icon.ResizableIcon; |
| 39 |
import org.pushingpixels.flamingo.internal.ui.ribbon.BasicRibbonGalleryUI; |
| 40 |
import org.pushingpixels.flamingo.internal.ui.ribbon.JRibbonGallery; |
| 41 |
import org.pushingpixels.substance.api.*; |
| 42 |
import org.pushingpixels.substance.flamingo.common.TransitionAwareResizableIcon; |
| 43 |
import org.pushingpixels.substance.flamingo.common.ui.ActionPopupTransitionAwareUI; |
| 44 |
import org.pushingpixels.substance.internal.animation.StateTransitionTracker; |
| 45 |
import org.pushingpixels.substance.internal.utils.*; |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
public class SubstanceRibbonGalleryUI extends BasicRibbonGalleryUI { |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
public static ComponentUI createUI(JComponent comp) { |
| 60 |
SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); |
| 61 |
return new SubstanceRibbonGalleryUI(); |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
private SubstanceRibbonGalleryUI() { |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
@Override |
| 78 |
protected void paintRibbonGalleryBorder(Graphics graphics) { |
| 79 |
Graphics2D g2d = (Graphics2D) graphics; |
| 80 |
SubstanceColorScheme borderColorScheme = SubstanceColorSchemeUtilities |
| 81 |
.getColorScheme(this.ribbonGallery, |
| 82 |
ColorSchemeAssociationKind.BORDER, |
| 83 |
ComponentState.ENABLED); |
| 84 |
SubstanceImageCreator.paintBorder(this.ribbonGallery, g2d, |
| 85 |
this.margin.left, this.margin.top, this.ribbonGallery |
| 86 |
.getWidth() |
| 87 |
- this.margin.left - this.margin.right, |
| 88 |
this.ribbonGallery.getHeight() - this.margin.top |
| 89 |
- this.margin.bottom, SubstanceSizeUtils |
| 90 |
.getClassicButtonCornerRadius(SubstanceSizeUtils |
| 91 |
.getComponentFontSize(this.ribbonGallery)), |
| 92 |
borderColorScheme); |
| 93 |
g2d.dispose(); |
| 94 |
} |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
@Override |
| 103 |
protected ExpandCommandButton createExpandButton() { |
| 104 |
final ExpandCommandButton button = super.createExpandButton(); |
| 105 |
final int fontSize = SubstanceSizeUtils.getComponentFontSize(button); |
| 106 |
int arrowIconHeight = (int) SubstanceSizeUtils |
| 107 |
.getSmallArrowIconHeight(fontSize) + 3; |
| 108 |
int arrowIconWidth = (int) SubstanceSizeUtils |
| 109 |
.getSmallArrowIconWidth(fontSize); |
| 110 |
final ResizableIcon arrowIcon = new TransitionAwareResizableIcon( |
| 111 |
button, |
| 112 |
new TransitionAwareResizableIcon.StateTransitionTrackerDelegate() { |
| 113 |
@Override |
| 114 |
public StateTransitionTracker getStateTransitionTracker() { |
| 115 |
return ((ActionPopupTransitionAwareUI) button.getUI()) |
| 116 |
.getActionTransitionTracker(); |
| 117 |
} |
| 118 |
}, new TransitionAwareResizableIcon.Delegate() { |
| 119 |
@Override |
| 120 |
public Icon getColorSchemeIcon(SubstanceColorScheme scheme, |
| 121 |
int width, int height) { |
| 122 |
return SubstanceImageCreator |
| 123 |
.getDoubleArrowIcon( |
| 124 |
SubstanceSizeUtils |
| 125 |
.getComponentFontSize(button), |
| 126 |
width, |
| 127 |
height, |
| 128 |
SubstanceSizeUtils |
| 129 |
.getDoubleArrowStrokeWidth(fontSize), |
| 130 |
SwingConstants.SOUTH, scheme); |
| 131 |
} |
| 132 |
}, new Dimension(arrowIconWidth, arrowIconHeight)); |
| 133 |
button.setIcon(arrowIcon); |
| 134 |
return button; |
| 135 |
} |
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
@Override |
| 145 |
protected JCommandButton createScrollDownButton() { |
| 146 |
final JCommandButton button = super.createScrollDownButton(); |
| 147 |
final int fontSize = SubstanceSizeUtils.getComponentFontSize(button); |
| 148 |
int arrowIconHeight = (int) SubstanceSizeUtils |
| 149 |
.getSmallArrowIconHeight(fontSize); |
| 150 |
int arrowIconWidth = (int) SubstanceSizeUtils |
| 151 |
.getSmallArrowIconWidth(fontSize); |
| 152 |
final ResizableIcon arrowIcon = new TransitionAwareResizableIcon( |
| 153 |
button, |
| 154 |
new TransitionAwareResizableIcon.StateTransitionTrackerDelegate() { |
| 155 |
@Override |
| 156 |
public StateTransitionTracker getStateTransitionTracker() { |
| 157 |
return ((ActionPopupTransitionAwareUI) button.getUI()) |
| 158 |
.getActionTransitionTracker(); |
| 159 |
} |
| 160 |
}, new TransitionAwareResizableIcon.Delegate() { |
| 161 |
@Override |
| 162 |
public Icon getColorSchemeIcon(SubstanceColorScheme scheme, |
| 163 |
int width, int height) { |
| 164 |
return SubstanceImageCreator.getArrowIcon(width, |
| 165 |
height, SubstanceSizeUtils |
| 166 |
.getDoubleArrowStrokeWidth(fontSize), |
| 167 |
SwingConstants.SOUTH, scheme); |
| 168 |
} |
| 169 |
}, new Dimension(arrowIconWidth, arrowIconHeight)); |
| 170 |
button.setIcon(arrowIcon); |
| 171 |
return button; |
| 172 |
} |
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
@Override |
| 181 |
protected JCommandButton createScrollUpButton() { |
| 182 |
final JCommandButton button = super.createScrollUpButton(); |
| 183 |
final int fontSize = SubstanceSizeUtils.getComponentFontSize(button); |
| 184 |
int arrowIconHeight = (int) SubstanceSizeUtils |
| 185 |
.getSmallArrowIconHeight(fontSize); |
| 186 |
int arrowIconWidth = (int) SubstanceSizeUtils |
| 187 |
.getSmallArrowIconWidth(fontSize); |
| 188 |
ResizableIcon arrowIcon = new TransitionAwareResizableIcon( |
| 189 |
button, |
| 190 |
new TransitionAwareResizableIcon.StateTransitionTrackerDelegate() { |
| 191 |
@Override |
| 192 |
public StateTransitionTracker getStateTransitionTracker() { |
| 193 |
return ((ActionPopupTransitionAwareUI) button.getUI()) |
| 194 |
.getActionTransitionTracker(); |
| 195 |
} |
| 196 |
}, new TransitionAwareResizableIcon.Delegate() { |
| 197 |
@Override |
| 198 |
public Icon getColorSchemeIcon(SubstanceColorScheme scheme, |
| 199 |
int width, int height) { |
| 200 |
return SubstanceImageCreator.getArrowIcon(width, |
| 201 |
height, SubstanceSizeUtils |
| 202 |
.getDoubleArrowStrokeWidth(fontSize), |
| 203 |
SwingConstants.NORTH, scheme); |
| 204 |
} |
| 205 |
}, new Dimension(arrowIconWidth, arrowIconHeight)); |
| 206 |
button.setIcon(arrowIcon); |
| 207 |
return button; |
| 208 |
} |
| 209 |
} |