Example usage for java.awt Graphics drawOval

List of usage examples for java.awt Graphics drawOval

Introduction

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

Prototype

public abstract void drawOval(int x, int y, int width, int height);

Source Link

Document

Draws the outline of an oval.

Usage

From source file:org.esa.nest.dat.views.polarview.PolarCanvas.java

private void draw(Graphics g, Dimension size) {
    final int annotationHeight = 100;
    final int x = Math.max((int) (size.height * 0.05), 10);
    final int y = Math.max((int) (size.width * 0.05), 10);
    final int bottom = Math.max((int) (size.height * 0.1) + annotationHeight, 20);
    final int right = Math.max((int) (size.width * 0.1), 20);
    final Rectangle r = positionPlot(size, x, y, bottom, right);
    plotRadius = Math.min(r.width / 2, r.height / 2);
    final Dimension quadrantSize = new Dimension(plotRadius, plotRadius);
    g.translate(0, origin.y + r.height);
    if (data != null) {
        loadColorBar(data.getColorScale());
        drawColorBar(g, colourAxis);// w  ww  .java 2  s  .c o m
    }
    g.translate(0, -origin.y - r.height);

    origin.y += r.height / 2;
    origin.x += r.width / 2;
    final Graphics graphics = g.create();
    graphics.translate(origin.x, origin.y);
    radialAxis.setSize(quadrantSize);
    if (data != null)
        data.draw(graphics);
    if (rings != null) {
        int ri = 0;
        for (double ring : rings) {
            final int rad = radialAxis.getScreenPoint(ring);
            final int rad2 = rad + rad;
            graphics.setColor(Color.lightGray);
            graphics.drawOval(-rad, -rad, rad2, rad2);
            if (ringText != null && ringText[ri] != null) {
                graphics.setColor(Color.black);
                graphics.drawString(ringText[ri], 0, -rad);
            }
            ++ri;
        }
    } else {
        radialAxis.draw(graphics);
    }

    // draw wind direction & speed
    if (showWindDirection)
        drawWindDirection(graphics, plotRadius, windDirection - 90);

    graphics.translate(-origin.x, -origin.y);

    drawAxisLabels(graphics);

    graphics.dispose();
}

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/* w  ww  . j a  v a  2s .  c o m*/
 * @param col The color to draw
 */
public void drawHeadHotspot(final Graphics g, final Color col) {
    final Point p = displayPosition;
    g.setColor(col);
    g.drawOval(p.x - halfHotSpotSize, p.y + hotSpotOffset, hotSpotSize, hotSpotSize);
}

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

private static final void drawHandles(final Graphics g, final int[] x, final int[] y, final int pointRectWidth,
        final int selection) {
    final Color oldColor = g.getColor();
    g.setColor(oldColor.darker());/*w  ww  .jav  a 2  s . co  m*/
    // int sizeOuter = 4;
    final int halfRectWidth = pointRectWidth / 2;

    if (selection < 0) {
        for (int i = 0; i < y.length; i++) {
            g.drawRect(x[i] - halfRectWidth, y[i] - halfRectWidth, pointRectWidth, pointRectWidth);
        }
    } else {
        int i;
        for (i = 0; i < selection; i++) {
            g.drawRect(x[i] - halfRectWidth, y[i] - halfRectWidth, pointRectWidth, pointRectWidth);
        }
        // is is now selection
        g.drawOval(x[i] - pointRectWidth, y[i] - pointRectWidth, pointRectWidth + pointRectWidth,
                pointRectWidth + pointRectWidth);
        i++;
        for (; i < y.length; i++) {
            g.drawRect(x[i] - halfRectWidth, y[i] - halfRectWidth, pointRectWidth, pointRectWidth);
        }
    }
    g.setColor(oldColor);
}

From source file:org.kineticsystem.commons.layout.TetrisLayout.java

/**
 * <p>This method draws the layout on a graphics context. Used to test the
 * layout during the design process. Override the 
 * <code>paint(Graphics g)</code> of the container to display the layout.
 * Here is an example code where <code>layout</code> is a 
 * <code>TestrisLayout</code>.</p>
 * <pre>// w  ww. j  av a2  s  .  co  m
 * JPanel panel = new JPanel(layout) {
 *     public void paint(Graphics g) {
 *         super.paint(g);
 *         ((TetrisLayout) getLayout()).drawLayout(g);
 *     }
 * };
 * </pre>
 * @param g The graphics context.
 */
public void drawLayout(Graphics g) {

    // Draw the spanning layout.

    g.setColor(spanningLayoutColor);

    Insets insets = container.getInsets();
    Dimension size = container.getSize();

    int actualGapFreeWidth = Math
            .max(size.width - insets.left - insets.right - cGaps[cBars.length].getIncSize(), 0);
    int actualGapFreeHeight = Math
            .max(size.height - insets.top - insets.bottom - rGaps[rBars.length].getIncSize(), 0);

    for (Cell cell : constraintsMap.values()) {

        if (cell != null) {

            /*
             * Calculate the center of the first and the last cell spanned
             * by the current component.
             */

            int cx0 = (int) Math.round((cSizes[cell.getCol()].evaluate(actualGapFreeWidth)
                    + cSizes[cell.getCol() + 1].evaluate(actualGapFreeWidth)) / 2);
            int cy0 = (int) Math.round((rSizes[cell.getRow()].evaluate(actualGapFreeHeight)
                    + rSizes[cell.getRow() + 1].evaluate(actualGapFreeHeight)) / 2);
            int cx1 = (int) Math.round((cSizes[cell.getCol() + cell.getCols()].evaluate(actualGapFreeWidth)
                    + cSizes[cell.getCol() + cell.getCols() - 1].evaluate(actualGapFreeWidth)) / 2) + 1;
            int cy1 = (int) Math.round((rSizes[cell.getRow() + cell.getRows()].evaluate(actualGapFreeHeight)
                    + rSizes[cell.getRow() + cell.getRows() - 1].evaluate(actualGapFreeHeight)) / 2) + 1;

            // Actual cell dimension.

            int w = cx1 - cx0;
            int h = cy1 - cy0;

            // Component position correction.

            int xCorrection = insets.left + cGaps[cell.getCol()].getIncSize();
            int yCorrection = insets.top + rGaps[cell.getRow()].getIncSize();

            // Component dimension correction.

            int wCorrection = cGaps[cell.getCol() + cell.getCols() - 1].getIncSize()
                    - cGaps[cell.getCol()].getIncSize();
            int hCorrection = rGaps[cell.getRow() + cell.getRows() - 1].getIncSize()
                    - rGaps[cell.getRow()].getIncSize();

            cx0 += xCorrection;
            cy0 += yCorrection;
            w += wCorrection;
            h += hCorrection;

            int radius = 6;
            g.drawRect(cx0 + 1, cy0 + 1, w - 1, h - 1);
            g.drawOval(cx0 + 1 - radius / 2, cy0 + 1 - radius / 2, radius, radius);
            g.drawOval(cx0 + w - radius / 2, cy0 + h - radius / 2, radius, radius);
        }
    }

    // Draw the internal layout.

    g.setColor(internalLayoutColor);

    int x2 = (int) Math.round(cSizes[cSizes.length - 1].evaluate(actualGapFreeWidth)
            + cGaps[cSizes.length - 1].getIncSize() + insets.left) - 1;
    int y2 = (int) Math.round(rSizes[rSizes.length - 1].evaluate(actualGapFreeHeight)
            + rGaps[rSizes.length - 1].getIncSize() + insets.top) - 1;

    for (int i = 1; i < cSizes.length - 1; i++) {
        int x = (int) Math
                .round(cSizes[i].evaluate(actualGapFreeWidth) + insets.left + cGaps[i - 1].getIncSize());
        g.drawLine(x, insets.top, x, y2);
        g.drawLine(x + cGaps[i].getSize(), insets.top, x + cGaps[i].getSize(), y2);
    }
    for (int i = 1; i < rSizes.length - 1; i++) {
        int y = (int) Math
                .round(rSizes[i].evaluate(actualGapFreeHeight) + insets.top + rGaps[i - 1].getIncSize());
        g.drawLine(insets.left, y, x2, y);
        g.drawLine(insets.left, y + rGaps[i].getSize(), x2, y + rGaps[i].getSize());
    }

    // Draw the layout internal frame.

    g.setColor(externalLayoutColor);
    g.drawRect(insets.left, insets.top, x2 - insets.left, y2 - insets.top);

    // Draw layout external frame.

    g.drawRect(0, 0, x2 + insets.right, y2 + insets.bottom);
}

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

/**
 * convenience method for internal use. paints a log item handle
 * visualization.//from   w  w  w .  j  a  v  a2s. 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.//from  w  ww  . java  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./*from  w  w w. j  a  va2s.co 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_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);
    }
}