Example usage for java.awt Color brighter

List of usage examples for java.awt Color brighter

Introduction

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

Prototype

public Color brighter() 

Source Link

Document

Creates a new Color that is a brighter version of this Color .

Usage

From source file:Main.java

public static void main(String[] args) {
    Color myColor = Color.RED;

    JLabel label = new JLabel("First Name");
    label.setForeground(myColor.brighter());

    JFrame frame = new JFrame();
    frame.add(label);//from  w  ww .  jav  a 2s. co m
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setBounds(20, 20, 500, 500);
    frame.setVisible(true);

}

From source file:com.hmsinc.epicenter.webapp.chart.ChartService.java

/**
 * @param chart//from w  w  w. jav a2 s  . c o  m
 * @return
 */
private static XYBarRenderer getTimeSeriesBarRenderer(final AbstractChart chart) {

    final XYBarRenderer renderer = new XYBarRenderer();
    renderer.setMargin(0.2);

    for (int i = 0; i < chart.getColors().size(); i++) {

        final Color c = chart.getColors().get(i);
        renderer.setSeriesPaint(i, new GradientPaint(0f, 0f, c, 0f, 0f, c.brighter().brighter()));
        renderer.setSeriesOutlinePaint(i, c);

    }
    return renderer;
}

From source file:com.hmsinc.epicenter.webapp.chart.ChartService.java

/**
 * @param chart/*from  ww w  . j  a va2 s . co  m*/
 * @return
 */
private static CategoryItemRenderer getBarRenderer(final AbstractChart chart) {

    final BarRenderer renderer = new BarRenderer();
    renderer.setMaximumBarWidth(0.3);

    for (int i = 0; i < chart.getColors().size(); i++) {

        final Color c = chart.getColors().get(i);
        renderer.setSeriesPaint(i, new GradientPaint(0f, 0f, c, 0f, 0f, c.brighter().brighter()));
        renderer.setSeriesOutlinePaint(i, c);

    }

    return renderer;
}

From source file:com.hmsinc.epicenter.webapp.chart.ChartService.java

/**
 * @param chart/* w  ww .  j ava 2s . c  o m*/
 */
private static void configureRenderer(final JFreeChart chart, final AbstractChart adapter) {

    if (ChartType.BAR.equals(adapter.getType())) {

        chart.getCategoryPlot().setRenderer(getBarRenderer(adapter));

    } else if (ChartType.TIMESERIES_BAR.equals(adapter.getType())) {

        chart.getXYPlot().setRenderer(getTimeSeriesBarRenderer(adapter));

    } else if (ChartType.MOUNTAIN.equals(adapter.getType())) {

        chart.getXYPlot().setRenderer(getMountainRenderer(adapter));
        chart.getXYPlot().setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD);

    } else {

        final XYItemRenderer renderer = chart.getXYPlot().getRenderer();

        for (int i = 0; i < adapter.getColors().size(); i++) {

            final Color c = adapter.getColors().get(i);
            renderer.setSeriesPaint(i, c);
            renderer.setSeriesOutlinePaint(i, c.brighter());
        }

        for (int i = 0; i < adapter.getStrokes().size(); i++) {
            renderer.setSeriesStroke(i, adapter.getStrokes().get(i));
        }

        if (renderer instanceof XYLineAndShapeRenderer) {
            ((XYLineAndShapeRenderer) renderer).setDrawSeriesLineAsPath(true);
        }

    }

}

From source file:lu.lippmann.cdb.common.gui.ts.TimeSeriesChartUtil.java

public static ChartPanel buildChartPanelForAllAttributesInterval(final Instances dataSet, final int dateIdx,
        final double deviation, final int deviatedAttrIdx) {
    final YIntervalSeriesCollection tsDataset = new YIntervalSeriesCollection();
    final JFreeChart tsChart = ChartFactory.createTimeSeriesChart("", "Time", "Value", tsDataset, true, true,
            false);/*from   w  ww  .j a va2 s.co m*/
    tsChart.getXYPlot().setBackgroundPaint(Color.WHITE);

    double startgap0 = -1d;
    double endgap0 = -1d;
    try {
        java.util.List<double[]> gaps = WekaTimeSeriesUtil.findGaps(dataSet, deviatedAttrIdx);
        startgap0 = gaps.get(0)[2] + gaps.get(0)[3];
        //System.out.println("start -> "+startgap0);
        endgap0 = gaps.get(1)[2] - 1;
        //System.out.println("end -> "+endgap0);
    } catch (Exception e) {
        e.printStackTrace();
    }
    final double startgap = startgap0;
    final double endgap = endgap0;
    System.out.println("gap --> " + startgap + " " + endgap);

    tsChart.getXYPlot().setRenderer(/*deviatedAttrIdx,*/new DeviationRenderer(true, false) {
        /** */
        private static final long serialVersionUID = 1234L;

        private boolean inRange(final int item) {
            return (item >= startgap && item <= endgap);
        }

        @Override
        public boolean getItemShapeVisible(int series, int item) {
            return false;
        }

        @Override
        public boolean getItemLineVisible(int series, int item) {
            return inRange(item);
        }

    });
    for (int i = 0; i < dataSet.numAttributes() - 1; i++) {
        //final Color cc=ColorHelper.COLORBREWER_ALL_QUALITATIVE[i];
        final Color cc = ColorHelper.getColorForAString(dataSet.attribute(i).name());
        tsChart.getXYPlot().getRenderer().setSeriesPaint(i, cc);
        ((AbstractRenderer) tsChart.getXYPlot().getRenderer()).setSeriesFillPaint(i, cc.brighter());
    }

    fillWithSingleAxisInterval(dataSet, dateIdx, tsDataset, deviation, deviatedAttrIdx);

    final ChartPanel cp = new ChartPanel(tsChart, true);
    if (dataSet.numAttributes() <= 2)
        cp.setBorder(new TitledBorder(dataSet.attribute(0).name()));
    return cp;
}

From source file:ExtendedParagraphExample.java

public static void createDocumentStyles(StyleContext sc) {
    Style defaultStyle = sc.getStyle(StyleContext.DEFAULT_STYLE);

    // Create and add the main document style
    Style mainStyle = sc.addStyle(mainStyleName, defaultStyle);
    StyleConstants.setLeftIndent(mainStyle, 16);
    StyleConstants.setRightIndent(mainStyle, 16);
    StyleConstants.setFirstLineIndent(mainStyle, 16);
    StyleConstants.setFontFamily(mainStyle, "serif");
    StyleConstants.setFontSize(mainStyle, 12);

    // Create and add the constant width style
    Style cwStyle = sc.addStyle(charStyleName, null);
    StyleConstants.setFontFamily(cwStyle, "monospaced");
    StyleConstants.setForeground(cwStyle, Color.white);

    // Create and add the heading style
    Style heading2Style = sc.addStyle(heading2StyleName, null);
    StyleConstants.setForeground(heading2Style, Color.red);
    StyleConstants.setFontSize(heading2Style, 16);
    StyleConstants.setFontFamily(heading2Style, "serif");
    StyleConstants.setBold(heading2Style, true);
    StyleConstants.setLeftIndent(heading2Style, 8);
    StyleConstants.setFirstLineIndent(heading2Style, 0);

    // Create and add the extended para styles
    Style paraStyle = sc.addStyle(paraStyleName, null);
    Color bgColor = Color.gray;
    ExtendedStyleConstants.setParagraphBackground(paraStyle, bgColor);
    ExtendedStyleConstants.setParagraphBorder(paraStyle,
            BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2),
                    BorderFactory.createCompoundBorder(
                            BorderFactory.createEtchedBorder(bgColor.brighter(), bgColor.darker()),
                            BorderFactory.createEmptyBorder(4, 4, 4, 4))));
}

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

/**
 * Draws the button body//w w  w  . j  a v  a 2  s  .  c om
 * @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:TreeLinkTest.java

/**
 * This piece of hackery is needed since one cant really draw things from a
 * layout manager. Call this if you want to draw lines between components.
 *//*from ww w .  j  a  v a  2s  .co m*/
public void paintLines(Graphics g, Color bg) {
    Color dk = bg.darker();
    Color br = bg.brighter();
    root.paintLines(g, dk, br);
}

From source file:ch.opentrainingcenter.charts.bar.OTCCategoryChartViewer.java

private void setSeriesPaint(final AbstractRenderer renderer, final TrainingChart chartType,
        final XAxisChart type, final boolean compareLast) {
    final String color;
    if (TrainingChart.DISTANZ.equals(chartType)) {
        color = PreferenceConstants.CHART_DISTANCE_COLOR;
    } else {//ww w  . j ava2s  .co  m
        color = PreferenceConstants.CHART_HEART_COLOR;
    }
    final Color barColor = ColorFromPreferenceHelper.getColor(store, color, ALPHA);
    renderer.setSeriesPaint(0, barColor.brighter().brighter());
    renderer.setSeriesPaint(1, barColor.brighter());
    renderer.setSeriesPaint(2, barColor);
}

From source file:it.cnr.istc.utils.gui.ReverseGradientXYBarPainter.java

/**
 * Paints a single bar instance./*w ww  .jav a 2  s.  c  o m*/
 *
 * @param g2 the graphics target.
 * @param renderer the renderer.
 * @param row the row index.
 * @param column the column index.
 * @param bar the bar
 * @param base indicates which side of the rectangle is the base of the bar.
 */
@Override
public void paintBar(Graphics2D g2, XYBarRenderer renderer, int row, int column, RectangularShape bar,
        RectangleEdge base) {

    Paint itemPaint = renderer.getItemPaint(row, column);

    Color c0, c1;
    if (itemPaint instanceof Color) {
        c0 = (Color) itemPaint;
        c1 = c0.brighter();
    } else if (itemPaint instanceof GradientPaint) {
        GradientPaint gp = (GradientPaint) itemPaint;
        c0 = gp.getColor1();
        c1 = gp.getColor2();
    } else {
        c0 = Color.blue;
        c1 = Color.blue.brighter();
    }

    // as a special case, if the bar colour has alpha == 0, we draw
    // nothing.
    if (c0.getAlpha() == 0) {
        return;
    }

    if (base == RectangleEdge.LEFT || base == RectangleEdge.RIGHT) {
        Rectangle2D[] regions = splitVerticalBar(bar, this.g1, this.g2, this.g3);
        GradientPaint gp = new GradientPaint((float) regions[0].getMinX(), 0.0f, c0,
                (float) regions[0].getMaxX(), 0.0f, Color.white);
        g2.setPaint(gp);
        g2.fill(regions[0]);

        gp = new GradientPaint((float) regions[1].getMinX(), 0.0f, Color.white, (float) regions[1].getMaxX(),
                0.0f, c0);
        g2.setPaint(gp);
        g2.fill(regions[1]);

        gp = new GradientPaint((float) regions[2].getMinX(), 0.0f, c0, (float) regions[2].getMaxX(), 0.0f, c1);
        g2.setPaint(gp);
        g2.fill(regions[2]);

        gp = new GradientPaint((float) regions[3].getMinX(), 0.0f, c1, (float) regions[3].getMaxX(), 0.0f, c0);
        g2.setPaint(gp);
        g2.fill(regions[3]);
    } else if (base == RectangleEdge.TOP || base == RectangleEdge.BOTTOM) {
        Rectangle2D[] regions = splitHorizontalBar(bar, this.g1, this.g2, this.g3);
        GradientPaint gp = new GradientPaint(0.0f, (float) regions[0].getMinY(), c0, 0.0f,
                (float) regions[0].getMaxX(), Color.white);
        g2.setPaint(gp);
        g2.fill(regions[0]);

        gp = new GradientPaint(0.0f, (float) regions[1].getMinY(), Color.white, 0.0f,
                (float) regions[1].getMaxY(), c0);
        g2.setPaint(gp);
        g2.fill(regions[1]);

        gp = new GradientPaint(0.0f, (float) regions[2].getMinY(), c0, 0.0f, (float) regions[2].getMaxY(), c1);
        g2.setPaint(gp);
        g2.fill(regions[2]);

        gp = new GradientPaint(0.0f, (float) regions[3].getMinY(), c1, 0.0f, (float) regions[3].getMaxY(), c0);
        g2.setPaint(gp);
        g2.fill(regions[3]);
    }

    // draw the outline...
    if (renderer.isDrawBarOutline()) {
        Stroke stroke = renderer.getItemOutlineStroke(row, column);
        Paint paint = renderer.getItemOutlinePaint(row, column);
        if (stroke != null && paint != null) {
            g2.setStroke(stroke);
            g2.setPaint(paint);
            g2.draw(bar);
        }
    }

}