| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- package customComponents;
- /**
- * Write a description of class Kruispunt here.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
- import java.awt.BasicStroke;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.Shape;
- import java.awt.geom.Line2D;
- import java.awt.image.BufferedImage;
- import java.io.File;
- import java.io.IOException;
- import javax.imageio.ImageIO;
- import javax.swing.JLabel;
- public class Kruispunt extends JLabel
- {
- BufferedImage kruispunt;
- public Kruispunt()
- {
- kruispunt = null;
- this.repaint();
- }
- public void setBoebot(int rotation)
- {
- if(rotation == 90)
- {
- try{
- kruispunt = ImageIO.read(new File("src/pictures/boebot.png"));
- }catch (IOException e){
-
- }
- }
- if(rotation == 0)
- {
- try{
- kruispunt = ImageIO.read(new File("src/pictures/boven boebot.png"));
- }catch (IOException e){
-
- }
- }
- if(rotation == 180)
- {
- try{
- kruispunt = ImageIO.read(new File("src/pictures/onder boebot.png"));
- }catch (IOException e){
-
- }
- }
- if(rotation == 270)
- {
- try{
- kruispunt = ImageIO.read(new File("src/pictures/links boebot.png"));
- }catch (IOException e){
-
- }
- }
- this.repaint();
- }
- public void setGat(int rotation)
- {
- if(rotation == 90)
- {
- try{
- kruispunt = ImageIO.read(new File("src/pictures/gatrechts.png"));
- }catch (IOException e){
-
- }
- }
- if(rotation == 0)
- {
- try{
- kruispunt = ImageIO.read(new File("src/pictures/gatboven.png"));
- }catch (IOException e){
-
- }
- }
- if(rotation == 180)
- {
- try{
- kruispunt = ImageIO.read(new File("src/pictures/gatonder.png"));
- }catch (IOException e){
-
- }
- }
- if(rotation == 270)
- {
- try{
- kruispunt = ImageIO.read(new File("src/pictures/gatlinks.png"));
- }catch (IOException e){
-
- }
- }
- this.repaint();
- }
- public void setFinish()
- {
-
- try{
- kruispunt = ImageIO.read(new File("src/pictures/finish.png"));
- }catch (IOException e){
-
- }
- this.repaint();
- }
- protected void paintComponent(Graphics g){
- super.paintComponent(g);
- Graphics2D g2 = (Graphics2D) g;
- g2.setStroke(new BasicStroke(3));
- Shape horLine = new Line2D.Double(0,getHeight()/2,getWidth(),getHeight()/2);
- Shape verLine = new Line2D.Double(getWidth()/2,0,getWidth()/2,getHeight());
- g2.draw(horLine);
- g2.draw(verLine);
-
- g2.drawImage(kruispunt, 0, 0, getWidth(), getHeight(), null);
- }
- }
|