package japlot;

import java.awt.*;
import javax.swing.Icon;


public class KeyIcon implements Icon {
  private Color color;

  private boolean selected;

  private int width;

  private int height;

  private int type=2;

  private int size=10;

  private Polygon poly;

  private static final int DEFAULT_WIDTH = 10;

  private static final int DEFAULT_HEIGHT = 10;

  public KeyIcon(Color color) {
    this(color, true, DEFAULT_WIDTH, DEFAULT_HEIGHT);
  }

  public KeyIcon(Color color, boolean selected) {
    this(color, selected, DEFAULT_WIDTH, DEFAULT_HEIGHT);
  }

  public KeyIcon(Color color, boolean selected, int width, int height) {
    this.color = color;
    this.selected = selected;
    this.width = width;
    this.height = height;
    initPolygon();
  }


  public void setType(int type){

 this.type=type;
  }

  public void setSize(int size){

 this.size=size;
  }


   public void setColor(Color color){

 this.color=color;
  }



  public int getType(){
  return type;
  }


  public int getSize(){
  return size;
  }



  private void initPolygon() {
    poly = new Polygon();
    int halfWidth = width / 2;
    int halfHeight = height / 2;
    poly.addPoint(0, halfHeight);
    poly.addPoint(halfWidth, 0);
    poly.addPoint(width, halfHeight);
    poly.addPoint(halfWidth, height);
  }

  public int getIconHeight() {
    return height;
  }

  public int getIconWidth() {
    return width;
  }

  public void paintIcon(Component c, Graphics g, int x, int y) {

   Graphics2D g2 = (Graphics2D) g;
   g2.setColor(color);
   jplot.GPoints.drawPointType(width,g2,x+size+1,y,height); 
   }

/*
    g.setColor(color);
    g.translate(x, y);
    if (selected) {
      g.fillPolygon(poly);
    } else {
      g.drawPolygon(poly);
    }
    g.translate(-x, -y);
  }
*/

}

 

Ads help maintain this website.