Java Code Examples for java.awt.Graphics#setXORMode()
The following examples show how to use
java.awt.Graphics#setXORMode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DrawXORModeTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@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(); } }
Example 2
Source File: DrawXORModeTest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@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(); } }
Example 3
Source File: DrawXORModeTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@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(); } }
Example 4
Source File: DrawXORModeTest.java From hottub with GNU General Public License v2.0 | 6 votes |
@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(); } }
Example 5
Source File: DrawXORModeTest.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
@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(); } }
Example 6
Source File: BasicScreenUI.java From tn5250j with GNU General Public License v2.0 | 6 votes |
protected void paintCursor(Graphics g) { // if (cursorEnabled) // { // iOhioPosition pos = screen.getCursor(); // if (screen.cursorShown) { iOhioPosition pos = new iOhioPosition(screen.getCurrentRow(),screen.getCurrentCol()); // // System.out.println("Cursor at " + pos.getColumn() + "," + pos.getRow()); Rectangle r = modelToView(pos); // g.setColor(Color.red); // g.setXORMode(Color.red); g.setColor(Color.red); g.setXORMode(colorBg); g.fillRect(r.x, r.y, r.width, r.height); g.setPaintMode(); // } // } }
Example 7
Source File: CompositionArea.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
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(); } }
Example 8
Source File: CompositionArea.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
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(); } }
Example 9
Source File: CompositionArea.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
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(); } }
Example 10
Source File: CompositionArea.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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(); } }
Example 11
Source File: DragManager.java From netbeans with Apache License 2.0 | 5 votes |
public void paint(Graphics g) { g.setXORMode(Color.white); //Color of line varies for (DragItem elem : allItems) { elem.paint(g); } }
Example 12
Source File: CompositionArea.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
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(); } }
Example 13
Source File: EditablePlot.java From OpenDA with GNU Lesser General Public License v3.0 | 5 votes |
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(); }
Example 14
Source File: PortraitPane.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected void paintComponent(Graphics g) { Insets insets = getInsets(); if (scale < 1) { int width = (int) (scale * portrait.getWidth()); int height = (int) (scale * portrait.getHeight()); g.drawImage(portrait, insets.left, insets.top, width, height, this); } else { g.drawImage(portrait, insets.left, insets.top, this); } g.setColor(Color.BLACK); g.setXORMode(Color.WHITE); if (cropRect != null) { if (scale < 1) { g.drawRect(((int) (cropRect.x * scale)) + insets.left, ((int) (cropRect.y * scale)) + insets.top, (int) (cropRect.width * scale), (int) (cropRect.height * scale)); } else { g.drawRect(cropRect.x + insets.left, cropRect.y + insets.top, cropRect.width, cropRect.height); } } }
Example 15
Source File: CompositionArea.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
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(); } }
Example 16
Source File: CompositionArea.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
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(); } }
Example 17
Source File: CompositionArea.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
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(); } }
Example 18
Source File: ProductSceneView.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
private void drawPixelBorder(int currentPixelX, int currentPixelY, int currentLevel, boolean showBorder) { final Graphics g = getGraphics(); g.setXORMode(Color.white); if (pixelBorderDrawn) { drawPixelBorder(g, currentLevelPixelX, currentLevelPixelY, this.currentLevel); pixelBorderDrawn = false; } if (showBorder) { drawPixelBorder(g, currentPixelX, currentPixelY, currentLevel); pixelBorderDrawn = true; } g.setPaintMode(); g.dispose(); }
Example 19
Source File: Plot.java From opt4j with MIT License | 4 votes |
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<PlotPoint> pts = _points.elementAt(dataset); PlotPoint pt = 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 = _prevx.elementAt(dataset).longValue(); long prevy = _prevy.elementAt(dataset).longValue(); // Avoid drawing points and lines that are invisible. // Note that if the size of the dataset is 1, then we have only // one point, so we should be sure to draw it. if ((xpos != prevx) || (ypos != prevy) || (pts.size() == 1)) { // 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(Long.valueOf(xpos), dataset); _prevy.setElementAt(Long.valueOf(ypos), dataset); // Draw decorations that may be specified on a per-dataset basis Format fmt = _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(); } }
Example 20
Source File: Plot.java From OpenDA with GNU Lesser General Public License v3.0 | 4 votes |
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(); } }