List of usage examples for java.awt Graphics2D setPaintMode
public abstract void setPaintMode();
From source file:org.gvsig.remotesensing.scatterplot.chart.ScatterPlotDiagram.java
/** * * Pinta el rectangulo sombreado mientras se realiza la seleccin * @param g2 the graphics device. /*from w w w .j a v a2 s . co m*/ */ private void drawRectangle(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(); }
From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.link_and_brush.LinkAndBrushChartPanel.java
/** * 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./* w ww.j ava2 s .c om*/ * * @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(); } } }
From source file:HelloUniverse.java
private void drawXPip(Graphics2D g2, float angle) { AffineTransform trans = new AffineTransform(); int y;// w ww . j a va 2s. c o m int xOrig = margin + diameter + space; int yOrig = margin; Color origColor = g2.getColor(); if (angle <= Math.PI) { y = yOrig + diameter - (int) ((Math.abs(angle - Math.PI / 2) / (Math.PI / 2)) * diameter / 2); } else y = yOrig + (int) ((Math.abs((angle - Math.PI * 1.5)) / (Math.PI / 2)) * diameter / 2); if (angle < Math.PI / 2 || angle > Math.PI * 1.5) g2.setColor(Color.red); // Infront of wheel else { g2.setColor(Color.black); // Behind Wheel g2.setClip(xBackClip); } g2.setXORMode(getBackground()); trans.setToTranslation(xOrig + pipOffset, y); g2.setTransform(trans); g2.fillPolygon(xPip); // Reset graphics context trans.setToIdentity(); g2.setTransform(trans); g2.setColor(origColor); g2.setPaintMode(); }
From source file:HelloUniverse.java
private void drawYPip(Graphics2D g2, float angle) { AffineTransform trans = new AffineTransform(); int x;// ww w . ja v a2 s .co m int xOrig = margin; int yOrig = margin + diameter + space; Color origColor = g2.getColor(); if (angle <= Math.PI) { x = xOrig + diameter - (int) ((Math.abs(angle - Math.PI / 2) / (Math.PI / 2)) * diameter / 2); } else x = xOrig + (int) ((Math.abs((angle - Math.PI * 1.5)) / (Math.PI / 2)) * diameter / 2); if (angle < Math.PI / 2 || angle > Math.PI * 1.5) g2.setColor(Color.red); // Infront on wheel else { g2.setColor(Color.black); // Behind Wheel g2.setClip(yBackClip); } g2.setXORMode(getBackground()); trans.setToTranslation(x, yOrig + pipOffset); g2.setTransform(trans); g2.fillPolygon(yPip); // Reset graphics context trans.setToIdentity(); g2.setTransform(trans); g2.setColor(origColor); g2.setPaintMode(); }
From source file:com.isti.traceview.common.TraceViewChartPanel.java
/** * 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.//from w w w . j a v a2 s .c om * * @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(); }
From source file:com.isti.traceview.common.TraceViewChartPanel.java
/** * Draws a vertical line used to trace the mouse position to the horizontal axis. * //from w w w . j av a 2s. com * @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(); }
From source file:com.isti.traceview.common.TraceViewChartPanel.java
/** * Draws a horizontal line used to trace the mouse position to the vertical axis. * //from ww w .j a v a2 s . c o m * @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(); }
From source file:org.rdv.viz.chart.ChartPanel.java
/** * Draws a vertical line used to trace the mouse position to the horizontal * axis.//from w w w. ja va 2 s . c o m * * @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(); }
From source file:org.rdv.viz.chart.ChartPanel.java
/** * Draws a horizontal line used to trace the mouse position to the vertical * axis./*ww w .ja v a 2s . c o m*/ * * @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(); }
From source file:org.tsho.dmc2.core.chart.TrajectoryRenderer.java
public void render(final Graphics2D g2, final Rectangle2D dataArea, final PlotRenderingInfo info) { ValueAxis domainAxis = plot.getDomainAxis(); ValueAxis rangeAxis = plot.getRangeAxis(); Stroke stroke = new BasicStroke(7f); Stroke origStroke = g2.getStroke(); Color color = Color.BLACK; /* transients */ if (!continua) { stepper.initialize();// w w w . j a v a 2 s .c o m state = STATE_TRANSIENTS; try { for (index = 0; index < transients; index++) { stepper.step(); if (stopped) { state = STATE_STOPPED; return; } } } catch (RuntimeException re) { throw new RuntimeException(re); } index = 0; prevX = 0; prevY = 0; } state = STATE_POINTS; Stepper.Point2D point; double[] fullPoint = new double[dataset.getNcol()]; dataset.clearRows(); int x, y; int start = index; int end = 0; if (index == 0) { end = start + iterations + 1; } else { end = start + iterations; } for (; index < end; index++) { point = stepper.getCurrentPoint2D(); stepper.getCurrentValue(fullPoint); try { dataset.addRow((double[]) fullPoint.clone()); } catch (DatasetException e) { System.err.println(e); } if (!timePlot) { x = (int) domainAxis.valueToJava2D(point.getX(), dataArea, RectangleEdge.BOTTOM); } else { x = (int) domainAxis.valueToJava2D(index + transients, dataArea, RectangleEdge.BOTTOM); } y = (int) rangeAxis.valueToJava2D(point.getY(), dataArea, RectangleEdge.LEFT); if (Double.isNaN(point.getX()) || Double.isNaN(point.getY())) { System.err.println("NaN values at iteration " + index); //FIXME //Don't simply throw exception: that would mess up the state machine! //throw new RuntimeException("NaN values at iteration " + index); } if (delay > 0) { boolean flag = false; try { Thread.sleep(delay * 5); drawItem(g2, index, x, y); g2.setXORMode(color); g2.setStroke(stroke); g2.drawRect(x - 1, y - 1, 3, 3); flag = true; Thread.sleep(delay * 5); } catch (final InterruptedException e) { } if (flag) { g2.drawRect(x - 1, y - 1, 3, 3); g2.setPaintMode(); g2.setStroke(origStroke); } else { drawItem(g2, index, x, y); } } else { drawItem(g2, index, x, y); } try { stepper.step(); } catch (RuntimeException re) { throw new RuntimeException(re); } if (stopped) { state = STATE_STOPPED; return; } } state = STATE_FINISHED; }