Example usage for java.awt RenderingHints VALUE_ANTIALIAS_ON

List of usage examples for java.awt RenderingHints VALUE_ANTIALIAS_ON

Introduction

In this page you can find the example usage for java.awt RenderingHints VALUE_ANTIALIAS_ON.

Prototype

Object VALUE_ANTIALIAS_ON

To view the source code for java.awt RenderingHints VALUE_ANTIALIAS_ON.

Click Source Link

Document

Antialiasing hint value -- rendering is done with antialiasing.

Usage

From source file:org.locationtech.udig.style.advanced.points.PointStyleManager.java

private TableViewer createStylesTableViewer(Composite parent) {
    final StyleFilter filter = new StyleFilter();
    final Text searchText = new Text(parent, SWT.BORDER | SWT.SEARCH);
    searchText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
    searchText.addKeyListener(new KeyAdapter() {
        public void keyReleased(KeyEvent ke) {
            filter.setSearchText(searchText.getText());
            stylesViewer.refresh();/*from   w  w w  .  jav  a2s  . co  m*/
        }

    });

    stylesViewer = new TableViewer(parent, SWT.SINGLE | SWT.BORDER);
    Table table = stylesViewer.getTable();
    GridData tableGD = new GridData(SWT.FILL, SWT.FILL, true, true);
    tableGD.heightHint = 200;
    table.setLayoutData(tableGD);

    stylesViewer.addFilter(filter);
    stylesViewer.setContentProvider(new IStructuredContentProvider() {
        public Object[] getElements(Object inputElement) {
            if (inputElement instanceof List<?>) {
                List<?> styles = (List<?>) inputElement;
                StyleWrapper[] array = (StyleWrapper[]) styles.toArray(new StyleWrapper[styles.size()]);
                return array;
            }
            return null;
        }

        public void dispose() {
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }
    });

    stylesViewer.setLabelProvider(new LabelProvider() {
        public Image getImage(Object element) {
            if (element instanceof StyleWrapper) {
                StyleWrapper styleWrapper = (StyleWrapper) element;
                List<FeatureTypeStyleWrapper> featureTypeStyles = styleWrapper
                        .getFeatureTypeStylesWrapperList();
                int iconSize = 48;
                BufferedImage image = new BufferedImage(iconSize, iconSize, BufferedImage.TYPE_INT_ARGB);
                Graphics2D g2d = image.createGraphics();
                g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
                for (FeatureTypeStyleWrapper featureTypeStyle : featureTypeStyles) {
                    List<RuleWrapper> rulesWrapperList = featureTypeStyle.getRulesWrapperList();
                    BufferedImage tmpImage = WrapperUtilities.pointRulesWrapperToImage(rulesWrapperList,
                            iconSize, iconSize);
                    g2d.drawImage(tmpImage, 0, 0, null);
                }
                g2d.dispose();
                Image convertToSWTImage = AWTSWTImageUtils.convertToSWTImage(image);
                return convertToSWTImage;
            }
            return null;
        }

        public String getText(Object element) {
            if (element instanceof StyleWrapper) {
                StyleWrapper styleWrapper = (StyleWrapper) element;
                String styleName = styleWrapper.getName();
                if (styleName == null || styleName.length() == 0) {
                    styleName = Utilities.DEFAULT_STYLENAME;
                    styleName = WrapperUtilities.checkSameNameStyle(getStyles(), styleName);
                    styleWrapper.setName(styleName);
                }
                return styleName;
            }
            return ""; //$NON-NLS-1$
        }
    });

    stylesViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            if (!(selection instanceof IStructuredSelection)) {
                return;
            }
            IStructuredSelection sel = (IStructuredSelection) selection;
            if (sel.isEmpty()) {
                return;
            }

            Object selectedItem = sel.getFirstElement();
            if (selectedItem == null) {
                // unselected, show empty panel
                return;
            }

            if (selectedItem instanceof StyleWrapper) {
                currentSelectedStyleWrapper = (StyleWrapper) selectedItem;
            }
        }

    });
    return stylesViewer;
}

From source file:doge.photo.DogePhotoManipulator.java

private void setGraphicsHints(Graphics2D graphics) {
    graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
    graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
}

From source file:com.sdk.connector.chart.TimeDomainRenderer.java

public TimeDomainRenderer(final String title, JPanel panel, String side, String type) {
    sdf = protocol.getTimestampFormat();
    this.side = side + type;
    this.type = type;
    serie.setKey(side);/*from  w  ww .  ja v  a 2  s . com*/
    dataset.addSeries(serie);
    String legendX = "";
    if (type.startsWith(java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("RR"))) {
        legendX = java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle")
                .getString("timeRR.ylabel");
    } else {
        legendX = java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle")
                .getString("timeBC.ylabel");
    }
    chart = ChartFactory.createTimeSeriesChart(title,
            java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("time.xlabel"),
            legendX, dataset, true, true, false);

    chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    chart.getRenderingHints().put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    chart.getRenderingHints().put(RenderingHints.KEY_ALPHA_INTERPOLATION,
            RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
    chart.getRenderingHints().put(RenderingHints.KEY_FRACTIONALMETRICS,
            RenderingHints.VALUE_FRACTIONALMETRICS_ON);
    chart.getRenderingHints().put(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
    chart.getRenderingHints().put(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
    chart.getRenderingHints().put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    chart.getRenderingHints().put(RenderingHints.KEY_TEXT_LCD_CONTRAST, 100);
    //chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.GREEN));
    // chart.setBackgroundPaint(new Color(220,255,220,0));
    //chart.setBackgroundImage(new javax.swing.ImageIcon(getClass().getResource("/com/sdk/connector/resources/background.png")).getImage());
    chart.addSubtitle(rangeAnnotation);

    plot = (XYPlot) chart.getPlot();

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, true);
    renderer.setSeriesShapesVisible(0, true);
    renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator(
            StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, sdf, new DecimalFormat("0.00")));
    renderer.setSeriesOutlinePaint(0, Color.BLACK);
    if (side.startsWith(
            java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("side.left"))) {
        renderer.setSeriesPaint(0, Color.BLUE);
    } else {
        renderer.setSeriesPaint(0, Color.RED);
    }

    renderer.setSeriesShape(0, new Ellipse2D.Double(-1.0, -1.0, 3.0, 3.0));
    if (type.startsWith(java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("BC"))) {
        renderer.setSeriesShape(0, new Rectangle2D.Double(-1.0, -1.0, 3.0, 3.0));
    }

    DateTickUnit dtUnit = new DateTickUnit(DateTickUnitType.MINUTE, 1, tickSDF);
    final DateAxis domainAxis = (DateAxis) plot.getDomainAxis();
    domainAxis.setTickUnit(dtUnit);

    //        ValueAxis axis = plot.getDomainAxis();
    //        axis = plot.getRangeAxis();
    //        ((NumberAxis) axis).setTickUnit(new NumberTickUnit(100));

    plot.setRenderer(renderer);
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.BLACK);
    plot.setRangeGridlinePaint(Color.BLACK);
    plot.getRenderer().setSeriesStroke(0, new BasicStroke(1.0f));
    // plot.getRenderer().setSeriesStroke(1, new BasicStroke(1.0f));
    plot.setForegroundAlpha(0.5f);
    plot.setNoDataMessage(
            java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("CALIBRATING..."));
    plot.setRangePannable(true);
    plot.setDomainPannable(true);
    Color color1 = new Color(0, 0, 0, 24);
    Color color2 = new Color(255, 255, 255, 24);

    GradientPaint gp = new GradientPaint(0, 0, color1, 0, 0, color2);
    plot.setBackgroundPaint(gp);

    chartPanel = new ChartPanel(chart);
    chartPanel.addChartMouseListener(this);
    panel.setLayout(new GridLayout(0, 1));

    panel.add(chartPanel);
    panel.repaint();
    panel.revalidate();

}

From source file:com.epiq.bitshark.ui.FrequencyDomainMouseMarker.java

/**
 * Draws the marker/*from  w w  w.j a v  a  2s. c  om*/
 * @param g2
 * @param rect
 */
public void draw(Graphics2D g2, Rectangle2D rect) {

    g2.setColor(outlineColor);
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    g2.fillOval((int) Math.round(rect.getX()), (int) Math.round(rect.getY()), (int) Math.round(rect.getWidth()),
            (int) Math.round(rect.getHeight()));
}

From source file:no.met.jtimeseries.chart.XYWindArrowRenderer.java

private void drawCircle(Graphics2D g) {
    g.setStroke(new BasicStroke(1));
    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g.drawOval(-arrowHeight / 2, -arrowHeight / 2, arrowHeight, arrowHeight);
}

From source file:ch.rasc.downloadchart.DownloadChartServlet.java

private static void handleJpg(HttpServletResponse response, byte[] imageData, Integer width, Integer height,
        String filename, JpegOptions options) throws IOException {

    response.setContentType("image/jpeg");
    response.setHeader("Content-Disposition", "attachment; filename=\"" + filename + ".jpg\";");

    BufferedImage image = ImageIO.read(new ByteArrayInputStream(imageData));

    Dimension newDimension = calculateDimension(image, width, height);
    int imgWidth = image.getWidth();
    int imgHeight = image.getHeight();
    if (newDimension != null) {
        imgWidth = newDimension.width;//from ww  w. j a v a 2s . c  o  m
        imgHeight = newDimension.height;
    }

    BufferedImage newImage = new BufferedImage(imgWidth, imgHeight, BufferedImage.TYPE_INT_RGB);

    Graphics2D g = newImage.createGraphics();
    g.drawImage(image, 0, 0, imgWidth, imgHeight, Color.BLACK, null);
    g.dispose();

    if (newDimension != null) {
        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);
    }

    try (ImageOutputStream ios = ImageIO.createImageOutputStream(response.getOutputStream())) {
        Iterator<ImageWriter> iter = ImageIO.getImageWritersByFormatName("jpg");
        ImageWriter writer = iter.next();
        ImageWriteParam iwp = writer.getDefaultWriteParam();
        iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
        if (options != null && options.quality != null && options.quality != 0 && options.quality != 100) {
            iwp.setCompressionQuality(options.quality / 100f);
        } else {
            iwp.setCompressionQuality(1);
        }
        writer.setOutput(ios);
        writer.write(null, new IIOImage(newImage, null, null), iwp);
        writer.dispose();
    }
}

From source file:org.yccheok.jstock.gui.charting.InvestmentFlowLayerUI.java

private void drawTitle(Graphics2D g2) {
    final Object oldValueAntiAlias = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
    final Color oldColor = g2.getColor();
    final Font oldFont = g2.getFont();

    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    final Font titleFont = oldFont.deriveFont(oldFont.getStyle() | Font.BOLD, (float) oldFont.getSize() * 1.5f);

    final int margin = 5;

    final FontMetrics titleFontMetrics = g2.getFontMetrics(titleFont);
    final FontMetrics oldFontMetrics = g2.getFontMetrics(oldFont);
    final java.text.NumberFormat numberFormat = java.text.NumberFormat.getInstance();
    numberFormat.setMaximumFractionDigits(2);
    numberFormat.setMinimumFractionDigits(2);

    final double totalInvestValue = this.investmentFlowChartJDialog.getTotalInvestValue();
    final double totalROIValue = this.investmentFlowChartJDialog.getTotalROIValue();

    final DecimalPlace decimalPlace = JStock.instance().getJStockOptions().getDecimalPlace();

    final String invest = org.yccheok.jstock.portfolio.Utils.toCurrencyWithSymbol(decimalPlace,
            totalInvestValue);/*from   w ww . j av  a2s.c  o  m*/
    final String roi = org.yccheok.jstock.portfolio.Utils.toCurrencyWithSymbol(decimalPlace, totalROIValue);
    final double gain = totalROIValue - totalInvestValue;
    final double percentage = totalInvestValue > 0.0 ? gain / totalInvestValue * 100.0 : 0.0;
    final String gain_str = org.yccheok.jstock.portfolio.Utils.toCurrencyWithSymbol(decimalPlace, gain);
    final String percentage_str = numberFormat.format(percentage);

    final String SELECTED = this.investmentFlowChartJDialog.getCurrentSelectedString();
    final String INVEST = GUIBundle.getString("InvestmentFlowLayerUI_Invest");
    final String RETURN = GUIBundle.getString("InvestmentFlowLayerUI_Return");
    final String GAIN = (SELECTED.length() > 0 ? SELECTED + " " : "")
            + GUIBundle.getString("InvestmentFlowLayerUI_Gain");
    final String LOSS = (SELECTED.length() > 0 ? SELECTED + " " : "")
            + GUIBundle.getString("InvestmentFlowLayerUI_Loss");

    final int string_width = oldFontMetrics.stringWidth(INVEST + ": ")
            + titleFontMetrics.stringWidth(invest + " ") + oldFontMetrics.stringWidth(RETURN + ": ")
            + titleFontMetrics.stringWidth(roi + " ")
            + oldFontMetrics.stringWidth((gain >= 0 ? GAIN : LOSS) + ": ")
            + titleFontMetrics.stringWidth(gain_str + " (" + percentage_str + "%)");

    int x = (int) (this.investmentFlowChartJDialog.getChartPanel().getWidth() - string_width) >> 1;
    final int y = margin + titleFontMetrics.getAscent();

    g2.setFont(oldFont);
    g2.drawString(INVEST + ": ", x, y);
    x += oldFontMetrics.stringWidth(INVEST + ": ");
    g2.setFont(titleFont);
    g2.drawString(invest + " ", x, y);
    x += titleFontMetrics.stringWidth(invest + " ");
    g2.setFont(oldFont);
    g2.drawString(RETURN + ": ", x, y);
    x += oldFontMetrics.stringWidth(RETURN + ": ");
    g2.setFont(titleFont);
    g2.drawString(roi + " ", x, y);
    x += titleFontMetrics.stringWidth(roi + " ");
    g2.setFont(oldFont);
    if (gain >= 0) {
        if (gain > 0) {
            if (org.yccheok.jstock.engine.Utils.isFallBelowAndRiseAboveColorReverse()) {
                g2.setColor(JStock.instance().getJStockOptions().getLowerNumericalValueForegroundColor());
            } else {
                g2.setColor(JStock.instance().getJStockOptions().getHigherNumericalValueForegroundColor());
            }
        }
        g2.drawString(GAIN + ": ", x, y);
        x += oldFontMetrics.stringWidth(GAIN + ": ");
    } else {
        if (org.yccheok.jstock.engine.Utils.isFallBelowAndRiseAboveColorReverse()) {
            g2.setColor(JStock.instance().getJStockOptions().getHigherNumericalValueForegroundColor());
        } else {
            g2.setColor(JStock.instance().getJStockOptions().getLowerNumericalValueForegroundColor());
        }
        g2.drawString(LOSS + ": ", x, y);
        x += oldFontMetrics.stringWidth(LOSS + ": ");
    }
    g2.setFont(titleFont);
    g2.drawString(gain_str + " (" + percentage_str + "%)", x, y);

    g2.setColor(oldColor);
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldValueAntiAlias);
    g2.setFont(oldFont);
}

From source file:com.hmsinc.epicenter.spatial.render.SpatialScanRenderer.java

/**
 * @param context/*from w ww  .  j  a v  a  2s . co  m*/
 * @return
 */
private BufferedImage renderImage(final MapContext context, int width, int height) {

    logger.trace("Image width: {}  height: {}", width, height);

    final BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);

    final Graphics2D graphics2D = (Graphics2D) image.getGraphics();

    final GTRenderer renderer = new StreamingRenderer();
    final RenderingHints h = new RenderingHints(RenderingHints.KEY_INTERPOLATION,
            RenderingHints.VALUE_INTERPOLATION_BICUBIC);
    h.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    h.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    h.put(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
    h.put(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE);
    renderer.setJava2DHints(h);
    renderer.setContext(context);
    renderer.paint(graphics2D, new Rectangle(width, height), context.getAreaOfInterest());

    return image;
}

From source file:uk.co.modularaudio.service.gui.impl.racktable.back.AbstractLinkImage.java

private void drawLinkWireIntoImage(final Point sourcePoint, final Point sinkPoint) {
    //      log.debug("Drawing link from " + sourcePoint + " to " + sinkPoint);

    final int fromX = sourcePoint.x;
    final int fromY = sourcePoint.y;
    final int toX = sinkPoint.x;
    final int toY = sinkPoint.y;

    float f1, f2, f3, f4, f5, f6, f7, f8 = 0.0f;
    f1 = fromX;/* w  w  w .  j  av  a 2  s .c o m*/
    f2 = fromY;
    f3 = fromX;
    f4 = fromY + WIRE_DIP_PIXELS;
    f5 = toX;
    f6 = toY + WIRE_DIP_PIXELS;
    f7 = toX;
    f8 = toY;
    final CubicCurve2D cubicCurve = new CubicCurve2D.Float(f1, f2, f3, f4, f5, f6, f7, f8);
    final Rectangle cubicCurveBounds = cubicCurve.getBounds();

    final int imageWidthToUse = cubicCurveBounds.width + LINK_IMAGE_PADDING_FOR_WIRE_RADIUS;
    //      int imageHeightToUse = cubicCurveBounds.height + WIRE_DIP_PIXELS;
    int imageHeightToUse = cubicCurveBounds.height;
    // If the wire is close to vertical (little Y difference) we make the image a little bigger to account for the wire "dip"
    if (Math.abs(sinkPoint.y - sourcePoint.y) <= WIRE_DIP_PIXELS) {
        imageHeightToUse += (WIRE_DIP_PIXELS / 2);
    }

    //      bufferedImage = new BufferedImage( imageWidthToUse, imageHeightToUse, BufferedImage.TYPE_INT_ARGB );
    try {
        tiledBufferedImage = bufferImageAllocationService.allocateBufferedImage(allocationSource,
                allocationMatchToUse, AllocationLifetime.SHORT, AllocationBufferType.TYPE_INT_ARGB,
                imageWidthToUse, imageHeightToUse);

        bufferedImage = tiledBufferedImage.getUnderlyingBufferedImage();
        final Graphics2D g2d = bufferedImage.createGraphics();

        g2d.setComposite(AlphaComposite.Clear);
        g2d.fillRect(0, 0, imageWidthToUse, imageHeightToUse);

        g2d.setComposite(AlphaComposite.SrcOver);

        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

        f1 += LINK_IMAGE_DIST_TO_CENTER - cubicCurveBounds.x;
        f2 += LINK_IMAGE_DIST_TO_CENTER - cubicCurveBounds.y;
        f3 += LINK_IMAGE_DIST_TO_CENTER - cubicCurveBounds.x;
        f4 += LINK_IMAGE_DIST_TO_CENTER - cubicCurveBounds.y;
        f5 += LINK_IMAGE_DIST_TO_CENTER - cubicCurveBounds.x;
        f6 += LINK_IMAGE_DIST_TO_CENTER - cubicCurveBounds.y;
        f7 += LINK_IMAGE_DIST_TO_CENTER - cubicCurveBounds.x;
        f8 += LINK_IMAGE_DIST_TO_CENTER - cubicCurveBounds.y;

        final CubicCurve2D offSetCubicCurve = new CubicCurve2D.Float(f1, f2, f3, f4, f5, f6, f7, f8);

        // Draw the highlight and shadow
        if (DRAW_HIGHTLIGHT_AND_SHADOW) {
            final Graphics2D sG2d = (Graphics2D) g2d.create();
            sG2d.translate(WIRE_SHADOW_X_OFFSET, WIRE_SHADOW_Y_OFFSET);
            sG2d.setColor(Color.BLUE.darker());
            sG2d.setStroke(new BasicStroke(WIRE_SHADOW_WIDTH, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
            sG2d.draw(offSetCubicCurve);

            final Graphics2D hG2d = (Graphics2D) g2d.create();
            hG2d.translate(WIRE_HIGHLIGHT_X_OFFSET, WIRE_HIGHLIGHT_Y_OFFSET);
            hG2d.setColor(Color.WHITE);
            hG2d.setStroke(
                    new BasicStroke(WIRE_HIGHLIGHT_WIDTH, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
            hG2d.draw(offSetCubicCurve);
        }

        g2d.setColor(Color.BLACK);
        g2d.setStroke(wireStroke);
        g2d.draw(offSetCubicCurve);

        g2d.setColor(Color.BLUE);
        g2d.setStroke(wireBodyStroke);
        g2d.draw(offSetCubicCurve);

        // For debugging, draw a green line around the outside of this image.
        if (DRAW_WIRE_BOUNDING_BOX) {
            g2d.setStroke(basicStrokeOfOne);
            g2d.setColor(Color.GREEN);
            g2d.drawRect(0, 0, imageWidthToUse - 1, imageHeightToUse - 1);
        }

        rectangle.x = cubicCurveBounds.x - LINK_IMAGE_DIST_TO_CENTER;
        rectangle.y = cubicCurveBounds.y - LINK_IMAGE_DIST_TO_CENTER;
        rectangle.width = imageWidthToUse;
        rectangle.height = imageHeightToUse;
    } catch (final Exception e) {
        final String msg = "Exception caught allocating buffered image: " + e.toString();
        log.error(msg, e);
    }
}

From source file:com.sdk.connector.chart.FrequencyDomainRenderer.java

/**
 * Creates a new demo application./* ww w .  j a  v  a  2s.co  m*/
 *
 * @param title  the frame title.
 */
public FrequencyDomainRenderer(String title, JPanel panel, String side, String type) {

    this.side = side;
    this.type = type;
    serie.setKey(side);

    dataset.addSeries(serie);
    JFreeChart chart = ChartFactory.createXYAreaChart(title,
            java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("frequency.xlabel"),
            java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("frequency.ylabel2"),
            dataset, PlotOrientation.VERTICAL, true, true, false);

    //        TextTitle t1 = new TextTitle( "Espectro de Frequncia Estimado (PSD)", new Font("SansSerif", Font.BOLD, 14)  );
    //        //TextTitle t2 = new TextTitle( "valores atualizados a cada potncia de 2", new Font("SansSerif", Font.PLAIN, 11)      );
    //        chart.addSubtitle(t1);
    chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    chart.getRenderingHints().put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    chart.getRenderingHints().put(RenderingHints.KEY_ALPHA_INTERPOLATION,
            RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
    chart.getRenderingHints().put(RenderingHints.KEY_FRACTIONALMETRICS,
            RenderingHints.VALUE_FRACTIONALMETRICS_ON);
    chart.getRenderingHints().put(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
    chart.getRenderingHints().put(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
    chart.getRenderingHints().put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    chart.getRenderingHints().put(RenderingHints.KEY_TEXT_LCD_CONTRAST, 100);
    //chart.addSubtitle(t2);
    plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.BLUE);
    plot.setRangeGridlinePaint(Color.CYAN);
    plot.getRenderer().setSeriesStroke(0, new BasicStroke(2.0f));
    plot.getRenderer().setSeriesStroke(1, new BasicStroke(2.0f));

    //plot.setRangePannable(true);
    plot.setForegroundAlpha(0.65f);

    //XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer = plot.getRenderer();
    renderer.setSeriesOutlinePaint(0, Color.BLACK);
    if (side.startsWith(
            java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("side.left"))) {
        renderer.setSeriesPaint(0, Color.BLUE);
    } else {
        renderer.setSeriesPaint(0, Color.RED);
    }
    //        renderer.setSeriesLinesVisible(0, true);
    //        renderer.setSeriesShapesVisible(0, false);
    //        renderer.setSeriesLinesVisible(1, true);
    //        renderer.setSeriesShapesVisible(1, false);
    plot.setRenderer(renderer);
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.BLACK);
    plot.setRangeGridlinePaint(Color.BLACK);
    plot.setForegroundAlpha(0.5f);

    Color color1 = new Color(0, 0, 0, 24);
    Color color2 = new Color(255, 255, 255, 24);

    GradientPaint gp = new GradientPaint(0, 0, color1, 0, 0, color2);
    plot.setBackgroundPaint(gp);

    final ValueAxis domainAxis = plot.getDomainAxis();
    domainAxis.setTickMarkPaint(Color.black);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    NumberAxis numDomainAxis = (NumberAxis) plot.getDomainAxis();
    numDomainAxis.setAutoRangeIncludesZero(true);
    //
    //        final NumberAxis rangeAxis = new LogarithmicAxis("Log(y)");
    //
    //        plot.setRangeAxis(rangeAxis);
    final ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setTickMarkPaint(Color.black);

    numRangeAxis = (NumberAxis) plot.getRangeAxis();
    numRangeAxis.setAutoRangeIncludesZero(true);

    vlfTarget.setLabel("VLF");
    vlfTarget.setLabelFont(new Font("SansSerif", Font.ITALIC, 9));
    vlfTarget.setLabelAnchor(RectangleAnchor.CENTER);
    vlfTarget.setLabelTextAnchor(TextAnchor.CENTER);
    vlfTarget.setPaint(new Color(0, 100, 255, 128));
    // plot.addRangeMarker(target, Layer.BACKGROUND);
    plot.addDomainMarker(vlfTarget, Layer.BACKGROUND);

    lfTarget.setLabel("LF");
    lfTarget.setLabelFont(new Font("SansSerif", Font.ITALIC, 9));
    lfTarget.setLabelAnchor(RectangleAnchor.CENTER);
    lfTarget.setLabelTextAnchor(TextAnchor.CENTER);
    lfTarget.setPaint(new Color(255, 255, 0, 128));
    // plot.addRangeMarker(target, Layer.BACKGROUND);
    plot.addDomainMarker(lfTarget, Layer.BACKGROUND);

    hfTarget.setLabel("HF");
    hfTarget.setLabelFont(new Font("SansSerif", Font.ITALIC, 9));
    hfTarget.setLabelAnchor(RectangleAnchor.CENTER);
    hfTarget.setLabelTextAnchor(TextAnchor.CENTER);
    hfTarget.setPaint(new Color(255, 0, 255, 128));
    // plot.addRangeMarker(target, Layer.BACKGROUND);
    plot.addDomainMarker(hfTarget, Layer.BACKGROUND);
    plot.setNoDataMessage(
            java.util.ResourceBundle.getBundle("com/sdk/connector/chart/Bundle").getString("message.wait"));

    chartPanel = new ChartPanel(chart);

    panel.setLayout(new GridLayout(0, 1));
    panel.add(chartPanel);
    panel.repaint();
    panel.revalidate();

}