/*main.c*/
/*printf("[%d]\n", a);
printf("[%10d]\n", a);
printf("[%-10d]\n", a);
printf("%010d\n", a);
}
*/
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
/*
* 그 이후에
* # b 추가
* 기타 표현 추가
* 소리 입히기 (피아노 ) 우리에겐 오픈 파일들이 인터넷에 있어 ! :) :( 어라...
*
*
* 일단 음표 무시하고 점으로
*
* */
public class Main extends JFrame
{
/*
*
*
* 이코드는 당신의 것이 아닙니다.
* 제발 이 코드에 덮어서 코딩하지 마세요
*
* 제발...
* 제발...
*
*
*/
public int[][] notes = new int[100][5];
//32 24 16 12 8 6 3 2
public int[][] beats = new int[100][5];
//이차원 배열로 층 만들기
public int input_beat = 1;
//일단 도레미파솔라시도부터 하고
public JButton[] setting = new JButton[20];
public int px=0,py=0;
void setbuttons()
{
int i;
for(i = 0;i < 20;i++)
{
setting[i] = new JButton();
}
File file = new File("./img/default.png");
try {
BufferedImage img = ImageIO.read(file);
ImageIcon icon = new ImageIcon(img);
setting[0].setIcon(icon);
setting[0].setSize(50, 50);
System.out.println("ahdugh");
setting[0].setLocation(5, 5);
panel.add(setting[0]);
file = new File("./img/simple.png");
img = ImageIO.read(file);
icon = new ImageIcon(img);
setting[1].setIcon(icon);
setting[1].setSize(50, 50);
System.out.println("ahdugh");
setting[1].setLocation(60, 5);
panel.add(setting[1]);
} catch (IOException e) {
System.out.println("sdjghiugwhbuib3rv");
}
}
class MyPanel extends JPanel{
public Graphics a ;
public int start = 150, term=10;
public int xstart = 150;
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(new Color(0,0,0,255));
int i;
//PointerInfo pt = MouseInfo.getPointerInfo();
//Point mousePoint = new Point(pt.getLocation());
g.fillOval(px,py, term, term);
//System.out.println(mousePoint.x+" "+ mousePoint.y);
//mous.getX();
for(i = 0;i < 5;i++)
{
g.drawLine(0, start+term*i, 1000, start+term*i);
}
for(i = 0;i < 100;i++)
{
if(notes[i][0]!=-100)
{
g.fillOval((i*(int)(term*1.5))+xstart,
start+(int)(((float)(7-notes[i][0])/2)*term)+term+term/2,
term+term/5,
term);
g.setColor(new Color(255,255,255));
/*
g.fillOval((i*(int)(term*1.5))+xstart+term/3-term/16,
start+(int)(((float)(7-notes[i][0])/2)*term)+term+term/2+(term/4)-term/10,
(int)(term/1.6),
(int)(term/1.4));*/
g.setColor(new Color(0,0,0));
//
if(true)
{
if(notes[i][0]<=6)
{
g.drawLine((i*(int)(term*1.5))+xstart+(term+term/5)-1,
start+(int)(((float)(7-notes[i][0])/2)*term)+term+term/2+term/2,
(i*(int)(term*1.5))+xstart+(term+term/5)-1,
start+(int)(((float)(7-(notes[i][0]+6))/2)*term)+term+term/2);
}
else
{
g.drawLine((i*(int)(term*1.5))+xstart+1,
start+(int)(((float)(7-notes[i][0])/2)*term)+term+term/2+term/2,
(i*(int)(term*1.5))+xstart+1,
start+(int)(((float)(7-(notes[i][0]-8))/2)*term)+term+term/2);
}
}
if(notes[i][0]<=1)
{
int j;
for(j = 1;j >= notes[i][0];j--)
{
g.drawLine((i*(int)(term*1.5))+xstart-term/5,
start+((7-j)/2)*term+term+term,
(i*(int)(term*1.5))+term+(int)(term/2)+xstart,
start+((7-j)/2)*term+term+term);
}
}
if(notes[i][0]>=13)
{
int j;
for(j = 13;j <= notes[i][0];j++)
{
g.drawLine((i*(int)(term*1.5))+xstart,
start+((7-j)/2)*term+term+term,
(i*(int)(term*1.5))+term+(int)(term/2)+xstart,
start+((7-j)/2)*term+term+term);
}
}
//if
}
}
for(i = 0;i < 5;i++)
{
g.drawLine(0, start+term*i, 1000, start+term*i);
}
}
}
MyPanel panel = new MyPanel();
class MyMouseListener extends MouseAdapter implements MouseMotionListener{
public void mousePressed(MouseEvent e)
{
px=e.getX();
py=e.getY();
int xx,yy;
xx = (e.getX()- panel.xstart )/(int)(panel.term*1.5);
yy = -2*(e.getY() - panel.start - (int)(3/2 * (float)panel.term) - (int)((7/2)*(float)panel.term))/panel.term +1;
if(xx>=0&&e.getButton() == 3)
{
/*
* getX() = i*term*1.5+xstart
* getX()- xstart /(term*1.5) = i
*
*
* getY() = start+((7-notes[i][0])/2)*term + term + term/2
*
* start+(7-notes[i][0])/2 *term + term + term/2
* start + (7/2)*term + (-notes[i][0]/2)*term + 3/2 * term = getY()
* -2(getY() - start - 3/2 * term - (7/2)*term)/term = notes[i][0]
*/
if(xx>=0&&yy+1==notes[xx][0]||yy+2==notes[xx][0])
{
notes[xx][0]=-100;
//System.out.println("YESSS");
}
System.out.println(xx+" "+yy);
//와 중학교 수학 만세!!!
//panel.term++;
/*
g.fillOval((i*(int)(term*1.5))+xstart,
start+(int)(((float)(7-notes[i][0])/2)*term)+term+term/2,
term+term/5,
term);*/
}
else if(e.getButton() == 1)
{
if(xx>=0&¬es[xx][0]==-100)
notes[xx][0] = yy+2;
}
panel.repaint();
}
public void mouseMoved(MouseEvent e)
{
px=e.getX();
py=e.getY();
//System.out.println("px : "+px+"py : "+py);
//notes[20]++;
panel.repaint();
}
}
public Main()
{
int i;
for(i = 0;i < 100;i++)
{
notes[i][0] = -100;
}
setbuttons();
panel.addMouseListener(new MyMouseListener());
panel.addMouseMotionListener(new MyMouseListener());
panel.setLayout(null);
setTitle("망할 음악");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Container c = getContentPane();
//c.setLayout(null);
/*JButton aaaa = new JButton();
aaaa.setSize(50,50);
aaaa.setLocation(5, 5);*/
setContentPane(panel);
//panel.add(aaaa);
for(i = 0;i < 17;i++)
{
if(i%2==0)
{
notes[i][0] = i/2;
}
}/*
notes[10] = 0;
notes[11] = -100;
notes[12] = -1;
notes[13] = -2;*/
setSize(1280,720);
setVisible(true);
}
public static void main(String [] args)
{
new Main();
}
}
/*
#include <stdio.h>
int main()
{
printf("Hello");
return 0;
}
*/
/*
#include <stdio.h>
int main()
{
printf("Hello World");
return 0;
}
*/
/*#include <stdio.h>
int main()
{
printf("Hello\nWorld");
return 0;
}*/
/*include <stdio.h>
int main()
{
printf("\'Hello'");
return 0;
}*/
/*#include <stdio.h>
int main()
{
printf("\"Hello World\"");
return 0;
}*/
/*#include <stdio.h>
int main()
{
printf("\"!@#$%^&*()\"");
return 0;
}*/
/*#include <stdio.h>
int main()
{
printf("\"C:\\Download\\hello.cpp\"");
return 0;
}*/
/*
#include<stdio.h>
int main() {
int a, b;
scanf("%d %d", &a, &b);
printf("%d", a+b);
}
*/
// 1010 1013 1017 1019 1020 1111
/*1010*/
/*#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
printf("%d", n);
}*/
/*1013*/
/*#include <stdio.h>
int main()
{
int a,b;
scanf("%d %d",&a,&b);
printf("%d %d",a,b);
}*/
/*1017*/
/*#include <stdio.h>
int main()
{
int a,b,c;
scanf("%d",&a);
printf("%d ",a);
printf("%d ",a);
printf("%d",a);
}*/
/*1019*/
/*#include <stdio.h>
int main()
{
int a,b,c;
scanf("%d.%d.%d", &a,&b,&c);
printf("%04d.%02d.%02d", a,b,c);
}*/
/*1020*/
/*#include <stdio.h>
int main()
{
int a,b;
scanf("%d-%d",&a,&b);
printf("%06d%07d",a,b);
return 0;
}*/
/*1111*/
/*#include <stdio.h>
int main()
{
int a;
scanf("%d",&a);
printf("%d%%",a);
return 0;
}*/
/*1113*/
/*#include <stdio.h>
int main()
{
int a,b;
scanf("%d %d",&a,&b);
printf("%d %d",b,a);
return 0;
}*/
//char c; %c
/*1011*/
/*#include <stdio.h>
int main()
{
char a;
scanf("%c",&a);
printf("%c",a);
}
*/
/*#include<stdio.h>
int main() {
double a;
scanf("%lf", &a);
printf("%lf", a);
}*/
// 1012 ~1018, 1023, 1025
/*1012*/
/*#include <stdio.h>
int main()
{
double x;
scanf("%lf", &x);
printf("%lf",x);
}
*/
/*#include <stdio.h>
int main()
{
char a,b;
scanf("%c %c",&a,&b);
printf("%c %c",b,a);
return 0;
}*/
/*#include <stdio.h>
int main()
{
double a;
scanf("%lf",&a);
printf("%.2lf",a);
}*/
/*
#include <stdio.h>
int main()
{
int a,b;
scanf("%d:%d",&a,&b);
printf("%d:%d", a,b);
}
*/
2021.03.13