Example usage for java.awt Graphics fillPolygon

List of usage examples for java.awt Graphics fillPolygon

Introduction

In this page you can find the example usage for java.awt Graphics fillPolygon.

Prototype

public abstract void fillPolygon(int[] xPoints, int[] yPoints, int nPoints);

Source Link

Document

Fills a closed polygon defined by arrays of x and y coordinates.

Usage

From source file:Main.java

public void paint(Graphics g) {
    int xpoints[] = { 25, 145, 25, 145, 25 };
    int ypoints[] = { 25, 25, 145, 145, 25 };
    int npoints = 5;

    g.fillPolygon(xpoints, ypoints, npoints);

}

From source file:MainClass.java

public void paint(Graphics g) {
    int xpoints[] = { 25, 145, 25, 145, 25 };
    int ypoints[] = { 25, 25, 145, 145, 25 };
    int npoints = 5;

    g.fillPolygon(xpoints, ypoints, npoints);
}

From source file:components.ArrowIcon.java

public void paintIcon(Component c, Graphics g, int x, int y) {
    if (c.isEnabled()) {
        g.setColor(c.getForeground());// w ww.j a v a 2  s . com
    } else {
        g.setColor(Color.gray);
    }

    g.translate(x, y);
    g.fillPolygon(xPoints, yPoints, xPoints.length);
    g.translate(-x, -y); //Restore graphics object
}

From source file:MainClass.java

public void paint(Graphics g) {
    int n = 3;//ww w  .  ja  v a  2  s .co  m
    int xdata[] = new int[n];
    int ydata[] = new int[n];
    xdata[0] = 50;
    ydata[0] = 150;
    xdata[1] = 200;
    ydata[1] = 50;
    xdata[2] = 350;
    ydata[2] = 150;
    int rgb = Color.HSBtoRGB(1.0f, 1.0f, 1.0f);
    g.setColor(new Color(rgb));
    g.fillPolygon(xdata, ydata, n);

}

From source file:CustomIconDemo.java

public void paintIcon(Component c, Graphics g, int x, int y) {
    if (c.isEnabled()) {
        g.setColor(c.getForeground());// w w w . j av  a 2  s .  co  m
    } else {
        g.setColor(Color.gray);
    }

    g.translate(x, y);
    g.fillPolygon(xPoints, yPoints, xPoints.length);
    g.translate(-x, -y); // Restore graphics object
}

From source file:Arrow.java

public void paintIcon(Component c, Graphics g, int x, int y) {
    Color color = c == null ? Color.GRAY : c.getBackground();

    int dx = (int) (size / 2);
    int dy = descending ? dx : -dx;

    // Align icon (roughly) with font baseline.
    y = y + 5 * size / 6 + (descending ? -dy : 0);

    g.translate(x, y);/*from   www. j  av a 2  s  . c  o m*/
    g.setColor(Color.GRAY);
    g.fillPolygon(new int[] { dx / 2, dx, 0 }, new int[] { dy, 0, 0 }, 3);
    g.translate(-x, -y);
    g.setColor(color);
}

From source file:CustomIconDemo.java

public void paintIcon(Component c, Graphics g, int x, int y) {
    int length = xPoints.length;
    int adjustedXPoints[] = new int[length];
    int adjustedYPoints[] = new int[length];

    for (int i = 0; i < length; i++) {
        adjustedXPoints[i] = xPoints[i] + x;
        adjustedYPoints[i] = yPoints[i] + y;
    }// www  .  j  av  a 2s  .  co  m

    if (c.isEnabled()) {
        g.setColor(Color.black);
    } else {
        g.setColor(Color.gray);
    }

    g.fillPolygon(adjustedXPoints, adjustedYPoints, length);
}

From source file:com.cburch.draw.shapes.Poly.java

@Override
public void paint(Graphics g, HandleGesture gesture) {
    List<Handle> hs = getHandles(gesture);
    int[] xs = new int[hs.size()];
    int[] ys = new int[hs.size()];
    int i = -1;//from w  w w .  j a  v  a2  s . c o m
    for (Handle h : hs) {
        i++;
        xs[i] = h.getX();
        ys[i] = h.getY();
    }

    if (setForFill(g)) {
        g.fillPolygon(xs, ys, xs.length);
    }
    if (setForStroke(g)) {
        if (closed)
            g.drawPolygon(xs, ys, xs.length);
        else
            g.drawPolyline(xs, ys, xs.length);
    }
}

From source file:org.esa.snap.graphbuilder.rcp.dialogs.support.GraphNode.java

/**
 * Draws the hotspot where the user can join the node to a source node
 *
 * @param g   The Java2D Graphics/*from  w w w  . j  ava2  s .c  o m*/
 * @param col The color to draw
 */
public void drawTailHotspot(final Graphics g, final Color col) {
    final Point p = displayPosition;
    g.setColor(col);

    final int x = p.x + nodeWidth;
    final int y = p.y + halfNodeHeight;
    final int[] xpoints = { x, x + hotSpotOffset, x, x };
    final int[] ypoints = { y - halfHotSpotSize, y, y + halfHotSpotSize, y - halfHotSpotSize };
    g.fillPolygon(xpoints, ypoints, xpoints.length);
}

From source file:org.kalypso.kalypsomodel1d2d.ui.map.grid.LinePointCollector.java

public void paint(final Graphics g, final GeoTransform projection, final GM_Point currentPoint,
        final int pointRectSize) {
    // IMPORTANT: we remeber GM_Points (not Point's) and retransform them for painting
    // because the projection depends on the current map-extent, so this builder
    // is stable in regard to zoom in/out
    if (!m_points.isEmpty()) {
        if (m_isSelected) {
            final int[][] points = getPointArrays(projection, null);
            final int[][] polygonPoints = toPolygonPoints(points, highlightDeltaX);

            g.drawPolygon(polygonPoints[0], polygonPoints[1], polygonPoints[0].length);
            g.fillPolygon(polygonPoints[0], polygonPoints[1], polygonPoints[0].length);

            drawHandles(g, points[0], points[1], pointRectSize, m_selection);
        } else {/*from   w  w w.j a  v a2s .  co  m*/
            // draw a line
            final int[][] points = getPointArrays(projection, currentPoint);
            final int[] arrayX = points[0];
            final int[] arrayY = points[1];

            /* Paint a linestring. */
            g.drawPolyline(arrayX, arrayY, arrayX.length);

            drawHandles(g, arrayX, arrayY, pointRectSize, m_selection);
        }
    }
}