Search in sources :

Example 26 with GradientPaint

use of java.awt.GradientPaint in project EnrichmentMapApp by BaderLab.

the class ColorGradientWidget method renderLegendGradient.

private void renderLegendGradient(Graphics2D g2d) {
    // minimum gradient
    final GradientPaint gradientLow = new GradientPaint((float) minimumConditionGradientRectangle.getX(), (float) minimumConditionGradientRectangle.getY(), colorGradientTheme.getMinColor(), (float) centerConditionGradientRectangle.getX(), (float) centerConditionGradientRectangle.getY(), colorGradientTheme.getCenterColor());
    g2d.setPaint(gradientLow);
    g2d.fillRect((int) minimumConditionGradientRectangle.getX(), (int) minimumConditionGradientRectangle.getY(), (int) minimumConditionGradientRectangle.getWidth(), (int) minimumConditionGradientRectangle.getHeight());
    // center gradient
    g2d.setPaint(colorGradientTheme.getCenterColor());
    g2d.fillRect((int) centerConditionGradientRectangle.getX(), (int) centerConditionGradientRectangle.getY(), (int) centerConditionGradientRectangle.getWidth(), (int) centerConditionGradientRectangle.getHeight());
    // max gradient
    final GradientPaint gradientHigh = new GradientPaint((float) centerConditionGradientRectangle.getX(), (float) centerConditionGradientRectangle.getY(), colorGradientTheme.getCenterColor(), (float) (maximumConditionGradientRectangle.getX() + maximumConditionGradientRectangle.getWidth()), (float) maximumConditionGradientRectangle.getY(), colorGradientTheme.getMaxColor());
    g2d.setPaint(gradientHigh);
    g2d.fillRect((int) maximumConditionGradientRectangle.getX(), (int) maximumConditionGradientRectangle.getY(), (int) maximumConditionGradientRectangle.getWidth(), (int) maximumConditionGradientRectangle.getHeight());
    // draw outline around gradient - use any rectangle for starting y
    final Rectangle rect = new Rectangle(positionLegendWidth, (int) minimumConditionGradientRectangle.getY(), gradientWidth - 1, gradientHeight - 1);
    g2d.setPaint(borderColor);
    g2d.draw(rect);
}
Also used : Rectangle(java.awt.Rectangle) GradientPaint(java.awt.GradientPaint)

Example 27 with GradientPaint

use of java.awt.GradientPaint in project openblocks by mikaelhg.

the class GlassHorizontalBar method paint.

/**
     * paints scrollbar
     */
@Override
public void paint(Graphics g) {
    //paint super
    super.paint(g);
    //set up values
    double viewValue = modelToView(modelrange.getValue());
    double viewExtent = modelToView(modelrange.getExtent());
    int vHeight = this.getHeight() / 2;
    Graphics2D g2 = (Graphics2D) g;
    g2.addRenderingHints(renderingHints);
    g2.translate(0, vHeight / 2);
    g2.setColor(trackColor);
    g2.fillRoundRect(0, 0, this.getWidth(), vHeight, vHeight, vHeight);
    g2.setColor(new Color(150, 150, 150));
    g2.drawRoundRect(0, 0, this.getWidth() - 1, vHeight, vHeight, vHeight);
    if (viewValue < this.getWidth() - 0.5f * this.getHeight()) {
        g2.translate(viewValue, 0);
    } else {
        g2.translate(this.getWidth() - 0.5f * this.getHeight(), 0);
    }
    g2.setPaint(new GradientPaint(0, 0, this.thumbColor, 0, this.getHeight() + 10, Color.black, true));
    g2.fillRoundRect(0, 0, (int) viewExtent, vHeight, vHeight, vHeight);
    g2.setColor(new Color(250, 250, 250, 100));
    g2.drawRoundRect(0, 0, (int) viewExtent, vHeight, vHeight, vHeight);
}
Also used : Color(java.awt.Color) GradientPaint(java.awt.GradientPaint) GradientPaint(java.awt.GradientPaint) Graphics2D(java.awt.Graphics2D)

Example 28 with GradientPaint

use of java.awt.GradientPaint in project openblocks by mikaelhg.

the class HoverHorizontalBar method paint.

/**
     * paints scrollbar
     */
@Override
public void paint(Graphics g) {
    //paint super
    super.paint(g);
    //set up values
    double viewValue = modelToView(modelrange.getValue());
    double viewExtent = modelToView(modelrange.getExtent());
    int vHeight = this.getHeight() / 2;
    Graphics2D g2 = (Graphics2D) g;
    g2.addRenderingHints(renderingHints);
    g2.translate(0, vHeight / 2);
    g2.setColor(trackColor);
    g2.fillRoundRect(0, 0, this.getWidth(), vHeight, vHeight, vHeight);
    g2.setColor(new Color(150, 150, 150));
    g2.drawRoundRect(0, 0, this.getWidth() - 1, vHeight, vHeight, vHeight);
    if (viewValue < this.getWidth() - 0.5f * this.getHeight()) {
        g2.translate(viewValue, 0);
    } else {
        g2.translate(this.getWidth() - 0.5f * this.getHeight(), 0);
    }
    g2.setPaint(new GradientPaint(0, 0, this.thumbColor, 0, this.getHeight() + 10, Color.black, true));
    g2.fillRoundRect(0, 0, (int) viewExtent, vHeight, vHeight, vHeight);
    g2.setColor(new Color(250, 250, 250, 100));
    g2.drawRoundRect(0, 0, (int) viewExtent, vHeight, vHeight, vHeight);
}
Also used : Color(java.awt.Color) GradientPaint(java.awt.GradientPaint) GradientPaint(java.awt.GradientPaint) Graphics2D(java.awt.Graphics2D)

Example 29 with GradientPaint

use of java.awt.GradientPaint in project openblocks by mikaelhg.

the class LowerRightCorner method paint.

/**
     * paints scrollbar
     */
@Override
public void paint(Graphics g) {
    super.paint(g);
    Graphics2D g2 = (Graphics2D) g;
    g2.addRenderingHints(renderingHints);
    g2.setColor(Color.gray);
    g2.drawRoundRect(0, 0, this.getWidth() - 1, this.getHeight() - 1, this.getHeight(), this.getHeight());
    double viewValue = modelToView(modelrange.getValue());
    double viewExtent = modelToView(modelrange.getExtent());
    if (viewValue < this.getWidth() - 0.5f * this.getHeight()) {
        g2.translate(viewValue, 0);
    } else {
        g2.translate(this.getWidth() - 0.5f * this.getHeight(), 0);
    }
    g2.setColor(Color.lightGray);
    g2.setPaint(new GradientPaint(0, 0, thumbColor, 0, this.getHeight() + 10, Color.black, true));
    g2.fill(reformThumbShape(this.getWidth(), this.getHeight(), (int) viewExtent));
}
Also used : GradientPaint(java.awt.GradientPaint) Graphics2D(java.awt.Graphics2D)

Example 30 with GradientPaint

use of java.awt.GradientPaint in project cubrid-manager by CUBRID.

the class CombinedBarTimeSeriesChart method createBarChart.

/**
	 * Create a bar chart instance.
	 * 
	 * @return a bar chart instance
	 */
private JFreeChart createBarChart() {
    bardataset = new DefaultCategoryDataset();
    if (valueMap != null) {
        for (String key : valueMap.keySet()) {
            bardataset.addValue(0D, key, "");
        }
    }
    bardataset.addValue(barMax, "100", "");
    JFreeChart chart = ChartFactory.createStackedBarChart("", "", "", bardataset, PlotOrientation.VERTICAL, false, false, false);
    chart.setBorderVisible(false);
    chart.setBorderStroke(new BasicStroke(0.0f));
    chart.setBackgroundPaint(Color.BLACK);
    //plot
    CategoryPlot categoryplot = (CategoryPlot) chart.getPlot();
    categoryplot.setOutlineVisible(false);
    RectangleInsets rectangleInsets = new RectangleInsets();
    categoryplot.setAxisOffset(rectangleInsets);
    categoryplot.setBackgroundPaint(Color.BLACK);
    categoryplot.setDomainGridlinesVisible(false);
    categoryplot.setRangeGridlinesVisible(false);
    //renderer
    StackedBarRenderer stackedbarrenderer = (StackedBarRenderer) categoryplot.getRenderer(0);
    stackedbarrenderer.setDrawBarOutline(false);
    stackedbarrenderer.setMaximumBarWidth(0.6);
    stackedbarrenderer.setItemMargin(0);
    //painter
    StandardBarPainter painter = new StandardBarPainter() {

        private static final long serialVersionUID = -3124115075260902181L;

        public void paintBar(Graphics2D g2, BarRenderer renderer, int row, int column, RectangularShape bar, RectangleEdge base) {
            Paint itemPaint = renderer.getItemPaint(row, column);
            GradientPaintTransformer t = renderer.getGradientPaintTransformer();
            if (t != null && itemPaint instanceof GradientPaint) {
                itemPaint = t.transform((GradientPaint) itemPaint, bar);
            }
            g2.setPaint(itemPaint);
            double height = bar.getHeight();
            double width = bar.getWidth();
            double x = bar.getBounds2D().getX();
            double y = bar.getBounds2D().getY();
            int barNumber = (int) (height / 2 + 0.5);
            if (height < 1 && height > 0.5) {
                barNumber = 1;
            }
            for (int i = 0; i < barNumber; i++) {
                RectangularShape subBarLeft = new Rectangle2D.Double(x, y, width / 2, 0.8);
                g2.fill(subBarLeft);
                RectangularShape subBarRight = new Rectangle2D.Double(x + width / 2 + 1, y, width / 2, 0.8);
                g2.fill(subBarRight);
                y += 2;
            }
            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);
                }
            }
        }
    };
    stackedbarrenderer.setBarPainter(painter);
    stackedbarrenderer.setSeriesPaint(0, Color.GREEN);
    stackedbarrenderer.setSeriesPaint(1, Color.RED);
    int backPaintOrder = 1;
    if (valueMap != null) {
        backPaintOrder = valueMap.size();
    }
    stackedbarrenderer.setSeriesPaint(backPaintOrder, new Color(136, 200, 135));
    stackedbarrenderer.setShadowVisible(false);
    stackedbarrenderer.setDrawBarOutline(false);
    //categoryAxis
    categoryAxis = categoryplot.getDomainAxis();
    categoryAxis.setAxisLineVisible(false);
    //	categoryAxis.setCategoryMargin(0);
    categoryAxis.setMinorTickMarksVisible(false);
    categoryAxis.setTickLabelsVisible(false);
    categoryAxis.setTickMarksVisible(false);
    categoryAxis.setLabelPaint(Color.GREEN);
    categoryAxis.setLabelFont(new Font("", 0, 10));
    //valueAxis
    ValueAxis valueAxis = categoryplot.getRangeAxis();
    valueAxis.setVisible(false);
    return chart;
}
Also used : BasicStroke(java.awt.BasicStroke) BasicStroke(java.awt.BasicStroke) Stroke(java.awt.Stroke) StackedBarRenderer(org.jfree.chart.renderer.category.StackedBarRenderer) GradientPaintTransformer(org.jfree.ui.GradientPaintTransformer) Color(java.awt.Color) BarRenderer(org.jfree.chart.renderer.category.BarRenderer) StackedBarRenderer(org.jfree.chart.renderer.category.StackedBarRenderer) GradientPaint(java.awt.GradientPaint) Paint(java.awt.Paint) GradientPaint(java.awt.GradientPaint) JFreeChart(org.jfree.chart.JFreeChart) CategoryPlot(org.jfree.chart.plot.CategoryPlot) Paint(java.awt.Paint) GradientPaint(java.awt.GradientPaint) Font(java.awt.Font) Graphics2D(java.awt.Graphics2D) StandardBarPainter(org.jfree.chart.renderer.category.StandardBarPainter) ValueAxis(org.jfree.chart.axis.ValueAxis) RectangularShape(java.awt.geom.RectangularShape) RectangleInsets(org.jfree.ui.RectangleInsets) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) RectangleEdge(org.jfree.ui.RectangleEdge)

Aggregations

GradientPaint (java.awt.GradientPaint)38 Graphics2D (java.awt.Graphics2D)24 Color (java.awt.Color)22 Font (java.awt.Font)12 Rectangle2D (java.awt.geom.Rectangle2D)11 BasicStroke (java.awt.BasicStroke)9 BufferedImage (java.awt.image.BufferedImage)8 FontMetrics (java.awt.FontMetrics)7 Paint (java.awt.Paint)6 Rectangle (java.awt.Rectangle)5 LinearGradientPaint (java.awt.LinearGradientPaint)4 RadialGradientPaint (java.awt.RadialGradientPaint)4 RoundRectangle2D (java.awt.geom.RoundRectangle2D)4 MultipleGradientPaint (java.awt.MultipleGradientPaint)3 Shape (java.awt.Shape)3 TexturePaint (java.awt.TexturePaint)3 Point2D (java.awt.geom.Point2D)3 RectangularShape (java.awt.geom.RectangularShape)3 ConvolveOp (java.awt.image.ConvolveOp)3 Kernel (java.awt.image.Kernel)3