下面列出了java.awt.SystemColor#control ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public static Color getDefaultBackgroundColor() {
if (Configuration.useRibbonInterface.get()) {
return SubstanceLookAndFeel.getCurrentSkin().getColorScheme(DecorationAreaType.GENERAL, ColorSchemeAssociationKind.FILL, ComponentState.ENABLED).getBackgroundFillColor();
} else {
return SystemColor.control;
}
}
private static Color getControlColor() {
if (Configuration.useRibbonInterface.get()) {
return SubstanceLookAndFeel.getCurrentSkin().getColorScheme(DecorationAreaType.GENERAL, ColorSchemeAssociationKind.FILL, ComponentState.ENABLED).getBackgroundFillColor();
} else {
return SystemColor.control;
}
}
public static Color getBackgroundColor() {
if (Configuration.useRibbonInterface.get()) {
return SubstanceLookAndFeel.getCurrentSkin().getColorScheme(DecorationAreaType.GENERAL, ColorSchemeAssociationKind.FILL, ComponentState.ENABLED).getBackgroundFillColor();
} else {
return SystemColor.control;
}
}
@Override
public void paint(Graphics g) {
super.paint(g);
repaintQueued = false;
Rectangle r = getVisibleRect();
int width = getWidth();
int cols = width / CELL_WIDTH;
int rows = (int) Math.ceil(items.size() / (float) cols);
int height = rows * CELL_HEIGHT;
int start_y = r.y / CELL_HEIGHT;
JLabel l = new JLabel();
Font f = l.getFont().deriveFont(AffineTransform.getScaleInstance(0.8, 0.8));
int finish_y = (int) Math.ceil((r.y + r.height) / (float) CELL_HEIGHT);
Color color;
Color selectedColor;
Color selectedTextColor;
Color borderColor;
Color textColor;
if (Configuration.useRibbonInterface.get()) {
SubstanceSkin skin = SubstanceLookAndFeel.getCurrentSkin();
color = skin.getColorScheme(DecorationAreaType.GENERAL, ColorSchemeAssociationKind.FILL, ComponentState.ENABLED).getBackgroundFillColor();
selectedColor = skin.getColorScheme(DecorationAreaType.GENERAL, ColorSchemeAssociationKind.FILL, ComponentState.ROLLOVER_SELECTED).getBackgroundFillColor();
borderColor = skin.getColorScheme(DecorationAreaType.GENERAL, ColorSchemeAssociationKind.BORDER, ComponentState.ROLLOVER_SELECTED).getUltraDarkColor();
textColor = skin.getColorScheme(DecorationAreaType.GENERAL, ColorSchemeAssociationKind.FILL, ComponentState.ENABLED).getForegroundColor();
selectedTextColor = skin.getColorScheme(DecorationAreaType.GENERAL, ColorSchemeAssociationKind.FILL, ComponentState.ROLLOVER_SELECTED).getForegroundColor();
} else {
color = SystemColor.control;
selectedColor = SystemColor.textHighlight;
borderColor = SystemColor.controlShadow;
textColor = SystemColor.controlText;
selectedTextColor = SystemColor.textHighlightText;
}
//g.setColor(SubstanceLookAndFeel.getCurrentSkin().getColorScheme(DecorationAreaType.GENERAL, ColorSchemeAssociationKind.FILL, ComponentState.ENABLED));
for (int y = start_y; y <= finish_y; y++) {
for (int x = 0; x < cols; x++) {
int index = y * cols + x;
if (index < items.size()) {
g.setColor(color);
if (selectedItems.containsKey(index)) {
g.setColor(selectedColor);
}
g.fillRect(x * CELL_WIDTH, y * CELL_HEIGHT, CELL_WIDTH, CELL_HEIGHT);
if (cachedPreviews.contains(index)) {
SerializableImage sImg = cachedPreviews.get(index);
if (sImg != null) {
BufferedImage img = cachedPreviews.get(index).getBufferedImage();
g.drawImage(img, x * CELL_WIDTH + BORDER_SIZE + PREVIEW_SIZE / 2 - img.getWidth() / 2, y * CELL_HEIGHT + BORDER_SIZE + PREVIEW_SIZE / 2 - img.getHeight() / 2, null);
}
} else {
cachedPreviews.put(index, noImage);
renderImageTask(index, items.get(index));
}
String s;
TreeItem treeItem = items.get(index);
if (treeItem instanceof Tag) {
s = ((Tag) treeItem).getTagName();
if (treeItem instanceof CharacterTag) {
s = s + " (" + ((CharacterTag) treeItem).getCharacterId() + ")";
}
} else {
s = treeItem.toString();
}
g.setFont(f);
g.setColor(borderColor);
g.drawLine(x * CELL_WIDTH, y * CELL_HEIGHT + BORDER_SIZE + PREVIEW_SIZE, x * CELL_WIDTH + CELL_WIDTH, y * CELL_HEIGHT + BORDER_SIZE + PREVIEW_SIZE);
g.drawRect(x * CELL_WIDTH, y * CELL_HEIGHT, CELL_WIDTH, CELL_HEIGHT);
g.setColor(textColor);
if (selectedItems.containsKey(index)) {
g.setColor(selectedTextColor);
}
g.drawString(s, x * CELL_WIDTH + BORDER_SIZE, y * CELL_HEIGHT + BORDER_SIZE + PREVIEW_SIZE + LABEL_HEIGHT);
}
}
}
if (lastWidth != width || lastHeight != height) {
lastWidth = width;
lastHeight = height;
setSize(new Dimension(width, height));
}
}