Example usage for java.awt RenderingHints VALUE_TEXT_ANTIALIAS_GASP

List of usage examples for java.awt RenderingHints VALUE_TEXT_ANTIALIAS_GASP

Introduction

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

Prototype

Object VALUE_TEXT_ANTIALIAS_GASP

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

Click Source Link

Document

Text antialiasing hint value -- text rendering is requested to use information in the font resource which specifies for each point size whether to apply #VALUE_TEXT_ANTIALIAS_ON or #VALUE_TEXT_ANTIALIAS_OFF .

Usage

From source file:TextQualityDemoVALUE_TEXT_ANTIALIAS_GASP.java

public static void main(String[] args) {
    JFrame frame = new JFrame("LCD Text Demo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setPreferredSize(new Dimension(630, 460));
    frame.setContentPane(new MyPanel(RenderingHints.VALUE_TEXT_ANTIALIAS_GASP));
    frame.pack();/*from   ww  w  .j  av  a2s.c o m*/
    frame.setVisible(true);
}

From source file:net.sf.maltcms.common.charts.api.XYChartBuilder.java

/**
 *
 *///  w  w w .j a  va 2 s .co  m
public XYChartBuilder() {
    plot = new XYPlot(dataset, domainAxis, rangeAxis, renderer);
    chart = new JFreeChart(plot);
    renderingHints = new RenderingHints(null);
    renderingHints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
    renderingHints.put(RenderingHints.KEY_TEXT_LCD_CONTRAST, 100);
    renderingHints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    renderingHints.put(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
    renderingHints.put(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE);
    renderingHints.put(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
    renderingHints.put(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
    renderingHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    renderingHints.put(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
    renderingHints.put(RenderingHints.KEY_ALPHA_INTERPOLATION,
            RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
}

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:weka.core.ChartUtils.java

/**
 * Render a combined histogram and pie chart from summary data
 * //from w  ww  . j a  v a  2  s . co  m
 * @param width the width of the resulting image
 * @param height the height of the resulting image
 * @param values the values for the chart
 * @param freqs the corresponding frequencies
 * @param additionalArgs optional arguments to the renderer (may be null)
 * @return a buffered image
 * @throws Exception if a problem occurs
 */
public static BufferedImage renderCombinedPieAndHistogramFromSummaryData(int width, int height,
        List<String> values, List<Double> freqs, List<String> additionalArgs) throws Exception {

    String plotTitle = "Combined Chart";
    String userTitle = getOption(additionalArgs, "-title");
    plotTitle = (userTitle != null) ? userTitle : plotTitle;

    List<String> opts = new ArrayList<String>();
    opts.add("-title=distribution");
    BufferedImage pie = renderPieChartFromSummaryData(width / 2, height, values, freqs, false, true, opts);

    opts.clear();
    opts.add("-title=histogram");
    BufferedImage hist = renderHistogramFromSummaryData(width / 2, height, values, freqs, opts);

    BufferedImage img = new BufferedImage(width, height + 20, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2d = img.createGraphics();
    g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
    g2d.setFont(new Font("SansSerif", Font.BOLD, 12));
    g2d.setColor(Color.lightGray);
    g2d.fillRect(0, 0, width, height + 20);
    g2d.setColor(Color.black);
    FontMetrics fm = g2d.getFontMetrics();
    int fh = fm.getHeight();
    int sw = fm.stringWidth(plotTitle);

    g2d.drawImage(pie, 0, 20, null);
    g2d.drawImage(hist, width / 2 + 1, 20, null);
    g2d.drawString(plotTitle, width / 2 - sw / 2, fh + 2);
    g2d.dispose();

    return img;
}

From source file:weka.core.ChartUtils.java

/**
 * Render a combined histogram and box plot chart from summary data
 * /*  w ww  . j  a v  a  2s . c o  m*/
 * @param width the width of the resulting image
 * @param height the height of the resulting image
 * @param bins the values for the chart
 * @param freqs the corresponding frequencies
 * @param summary the summary stats for the box plot
 * @param outliers an optional list of outliers for the box plot
 * @param additionalArgs optional arguments to the renderer (may be null)
 * @return a buffered image
 * @throws Exception if a problem occurs
 */
public static BufferedImage renderCombinedBoxPlotAndHistogramFromSummaryData(int width, int height,
        List<String> bins, List<Double> freqs, List<Double> summary, List<Double> outliers,
        List<String> additionalArgs) throws Exception {

    String plotTitle = "Combined Chart";
    String userTitle = getOption(additionalArgs, "-title");
    plotTitle = (userTitle != null) ? userTitle : plotTitle;

    List<String> opts = new ArrayList<String>();
    opts.add("-title=histogram");
    BufferedImage hist = renderHistogramFromSummaryData(width / 2, height, bins, freqs, opts);
    opts.clear();
    opts.add("-title=box plot");
    BufferedImage box = null;
    try {
        box = renderBoxPlotFromSummaryData(width / 2, height, summary, outliers, opts);
    } catch (Exception ex) {
        // if we can't generate the box plot (i.e. probably because
        // data is 100% missing) then just return the histogram
    }

    if (box == null) {
        width /= 2;
    }
    BufferedImage img = new BufferedImage(width, height + 20, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2d = img.createGraphics();
    g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
    g2d.setFont(new Font("SansSerif", Font.BOLD, 12));
    g2d.setColor(Color.lightGray);
    g2d.fillRect(0, 0, width, height + 20);
    g2d.setColor(Color.black);
    FontMetrics fm = g2d.getFontMetrics();
    int fh = fm.getHeight();
    int sw = fm.stringWidth(plotTitle);

    if (box != null) {
        g2d.drawImage(box, 0, 20, null);
        g2d.drawImage(hist, width / 2 + 1, 20, null);
    } else {
        g2d.drawImage(hist, 0, 20, null);
    }
    g2d.drawString(plotTitle, width / 2 - sw / 2, fh + 2);
    g2d.dispose();

    return img;
}

From source file:org.signserver.admin.gui.SignServerAdminGUIApplication.java

/**
 * Main method launching the application.
 *//*from   w  w  w  .jav a  2s  .com*/
public static void main(String[] args) {
    LOG.debug("SignServer Administration GUI startup");

    final SplashScreen splash = SplashScreen.getSplashScreen();
    if (splash == null) {
        LOG.debug("No splash screen available.");
    } else {
        // Fill in version and copyright information
        final Graphics2D image = splash.createGraphics();
        image.setPaint(Color.BLACK);
        image.setFont(new Font("Arial", Font.BOLD, 14));
        image.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
        final ResourceMap resourceMap = getApplication().getContext()
                .getResourceMap(SignServerAdminGUIApplicationAboutBox.class);
        final String version = "Version " + resourceMap.getString("appVendorLabel1.text");
        ;
        image.drawString(version, 512 - image.getFontMetrics().stringWidth(version), 215);
        image.setPaint(Color.DARK_GRAY);
        image.drawString(resourceMap.getString("appCopyright.text"), 12, 392);
        splash.update();
    }

    try {
        // Parse the command line
        final CommandLine line = new GnuParser().parse(OPTIONS, args);
        if (line.hasOption(OPTION_HELP)) {
            printUsage();
        } else {
            if (line.hasOption(OPTION_WS)) {
                protocol = Protocol.WS;
            } else {
                if (isNamingContextAvailable()) {
                    protocol = Protocol.EJB;
                } else {
                    JOptionPane.showMessageDialog(null,
                            "Application server libraries not detected."
                                    + "\n\nTo connect to a locally running SignServer instance "
                                    + "\nplease append the appropriate application server "
                                    + "\nJAR-files and if needed a jndi.properties file."
                                    + "\n\nTo connect using web services invoke this command "
                                    + "\nwith the argument \"-ws\".");
                    protocol = Protocol.WS;
                }
            }
            if (line.hasOption(OPTION_CONNECTFILE)) {
                connectFile = new File(line.getOptionValue(OPTION_CONNECTFILE));
            }
            if (line.hasOption(OPTION_DEFAULTCONNECTFILE)) {
                defaultConnectFile = new File(line.getOptionValue(OPTION_DEFAULTCONNECTFILE));
            }
            if (line.hasOption(OPTION_BASEDIR)) {
                baseDir = new File(line.getOptionValue(OPTION_BASEDIR));
            }

            try {
                launch(SignServerAdminGUIApplication.class, args);
            } catch (Exception ex) {
                displayException(ex);
            }
        }
    } catch (ParseException ex) {
        throw new IllegalArgumentException(ex.getLocalizedMessage(), ex);
    }
}