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


Java Graphics2D.setPaintMode方法代码示例

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


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

示例1: drawHorizontalAxisTrace

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Draws a vertical line used to trace the mouse position to the horizontal axis.
 * 
 * @param g2
 *            the graphics device.
 * @param x
 *            the x-coordinate of the trace line.
 */
private void drawHorizontalAxisTrace(Graphics2D g2, int x) {

	Rectangle2D dataArea = getScreenDataArea();

	g2.setXORMode(Color.orange);
	if ((int) dataArea.getMinX() < x && x < (int) dataArea.getMaxX()) {

		if (this.verticalTraceLine != null) {
			g2.draw(this.verticalTraceLine);
			this.verticalTraceLine.setLine(x, (int) dataArea.getMinY(), x, (int) dataArea.getMaxY());
		} else {
			this.verticalTraceLine = new Line2D.Float(x, (int) dataArea.getMinY(), x, (int) dataArea.getMaxY());
		}
		g2.draw(this.verticalTraceLine);
	}

	// Reset to the default 'overwrite' mode
	g2.setPaintMode();
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:28,代码来源:AbstractChartPanel.java

示例2: drawVerticalAxisTrace

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Draws a horizontal line used to trace the mouse position to the vertical axis.
 * 
 * @param g2
 *            the graphics device.
 * @param y
 *            the y-coordinate of the trace line.
 */
private void drawVerticalAxisTrace(Graphics2D g2, int y) {

	Rectangle2D dataArea = getScreenDataArea();

	g2.setXORMode(Color.orange);
	if ((int) dataArea.getMinY() < y && y < (int) dataArea.getMaxY()) {

		if (this.horizontalTraceLine != null) {
			g2.draw(this.horizontalTraceLine);
			this.horizontalTraceLine.setLine((int) dataArea.getMinX(), y, (int) dataArea.getMaxX(), y);
		} else {
			this.horizontalTraceLine = new Line2D.Float((int) dataArea.getMinX(), y, (int) dataArea.getMaxX(), y);
		}
		g2.draw(this.horizontalTraceLine);
	}

	// Reset to the default 'overwrite' mode
	g2.setPaintMode();
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:28,代码来源:AbstractChartPanel.java

示例3: drawZoomRectangle

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Draws zoom rectangle (if present). The drawing is performed in XOR mode, therefore when this
 * method is called twice in a row, the second call will completely restore the state of the
 * canvas.
 * 
 * @param g2
 *            the graphics device.
 * @param xor
 *            use XOR for drawing?
 */
private void drawZoomRectangle(Graphics2D g2, boolean xor) {
	Rectangle2D zoomRectangle = (Rectangle2D) getChartFieldValueByName("zoomRectangle");
	if (zoomRectangle != null) {
		// fix rectangle parameters when chart is transformed
		zoomRectangle = coordinateTransformation.transformRectangle(zoomRectangle, this);
		if (!(coordinateTransformation instanceof NullCoordinateTransformation)) {
			g2 = coordinateTransformation.getTransformedGraphics(this);
		}
		if (xor) {
			// Set XOR mode to draw the zoom rectangle
			g2.setXORMode(Color.gray);
		}
		if ((Boolean) getChartFieldValueByName("fillZoomRectangle")) {
			g2.setPaint((Paint) getChartFieldValueByName("zoomFillPaint"));
			g2.fill(zoomRectangle);
		} else {
			g2.setPaint((Paint) getChartFieldValueByName("zoomOutlinePaint"));
			g2.draw(zoomRectangle);
		}
		if (xor) {
			// Reset to the default 'overwrite' mode
			g2.setPaintMode();
		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:36,代码来源:LinkAndBrushChartPanel.java

示例4: updateNativeImage

import java.awt.Graphics2D; //导入方法依赖的package包/类
synchronized void updateNativeImage(Image image) {
    if (isDisposed())
        return;

    boolean autosize = ((TrayIcon)target).isImageAutoSize();

    BufferedImage bufImage = new BufferedImage(TRAY_ICON_WIDTH, TRAY_ICON_HEIGHT,
                                               BufferedImage.TYPE_INT_ARGB);
    Graphics2D gr = bufImage.createGraphics();
    if (gr != null) {
        try {
            gr.setPaintMode();

            gr.drawImage(image, 0, 0, (autosize ? TRAY_ICON_WIDTH : image.getWidth(observer)),
                         (autosize ? TRAY_ICON_HEIGHT : image.getHeight(observer)), observer);

            createNativeImage(bufImage);

            updateNativeIcon(!firstUpdate);
            if (firstUpdate) firstUpdate = false;

        } finally {
            gr.dispose();
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:WTrayIconPeer.java

示例5: drawHorizontalAxisTrace

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Draws a vertical line used to trace the mouse position to the horizontal 
 * axis.
 *
 * @param g2 the graphics device.
 * @param x  the x-coordinate of the trace line.
 */
private void drawHorizontalAxisTrace(Graphics2D g2, int x) {

    Rectangle2D dataArea = getScreenDataArea();

    g2.setXORMode(Color.orange);
    if (((int) dataArea.getMinX() < x) && (x < (int) dataArea.getMaxX())) {

        if (this.verticalTraceLine != null) {
            g2.draw(this.verticalTraceLine);
            this.verticalTraceLine.setLine(x, (int) dataArea.getMinY(), x, 
                    (int) dataArea.getMaxY());
        }
        else {
            this.verticalTraceLine = new Line2D.Float(x, 
                    (int) dataArea.getMinY(), x, (int) dataArea.getMaxY());
        }
        g2.draw(this.verticalTraceLine);
    }

    // Reset to the default 'overwrite' mode
    g2.setPaintMode();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:30,代码来源:ChartPanel.java

示例6: drawVerticalAxisTrace

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Draws a horizontal line used to trace the mouse position to the vertical
 * axis.
 *
 * @param g2 the graphics device.
 * @param y  the y-coordinate of the trace line.
 */
private void drawVerticalAxisTrace(Graphics2D g2, int y) {

    Rectangle2D dataArea = getScreenDataArea();

    g2.setXORMode(Color.orange);
    if (((int) dataArea.getMinY() < y) && (y < (int) dataArea.getMaxY())) {

        if (this.horizontalTraceLine != null) {
            g2.draw(this.horizontalTraceLine);
            this.horizontalTraceLine.setLine((int) dataArea.getMinX(), y, 
                    (int) dataArea.getMaxX(), y);
        }
        else {
            this.horizontalTraceLine = new Line2D.Float(
                    (int) dataArea.getMinX(), y, (int) dataArea.getMaxX(), 
                    y);
        }
        g2.draw(this.horizontalTraceLine);
    }

    // Reset to the default 'overwrite' mode
    g2.setPaintMode();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:31,代码来源:ChartPanel.java

示例7: drawZoomRectangle

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Draws zoom rectangle (if present).
 * The drawing is performed in XOR mode, therefore
 * when this method is called twice in a row,
 * the second call will completely restore the state
 * of the canvas.
 * 
 * @param g2 the graphics device. 
 */
private void drawZoomRectangle(Graphics2D g2) {
    // Set XOR mode to draw the zoom rectangle
    g2.setXORMode(Color.gray);
    if (this.zoomRectangle != null) {
        if (this.fillZoomRectangle) {
            g2.fill(this.zoomRectangle);
        }
        else {
            g2.draw(this.zoomRectangle);
        }
    }
    // Reset to the default 'overwrite' mode
    g2.setPaintMode();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:24,代码来源:ChartPanel.java

示例8: createBufferedImage

import java.awt.Graphics2D; //导入方法依赖的package包/类
private static BufferedImage createBufferedImage() {
    BufferedImage image = new BufferedImage(128, 128,
                  BufferedImage.TYPE_4BYTE_ABGR_PRE);
    Graphics2D graph = image.createGraphics();
    graph.setPaintMode();
    graph.setColor(Color.orange);
    graph.fillRect(32, 32, 64, 64);
    graph.dispose();
    return image;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:ITXtTest.java

示例9: updateNativeImage

import java.awt.Graphics2D; //导入方法依赖的package包/类
synchronized void updateNativeImage(Image image) {
    if (isDisposed())
        return;

    boolean autosize = ((TrayIcon)target).isImageAutoSize();
    AffineTransform tx = GraphicsEnvironment.getLocalGraphicsEnvironment().
            getDefaultScreenDevice().getDefaultConfiguration().
            getDefaultTransform();
    int w = Region.clipScale(TRAY_ICON_WIDTH, tx.getScaleX());
    int h = Region.clipScale(TRAY_ICON_HEIGHT, tx.getScaleY());
    int imgWidth = Region.clipScale(image.getWidth(observer), tx.getScaleX());
    int imgHeight = Region.clipScale(image.getHeight(observer), tx.getScaleY());
    BufferedImage bufImage = new BufferedImage(w,
            h, BufferedImage.TYPE_INT_ARGB);
    Graphics2D gr = bufImage.createGraphics();
    if (gr != null) {
        try {
            gr.setPaintMode();

            gr.drawImage(image, 0, 0, (autosize ? w : imgWidth),
                         (autosize ? h : imgHeight), observer);

            createNativeImage(bufImage);

            updateNativeIcon(!firstUpdate);
            if (firstUpdate) firstUpdate = false;

        } finally {
            gr.dispose();
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:33,代码来源:WTrayIconPeer.java

示例10: renderSplashFrame

import java.awt.Graphics2D; //导入方法依赖的package包/类
static void renderSplashFrame(Graphics2D g, int frame) {
    final String[] comps = {"foo", "bar", "baz"};
    g.setComposite(AlphaComposite.Clear);
    g.fillRect(120, 140, 200, 40);
    g.setPaintMode();
    g.setColor(Color.BLACK);
    g.drawString("Loading " + comps[(frame / 5) % 3] + "...", 120, 150);
}
 
开发者ID:bcgov,项目名称:sbc-qsystem,代码行数:9,代码来源:Uses.java

示例11: drawSymbolicGridLinesHorizontal

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.
 * or if <CODE>firstGridLineIsDark</CODE> is <CODE>true</CODE> white and
 * the color specified by <CODE>symbolicGridPaint<CODE>.
 *
 * @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 firstGridLineIsDark  True: the first symbolic grid line take the
 *                             color of <CODE>symbolicGridPaint<CODE>.
 *                             False: the first symbolic grid line is white.
 * @param ticks  the ticks.
 */
public void drawSymbolicGridLinesHorizontal(Graphics2D g2,
                                            Rectangle2D plotArea, 
                                            Rectangle2D dataArea,
                                            boolean firstGridLineIsDark, 
                                            List ticks) {

    this.symbolicGridLineList = new Vector(ticks.size());
    boolean currentGridLineIsDark = firstGridLineIsDark;
    double yy = dataArea.getY();
    double xx1, xx2;

    //gets the outline stroke width of the plot
    double outlineStrokeWidth;
    if (getPlot().getOutlineStroke() !=  null) {
        outlineStrokeWidth = ((BasicStroke) getPlot().getOutlineStroke()).getLineWidth();
    }
    else {
        outlineStrokeWidth = 1d;
    }

    Iterator iterator = ticks.iterator();
    ValueTick tick;
    Rectangle2D symbolicGridLine;
    while (iterator.hasNext()) {
        tick = (ValueTick) iterator.next();
        xx1 = valueToJava2D(tick.getValue() - 0.5d, dataArea, RectangleEdge.BOTTOM);
        xx2 = valueToJava2D(tick.getValue() + 0.5d, dataArea, RectangleEdge.BOTTOM);
        if (currentGridLineIsDark) {
            g2.setPaint(this.symbolicGridPaint);
            //g2.setXORMode((Color) this.symbolicGridPaint);
        }
        else {
            g2.setPaint(Color.white);
            //g2.setXORMode(Color.white);
        }
        symbolicGridLine =
            new Rectangle2D.Double(xx1,
                                   yy + outlineStrokeWidth, xx2 - xx1,
                                   dataArea.getMaxY() - yy - outlineStrokeWidth);
        g2.fill(symbolicGridLine);
        this.symbolicGridLineList.add(symbolicGridLine);
        currentGridLineIsDark = !currentGridLineIsDark;
    }
    g2.setPaintMode();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:64,代码来源:SymbolicAxis.java

示例12: drawSymbolicGridLinesVertical

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.
 * or if <CODE>firstGridLineIsDark</CODE> is <CODE>true</CODE> white and
 * the color specified by <CODE>symbolicGridPaint<CODE>.
 *
 * @param g2  the graphics device.
 * @param drawArea  the area within which the chart should be drawn.
 * @param plotArea  the area within which the plot should be drawn (a
 *                  subset of the drawArea).
 * @param firstGridLineIsDark   True: the first symbolic grid line take the
 *      color of <CODE>symbolicGridPaint<CODE>.
 *      False: the first symbolic grid line is white.
 * @param ticks  a list of ticks.
 */
public void drawSymbolicGridLinesVertical(Graphics2D g2, Rectangle2D drawArea,
                                          Rectangle2D plotArea, boolean firstGridLineIsDark,
                                          List ticks) {

    this.symbolicGridLineList = new Vector(ticks.size());
    boolean currentGridLineIsDark = firstGridLineIsDark;
    double xx = plotArea.getX();
    double yy1, yy2;

    //gets the outline stroke width of the plot
    double outlineStrokeWidth;
    if (getPlot().getOutlineStroke() != null) {
        outlineStrokeWidth = ((BasicStroke) getPlot().getOutlineStroke()).getLineWidth();
    }
    else {
        outlineStrokeWidth = 1d;
    }

    Iterator iterator = ticks.iterator();
    ValueTick tick;
    Rectangle2D symbolicGridLine;
    while (iterator.hasNext()) {
        tick = (ValueTick) iterator.next();
        yy1 = valueToJava2D(tick.getValue() + 0.5d, plotArea, RectangleEdge.LEFT);
        yy2 = valueToJava2D(tick.getValue() - 0.5d, plotArea, RectangleEdge.LEFT);
        if (currentGridLineIsDark) {
            g2.setPaint(this.symbolicGridPaint);
            //g2.setXORMode((Color) getSymbolicGridPaint());
        }
        else {
            g2.setPaint(Color.white);
            //g2.setXORMode(Color.white);
        }
        symbolicGridLine = new Rectangle2D.Double(xx + outlineStrokeWidth,
            yy1, plotArea.getMaxX() - xx - outlineStrokeWidth, yy2 - yy1);
        g2.fill(symbolicGridLine);
        this.symbolicGridLineList.add(symbolicGridLine);
        currentGridLineIsDark = !currentGridLineIsDark;
    }
    g2.setPaintMode();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:60,代码来源:SymbolicAxis.java

示例13: drawGridBandsHorizontal

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Draws the grid bands for the axis when it is at the top or bottom of 
 * the plot.
 *
 * @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 firstGridBandIsDark  True: the first grid band takes the
 *                             color of <CODE>gridBandPaint<CODE>.
 *                             False: the second grid band takes the 
 *                             color of <CODE>gridBandPaint<CODE>.
 * @param ticks  the ticks.
 */
protected void drawGridBandsHorizontal(Graphics2D g2,
                                       Rectangle2D plotArea, 
                                       Rectangle2D dataArea,
                                       boolean firstGridBandIsDark, 
                                       List ticks) {

    boolean currentGridBandIsDark = firstGridBandIsDark;
    double yy = dataArea.getY();
    double xx1, xx2;

    //gets the outline stroke width of the plot
    double outlineStrokeWidth;
    if (getPlot().getOutlineStroke() !=  null) {
        outlineStrokeWidth 
            = ((BasicStroke) getPlot().getOutlineStroke()).getLineWidth();
    }
    else {
        outlineStrokeWidth = 1d;
    }

    Iterator iterator = ticks.iterator();
    ValueTick tick;
    Rectangle2D band;
    while (iterator.hasNext()) {
        tick = (ValueTick) iterator.next();
        xx1 = valueToJava2D(tick.getValue() - 0.5d, dataArea, 
                RectangleEdge.BOTTOM);
        xx2 = valueToJava2D(tick.getValue() + 0.5d, dataArea, 
                RectangleEdge.BOTTOM);
        if (currentGridBandIsDark) {
            g2.setPaint(this.gridBandPaint);
        }
        else {
            g2.setPaint(Color.white);
        }
        band = new Rectangle2D.Double(xx1, yy + outlineStrokeWidth, 
            xx2 - xx1, dataArea.getMaxY() - yy - outlineStrokeWidth);
        g2.fill(band);
        currentGridBandIsDark = !currentGridBandIsDark;
    }
    g2.setPaintMode();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:57,代码来源:SymbolAxis.java

示例14: drawGridBandsVertical

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Draws the grid bands for the axis when it is at the top or bottom of 
 * the plot.
 *
 * @param g2  the graphics device.
 * @param drawArea  the area within which the chart should be drawn.
 * @param plotArea  the area within which the plot should be drawn (a
 *                  subset of the drawArea).
 * @param firstGridBandIsDark  True: the first grid band takes the
 *                             color of <CODE>gridBandPaint<CODE>.
 *                             False: the second grid band takes the 
 *                             color of <CODE>gridBandPaint<CODE>.
 * @param ticks  a list of ticks.
 */
protected void drawGridBandsVertical(Graphics2D g2, 
                                     Rectangle2D drawArea,
                                     Rectangle2D plotArea, 
                                     boolean firstGridBandIsDark,
                                     List ticks) {

    boolean currentGridBandIsDark = firstGridBandIsDark;
    double xx = plotArea.getX();
    double yy1, yy2;

    //gets the outline stroke width of the plot
    double outlineStrokeWidth;
    Stroke outlineStroke = getPlot().getOutlineStroke();
    if (outlineStroke != null && outlineStroke instanceof BasicStroke) {
        outlineStrokeWidth = ((BasicStroke) outlineStroke).getLineWidth();
    }
    else {
        outlineStrokeWidth = 1d;
    }

    Iterator iterator = ticks.iterator();
    ValueTick tick;
    Rectangle2D band;
    while (iterator.hasNext()) {
        tick = (ValueTick) iterator.next();
        yy1 = valueToJava2D(tick.getValue() + 0.5d, plotArea, 
                RectangleEdge.LEFT);
        yy2 = valueToJava2D(tick.getValue() - 0.5d, plotArea, 
                RectangleEdge.LEFT);
        if (currentGridBandIsDark) {
            g2.setPaint(this.gridBandPaint);
        }
        else {
            g2.setPaint(Color.white);
        }
        band = new Rectangle2D.Double(xx + outlineStrokeWidth, yy1, 
                plotArea.getMaxX() - xx - outlineStrokeWidth, yy2 - yy1);
        g2.fill(band);
        currentGridBandIsDark = !currentGridBandIsDark;
    }
    g2.setPaintMode();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:57,代码来源:SymbolAxis.java


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