-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHistogram.java
More file actions
56 lines (47 loc) · 1.44 KB
/
Copy pathHistogram.java
File metadata and controls
56 lines (47 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import org.bytedeco.javacv.CanvasFrame;
import javax.swing.*;
import java.awt.image.BufferedImage;
/**
* Created by Linus Karsai (312070209) on 28/05/2014.
*/
public class Histogram {
private JFrame canvas = new CanvasFrame("Histogram");
private JLabel histogramLabel = new JLabel();
public Histogram() {
canvas.setLayout(null);
canvas.add(histogramLabel);
canvas.setFocusableWindowState(false);
canvas.setVisible(false);
}
/**
* If Histogram dialog is visible
* draw histogram on it
* @param img
*/
public void drawHistogram(BufferedImage img) {
if (canvas.isVisible()) {
drawHistogram(ImageUtilities.getHistogram(img));
}
}
/**
* Get the histogram from ImageUtilities and wrap it
* in html
* @param s
*/
public void drawHistogram(String s) {
if (canvas.isVisible()) {
histogramLabel.setText("<html>" + s.replace("\n", "<br>") + "<html>");
histogramLabel.setBounds(0, 0, (int) histogramLabel.getPreferredSize().getWidth(), (int) histogramLabel.getPreferredSize().getHeight());
canvas.setSize(histogramLabel.getWidth() + 25, histogramLabel.getHeight() + 25);
}
}
public void hide() {
canvas.setVisible(false);
}
public void show() {
canvas.setVisible(true);
}
public boolean isVisible() {
return canvas.isVisible();
}
}