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(float x1, float y1, Color color1, float x2, float y2, Color color2) 

Source Link

Document

Constructs a simple acyclic GradientPaint object.

Usage

From source file:org.jfree.chart.demo.BarChartDemo9.java

private static Paint[] createPaint() {
    Paint apaint[] = new Paint[5];
    apaint[0] = new GradientPaint(0.0F, 0.0F, Color.white, 0.0F, 0.0F, Color.red);
    apaint[1] = new GradientPaint(0.0F, 0.0F, Color.white, 0.0F, 0.0F, Color.green);
    apaint[2] = new GradientPaint(0.0F, 0.0F, Color.white, 0.0F, 0.0F, Color.blue);
    apaint[3] = new GradientPaint(0.0F, 0.0F, Color.white, 0.0F, 0.0F, Color.orange);
    apaint[4] = new GradientPaint(0.0F, 0.0F, Color.white, 0.0F, 0.0F, Color.magenta);
    return apaint;
}

From source file:org.jfree.chart.demo.WindChartDemo.java

/**
 * Creates a chart.//from  ww w . j a  v a2s  . co  m
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
private JFreeChart createChart(final WindDataset dataset) {

    final JFreeChart chart = ChartFactory.createWindPlot("Wind Chart Demo", "Date", "Direction / Force",
            dataset, true, false, false);

    // then customise it a little...
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 1000, 0, Color.green));
    return chart;

}

From source file:com.bdb.weather.display.current.Hygrometer.java

private ChartViewer createChartElements() {
    humidityPlot.addLayer(/*from www .  java  2  s  .c  o  m*/
            new DialBackground(new GradientPaint(0.0f, 0.0f, Color.LIGHT_GRAY, 100.0f, 0.0f, Color.blue)));
    StandardDialScale scale = new StandardDialScale(Humidity.MIN_HUMIDITY.get(), Humidity.MAX_HUMIDITY.get(),
            240.0, -300.0, 10.0, 9);
    scale.setTickLabelFont(scale.getTickLabelFont().deriveFont(14.0F).deriveFont(Font.PLAIN));
    scale.setTickRadius(.9);
    scale.setTickLabelFormatter(new DecimalFormat("#"));
    scale.setTickLabelOffset(.2);
    scale.setTickLabelPaint(Color.BLACK);
    humidityPlot.addScale(0, scale);
    humidityPlot.setDialFrame(new StandardDialFrame());

    DialValueIndicator valueInd = new DialValueIndicator(0);
    valueInd.setNumberFormat(new DecimalFormat("# '%rH'"));
    Color c = new Color(255, 255, 255, 0);
    valueInd.setBackgroundPaint(c);
    valueInd.setOutlinePaint(c);
    valueInd.setPaint(Color.cyan);
    humidityPlot.addLayer(valueInd);

    double angle = valueInd.getAngle();
    double radius = valueInd.getRadius();

    trendAnnotation.setPaint(Color.cyan);
    trendAnnotation.setAngle(angle);
    trendAnnotation.setRadius(radius + .1);
    humidityPlot.addLayer(trendAnnotation);

    DialPointer.Pointer pointer = new DialPointer.Pointer(0);
    humidityPlot.addPointer(pointer);

    DialCap cap = new DialCap();
    cap.setRadius(cap.getRadius() * 1.5);
    humidityPlot.setCap(cap);

    range = new StandardDialRange(Humidity.MIN_HUMIDITY.get(), Humidity.MAX_HUMIDITY.get(), Color.BLACK);
    range.setInnerRadius(.40);
    range.setOuterRadius(.45);
    range.setScaleIndex(0);
    humidityPlot.addLayer(range);

    JFreeChart chart = new JFreeChart(humidityPlot);
    chart.setBackgroundPaint(Color.GRAY);

    ChartViewer chartViewer = new ChartViewer(chart);
    //chartViewer.setMinHeight(100);
    //chartViewer.setMinWidth(100);
    //chartViewer.setMaxHeight(400);
    //chartViewer.setMaxWidth(400);
    //chartViewer.setBackground(Color.GRAY);
    return chartViewer;
}

From source file:org.jfree.chart.demo.WaferMapChartDemo.java

/**
 * Creates a new demo.//from  w w  w  . jav  a 2  s . c  o  m
 * 
 * @param title  the frame title.
 */
public WaferMapChartDemo(final String title) {
    super(title);
    final WaferMapDataset dataset = DemoDatasetFactory.createRandomWaferMapDataset(5);
    final JFreeChart chart = ChartFactory.createWaferMapChart("Wafer Map Demo", // title
            dataset, // wafermapdataset
            PlotOrientation.VERTICAL, // vertical = notchdown
            true, // legend           
            false, // tooltips
            false);

    //        final Legend legend = chart.getLegend();
    //      legend.setAnchor(Legend.EAST);
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue));

    final TextTitle copyright = new TextTitle("JFreeChart WaferMapPlot", new Font("SansSerif", Font.PLAIN, 9));
    copyright.setPosition(RectangleEdge.BOTTOM);
    copyright.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    chart.addSubtitle(copyright);

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 400));
    setContentPane(chartPanel);
}

From source file:com.cburch.logisim.gui.start.AboutCredits.java

public AboutCredits() {
    scroll = 0;//from   w w w  .j  a v a 2 s .  co  m
    setOpaque(false);

    int prefWidth = About.IMAGE_WIDTH + 2 * About.IMAGE_BORDER;
    int prefHeight = About.IMAGE_HEIGHT / 2 + About.IMAGE_BORDER;
    setPreferredSize(new Dimension(prefWidth, prefHeight));

    fadeStop = (float) (About.IMAGE_HEIGHT / 4.0);

    colorBase = new Color[] { new Color(143, 0, 0), new Color(48, 0, 96), new Color(48, 0, 96), };
    font = new Font[] { new Font("Sans Serif", Font.ITALIC, 20), new Font("Sans Serif", Font.BOLD, 24),
            new Font("Sans Serif", Font.BOLD, 18), };
    paintSteady = new Paint[colorBase.length];
    for (int i = 0; i < colorBase.length; i++) {
        Color hue = colorBase[i];
        paintSteady[i] = new GradientPaint(0.0f, 0.0f, derive(hue, 0), 0.0f, fadeStop, hue);
    }

    URL url = AboutCredits.class.getClassLoader().getResource(HENDRIX_PATH);
    Image hendrixLogo = null;
    if (url != null) {
        hendrixLogo = getToolkit().createImage(url);
    }

    // Logisim's policy concerning who is given credit:
    // Past contributors are not acknowledged in the About dialog for the current
    // version, but they do appear in the acknowledgements section of the User's
    // Guide. Current contributors appear in both locations.

    lines = new ArrayList<CreditsLine>();
    linesHeight = 0; // computed in paintComponent
    lines.add(new CreditsLine(1, "www.cburch.com/logisim/"));
    lines.add(new CreditsLine(0, Strings.get("creditsRoleLead"), hendrixLogo, HENDRIX_WIDTH));
    lines.add(new CreditsLine(1, "Carl Burch"));
    lines.add(new CreditsLine(2, "Hendrix College"));
    initialLines = lines.size();
    lines.add(new CreditsLine(0, Strings.get("creditsRoleGerman")));
    lines.add(new CreditsLine(1, "Uwe Zimmerman"));
    lines.add(new CreditsLine(2, "Uppsala universitet"));
    lines.add(new CreditsLine(0, Strings.get("creditsRoleGreek")));
    lines.add(new CreditsLine(1, "Thanos Kakarountas"));
    lines.add(new CreditsLine(2,
            "\u03A4.\u0395.\u0399 \u0399\u03BF\u03BD\u03AF\u03C9\u03BD \u039D\u03AE\u03C3\u03C9\u03BD"));
    lines.add(new CreditsLine(0, Strings.get("creditsRolePortuguese")));
    lines.add(new CreditsLine(1, "Theldo Cruz Franqueira"));
    lines.add(new CreditsLine(2, "PUC Minas"));
    lines.add(new CreditsLine(0, Strings.get("creditsRoleRussian")));
    lines.add(new CreditsLine(1, "Ilia Lilov"));
    lines.add(new CreditsLine(2,
            "\u041C\u043E\u0441\u043A\u043E\u0432\u0441\u043A\u0438\u0439 \u0433\u043E\u0441\u0443\u0434\u0430\u0440\u0441\u0442\u0432\u0435\u043D\u043D\u044B\u0439"));
    lines.add(new CreditsLine(2,
            "\u0443\u043D\u0438\u0432\u0435\u0440\u0441\u0438\u0442\u0435\u0442 \u043F\u0435\u0447\u0430\u0442\u0438"));
    lines.add(new CreditsLine(0, Strings.get("creditsRoleTesting")));
    lines.add(new CreditsLine(1, "Ilia Lilov"));
    lines.add(new CreditsLine(2,
            "\u041C\u043E\u0441\u043A\u043E\u0432\u0441\u043A\u0438\u0439 \u0433\u043E\u0441\u0443\u0434\u0430\u0440\u0441\u0442\u0432\u0435\u043D\u043D\u044B\u0439"));
    lines.add(new CreditsLine(2,
            "\u0443\u043D\u0438\u0432\u0435\u0440\u0441\u0438\u0442\u0435\u0442 \u043F\u0435\u0447\u0430\u0442\u0438"));

    /* If you fork Logisim, feel free to change the above lines, but
     * please do not change these last four lines! */
    lines.add(new CreditsLine(0, Strings.get("creditsRoleOriginal"), hendrixLogo, HENDRIX_WIDTH));
    lines.add(new CreditsLine(1, "Carl Burch"));
    lines.add(new CreditsLine(2, "Hendrix College"));
    lines.add(new CreditsLine(1, "www.cburch.com/logisim/"));
}

From source file:org.jfree.chart.demo.XYBarChartDemo.java

/**
 * Constructs the demo application.//from ww  w .  j a v  a 2 s  .c  o  m
 *
 * @param title  the frame title.
 */
public XYBarChartDemo(final String title) {

    super(title);

    final TimeSeriesCollection data = DemoDatasetFactory.createTimeSeriesCollection1();
    data.setDomainIsPointsInTime(false);
    final JFreeChart chart = ChartFactory.createXYBarChart(title, "X", true, "Y", data,
            PlotOrientation.VERTICAL, true, false, false);

    // then customise it a little...
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 1000, 0, Color.blue));

    final XYItemRenderer renderer = chart.getXYPlot().getRenderer();
    final StandardXYToolTipGenerator generator = new StandardXYToolTipGenerator("{1} = {2}",
            new SimpleDateFormat("yyyy"), new DecimalFormat("0.00"));
    renderer.setToolTipGenerator(generator);

    final XYPlot plot = chart.getXYPlot();
    final DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);

    // add the chart to a panel...
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 300));
    setContentPane(chartPanel);

}

From source file:ca.sqlpower.wabit.swingui.chart.WabitDrawingSupplier.java

private Paint makeGradient(int i) {
    Paint p = new GradientPaint(0.0f, 0.0f, SERIES_COLOURS[i][0], 0.0f, 1.0f, SERIES_COLOURS[i][1]);
    return p;/*from  w  w w.  j a v  a 2  s .  c  o  m*/
}

From source file:dinamica.ChartOutput.java

/**
 * Creates a gradient (white->gray) for charts, may
 * be overrided by subclasses to provide a custom gradient
 * @return Default gradient for charts/*from w w  w.ja va  2 s .co m*/
 */
protected GradientPaint getGradient() {
    return new GradientPaint(0, 0, Color.WHITE, 1000, 0, Color.LIGHT_GRAY);
}

From source file:org.jfree.chart.demo.SymbolicYPlotDemo.java

/**
 * Displays an XYPlot with Y symbolic data.
 * /*  w  ww . j av a2 s.c o m*/
 * @param frameTitle
 *           the frame title.
 * @param data
 *           the data.
 * @param chartTitle
 *           the chart title.
 * @param xAxisLabel
 *           the x-axis label.
 * @param yAxisLabel
 *           the y-axis label.
 */
private static void displayYSymbolic(final String frameTitle, final XYDataset data, final String chartTitle,
        final String xAxisLabel, final String yAxisLabel) {

    final JFreeChart chart = createYSymbolicPlot(chartTitle, xAxisLabel, yAxisLabel, data, true);
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 1000, 0, Color.green));

    final JFrame frame = new ChartFrame(frameTitle, chart);
    frame.pack();
    RefineryUtilities.positionFrameRandomly(frame);
    frame.show();

}

From source file:com.seagate.kinetic.monitor.view.DefaultKineticOverviewView.java

private JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createStackedBarChart("", "", "Total " + unitName, categorydataset,
            PlotOrientation.HORIZONTAL, true, true, false);
    keytogroupmap = new KeyToGroupMap("G1");
    keytogroupmap.mapKeyToGroup("Get", "G1");
    keytogroupmap.mapKeyToGroup("Put", "G1");
    keytogroupmap.mapKeyToGroup("Delete", "G1");
    groupedstackedbarrenderer.setSeriesToGroupMap(keytogroupmap);
    groupedstackedbarrenderer.setItemMargin(0.10000000000000001D);
    groupedstackedbarrenderer.setDrawBarOutline(false);

    GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, new Color(34, 34, 255), 0.0F, 0.0F,
            new Color(136, 136, 255));
    groupedstackedbarrenderer.setSeriesPaint(0, gradientpaint);
    groupedstackedbarrenderer.setSeriesPaint(4, gradientpaint);
    groupedstackedbarrenderer.setSeriesPaint(8, gradientpaint);
    GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, new Color(34, 255, 34), 0.0F, 0.0F,
            new Color(136, 255, 136));
    groupedstackedbarrenderer.setSeriesPaint(1, gradientpaint1);
    groupedstackedbarrenderer.setSeriesPaint(5, gradientpaint1);
    groupedstackedbarrenderer.setSeriesPaint(9, gradientpaint1);
    GradientPaint gradientpaint2 = new GradientPaint(0.0F, 0.0F, new Color(255, 34, 34), 0.0F, 0.0F,
            new Color(255, 136, 136));
    groupedstackedbarrenderer.setSeriesPaint(2, gradientpaint2);
    groupedstackedbarrenderer.setSeriesPaint(6, gradientpaint2);
    groupedstackedbarrenderer.setSeriesPaint(10, gradientpaint2);
    GradientPaint gradientpaint3 = new GradientPaint(0.0F, 0.0F, new Color(255, 255, 34), 0.0F, 0.0F,
            new Color(255, 255, 136));
    groupedstackedbarrenderer.setSeriesPaint(3, gradientpaint3);
    groupedstackedbarrenderer.setSeriesPaint(7, gradientpaint3);
    groupedstackedbarrenderer.setSeriesPaint(11, gradientpaint3);
    groupedstackedbarrenderer.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL));

    return jfreechart;
}