Java Graphics Draw paintShape(Shape shape, Graphics2D g2d, Color colorStroke, Stroke stroke, Color colorFill, double downsample)

Here you can find the source of paintShape(Shape shape, Graphics2D g2d, Color colorStroke, Stroke stroke, Color colorFill, double downsample)

Description

paint Shape

License

Open Source License

Declaration

public static void paintShape(Shape shape, Graphics2D g2d, Color colorStroke, Stroke stroke, Color colorFill,
            double downsample) 

Method Source Code

//package com.java2s;
/*-// w  w w  .ja v a  2s  . c  om
 * #%L
 * This file is part of QuPath.
 * %%
 * Copyright (C) 2014 - 2016 The Queen's University of Belfast, Northern Ireland
 * Contact: IP Management (ipmanagement@qub.ac.uk)
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public
 * License along with this program.  If not, see
 * <http://www.gnu.org/licenses/gpl-3.0.html>.
 * #L%
 */

import java.awt.Color;

import java.awt.Graphics2D;

import java.awt.Shape;
import java.awt.Stroke;

public class Main {
    public static void paintShape(Shape shape, Graphics2D g2d, Color colorStroke, Stroke stroke, Color colorFill,
            double downsample) {

        //      if (shape instanceof Path2D && downsample > 10) {
        //         Shape shape2 = downsampledShapes.get(shape);
        //         if (shape2 == null) {
        //            shape2 = ShapeSimplifierAwt.simplifyPath((Path2D)shape, 10);
        //            if (shape2 != null) {
        //               downsampledShapes.put(shape, shape2);
        //               shape = shape2;
        //            }
        //         }
        //      }

        //      if (stroke != null)
        //         g2d.setStroke(stroke);
        //      g2d.setColor(colorStroke);
        //      System.out.println("Drawing: " + AWTAreaROI.getVertices(shape).size());
        //      for (Vertices v : AWTAreaROI.getVertices(shape)) {
        //         g2d.draw(PathROIToolsAwt.getShape(new PolygonROI(v.getPoints())));
        //         //            g2d.fill(PathROIToolsAwt.getShape(new PolygonROI(v.getPoints())));
        //      }

        if (colorFill != null) {
            g2d.setColor(colorFill);
            g2d.fill(shape);
        }
        if (colorStroke != null) {
            if (stroke != null)
                g2d.setStroke(stroke);
            g2d.setColor(colorStroke);
            g2d.draw(shape);
        }
    }
}

Related

  1. paintLine(Graphics2D g2, Point2D.Double from, Point2D.Double to)
  2. paintOval(int x, int y, Color c, int size, Graphics g)
  3. paintPoint(java.awt.Graphics g2, int x, int y)
  4. paintRectCompartment(Graphics g, Dimension size, int x, int y, Color fillColor, Color strokeColor)
  5. paintRectShadow(Graphics g, int x, int y, int width, int height)
  6. paintSprite(Graphics g, int x, int y, int[][] sprite, Color[] colors)
  7. prepareGraphics(Graphics g)
  8. printAll(java.awt.Graphics2D g2, java.awt.Component component)
  9. raiseOval(Graphics2D g2, Rectangle r, Color foreColor)