only:minor clean-up
This commit is contained in:
parent
18c6e7b0a9
commit
59cee800bc
|
@ -2,7 +2,6 @@ package com.rusefi.ts_plugin;
|
|||
|
||||
import com.efiAnalytics.plugin.ecu.*;
|
||||
import com.rusefi.core.ui.AutoupdateUtil;
|
||||
import com.rusefi.models.Utils;
|
||||
import org.putgemin.VerticalFlowLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
|
@ -261,11 +260,10 @@ public class KnockAnalyzerTab {
|
|||
flushed = true;
|
||||
}
|
||||
|
||||
private void initCanvas(KnockMotionListener kmml, KnockMouseListener kml, KnockKeyListener l, JComponent canvas) {
|
||||
private void initCanvas(KnockMotionListener kmml, KnockMouseListener kml, JComponent canvas) {
|
||||
canvas.setFocusTraversalKeysEnabled(false);
|
||||
canvas.addMouseMotionListener(kmml);
|
||||
canvas.addMouseListener(kml);
|
||||
canvas.addKeyListener(l);
|
||||
canvas.setFocusable(true);
|
||||
canvas.setFocusTraversalKeysEnabled(false);
|
||||
canvas.setFocusable(true);
|
||||
|
@ -310,8 +308,7 @@ public class KnockAnalyzerTab {
|
|||
KnockCanvas canvas = new KnockCanvas(number, divider);
|
||||
KnockMouseListener kml = new KnockMouseListener(canvas);
|
||||
KnockMotionListener kmml = new KnockMotionListener(canvas, this.magnituges);
|
||||
KnockKeyListener l = new KnockKeyListener();
|
||||
initCanvas(kmml, kml, l, canvas.getComponent());
|
||||
initCanvas(kmml, kml, canvas.getComponent());
|
||||
canvasesComponent.add(canvas.getComponent());
|
||||
canvases.add(canvas);
|
||||
}
|
||||
|
@ -365,38 +362,10 @@ public class KnockAnalyzerTab {
|
|||
refreshCanvases();
|
||||
}
|
||||
|
||||
public boolean getStartState() {
|
||||
return this.started;
|
||||
}
|
||||
|
||||
public JComponent getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public class KnockKeyListener extends KeyAdapter implements ActionListener {
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
|
||||
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_UP) {
|
||||
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_LEFT) {
|
||||
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_DOWN) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
//drawPanel.repaint();
|
||||
}
|
||||
}
|
||||
|
||||
public class KnockMotionListener implements MouseMotionListener {
|
||||
|
||||
private KnockCanvas knockCanvas;
|
||||
|
@ -423,9 +392,9 @@ public class KnockAnalyzerTab {
|
|||
}
|
||||
}
|
||||
|
||||
public class KnockMouseListener implements MouseListener {
|
||||
public class KnockMouseListener extends MouseAdapter {
|
||||
|
||||
private KnockCanvas knockCanvas;
|
||||
private final KnockCanvas knockCanvas;
|
||||
|
||||
KnockMouseListener(KnockCanvas canvas) {
|
||||
knockCanvas = canvas;
|
||||
|
@ -435,25 +404,5 @@ public class KnockAnalyzerTab {
|
|||
public void mouseClicked(MouseEvent e) {
|
||||
knockCanvas.setupFrequencyByClick(e.getX(), e.getY());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,49 +100,40 @@ public class KnockCanvas {
|
|||
}
|
||||
};
|
||||
|
||||
private ComponentListener componentListener = new ComponentAdapter() {
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
bufferedImage = new BufferedImage(component.getWidth(), component.getHeight(), BufferedImage.TYPE_INT_RGB);
|
||||
bufferedGraphics = bufferedImage.createGraphics();
|
||||
}
|
||||
};
|
||||
|
||||
private BufferedImage bufferedImage;
|
||||
private Graphics2D bufferedGraphics;
|
||||
|
||||
int SPECTROGRAM_X_AXIS_SIZE_BASE = 1024 * 4;
|
||||
int SPECTROGRAM_X_AXIS_SIZE = SPECTROGRAM_X_AXIS_SIZE_BASE;
|
||||
float[][] specrtogram;
|
||||
Color[] colorspace;
|
||||
private int SPECTROGRAM_X_AXIS_SIZE_BASE = 1024 * 4;
|
||||
private int SPECTROGRAM_X_AXIS_SIZE = SPECTROGRAM_X_AXIS_SIZE_BASE;
|
||||
private float[][] specrtogram;
|
||||
private Color[] colorspace;
|
||||
|
||||
int spectrogramYAxisSize;
|
||||
private int spectrogramYAxisSize;
|
||||
|
||||
int currentIndexXAxis = 0;
|
||||
private int currentIndexXAxis = 0;
|
||||
|
||||
int number = 1;
|
||||
private int number = 1;
|
||||
|
||||
|
||||
public double yAxisHz[];
|
||||
int yAxisFequencyStart = -1;
|
||||
float yAxisFequencyStep = -1;
|
||||
private int yAxisFequencyStart = -1;
|
||||
private float yAxisFequencyStep = -1;
|
||||
|
||||
|
||||
float currentFrequency = 0;
|
||||
float currentAmplitude = 0;
|
||||
private float currentFrequency = 0;
|
||||
private float currentAmplitude = 0;
|
||||
|
||||
|
||||
int peakX = 0;
|
||||
int peakY = 0;
|
||||
float peakFrequency = 0;
|
||||
float peakAmplitude = 0;
|
||||
int peakAmplitudeCol = 0;
|
||||
private int peakY = 0;
|
||||
private float peakFrequency = 0;
|
||||
private float peakAmplitude = 0;
|
||||
private int peakAmplitudeCol = 0;
|
||||
|
||||
|
||||
int mouse_x = 0;
|
||||
int mouse_y = 0;
|
||||
float mouseFrequency = 0;
|
||||
float mouseAmplitude = 0;
|
||||
private float mouseFrequency = 0;
|
||||
private float mouseAmplitude = 0;
|
||||
|
||||
|
||||
public KnockCanvas(int number, int divider) {
|
||||
|
@ -154,6 +145,13 @@ public class KnockCanvas {
|
|||
|
||||
bufferedImage = new BufferedImage(640,480, BufferedImage.TYPE_INT_RGB);
|
||||
bufferedGraphics = bufferedImage.createGraphics();
|
||||
ComponentListener componentListener = new ComponentAdapter() {
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
bufferedImage = new BufferedImage(component.getWidth(), component.getHeight(), BufferedImage.TYPE_INT_RGB);
|
||||
bufferedGraphics = bufferedImage.createGraphics();
|
||||
}
|
||||
};
|
||||
component.addComponentListener(componentListener);
|
||||
|
||||
//linear-gradient(to right, #000000, #290d1a, #490b32, #670353, #81007b, #a60085, #ca008b, #ef008f, #ff356b, #ff6947, #ff9a22, #ffc700);
|
||||
|
@ -216,12 +214,9 @@ public class KnockCanvas {
|
|||
}
|
||||
}
|
||||
|
||||
public void processValues(float values[]) {
|
||||
|
||||
//mainFrequency = 0;
|
||||
public void processValues(float[] values) {
|
||||
|
||||
for (int i = 0; i < spectrogramYAxisSize; ++i) {
|
||||
|
||||
specrtogram[currentIndexXAxis][i] = values[i];
|
||||
}
|
||||
|
||||
|
@ -268,14 +263,12 @@ public class KnockCanvas {
|
|||
if(peakAmplitudeCol == currentIndexXAxis) {
|
||||
peakFrequency = 0;
|
||||
peakAmplitude = 0;
|
||||
peakX = 0;
|
||||
peakY = 0;
|
||||
}
|
||||
|
||||
if(currentAmplitude > peakAmplitude) {
|
||||
peakFrequency = currentFrequency;
|
||||
peakAmplitude = currentAmplitude;
|
||||
peakX = maxX;
|
||||
peakY = maxY;
|
||||
peakAmplitudeCol = currentIndexXAxis;
|
||||
}
|
||||
|
@ -326,7 +319,6 @@ public class KnockCanvas {
|
|||
void resetPeak() {
|
||||
peakFrequency = 0;
|
||||
peakAmplitude = 0;
|
||||
peakX = 0;
|
||||
peakY = 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue