Java Graphics Draw drawRTriangle(Graphics g, Color color, int x, int y, int r)

Here you can find the source of drawRTriangle(Graphics g, Color color, int x, int y, int r)

Description

draw R Triangle

License

Apache License

Declaration

public static void drawRTriangle(Graphics g, Color color, int x, int y, int r) 

Method Source Code

//package com.java2s;
/**//from   ww w .  j a  va2s  . com
 * 
 * Copyright 2008 - 2009
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 * 
 * @project loon
 * @author cping
 * @email?javachenpeng@yahoo.com
 * @version 0.1
 */

import java.awt.Color;

import java.awt.Graphics;

public class Main {

    public static void drawRTriangle(Graphics g, Color color, int x, int y, int r) {
        int x1 = x;
        int y1 = y + r;
        int x2 = x - (int) (r * Math.cos(Math.PI / 6.0));
        int y2 = y - (int) (r * Math.sin(Math.PI / 6.0));
        int x3 = x + (int) (r * Math.cos(Math.PI / 6.0));
        int y3 = y - (int) (r * Math.sin(Math.PI / 6.0));
        int[] xpos = new int[3];
        xpos[0] = x1;
        xpos[1] = x2;
        xpos[2] = x3;
        int[] ypos = new int[3];
        ypos[0] = y1;
        ypos[1] = y2;
        ypos[2] = y3;
        g.setColor(color);
        g.fillPolygon(xpos, ypos, 3);
    }
}

Related

  1. drawPaintedShape(Graphics2D graphics, Shape shape, Paint paint, Rectangle2D paintBounds, Stroke stroke)
  2. drawPowerScaleLabel(Graphics g, int base, int power, int x, int y, boolean yAxisP)
  3. drawProgressBar(Graphics2D g, final int x, final int y, final int width, final int height, final Color main, final Color progress, final int alpha, final int percentage)
  4. drawRainbow(Graphics2D g2, int x, int y, int Width, int Height, int Mode)
  5. drawRequiredMarker(Graphics2D g2, int x, int y, int iconSize)
  6. drawScaleTick(Graphics g, int x, int y, boolean yAxisP, int length)
  7. drawScrollBar(Graphics g, int which, int direction, int x, int y, int fmWidth, int fmHeight, Color fg, Color bg)
  8. drawSelectionBox(Graphics g)
  9. drawSelectionPoint(Graphics g, Point p)