Example usage for java.awt GradientPaint GradientPaint

List of usage examples for java.awt GradientPaint GradientPaint

Introduction

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

Prototype

public GradientPaint(Point2D pt1, Color color1, Point2D pt2, Color color2) 

Source Link

Document

Constructs a simple acyclic GradientPaint object.

Usage

From source file:edu.ku.brc.ui.GradiantButton.java

/**
 * Draws the button body// ww w  . j  ava  2 s . c  o m
 * @param g2 the graphics to be painted into
 * @param w the width of the control
 * @param h the height of the control
 * @param color the of the background
 */
protected void drawButtonBody(Graphics2D g2, int w, int h, Color color) {
    // draw the button body
    Color grad_top = color.brighter();
    Color grad_bot = color.darker();
    GradientPaint bg = new GradientPaint(new Point(0, 0), grad_top, new Point(0, h), grad_bot);
    g2.setPaint(bg);
    g2.fillRect(0, 0, w, h);
}

From source file:com.romraider.logger.ecu.ui.handler.dash.DialGaugeStyle.java

protected JFreeChart buildChart() {
    DialPlot plot = new DialPlot();
    plot.setView(0.0, 0.0, 1.0, 1.0);//from  w  ww.j  a  v a  2 s . c om
    plot.setDataset(0, current);
    plot.setDataset(1, max);
    plot.setDataset(2, min);
    DialFrame dialFrame = new StandardDialFrame();
    plot.setDialFrame(dialFrame);

    GradientPaint gp = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(),
            new Color(170, 170, 220));
    DialBackground db = new DialBackground(gp);
    db.setGradientPaintTransformer(new StandardGradientPaintTransformer(VERTICAL));
    plot.setBackground(db);

    unitsLabel.setFont(new Font(Font.DIALOG, BOLD, 15));
    unitsLabel.setRadius(0.7);
    unitsLabel.setLabel(loggerData.getSelectedConvertor().getUnits());
    plot.addLayer(unitsLabel);

    DecimalFormat format = new DecimalFormat(loggerData.getSelectedConvertor().getFormat());

    DialValueIndicator dvi = new DialValueIndicator(0);
    dvi.setNumberFormat(format);
    plot.addLayer(dvi);

    EcuDataConvertor convertor = loggerData.getSelectedConvertor();
    GaugeMinMax minMax = convertor.getGaugeMinMax();
    StandardDialScale scale = new StandardDialScale(minMax.min, minMax.max, 225.0, -270.0, minMax.step, 5);
    scale.setTickRadius(0.88);
    scale.setTickLabelOffset(0.15);
    scale.setTickLabelFont(new Font(Font.DIALOG, PLAIN, 12));
    scale.setTickLabelFormatter(format);
    plot.addScale(0, scale);
    plot.addScale(1, scale);
    plot.addScale(2, scale);

    StandardDialRange range = new StandardDialRange(rangeLimit(minMax, 0.75), minMax.max, RED);
    range.setInnerRadius(0.52);
    range.setOuterRadius(0.55);
    plot.addLayer(range);

    StandardDialRange range2 = new StandardDialRange(rangeLimit(minMax, 0.5), rangeLimit(minMax, 0.75), ORANGE);
    range2.setInnerRadius(0.52);
    range2.setOuterRadius(0.55);
    plot.addLayer(range2);

    StandardDialRange range3 = new StandardDialRange(minMax.min, rangeLimit(minMax, 0.5), GREEN);
    range3.setInnerRadius(0.52);
    range3.setOuterRadius(0.55);
    plot.addLayer(range3);

    DialPointer needleCurrent = new DialPointer.Pointer(0);
    plot.addLayer(needleCurrent);

    DialPointer needleMax = new DialPointer.Pin(1);
    needleMax.setRadius(0.84);
    ((DialPointer.Pin) needleMax).setPaint(RED);
    ((DialPointer.Pin) needleMax).setStroke(new BasicStroke(1.5F));
    plot.addLayer(needleMax);

    DialPointer needleMin = new DialPointer.Pin(2);
    needleMin.setRadius(0.84);
    ((DialPointer.Pin) needleMin).setPaint(BLUE);
    ((DialPointer.Pin) needleMin).setStroke(new BasicStroke(1.5F));
    plot.addLayer(needleMin);

    DialCap cap = new DialCap();
    cap.setRadius(0.10);
    plot.setCap(cap);

    JFreeChart chart = new JFreeChart(plot);
    chart.setTitle(loggerData.getName());

    return chart;
}

From source file:org.jfree.eastwood.GXYPlot.java

/**
 * Draws the background for the plot.//from  ww w  .j a  va2 s .  co m
 *
 * @param g2  the graphics device.
 * @param area  the area.
 */
public void drawBackground(Graphics2D g2, Rectangle2D area) {
    Paint p = getBackgroundPaint();
    if (p instanceof GradientPaint) {
        // do the transformation directly
        GradientPaint gp = (GradientPaint) p;
        double r = (this.f1 - this.f0) * area.getWidth();
        Point2D p0 = new Point2D.Double(area.getMinX() + this.f0 * area.getWidth(), area.getMaxY());
        Point2D p1 = new Point2D.Double(p0.getX() + r * Math.cos(this.angle),
                p0.getY() - r * Math.sin(this.angle));
        p = new GradientPaint(p0, gp.getColor1(), p1, gp.getColor2());
    }
    g2.setPaint(p);
    g2.fill(area);
}

From source file:org.pentaho.chart.plugin.jfreechart.chart.dial.JFreeDialChartGenerator.java

protected void setDialBackground(ChartDocument chartDocument, DialPlot dialPlot) {
    ChartElement plotElement = getUniqueElement(chartDocument, ChartElement.TAG_NAME_PLOT);

    CSSValuePair cssValue = (CSSValuePair) plotElement.getLayoutStyle().getValue(ChartStyleKeys.GRADIENT_COLOR);
    Color beginColor = JFreeChartUtils.getColorFromCSSValue(cssValue.getFirstValue());
    Color endColor = JFreeChartUtils.getColorFromCSSValue(cssValue.getSecondValue());

    GradientPaint gradientpaint = new GradientPaint(new Point(), beginColor, new Point(), endColor);
    DialBackground dialbackground = new DialBackground(gradientpaint); // specify Color here for no gradient
    dialbackground.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL));
    dialPlot.setBackground(dialbackground);
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.dialcharts.SimpleDial.java

/**
 * Creates the chart ./*from w  w w .j  av a 2 s  . c  o m*/
 * 
 * @param chartTitle  the chart title.
 * @param dataset  the dataset.
 * 
 * @return A chart .
 */

public JFreeChart createChart(DatasetMap datasets) {
    // get data for diagrams
    logger.debug("IN");
    Dataset dataset = (Dataset) datasets.getDatasets().get("1");

    DialPlot plot = new DialPlot();
    plot.setDataset((ValueDataset) dataset);

    ArcDialFrame dialFrame = null;
    if (!horizontalView) {
        plot.setView(0.78, 0.37, 0.22, 0.26);
        dialFrame = new ArcDialFrame(-10.0, 20.0);
    } else {
        plot.setView(0.21, 0.0, 0.58, 0.30);
        dialFrame = new ArcDialFrame(60.0, 60.0);
    }

    dialFrame.setInnerRadius(0.65);
    dialFrame.setOuterRadius(0.90);
    dialFrame.setForegroundPaint(Color.darkGray);
    dialFrame.setStroke(new BasicStroke(3.0f));
    plot.setDialFrame(dialFrame);

    GradientPaint gp = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(),
            new Color(240, 240, 240));
    DialBackground sdb = new DialBackground(gp);

    GradientPaintTransformType gradientPaintTransformType = GradientPaintTransformType.VERTICAL;
    if (horizontalView) {
        gradientPaintTransformType = GradientPaintTransformType.HORIZONTAL;
    }

    sdb.setGradientPaintTransformer(new StandardGradientPaintTransformer(gradientPaintTransformType));
    plot.addLayer(sdb);

    if (!(increment > 0)) {
        logger.warn("increment cannot be less than 0, put default to 0.1 ");
        increment = 0.1;
    }

    StandardDialScale scale = null;
    if (!horizontalView) {
        scale = new StandardDialScale(lower, upper, -8, 16.0, increment, minorTickCount);
    } else {
        scale = new StandardDialScale(lower, upper, 115.0, -50.0, increment, minorTickCount);
    }

    // sets intervals
    for (Iterator iterator = intervals.iterator(); iterator.hasNext();) {
        KpiInterval interval = (KpiInterval) iterator.next();
        StandardDialRange range = new StandardDialRange(interval.getMin(), interval.getMax(),
                interval.getColor());
        range.setInnerRadius(0.70);
        range.setOuterRadius(0.75);
        plot.addLayer(range);

    }

    scale.setTickRadius(0.88);
    scale.setTickLabelOffset(0.07);
    //set tick label style
    Font tickLabelsFont = new Font(labelsTickStyle.getFontName(), Font.PLAIN, labelsTickStyle.getSize());
    scale.setTickLabelFont(tickLabelsFont);
    scale.setTickLabelPaint(labelsTickStyle.getColor());
    //scale.setMajorTickIncrement(25.0);
    plot.addScale(0, scale);

    DialPointer needle = new DialPointer.Pin();
    needle.setRadius(0.82);
    plot.addLayer(needle);
    DialValueIndicator dvi = new DialValueIndicator(0);
    dvi.setFont(new Font(labelsValueStyle.getFontName(), Font.PLAIN, labelsValueStyle.getSize()));
    dvi.setPaint(labelsValueStyle.getColor());
    plot.addLayer(dvi);

    JFreeChart chart1 = new JFreeChart(plot);
    chart1.setBackgroundPaint(color);

    TextTitle title = setStyleTitle(name, styleTitle);
    chart1.setTitle(title);
    if (subName != null && !subName.equals("")) {
        TextTitle subTitle = setStyleTitle(subName, styleSubTitle);
        chart1.addSubtitle(subTitle);
    }

    logger.debug("OUT");
    return chart1;
}

From source file:controller.VisLP.java

/**
 * Draw the linear constraints of an {@code LP} and color
 * it's feasible region in a given {@code CCSystem}.
 * //w  w  w .  j  av  a2  s .  c  o m
 * @param cs
 *        a {@code CCSystem}.
 * @param lp
 *        a {@code LP}.
 */
static void drawLP(CCSystem cs, LP lp) {
    cs.clear();

    /* Don't draw the LP if it is not in two variables */
    if (lp == null || lp.getNoBasic() != 2) {
        cs.setVisibleAxes(false);
        return;
    }
    cs.setVisibleAxes(true);

    CCSLine line;
    FieldMatrix<BigFraction> cons = lp.getConstraints();
    cons = checkForBounds(cons);

    /* Draw all constraints as lines, except hidden bounded constraint */
    for (int i = 0; i < cons.getRowDimension() - 1; i++) {
        line = new CCSLine(cons.getEntry(i, 0).doubleValue(), cons.getEntry(i, 1).doubleValue(),
                cons.getEntry(i, 2).doubleValue(), Color.gray);
        cs.addLine(line);
    }

    Point2D[] fpoints = getFeasibleIntersections(cons);

    /* 
     * Move the center of the coordinate system
     * to the center of the feasible region.
     */
    if (readScope) {
        scopeArea(cs, fpoints, true);
        readScope = false;
    }
    if (feasScope && lp.feasible(false)) {
        scopeArea(cs, fpoints, false);
        feasScope = false;
    }

    /* If there is no feasible region there is no need to try to color it */
    if (fpoints.length == 0)
        return;

    /* Draw all feasible solutions as points */
    Point2D[] pconv = convex(fpoints);
    for (Point2D p2d : pconv) {
        CCSPoint ccsp = new CCSPoint(p2d.getX(), p2d.getY());
        if (!unb.contains(p2d))
            cs.addPoint(ccsp);
    }

    /* Color the region depending on whether it is unbounded or not. */
    if (unb.size() == 0) {
        cs.addPolygon(new CCSPolygon(pconv, Color.pink, true));
    } else if (unb.size() == 1) {
        GradientPaint gp = new GradientPaint(pconv[0], Color.pink, unb.get(0), cs.getBackground());
        cs.addPolygon(new CCSPolygon(pconv, gp, true));
    } else {
        Point2D p1 = unb.get(0);
        Point2D p2 = unb.get(1);
        double xavg = (p1.getX() + p2.getX()) / 2.0;
        double yavg = (p1.getY() + p2.getY()) / 2.0;
        /* 
         * Move the end point of the gradient further away from the
         * polygon edge to make the end of the gradient look less sudden.
         */
        xavg *= 0.9;
        yavg *= 0.9;

        Point2D pavg = new Point2D.Double(xavg, yavg);

        /* Fade into the background color */
        GradientPaint gp = new GradientPaint(pconv[0], Color.pink, pavg, cs.getBackground());

        cs.addPolygon(new CCSPolygon(pconv, gp, true));
    }

    /* Draw the current objective function */
    FieldVector<BigFraction> obj = lp.getObjFunction();
    line = new CCSLine(obj.getEntry(0).doubleValue(), obj.getEntry(1).doubleValue(), lp.objVal().doubleValue(),
            Color.red);
    cs.addLine(line);

    /* Draw the current basic solution as a point. */
    BigFraction[] point = lp.point();
    cs.addPoint(new CCSPoint(point[0].doubleValue(), point[1].doubleValue(), Color.red, true));
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.dialcharts.SBISpeedometer.java

/**
 * Creates a chart of type speedometer./*from   w w  w  .  j a v  a 2  s  . c  om*/
 * 
 * @param chartTitle  the chart title.
 * @param dataset  the dataset.
 * 
 * @return A chart speedometer.
 */

public JFreeChart createChart(DatasetMap datasets) {
    logger.debug("IN");
    Dataset dataset = (Dataset) datasets.getDatasets().get("1");

    DialPlot plot = new DialPlot();
    plot.setDataset((ValueDataset) dataset);
    plot.setDialFrame(new StandardDialFrame());

    plot.setBackground(new DialBackground());
    if (dialtextuse) {
        DialTextAnnotation annotation1 = new DialTextAnnotation(dialtext);
        annotation1.setFont(styleTitle.getFont());
        annotation1.setRadius(0.7);

        plot.addLayer(annotation1);
    }

    DialValueIndicator dvi = new DialValueIndicator(0);
    dvi.setFont(new Font(labelsValueStyle.getFontName(), Font.PLAIN, labelsValueStyle.getSize()));
    dvi.setPaint(labelsValueStyle.getColor());
    plot.addLayer(dvi);

    StandardDialScale scale = new StandardDialScale(lower, upper, -120, -300, 10.0, 4);

    if (!(increment > 0)) {
        logger.warn("increment cannot be less than 0, put default to 0.1");
        increment = 0.01;
    }

    scale.setMajorTickIncrement(increment);

    //      if (!( minorTickCount > 0)){
    //         logger.warn("minor tick count cannot be less than 0, put default to 1");
    //         minorTickCount = 1;
    //      }

    scale.setMinorTickCount(minorTickCount);
    scale.setTickRadius(0.88);
    scale.setTickLabelOffset(0.15);
    //set tick label style
    Font tickLabelsFont = new Font(labelsTickStyle.getFontName(), Font.PLAIN, labelsTickStyle.getSize());
    scale.setTickLabelFont(tickLabelsFont);
    scale.setTickLabelPaint(labelsTickStyle.getColor());
    plot.addScale(0, scale);

    plot.addPointer(new DialPointer.Pin());

    DialCap cap = new DialCap();
    plot.setCap(cap);

    // sets intervals
    for (Iterator iterator = intervals.iterator(); iterator.hasNext();) {
        KpiInterval interval = (KpiInterval) iterator.next();
        StandardDialRange range = new StandardDialRange(interval.getMin(), interval.getMax(),
                interval.getColor());
        range.setInnerRadius(0.52);
        range.setOuterRadius(0.55);
        plot.addLayer(range);

    }

    GradientPaint gp = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(),
            new Color(170, 170, 220));
    DialBackground db = new DialBackground(gp);
    db.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL));
    plot.setBackground(db);

    plot.removePointer(0);
    DialPointer.Pointer p = new DialPointer.Pointer();
    p.setFillPaint(Color.yellow);
    plot.addPointer(p);

    logger.debug("OUT");
    JFreeChart chart = new JFreeChart(name, plot);

    TextTitle title = setStyleTitle(name, styleTitle);
    chart.setTitle(title);
    if (subName != null && !subName.equals("")) {
        TextTitle subTitle = setStyleTitle(subName, styleSubTitle);
        chart.addSubtitle(subTitle);
    }

    chart.setBackgroundPaint(color);
    return chart;
}

From source file:org.pentaho.chart.plugin.jfreechart.JFreeChartFactoryEngine.java

protected JFreeChart makeDialChart(ChartModel chartModel, BasicDataModel data) {
    DialPlot chartBeansDialPlot = (DialPlot) chartModel.getPlot();

    org.jfree.chart.plot.dial.DialPlot jFreeDialPlot = new SquareDialPlot();

    final DefaultValueDataset dataset = new DefaultValueDataset();
    dataset.setValue(scaleNumber(data.getData().get(0), data.getScalingFactor()));

    jFreeDialPlot.setDataset(dataset);/*  w w w  .  j  a  va 2  s .  com*/

    final DoubleLineDialFrame dialFrame = new DoubleLineDialFrame();
    dialFrame.setForegroundPaint(new Color(0x8d8d8d));
    dialFrame.setInnerForegroundPaint(new Color(0x5d5d5d));
    dialFrame.setStroke(new BasicStroke(2));
    dialFrame.setBackgroundPaint(Color.WHITE);
    jFreeDialPlot.setDialFrame(dialFrame);

    for (DialRange dialRange : chartBeansDialPlot.getScale()) {
        if (dialRange.getColor() != null) {
            SingleLineDialRange standarddialrange = new SingleLineDialRange(
                    dialRange.getMinValue().doubleValue(), dialRange.getMaxValue().doubleValue(),
                    new Color(0x00FFFFFF & dialRange.getColor()));
            standarddialrange.setInnerRadius(0.4D);
            jFreeDialPlot.addLayer(standarddialrange);
        }
    }

    double scaleMajorTickIncrement = (chartBeansDialPlot.getScale().getMaxValue().doubleValue()
            - chartBeansDialPlot.getScale().getMinValue().doubleValue()) / 5;
    FixedStandardDialScale standardDialScale = new FixedStandardDialScale(
            chartBeansDialPlot.getScale().getMinValue().doubleValue(),
            chartBeansDialPlot.getScale().getMaxValue().doubleValue(), -150.0, -240.0, scaleMajorTickIncrement,
            2);
    standardDialScale.setTickRadius(0.88D);
    standardDialScale.setTickLabelOffset(0.15D);
    standardDialScale
            .setTickLabelFont(ChartUtils.getFont("sans-serif", FontStyle.NORMAL, FontWeight.NORMAL, 10));
    standardDialScale.setTickLabelPaint(Color.BLACK);
    standardDialScale.setMajorTickLength(0.04);
    standardDialScale.setMajorTickPaint(Color.BLACK);
    standardDialScale.setMajorTickStroke(new BasicStroke(2));
    standardDialScale.setMinorTickLength(0.02);
    standardDialScale.setMinorTickPaint(new Color(0x8b8b8b));
    standardDialScale.setMinorTickStroke(new BasicStroke(1));
    jFreeDialPlot.addScale(0, standardDialScale);

    DialCap dialCap = new DialCap();
    dialCap.setRadius(0.06);
    dialCap.setFillPaint(new Color(0x636363));
    dialCap.setOutlinePaint(new Color(0x5d5d5d));
    dialCap.setOutlineStroke(new BasicStroke(2));
    jFreeDialPlot.setCap(dialCap);

    GradientPaint gradientpaint = new GradientPaint(new Point(), new Color(0xfcfcfc), new Point(),
            new Color(0xd7d8da));
    DialBackground dialbackground = new DialBackground(gradientpaint); // specify Color here for no gradient
    dialbackground.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL));
    jFreeDialPlot.setBackground(dialbackground);

    VariableStrokePointer pointer = new VariableStrokePointer();
    pointer.setRadius(0.9);
    pointer.setOutlineStroke(new BasicStroke(2));
    pointer.setWidthRadius(0.05);
    pointer.setFillPaint(new Color(0x636363));
    pointer.setOutlinePaint(new Color(0x5d5d5d));
    jFreeDialPlot.addPointer(pointer);

    DialValueIndicator dialValueIndicator = new DialValueIndicator(0);
    dialValueIndicator.setTemplateValue(chartBeansDialPlot.getScale().getMaxValue());
    dialValueIndicator.setFont(ChartUtils.getFont("Dialog", FontStyle.NORMAL, FontWeight.BOLD, 10));
    dialValueIndicator.setPaint(Color.BLACK);
    dialValueIndicator.setBackgroundPaint(Color.WHITE);
    dialValueIndicator.setOutlineStroke(new BasicStroke(1));
    dialValueIndicator.setOutlinePaint(new Color(0x8b8b8b));
    jFreeDialPlot.addLayer(dialValueIndicator);

    if ((chartBeansDialPlot.getAnnotation() != null) && (chartBeansDialPlot.getAnnotation().getText() != null)
            && (chartBeansDialPlot.getAnnotation().getText().trim().length() > 0)) {
        Font font = ChartUtils.getFont(chartBeansDialPlot.getAnnotation().getFontFamily(),
                chartBeansDialPlot.getAnnotation().getFontStyle(),
                chartBeansDialPlot.getAnnotation().getFontWeight(),
                chartBeansDialPlot.getAnnotation().getFontSize());
        if (font == null) {
            font = ChartUtils.getFont("sans-serif", FontStyle.NORMAL, FontWeight.NORMAL, 10);
        }
        DialTextAnnotation dialTextAnnotation = new DialTextAnnotation(
                chartBeansDialPlot.getAnnotation().getText().trim());
        dialTextAnnotation.setFont(font);
        dialTextAnnotation.setRadius(0.6);
        jFreeDialPlot.addLayer(dialTextAnnotation);
    }

    String title = "";
    if ((chartModel.getTitle() != null) && (chartModel.getTitle().getText() != null)
            && (chartModel.getTitle().getText().trim().length() > 0)) {
        title = chartModel.getTitle().getText();
    }

    JFreeChart chart = new JFreeChart(title, jFreeDialPlot);
    initChart(chart, chartModel);

    return chart;
}

From source file:ecg.ecgshow.ECGShowUI.java

private void createGuardData() {
    GuardDataPanel = new JPanel();
    GuardDataPanel.setBackground(new Color(0, 150, 255));
    //        GuardDataPanel.setBounds();
    //        BoxLayout layout=new BoxLayout(GuardDataPanel,BoxLayout.Y_AXIS);
    //        GuardDataPanel.setLayout(layout);
    GroupLayout layout = new GroupLayout(GuardDataPanel);
    GuardDataPanel.setLayout(layout);/*from  w w w .ja  va  2s .co  m*/
    JPanel temperatureData = new JPanel();
    temperatureData.setLayout(new FlowLayout());
    //        temperatureData.setLayout(null);
    //        temperatureData.setBounds(0,0,(int) (WIDTH * 0.14), (int) (HEIGHT * 0.15));
    temperatureData.setSize((int) (WIDTH * 0.16), (int) (HEIGHT * 0.11));
    temperatureData.setBackground(new Color(0, 150, 255));
    temperatureLabel = new JLabel("--.- ");
    temperatureLabel.setFont(loadFont("LED.tff", (float) (HEIGHT * 0.070)));
    temperatureLabel.setBackground(new Color(0, 150, 255));
    temperatureLabel.setForeground(Color.RED);
    //        temperatureLabel.setBounds(0,0,200,100);
    temperatureLabel.setOpaque(true);
    JLabel temperatureLabelName = new JLabel(" ");
    temperatureLabelName.setFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.020)));
    temperatureLabelName.setBackground(new Color(0, 150, 255));
    temperatureLabelName.setForeground(Color.BLACK);
    temperatureLabelName.setBounds(0, 0, 100, 100);
    temperatureLabelName.setOpaque(true); //??
    temperatureData.add(temperatureLabelName);
    temperatureData.add(temperatureLabel);
    //        JPanel emptyPanel=new JPanel();
    //        emptyPanel.setSize((int)(WIDTH*0.14),(int)(HEIGHT*0.2));
    //        emptyPanel.setBackground(new Color(0,150,255));
    //        GuardDataPanel.add(emptyPanel);

    JPanel lightValueData = new JPanel();
    lightValueData.setLayout(new BorderLayout());
    lightValueData.setBackground(new Color(0, 150, 255));
    //        lightValueData.setBounds(0,(int)(HEIGHT*0.28),(int)(WIDTH*0.14),(int)(HEIGHT*0.30));
    lightValueData.setSize((int) (WIDTH * 0.14), (int) (HEIGHT * 0.22));
    lightValueDataSet = new DefaultValueDataset();
    DialPlot lightValueDialPlot = new DialPlot();
    lightValueDialPlot.setDataset(lightValueDataSet);
    StandardDialFrame dialFrame = new StandardDialFrame();
    dialFrame.setVisible(false);
    lightValueDialPlot.setDialFrame(dialFrame);

    GradientPaint gradientpaint = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(),
            new Color(170, 170, 170));
    DialBackground dialBackground = new DialBackground(gradientpaint);
    dialBackground.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL));
    lightValueDialPlot.setBackground(dialBackground);
    // ??
    DialTextAnnotation dialtextannotation = new DialTextAnnotation("");
    dialtextannotation.setFont(new Font("Dialog", 0, (int) (0.016 * HEIGHT)));
    dialtextannotation.setRadius(0.1D);
    lightValueDialPlot.addLayer(dialtextannotation);

    DialValueIndicator dialValueIndicator = new DialValueIndicator(0);
    dialValueIndicator.setFont(new Font("Dialog", Font.PLAIN, (int) (0.011 * HEIGHT)));
    dialValueIndicator.setOutlinePaint(Color.darkGray);
    dialValueIndicator.setRadius(0.4D);
    dialValueIndicator.setAngle(-90.0);
    lightValueDialPlot.addLayer(dialValueIndicator);

    StandardDialScale dialScale = new StandardDialScale();
    dialScale.setLowerBound(0D); // 
    dialScale.setUpperBound(1024); // 
    dialScale.setMajorTickIncrement(100);
    dialScale.setStartAngle(-120D); // 120,?
    dialScale.setExtent(-300D); // 300,?
    dialScale.setTickRadius(0.85D); // ,
    dialScale.setTickLabelOffset(0.1D); // ,0

    bloodDialRange = new StandardDialRange(500D, 750D, Color.red);
    bloodDialRange.setInnerRadius(0.52000000000000002D);
    bloodDialRange.setOuterRadius(0.55000000000000004D);
    lightValueDialPlot.addLayer(bloodDialRange);
    //
    bubbleDialRange = new StandardDialRange(0D, 500D, Color.black);
    bubbleDialRange.setInnerRadius(0.52000000000000002D);
    bubbleDialRange.setOuterRadius(0.55000000000000004D);
    lightValueDialPlot.addLayer(bubbleDialRange);
    //
    normalDialRange = new StandardDialRange(750D, 1024D, Color.green);
    normalDialRange.setInnerRadius(0.52000000000000002D);
    normalDialRange.setOuterRadius(0.55000000000000004D);
    lightValueDialPlot.addLayer(normalDialRange);

    dialScale.setTickLabelFont(new Font("Dialog", 0, (int) (0.011 * HEIGHT))); // 
    lightValueDialPlot.addScale(0, dialScale);

    DialPointer.Pointer pointer = new DialPointer.Pointer();
    lightValueDialPlot.addPointer(pointer);
    lightValueDialPlot.mapDatasetToScale(0, 0);
    DialCap dialCap = new DialCap();
    dialCap.setRadius(0.07D);
    JFreeChart lightValueDialChart = new JFreeChart(lightValueDialPlot);
    lightValueDialChart.setBackgroundPaint(new Color(0, 150, 255));
    lightValueDialChart.setTitle("??");
    lightValueDialChart.getTitle().setFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.020)));
    ChartPanel lightValueDialChartPanel = new ChartPanel(lightValueDialChart, (int) (WIDTH * 0.15),
            (int) (HEIGHT * 0.27), 0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE, true, true, false, true, false,
            false);
    lightValueData.add(lightValueDialChartPanel, BorderLayout.CENTER);
    layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
                            .addComponent(temperatureData, GroupLayout.Alignment.LEADING)
                            .addComponent(lightValueData, GroupLayout.Alignment.LEADING))));
    layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                    .addGap((int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05))
                    .addComponent(temperatureData)
                    .addGap((int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05))
                    .addComponent(lightValueData)
                    .addGap((int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05))));

    //        JPanel alarmMessage=new JPanel();
    //        alarmMessage.setBackground(new Color(0,150,255));
    //        alarmMessLabel=new JLabel("");
    //        alarmMessLabel.setFont(new Font("SansSerif", 0, (int)(HEIGHT *0.020)));
    //        alarmMessLabel.setBackground(new Color(0,150,255));
    //        alarmMessage.add(alarmMessLabel);
    //        GuardDataPanel.add(alarmMessage);
}

From source file:org.eclipse.birt.chart.device.g2d.G2dRendererBase.java

@Override
public void fillRectangle(RectangleRenderEvent rre) throws ChartException {
    if (iv != null) {
        iv.modifyEvent(rre);// w ww .j a va  2 s  .  c o m
    }
    final Fill flBackground = validateMultipleFill(rre.getBackground());

    if (isFullTransparent(flBackground)) {
        return;
    }

    final Bounds bo = normalizeBounds(rre.getBounds());
    final Rectangle2D.Double r2d = new Rectangle2D.Double(bo.getLeft(), bo.getTop(), bo.getWidth(),
            bo.getHeight());
    if (flBackground instanceof ColorDefinition) {
        final ColorDefinition cd = (ColorDefinition) flBackground;
        _g2d.setColor((Color) _ids.getColor(cd));
        _g2d.fill(r2d);
    } else if (flBackground instanceof Gradient) {
        final Gradient g = (Gradient) flBackground;
        final ColorDefinition cdStart = g.getStartColor();
        final ColorDefinition cdEnd = g.getEndColor();
        // boolean bCyclic = g.isCyclic();
        double dAngleInDegrees = g.getDirection();
        final double dAngleInRadians = ((-dAngleInDegrees * Math.PI) / 180.0);
        // int iAlpha = g.getTransparency();

        if (dAngleInDegrees < -90 || dAngleInDegrees > 90) {
            throw new ChartException(ChartDeviceExtensionPlugin.ID, ChartException.RENDERING,
                    "SwingRendererImpl.exception.gradient.angle", //$NON-NLS-1$
                    new Object[] { new Double(dAngleInDegrees) }, Messages.getResourceBundle(getULocale()));
        }

        Point2D.Double p2dStart, p2dEnd;
        if (dAngleInDegrees == 90) {
            p2dStart = new Point2D.Double(bo.getLeft(), bo.getTop() + bo.getHeight());
            p2dEnd = new Point2D.Double(bo.getLeft(), bo.getTop());
        } else if (dAngleInDegrees == -90) {
            p2dEnd = new Point2D.Double(bo.getLeft(), bo.getTop() + bo.getHeight());
            p2dStart = new Point2D.Double(bo.getLeft(), bo.getTop());
        } else if (dAngleInDegrees > 0) {
            p2dStart = new Point2D.Double(bo.getLeft(), bo.getTop() + bo.getHeight());
            p2dEnd = new Point2D.Double(bo.getLeft() + bo.getWidth(),
                    bo.getTop() + bo.getHeight() - bo.getWidth() * Math.abs(Math.tan(dAngleInRadians)));
        } else if (dAngleInDegrees < 0) {
            p2dStart = new Point2D.Double(bo.getLeft(), bo.getTop());
            p2dEnd = new Point2D.Double(bo.getLeft() + bo.getWidth(),
                    bo.getTop() + bo.getWidth() * Math.abs(Math.tan(dAngleInRadians)));
        } else {
            p2dStart = new Point2D.Double(bo.getLeft(), bo.getTop());
            p2dEnd = new Point2D.Double(bo.getLeft() + bo.getWidth(), bo.getTop());
        }
        _g2d.setPaint(new GradientPaint(p2dStart, (Color) _ids.getColor(cdStart), p2dEnd,
                (Color) _ids.getColor(cdEnd)));
        _g2d.fill(r2d);
    } else if (flBackground instanceof org.eclipse.birt.chart.model.attribute.Image) {
        if (flBackground instanceof PatternImage) {
            fillWithPatternImage(new Area(r2d), flBackground);
            return;
        }
        java.awt.Image img = createImageFromModel(flBackground);

        if (img != null) {
            final Shape shClip = _g2d.getClip();
            Area ar2 = new Area(r2d);
            if (shClip != null) {
                Area ar1 = new Area(shClip);
                ar2.intersect(ar1);
            }
            _g2d.setClip(ar2);

            img = scaleImage(img);
            final Size szImage = _ids.getSize(img);

            int iXRepeat = (int) (Math.ceil(r2d.width / szImage.getWidth()));
            int iYRepeat = (int) (Math.ceil(r2d.height / szImage.getHeight()));
            ImageObserver io = (ImageObserver) _ids.getObserver();
            for (int i = 0; i < iXRepeat; i++) {
                for (int j = 0; j < iYRepeat; j++) {
                    _g2d.drawImage(img, (int) (r2d.x + i * szImage.getWidth()),
                            (int) (r2d.y + j * szImage.getHeight()), io);
                }
            }

            _g2d.setClip(shClip); // RESTORE
        }
    }
}