Java Code Examples for java.awt.Graphics2D#fillPolygon()

The following examples show how to use java.awt.Graphics2D#fillPolygon() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Plot.java    From simple-java-plot with MIT License 7 votes vote down vote up
private void drawMarker(Graphics2D g, int halfMarkerSize, int halfDiagMarkerSize, double x2, double y2, double x3, double y3) {
	switch (opts.marker) {
	case CIRCLE:
		g.setColor(opts.markerColor);
		g.fillOval(toInt(x2 - halfMarkerSize), toInt(y2 - halfMarkerSize), opts.markerSize, opts.markerSize);
		g.setColor(opts.seriesColor);
		g.drawOval(toInt(x2 - halfMarkerSize), toInt(y2 - halfMarkerSize), opts.markerSize, opts.markerSize);
		break;
	case SQUARE:
		g.setColor(opts.markerColor);
		g.fillRect(toInt(x2 - halfMarkerSize), toInt(y2 - halfMarkerSize), opts.markerSize, opts.markerSize);
		g.setColor(opts.seriesColor);
		g.drawRect(toInt(x2 - halfMarkerSize), toInt(y2 - halfMarkerSize), opts.markerSize, opts.markerSize);							
		break;
	case DIAMOND:
		int[] xpts = { toInt(x2), toInt(x2 + halfDiagMarkerSize), toInt(x2), toInt(x2 - halfDiagMarkerSize) };
		int[] ypts = { toInt(y2 - halfDiagMarkerSize), toInt(y2), toInt(y2 + halfDiagMarkerSize), toInt(y2) };
		g.setColor(opts.markerColor);
		g.fillPolygon(xpts, ypts, 4);
		g.setColor(opts.seriesColor);
		g.drawPolygon(xpts, ypts, 4);
		break;
	case COLUMN:
		g.setColor(opts.markerColor);
		g.fillRect(toInt(x2), toInt(y2), opts.markerSize, toInt(y3 - y2));
		g.setColor(opts.seriesColor);
		g.drawRect(toInt(x2), toInt(y2), opts.markerSize, toInt(y3 - y2));
		break;
	case BAR:
		g.setColor(opts.markerColor);
		g.fillRect(toInt(x3), toInt(y2), toInt(x2 - x3), opts.markerSize);
		g.setColor(opts.seriesColor);
		g.drawRect(toInt(x3), toInt(y2), toInt(x2 - x3), opts.markerSize);				
		break;
	default:
	} 
}
 
Example 2
Source File: TerritoryDrawable.java    From triplea with GNU General Public License v3.0 6 votes vote down vote up
protected static void draw(
    final Rectangle bounds,
    final Graphics2D graphics,
    final MapData mapData,
    final Territory territory,
    final Paint territoryPaint) {
  final List<Polygon> polygons = mapData.getPolygons(territory);
  for (final Polygon polygon : polygons) {
    if (!polygon.intersects(bounds) && !polygon.contains(bounds)) {
      continue;
    }

    final Polygon translatedPolygon = Util.translatePolygon(polygon, -bounds.x, -bounds.y);
    graphics.setPaint(territoryPaint);
    graphics.fillPolygon(translatedPolygon);
    graphics.setColor(Color.BLACK);
    graphics.drawPolygon(translatedPolygon);
  }
}
 
Example 3
Source File: NestedHierarchicalDisplayPanel.java    From constellation with Apache License 2.0 5 votes vote down vote up
@Override
public void paintComponent(Graphics g) {
    if (lines == null) {
        return;
    }

    Graphics2D g2 = (Graphics2D) g;
    g2.setBackground(new Color(44, 44, 44));
    g2.clearRect(0, 0, getWidth(), getHeight());

    // Draw each line.
    g2.setColor(Color.blue);
    for (int i = 0; i < lines.size(); i++) {
        g2.setColor(lines.get(i).color);
        // horizontal line
        g2.fillRect(HORIZONTAL_BORDER_SIZE, VERTICAL_GAP + lines.get(i).ystart, lines.get(i).xstop, lineThickness);
        // vertical line
        g2.fillRect(HORIZONTAL_BORDER_SIZE + lines.get(i).xstop, VERTICAL_GAP + lines.get(i).ystop, lineThickness, lines.get(i).ystart - lines.get(i).ystop + lineThickness);
    }

    g2.setColor(new Color(0xB0, 0xB0, 0xB0));
    int arrowTop = scrollManager.getViewport().getViewPosition().y;
    int arrowBottom = arrowTop + Math.min(neededHeight, scrollManager.getViewport().getExtentSize().height);
    int[] xpoints = {progress_x - 6, progress_x + 8, progress_x + 1};
    int[] ypoints_top = {arrowTop, arrowTop, arrowTop + 10};
    int[] ypoints_bottom = {arrowBottom, arrowBottom, arrowBottom - 10};
    g2.fillPolygon(xpoints, ypoints_top, 3);
    g2.fillPolygon(xpoints, ypoints_bottom, 3);
    g2.setColor(new Color(0xB0, 0xB0, 0xB0, 130));
    g2.fillRect(progress_x, 0, progressBarThickness, neededHeight);
}
 
Example 4
Source File: TMAbstractEdge.java    From ontopia with Apache License 2.0 5 votes vote down vote up
protected void paintBowTie(Graphics2D g) {
  double x1 = from.drawx;
  double x2 = to.drawx;
  double y1 = from.drawy;
  double y2 = to.drawy;

  double midx = calculateMidPointBetween(x1, x2);
  double midy = calculateMidPointBetween(y1, y2);

  Dimension offset = calculateOffset(x1, x2, y1, y2, getLineWeight());

  g.setColor(getColor());

  int xPoints[] = new int[3];
  xPoints[0] = (int) midx;
  int yPoints[] = new int[3];
  yPoints[0] = (int) midy;

  xPoints[1] = (int) (x1 - offset.width);
  yPoints[1] = (int) (y1 + offset.height);
  xPoints[2] = (int) (x1 + offset.width);
  yPoints[2] = (int) (y1 - offset.height);

  g.fillPolygon(xPoints, yPoints, 3);

  xPoints[1] = (int) (x2 - offset.width);
  yPoints[1] = (int) (y2 + offset.height);
  xPoints[2] = (int) (x2 + offset.width);
  yPoints[2] = (int) (y2 - offset.height);

  g.fillPolygon(xPoints, yPoints, 3);

  g.drawLine((int) x1, (int) y1, (int) x2, (int) y2);

}
 
Example 5
Source File: SimpleTextPaneResizeable.java    From wandora with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Paint the text area
 */
@Override
protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D graphics = (Graphics2D)g;
    if(inTheTriangleZone) {
        graphics.setColor(new Color(0.5f,0.5f,0.5f,0.75f));
    }
    else {
        graphics.setColor(new Color(0.5f,0.5f,0.5f,0.2f));
    }
    graphics.fillPolygon(getTriangle());
}
 
Example 6
Source File: Test8004821.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void test(final Graphics2D g, final int[] arr) {
    g.drawPolygon(arr, arr, arr.length);
    g.drawPolygon(new Polygon(arr, arr, arr.length));
    g.fillPolygon(arr, arr, arr.length);
    g.fillPolygon(new Polygon(arr, arr, arr.length));
    g.drawPolyline(arr, arr, arr.length);
}
 
Example 7
Source File: Test8004821.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void test(final Graphics2D g, final int[] arr) {
    g.drawPolygon(arr, arr, arr.length);
    g.drawPolygon(new Polygon(arr, arr, arr.length));
    g.fillPolygon(arr, arr, arr.length);
    g.fillPolygon(new Polygon(arr, arr, arr.length));
    g.drawPolyline(arr, arr, arr.length);
}
 
Example 8
Source File: UnusedSpaceImageRenderer.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void render(
	JasperReportsContext jasperReportsContext,
	Graphics2D grx, 
	Rectangle2D rectangle
	) throws JRException
{
	Graphics2D graphics = (Graphics2D) grx.create();
	try
	{
		graphics.translate(rectangle.getX(), rectangle.getY());
		graphics.setColor(FILL);
		
		if (clip != null)
		{
			graphics.clip(clip);
		}
		
		int width = (int) rectangle.getWidth();
		int limit = width + (int) rectangle.getHeight();
		int increment = lineGap + lineWidth;
		int reverseOffset = (width - 4 * lineWidth / 3) % increment;
		for (int x = 0; x <= limit; x += increment)
		{
			graphics.fillPolygon(
					new int[]{x, x + lineWidth, 0, 0},
					new int[]{0, 0, x + lineWidth, x},
					4);

			graphics.fillPolygon(
					new int[]{width - x - reverseOffset, width - x - lineWidth - reverseOffset, width, width},
					new int[]{0, 0, x + lineWidth, x},
					4);
		}
	}
	finally
	{
		graphics.dispose();
	}
}
 
Example 9
Source File: VGDLSprite.java    From GVGAI_GYM with Apache License 2.0 5 votes vote down vote up
/**
 * In case this sprite is oriented and has an arrow to draw, it draws it.
 * @param g graphics device to draw in.
 */
public void _drawOriented(Graphics2D g, Rectangle r)
{
    Color arrowColor = new Color(color.getRed(), 255-color.getGreen(), color.getBlue());
    Polygon p = Utils.triPoints(r, orientation);

    // Rotation information

    if(shrinkfactor != 1)
    {
        r.width *= shrinkfactor;
        r.height *= shrinkfactor;
        r.x += (rect.width-r.width)/2;
        r.y += (rect.height-r.height)/2;
    }

    int w = image.getWidth(null);
    int h = image.getHeight(null);
    float scale = (float)r.width/w; //assume all sprites are quadratic.

    AffineTransform trans = new AffineTransform();
    trans.translate(r.x, r.y);
    trans.scale(scale,scale);
    trans.rotate(rotation,w/2.0,h/2.0);
    // Uncomment this line to have only one sprite
    //g.drawImage(image, trans, null);

    /* Code added by Carlos*/
    g.drawImage(image, trans, null);
    /* End of code added by carlos*/

    // We only draw the arrow if the directional sprites are null
    if (draw_arrow) {
        g.setColor(arrowColor);
        g.drawPolygon(p);
        g.fillPolygon(p);
    }

}
 
Example 10
Source File: baseDrawerItem.java    From brModelo with GNU General Public License v3.0 5 votes vote down vote up
private boolean DrawComplexPath(Graphics2D g, int l, int t) {
        String[] dist = getPath().split(",");
        int dl = dist.length;
        if (dl < 3) {
            g.drawString("?", l, t);
            return false;
        }
        if (dl % 2 > 0) {
            String[] tmp = new String[dl + 1];
            tmp[dl] = "0";
            dist = tmp;
            dl = dist.length;
        }
        int tam = dl / 2;
        int xPoints[] = new int[tam];
        int yPoints[] = new int[tam];
        try {
            int y = 0;
            for (int i = 0; i < tam; i++) {
                xPoints[i] = Expr(dist[y++].trim());
                yPoints[i] = Expr(dist[y++].trim());
//                xPoints[i] = l + Integer.valueOf(dist[y++].trim());
//                yPoints[i] = t + Integer.valueOf(dist[y++].trim());
            }
        } catch (Exception x) {
            g.drawString("?", l, t);
            return false;
        }
        if (isFill()) {
            g.fillPolygon(xPoints, yPoints, tam);
        } else {
            g.drawPolygon(xPoints, yPoints, tam);
        }
        return true;
    }
 
Example 11
Source File: BlastMineRockOverlay.java    From runelite with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private void drawAreaWarning(Graphics2D graphics, BlastMineRock rock, Color color, Tile[][][] tiles)
{
	if (!config.showWarningOverlay())
	{
		return;
	}

	final int z = client.getPlane();
	int x = rock.getGameObject().getLocalLocation().getX() / Perspective.LOCAL_TILE_SIZE;
	int y = rock.getGameObject().getLocalLocation().getY() / Perspective.LOCAL_TILE_SIZE;
	final int orientation = tiles[z][x][y].getWallObject().getOrientationA();

	switch (orientation) //calculate explosion around the tile in front of the wall
	{
		case 1:
			x--;
			break;
		case 4:
			x++;
			break;
		case 8:
			y--;
			break;
		default:
			y++;
	}

	for (int i = -WARNING_DISTANCE; i <= WARNING_DISTANCE; i++)
	{
		for (int j = -WARNING_DISTANCE; j <= WARNING_DISTANCE; j++)
		{
			final GameObject gameObject = tiles[z][x + i][y + j].getGameObjects()[0];

			//check if tile is empty, or is a wall...
			if (gameObject == null || !WALL_OBJECTS.contains(gameObject.getId()))
			{
				final LocalPoint localTile = new LocalPoint(
					(x + i) * Perspective.LOCAL_TILE_SIZE + Perspective.LOCAL_TILE_SIZE / 2,
					(y + j) * Perspective.LOCAL_TILE_SIZE + Perspective.LOCAL_TILE_SIZE / 2);
				final Polygon poly = Perspective.getCanvasTilePoly(client, localTile);

				if (poly != null)
				{
					graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 100));
					graphics.fillPolygon(poly);
				}
			}
		}
	}
}
 
Example 12
Source File: BlastMineRockOverlay.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
private void drawAreaWarning(Graphics2D graphics, BlastMineRock rock, Color color, Tile[][][] tiles)
{
	if (!config.showWarningOverlay())
	{
		return;
	}

	final int z = client.getPlane();
	int x = rock.getGameObject().getLocalLocation().getX() / Perspective.LOCAL_TILE_SIZE;
	int y = rock.getGameObject().getLocalLocation().getY() / Perspective.LOCAL_TILE_SIZE;
	final int orientation = tiles[z][x][y].getWallObject().getOrientationA();

	switch (orientation) //calculate explosion around the tile in front of the wall
	{
		case 1:
			x--;
			break;
		case 4:
			x++;
			break;
		case 8:
			y--;
			break;
		default:
			y++;
	}

	for (int i = -WARNING_DISTANCE; i <= WARNING_DISTANCE; i++)
	{
		for (int j = -WARNING_DISTANCE; j <= WARNING_DISTANCE; j++)
		{
			final GameObject gameObject = tiles[z][x + i][y + j].getGameObjects()[0];

			//check if tile is empty, or is a wall...
			if (gameObject == null || !WALL_OBJECTS.contains(gameObject.getId()))
			{
				final LocalPoint localTile = new LocalPoint(
					(x + i) * Perspective.LOCAL_TILE_SIZE + Perspective.LOCAL_TILE_SIZE / 2,
					(y + j) * Perspective.LOCAL_TILE_SIZE + Perspective.LOCAL_TILE_SIZE / 2);
				final Polygon poly = Perspective.getCanvasTilePoly(client, localTile);

				if (poly != null)
				{
					graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 100));
					graphics.fillPolygon(poly);
				}
			}
		}
	}
}
 
Example 13
Source File: MultiGradientTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
public void paintComponent(Graphics g) {
    Graphics2D g2d = (Graphics2D)g.create();

    int w = getWidth();
    int h = getHeight();
    g2d.setColor(Color.black);
    g2d.fillRect(0, 0, w, h);

    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                         antialiasHint);
    g2d.setRenderingHint(RenderingHints.KEY_RENDERING,
                         renderHint);

    g2d.transform(transform);
    g2d.setPaint(paint);

    switch (shapeType) {
    default:
    case RECT:
        g2d.fillRect(0, 0, w, h);
        break;

    case ELLIPSE:
        g2d.fillOval(0, 0, w, h);
        break;

    case MULTIPLE:
        g2d.fillRect(0, 0, w/2, h/2);
        g2d.fillOval(w/2, 0, w/2, h/2);
        g2d.drawOval(0, h/2, w/2, h/2);
        g2d.drawLine(0, h/2, w/2, h);
        g2d.drawLine(0, h, w/2, h/2);
        Polygon p = new Polygon();
        p.addPoint(w/2, h);
        p.addPoint(w, h);
        p.addPoint(3*w/4, h/2);
        g2d.fillPolygon(p);
        break;
    }

    switch (paintType) {
    default:
    case BASIC:
    case LINEAR:
        g2d.setColor(Color.white);
        g2d.fillRect(startX-1, startY-1, 2, 2);
        g2d.drawString("1", startX, startY + 12);
        g2d.fillRect(endX-1, endY-1, 2, 2);
        g2d.drawString("2", endX, endY + 12);
        break;

    case RADIAL:
        g2d.setColor(Color.white);
        g2d.fillRect(ctrX-1, ctrY-1, 2, 2);
        g2d.drawString("C", ctrX, ctrY + 12);
        g2d.fillRect(focusX-1, focusY-1, 2, 2);
        g2d.drawString("F", focusX, focusY + 12);
        break;
    }

    g2d.dispose();
}
 
Example 14
Source File: MultiGradientTest.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public void paintComponent(Graphics g) {
    Graphics2D g2d = (Graphics2D)g.create();

    int w = getWidth();
    int h = getHeight();
    g2d.setColor(Color.black);
    g2d.fillRect(0, 0, w, h);

    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                         antialiasHint);
    g2d.setRenderingHint(RenderingHints.KEY_RENDERING,
                         renderHint);

    g2d.transform(transform);
    g2d.setPaint(paint);

    switch (shapeType) {
    default:
    case RECT:
        g2d.fillRect(0, 0, w, h);
        break;

    case ELLIPSE:
        g2d.fillOval(0, 0, w, h);
        break;

    case MULTIPLE:
        g2d.fillRect(0, 0, w/2, h/2);
        g2d.fillOval(w/2, 0, w/2, h/2);
        g2d.drawOval(0, h/2, w/2, h/2);
        g2d.drawLine(0, h/2, w/2, h);
        g2d.drawLine(0, h, w/2, h/2);
        Polygon p = new Polygon();
        p.addPoint(w/2, h);
        p.addPoint(w, h);
        p.addPoint(3*w/4, h/2);
        g2d.fillPolygon(p);
        break;
    }

    switch (paintType) {
    default:
    case BASIC:
    case LINEAR:
        g2d.setColor(Color.white);
        g2d.fillRect(startX-1, startY-1, 2, 2);
        g2d.drawString("1", startX, startY + 12);
        g2d.fillRect(endX-1, endY-1, 2, 2);
        g2d.drawString("2", endX, endY + 12);
        break;

    case RADIAL:
        g2d.setColor(Color.white);
        g2d.fillRect(ctrX-1, ctrY-1, 2, 2);
        g2d.drawString("C", ctrX, ctrY + 12);
        g2d.fillRect(focusX-1, focusY-1, 2, 2);
        g2d.drawString("F", focusX, focusY + 12);
        break;
    }

    g2d.dispose();
}
 
Example 15
Source File: MultiGradientTest.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public void paintComponent(Graphics g) {
    Graphics2D g2d = (Graphics2D)g.create();

    int w = getWidth();
    int h = getHeight();
    g2d.setColor(Color.black);
    g2d.fillRect(0, 0, w, h);

    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                         antialiasHint);
    g2d.setRenderingHint(RenderingHints.KEY_RENDERING,
                         renderHint);

    g2d.transform(transform);
    g2d.setPaint(paint);

    switch (shapeType) {
    default:
    case RECT:
        g2d.fillRect(0, 0, w, h);
        break;

    case ELLIPSE:
        g2d.fillOval(0, 0, w, h);
        break;

    case MULTIPLE:
        g2d.fillRect(0, 0, w/2, h/2);
        g2d.fillOval(w/2, 0, w/2, h/2);
        g2d.drawOval(0, h/2, w/2, h/2);
        g2d.drawLine(0, h/2, w/2, h);
        g2d.drawLine(0, h, w/2, h/2);
        Polygon p = new Polygon();
        p.addPoint(w/2, h);
        p.addPoint(w, h);
        p.addPoint(3*w/4, h/2);
        g2d.fillPolygon(p);
        break;
    }

    switch (paintType) {
    default:
    case BASIC:
    case LINEAR:
        g2d.setColor(Color.white);
        g2d.fillRect(startX-1, startY-1, 2, 2);
        g2d.drawString("1", startX, startY + 12);
        g2d.fillRect(endX-1, endY-1, 2, 2);
        g2d.drawString("2", endX, endY + 12);
        break;

    case RADIAL:
        g2d.setColor(Color.white);
        g2d.fillRect(ctrX-1, ctrY-1, 2, 2);
        g2d.drawString("C", ctrX, ctrY + 12);
        g2d.fillRect(focusX-1, focusY-1, 2, 2);
        g2d.drawString("F", focusX, focusY + 12);
        break;
    }

    g2d.dispose();
}
 
Example 16
Source File: MultiGradientTest.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public void paintComponent(Graphics g) {
    Graphics2D g2d = (Graphics2D)g.create();

    int w = getWidth();
    int h = getHeight();
    g2d.setColor(Color.black);
    g2d.fillRect(0, 0, w, h);

    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                         antialiasHint);
    g2d.setRenderingHint(RenderingHints.KEY_RENDERING,
                         renderHint);

    g2d.transform(transform);
    g2d.setPaint(paint);

    switch (shapeType) {
    default:
    case RECT:
        g2d.fillRect(0, 0, w, h);
        break;

    case ELLIPSE:
        g2d.fillOval(0, 0, w, h);
        break;

    case MULTIPLE:
        g2d.fillRect(0, 0, w/2, h/2);
        g2d.fillOval(w/2, 0, w/2, h/2);
        g2d.drawOval(0, h/2, w/2, h/2);
        g2d.drawLine(0, h/2, w/2, h);
        g2d.drawLine(0, h, w/2, h/2);
        Polygon p = new Polygon();
        p.addPoint(w/2, h);
        p.addPoint(w, h);
        p.addPoint(3*w/4, h/2);
        g2d.fillPolygon(p);
        break;
    }

    switch (paintType) {
    default:
    case BASIC:
    case LINEAR:
        g2d.setColor(Color.white);
        g2d.fillRect(startX-1, startY-1, 2, 2);
        g2d.drawString("1", startX, startY + 12);
        g2d.fillRect(endX-1, endY-1, 2, 2);
        g2d.drawString("2", endX, endY + 12);
        break;

    case RADIAL:
        g2d.setColor(Color.white);
        g2d.fillRect(ctrX-1, ctrY-1, 2, 2);
        g2d.drawString("C", ctrX, ctrY + 12);
        g2d.fillRect(focusX-1, focusY-1, 2, 2);
        g2d.drawString("F", focusX, focusY + 12);
        break;
    }

    g2d.dispose();
}
 
Example 17
Source File: TabbedPaneUI.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
private static void paintSelectedBottom(Graphics g, int x, int y, int w, int h) {
	g.setColor(RapidLookTools.getColors().getTabbedPaneColors()[1]);
	g.drawLine(x + 11, y + h - 1, x + w - 12, y + h - 1);
	g.setColor(RapidLookTools.getColors().getTabbedPaneColors()[2]);
	g.drawLine(x + 10, y + h - 2, x + w - 11, y + h - 2);

	g.setColor(RapidLookTools.getColors().getTabbedPaneColors()[3]);
	g.drawLine(x + 13, y + h - 1, x + w - 14, y + h - 1);

	ColorUIResource c1 = RapidLookTools.getColors().getTabbedPaneColors()[4];
	g.setColor(c1);

	// left
	g.drawLine(x + 9, y + h - 2, x + 9, y + h - 3);
	g.drawLine(x + 8, y + h - 3, x + 8, y + h - 3);
	g.drawLine(x + 7, y + h - 3, x + 7, y + h - 4);
	g.drawLine(x + 6, y + h - 4, x + 6, y + h - 5);
	g.drawLine(x + 5, y + h - 5, x + 5, y + h - 6);

	// right
	g.drawLine(w + x - 10, y + h - 2, w + x - 10, y + h - 3);
	g.drawLine(w + x - 9, y + h - 3, w + x - 9, y + h - 3);
	g.drawLine(w + x - 8, y + h - 3, w + x - 8, y + h - 4);
	g.drawLine(w + x - 7, y + h - 4, w + x - 7, y + h - 5);
	g.drawLine(w + x - 6, y + h - 5, w + x - 6, y + h - 6);

	// inner section
	g.setColor(RapidLookTools.getColors().getTabbedPaneColors()[5]);

	g.drawLine(x + 10, y + h - 3, x + w - 11, y + h - 3);
	g.drawLine(x + 8, y + h - 4, x + w - 9, y + h - 4);
	g.drawLine(x + 7, y + h - 5, x + w - 8, y + h - 5);
	g.drawLine(x + 6, y + h - 6, x + w - 7, y + h - 6);

	Graphics2D g2 = (Graphics2D) g;
	g2.setPaint(new GradientPaint(1, y, RapidLookTools.getColors().getTabbedPaneColors()[7], 1, y + h - 6,
			RapidLookTools.getColors().getTabbedPaneColors()[6]));

	int[] xArr = new int[]{x + 4, w + x - 5, x + w - 1, x};
	int[] yArr = new int[]{y + h - 6, y + h - 6, y, y};
	Polygon p1 = new Polygon(xArr, yArr, 4);
	g2.fillPolygon(p1);

	g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
	g2.setColor(c1);
	g2.drawLine(x, y, x + 4, y + h - 6);
	g2.drawLine(w + x - 1, y, x + w - 5, y + h - 6);
	g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_DEFAULT);
}
 
Example 18
Source File: MultiGradientTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public void paintComponent(Graphics g) {
    Graphics2D g2d = (Graphics2D)g.create();

    int w = getWidth();
    int h = getHeight();
    g2d.setColor(Color.black);
    g2d.fillRect(0, 0, w, h);

    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                         antialiasHint);
    g2d.setRenderingHint(RenderingHints.KEY_RENDERING,
                         renderHint);

    g2d.transform(transform);
    g2d.setPaint(paint);

    switch (shapeType) {
    default:
    case RECT:
        g2d.fillRect(0, 0, w, h);
        break;

    case ELLIPSE:
        g2d.fillOval(0, 0, w, h);
        break;

    case MULTIPLE:
        g2d.fillRect(0, 0, w/2, h/2);
        g2d.fillOval(w/2, 0, w/2, h/2);
        g2d.drawOval(0, h/2, w/2, h/2);
        g2d.drawLine(0, h/2, w/2, h);
        g2d.drawLine(0, h, w/2, h/2);
        Polygon p = new Polygon();
        p.addPoint(w/2, h);
        p.addPoint(w, h);
        p.addPoint(3*w/4, h/2);
        g2d.fillPolygon(p);
        break;
    }

    switch (paintType) {
    default:
    case BASIC:
    case LINEAR:
        g2d.setColor(Color.white);
        g2d.fillRect(startX-1, startY-1, 2, 2);
        g2d.drawString("1", startX, startY + 12);
        g2d.fillRect(endX-1, endY-1, 2, 2);
        g2d.drawString("2", endX, endY + 12);
        break;

    case RADIAL:
        g2d.setColor(Color.white);
        g2d.fillRect(ctrX-1, ctrY-1, 2, 2);
        g2d.drawString("C", ctrX, ctrY + 12);
        g2d.fillRect(focusX-1, focusY-1, 2, 2);
        g2d.drawString("F", focusX, focusY + 12);
        break;
    }

    g2d.dispose();
}
 
Example 19
Source File: MultiGradientTest.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public void paintComponent(Graphics g) {
    Graphics2D g2d = (Graphics2D)g.create();

    int w = getWidth();
    int h = getHeight();
    g2d.setColor(Color.black);
    g2d.fillRect(0, 0, w, h);

    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                         antialiasHint);
    g2d.setRenderingHint(RenderingHints.KEY_RENDERING,
                         renderHint);

    g2d.transform(transform);
    g2d.setPaint(paint);

    switch (shapeType) {
    default:
    case RECT:
        g2d.fillRect(0, 0, w, h);
        break;

    case ELLIPSE:
        g2d.fillOval(0, 0, w, h);
        break;

    case MULTIPLE:
        g2d.fillRect(0, 0, w/2, h/2);
        g2d.fillOval(w/2, 0, w/2, h/2);
        g2d.drawOval(0, h/2, w/2, h/2);
        g2d.drawLine(0, h/2, w/2, h);
        g2d.drawLine(0, h, w/2, h/2);
        Polygon p = new Polygon();
        p.addPoint(w/2, h);
        p.addPoint(w, h);
        p.addPoint(3*w/4, h/2);
        g2d.fillPolygon(p);
        break;
    }

    switch (paintType) {
    default:
    case BASIC:
    case LINEAR:
        g2d.setColor(Color.white);
        g2d.fillRect(startX-1, startY-1, 2, 2);
        g2d.drawString("1", startX, startY + 12);
        g2d.fillRect(endX-1, endY-1, 2, 2);
        g2d.drawString("2", endX, endY + 12);
        break;

    case RADIAL:
        g2d.setColor(Color.white);
        g2d.fillRect(ctrX-1, ctrY-1, 2, 2);
        g2d.drawString("C", ctrX, ctrY + 12);
        g2d.fillRect(focusX-1, focusY-1, 2, 2);
        g2d.drawString("F", focusX, focusY + 12);
        break;
    }

    g2d.dispose();
}
 
Example 20
Source File: MultiGradientTest.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public void paintComponent(Graphics g) {
    Graphics2D g2d = (Graphics2D)g.create();

    int w = getWidth();
    int h = getHeight();
    g2d.setColor(Color.black);
    g2d.fillRect(0, 0, w, h);

    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                         antialiasHint);
    g2d.setRenderingHint(RenderingHints.KEY_RENDERING,
                         renderHint);

    g2d.transform(transform);
    g2d.setPaint(paint);

    switch (shapeType) {
    default:
    case RECT:
        g2d.fillRect(0, 0, w, h);
        break;

    case ELLIPSE:
        g2d.fillOval(0, 0, w, h);
        break;

    case MULTIPLE:
        g2d.fillRect(0, 0, w/2, h/2);
        g2d.fillOval(w/2, 0, w/2, h/2);
        g2d.drawOval(0, h/2, w/2, h/2);
        g2d.drawLine(0, h/2, w/2, h);
        g2d.drawLine(0, h, w/2, h/2);
        Polygon p = new Polygon();
        p.addPoint(w/2, h);
        p.addPoint(w, h);
        p.addPoint(3*w/4, h/2);
        g2d.fillPolygon(p);
        break;
    }

    switch (paintType) {
    default:
    case BASIC:
    case LINEAR:
        g2d.setColor(Color.white);
        g2d.fillRect(startX-1, startY-1, 2, 2);
        g2d.drawString("1", startX, startY + 12);
        g2d.fillRect(endX-1, endY-1, 2, 2);
        g2d.drawString("2", endX, endY + 12);
        break;

    case RADIAL:
        g2d.setColor(Color.white);
        g2d.fillRect(ctrX-1, ctrY-1, 2, 2);
        g2d.drawString("C", ctrX, ctrY + 12);
        g2d.fillRect(focusX-1, focusY-1, 2, 2);
        g2d.drawString("F", focusX, focusY + 12);
        break;
    }

    g2d.dispose();
}