📄 metaliconfactory.java
字号:
ulLightHighlightColor = internalBackgroundColor; mainItemColor = darkHighlightColor; // darkHighlightColor is still "getBlack()" } g.translate(x, y); // fill background g.setColor(backgroundColor); g.fillRect(0,0, iconSize,iconSize); // BOX drawing // fill inside the box g.setColor(internalBackgroundColor); g.fillRect(3,7, iconSize-10,iconSize-10); // light highlight g.setColor(ulLightHighlightColor); g.drawRect(3,7, iconSize-10,iconSize-10); // up,left g.setColor(lrLightHighlightColor); g.drawRect(2,6, iconSize-7,iconSize-7); // low,right // dark highlight g.setColor(darkHighlightColor); g.drawRect(1,5, iconSize-7,iconSize-7); // outer g.drawRect(2,6, iconSize-9,iconSize-9); // inner // main box g.setColor(mainItemColor); g.drawRect(2,6, iconSize-8,iconSize-8); // g.drawRect(2,6, 8,8); // ARROW drawing // dark highlight g.setColor(darkHighlightColor); // down,left to up,right - inside box g.drawLine(3,iconSize-5, iconSize-9,7); // down,left to up,right - outside box g.drawLine(iconSize-6,4, iconSize-5,3); // outside edge of arrow head g.drawLine(iconSize-7,1, iconSize-7,2); // outside edge of arrow head g.drawLine(iconSize-6,1, iconSize-2,1); // light highlight g.setColor(ulLightHighlightColor); // down,left to up,right - inside box g.drawLine(5,iconSize-4, iconSize-8,9); g.setColor(lrLightHighlightColor); g.drawLine(iconSize-6,3, iconSize-4,5); // outside box g.drawLine(iconSize-4,5, iconSize-4,6); // one down from this g.drawLine(iconSize-2,7, iconSize-1,7); // outside edge arrow head g.drawLine(iconSize-1,2, iconSize-1,6); // outside edge arrow head // main part of arrow g.setColor(mainItemColor); g.drawLine(3,iconSize-4, iconSize-3,2); // top edge of staff g.drawLine(3,iconSize-3, iconSize-2,2); // bottom edge of staff g.drawLine(4,iconSize-3, 5,iconSize-3); // highlights inside of box g.drawLine(iconSize-7,8, iconSize-7,9); // highlights inside of box g.drawLine(iconSize-6,2, iconSize-4,2); // top of arrow head g.drawRect(iconSize-3,3, 1,3); // right of arrow head g.translate(-x, -y); } public int getIconWidth() { return iconSize; } public int getIconHeight() { return iconSize; } } // End class InternalFrameMaximizeIcon // Internal Frame Minimize code private static class InternalFrameMinimizeIcon implements Icon, UIResource, Serializable { int iconSize = 16; public InternalFrameMinimizeIcon(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 drawing // fill inside the box g.setColor(internalBackgroundColor); g.fillRect(4,11, iconSize-13,iconSize-13); // light highlight g.setColor(lrLightHighlightColor); g.drawRect(2,10, iconSize-10,iconSize-11); // low,right g.setColor(ulLightHighlightColor); g.drawRect(3,10, iconSize-12,iconSize-12); // up,left // dark highlight g.setColor(darkHighlightColor); g.drawRect(1,8, iconSize-10,iconSize-10); // outer g.drawRect(2,9, iconSize-12,iconSize-12); // inner // main box g.setColor(mainItemColor); g.drawRect(2,9, iconSize-11,iconSize-11); g.drawLine(iconSize-10,10, iconSize-10,10); // up right highlight g.drawLine(3,iconSize-3, 3,iconSize-3); // low left highlight // 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-7,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 InternalFrameMinimizeIcon private static class CheckBoxIcon implements Icon, UIResource, Serializable { protected int getControlSize() { return 13; } public void paintIcon(Component c, Graphics g, int x, int y) { JCheckBox cb = (JCheckBox)c; ButtonModel model = cb.getModel(); int controlSize = getControlSize(); boolean drawCheck = model.isSelected(); if ( model.isEnabled() ) { if (model.isPressed() && model.isArmed()) { g.setColor( MetalLookAndFeel.getControlShadow() ); g.fillRect( x, y, controlSize-1, controlSize-1); MetalUtils.drawPressed3DBorder(g, x, y, controlSize, controlSize); } else { MetalUtils.drawFlush3DBorder(g, x, y, controlSize, controlSize); } g.setColor( MetalLookAndFeel.getControlInfo() ); } else { g.setColor( MetalLookAndFeel.getControlShadow() ); g.drawRect( x, y, controlSize-2, controlSize-2); } if (model.isSelected()) { drawCheck(c,g,x,y); } } protected void drawCheck(Component c, Graphics g, int x, int y) { int controlSize = getControlSize(); g.fillRect( x+3, y+5, 2, controlSize-8 ); g.drawLine( x+(controlSize-4), y+3, x+5, y+(controlSize-6) ); g.drawLine( x+(controlSize-4), y+4, x+5, y+(controlSize-5) ); } public int getIconWidth() { return getControlSize(); } public int getIconHeight() { return getControlSize(); } } // End class CheckBoxIcon // Radio button code private static class RadioButtonIcon implements Icon, UIResource, Serializable { public void paintIcon(Component c, Graphics g, int x, int y) { JRadioButton rb = (JRadioButton)c; ButtonModel model = rb.getModel(); boolean drawDot = model.isSelected(); Color background = c.getBackground(); Color dotColor = c.getForeground(); Color shadow = MetalLookAndFeel.getControlShadow(); Color darkCircle = MetalLookAndFeel.getControlDarkShadow(); Color whiteInnerLeftArc = MetalLookAndFeel.getControlHighlight(); Color whiteOuterRightArc = MetalLookAndFeel.getControlHighlight(); Color interiorColor = background; // Set up colors per RadioButtonModel condition if ( !model.isEnabled() ) { whiteInnerLeftArc = whiteOuterRightArc = background; darkCircle = dotColor = shadow; } else if (model.isPressed() && model.isArmed() ) { whiteInnerLeftArc = interiorColor = shadow; } g.translate(x, y); // fill interior g.setColor(interiorColor); g.fillRect(2,2, 9,9); // draw Dark Circle (start at top, go clockwise) g.setColor(darkCircle); g.drawLine( 4, 0, 7, 0); g.drawLine( 8, 1, 9, 1); g.drawLine(10, 2, 10, 3); g.drawLine(11, 4, 11, 7); g.drawLine(10, 8, 10, 9); g.drawLine( 9,10, 8,10); g.drawLine( 7,11, 4,11); g.drawLine( 3,10, 2,10); g.drawLine( 1, 9, 1, 8); g.drawLine( 0, 7, 0, 4); g.drawLine( 1, 3, 1, 2); g.drawLine( 2, 1, 3, 1); // draw Inner Left (usually) White Arc // start at lower left corner, go clockwise g.setColor(whiteInnerLeftArc); g.drawLine( 2, 9, 2, 8); g.drawLine( 1, 7, 1, 4); g.drawLine( 2, 2, 2, 3); g.drawLine( 2, 2, 3, 2); g.drawLine( 4, 1, 7, 1); g.drawLine( 8, 2, 9, 2); // draw Outer Right White Arc // start at upper right corner, go clockwise g.setColor(whiteOuterRightArc); g.drawLine(10, 1, 10, 1); g.drawLine(11, 2, 11, 3); g.drawLine(12, 4, 12, 7); g.drawLine(11, 8, 11, 9); g.drawLine(10,10, 10,10); g.drawLine( 9,11, 8,11); g.drawLine( 7,12, 4,12); g.drawLine( 3,11, 2,11); // selected dot if ( drawDot ) { g.setColor(dotColor); g.fillRect( 4, 4, 4, 4); g.drawLine( 4, 3, 7, 3); g.drawLine( 8, 4, 8, 7); g.drawLine( 7, 8, 4, 8); g.drawLine( 3, 7, 3, 4); } g.translate(-x, -y); } public int getIconWidth() { return 13; } public int getIconHeight() { return 13; } } // End class RadioButtonIcon // Tree Computer Icon code private static class TreeComputerIcon implements Icon, UIResource, Serializable { public void paintIcon(Component c, Graphics g, int x, int y) { g.translate(x, y); // Fill glass portion of monitor g.setColor(MetalLookAndFeel.getPrimaryControl()); g.fillRect(5,4, 6,4); // Draw outside edge of monitor g.setColor(MetalLookAndFeel.getPrimaryControlInfo()); g.drawLine( 2,2, 2,8); // left g.drawLine(13,2, 13,8); // right g.drawLine( 3,1, 12,1); // top g.drawLine(12,9, 12,9); // bottom right base g.drawLine( 3,9, 3,9); // bottom left base // Draw the edge of the glass g.drawLine( 4,4, 4,7); // left g.drawLine( 5,3, 10,3); // top g.drawLine(11,4, 11,7); // right g.drawLine( 5,8, 10,8); // bottom // Draw the edge of the CPU g.drawLine( 1,10, 14,10); // top g.drawLine(14,10, 14,14); // right g.drawLine( 1,14, 14,14); // bottom g.drawLine( 1,10, 1,14); // left // Draw the disk drives g.setColor(MetalLookAndFeel.getControlDarkShadow()); g.drawLine( 6,12, 8,12); // left g.drawLine(10,12, 12,12); // right g.translate(-x, -y); } public int getIconWidth() { return 16; } public int getIconHeight() { return 16; } } // End class TreeComputerIcon // Tree HardDrive Icon code private static class TreeHardDriveIcon implements Icon, UIResource, Serializable { public void paintIcon(Component c, Graphics g, int x, int y) { g.translate(x, y); // Draw edges of the disks g.setColor(MetalLookAndFeel.getPrimaryControlInfo()); // top disk g.drawLine(1,4, 1,5); // left g.drawLine(2,3, 3,3); g.drawLine(4,2, 11,2); // top g.drawLine(12,3, 13,3); g.drawLine(14,4, 14,5); // right g.drawLine(12,6, 13,6); g.drawLine(4,7, 11,7); // bottom g.drawLine(2,6, 3,6); // middle disk g.drawLine(1,7, 1,8); // left g.drawLine(2,9, 3,9); g.drawLine(4,10, 11,10); // bottom g.drawLine(12,9, 13,9); g.drawLine(14,7, 14, 8); // right // bottom disk g.drawLine(1,10, 1,11); // left g.drawLine(2,12, 3,12); g.drawLine(4,13, 11,13); // bottom g.drawLine(12,12, 13,12); g.drawLine(14,10, 14,11); // right // Draw the down right shadows g.setColor(MetalLookAndFeel.getControlShadow()); // top disk g.drawLine(7,6, 7,6); g.drawLine(9,6, 9,6); g.drawLine(10,5, 10,5); g.drawLine(11,6, 11,6); g.drawLine(12,5, 13,5); g.drawLine(13,4, 13,4); // middle disk g.drawLine(7,9, 7,9); g.drawLine(9,9, 9,9); g.drawLine(10,8, 10,8); g.drawLine(11,9, 11,9); g.drawLine(12,8, 13,8); g.drawLine(13,7, 13,7); // bottom disk g.drawLine(7,12, 7,12); g.drawLine(9,12, 9,12); g.drawLine(10,11, 10,11); g.drawLine(11,12, 11,12); g.drawLine(12,11, 13,11); g.drawLine(13,10, 13,10); // Draw the up left highlight g.setColor(MetalLookAndFeel.getControlHighlight()); // top disk g.drawLine(4,3, 5,3); g.drawLine(7,3, 9,3); g.drawLine(11,3, 11,3); g.drawLine(2,4, 6,4); g.drawLine(8,4, 8,4); g.drawLine(2,5, 3,5);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -