use of java.awt.BasicStroke in project processdash by dtuma.
the class ReportsAndToolsIcon method paintLargeIconImpl.
private void paintLargeIconImpl(Graphics2D g2, int pw, int ph) {
// draw a white page with a black outline.
int pageHeight = ph - 1;
int pageWidth = ph * 9 / 11;
g2.setColor(Color.white);
g2.fillRect(0, 0, pageWidth, pageHeight);
g2.setColor(Color.gray);
g2.drawRect(0, 0, pageWidth, pageHeight);
// draw text onto the page
int pad = 1 + ph / 20;
float lineSpacing = Math.max(2, ph / 14);
float fontSize = 0.85f * lineSpacing;
float y = pad + lineSpacing;
g2.setClip(pad + 1, pad, pageWidth - 2 * pad, pageHeight - 2 * pad);
g2.setFont(new Font("Dialog", Font.PLAIN, 10).deriveFont(fontSize));
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2.setColor(Color.darkGray);
String s = TEXT;
while (y <= ph) {
g2.drawString(s, pad + 1, y);
s = s.substring(20);
if (s.charAt(0) == ' ')
s = s.substring(1);
y += lineSpacing;
}
// calculate the geometry for the chart in the lower-left corner
int barWidth = pageWidth / 5;
int chartHeight = (int) (pageHeight * 0.4);
int chartTop = pageHeight - pad - chartHeight;
Rectangle2D[] bars = new Rectangle2D[BAR_DELTA.length];
for (int i = bars.length; i-- > 0; ) {
float barGap = chartHeight * BAR_DELTA[i];
bars[i] = new Rectangle2D.Float(pad + 1 + barWidth * i, chartTop + barGap, barWidth, chartHeight);
}
// draw white areas to ensure the text doesn't run into the bars
g2.setColor(Color.white);
g2.setStroke(new BasicStroke(Math.max(3, 1 + pad * 1.2f)));
for (int i = bars.length; i-- > 0; ) g2.draw(bars[i]);
// draw the bars themselves
for (int i = bars.length; i-- > 0; ) {
Color light = PaintUtils.mixColors(BAR_COLORS[i], Color.white, 0.7);
g2.setPaint(new GradientPaint((int) bars[i].getX(), 0, BAR_COLORS[i], (int) bars[i].getMaxX(), 0, light));
g2.fill(bars[i]);
}
// draw the calculator
ImageIcon calc = loadImage("calc.png");
int calcHeight = ph * 2 / 3;
float calcScale = calcHeight / (float) calc.getIconHeight();
int calcWidth = (int) (0.5 + calc.getIconWidth() * calcScale);
int calcLeft = (int) (pageWidth - pad * 2 / 3);
int calcTop = ph / 4;
Image scaledCalc = new ImageIcon(//
calc.getImage().getScaledInstance(calcWidth, calcHeight, Image.SCALE_SMOOTH)).getImage();
g2.setClip(null);
g2.drawImage(scaledCalc, calcLeft, calcTop, null);
}
use of java.awt.BasicStroke in project processdash by dtuma.
the class TaskOverflowIcon method paintIcon.
@Override
protected void paintIcon(Graphics2D g2, int width, int height, float scale) {
int hh = width / 4;
float lw = hh;
int top = (height - 2 * hh) / 2;
g2.setStroke(new BasicStroke(1));
g2.setColor(color);
for (int left = 0; left < lw * 3; left++) {
g2.drawLine(left, top + hh, left + hh, top);
g2.drawLine(left, top + hh, left + hh, top + hh * 2);
if (left == lw - 1)
left += lw;
}
}
use of java.awt.BasicStroke in project processdash by dtuma.
the class TooltipLineXYLineAndShapeRenderer method getAreaWidth.
/**
* This method tries to get the line stroke's thickness to determine how big we need
* to draw the area. If it fails, or if the stroke thickness is not big enough, the
* minimum width will be used.
*/
private float getAreaWidth(int series) {
float areaWidth = MINIMUM_TOOLTIP_AREA_WIDTH;
Stroke seriesStroke = getSeriesStroke(series);
if (seriesStroke instanceof BasicStroke) {
float lineWidth = ((BasicStroke) seriesStroke).getLineWidth();
if (lineWidth > areaWidth)
areaWidth = lineWidth;
}
return areaWidth;
}
use of java.awt.BasicStroke in project processdash by dtuma.
the class StopIcon method paintIcon.
@Override
protected void paintIcon(Graphics2D g2, int width, int height, float scale) {
// calculate the pixel geometry of the octagon
int angle = (int) (width / (Math.sqrt(2) * (1 + 2 / Math.sqrt(2))));
int side = width - 1 - 2 * angle;
int a = 0, b = angle, c = side + angle, d = side + 2 * angle;
Shape s = shape(b, a, c, a, d, b, d, c, c, d, b, d, a, c, a, b);
// fill the shape
g2.setColor(fill);
g2.fill(s);
// draw the outer edge
g2.setStroke(new BasicStroke(1));
g2.setColor(edge);
g2.draw(s);
}
use of java.awt.BasicStroke in project processdash by dtuma.
the class BlockArrowIcon method paintIcon.
@Override
protected void paintIcon(Graphics2D g2, Shape clip, float scale) {
// fill the shape
g2.setColor(fill);
g2.fill(shape);
// draw edge
g2.setStroke(new BasicStroke(0.7f / scale));
g2.setColor(edge);
g2.draw(shape);
}
Aggregations