@Test public void testPaintComponent() { System.out.println("paintComponent"); Graphics g = new TestGraphics(); GraphPanelChart instance = new GraphPanelChart(); instance.setSize(500, 500); instance.getChartSettings().setDrawFinalZeroingLines(true); instance.getChartSettings().setDrawCurrentX(true); instance.getChartSettings().setExpendRows(true); final ConcurrentSkipListMap<String, AbstractGraphRow> rows = new ConcurrentSkipListMap<String, AbstractGraphRow>(); instance.setRows(rows); final GraphRowAverages row1 = new GraphRowAverages(); row1.setDrawThickLines(true); row1.setDrawLine(true); row1.setDrawBar(true); row1.setDrawValueLabel(true); row1.setMarkerSize(AbstractGraphRow.MARKER_SIZE_BIG); rows.put("test 1", row1); row1.add(System.currentTimeMillis(), 20); instance.paintComponent(g); row1.add(System.currentTimeMillis(), 540); instance.setxAxisLabelRenderer(new DateTimeRenderer("HH:mm:ss")); instance.paintComponent(g); row1.add(System.currentTimeMillis(), 8530); instance.paintComponent(g); }
@Override public void paintComponent(Graphics g) { super.paintComponent(g); int witdh = this.getWidth(); int height = this.getHeight(); if (cacheHeight != height || cacheWitdh != witdh || gpcId != cacheOwner) { cacheValid = false; } if (!cacheValid) { if (cache == null || cacheHeight != height || cacheWitdh != witdh) { cache = new BufferedImage(witdh, height, BufferedImage.TYPE_INT_ARGB); } Graphics2D g2d = cache.createGraphics(); g2d.setClip(0, 0, witdh, height); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); drawPanel(g2d); cacheValid = true; cacheHeight = height; cacheWitdh = witdh; cacheOwner = gpcId; } g.drawImage(cache, 0, 0, this); }
GraphPanelChart extends JComponent implements ClipboardOwner { @Override public void paintComponent(Graphics g) { super.paintComponent(g); int witdh = this.getWidth(); int height = this.getHeight(); if (cacheHeight != height || cacheWitdh != witdh || gpcId != cacheOwner) { cacheValid = false; } if (!cacheValid) { if (cache == null || cacheHeight != height || cacheWitdh != witdh) { cache = new BufferedImage(witdh, height, BufferedImage.TYPE_INT_ARGB); } Graphics2D g2d = cache.createGraphics(); g2d.setClip(0, 0, witdh, height); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); drawPanel(g2d); cacheValid = true; cacheHeight = height; cacheWitdh = witdh; cacheOwner = gpcId; } g.drawImage(cache, 0, 0, this); } }
GraphPanelChart extends JComponent implements ClipboardOwner { @Override public void paintComponent(Graphics g) { super.paintComponent(g); int witdh = this.getWidth(); int height = this.getHeight(); if (cacheHeight != height || cacheWitdh != witdh || gpcId != cacheOwner) { cacheValid = false; } if (!cacheValid) { if (cache == null || cacheHeight != height || cacheWitdh != witdh) { cache = new BufferedImage(witdh, height, BufferedImage.TYPE_INT_ARGB); } Graphics2D g2d = cache.createGraphics(); g2d.setClip(0, 0, witdh, height); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); drawPanel(g2d); cacheValid = true; cacheHeight = height; cacheWitdh = witdh; cacheOwner = gpcId; } g.drawImage(cache, 0, 0, this); } GraphPanelChart(boolean allowCsvExport, boolean haveGUI);  GraphPanelChart(boolean haveGUI);  GraphPanelChart(); }
GraphPanelChart extends JComponent implements ClipboardOwner { @Override public void paintComponent(Graphics g) { super.paintComponent(g); int witdh = this.getWidth(); int height = this.getHeight(); if (cacheHeight != height || cacheWitdh != witdh || gpcId != cacheOwner) { cacheValid = false; } if (!cacheValid) { if (cache == null || cacheHeight != height || cacheWitdh != witdh) { cache = new BufferedImage(witdh, height, BufferedImage.TYPE_INT_ARGB); } Graphics2D g2d = cache.createGraphics(); g2d.setClip(0, 0, witdh, height); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); drawPanel(g2d); cacheValid = true; cacheHeight = height; cacheWitdh = witdh; cacheOwner = gpcId; } g.drawImage(cache, 0, 0, this); } GraphPanelChart(boolean allowCsvExport, boolean haveGUI);  GraphPanelChart(boolean haveGUI);  GraphPanelChart(); ChartSettings getChartSettings(); void setReSetColors(boolean reSetColors); void setDisplayPrecision(boolean displayPrecision); void setxAxisLabel(String xAxisLabel); void setYAxisLabel(String yAxisLabel); void setPrecisionLabel(int precision); void setIsPreview(boolean isPreview); void setTestStartTime(long time); boolean isModelContainsRow(AbstractGraphRow row); void setChartType(int type); void invalidateCache(); @Override void paintComponent(Graphics g); void setRows(AbstractMap<String, AbstractGraphRow> aRows); void setyAxisLabelRenderer(NumberRenderer yAxisLabelRenderer); void setxAxisLabelRenderer(NumberRenderer xAxisLabelRenderer); void setCurrentX(long currentX); void setForcedMinX(long minX); void clearErrorMessage(); void setErrorMessage(String msg); @Override void lostOwnership(Clipboard clipboard, Transferable contents); void setUseRelativeTime(boolean selected); void saveGraphToPNG(File file, int w, int h); void saveGraphToCSV(File file); }
GraphPanelChart extends JComponent implements ClipboardOwner { @Override public void paintComponent(Graphics g) { super.paintComponent(g); int witdh = this.getWidth(); int height = this.getHeight(); if (cacheHeight != height || cacheWitdh != witdh || gpcId != cacheOwner) { cacheValid = false; } if (!cacheValid) { if (cache == null || cacheHeight != height || cacheWitdh != witdh) { cache = new BufferedImage(witdh, height, BufferedImage.TYPE_INT_ARGB); } Graphics2D g2d = cache.createGraphics(); g2d.setClip(0, 0, witdh, height); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); drawPanel(g2d); cacheValid = true; cacheHeight = height; cacheWitdh = witdh; cacheOwner = gpcId; } g.drawImage(cache, 0, 0, this); } GraphPanelChart(boolean allowCsvExport, boolean haveGUI);  GraphPanelChart(boolean haveGUI);  GraphPanelChart(); ChartSettings getChartSettings(); void setReSetColors(boolean reSetColors); void setDisplayPrecision(boolean displayPrecision); void setxAxisLabel(String xAxisLabel); void setYAxisLabel(String yAxisLabel); void setPrecisionLabel(int precision); void setIsPreview(boolean isPreview); void setTestStartTime(long time); boolean isModelContainsRow(AbstractGraphRow row); void setChartType(int type); void invalidateCache(); @Override void paintComponent(Graphics g); void setRows(AbstractMap<String, AbstractGraphRow> aRows); void setyAxisLabelRenderer(NumberRenderer yAxisLabelRenderer); void setxAxisLabelRenderer(NumberRenderer xAxisLabelRenderer); void setCurrentX(long currentX); void setForcedMinX(long minX); void clearErrorMessage(); void setErrorMessage(String msg); @Override void lostOwnership(Clipboard clipboard, Transferable contents); void setUseRelativeTime(boolean selected); void saveGraphToPNG(File file, int w, int h); void saveGraphToCSV(File file); static final int CHART_PERCENTAGE; static final int CHART_DEFAULT; }