-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathMandelbrotDisplay.java
More file actions
163 lines (141 loc) · 3.93 KB
/
Copy pathMandelbrotDisplay.java
File metadata and controls
163 lines (141 loc) · 3.93 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
import java.awt.BorderLayout;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Panel;
import java.awt.Color;
import java.awt.image.BufferedImage;
import javax.swing.*;
/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class MandelbrotDisplay extends javax.swing.JFrame {
private JPanel jPanel1;
private JPanel jPanel2;
private JPanel jPanel6;
private JPanel jPanel5;
private JPanel jPanel4;
private JPanel jPanel3;
public ImagePanel impnl;
/**
* Auto-generated main method to display this JFrame
*/
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
MandelbrotDisplay inst = new MandelbrotDisplay(340,240);
inst.setLocationRelativeTo(null);
inst.setVisible(true);
}
});
}
public MandelbrotDisplay(int x, int y) {
super();
this.impnl = new ImagePanel(x,y);
initGUI();
}
private void initGUI() {
try {
{
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
{
jPanel1 = new JPanel();
BorderLayout jPanel1Layout = new BorderLayout();
jPanel1.setLayout(jPanel1Layout);
getContentPane().add(jPanel1, BorderLayout.CENTER);
{
jPanel6 = new JPanel();
jPanel1.add(jPanel6, BorderLayout.SOUTH);
jPanel6.setPreferredSize(new java.awt.Dimension(732, 53));
}
{
jPanel5 = new JPanel();
jPanel1.add(jPanel5, BorderLayout.EAST);
jPanel5.setPreferredSize(new java.awt.Dimension(72, 360));
}
{
jPanel4 = new JPanel();
jPanel1.add(jPanel4, BorderLayout.WEST);
jPanel4.setPreferredSize(new java.awt.Dimension(55, 360));
}
{
jPanel3 = new JPanel();
jPanel1.add(jPanel3, BorderLayout.NORTH);
jPanel3.setPreferredSize(new java.awt.Dimension(732, 48));
}
{
jPanel2 = new JPanel();
jPanel2.add(this.impnl);
jPanel1.add(jPanel2, BorderLayout.CENTER);
}
}
pack();
} catch (Exception e) {
e.printStackTrace();
}
}
public int count = 0;
public void setColorArray(int x, int[][] colors){
int[] p = new int[colors.length];
for(int i = 0; i<colors.length;i++){
p[i] = new Color(colors[i][0], colors[i][1], colors[i][2]).getRGB();
}
this.impnl.setArray(x,p);
System.out.println("Here " + count++);
}
public void toggleVis(){
this.setVisible(!this.isVisible());
}
public class ImagePanel extends Panel {
private BufferedImage myimg = null;
public ImagePanel() {
setLayout(null);
setSize(500, 500);
this.setMyimg(new BufferedImage(500,500,BufferedImage.TYPE_INT_RGB));
}
public ImagePanel(int x, int y) {
setLayout(null);
setSize(x, y);
this.setMyimg(new BufferedImage(x,y,BufferedImage.TYPE_INT_RGB));
}
public void setImage(BufferedImage img) {
this.setMyimg(img);
repaint();
}
public void paint(Graphics g) {
if (getMyimg() != null) {
g.drawImage(getMyimg(), 0, 0, this);
}
}
public BufferedImage getCompatible(){
return new BufferedImage(this.getMyimg().getWidth(null),this.getMyimg().getHeight(null),BufferedImage.TYPE_INT_RGB);
}
/**
* @return the myimg
*/
public Image getImage() {
return getMyimg();
}
public void setMyimg(BufferedImage myimg) {
this.myimg = myimg;
}
public Image getMyimg() {
return myimg;
}
public void setArray(int x,int[] colors){
synchronized(this.myimg){
this.myimg.setRGB(x, 0, 1, this.myimg.getHeight(), colors, 0, 1);
repaint();
}
}
}
}