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


Java Graphics.setXORMode方法代码示例

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


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

示例1: paint

import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paint(Graphics g) {
    if (g == null || !(g instanceof Graphics2D)) {
        return;
    }
    g.setColor(Color.white);
    g.setXORMode(Color.black);
    Graphics2D dg = (Graphics2D) g;
    Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT,
            BasicStroke.JOIN_MITER,
            10.0f,
            new float[]{1.0f, 1.0f},
            0.0f);
    dg.setStroke(stroke);
    try {
        dg.draw(new Line2D.Float(10, 10, 20, 20));
    } catch (Throwable e) {
        synchronized (this) {
            theError = e;
        }
    } finally {
        didDraw.countDown();
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:25,代码来源:DrawXORModeTest.java

示例2: paint

import java.awt.Graphics; //导入方法依赖的package包/类
public void paint(Graphics g) {
    g.setXORMode(Color.white); //Color of line varies
    
    for (DragItem elem : allItems) {
        elem.paint(g);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:DragManager.java

示例3: _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

示例4: _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

示例5: 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

示例6: _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

示例7: paint

import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paint(Graphics g) {
    JTextComponent comp = getComponent();
    if (comp == null) {
        return;
    }

    int dot = getDot();

    Rectangle rectangle;
    char dotChar;
    try {
        rectangle = comp.modelToView(dot);
        if (rectangle == null) {
            return;
        }
        dotChar = comp.getText(dot, 1).charAt(0);
    } catch (BadLocationException e) {
        return;
    }

    if (dotChar == '\r' || dotChar == '\n') {
        dotChar = ' ';
    }

    if ((x != rectangle.x) || (y != rectangle.y)) {
        repaint();
        x = rectangle.x;
        y = rectangle.y;
        height = rectangle.height;
    }

    g.setColor(comp.getCaretColor());
    g.setXORMode(comp.getBackground());

    width = g.getFontMetrics().charWidth(dotChar);
    if (width <= 0) {
        width = g.getFontMetrics().charWidth(' ');
    }

    if (isVisible()) {
        g.fillRect(rectangle.x, rectangle.y, width, rectangle.height);
    }
}
 
开发者ID:pascalgn,项目名称:jiracli,代码行数:45,代码来源:BlockCaret.java


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