当前位置: 首页>>代码示例>>Java>>正文


Java Graphics2D.getClip方法代码示例

本文整理汇总了Java中java.awt.Graphics2D.getClip方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics2D.getClip方法的具体用法?Java Graphics2D.getClip怎么用?Java Graphics2D.getClip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Graphics2D的用法示例。


在下文中一共展示了Graphics2D.getClip方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: draw

import java.awt.Graphics2D; //导入方法依赖的package包/类
public void draw(Graphics g, Rectangle bounds, Rectangle visibleRect, double scale, boolean reversed) {
  if ((getGrid() != null && getGrid().isVisible()) || highlighter != null) {
    final Graphics2D g2d = (Graphics2D) g;
    final Shape oldClip = g2d.getClip();
    final Area newClip = new Area(visibleRect);
    final Shape s = getCachedShape(myPolygon, bounds.x, bounds.y, scale);
    newClip.intersect(new Area(s));
    g2d.setClip(newClip);
    if (getGrid() != null && getGrid().isVisible()) {
      getGrid().draw(g, bounds, visibleRect, scale, reversed);
    }
    if (highlighter != null) {
      highlighter.draw(g2d, s, scale);
    }
    g2d.setClip(oldClip);
  }
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:18,代码来源:Zone.java

示例2: drawNoDataMessage

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
     * Draws a message to state that there is no data to plot.
     *
     * @param g2  the graphics device.
     * @param area  the area within which the plot should be drawn.
     */
    protected void drawNoDataMessage(Graphics2D g2, Rectangle2D area) {

        Shape savedClip = g2.getClip();
        g2.clip(area);
        String message = this.noDataMessage;
        if (message != null) {
            g2.setFont(this.noDataMessageFont);
            g2.setPaint(this.noDataMessagePaint);
//            FontMetrics fm = g2.getFontMetrics(this.noDataMessageFont);
//            Rectangle2D bounds = TextUtilities.getTextBounds(message, g2, fm);
//            float x = (float) (area.getX() + area.getWidth() / 2 - bounds.getWidth() / 2);
//            float y = (float) (area.getMinY() + (area.getHeight() / 2) - (bounds.getHeight() / 2));
//            g2.drawString(message, x, y);
            TextBlock block = TextUtilities.createTextBlock(
                this.noDataMessage, this.noDataMessageFont, this.noDataMessagePaint, 
                0.9f * (float) area.getWidth(), new G2TextMeasurer(g2)
            );
            block.draw(
                g2, (float) area.getCenterX(), (float) area.getCenterY(), TextBlockAnchor.CENTER
            );
        }
        g2.setClip(savedClip);

    }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:31,代码来源:Plot.java

示例3: drawSymbolicGridLines

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Draws the symbolic grid lines.
 * <P>
 * The colors are consecutively the color specified by
 * <CODE>symbolicGridPaint<CODE>
 * (<CODE>DEFAULT_SYMBOLIC_GRID_LINE_PAINT</CODE> by default) and white.
 *
 * @param g2  the graphics device.
 * @param plotArea  the area within which the chart should be drawn.
 * @param dataArea  the area within which the plot should be drawn (a subset of the drawArea).
 * @param edge  the axis location.
 * @param ticks  the ticks.
 */
public void drawSymbolicGridLines(Graphics2D g2,
                                  Rectangle2D plotArea, 
                                  Rectangle2D dataArea,
                                  RectangleEdge edge, 
                                  List ticks) {

    Shape savedClip = g2.getClip();
    g2.clip(dataArea);
    if (RectangleEdge.isTopOrBottom(edge)) {
        drawSymbolicGridLinesHorizontal(g2, plotArea, dataArea, true, ticks);
    }
    else if (RectangleEdge.isLeftOrRight(edge)) {
        drawSymbolicGridLinesVertical(g2, plotArea, dataArea, true, ticks);
    }
    g2.setClip(savedClip);

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:31,代码来源:SymbolicAxis.java

示例4: drawNoDataMessage

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Draws a message to state that there is no data to plot.
 *
 * @param g2  the graphics device.
 * @param area  the area within which the plot should be drawn.
 */
protected void drawNoDataMessage(Graphics2D g2, Rectangle2D area) {
    Shape savedClip = g2.getClip();
    g2.clip(area);
    String message = this.noDataMessage;
    if (message != null) {
        g2.setFont(this.noDataMessageFont);
        g2.setPaint(this.noDataMessagePaint);
        TextBlock block = TextUtilities.createTextBlock(
                this.noDataMessage, this.noDataMessageFont, 
                this.noDataMessagePaint, 0.9f * (float) area.getWidth(), 
                new G2TextMeasurer(g2));
        block.draw(g2, (float) area.getCenterX(), (float) area.getCenterY(), 
                TextBlockAnchor.CENTER);
    }
    g2.setClip(savedClip);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:23,代码来源:Plot.java

示例5: drawGridBands

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Draws the grid bands.  Alternate bands are colored using 
 * <CODE>gridBandPaint<CODE> (<CODE>DEFAULT_GRID_BAND_PAINT</CODE> by 
 * default).
 *
 * @param g2  the graphics device.
 * @param plotArea  the area within which the chart should be drawn.
 * @param dataArea  the area within which the plot should be drawn (a 
 *                  subset of the drawArea).
 * @param edge  the axis location.
 * @param ticks  the ticks.
 */
protected void drawGridBands(Graphics2D g2,
                             Rectangle2D plotArea, 
                             Rectangle2D dataArea,
                             RectangleEdge edge, 
                             List ticks) {

    Shape savedClip = g2.getClip();
    g2.clip(dataArea);
    if (RectangleEdge.isTopOrBottom(edge)) {
        drawGridBandsHorizontal(g2, plotArea, dataArea, true, ticks);
    }
    else if (RectangleEdge.isLeftOrRight(edge)) {
        drawGridBandsVertical(g2, plotArea, dataArea, true, ticks);
    }
    g2.setClip(savedClip);

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:30,代码来源:SymbolAxis.java

示例6: renderEntities

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
public void renderEntities(final Graphics2D g, final Collection<? extends IEntity> entities, final boolean sort, final IVision vision) {
  // set render shape according to the vision
  final Shape oldClip = g.getClip();

  if (vision != null) {
    g.setClip(vision.getRenderVisionShape());
  }

  this.renderEntities(g, entities, sort);

  g.setClip(oldClip);
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:14,代码来源:RenderEngine.java

示例7: gInfo

import java.awt.Graphics2D; //导入方法依赖的package包/类
public gInfo(Graphics2D g)
{
	transform = g.getTransform();
	paint = g.getPaint();
	stroke = g.getStroke();
	font = g.getFont();
	composite = g.getComposite();
	bgrnd = g.getBackground();
	shape = g.getClip();
	hints = g.getRenderingHints();
}
 
开发者ID:Chroniaro,项目名称:What-Happened-to-Station-7,代码行数:12,代码来源:TStack.java

示例8: draw

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Draws the plot on a Java 2D graphics device (such as the screen or a 
 * printer).
 *
 * @param g2  the graphics device.
 * @param area  the area within which the plot should be drawn.
 * @param anchor  the anchor point (<code>null</code> permitted).
 * @param parentState  the state from the parent plot, if there is one.
 * @param info  collects info about the drawing 
 *              (<code>null</code> permitted).
 */
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor,
                 PlotState parentState, PlotRenderingInfo info) {

    // adjust for insets...
    RectangleInsets insets = getInsets();
    insets.trim(area);

    if (info != null) {
        info.setPlotArea(area);
        info.setDataArea(area);
    }

    drawBackground(g2, area);
    drawOutline(g2, area);

    Shape savedClip = g2.getClip();
    g2.clip(area);

    Composite originalComposite = g2.getComposite();
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 
            getForegroundAlpha()));

    if (!DatasetUtilities.isEmptyOrNull(this.dataset)) {
        drawPie(g2, area, info);
    }
    else {
        drawNoDataMessage(g2, area);
    }

    g2.setClip(savedClip);
    g2.setComposite(originalComposite);

    drawOutline(g2, area);

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:47,代码来源:PiePlot.java

示例9: DoPaint

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
public void DoPaint(Graphics2D g) {
    super.DoPaint(g);
    int h = getHeight() / 8;
    int w = getWidth() / 8;
    
    Font fbkp = getFont();
    g.setFont(getFont());
    
    int fh = g.getFontMetrics().getHeight() / 2;
    int fw = g.getFontMetrics().stringWidth("p");
    int x =0, y = 0;
    Rectangle r = getBounds();
    Shape bkp = g.getClip();
    g.setClip(Regiao);
    switch (getDirecao()) {
        case Up:
            g.fillRect(r.x, r.y, r.width, h);
            x =  r.x + r.width -fw;
            y =  r.y + r.height/2 + fh/2;
            break;
        case Right:
            g.fillRect(getLeftWidth() - w, r.y, w, r.height);
            x =  r.x + r.width/2 - fw/2;
            y =  r.y + fh;
            break;
        case Down:
            g.fillRect(r.x, getTopHeight() - h, r.width, h);
            x =  r.x + r.width - fw;
            y =  r.y + r.height/2 + fh/2;
            break;
        case Left:
            g.fillRect(r.x, r.y, w, r.height);
            x =  r.x + r.width/2 - fw/2;
            y =  r.y + fh;
            break;
    }
    g.setClip(bkp);
    PaintPDeParcial(g, x, y);
    g.setFont(fbkp);
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:42,代码来源:PreEspecializacao.java

示例10: paint

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
public void paint(Graphics2D g, Shape alloc, Rectangle clipBounds) {
    Rectangle2D.Double allocBounds = ViewUtils.shape2Bounds(alloc);
    if (allocBounds.intersects(clipBounds)) {
        Font origFont = g.getFont();
        Color origColor = g.getColor();
        Color origBkColor = g.getBackground();
        Shape origClip = g.getClip();
        try {
            // Leave component font
            
            g.setBackground(getBackgroundColor());

            int xInt = (int) allocBounds.getX();
            int yInt = (int) allocBounds.getY();
            int endXInt = (int) (allocBounds.getX() + allocBounds.getWidth() - 1);
            int endYInt = (int) (allocBounds.getY() + allocBounds.getHeight() - 1);
            g.setColor(getBorderColor());
            g.drawRect(xInt, yInt, endXInt - xInt, endYInt - yInt);
            
            g.setColor(getForegroundColor());
            g.clearRect(xInt + 1, yInt + 1, endXInt - xInt - 1, endYInt - yInt - 1);
            g.clip(alloc);
            TextLayout textLayout = getTextLayout();
            if (textLayout != null) {
                EditorView.Parent parent = (EditorView.Parent) getParent();
                float ascent = parent.getViewRenderContext().getDefaultAscent();
                String desc = fold.getDescription(); // For empty desc a single-space text layout is returned
                float x = (float) (allocBounds.getX() + EXTRA_MARGIN_WIDTH);
                float y = (float) allocBounds.getY();
                if (desc.length() > 0) {
                    
                    textLayout.draw(g, x, y + ascent);
                }
            }
        } finally {
            g.setClip(origClip);
            g.setBackground(origBkColor);
            g.setColor(origColor);
            g.setFont(origFont);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:44,代码来源:FoldView.java

示例11: paintNewline

import java.awt.Graphics2D; //导入方法依赖的package包/类
static void paintNewline(Graphics2D g, Shape viewAlloc, Rectangle clipBounds,
        DocumentView docView, EditorView view, int viewStartOffset)
{
    Rectangle2D viewRectReadonly = ViewUtils.shape2Bounds(viewAlloc);
    PaintState paintState = PaintState.save(g);
    Shape origClip = g.getClip();
    try {
        JTextComponent textComponent = docView.getTextComponent();
        SplitOffsetHighlightsSequence highlights = docView.getPaintHighlights(view, 0);
        boolean showNonPrintingChars = docView.op.isNonPrintableCharactersVisible();
        float charWidth = docView.op.getDefaultCharWidth();
        boolean logFiner = ViewHierarchyImpl.PAINT_LOG.isLoggable(Level.FINER);
        if (logFiner) {
            ViewHierarchyImpl.PAINT_LOG.finer("      Newline-View-Id=" + view.getDumpId() + // NOI18N
                    ", startOffset=" + viewStartOffset + ", alloc=" + viewAlloc + '\n' // NOI18N
            );

        }
        while (highlights.moveNext()) {
            int hiStartOffset = highlights.getStartOffset();
            int hiStartSplitOffset = highlights.getStartSplitOffset();
            int hiEndOffset = Math.min(highlights.getEndOffset(), viewStartOffset + 1); // TBD
            int hiEndSplitOffset = highlights.getEndSplitOffset();
            AttributeSet attrs = highlights.getAttributes();
            if (hiStartOffset > viewStartOffset) { // HL above newline
                break;
            }

            double startX = viewRectReadonly.getX() + hiStartSplitOffset * charWidth;
            double endX = (hiEndOffset > viewStartOffset)
                    ? viewRectReadonly.getMaxX()
                    : Math.min(viewRectReadonly.getX() + hiEndSplitOffset * charWidth, viewRectReadonly.getMaxX());
            Rectangle2D.Double renderPartRect = new Rectangle2D.Double(startX, viewRectReadonly.getY(), endX - startX, viewRectReadonly.getHeight());
            fillBackground(g, renderPartRect, attrs, textComponent);
            boolean hitsClip = (clipBounds == null) || renderPartRect.intersects(clipBounds);
            if (hitsClip) {
                // First render background and background related highlights
                // Do not g.clip() before background is filled since otherwise there would be
                // painting artifacts for italic fonts (one-pixel slanting lines) at certain positions.
                // Clip to part's alloc since textLayout.draw() renders fully the whole text layout
                g.clip(renderPartRect);
                paintBackgroundHighlights(g, renderPartRect, attrs, docView);
                // Render foreground with proper color
                g.setColor(HighlightsViewUtils.validForeColor(attrs, textComponent));
                Object strikeThroughValue = (attrs != null)
                        ? attrs.getAttribute(StyleConstants.StrikeThrough)
                        : null;
                if (showNonPrintingChars && hiStartSplitOffset == 0) { // First part => render newline char visible representation
                    TextLayout textLayout = docView.op.getNewlineCharTextLayout();
                    if (textLayout != null) {
                        paintTextLayout(g, renderPartRect, textLayout, docView);
                    }
                }
                if (strikeThroughValue != null) {
                    paintStrikeThrough(g, viewRectReadonly, strikeThroughValue, attrs, docView);
                }
                g.setClip(origClip);
            }
            if (logFiner) {
                ViewHierarchyImpl.PAINT_LOG.finer("        Highlight <" + 
                        hiStartOffset + '_' + hiStartSplitOffset + "," + // NOI18N
                        hiEndOffset + '_' + hiEndSplitOffset + ">, Color=" + // NOI18N
                        ViewUtils.toString(g.getColor()) + '\n'); // NOI18N
            }
            if (clipBounds != null && (renderPartRect.getX() > clipBounds.getMaxX())) {
                break;
            }
        }
    } finally {
        g.setClip(origClip);
        paintState.restore();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:74,代码来源:HighlightsViewUtils.java

示例12: forceDraw

import java.awt.Graphics2D; //导入方法依赖的package包/类
/** Draw the grid even if not marked visible */
public void forceDraw(Graphics g, Rectangle bounds, Rectangle visibleRect, double scale, boolean reversed) {
  if (!bounds.intersects(visibleRect) || color == null) {
    return;
  }

  Graphics2D g2d = (Graphics2D) g;
  g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                       RenderingHints.VALUE_ANTIALIAS_ON);

  Rectangle region = bounds.intersection(visibleRect);

  Shape oldClip = g2d.getClip();
  if (oldClip != null) {
    Area clipArea = new Area(oldClip);
    clipArea.intersect(new Area(region));
    g2d.setClip(clipArea);
  }

  double deltaX = scale * dx;
  double deltaY = scale * dy;

  double xmin = reversed ? bounds.x + scale * origin.x + bounds.width - deltaX * round((bounds.x + scale * origin.x + bounds.width - region.x) / deltaX) + deltaX / 2
      : bounds.x + scale * origin.x + deltaX * round((region.x - bounds.x - scale * origin.x) / deltaX) + deltaX / 2;
  double xmax = region.x + region.width;
  double ymin = reversed ? bounds.y + scale * origin.y + bounds.height - deltaY * round((bounds.y + scale * origin.y + bounds.height - region.y) / deltaY) + deltaY / 2
      : bounds.y + scale * origin.y + deltaY * round((region.y - bounds.y - scale * origin.y) / deltaY) + deltaY / 2;
  double ymax = region.y + region.height;

  Point p1 = new Point();
  Point p2 = new Point();
  g2d.setColor(color);
  // x is the location of a vertical line
  for (double x = xmin; x < xmax; x += deltaX) {
    p1.move((int) round(x), region.y);
    p2.move((int) round(x), region.y + region.height);
    g2d.drawLine(p1.x, p1.y, p2.x, p2.y);
  }
  for (double y = ymin; y < ymax; y += deltaY) {
    g2d.drawLine(region.x, (int) round(y), region.x + region.width, (int) round(y));
  }
  if (dotsVisible) {
    xmin = reversed ? bounds.x + scale * origin.x + bounds.width - deltaX * round((bounds.x + scale * origin.x + bounds.width - region.x) / deltaX)
        : bounds.x + scale * origin.x + deltaX * round((region.x - bounds.x - scale * origin.x) / deltaX);
    ymin = reversed ? bounds.y + scale * origin.y + bounds.height - deltaY * round((bounds.y + scale * origin.y + bounds.height - region.y) / deltaY)
        : bounds.y + scale * origin.y + deltaY * round((region.y - bounds.y - scale * origin.y) / deltaY);
    for (double x = xmin; x < xmax; x += deltaX) {
      for (double y = ymin; y < ymax; y += deltaY) {
        p1.move((int) round(x - 0.5), (int) round(y - 0.5));
        g2d.fillRect(p1.x, p1.y, 2, 2);
      }
    }
  }
  g2d.setClip(oldClip);
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:56,代码来源:SquareGrid.java

示例13: drawBackground

import java.awt.Graphics2D; //导入方法依赖的package包/类
private void drawBackground(Graphics2D g2d, int x, int y, int w, int h) {
  CssStyleDeclaration style = getComputedStyle();
  if (style.isSet(CssProperty.BACKGROUND_COLOR)) {
    g2d.setColor(createColor(style.getColor(CssProperty.BACKGROUND_COLOR)));
    g2d.fillRect(x, y, w, h);
  }

  if (!style.isSet(CssProperty.BACKGROUND_IMAGE)) {
    return;
  }

  String bgImage = style.getString(CssProperty.BACKGROUND_IMAGE);
  Image image = ((SwingPlatform) getOwnerDocument().getPlatform()).getImage(this, getOwnerDocument().getUrl().resolve(bgImage));
  
  if (image == null) {
    return;
  }

  Shape savedClip = g2d.getClip(); 
  g2d.clipRect(x, y, w, h);
  CssEnum repeat = style.getEnum(CssProperty.BACKGROUND_REPEAT);
     int bgY = 0;
     int bgX = 0;
     if (repeat == CssEnum.REPEAT_Y || repeat == CssEnum.REPEAT) {
       do {
         if (repeat == CssEnum.REPEAT) {
           int currentBgX = bgX;
           do {
             g2d.drawImage(image, x + currentBgX, y + bgY, null);
             currentBgX += image.getWidth(null);
           } while (currentBgX < w);
         } else {
           g2d.drawImage(image, x + bgX, y + bgY, null);
         }
         bgY += image.getHeight(null);
       } while (bgY < h);
     } else if (repeat == CssEnum.REPEAT_X) {
       do {
         g2d.drawImage(image, x + bgX, y + bgY, null);
         bgX += image.getWidth(null);
       } while (bgX < w);
     } else {
       g2d.drawImage(image, x + bgX, y + bgY, null);
     }
     
     g2d.setClip(savedClip);
}
 
开发者ID:stefanhaustein,项目名称:nativehtml,代码行数:48,代码来源:AbstractSwingComponentElement.java

示例14: draw

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Draws the plot on a Java 2D graphics device (such as the screen or a printer).
 * <P>
 * This plot relies on an {@link org.jfree.chart.renderer.DefaultPolarItemRenderer} to draw 
 * each item in the plot.  This allows the visual representation of the data to be changed 
 * easily.
 * <P>
 * The optional info argument collects information about the rendering of
 * the plot (dimensions, tooltip information etc).  Just pass in <code>null</code> if
 * you do not need this information.
 *
 * @param g2  the graphics device.
 * @param plotArea  the area within which the plot (including axes and labels) should be drawn.
 * @param parentState  ignored.
 * @param info  collects chart drawing information (<code>null</code> permitted).
 */
public void draw(Graphics2D g2, 
                 Rectangle2D plotArea, 
                 PlotState parentState,
                 PlotRenderingInfo info) {
   
    // if the plot area is too small, just return...
    boolean b1 = (plotArea.getWidth() <= MINIMUM_WIDTH_TO_DRAW);
    boolean b2 = (plotArea.getHeight() <= MINIMUM_HEIGHT_TO_DRAW);
    if (b1 || b2) {
        return;
    }
   
    // record the plot area...
    if (info != null) {
        info.setPlotArea(plotArea);
    }
   
    // adjust the drawing area for the plot insets (if any)...
    Insets insets = getInsets();
    if (insets != null) {
        plotArea.setRect(plotArea.getX() + insets.left,
                         plotArea.getY() + insets.top,
                         plotArea.getWidth() - insets.left - insets.right,
                         plotArea.getHeight() - insets.top - insets.bottom);
    }
  
    Rectangle2D dataArea = plotArea;
    if (info != null) {
        info.setDataArea(dataArea);
    }
   
    // draw the plot background and axes...
    drawBackground(g2, dataArea);
    double h = Math.min(dataArea.getWidth() / 2.0, dataArea.getHeight() / 2.0) - MARGIN;
    Rectangle2D quadrant = new Rectangle2D.Double(
        dataArea.getCenterX(), dataArea.getCenterY(), h, h
    );
    AxisState state = drawAxis(g2, plotArea, quadrant);
    if (this.renderer != null) {
        Shape originalClip = g2.getClip();
        Composite originalComposite = g2.getComposite();
      
        g2.clip(dataArea);
        g2.setComposite(
            AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getForegroundAlpha())
        );
      
        drawGridlines(g2, dataArea, this.angleTicks, state.getTicks());
      
        // draw...
        render(g2, dataArea, info);
      
        g2.setClip(originalClip);
        g2.setComposite(originalComposite);
    }
    drawOutline(g2, dataArea);
    drawCornerTextItems(g2, dataArea);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:75,代码来源:PolarPlot.java

示例15: draw

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Draws the fast scatter plot on a Java 2D graphics device (such as the screen or
 * a printer).
 *
 * @param g2  the graphics device.
 * @param plotArea   the area within which the plot (including axis labels) should be drawn.
 * @param parentState  the state from the parent plot, if there is one.
 * @param info  collects chart drawing information (<code>null</code> permitted).
 */
public void draw(Graphics2D g2, Rectangle2D plotArea, PlotState parentState, 
                 PlotRenderingInfo info) {

    // set up info collection...
    if (info != null) {
        info.setPlotArea(plotArea);

    }

    // adjust the drawing area for plot insets (if any)...
    Insets insets = getInsets();
    if (insets != null) {
        plotArea.setRect(plotArea.getX() + insets.left,
                         plotArea.getY() + insets.top,
                         plotArea.getWidth() - insets.left - insets.right,
                         plotArea.getHeight() - insets.top - insets.bottom);
    }

    AxisSpace space = new AxisSpace();
    space = this.domainAxis.reserveSpace(g2, this, plotArea, RectangleEdge.BOTTOM, space);
    space = this.rangeAxis.reserveSpace(g2, this, plotArea, RectangleEdge.LEFT, space);
    Rectangle2D dataArea = space.shrink(plotArea, null);

    if (info != null) {
        info.setDataArea(dataArea);
    }

    // draw the plot background and axes...
    drawBackground(g2, dataArea);

    AxisState domainAxisState = null;
    AxisState rangeAxisState = null;
    if (this.domainAxis != null) {
        domainAxisState = this.domainAxis.draw(
            g2, dataArea.getMaxY(), plotArea, dataArea, RectangleEdge.BOTTOM, info
        );
    }
    if (this.rangeAxis != null) {
        rangeAxisState = this.rangeAxis.draw(
            g2, dataArea.getMinX(), plotArea, dataArea, RectangleEdge.LEFT, info
        );
    }
    drawDomainGridlines(g2, dataArea, domainAxisState.getTicks());
    drawRangeGridlines(g2, dataArea, rangeAxisState.getTicks());
    
    Shape originalClip = g2.getClip();
    Composite originalComposite = g2.getComposite();

    g2.clip(dataArea);
    g2.setComposite(
        AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getForegroundAlpha())
    );

    render(g2, dataArea, info, null);

    g2.setClip(originalClip);
    g2.setComposite(originalComposite);
    drawOutline(g2, dataArea);

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:70,代码来源:FastScatterPlot.java


注:本文中的java.awt.Graphics2D.getClip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。