public abstract class gl_AbstControl extends JComponent{
public gl_AbstControl(){
}
}
public class gl_Card extends gl_AbstControl implements HierarchyBoundsListener, DropTargetListener,
MouseListener, MouseMotionListener, Scrollable{
public enum UpdateAction { New, Add, Remove };
public class gl_CardButton extends gl_AbstControl{
}
private String title;
private List<Student> students;
private List<gl_CardButton> buttons;
private DropTarget dropTarget;
private DataFlavor dataFlavor;
private Rectangle rectAddButton;
private FontMetrics fm;
private boolean bHasAddButton;
private boolean bMouseInAddButton;
private Color cAddButtonColor;
private Color cBorderColor;
protected GL_RequestEventMulticaster multicaster;
public boolean HasAddButton(){ return bHasAddButton; }
public void SetHasAddButton(boolean hasAddButton){ this.bHasAddButton = hasAddButton; repaint(); }
public gl_Card(String title){
super();
this.setFont(new Font("Myriad Pro", Font.BOLD, 16));
fm = getFontMetrics(this.getFont());
this.title = title;
buttons = new ArrayList<gl_CardButton>();
this.setBackground(new Color(255, 255, 255, 0));
this.cBorderColor = Color.white;
this.bHasAddButton = false;
this.cAddButtonColor = Color.white;
rectAddButton = new Rectangle(this.getX() + this.getWidth() - (fm.getHeight() + 4), 4,
fm.getHeight() - 4, fm.getHeight() - 4);
dropTarget = new DropTarget(this, DnDConstants.ACTION_COPY_OR_MOVE,
this, true, null);
this.addMouseListener(this);
this.addMouseMotionListener(this);
this.addHierarchyBoundsListener(this);
}
private void calcStuff(){
if(students != null && buttons != null){
for(int i=0; i<buttons.size(); i++){
buttons.get(i).setSize(this.getWidth() - 10, 20);
buttons.get(i).setLocation(5, 30 + i * 25);
}
}
}
@Override
public void paint(Graphics g){
super.paint(g);
g.setColor(cBorderColor);
g.fillRoundRect(0, 0, this.getWidth(), this.getHeight(), 25, 25);
g.setColor(new Color(135, 197, 255));
g.fillRoundRect(g.getClipBounds().x + 2, g.getClipBounds().y + 2, g.getClipBounds().width - 4, g.getClipBounds().height - 4, 25, 25);
g.setColor(Color.white);
g.setFont(this.getFont());
g.drawString(this.title, (int)((g.getClipBounds().getWidth() - fm.stringWidth(title))/2), 18);
g.fillRect(0, fm.getHeight() + 2, (int)g.getClipBounds().getWidth(), 3);
if(bHasAddButton){
g.setColor(cAddButtonColor);
Rectangle r = rectAddButton = new Rectangle(g.getClipBounds().x + g.getClipBounds().width - (fm.getHeight() + 4), 4,
fm.getHeight() - 4, fm.getHeight() - 4);
g.drawRoundRect(r.x, r.y, r.width, r.height,
fm.getHeight() - 4, fm.getHeight() - 4);
g.drawLine( r.x + (int)(r.width / 2) + 1,
r.y + 3,
r.x + (int)(r.width / 2) + 1,
r.y + r.height - 3);
g.drawLine( r.x + 3,
r.y + (int)(r.height / 2),
r.x + r.width - 3,
r.y + (int)(r.height / 2));
}
super.paintComponents(g);
}
@Override
public Dimension getPreferredScrollableViewportSize() {
return null;
}
@Override
public int getScrollableBlockIncrement(Rectangle arg0, int arg1, int arg2) {
return 0;
}
@Override
public boolean getScrollableTracksViewportHeight() {
return false;
}
@Override
public boolean getScrollableTracksViewportWidth() {
return false;
}
@Override
public int getScrollableUnitIncrement(Rectangle arg0, int arg1, int arg2) {
return 0;
}
}