Skip to content

Commit

Permalink
init project
Browse files Browse the repository at this point in the history
  • Loading branch information
aguegu committed Nov 1, 2012
1 parent d7f169a commit 155a88b
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .classpath
@@ -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>
17 changes: 17 additions & 0 deletions .project
@@ -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>
49 changes: 49 additions & 0 deletions src/aguegu/dotmatrix/DotMatrixPanel.java
@@ -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);
}
}
}
}
26 changes: 26 additions & 0 deletions src/aguegu/dotmatrix/DotMatrixTest.java
@@ -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);
}
}

0 comments on commit 155a88b

Please sign in to comment.