forked from aguegu/DotMatrixJava
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
98 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
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,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>DotMatrixJava</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
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,49 @@ | ||
package aguegu.dotmatrix; | ||
|
||
import javax.swing.JPanel; | ||
|
||
import java.awt.Color; | ||
import java.awt.Graphics; | ||
import java.awt.Graphics2D; | ||
import java.awt.BasicStroke; | ||
|
||
class DotMatrixPanel extends JPanel | ||
{ | ||
private static final long serialVersionUID = -2531292225634588108L; | ||
|
||
private static final int BLOCK_WIDTH = 13; | ||
private static final Color BACKGROUND_COLOR = Color.lightGray; | ||
private static final Color ON_Color = Color.white; | ||
private static final Color OFF_Color = Color.gray; | ||
|
||
private boolean[] _dot; | ||
|
||
public DotMatrixPanel() | ||
{ | ||
super(); | ||
_dot = new boolean[64]; | ||
} | ||
|
||
@Override | ||
public void paintComponent(Graphics g) | ||
{ | ||
super.paintComponent(g); | ||
Graphics2D g2d = (Graphics2D) g; | ||
g2d.setBackground(BACKGROUND_COLOR); | ||
g2d.clearRect(0, 0, this.getWidth(), this.getHeight()); | ||
|
||
g2d.setColor(ON_Color); | ||
BasicStroke bs = new BasicStroke(BLOCK_WIDTH - 1); | ||
g2d.setStroke(bs); | ||
|
||
for (int r = 0; r < 8; r++) | ||
{ | ||
int y = BLOCK_WIDTH + r * BLOCK_WIDTH; | ||
for (int c = 0; c < 8; c++) | ||
{ | ||
int x = BLOCK_WIDTH + c * BLOCK_WIDTH; | ||
g2d.drawLine(x, y, x, y); | ||
} | ||
} | ||
} | ||
} |
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,26 @@ | ||
package aguegu.dotmatrix; | ||
|
||
import javax.swing.JFrame; | ||
import aguegu.dotmatrix.DotMatrixPanel; | ||
|
||
public class DotMatrixTest | ||
{ | ||
|
||
public static void main(String[] args) | ||
{ | ||
DotMatrixTest dmt = new DotMatrixTest(); | ||
dmt.go(); | ||
|
||
} | ||
|
||
public void go() | ||
{ | ||
JFrame frame = new JFrame("dot-matrix"); | ||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
frame.setContentPane(new DotMatrixPanel()); | ||
frame.setBounds(100, 100, 800, 400); | ||
// frame.setLocationRelativeTo(null); | ||
// frame.setSize(800, 600); | ||
frame.setVisible(true); | ||
} | ||
} |