use of java.awt.Polygon in project JMRI by JMRI.
the class AnalogClock2Display method scaleFace.
// Method called on resizing event - sets various sizing variables
// based on the size of the resized panel and scales the logo/hands
private void scaleFace() {
panelHeight = this.getSize().height;
panelWidth = this.getSize().width;
if (panelHeight > 0 && panelWidth > 0) {
size = Math.min(panelHeight, panelWidth);
}
faceSize = size;
if (faceSize == 0) {
faceSize = 1;
}
// Had trouble getting the proper sizes when using Images by themselves so
// use the NamedIcon as a source for the sizes
int logoScaleWidth = faceSize / 6;
int logoScaleHeight = (int) ((float) logoScaleWidth * (float) jmriIcon.getIconHeight() / jmriIcon.getIconWidth());
scaledLogo = logo.getScaledInstance(logoScaleWidth, logoScaleHeight, Image.SCALE_SMOOTH);
scaledIcon.setImage(scaledLogo);
logoWidth = scaledIcon.getIconWidth();
logoHeight = scaledIcon.getIconHeight();
scaleRatio = faceSize / 2.7 / minuteHeight;
for (int i = 0; i < minuteX.length; i++) {
scaledMinuteX[i] = (int) (minuteX[i] * scaleRatio);
scaledMinuteY[i] = (int) (minuteY[i] * scaleRatio);
scaledHourX[i] = (int) (hourX[i] * scaleRatio);
scaledHourY[i] = (int) (hourY[i] * scaleRatio);
}
scaledHourHand = new Polygon(scaledHourX, scaledHourY, scaledHourX.length);
scaledMinuteHand = new Polygon(scaledMinuteX, scaledMinuteY, scaledMinuteX.length);
if (panelHeight > 0 && panelWidth > 0) {
centreX = panelWidth / 2;
centreY = panelHeight / 2;
} else {
centreX = centreY = size / 2;
}
}
use of java.awt.Polygon in project processdash by dtuma.
the class RangeXYItemRenderer method drawItemRangeGradient.
private void drawItemRangeGradient(Graphics2D g2, Line2D line, Paint paint, Stroke stroke, double x2, double y2, double x3, double y3) {
Line2D edge1, edge2, mainLine;
Polygon fillArea;
Stroke mainLineStroke, edgeLineStroke;
Paint mainLinePaint, edgeLinePaint, fillPaint;
double x0 = line.getX1();
double y0 = line.getY1();
double x1 = line.getX2();
double y1 = line.getY2();
mainLine = new Line2D.Double(x0, y0, x1, y1);
edge1 = new Line2D.Double(x0, y0, x2, y2);
edge2 = new Line2D.Double(x0, y0, x3, y3);
fillArea = new Polygon();
fillArea.addPoint((int) Math.round(x0), (int) Math.round(y0));
fillArea.addPoint((int) Math.round(x2), (int) Math.round(y2));
fillArea.addPoint((int) Math.round(x3), (int) Math.round(y3));
mainLinePaint = paint;
if (mainLinePaint instanceof Color) {
Color c = (Color) mainLinePaint;
Color dark = transp(c, calcAlpha(c));
Color light = transp(c, 0.01);
edgeLinePaint = fillPaint = c;
try {
fillPaint = new GradientPaint(gradientStart(x0, y0, x1, y1, x2, y2, x3, y3), light, new Point2D.Double(x1, y1), dark, true);
} catch (Exception e) {
}
} else {
edgeLinePaint = fillPaint = mainLinePaint;
}
if (stroke instanceof BasicStroke) {
float lineWidth = ((BasicStroke) stroke).getLineWidth();
edgeLineStroke = new BasicStroke(lineWidth / 4);
mainLineStroke = new BasicStroke(lineWidth * 2);
} else {
mainLineStroke = edgeLineStroke = stroke;
}
g2.setPaint(fillPaint);
g2.fill(fillArea);
g2.fill(fillArea);
g2.setStroke(edgeLineStroke);
g2.setPaint(edgeLinePaint);
g2.draw(edge1);
g2.draw(edge2);
g2.setStroke(mainLineStroke);
g2.setPaint(mainLinePaint);
g2.draw(mainLine);
}
use of java.awt.Polygon in project vcell by virtualcell.
the class Edge method getArrow.
protected Polygon getArrow() {
int dX = _to.X() - _from.X();
int dY = _to.Y() - _from.Y();
double len = Math.sqrt(dX * dX + dY * dY);
double ndx = _dir * arrowSize * dX / len;
double ndy = _dir * arrowSize * dY / len;
double cx = (_to.X() + _from.X()) / 2;
double cy = (_to.Y() + _from.Y()) / 2;
Polygon tmp = new Polygon();
tmp.addPoint((int) (cx - ndy), (int) (cy + ndx));
tmp.addPoint((int) (cx + ndx), (int) (cy + ndy));
tmp.addPoint((int) (cx + ndy), (int) (cy - ndx));
tmp.addPoint((int) (cx - ndy), (int) (cy + ndx));
return tmp;
}
use of java.awt.Polygon in project knime-core by knime.
the class ParallelCoordinatesViewPanel method drawingPolygon.
/**
* Comment for <code>drawingPolygon</code> drawing polygon representing
* the part of a row between two coordinates col and col + 1.
*/
private void drawingPolygon(final Color c, final int size, final int col, final int lPMinDY, final int lPMaxDY, final int cPMaxDY, final int cPMinDY, final Graphics2D g2d) {
Color oldColor = g2d.getColor();
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));
g2d.setColor(c);
int // lastPointDimensionX
lPDX, // currentPointDimensionX
cPDX;
cPDX = (col + 1) * m_distanceBetweenCoordinates;
lPDX = col * m_distanceBetweenCoordinates;
Polygon p = new Polygon();
p.addPoint(lPDX, lPMinDY - size / 2);
p.addPoint(lPDX, lPMaxDY + size / 2);
p.addPoint(cPDX, cPMaxDY + size / 2);
p.addPoint(cPDX, cPMinDY - size / 2);
g2d.fillPolygon(p);
g2d.drawPolygon(p);
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f));
drawPointAsRectangle(cPDX, cPMinDY, g2d);
drawPointAsRectangle(cPDX, cPMaxDY, g2d);
drawPointAsRectangle(lPDX, lPMinDY, g2d);
drawPointAsRectangle(lPDX, lPMaxDY, g2d);
g2d.setColor(oldColor);
}
Aggregations