Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2011
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.54 KB | None | 0 0
  1. //
  2. // NOT COMPILABLE
  3. //
  4.  
  5. public BufferedImage render(int w, int h, int xP, int yP, Logic8Set dat) {
  6. ...
  7. ...
  8. if (w != width || h != height) {
  9. width = w;
  10. height = h;
  11.  
  12.  
  13.  
  14. background = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
  15. backgroundGraphics = background.createGraphics();
  16.  
  17. cursors = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
  18. cursorsGraphics = background.createGraphics();
  19.  
  20. channels = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
  21. channelsGraphics = background.createGraphics();
  22.  
  23. datadisplay = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
  24. dataGraphics = background.createGraphics();
  25.  
  26. highlight = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
  27. highlightGraphics = background.createGraphics();
  28.  
  29. updateBackground = true;
  30. updateData = true;
  31. }
  32.  
  33. image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
  34. g = image.createGraphics();
  35. fm = g.getFontMetrics();
  36. ...
  37. ...
  38. if (updateBackground) {
  39. drawBackground();
  40. }
  41. if (oldRowsActivated != rowsActivated()) {
  42. drawChannels();
  43. }
  44. if (settings.chanHigh.isSelected() && color && yP > 0) {
  45. drawHighlight();
  46. }
  47. if (updateData) {
  48. drawData();
  49. }
  50. updateCursors();
  51.  
  52. g.drawImage(background, 0, 0, null);
  53. g.drawImage(channels, 0, 0, null);
  54. if (settings.chanHigh.isSelected() && color && yP > 0) {
  55. g.drawImage(highlight, 0, 0, null);
  56. }
  57. g.drawImage(datadisplay, 0, 0, null);
  58. g.drawImage(cursors, 0, 0, null);
  59. return image;
  60. }
  61.  
  62. private void drawBackground() {
  63. backgroundGraphics.setColor(defaultColorSet.getBackgroundColor());
  64. backgroundGraphics.fillRect(0, 0, width, height);
  65. }
  66.  
  67. private void drawChannels() {
  68. //channels = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
  69. //channelsGraphics = channels.createGraphics();
  70. channelsGraphics.setColor(clear);
  71. channelsGraphics.fillRect(0, 0, width, height);
  72. for (int d = 1; d <= 8; d++) {
  73. currentRow = chanMap[d - 1];
  74. if (isActivated(d)) {
  75.  
  76. if (color) {
  77. drawPlate(defaultColorSet.getBackgroundColor(), channelsGraphics, left, (rowHeight) * currentRow + top, width - left, rowHeight);
  78. }
  79.  
  80. if (leftMargin) {
  81. if (color) {
  82. channelsGraphics.setColor(defaultColorSet.getChannelColor(d));
  83. drawPlate(defaultColorSet.getChannelColor(d), channelsGraphics, 0, (rowHeight) * currentRow + top, 20, rowHeight);
  84. drawPlate(darkBg, channelsGraphics, 20, (rowHeight) * currentRow + top, left - 20, rowHeight);
  85. }
  86. if (settings.chanText.isSelected()) {
  87. channelsGraphics.setColor(defaultColorSet.getTextColor());
  88. channelsGraphics.drawString("Channel " + d, 30, (rowHeight) * (currentRow) + top + 25);
  89. }
  90. }
  91. }
  92. }
  93. }
  94.  
  95. private void drawHighlight() {
  96. // highlight = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
  97. // highlightGraphics = highlight.createGraphics();
  98. highlightGraphics.setColor(clear);
  99. highlightGraphics.fillRect(0, 0, width, height);
  100. highlight(yP, rowHeight, highlightGraphics, left, top, sampleStep);
  101. }
  102.  
  103. private void drawData() {
  104. // datadisplay = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
  105. //dataGraphics = datadisplay.createGraphics();
  106. dataGraphics.setColor(clear);
  107. dataGraphics.fillRect(0, 0, width, height);
  108. for (int d = 1; d <= 8; d++) {
  109. if (isActivated(d)) {
  110. currentRow = chanMap[d - 1];
  111. int prev = -1;
  112. for (int i = 0; i < width; i++) {
  113.  
  114. if (i % 200 == 0 && settings.timingMarkers.isSelected()) {
  115. dataGraphics.setColor(defaultColorSet.getTextColor());
  116.  
  117. time = ((i + xoff) * sampleStep) * currentSet.getTimeStep();
  118. String str = "";
  119. String str2 = null;
  120. if (time >= 1 || time == 0) {
  121. str = time + "";
  122. str = str.substring(0, 1);
  123. str = str + " S";
  124. str2 = ((time - Integer.parseInt(str.replaceAll(" S", ""))) * 1000) + "";
  125. str2 = str2.substring(0, Math.min(6, str2.length()));
  126.  
  127. if (Double.parseDouble(str2) == 0) {
  128. str2 = null;
  129. } else {
  130. str2 = str2.concat(" ms");
  131. }
  132. dataGraphics.drawString(str, i + left - (fm.stringWidth(str) / 2), top - 25);
  133. if (str2 != null) {
  134. dataGraphics.drawString(str2, i + left - (fm.stringWidth(str2) / 2), top - 12);
  135. }
  136. } else {
  137. str = (time * 1000) + "";
  138. str = str.substring(0, Math.min(5, str.length()));
  139. str = str + " ms";
  140. dataGraphics.drawString(str, i + left - (fm.stringWidth(str) / 2), top - 12);
  141.  
  142. }
  143.  
  144. dataGraphics.fillRect(i + left - 2, top - 5, 4, 4);
  145.  
  146. }
  147. if (!color) {
  148. dataGraphics.setColor(Color.black);
  149. } else if (coloredLines) {
  150. dataGraphics.setColor(defaultColorSet.getChannelColor(d));
  151. if (d == 8) {
  152. dataGraphics.setColor(Color.white);
  153. }
  154. }
  155.  
  156. data = currentSet.getSample((i + xoff) * sampleStep);
  157.  
  158. if (prev < 0) {
  159. prev = data[d - 1];
  160. } else {
  161. if (data[d - 1] != prev) {
  162. prev = data[d - 1];
  163. dataGraphics.drawLine(i - 1 + left, ((rowHeight / 5) + rowHeight * currentRow) + top,
  164. i - 1 + left, ((rowHeight / 5) * 4 + rowHeight * currentRow) + top);
  165. }
  166. }
  167. boolean thick = false;
  168. int y = ((rowHeight) / 5) * data[d - 1];
  169. if (y == 0) {
  170. y = ((rowHeight) / 5) * 4;
  171. thick = true;
  172. }
  173. y += (rowHeight) * currentRow;
  174. y += top;
  175. if (!thick) {
  176. dataGraphics.fillRect(i + left, y, 1, 1);
  177. } else {
  178. if (settings.thickBottom.isSelected()) {
  179. dataGraphics.fillRect(i + left, y - 1, 1, 1);
  180. }
  181.  
  182. dataGraphics.fillRect(i + left, y, 1, 1);
  183.  
  184. }
  185. }
  186. }
  187. }
  188. }
  189.  
  190. private void updateCursors() {
  191. // cursors = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
  192. //cursorsGraphics = cursors.createGraphics();
  193. cursorsGraphics.setColor(clear);
  194. cursorsGraphics.fillRect(0, 0, width, height);
  195. if (settings.vertCursor.isSelected()) {
  196. cursorsGraphics.setColor(defaultColorSet.getVerticalCursorColor());
  197. if (leftMargin) {
  198. cursorsGraphics.drawLine(Math.max(0, xP), top, xP, height);
  199. } else {
  200. cursorsGraphics.drawLine(xP, top, xP, height);
  201. }
  202. }
  203. drawInfo(cursorsGraphics, xP, yP, rowHeight, sampleStep);
  204. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement