Example usage for java.awt Graphics drawPolygon

List of usage examples for java.awt Graphics drawPolygon

Introduction

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

Prototype

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

Source Link

Document

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

Usage

From source file:org.kalypso.ogc.gml.map.widgets.builders.RectangleGeometryBuilder.java

/**
 * @see org.kalypso.informdss.manager.util.widgets.IGeometryBuilder#paint(java.awt.Graphics, org.kalypsodeegree.graphics.transformation.GeoTransform)
 *//*from   w  ww . j a v  a2s .co m*/
@Override
public void paint(final Graphics g, final GeoTransform projection, final Point currentPoint) {
    if (m_startPoint != null) {
        final int[][] points = getPointArrays(projection, currentPoint);

        final int[] arrayX = points[0];
        final int[] arrayY = points[1];

        /* Paint a polygon. */
        g.drawPolygon(arrayX, arrayY, arrayX.length);
        drawHandles(g, arrayX, arrayY);
    }

    m_renderer.paint(g);
}

From source file:org.processmining.analysis.performance.dottedchart.ui.DottedChartPanel.java

/**
 * convenience method for internal use. paints a log item handle
 * visualization.// w w  w .j  a va  2  s.c o  m
 * 
 * @param x
 *            horizontal anchor coordinate of the handle
 * @param y
 *            vertical anchor coordinate of the handle
 * @param g
 *            the Graphics object used for painting
 */
protected void paintItem(int x, int y, Graphics g, String shape) {
    if (shape.equals(STR_NONE)) {
        return;
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DOT)) {
        g.fillOval(x - 2, y - 2, 4, 4);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_BOX)) {
        g.fill3DRect(x - 5, y - 5, 10, 10, false);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_CIRCLE)) {
        g.fillOval(x - 5, y - 5, 11, 11);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_RHOMBUS)) {
        int rhombX[] = { x, x - 5, x, x + 5 };
        int rhombY[] = { y - 5, y, y + 5, y };
        g.fillPolygon(rhombX, rhombY, 4);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_TRIANGLE)) {
        int triX[] = { x, x - 5, x + 5 };
        int triY[] = { y + 5, y - 5, y - 5 };
        g.fillPolygon(triX, triY, 3);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_ROUND_BOX)) {
        g.fillRoundRect(x - 5, y - 5, 10, 10, 2, 2);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_BOX)) {
        g.drawRect(x - 5, y - 5, 10, 10);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_CIRCLE)) {
        g.drawOval(x - 5, y - 5, 11, 11);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_RHOMBUS)) {
        int rhombX[] = { x, x - 5, x, x + 5 };
        int rhombY[] = { y - 5, y, y + 5, y };
        g.drawPolygon(rhombX, rhombY, 4);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_TRIANGLE)) {
        int triX[] = { x, x - 5, x + 5 };
        int triY[] = { y + 5, y - 5, y - 5 };
        g.drawPolygon(triX, triY, 3);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_ROUND_BOX)) {
        g.drawRoundRect(x - 5, y - 5, 10, 10, 2, 2);
    }
}

From source file:org.processmining.analysis.performance.dottedchart.ui.DottedChartPanel.java

/**
 * convenience method for internal use. paints a log item handle
 * visualization.// w ww . j  a  va 2  s  . c  om
 * 
 * @param x
 *            horizontal anchor coordinate of the handle
 * @param y
 *            vertical anchor coordinate of the handle
 * @param g
 *            the Graphics object used for painting
 */
protected void paintHighligtedItem(int x, int y, Graphics g, String shape) {
    Color color = g.getColor();
    if (shape.equals(STR_NONE)) {
        return;
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DOT)) {
        if (!color.equals(Color.red))
            g.setColor(Color.red);
        else
            g.setColor(Color.black);
        g.fillOval(x - 3, y - 3, 6, 6);
        g.setColor(color);
        g.fillOval(x - 2, y - 2, 4, 4);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_BOX)) {
        if (!color.equals(Color.black))
            g.setColor(Color.black);
        else
            g.setColor(Color.red);
        g.fillRect(x - 6, y - 6, 12, 12);
        g.setColor(color);
        g.fill3DRect(x - 5, y - 5, 10, 10, false);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_CIRCLE)) {
        if (!color.equals(Color.black))
            g.setColor(Color.black);
        else
            g.setColor(Color.red);
        g.fillOval(x - 6, y - 6, 13, 13);
        g.setColor(color);
        g.fillOval(x - 5, y - 5, 11, 11);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_RHOMBUS)) {
        int rhombX[] = { x, x - 5, x, x + 5 };
        int rhombY[] = { y - 5, y, y + 5, y };
        g.fillPolygon(rhombX, rhombY, 4);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_TRIANGLE)) {
        int triX[] = { x, x - 5, x + 5 };
        int triY[] = { y + 5, y - 5, y - 5 };
        g.fillPolygon(triX, triY, 3);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_ROUND_BOX)) {
        if (!color.equals(Color.black))
            g.setColor(Color.black);
        else
            g.setColor(Color.red);
        g.fillRoundRect(x - 6, y - 6, 13, 13, 2, 2);
        g.setColor(color);
        g.fillRoundRect(x - 5, y - 5, 10, 10, 2, 2);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_BOX)) {
        g.drawRect(x - 5, y - 5, 10, 10);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_CIRCLE)) {
        if (!color.equals(Color.black))
            g.setColor(Color.black);
        else
            g.setColor(Color.red);
        g.fillOval(x - 6, y - 6, 13, 13);
        g.setColor(color);
        g.drawOval(x - 5, y - 5, 11, 11);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_RHOMBUS)) {
        int rhombX[] = { x, x - 5, x, x + 5 };
        int rhombY[] = { y - 5, y, y + 5, y };
        g.drawPolygon(rhombX, rhombY, 4);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_TRIANGLE)) {
        int triX[] = { x, x - 5, x + 5 };
        int triY[] = { y + 5, y - 5, y - 5 };
        g.drawPolygon(triX, triY, 3);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_ROUND_BOX)) {
        g.drawRoundRect(x - 5, y - 5, 10, 10, 2, 2);
    }
}

From source file:org.processmining.analysis.performance.dottedchart.ui.DottedChartPanel.java

/**
 * convenience method for internal use. paints a log item handle
 * visualization.//w  w  w .j a v a2  s. com
 * 
 * @param x
 *            horizontal anchor coordinate of the handle
 * @param y
 *            vertical anchor coordinate of the handle
 * @param g
 *            the Graphics object used for painting
 */
protected void paintItem_buffer(int x, int y, Graphics g, String shape) {
    if (shape.equals(STR_NONE)) {
        return;
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DOT)) {
        g.fillOval(x - 2, y - 2, 7, 7);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_BOX)) {
        g.fill3DRect(x - 3, y - 3, 6, 6, false);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_CIRCLE)) {
        g.fillOval(x - 2, y - 2, 7, 7);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_RHOMBUS)) {
        int rhombX[] = { x, x - 3, x, x + 3 };
        int rhombY[] = { y - 3, y, y + 3, y };
        g.fillPolygon(rhombX, rhombY, 4);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_TRIANGLE)) {
        int triX[] = { x, x - 3, x + 3 };
        int triY[] = { y + 3, y - 3, y - 3 };
        g.fillPolygon(triX, triY, 3);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_ROUND_BOX)) {
        g.fillRoundRect(x - 3, y - 3, 6, 6, 2, 2);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_BOX)) {
        g.drawRect(x - 3, y - 3, 6, 6);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_CIRCLE)) {
        g.drawOval(x - 2, y - 2, 7, 7);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_RHOMBUS)) {
        int rhombX[] = { x, x - 3, x, x + 3 };
        int rhombY[] = { y - 3, y, y + 3, y };
        g.drawPolygon(rhombX, rhombY, 4);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_TRIANGLE)) {
        int triX[] = { x, x - 3, x + 3 };
        int triY[] = { y + 3, y - 3, y - 3 };
        g.drawPolygon(triX, triY, 3);
    } else if (shape.equals(DottedChartPanel.ITEM_HANDLE_DRAW_ROUND_BOX)) {
        g.drawRoundRect(x - 3, y - 3, 6, 6, 2, 2);
    }
}