599 } 600 } 601 602 /** Paint a skin at a defined position and size. This method 603 * does not trigger animation. It is needed for the animation 604 * support. 605 * 606 * @param g the graphics context to use for painting 607 * @param dx the destination <i>x</i> coordinate. 608 * @param dy the destination <i>y</i> coordinate. 609 * @param dw the width of the area to fill, may cause 610 * the image to be stretched or tiled 611 * @param dh the height of the area to fill, may cause 612 * the image to be stretched or tiled 613 * @param state which state to paint 614 */ 615 void paintSkinRaw(Graphics g, int dx, int dy, int dw, int dh, State state) { 616 if (XPStyle.getXP() == null) { 617 return; 618 } 619 skinPainter.paint(null, g, dx, dy, dw, dh, this, state); 620 } 621 622 /** Paint a skin at a defined position and size 623 * 624 * @param g the graphics context to use for painting 625 * @param dx the destination <i>x</i> coordinate 626 * @param dy the destination <i>y</i> coordinate 627 * @param dw the width of the area to fill, may cause 628 * the image to be stretched or tiled 629 * @param dh the height of the area to fill, may cause 630 * the image to be stretched or tiled 631 * @param state which state to paint 632 * @param borderFill should test if the component uses a border fill 633 and skip painting if it is 634 */ 635 void paintSkin(Graphics g, int dx, int dy, int dw, int dh, State state, 636 boolean borderFill) { 637 if (XPStyle.getXP() == null) { 638 return; 639 } 640 if(borderFill && "borderfill".equals(getTypeEnumName(component, part, 656 } 657 658 protected void paintToImage(Component c, Image image, Graphics g, 659 int w, int h, Object[] args) { 660 boolean accEnabled = false; 661 Skin skin = (Skin)args[0]; 662 Part part = skin.part; 663 State state = (State)args[1]; 664 if (state == null) { 665 state = skin.state; 666 } 667 if (c == null) { 668 c = skin.component; 669 } 670 BufferedImage bi = (BufferedImage)image; 671 672 WritableRaster raster = bi.getRaster(); 673 DataBufferInt dbi = (DataBufferInt)raster.getDataBuffer(); 674 // Note that stealData() requires a markDirty() afterwards 675 // since we modify the data in it. 676 ThemeReader.paintBackground(SunWritableRaster.stealData(dbi, 0), 677 part.getControlName(c), part.getValue(), 678 State.getValue(part, state), 679 0, 0, w, h, w); 680 SunWritableRaster.markDirty(dbi); 681 } 682 683 protected Image createImage(Component c, int w, int h, 684 GraphicsConfiguration config, Object[] args) { 685 return new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); 686 } 687 } 688 689 @SuppressWarnings("serial") // Superclass is not serializable across versions 690 static class GlyphButton extends JButton { 691 private Skin skin; 692 693 public GlyphButton(Component parent, Part part) { 694 XPStyle xp = getXP(); 695 skin = xp != null ? xp.getSkin(parent, part) : null; 696 setBorder(null); 697 setContentAreaFilled(false); 698 setMinimumSize(new Dimension(5, 5)); 699 setPreferredSize(new Dimension(16, 16)); | 599 } 600 } 601 602 /** Paint a skin at a defined position and size. This method 603 * does not trigger animation. It is needed for the animation 604 * support. 605 * 606 * @param g the graphics context to use for painting 607 * @param dx the destination <i>x</i> coordinate. 608 * @param dy the destination <i>y</i> coordinate. 609 * @param dw the width of the area to fill, may cause 610 * the image to be stretched or tiled 611 * @param dh the height of the area to fill, may cause 612 * the image to be stretched or tiled 613 * @param state which state to paint 614 */ 615 void paintSkinRaw(Graphics g, int dx, int dy, int dw, int dh, State state) { 616 if (XPStyle.getXP() == null) { 617 return; 618 } 619 if (component != null) { 620 skinPainter.paint(null, g, dx, dy, dw, dh, this, state, 621 component.isOpaque()); 622 } else { 623 skinPainter.paint(null, g, dx, dy, dw, dh, this, state); 624 } 625 } 626 627 /** Paint a skin at a defined position and size 628 * 629 * @param g the graphics context to use for painting 630 * @param dx the destination <i>x</i> coordinate 631 * @param dy the destination <i>y</i> coordinate 632 * @param dw the width of the area to fill, may cause 633 * the image to be stretched or tiled 634 * @param dh the height of the area to fill, may cause 635 * the image to be stretched or tiled 636 * @param state which state to paint 637 * @param borderFill should test if the component uses a border fill 638 and skip painting if it is 639 */ 640 void paintSkin(Graphics g, int dx, int dy, int dw, int dh, State state, 641 boolean borderFill) { 642 if (XPStyle.getXP() == null) { 643 return; 644 } 645 if(borderFill && "borderfill".equals(getTypeEnumName(component, part, 661 } 662 663 protected void paintToImage(Component c, Image image, Graphics g, 664 int w, int h, Object[] args) { 665 boolean accEnabled = false; 666 Skin skin = (Skin)args[0]; 667 Part part = skin.part; 668 State state = (State)args[1]; 669 if (state == null) { 670 state = skin.state; 671 } 672 if (c == null) { 673 c = skin.component; 674 } 675 BufferedImage bi = (BufferedImage)image; 676 677 WritableRaster raster = bi.getRaster(); 678 DataBufferInt dbi = (DataBufferInt)raster.getDataBuffer(); 679 // Note that stealData() requires a markDirty() afterwards 680 // since we modify the data in it. 681 if (c == null || c.isOpaque() || state == State.PRESSED) { 682 ThemeReader.paintBackground(SunWritableRaster.stealData(dbi, 0), 683 part.getControlName(c), part.getValue(), 684 State.getValue(part, state), 685 0, 0, w, h, w); 686 } 687 SunWritableRaster.markDirty(dbi); 688 } 689 690 protected Image createImage(Component c, int w, int h, 691 GraphicsConfiguration config, Object[] args) { 692 return new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); 693 } 694 } 695 696 @SuppressWarnings("serial") // Superclass is not serializable across versions 697 static class GlyphButton extends JButton { 698 private Skin skin; 699 700 public GlyphButton(Component parent, Part part) { 701 XPStyle xp = getXP(); 702 skin = xp != null ? xp.getSkin(parent, part) : null; 703 setBorder(null); 704 setContentAreaFilled(false); 705 setMinimumSize(new Dimension(5, 5)); 706 setPreferredSize(new Dimension(16, 16)); |