-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
canvas finished, partially finished checker graphic
- Loading branch information
Showing
4 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package view; | ||
|
||
import java.awt.Color; | ||
import java.awt.Graphics; | ||
import java.awt.Graphics2D; | ||
import java.awt.RenderingHints; | ||
|
||
import javax.swing.JButton; | ||
|
||
public class GUIPiece extends JButton { | ||
private Color color; | ||
|
||
public GUIPiece(Color color) { | ||
super(""); | ||
this.color = color; | ||
this.setContentAreaFilled(false); | ||
this.setBorderPainted(false); | ||
} | ||
|
||
protected void paintComponent(Graphics g) { | ||
if (getModel().isArmed()) { | ||
g.setColor(color); | ||
} else { | ||
g.setColor(getBackground()); | ||
} | ||
Graphics2D g2 = (Graphics2D)g; | ||
RenderingHints hints = new RenderingHints(null); | ||
hints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); | ||
hints.put(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); | ||
hints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); | ||
g2.setRenderingHints(hints); | ||
g2.fillOval(0, 0, getSize().width,getSize().height-1); | ||
super.paintComponent(g2); | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package view; | ||
|
||
import java.awt.Component; | ||
import java.awt.Graphics; | ||
import java.awt.Insets; | ||
|
||
import javax.swing.border.Border; | ||
|
||
public class RoundedBorder implements Border { | ||
|
||
private int radius; | ||
|
||
|
||
RoundedBorder(int radius) { | ||
this.radius = radius; | ||
} | ||
|
||
|
||
public Insets getBorderInsets(Component c) { | ||
return new Insets(this.radius+1, this.radius+1, this.radius+2, this.radius); | ||
} | ||
|
||
|
||
public boolean isBorderOpaque() { | ||
return true; | ||
} | ||
|
||
|
||
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { | ||
g.drawRoundRect(x, y, width-2, height-2, radius, radius); | ||
} | ||
} |
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