List of usage examples for java.awt RenderingHints VALUE_ANTIALIAS_ON
Object VALUE_ANTIALIAS_ON
To view the source code for java.awt RenderingHints VALUE_ANTIALIAS_ON.
Click Source Link
From source file:savant.view.swing.GraphPane.java
private void renderCurrentSelected(Graphics2D g2) { // Temporarily shift the origin g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.translate(0, getOffset());//from www . jav a2 s . c o m for (Track t : tracks) { if (t.getRenderer().hasMappedValues()) { List<Shape> currentSelected = t.getRenderer().getCurrentSelectedShapes(this); if (currentSelected.size() > 0) { boolean arcMode = t.getDrawingMode() == DrawingMode.ARC_PAIRED; for (Shape selectedShape : currentSelected) { if (selectedShape != currentOverShape) { if (arcMode) { g2.setColor(Color.GREEN); g2.draw(selectedShape); } else { //g2.setColor(Color.GREEN); g2.setColor(new Color(0, 255, 0, 150)); g2.fill(selectedShape); if (selectedShape.getBounds().getWidth() > 5) { g2.setColor(Color.BLACK); g2.draw(selectedShape); } } } } } break; } } if (currentOverShape != null) { if (tracks[0].getDrawingMode() == DrawingMode.ARC_PAIRED) { g2.setColor(Color.RED); g2.draw(currentOverShape); //get record pair BAMIntervalRecord rec1 = (BAMIntervalRecord) currentOverRecord; BAMIntervalRecord rec2 = ((BAMTrack) tracks[0]).getMate(rec1); //mate //render reads with mismatches ((BAMTrackRenderer) tracks[0].getRenderer()).renderReadsFromArc(g2, this, rec1, rec2, prevRange); } else { g2.setColor(new Color(255, 0, 0, 150)); g2.fill(currentOverShape); if (currentOverShape.getBounds() != null && currentOverShape.getBounds().getWidth() > 5 && currentOverShape.getBounds().getHeight() > 3) { g2.setColor(Color.BLACK); g2.draw(currentOverShape); } } } //shift the origin back g2.translate(0, -getOffset()); }
From source file:org.yccheok.jstock.gui.charting.ChartLayerUI.java
@Override protected void paintLayer(Graphics2D g2, JXLayer<? extends V> layer) { super.paintLayer(g2, layer); if (this.mainTraceInfo.getPoint() == null) { return;//from ww w .j a va2 s . c o m } final Object oldValueAntiAlias = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING); final Color oldColor = g2.getColor(); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setColor(COLOR_BLUE); final int BALL_RADIUS = 8; g2.fillOval((int) (this.mainTraceInfo.getPoint().getX() - (BALL_RADIUS >> 1) + 0.5), (int) (this.mainTraceInfo.getPoint().getY() - (BALL_RADIUS >> 1) + 0.5), BALL_RADIUS, BALL_RADIUS); for (TraceInfo indicatorTraceInfo : this.indicatorTraceInfos) { final Point2D point = indicatorTraceInfo.getPoint(); if (null == point) { continue; } g2.fillOval((int) (point.getX() - (BALL_RADIUS >> 1) + 0.5), (int) (point.getY() - (BALL_RADIUS >> 1) + 0.5), BALL_RADIUS, BALL_RADIUS); } g2.setColor(oldColor); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldValueAntiAlias); this.drawInformationBox(g2, layer); }
From source file:com.cmart.PageControllers.SellItemImagesController.java
private static BufferedImage resizeImageWithHint(BufferedImage originalImage, int type, int width, int height) { BufferedImage resizedImage = new BufferedImage(width, width, type); Graphics2D g = resizedImage.createGraphics(); g.drawImage(originalImage, 0, 0, width, width, null); g.dispose();/*from w ww. jav a 2 s .co m*/ g.setComposite(AlphaComposite.Src); g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); return resizedImage; }
From source file:gg.msn.ui.panel.MainPanel.java
@Override public void paint(Graphics g) { super.paint(g); try {//from ww w . ja v a 2 s . c o m Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB); g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); //render per utenti Facebook if (ChatClientView.protocol.equals(ChatClientView.FACEBOOK_PROTOCOL)) { final FacebookUser user = (FacebookUser) value; int textY = (getHeight() / 2) + (g2.getFont().getSize() / 2); //name string g2.setFont(list.getFont()); g2.drawString(user.name, WHITE_SPACE + IMAGE_LATE + 3, textY); //status string // g2.setFont(list.getFont()); // g2.drawString(user.status, WHITE_SPACE + IMAGE_LATE + 3, textY); //icon ImageIcon icon = user.portrait; //log.debug("icon [" + icon + "]"); //ImageIcon scaledIcon = new ImageIcon(icon.getImage().getScaledInstance(24, 24, Image.SCALE_AREA_AVERAGING)); g2.drawImage(icon.getImage(), WHITE_SPACE, getHeight() / 2 - (IMAGE_LATE / 2), IMAGE_LATE, IMAGE_LATE, null); // g2.setColor(Color.WHITE); // g2.drawRoundRect(WHITE_SPACE, getHeight() / 2 - (IMAGE_LATE / 2), IMAGE_LATE, IMAGE_LATE, ARC_SIZE, ARC_SIZE); // g2.drawRoundRect(WHITE_SPACE, getHeight() / 2 - ((IMAGE_LATE+1) / 2), IMAGE_LATE+1, IMAGE_LATE+1, ARC_SIZE, ARC_SIZE); // g2.drawRoundRect(WHITE_SPACE, getHeight() / 2 - ((IMAGE_LATE+2) / 2), IMAGE_LATE+2, IMAGE_LATE+2, ARC_SIZE, ARC_SIZE); //render per utenti Client // log.debug("user status [" + user.status + "]"); // log.debug("user online status [" + user.onlineStatus + "]"); if (StringUtils.equals(user.status, FacebookUser.STATUS_ONLINE)) { g2.setColor(Color.GREEN); g2.fillOval(getWidth() - STATUS_ICON_OFFSET, (getHeight() / 2) - (STATUS_ICON_WIDTH / 2), STATUS_ICON_WIDTH, STATUS_ICON_WIDTH); } else { g2.setColor(Color.GRAY); g2.fillOval(getWidth() - STATUS_ICON_OFFSET, (getHeight() / 2) - (STATUS_ICON_WIDTH / 2), STATUS_ICON_WIDTH, STATUS_ICON_WIDTH); } } else { g2.setFont(list.getFont()); int textY = (getHeight() / 2) + (g2.getFont().getSize() / 2); Client client = (Client) value; // setText((client).getNick()); ImageIcon icon = null; try { new ImageIcon(client.getImage()); } catch (Exception e) { // log.debug("immgine non presente"); icon = ThemeManager.getTheme().get(ThemeManager.USER_ICON); } g2.drawString(client.getNick(), WHITE_SPACE + IMAGE_LATE + 3, textY); //log.debug("icon [" + icon + "]"); //ImageIcon scaledIcon = new ImageIcon(icon.getImage().getScaledInstance(24, 24, Image.SCALE_AREA_AVERAGING)); g2.drawImage(icon.getImage(), WHITE_SPACE, getHeight() / 2 - (IMAGE_LATE / 2), IMAGE_LATE, IMAGE_LATE, null); // setFont(list.getFont()); // setIcon(scaledIcon); } } catch (Exception e) { log.warn(e); } }
From source file:eu.udig.style.advanced.utils.Utilities.java
/** * Creates an image from a set of {@link RuleWrapper}s. * /*from w w w .jav a 2s. c om*/ * @param rulesWrapperList the list of rules wrapper. * @param width the image width. * @param height the image height. * @return the new created {@link BufferedImage}. */ public static BufferedImage lineRulesWrapperToImage(final List<RuleWrapper> rulesWrapperList, int width, int height) { BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D g2d = image.createGraphics(); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); for (RuleWrapper rule : rulesWrapperList) { BufferedImage tmpImage = Utilities.lineRuleWrapperToImage(rule, width, height); g2d.drawImage(tmpImage, 0, 0, null); } g2d.dispose(); return image; }
From source file:org.viafirma.util.QRCodeUtil.java
/** * Genera codigo de firma para impresin formado por el texto, el cdigo qr * del texto y un cdigo de barras con el cdigo de firma. * //w w w. j a v a 2 s.co m * @param text * @param codFirma * @return * @throws ExcepcionErrorInterno */ public byte[] generate(String text, String url, String textoQR, String codFirma) throws ExcepcionErrorInterno { // Comprobamos el tamao del texto. No recomendamos textos de mas de 120 // caracteres if (textoQR.length() > MAX_TEXT_SIZE) { log.warn("El tamao del texto '" + text + "' ha excedido el tamao mximo. " + text.length() + ">" + MAX_TEXT_SIZE); textoQR = textoQR.substring(textoQR.lastIndexOf(" ")); log.warn("El texto sera recortado: '" + textoQR + "'"); } // Generamos la sufperficie de dibujo BufferedImage imagenQR = new BufferedImage(ANCHO_ETIQUETA, ALTO_ETIQUETA, BufferedImage.TYPE_INT_RGB); Graphics2D g = imagenQR.createGraphics(); // El fondo es blanco g.setBackground(Color.WHITE); g.clearRect(0, 0, ANCHO_ETIQUETA, ALTO_ETIQUETA); g.setColor(Color.BLACK); g.setStroke(new BasicStroke(2f)); // Pintamos la caja de borde g.draw(new java.awt.Rectangle(MARGEN_CAJA, MARGEN_CAJA, ANCHO_ETIQUETA - MARGEN_CAJA * 2, ALTO_ETIQUETA - MARGEN_CAJA * 2)); g.draw(new java.awt.Rectangle(MARGEN_CAJA + 3, MARGEN_CAJA + 3, ANCHO_ETIQUETA - MARGEN_CAJA * 2 - 6, ALTO_ETIQUETA - MARGEN_CAJA * 2 - 6)); // Generamos el cdigo QR Qrcode x = new Qrcode(); x.setQrcodeErrorCorrect('L'); x.setQrcodeEncodeMode('B'); // Modo Binario byte[] d = textoQR.getBytes(); // Generamos el cdigo QR boolean[][] s = x.calQrcode(d); for (int i = 0; i < s.length; i++) { for (int j = 0; j < s.length; j++) { if (s[j][i]) { g.fillRect(j * SIZE_QR + MARGEN, i * SIZE_QR + MARGEN, SIZE_QR, SIZE_QR); } } } int marjenSeparador = MARGEN + SIZE_QR * s.length + MARGEN_CAJA; int marjenTexto = marjenSeparador + MARGEN_CAJA; // Linea de separacin entre el QR cdigo y el texto g.drawLine(marjenSeparador - 3, MARGEN_CAJA + 3, marjenSeparador - 3, ALTO_ETIQUETA - MARGEN_CAJA - 3); g.drawLine(marjenSeparador, MARGEN_CAJA + 3, marjenSeparador, ALTO_ETIQUETA - MARGEN_CAJA - 3); // Linea de separacin entre texto y cdigo de barras. int marjenCodigoBarras = MARGEN + MAX_ROWS * FONT_SIZE; // Pintamos una pequea linea de separacin g.drawLine(marjenSeparador, marjenCodigoBarras, ANCHO_ETIQUETA - MARGEN_CAJA - 3, marjenCodigoBarras); g.drawLine(marjenSeparador, marjenCodigoBarras - 3, ANCHO_ETIQUETA - MARGEN_CAJA - 3, marjenCodigoBarras - 3); // Escribimos el texto List<String> parrafos = split(text); g.setFont(new Font(g.getFont().getName(), Font.BOLD, FONT_SIZE)); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); for (int i = 0; i < parrafos.size(); i++) { String linea = parrafos.get(i); // Pintamos la nueva linea de texto g.drawString(linea, marjenTexto, MARGEN + 3 + (FONT_SIZE * i + 1)); } g.setFont(new Font(g.getFont().getName(), Font.BOLD, FONT_SIZE - 4)); // Pintamos el texto final de una sola lnea( Generalmente el MD5 ) //if(url.length()) if (!url.equals("")) { g.drawString("Custodia del documento: ", marjenTexto, marjenCodigoBarras - 10 * 2); g.drawString(url, marjenTexto, marjenCodigoBarras - 6); } marjenCodigoBarras += MARGEN_CAJA; // Generamos el cdigo de barras try { // int marjenCodigoBarras=MARGEN+MAX_ROWS*FONT_SIZE; BarcodeFactory.createCode39(codFirma, true).draw(g, marjenTexto, marjenCodigoBarras); } catch (Exception e1) { // TODO e1.printStackTrace(); } // g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, // RenderingHints.VALUE_ANTIALIAS_OFF); // Finalizamos la superficie de dibujo g.dispose(); ByteArrayOutputStream out = new ByteArrayOutputStream(); // Generamos la imagen try { ImageIO.write(imagenQR, "png", out); // ImageIO.write(imagenQR, "png", new // FileOutputStream("/tmp/imagen.png")); out.close(); } catch (Exception e) { throw new ExcepcionErrorInterno(CodigoError.ERROR_INTERNO, e); } return out.toByteArray(); }
From source file:coolmap.canvas.datarenderer.renderer.impl.NumberToColor.java
private void updateGradient() { // System.out.println("Gradient updated.."); _gradient.reset();//from w w w .j av a 2 s . c o m for (int i = 0; i < editor.getNumPoints(); i++) { Color c = editor.getColorAt(i); float p = editor.getColorPositionAt(i); if (c == null || p < 0 || p > 1) { continue; } _gradient.addColor(c, p); } _gradientColors = _gradient.generateGradient(CImageGradient.InterType.Linear); int width = DEFAULT_LEGEND_WIDTH; int height = DEFAULT_LEGENT_HEIGHT; legend = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice() .getDefaultConfiguration().createCompatibleImage(width, height, Transparency.TRANSLUCENT); Graphics2D g = (Graphics2D) legend.createGraphics(); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); LinearGradientPaint paint = editor.getLinearGradientPaint(0, 0, width, 0); g.setPaint(paint); g.fillRoundRect(0, 0, width, height - 12, 5, 5); g.setColor(UI.colorBlack2); g.setFont(UI.fontMono.deriveFont(10f)); DecimalFormat format = new DecimalFormat("#.##"); g.drawString(format.format(_minValue), 2, 23); String maxString = format.format(_maxValue); int swidth = g.getFontMetrics().stringWidth(maxString); g.drawString(maxString, width - 2 - swidth, 23); g.dispose(); // System.out.println("===Gradient updated===" + _gradientColors + " " + this); }
From source file:business.ImageManager.java
public ImageIcon getArrow(double angle) { BufferedImage img = new BufferedImage(40, 40, BufferedImage.TRANSLUCENT); Graphics2D big = img.createGraphics(); //setup para os rastros big.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); big.setStroke(/*from www . ja v a 2s .c om*/ new BasicStroke(2f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1f, new float[] { 5f }, 0f)); big.setColor(Color.red); int cx = this.getYellowBall().getIconWidth() / 2; int cy = this.getYellowBall().getIconHeight() / 2; AffineTransform at = AffineTransform.getTranslateInstance(cx, cy); at.rotate(Math.toRadians(angle)); // at.scale(2.0, 2.0); Shape shape = at.createTransformedShape(createArrow()); big.setPaint(Color.red); big.draw(shape); ImageIcon ret = new ImageIcon(img); return (ret); // tenta com o icone...angle. }
From source file:eu.planets_project.tb.impl.chart.ExperimentChartServlet.java
public JFreeChart createWallclockChart(String expId) { ExperimentPersistencyRemote edao = ExperimentPersistencyImpl.getInstance(); long eid = Long.parseLong(expId); log.info("Building experiment chart for eid = " + eid); Experiment exp = edao.findExperiment(eid); final DefaultCategoryDataset dataset = new DefaultCategoryDataset(); final String expName = exp.getExperimentSetup().getBasicProperties().getExperimentName(); boolean hasSuccesses = false; boolean hasFails = false; for (BatchExecutionRecordImpl batch : exp.getExperimentExecutable().getBatchExecutionRecords()) { int i = 1; List<ExecutionRecordImpl> runs = new ArrayList<ExecutionRecordImpl>(batch.getRuns()); Collections.sort(runs, new RunComparator()); for (ExecutionRecordImpl exr : runs) { //log.info("Found Record... "+exr+" stages: "+exr.getStages()); if (exr != null && exr.getStages() != null) { // Look up the object, so we can get the name. DigitalObjectRefBean dh = new DataHandlerImpl().get(exr.getDigitalObjectReferenceCopy()); String dobName = "Object " + i; if (dh != null) dobName = dh.getName(); ResultsForDigitalObjectBean res = new ResultsForDigitalObjectBean( exr.getDigitalObjectReferenceCopy()); Double time = null; boolean success = false; // First, attempt to pull from stage records: // FIXME: Note that this record is really at the wrong level. /*/* w w w . j av a2s . c om*/ if( exr.getStages().size() == 1 ) { for( ExecutionStageRecordImpl exsr : exr.getStages() ) { Double stageTime = exsr.getDoubleMeasurement( TecRegMockup.PROP_SERVICE_TIME ); if( stageTime != null ) { time = stageTime; success = exsr.isMarkedAsSuccessful(); } } } */ // Pick up from record duration: if (time == null && res.getExecutionDuration() != null) { //convert from milli seconds to seconds time = (double) res.getExecutionDuration() / 1000.0; success = res.getHasExecutionSucceededOK(); } log.info("Found DOB: {" + exr.getDigitalObjectReferenceCopy() + "} {" + dobName + "} w/ time " + time); if (res.getExecutionRecord() != null) log.info("Timing: " + res.getExecutionRecord().getStartDate() + " " + res.getExecutionRecord().getEndDate()); if (time != null) { if (success) { dataset.addValue(time, "Succeeded", dobName); hasSuccesses = true; } else { dataset.addValue(time, "Failed", dobName); hasFails = true; } } } // Increment, for the next run. i++; } } int si = dataset.getRowIndex("Succeeded"); int ri = dataset.getRowIndex("Failed"); // Create the chart. JFreeChart chart = ChartFactory.createStackedBarChart(null, "Digital Object", "Time [s]", dataset, PlotOrientation.VERTICAL, true, true, false); // set the background color for the chart... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); // set the range axis to display integers only... //final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); //rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // disable bar outlines... final BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(true); renderer.setShadowVisible(false); renderer.setBarPainter(new StandardBarPainter()); // set up gradient paints for series... final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0.0f, 0.9f, 0.0f)); final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(0.9f, 0.0f, 0.0f)); if (hasSuccesses) renderer.setSeriesPaint(si, gp0); if (hasFails) renderer.setSeriesPaint(ri, gp1); // Set the tooltips... //renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator("xy_chart.jsp","series","section")); renderer.setBaseToolTipGenerator(new MeasurementToolTipGenerator()); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 4.0)); // More settings chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // Remove the border, as the SVG renderer has problems with the text overflowing. chart.getLegend().setBorder(0.0, 0.0, 0.0, 0.0); // Remove the padding between the axes and the plot: chart.getPlot().setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); // Set a gradient fill, fading towards the top: final GradientPaint gpb0 = new GradientPaint(0.0f, 0.0f, new Color(245, 245, 245), 0.0f, 0.0f, Color.white); chart.getPlot().setBackgroundPaint(gpb0); return chart; }
From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.JFreeChartPlotEngine.java
/** * Updates the chart panel to show the provided {@link JFreeChart}. If the chart is * <code>null</code> an empty Plot will be shown. If an overlay has been defined and the chart * is a {@link XYPlot} the overlay is also drawn. */// w ww. ja v a 2 s . c o m private synchronized void updateChartPanel(final JFreeChart chart) { Runnable updateChartPanelRunnable = new Runnable() { @Override public void run() { if (chart != chartPanel.getChart()) { if (chart == null) { chartPanel.setChart(new JFreeChart(new CategoryPlot())); fireChartChanged(new JFreeChart(new CategoryPlot())); } else { RenderingHints renderingHints = chart.getRenderingHints(); // enable antialiasing renderingHints.add(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); // disable normalization (normalization tries to draw the center of strokes // at whole pixels, which causes e.g. // scaled shapes to appear more like potatoes than like circles) renderingHints.add(new RenderingHints(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE)); chart.setRenderingHints(renderingHints); chartPanel.setChart(chart); fireChartChanged(chart); } } if (chart != null) { chartPanel.removeOverlay(crosshairOverlay); crosshairOverlay = new MultiAxesCrosshairOverlay(); if (chart.getPlot() instanceof XYPlot) { // add overlays for range axes int axisIdx = 0; for (RangeAxisConfig rangeAxisConfig : plotInstance.getCurrentPlotConfigurationClone() .getRangeAxisConfigs()) { for (AxisParallelLineConfiguration line : rangeAxisConfig.getCrossHairLines() .getLines()) { Crosshair crosshair = new Crosshair(line.getValue(), line.getFormat().getColor(), line.getFormat().getStroke()); crosshairOverlay.addRangeCrosshair(axisIdx, crosshair); } ++axisIdx; } // add overlays for domain axis for (AxisParallelLineConfiguration line : plotInstance.getCurrentPlotConfigurationClone() .getDomainConfigManager().getCrosshairLines().getLines()) { Crosshair crosshair = new Crosshair(line.getValue(), line.getFormat().getColor(), line.getFormat().getStroke()); crosshairOverlay.addDomainCrosshair(crosshair); } chartPanel.addOverlay(crosshairOverlay); } } } }; if (SwingUtilities.isEventDispatchThread()) { updateChartPanelRunnable.run(); } else { SwingUtilities.invokeLater(updateChartPanelRunnable); } }