Java Scope

ts230

Gesperrt
Hallo!
Ich muss für ein Programm ein Scope machen(das Grid hab ich schon) das auf MIDI-Noten reagieren soll(z.b. wenn die Note 22 ist,dan wird die Linie bei 11 sein),halt eben wie ein Scope. Nur ich brauche Hilfe beim Zeichnen der Linien. Die sehen ja normalerweise wie eine Kurve aus. Dabei brauche ich nun Hilfe. Ich dachte dass ich das mit einem Polygon machen könnte und dann jeden zweiten Beat das Scope aktualisieren.Ich hoffe ihr wisst was ich meine.
Falls mein Bestehender Code hilft:
Java:
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package onscreenpiano;
import java.awt.*;
import javax.swing.*;
/**
 *
 * @author tristan
 */
public class ScopePane extends JPanel{
    private static final long serialVersionUID = 1L;
public ScopePane(){
setSize(300, 170);
}
public void paintComponent(Graphics g){
Graphics2D olG = (Graphics2D) g;
    olG.setColor(Color.BLACK);
olG.fillRect(0, 0, 300, 170);
olG.setColor(Color.GREEN);
int j=0;
int i=0;
while(j < 300){
olG.drawLine(j, 0, j, 170);
j=j+15;
}
while(i < 170){
if(i != 75){
olG.drawLine(0, i, 300, i);
olG.drawLine(0, i, 300, i);}
i=i+15;
}
olG.setColor(Color.ORANGE);
olG.drawLine(0, 37, 300, 37);
olG.setColor(Color.RED);
olG.drawLine(0, 112, 300, 112);
olG.setColor(Color.WHITE);
olG.setStroke (new BasicStroke(1f,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND,1f,new float[] {2f},0f));
olG.drawLine(0, 75, 300, 75);

//olG.drawLine(0, 0, 300, 0);
//olG.drawLine(0, 10, 300, 10);

}
public static void main(String[] args){
JFrame y = new JFrame("ScopePaneTest");
y.setSize(300,180);
y.getContentPane().add(new ScopePane(),BorderLayout.CENTER);
y.setVisible(true);
y.setDefaultCloseOperation(y.EXIT_ON_CLOSE);
}
}
 
Zuletzt bearbeitet von einem Moderator:
Zurück