-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIFrame.java
More file actions
129 lines (105 loc) · 3.72 KB
/
IFrame.java
File metadata and controls
129 lines (105 loc) · 3.72 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/**
* IFrame.java
*
* Created: Time-stamp: <2019-01-10 15:52:48 rlc3>
*
* @author <a href="mailto:">Roy L. Crole</a>
* @version 1.0
*/
import javax.swing.*;
import javax.swing.plaf.basic.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
public class IFrame extends JFrame implements MouseListener, MouseMotionListener{
private IMTCanvas canvas;
private JComboBox box;
private JCheckBox checkBox;
private String[] options ={"linearBox","linearOct","phaseShift"};
private JSpinner sp;
public final int size=60;
// IFrame constructor
public IFrame() {
// Setting for the Frame
setTitle("Image Manipulation Tool");
setSize(850,850);
setDefaultCloseOperation(EXIT_ON_CLOSE);
Container cp = getContentPane();
cp.setLayout(null);
// creating and adding the canvas to the frame
canvas= new IMTCanvas();
canvas.setBounds(0,0,600,600);
canvas.addMouseListener(this);
canvas.addMouseMotionListener(this);
cp.add(canvas);
// creating and adding the drop box to the frame
box = new JComboBox(options);
box.setBounds(650,50,150,50);
cp.add(box);
// creating and adding the check box to the frame
checkBox= new JCheckBox( "active on movement");
checkBox.setBounds(650,150,170,50);
cp.add(checkBox);
sp = new JSpinner();
sp.setBounds(650,200,40,20);
cp.add(sp);
} // end IFrame
// --- begin mouse listener methods
public void mouseClicked(MouseEvent e) {
int parameter = Integer.parseInt(sp.getValue().toString());
int answer=box.getSelectedIndex();
switch (answer) {
case 0 :
ImageManipulation.linearBox(canvas.getImage(), parameter,
e.getX(),e.getY(), size);
canvas.reset();
break;
case 1 :
ImageManipulation.linearOct(canvas.getImage(), parameter,
e.getX(),e.getY(), size);
canvas.reset();
break;
case 2 :
ImageManipulation.phaseShift(canvas.getImage(), parameter,
e.getX(),e.getY(), size);
canvas.reset();
break;
}
canvas.repaint();
} // end mouseClicked
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e){}
public void mousePressed(MouseEvent e){}
public void mouseReleased(MouseEvent e) {}
public void mouseDragged(MouseEvent e){}
public void mouseMoved(MouseEvent e) {
if (checkBox.isSelected()) {
int parameter = Integer.parseInt( sp.getValue().toString());
int answer=box.getSelectedIndex();
switch (answer) {
case 0 :
BufferedImage temp=canvas.getTempImage();
ImageManipulation.linearBox(temp, parameter,
e.getX(),e.getY(), size);
break;
case 1 :
temp=canvas.getTempImage();
ImageManipulation.linearOct(temp, parameter,
e.getX(),e.getY(), size);
break;
case 2 :
temp=canvas.getTempImage();
ImageManipulation.phaseShift(temp, parameter,
e.getX(),e.getY(), size);
break;
}
canvas.repaint();
}
} // end mouseMoved
// --- end mouse listener methods
// main method
public static void main(String[] args) {
IFrame i= new IFrame();
i.setVisible(true);
}
} // IFrame