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);
}
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);
}
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);
}
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));
}
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;
}
Aggregations