// // NOT COMPILABLE // public BufferedImage render(int w, int h, int xP, int yP, Logic8Set dat) { ... ... if (w != width || h != height) { width = w; height = h; background = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); backgroundGraphics = background.createGraphics(); cursors = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); cursorsGraphics = background.createGraphics(); channels = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); channelsGraphics = background.createGraphics(); datadisplay = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); dataGraphics = background.createGraphics(); highlight = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); highlightGraphics = background.createGraphics(); updateBackground = true; updateData = true; } image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); g = image.createGraphics(); fm = g.getFontMetrics(); ... ... if (updateBackground) { drawBackground(); } if (oldRowsActivated != rowsActivated()) { drawChannels(); } if (settings.chanHigh.isSelected() && color && yP > 0) { drawHighlight(); } if (updateData) { drawData(); } updateCursors(); g.drawImage(background, 0, 0, null); g.drawImage(channels, 0, 0, null); if (settings.chanHigh.isSelected() && color && yP > 0) { g.drawImage(highlight, 0, 0, null); } g.drawImage(datadisplay, 0, 0, null); g.drawImage(cursors, 0, 0, null); return image; } private void drawBackground() { backgroundGraphics.setColor(defaultColorSet.getBackgroundColor()); backgroundGraphics.fillRect(0, 0, width, height); } private void drawChannels() { //channels = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); //channelsGraphics = channels.createGraphics(); channelsGraphics.setColor(clear); channelsGraphics.fillRect(0, 0, width, height); for (int d = 1; d <= 8; d++) { currentRow = chanMap[d - 1]; if (isActivated(d)) { if (color) { drawPlate(defaultColorSet.getBackgroundColor(), channelsGraphics, left, (rowHeight) * currentRow + top, width - left, rowHeight); } if (leftMargin) { if (color) { channelsGraphics.setColor(defaultColorSet.getChannelColor(d)); drawPlate(defaultColorSet.getChannelColor(d), channelsGraphics, 0, (rowHeight) * currentRow + top, 20, rowHeight); drawPlate(darkBg, channelsGraphics, 20, (rowHeight) * currentRow + top, left - 20, rowHeight); } if (settings.chanText.isSelected()) { channelsGraphics.setColor(defaultColorSet.getTextColor()); channelsGraphics.drawString("Channel " + d, 30, (rowHeight) * (currentRow) + top + 25); } } } } } private void drawHighlight() { // highlight = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); // highlightGraphics = highlight.createGraphics(); highlightGraphics.setColor(clear); highlightGraphics.fillRect(0, 0, width, height); highlight(yP, rowHeight, highlightGraphics, left, top, sampleStep); } private void drawData() { // datadisplay = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); //dataGraphics = datadisplay.createGraphics(); dataGraphics.setColor(clear); dataGraphics.fillRect(0, 0, width, height); for (int d = 1; d <= 8; d++) { if (isActivated(d)) { currentRow = chanMap[d - 1]; int prev = -1; for (int i = 0; i < width; i++) { if (i % 200 == 0 && settings.timingMarkers.isSelected()) { dataGraphics.setColor(defaultColorSet.getTextColor()); time = ((i + xoff) * sampleStep) * currentSet.getTimeStep(); String str = ""; String str2 = null; if (time >= 1 || time == 0) { str = time + ""; str = str.substring(0, 1); str = str + " S"; str2 = ((time - Integer.parseInt(str.replaceAll(" S", ""))) * 1000) + ""; str2 = str2.substring(0, Math.min(6, str2.length())); if (Double.parseDouble(str2) == 0) { str2 = null; } else { str2 = str2.concat(" ms"); } dataGraphics.drawString(str, i + left - (fm.stringWidth(str) / 2), top - 25); if (str2 != null) { dataGraphics.drawString(str2, i + left - (fm.stringWidth(str2) / 2), top - 12); } } else { str = (time * 1000) + ""; str = str.substring(0, Math.min(5, str.length())); str = str + " ms"; dataGraphics.drawString(str, i + left - (fm.stringWidth(str) / 2), top - 12); } dataGraphics.fillRect(i + left - 2, top - 5, 4, 4); } if (!color) { dataGraphics.setColor(Color.black); } else if (coloredLines) { dataGraphics.setColor(defaultColorSet.getChannelColor(d)); if (d == 8) { dataGraphics.setColor(Color.white); } } data = currentSet.getSample((i + xoff) * sampleStep); if (prev < 0) { prev = data[d - 1]; } else { if (data[d - 1] != prev) { prev = data[d - 1]; dataGraphics.drawLine(i - 1 + left, ((rowHeight / 5) + rowHeight * currentRow) + top, i - 1 + left, ((rowHeight / 5) * 4 + rowHeight * currentRow) + top); } } boolean thick = false; int y = ((rowHeight) / 5) * data[d - 1]; if (y == 0) { y = ((rowHeight) / 5) * 4; thick = true; } y += (rowHeight) * currentRow; y += top; if (!thick) { dataGraphics.fillRect(i + left, y, 1, 1); } else { if (settings.thickBottom.isSelected()) { dataGraphics.fillRect(i + left, y - 1, 1, 1); } dataGraphics.fillRect(i + left, y, 1, 1); } } } } } private void updateCursors() { // cursors = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); //cursorsGraphics = cursors.createGraphics(); cursorsGraphics.setColor(clear); cursorsGraphics.fillRect(0, 0, width, height); if (settings.vertCursor.isSelected()) { cursorsGraphics.setColor(defaultColorSet.getVerticalCursorColor()); if (leftMargin) { cursorsGraphics.drawLine(Math.max(0, xP), top, xP, height); } else { cursorsGraphics.drawLine(xP, top, xP, height); } } drawInfo(cursorsGraphics, xP, yP, rowHeight, sampleStep); }