Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
GTEFP/Swatch.java
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
25 lines (25 sloc)
660 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Swatch { | |
private java.awt.Polygon _swatch; | |
private int [] _x; | |
private int [] _y; | |
private java.awt.Color _c; | |
Swatch(int x,int y){ | |
_x = new int [] {0+x,10+x,10+x,0+x}; | |
_y = new int [] {0+y,0+y,45+y,45+y}; | |
_swatch = new java.awt.Polygon(_x,_y,4); | |
} | |
public void setColor(java.awt.Color c){ | |
_c = c; | |
} | |
public java.awt.Color getColor(){ | |
java.awt.Color _C = _c; | |
return(_C); | |
} | |
public void paint(java.awt.Graphics aBrush){ | |
java.awt.Color oldColor = aBrush.getColor(); | |
java.awt.Graphics2D betterBrush = (java.awt.Graphics2D) aBrush; | |
betterBrush.setColor(_c); | |
betterBrush.fillPolygon(_swatch); | |
aBrush.setColor(oldColor); | |
} | |
} |