home *** CD-ROM | disk | FTP | other *** search
- package com.sun.java.swing.plaf.metal;
-
- import com.sun.java.swing.Icon;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Dimension;
- import java.awt.Graphics;
- import java.awt.Rectangle;
- import java.awt.image.ImageObserver;
- import java.io.Serializable;
- import java.util.Enumeration;
- import java.util.Vector;
-
- class MetalBumps implements Icon, Serializable {
- protected int xBumps;
- protected int yBumps;
- protected Color topColor;
- protected Color shadowColor;
- protected Color backColor;
- protected static Vector buffers = new Vector();
- protected BumpBuffer buffer;
-
- public MetalBumps(Dimension var1) {
- this(var1.width, var1.height);
- }
-
- public MetalBumps(int var1, int var2) {
- this.topColor = MetalLookAndFeel.getPrimaryControlHighlight();
- this.shadowColor = MetalLookAndFeel.getPrimaryControlDarkShadow();
- this.backColor = MetalLookAndFeel.getPrimaryControlShadow();
- this.setBumpArea(var1, var2);
- this.buffer = this.getBuffer(this.topColor, this.shadowColor, this.backColor);
- if (this.buffer == null) {
- this.createBuffer();
- }
-
- }
-
- public MetalBumps(int var1, int var2, Color var3, Color var4, Color var5) {
- this.topColor = MetalLookAndFeel.getPrimaryControlHighlight();
- this.shadowColor = MetalLookAndFeel.getPrimaryControlDarkShadow();
- this.backColor = MetalLookAndFeel.getPrimaryControlShadow();
- this.setBumpArea(var1, var2);
- this.setBumpColors(var3, var4, var5);
- this.buffer = this.getBuffer(this.topColor, this.shadowColor, this.backColor);
- if (this.buffer == null) {
- this.createBuffer();
- }
-
- }
-
- protected void createBuffer() {
- this.buffer = new BumpBuffer(this.topColor, this.shadowColor, this.backColor);
- buffers.addElement(this.buffer);
- }
-
- protected BumpBuffer getBuffer(Color var1, Color var2, Color var3) {
- BumpBuffer var4 = null;
- Enumeration var5 = buffers.elements();
-
- while(var5.hasMoreElements()) {
- BumpBuffer var6 = (BumpBuffer)var5.nextElement();
- if (var6.hasSameColors(var1, var2, var3)) {
- var4 = var6;
- break;
- }
- }
-
- return var4;
- }
-
- public void setBumpArea(Dimension var1) {
- this.setBumpArea(var1.width, var1.height);
- }
-
- public void setBumpArea(int var1, int var2) {
- this.xBumps = var1 / 2;
- this.yBumps = var2 / 2;
- }
-
- public void setBumpColors(Color var1, Color var2, Color var3) {
- this.topColor = var1;
- this.shadowColor = var2;
- this.backColor = var3;
- this.buffer = this.getBuffer(this.topColor, this.shadowColor, this.backColor);
- if (this.buffer == null) {
- this.createBuffer();
- }
-
- }
-
- public void paintIcon(Component var1, Graphics var2, int var3, int var4) {
- Rectangle var5 = var2.getClipBounds();
- var2.setClip(var3, var4, this.getIconWidth(), this.getIconHeight());
- int var6 = this.buffer.getImageSize().width;
- int var7 = this.buffer.getImageSize().height;
- int var8 = this.getIconWidth() / var6 + 1;
- int var9 = this.getIconHeight() / var7 + 1;
-
- for(int var10 = 0; var10 < var9; ++var10) {
- for(int var11 = 0; var11 < var8; ++var11) {
- var2.drawImage(this.buffer.getImage(), var3 + var11 * var6, var4 + var10 * var7, (ImageObserver)null);
- }
- }
-
- var2.setClip(var5.x, var5.y, var5.width, var5.height);
- }
-
- public int getIconWidth() {
- return this.xBumps * 2;
- }
-
- public int getIconHeight() {
- return this.yBumps * 2;
- }
- }
-