-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathByteLattice.java
More file actions
247 lines (217 loc) · 5.94 KB
/
ByteLattice.java
File metadata and controls
247 lines (217 loc) · 5.94 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
/*
* Open Source Physics software is free software as described near the bottom of this code file.
*
* For additional information and documentation on Open Source Physics please see:
* <http://www.opensourcephysics.org/>
*/
package org.opensourcephysics.display2d;
import java.awt.Color;
import javax.swing.JFrame;
import org.opensourcephysics.display.Measurable;
/**
* The ByteLattice interface defines a lattice visualization component where each
* array element can assume one of 256 values.
*
* Known implementations are: ByteRaster, CellLattice, and SiteLattice.
*
* @author Wolfgang Christian
* @created May 27, 2003
* @version 1.0
*/
public interface ByteLattice extends Measurable {
/**
* Gets the number of x entries.
* @return nx
*/
public int getNx();
/**
* Gets the number of y entries.
* @return ny
*/
public int getNy();
/**
* Determines the lattice index (row-major order) from given x and y world coordinates.
* Returns -1 if the world coordinates are outside the lattice.
*
* @param x
* @param y
* @return index
*/
public int indexFromPoint(double x, double y);
/**
* Gets closest index from the given x world coordinate.
*
* @param x double the coordinate
* @return int the index
*/
public int xToIndex(double x);
/**
* Gets closest index from the given y world coordinate.
*
* @param y double the coordinate
* @return int the index
*/
public int yToIndex(double y);
/**
* Gets a value from the given location.
*
* @param ix
* @param iy
* @return the value.
*/
public byte getValue(int ix, int iy);
/**
* Sets the given x,y location to a value.
*
* @param ix
* @param iy
* @param val
*/
public void setValue(int ix, int iy, byte val);
/**
* Randomizes the values.
*/
public void randomize();
/**
* Resizes the lattice.
*
* @param _nx
* @param _ny
*/
public void resizeLattice(int _nx, int _ny);
/**
* Sets the lattice values and scale.
*
* The lattice is resized to fit the new data if needed.
*
* @param val int[][] the new values
* @param xmin double
* @param xmax double
* @param ymin double
* @param ymax double
*/
public void setAll(byte val[][], double xmin, double xmax, double ymin, double ymax);
/**
* Sets a block of data to new values.
*
* @param ix_offset the x offset into the lattice
* @param iy_offset the y offset into the lattice
* @param val
*/
public void setBlock(int ix_offset, int iy_offset, byte val[][]);
/**
* Sets a block of data starting at (0,0) to new values.
*
* @param val
*/
public void setBlock(byte val[][]);
/**
* Sets a column to new values.
*
* @param ix the x index of the column
* @param iy_offset the y offset in the column
* @param val values in column
*/
public void setCol(int ix, int iy_offset, byte val[]);
/**
* Sets a row to new values.
*
* @param iy the y index of the row
* @param ix_offset the x offset in the row
* @param val
*/
public void setRow(int iy, int ix_offset, byte val[]);
/**
* Outlines the lattice boundaries with a grid.
*
* @param showGridLines
*/
public void setShowGridLines(boolean showGridLines);
/**
* Sets the color for grid line boundaries
*
* @param c
*/
public void setGridLineColor(Color c);
/**
* Shows the color associated with each value.
* @return the JFrame containing the legend
*/
public JFrame showLegend();
/**
* Sets the visibility of the lattice.
* Drawing will be disabled if visible is false.
*
* @param isVisible
*/
public void setVisible(boolean isVisible);
/**
* Sets the color palette.
*
* @param colors
*/
public void setColorPalette(Color[] colors);
/**
* Sets the color for a single index.
* @param i
* @param color
*/
public void setIndexedColor(int i, Color color);
/**
* Assigns a scale to the lattice in world units.
*
* This method does not change lattice values; it assigns units corners of the lattice.
*
* @param xmin
* @param xmax
* @param ymin
* @param ymax
*/
public void setMinMax(double xmin, double xmax, double ymin, double ymax);
/**
* Sets xmin.
* @param xmin double
*/
public void setXMin(double xmin);
/**
* Sets xmax.
* @param xmax double
*/
public void setXMax(double xmax);
/**
* Sets ymin.
* @param ymin double
*/
public void setYMin(double ymin);
/**
* Sets ymax.
* @param ymax double
*/
public void setYMax(double ymax);
/**
* Creates the default palette.
*/
public void createDefaultColors();
}
/*
* Open Source Physics software is free software; you can redistribute
* it and/or modify it under the terms of the GNU General Public License (GPL) as
* published by the Free Software Foundation; either version 2 of the License,
* or(at your option) any later version.
* Code that uses any portion of the code in the org.opensourcephysics package
* or any subpackage (subdirectory) of this package must must also be be released
* under the GNU GPL license.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston MA 02111-1307 USA
* or view the license online at http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2007 The Open Source Physics project
* http://www.opensourcephysics.org
*/