Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package color;
- public class rgb implements Comparable<Object>{
- final static int BYTE_MASK=255;
- private long red,blue,green;
- private long color;
- public void rgb2color() {
- color=(red<<16)|(green<<8)|(blue);
- }
- public void color2rgb() {
- red=color>>16;
- green=(color>>8)&BYTE_MASK;
- blue = color&BYTE_MASK;
- }
- public rgb() {}
- public rgb(int redcolor, int bluecolor, int greencolor) {
- this.red = redcolor;
- this.blue = bluecolor;
- this.green = greencolor;
- }
- public long getred(){
- return red;
- }
- public long getblue(){
- return blue;
- }
- public long getgreen(){
- return green;
- }
- public void setred(long r) {
- red=r;
- }
- public void setblue(long r) {
- blue=r;
- }
- public void setgreen(long r) {
- green=r;
- }
- public String toString() {
- return "Red:"+red+",Green:"+green+",Blue:"+blue+",Compound:"+color;
- }
- public boolean equals(Object r) {
- return this.color==((rgb)r).color;}
- public int compareTo(Object c) {
- if(this.color<((rgb)c).color) return-1;
- if(this.color>((rgb)c).color) return 1;
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement