⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 metaliconfactory.java

📁 Mobile 应用程序使用 Java Micro Edition (Java ME) 平台
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        public void paintIcon(Component c, Graphics g, int x, int y) {            if (MetalLookAndFeel.usingOcean()) {                paintOceanIcon(c, g, x, y);                return;            }	    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);	    g.drawLine(4,6, 4,6);	    //     middle disk	    g.drawLine(2,7, 3,7);	    g.drawLine(2,8, 3,8);	    g.drawLine(4,9, 4,9);	    //     bottom disk	    g.drawLine(2,10, 3,10);	    g.drawLine(2,11, 3,11);	    g.drawLine(4,12, 4,12);	    g.translate(-x, -y);	}		public int getIconWidth() {	    return 16;	}		public int getIconHeight() {	    return 16;	}    }  // End class TreeHardDriveIcon    // Tree FloppyDrive Icon code    private static class TreeFloppyDriveIcon implements Icon, UIResource, Serializable {        public void paintIcon(Component c, Graphics g, int x, int y) {	    g.translate(x, y);	    // Fill body of floppy	    g.setColor(MetalLookAndFeel.getPrimaryControl());	    g.fillRect(2,2, 12,12);	    // Draw outside edge of floppy	    g.setColor(MetalLookAndFeel.getPrimaryControlInfo());	    g.drawLine( 1, 1, 13, 1); // top	    g.drawLine(14, 2, 14,14); // right	    g.drawLine( 1,14, 14,14); // bottom	    g.drawLine( 1, 1,  1,14); // left	    // Draw grey-ish highlights	    g.setColor(MetalLookAndFeel.getControlDarkShadow());	    g.fillRect(5,2, 6,5); // metal disk protector part	    g.drawLine(4,8, 11,8); // top of label	    g.drawLine(3,9, 3,13); // left of label	    g.drawLine(12,9, 12,13); // right of label	    // Draw label and exposed disk	    g.setColor(MetalLookAndFeel.getPrimaryControlHighlight());	    g.fillRect(8,3, 2,3); // exposed disk	    g.fillRect(4,9, 8,5); // label	    // Draw text on label	    g.setColor(MetalLookAndFeel.getPrimaryControlShadow());	    g.drawLine(5,10, 9,10);	    g.drawLine(5,12, 8,12);	    g.translate(-x, -y);	}		public int getIconWidth() {	    return 16;	}		public int getIconHeight() {	    return 16;	}    }  // End class TreeFloppyDriveIcon    static private final Dimension folderIcon16Size = new Dimension( 16, 16 );    /**     * Utility class for caching icon images.  This is necessary because     * we need a new image whenever we are rendering into a new      * GraphicsConfiguration, but we do not want to keep recreating icon      * images for GC's that we have already seen (for example,      * dragging a window back and forth between monitors on a multimon      * system, or drawing an icon to different Components that have different     * GC's).     * So now whenever we create a new icon image for a given GC, we     * cache that image with the GC for later retrieval.     */    static class ImageCacher {        // PENDING: Replace this class with CachedPainter.	Vector images = new Vector(1, 1);	ImageGcPair currentImageGcPair;	class ImageGcPair {	    Image image;	    GraphicsConfiguration gc;	    ImageGcPair(Image image, GraphicsConfiguration gc) {		this.image = image;		this.gc = gc;	    }	    boolean hasSameConfiguration(GraphicsConfiguration newGC) {		if (((newGC != null) && (newGC.equals(gc))) ||		    ((newGC == null) && (gc == null))) 		{		    return true;		}		return false;	    }	}	Image getImage(GraphicsConfiguration newGC) {	    if ((currentImageGcPair == null) ||		!(currentImageGcPair.hasSameConfiguration(newGC)))	    {		Enumeration elements = images.elements();		while (elements.hasMoreElements()) {		    ImageGcPair imgGcPair = (ImageGcPair)elements.nextElement();		    if (imgGcPair.hasSameConfiguration(newGC)) {			currentImageGcPair = imgGcPair;			return imgGcPair.image;		    }		}		return null;	    }	    return currentImageGcPair.image;	}	void cacheImage(Image image, GraphicsConfiguration gc) {	    ImageGcPair imgGcPair = new ImageGcPair(image, gc);	    images.addElement(imgGcPair);	    currentImageGcPair = imgGcPair;	}    }    /**     * <p>     * <strong>Warning:</strong>     * Serialized objects of this class will not be compatible with     * future Swing releases. The current serialization support is     * appropriate for short term storage or RMI between applications running     * the same version of Swing.  As of 1.4, support for long term storage     * of all JavaBeans<sup><font size="-2">TM</font></sup>     * has been added to the <code>java.beans</code> package.     * Please see {@link java.beans.XMLEncoder}.     */    public static class FolderIcon16 implements Icon, Serializable {	ImageCacher imageCacher;	public void paintIcon(Component c, Graphics g, int x, int y) {	    GraphicsConfiguration gc = c.getGraphicsConfiguration();	    if (imageCacher == null) {		imageCacher = new ImageCacher();	    }	    Image image = imageCacher.getImage(gc);	    if (image == null) {		if (gc != null) {		    image = gc.createCompatibleImage(getIconWidth(), 						     getIconHeight(),						     Transparency.BITMASK);		} else {		    image = new BufferedImage(getIconWidth(),					      getIconHeight(),					      BufferedImage.TYPE_INT_ARGB);		}                Graphics imageG = image.getGraphics();				paintMe(c,imageG);		imageG.dispose();		imageCacher.cacheImage(image, gc);	    }            g.drawImage(image, x, y+getShift(), null);	}	private void paintMe(Component c, Graphics g) {	    int right = folderIcon16Size.width - 1;	    int bottom = folderIcon16Size.height - 1;	    // Draw tab top	    g.setColor( MetalLookAndFeel.getPrimaryControlDarkShadow() );	    g.drawLine( right - 5, 3, right, 3 );	    g.drawLine( right - 6, 4, right, 4 );	    // Draw folder front	    g.setColor( MetalLookAndFeel.getPrimaryControl() );	    g.fillRect( 2, 7, 13, 8 );	    // Draw tab bottom	    g.setColor( MetalLookAndFeel.getPrimaryControlShadow() );	    g.drawLine( right - 6, 5, right - 1, 5 );	    // Draw outline	    g.setColor( MetalLookAndFeel.getPrimaryControlInfo() );	    g.drawLine( 0, 6, 0, bottom );            // left side	    g.drawLine( 1, 5, right - 7, 5 );         // first part of top	    g.drawLine( right - 6, 6, right - 1, 6 ); // second part of top	    g.drawLine( right, 5, right, bottom );    // right side	    g.drawLine( 0, bottom, right, bottom );   // bottom	    // Draw highlight	    g.setColor( MetalLookAndFeel.getPrimaryControlHighlight() );	    g.drawLine( 1, 6, 1, bottom - 1 );	    g.drawLine( 1, 6, right - 7, 6 );	    g.drawLine( right - 6, 7, right - 1, 7 );	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -