📄 metaliconfactory.java
字号:
// File Chooser New Folder code private static class FileChooserNewFolderIcon implements Icon, UIResource, Serializable { public void paintIcon(Component c, Graphics g, int x, int y) { g.translate(x, y); // Fill background g.setColor(MetalLookAndFeel.getPrimaryControl()); g.fillRect(3,5, 12,9); // Draw outside edge of folder g.setColor(MetalLookAndFeel.getPrimaryControlInfo()); g.drawLine(1,6, 1,14); // left g.drawLine(2,14, 15,14); // bottom g.drawLine(15,13, 15,5); // right g.drawLine(2,5, 9,5); // top left g.drawLine(10,6, 14,6); // top right // Draw inner folder highlight g.setColor(MetalLookAndFeel.getPrimaryControlHighlight()); g.drawLine( 2,6, 2,13); // left g.drawLine( 3,6, 9,6); // top left g.drawLine(10,7, 14,7); // top right // Draw tab on folder g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow()); g.drawLine(11,3, 15,3); // top g.drawLine(10,4, 15,4); // bottom g.translate(-x, -y); } public int getIconWidth() { return 18; } public int getIconHeight() { return 18; } } // End class FileChooserNewFolderIcon // File Chooser Up Folder code private static class FileChooserUpFolderIcon implements Icon, UIResource, Serializable { public void paintIcon(Component c, Graphics g, int x, int y) { g.translate(x, y); // Fill background g.setColor(MetalLookAndFeel.getPrimaryControl()); g.fillRect(3,5, 12,9); // Draw outside edge of folder g.setColor(MetalLookAndFeel.getPrimaryControlInfo()); g.drawLine(1,6, 1,14); // left g.drawLine(2,14, 15,14); // bottom g.drawLine(15,13, 15,5); // right g.drawLine(2,5, 9,5); // top left g.drawLine(10,6, 14,6); // top right // Draw the UP arrow // same color as edge g.drawLine(8,13, 8,16); // arrow shaft g.drawLine(8, 9, 8, 9); // arrowhead top g.drawLine(7,10, 9,10); g.drawLine(6,11, 10,11); g.drawLine(5,12, 11,12); // Draw inner folder highlight g.setColor(MetalLookAndFeel.getPrimaryControlHighlight()); g.drawLine( 2,6, 2,13); // left g.drawLine( 3,6, 9,6); // top left g.drawLine(10,7, 14,7); // top right // Draw tab on folder g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow()); g.drawLine(11,3, 15,3); // top g.drawLine(10,4, 15,4); // bottom g.translate(-x, -y); } public int getIconWidth() { return 18; } public int getIconHeight() { return 18; } } // End class FileChooserUpFolderIcon /** * Defines an icon for Palette close * @since 1.3 */ public static class PaletteCloseIcon implements Icon, UIResource, Serializable{ int iconSize = 7; public void paintIcon(Component c, Graphics g, int x, int y) { JButton parentButton = (JButton)c; ButtonModel buttonModel = parentButton.getModel(); Color back; Color highlight = MetalLookAndFeel.getPrimaryControlHighlight(); Color shadow = MetalLookAndFeel.getPrimaryControlInfo(); if (buttonModel.isPressed() && buttonModel.isArmed()) { back = shadow; } else { back = MetalLookAndFeel.getPrimaryControlDarkShadow(); } g.translate(x, y); g.setColor(back); g.drawLine( 0, 1, 5, 6); g.drawLine( 1, 0, 6, 5); g.drawLine( 1, 1, 6, 6); g.drawLine( 6, 1, 1, 6); g.drawLine( 5,0, 0,5); g.drawLine(5,1, 1,5); g.setColor(highlight); g.drawLine(6,2, 5,3); g.drawLine(2,6, 3, 5); g.drawLine(6,6,6,6); g.translate(-x, -y); } public int getIconWidth() { return iconSize; } public int getIconHeight() { return iconSize; } } // Internal Frame Close code private static class InternalFrameCloseIcon implements Icon, UIResource, Serializable { int iconSize = 16; public InternalFrameCloseIcon(int size) { iconSize = size; } public void paintIcon(Component c, Graphics g, int x, int y) { JButton parentButton = (JButton)c; ButtonModel buttonModel = parentButton.getModel(); Color backgroundColor = MetalLookAndFeel.getPrimaryControl(); Color internalBackgroundColor = MetalLookAndFeel.getPrimaryControl(); Color mainItemColor = MetalLookAndFeel.getPrimaryControlDarkShadow(); Color darkHighlightColor = MetalLookAndFeel.getBlack(); Color xLightHighlightColor = MetalLookAndFeel.getWhite(); Color boxLightHighlightColor = MetalLookAndFeel.getWhite(); // if the inactive window if (parentButton.getClientProperty("paintActive") != Boolean.TRUE) { backgroundColor = MetalLookAndFeel.getControl(); internalBackgroundColor = backgroundColor; mainItemColor = MetalLookAndFeel.getControlDarkShadow(); // if inactive and pressed if (buttonModel.isPressed() && buttonModel.isArmed()) { internalBackgroundColor = MetalLookAndFeel.getControlShadow(); xLightHighlightColor = internalBackgroundColor; mainItemColor = darkHighlightColor; } } // if pressed else if (buttonModel.isPressed() && buttonModel.isArmed()) { internalBackgroundColor = MetalLookAndFeel.getPrimaryControlShadow(); xLightHighlightColor = internalBackgroundColor; mainItemColor = darkHighlightColor; // darkHighlightColor is still "getBlack()" } // Some calculations that are needed more than once later on. int oneHalf = (int)(iconSize / 2); // 16 -> 8 g.translate(x, y); // fill background g.setColor(backgroundColor); g.fillRect(0,0, iconSize,iconSize); // fill inside of box area g.setColor(internalBackgroundColor); g.fillRect(3,3, iconSize-6,iconSize-6); // THE BOX // the top/left dark higlight - some of this will get overwritten g.setColor(darkHighlightColor); g.drawRect(1,1, iconSize-3,iconSize-3); // draw the inside bottom/right highlight g.drawRect(2,2, iconSize-5,iconSize-5); // draw the light/outside, bottom/right highlight g.setColor(boxLightHighlightColor); g.drawRect(2,2, iconSize-3,iconSize-3); // draw the "normal" box g.setColor(mainItemColor); g.drawRect(2,2, iconSize-4,iconSize-4); g.drawLine(3,iconSize-3, 3,iconSize-3); // lower left g.drawLine(iconSize-3,3, iconSize-3,3); // up right // THE "X" // Dark highlight g.setColor(darkHighlightColor); g.drawLine(4,5, 5,4); // far up left g.drawLine(4,iconSize-6, iconSize-6,4); // against body of "X" // Light highlight g.setColor(xLightHighlightColor); g.drawLine(6,iconSize-5, iconSize-5,6); // against body of "X" // one pixel over from the body g.drawLine(oneHalf,oneHalf+2, oneHalf+2,oneHalf); // bottom right g.drawLine(iconSize-5,iconSize-5, iconSize-4,iconSize-5); g.drawLine(iconSize-5,iconSize-4, iconSize-5,iconSize-4); // Main color g.setColor(mainItemColor); // Upper left to lower right g.drawLine(5,5, iconSize-6,iconSize-6); // g.drawLine(5,5, 10,10); g.drawLine(6,5, iconSize-5,iconSize-6); // g.drawLine(6,5, 11,10); g.drawLine(5,6, iconSize-6,iconSize-5); // g.drawLine(5,6, 10,11); // Lower left to upper right g.drawLine(5,iconSize-5, iconSize-5,5); // g.drawLine(5,11, 11,5); g.drawLine(5,iconSize-6, iconSize-6,5); // g.drawLine(5,10, 10,5); g.translate(-x, -y); } public int getIconWidth() { return iconSize; } public int getIconHeight() { return iconSize; } } // End class InternalFrameCloseIcon // Internal Frame Alternate Maximize code (actually, the un-maximize icon) private static class InternalFrameAltMaximizeIcon implements Icon, UIResource, Serializable { int iconSize = 16; public InternalFrameAltMaximizeIcon(int size) { iconSize = size; } public void paintIcon(Component c, Graphics g, int x, int y) { JButton parentButton = (JButton)c; ButtonModel buttonModel = parentButton.getModel(); Color backgroundColor = MetalLookAndFeel.getPrimaryControl(); Color internalBackgroundColor = MetalLookAndFeel.getPrimaryControl(); Color mainItemColor = MetalLookAndFeel.getPrimaryControlDarkShadow(); Color darkHighlightColor = MetalLookAndFeel.getBlack(); // ul = Upper Left and lr = Lower Right Color ulLightHighlightColor = MetalLookAndFeel.getWhite(); Color lrLightHighlightColor = MetalLookAndFeel.getWhite(); // if the internal frame is inactive if (parentButton.getClientProperty("paintActive") != Boolean.TRUE) { backgroundColor = MetalLookAndFeel.getControl(); internalBackgroundColor = backgroundColor; mainItemColor = MetalLookAndFeel.getControlDarkShadow(); // if inactive and pressed if (buttonModel.isPressed() && buttonModel.isArmed()) { internalBackgroundColor = MetalLookAndFeel.getControlShadow(); ulLightHighlightColor = internalBackgroundColor; mainItemColor = darkHighlightColor; } } // if the button is pressed and the mouse is over it else if (buttonModel.isPressed() && buttonModel.isArmed()) { internalBackgroundColor = MetalLookAndFeel.getPrimaryControlShadow(); ulLightHighlightColor = internalBackgroundColor; mainItemColor = darkHighlightColor; // darkHighlightColor is still "getBlack()" } g.translate(x, y); // fill background g.setColor(backgroundColor); g.fillRect(0,0, iconSize,iconSize); // BOX // fill inside the box g.setColor(internalBackgroundColor); g.fillRect(3,6, iconSize-9,iconSize-9); // draw dark highlight color g.setColor(darkHighlightColor); g.drawRect(1,5, iconSize-8,iconSize-8); g.drawLine(1,iconSize-2, 1,iconSize-2); // extra pixel on bottom // draw lower right light highlight g.setColor(lrLightHighlightColor); g.drawRect(2,6, iconSize-7,iconSize-7); // draw upper left light highlight g.setColor(ulLightHighlightColor); g.drawRect(3,7, iconSize-9,iconSize-9); // draw the main box g.setColor(mainItemColor); g.drawRect(2,6, iconSize-8,iconSize-8); // Six extraneous pixels to deal with g.setColor(ulLightHighlightColor); g.drawLine(iconSize-6,8,iconSize-6,8); g.drawLine(iconSize-9,6, iconSize-7,8); g.setColor(mainItemColor); g.drawLine(3,iconSize-3,3,iconSize-3); g.setColor(darkHighlightColor); g.drawLine(iconSize-6,9,iconSize-6,9); g.setColor(backgroundColor); g.drawLine(iconSize-9,5,iconSize-9,5); // ARROW // do the shaft first g.setColor(mainItemColor); g.fillRect(iconSize-7,3, 3,5); // do a big block g.drawLine(iconSize-6,5, iconSize-3,2); // top shaft g.drawLine(iconSize-6,6, iconSize-2,2); // bottom shaft g.drawLine(iconSize-6,7, iconSize-3,7); // bottom arrow head // draw the dark highlight g.setColor(darkHighlightColor); g.drawLine(iconSize-8,2, iconSize-7,2); // top of arrowhead g.drawLine(iconSize-8,3, iconSize-8,7); // left of arrowhead g.drawLine(iconSize-6,4, iconSize-3,1); // top of shaft g.drawLine(iconSize-4,6, iconSize-3,6); // top,right of arrowhead // draw the light highlight g.setColor(lrLightHighlightColor); g.drawLine(iconSize-6,3, iconSize-6,3); // top g.drawLine(iconSize-4,5, iconSize-2,3); // under shaft g.drawLine(iconSize-4,8, iconSize-3,8); // under arrowhead g.drawLine(iconSize-2,8, iconSize-2,7); // right of arrowhead g.translate(-x, -y); } public int getIconWidth() { return iconSize; } public int getIconHeight() { return iconSize; } } // End class InternalFrameAltMaximizeIcon // Code for the default icons that goes in the upper left corner private static class InternalFrameDefaultMenuIcon implements Icon, UIResource, Serializable { public void paintIcon(Component c, Graphics g, int x, int y) { Color windowBodyColor = MetalLookAndFeel.getWindowBackground(); Color titleColor = MetalLookAndFeel.getPrimaryControl(); Color edgeColor = MetalLookAndFeel.getPrimaryControlDarkShadow(); g.translate(x, y); // draw background color for title area // catch four corners and title area g.setColor(titleColor); g.fillRect(0,0, 16,16); // fill body of window g.setColor(windowBodyColor); g.fillRect(2,6, 13,9); // draw light parts of two "bumps" g.drawLine(2,2, 2,2); g.drawLine(5,2, 5,2); g.drawLine(8,2, 8,2); g.drawLine(11,2, 11,2); // draw line around edge of title and icon g.setColor(edgeColor); g.drawRect(1,1, 13,13); // entire inner edge g.drawLine(1,0, 14,0); // top outter edge g.drawLine(15,1, 15,14); // right outter edge g.drawLine(1,15, 14,15); // bottom outter edge g.drawLine(0,1, 0,14); // left outter edge g.drawLine(2,5, 13,5); // bottom of title bar area // draw dark part of four "bumps" (same color) g.drawLine(3,3, 3,3); g.drawLine(6,3, 6,3); g.drawLine(9,3, 9,3); g.drawLine(12,3, 12,3); g.translate(-x, -y); } public int getIconWidth() {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -