Example usage for java.io OutputStream hashCode

List of usage examples for java.io OutputStream hashCode

Introduction

In this page you can find the example usage for java.io OutputStream hashCode.

Prototype

@HotSpotIntrinsicCandidate
public native int hashCode();

Source Link

Document

Returns a hash code value for the object.

Usage

From source file:net.sourceforge.processdash.ui.web.CGIChartBase.java

/** Generate CGI chart output. */
@Override//from  ww w.  ja  v a 2s  .c o  m
protected void writeContents() throws IOException {
    buildData(); // get the data for display

    chromeless = (parameters.get("chromeless") != null);
    JFreeChart chart = createChart();

    int width = getIntSetting("width");
    int height = getIntSetting("height");
    Color initGradColor = getColorSetting("initGradColor");
    Color finalGradColor = getColorSetting("finalGradColor");
    chart.setBackgroundPaint(new GradientPaint(0, 0, initGradColor, width, height, finalGradColor));
    if (parameters.get("hideOutline") != null)
        chart.getPlot().setOutlinePaint(INVISIBLE);

    String title = getSetting("title");
    if (chromeless || title == null || title.length() == 0)
        chart.setTitle((TextTitle) null);
    else {
        chart.setTitle(Translator.translate(title));
        String titleFontSize = getSetting("titleFontSize");
        if (titleFontSize != null)
            try {
                float fontSize = Float.parseFloat(titleFontSize);
                TextTitle t = chart.getTitle();
                t.setFont(t.getFont().deriveFont(fontSize));
            } catch (Exception tfe) {
            }
    }

    if (chromeless || parameters.get("hideLegend") != null)
        chart.removeLegend();
    else {
        LegendTitle l = chart.getLegend();
        String legendFontSize = getSetting("legendFontSize");
        if (l != null && legendFontSize != null)
            try {
                float fontSize = Float.parseFloat(legendFontSize);
                l.setItemFont(l.getItemFont().deriveFont(fontSize));
            } catch (Exception lfe) {
            }
    }

    chart.getPlot().setNoDataMessage(resources.getString("No_Data_Message"));

    Axis xAxis = getHorizontalAxis(chart);
    if (xAxis != null) {
        if (parameters.get("hideTickLabels") != null || parameters.get("hideXTickLabels") != null) {
            xAxis.setTickLabelsVisible(false);
        } else if (parameters.get("tickLabelFontSize") != null
                || parameters.get("xTickLabelFontSize") != null) {
            String tfs = getParameter("xTickLabelFontSize");
            if (tfs == null)
                tfs = getParameter("tickLabelFontSize");
            float fontSize = Float.parseFloat(tfs);
            xAxis.setTickLabelFont(xAxis.getTickLabelFont().deriveFont(fontSize));
        }
    }

    Axis yAxis = getVerticalAxis(chart);
    if (yAxis != null) {
        if (parameters.get("hideTickLabels") != null || parameters.get("hideYTickLabels") != null) {
            yAxis.setTickLabelsVisible(false);
        } else if (parameters.get("tickLabelFontSize") != null
                || parameters.get("yTickLabelFontSize") != null) {
            String tfs = getParameter("yTickLabelFontSize");
            if (tfs == null)
                tfs = getParameter("tickLabelFontSize");
            float fontSize = Float.parseFloat(tfs);
            yAxis.setTickLabelFont(yAxis.getTickLabelFont().deriveFont(fontSize));
        }
    }

    String axisFontSize = getSetting("axisLabelFontSize");
    if (axisFontSize != null)
        try {
            float fontSize = Float.parseFloat(axisFontSize);
            if (xAxis != null)
                xAxis.setLabelFont(xAxis.getLabelFont().deriveFont(fontSize));
            if (yAxis != null)
                yAxis.setLabelFont(yAxis.getLabelFont().deriveFont(fontSize));
        } catch (Exception afs) {
        }

    ChartRenderingInfo info = (isHtmlMode() ? new ChartRenderingInfo() : null);
    BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = img.createGraphics();
    if ("auto".equals(getSetting("titleFontSize")))
        maybeAdjustTitleFontSize(chart, g2, width);
    chart.draw(g2, new Rectangle2D.Double(0, 0, width, height), info);
    g2.dispose();

    String outputFormat = getSetting("outputFormat");
    OutputStream imgOut;
    if (isHtmlMode()) {
        imgOut = PngCache.getOutputStream();
    } else {
        imgOut = outStream;
    }
    ImageIO.write(img, outputFormat, imgOut);
    imgOut.flush();
    imgOut.close();
    if (isHtmlMode())
        writeImageHtml(width, height, imgOut.hashCode(), info);
}