當前位置: 首頁>>代碼示例>>Java>>正文


Java Graphics.setPaintMode方法代碼示例

本文整理匯總了Java中java.awt.Graphics.setPaintMode方法的典型用法代碼示例。如果您正苦於以下問題:Java Graphics.setPaintMode方法的具體用法?Java Graphics.setPaintMode怎麽用?Java Graphics.setPaintMode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.Graphics的用法示例。


在下文中一共展示了Graphics.setPaintMode方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: _editPoint

import java.awt.Graphics; //導入方法依賴的package包/類
private synchronized void _editPoint(int x, int y) {

        if (_dataset < 0) return;

        Graphics graphics = getGraphics();
        // constrain to be in range
        if (y > _lry) y = _lry;
        if (y < _uly) y = _uly;
        if (x > _lrx) x = _lrx;
        if (x < _ulx) x = _ulx;

        if (x <= _currentEditX || x >= _lrx) {
            // ignore
            return;
        }
        int step = _currentEditX;
        while (step <= x) {
            int index = step-(_lrx-_editSpecX.length);
            double proportion =
                (step - _currentEditX)/(double)(x - _currentEditX);
            int newY = (int)(_currentEditY + proportion*(y-_currentEditY));
            if (!_editSpecSet[index]) {
                _editSpecX[index] = step;
                _editSpecY[index] = newY;
                _editSpecSet[index] = true;

                // Draw point, linearly interpolated from previous point
                graphics.setXORMode(_editColor);
                graphics.drawLine(step, newY-1, step, newY+1);
                graphics.setPaintMode();
            }
            step++;
        }
        _currentEditX = x;
        _currentEditY = y;
    }
 
開發者ID:OpenDA-Association,項目名稱:OpenDA,代碼行數:37,代碼來源:EditablePlot.java

示例2: _editStart

import java.awt.Graphics; //導入方法依賴的package包/類
private synchronized void _editStart(int x, int y) {

        if (_dataset < 0) return;

        // constrain to be in range
        if (y > _lry) y = _lry;
        if (y < _uly) y = _uly;
        if (x > _lrx) x = _lrx;
        if (x < _ulx) x = _ulx;

        // Allocate a vector to store the points.
        int size = _lrx - x + 1;
        _editSpecX = new int[size];
        _editSpecY = new int[size];
        _editSpecSet = new boolean[size];

        _editSpecX[0] = x;
        _editSpecY[0] = y;
        _editSpecSet[0] = true;

        _currentEditX = x;
        _currentEditY = y;

        Graphics graphics = getGraphics();
        // Draw point (as a 3 pixel vertical line, for thickness)
        graphics.setXORMode(_editColor);
        graphics.drawLine(x, y-1, x, y+1);
        graphics.setPaintMode();
    }
 
開發者ID:OpenDA-Association,項目名稱:OpenDA,代碼行數:30,代碼來源:EditablePlot.java

示例3: paint

import java.awt.Graphics; //導入方法依賴的package包/類
public void paint(Graphics g) {
    super.paint(g);
    g.setColor(getForeground());
    TextLayout layout = composedTextLayout;
    if (layout != null) {
        layout.draw((Graphics2D) g, TEXT_ORIGIN_X, TEXT_ORIGIN_Y);
    }
    if (caret != null) {
        Rectangle rectangle = getCaretRectangle(caret);
        g.setXORMode(getBackground());
        g.fillRect(rectangle.x, rectangle.y, 1, rectangle.height);
        g.setPaintMode();
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:15,代碼來源:CompositionArea.java

示例4: _drawPlotPoint

import java.awt.Graphics; //導入方法依賴的package包/類
private void _drawPlotPoint(Graphics graphics,
        int dataset, int index) {
    if (_pointsPersistence > 0 || _xPersistence > 0.0) {
        // To allow erasing to work by just redrawing the points.
        if (_background == null) {
            // java.awt.Component.setBackground(color) says that
            // if the color "parameter is null then this component
            // will inherit the  background color of its parent."
            graphics.setXORMode(getBackground());
        } else {
            graphics.setXORMode(_background);
        }
    }
    // Set the color
    if (_usecolor) {
        int color = dataset % _colors.length;
        graphics.setColor(_colors[color]);
    } else {
        graphics.setColor(_foreground);
    }

    Vector pts = (Vector)_points.elementAt(dataset);
    PlotPoint pt = (PlotPoint)pts.elementAt(index);
    // Use long here because these numbers can be quite large
    // (when we are zoomed out a lot).
    long ypos = _lry - (long)((pt.y - _yMin) * _yscale);
    long xpos = _ulx + (long)((pt.x - _xMin) * _xscale);

    // Draw the line to the previous point.
    long prevx = ((Long)_prevx.elementAt(dataset)).longValue();
    long prevy = ((Long)_prevy.elementAt(dataset)).longValue();
    // MIN_VALUE is a flag that there has been no previous x or y.
    if (pt.connected) {
        _drawLine(graphics, dataset, xpos, ypos, prevx, prevy, true, 2f);
    }

    // Save the current point as the "previous" point for future
    // line drawing.
    _prevx.setElementAt(new Long(xpos), dataset);
    _prevy.setElementAt(new Long(ypos), dataset);

    // Draw decorations that may be specified on a per-dataset basis
    Format fmt = (Format)_formats.elementAt(dataset);
    if (fmt.impulsesUseDefault) {
        if (_impulses) _drawImpulse(graphics, xpos, ypos, true);
    } else {
        if (fmt.impulses) _drawImpulse(graphics, xpos, ypos, true);
    }

    // Check to see whether the dataset has a marks directive
    int marks = _marks;
    if (!fmt.marksUseDefault) marks = fmt.marks;
    if (marks != 0) _drawPoint(graphics, dataset, xpos, ypos, true);

    if (_bars) _drawBar(graphics, dataset, xpos, ypos, true);
    if (pt.errorBar)
        _drawErrorBar(graphics, dataset, xpos,
                _lry - (long)((pt.yLowEB - _yMin) * _yscale),
                _lry - (long)((pt.yHighEB - _yMin) * _yscale), true);

    // Restore the color, in case the box gets redrawn.
    graphics.setColor(_foreground);
    if (_pointsPersistence > 0 || _xPersistence > 0.0) {
        // Restore paint mode in case axes get redrawn.
        graphics.setPaintMode();
    }
}
 
開發者ID:OpenDA-Association,項目名稱:OpenDA,代碼行數:68,代碼來源:Plot.java


注:本文中的java.awt.Graphics.setPaintMode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。