List of usage examples for java.awt Graphics2D setPaintMode
public abstract void setPaintMode();
From source file:JDK6SplashTest.java
static void renderSplashFrame(Graphics2D g, int frame) { final String[] comps = { "foo", "bar", "baz" }; g.setComposite(AlphaComposite.Clear); g.fillRect(130, 250, 280, 40);/* w w w. j a v a 2 s.c o m*/ g.setPaintMode(); g.setColor(Color.BLACK); g.drawString("Loading " + comps[(frame / 5) % 3] + "...", 130, 260); g.fillRect(130, 270, (frame * 10) % 280, 20); }
From source file:SplashDemo.java
static void renderSplashFrame(Graphics2D g, int frame) { final String[] comps = { "foo", "bar", "baz" }; g.setComposite(AlphaComposite.Clear); g.fillRect(120, 140, 200, 40);/*from w w w . j a va 2s . co m*/ g.setPaintMode(); g.setColor(Color.BLACK); g.drawString("Loading " + comps[(frame / 5) % 3] + "...", 120, 150); }
From source file:de.brazzy.nikki.model.ImageReader.java
/** * Scales image to given size, preserving aspec ratio * // ww w . ja v a2s . c om * @param toWidth * width to scale to * @param paintBorder * whether to paint an etched border around the image * @param isThumbnail * if true, faster low-quality scaling will be used */ public byte[] scale(int toWidth, boolean paintBorder, boolean isThumbnail) throws IOException, LLJTranException { readMainImage(); int toHeight = heightForWidth(mainImage, toWidth); BufferedImageOp op = isThumbnail ? new ThumpnailRescaleOp(toWidth, toHeight) : new ResampleOp(toWidth, toHeight); BufferedImage scaledImage = op.filter(mainImage, null); if (paintBorder) { Graphics2D g = scaledImage.createGraphics(); g.setPaintMode(); new EtchedBorder(EtchedBorder.RAISED, Color.LIGHT_GRAY, Color.DARK_GRAY).paintBorder(null, g, 0, 0, toWidth, toHeight); } ByteArrayOutputStream out = new ByteArrayOutputStream(); ImageIO.write(scaledImage, "jpg", out); return adjustForRotation(out.toByteArray()); }
From source file:dbseer.gui.panel.DBSeerExplainChartPanel.java
private void drawSelectRectangle(Graphics2D g2) { if (selectRectangle != null) { g2.setXORMode(Color.GRAY); g2.fill(this.selectRectangle); g2.setPaintMode(); }//ww w. j av a 2 s.co m }
From source file:org.fhcrc.cpl.viewer.mrm.utilities.MRMerMouseListener.java
/** * Draws zoom rectangle (if present)./*w w w . j a v a 2 s . c om*/ * 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 drawCoElutionRegion(Graphics2D g2) { // Set XOR mode to draw the zoom rectangle if (g2 == null) return; Paint origColor = g2.getPaint(); // g2.setXORMode(Color.gray); g2.setXORMode(new Color(30, 10, 30, 5)); if (this.coElutionRegion != null) { g2.fill(this.coElutionRegion); g2.setPaint(Color.white); g2.setStroke(new BasicStroke(3.0f)); g2.draw(this.coElutionRegion); } g2.setPaintMode(); g2.setPaint(origColor); }
From source file:org.fhcrc.cpl.toolbox.gui.chart.ChartMouseAndMotionListener.java
/** * Draws zoom rectangle (if present)./*from w w w . j a va 2 s. com*/ * 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 selectedRegion * @param stroke * @param fillColor */ protected void drawSelectedRegion(Rectangle2D selectedRegion, Stroke stroke, Color fillColor, boolean xorMode, Graphics2D g2) { // Set XOR mode to draw the zoom rectangle if (g2 == null) return; Paint origColor = g2.getPaint(); if (selectedRegion != null) { if (xorMode) { g2.setXORMode(fillColor); } else g2.setPaint(fillColor); g2.fill(selectedRegion); g2.setPaint(Color.black); g2.setStroke(stroke); if (xorMode) g2.setPaint(Color.white); else g2.setPaint(Color.black); g2.draw(selectedRegion); g2.setPaintMode(); g2.setPaint(origColor); } }
From source file:MWC.GUI.JFreeChart.StepperXYPlot.java
/** * draw the new stepper line into the plot * //from w w w .j a v a 2 s . c om * @param g2 * @param linePosition * @param dataArea */ protected void plotStepperLine(final Graphics2D g2, final double linePosition, final Rectangle2D dataArea) { // prepare to draw final Stroke oldStroke = g2.getStroke(); g2.setXORMode(Color.darkGray); // thicken up the line g2.setStroke(new BasicStroke(3)); if (this.getOrientation() == PlotOrientation.VERTICAL) { // draw the line g2.drawLine((int) linePosition - 1, (int) dataArea.getY() + 1, (int) linePosition - 1, (int) dataArea.getY() + (int) dataArea.getHeight() - 1); } else { // draw the line g2.drawLine((int) dataArea.getY() + 1, (int) linePosition - 1, (int) dataArea.getY() + (int) dataArea.getHeight() - 1, (int) linePosition - 1); } // and restore everything g2.setStroke(oldStroke); g2.setPaintMode(); }
From source file:com.rapidminer.gui.plotter.charts.WeightBasedSymbolAxis.java
/** * Draws the grid bands for the axis when it is at the top or bottom of the plot. * //from ww w. j a va 2 s .c o m * @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. */ @Override protected void drawGridBandsHorizontal(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, boolean firstGridBandIsDark, List ticks) { 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(); int weightIndex = (int) tick.getValue(); xx1 = valueToJava2D(tick.getValue() - 0.5d, dataArea, RectangleEdge.BOTTOM); xx2 = valueToJava2D(tick.getValue() + 0.5d, dataArea, RectangleEdge.BOTTOM); g2.setColor(PlotterAdapter.getWeightColor(this.weights[weightIndex], this.maxWeight)); band = new Rectangle2D.Double(xx1, yy + outlineStrokeWidth, xx2 - xx1, dataArea.getMaxY() - yy - outlineStrokeWidth); g2.fill(band); } g2.setPaintMode(); }
From source file:HelloUniverse.java
private void drawZPip(Graphics2D g2, float zAngle) { AffineTransform trans = new AffineTransform(); Color origColor = g2.getColor(); trans.translate(margin, margin);// www . j a v a2s.co m trans.rotate(zAngle, diameter / 2, diameter / 2); g2.setXORMode(getBackground()); g2.setTransform(trans); g2.setColor(Color.red); g2.fillPolygon(zPip); // Reset graphics context trans.setToIdentity(); g2.setTransform(trans); g2.setColor(origColor); g2.setPaintMode(); }
From source file:com.rapidminer.gui.plotter.charts.WeightBasedSymbolAxis.java
/** * Draws the grid bands for the axis when it is at the top or bottom of the plot. * /*from w ww . ja va 2 s . c o m*/ * @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. */ @Override protected void drawGridBandsVertical(Graphics2D g2, Rectangle2D drawArea, Rectangle2D plotArea, boolean firstGridBandIsDark, List ticks) { 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(); int weightIndex = (int) tick.getValue(); yy1 = valueToJava2D(tick.getValue() + 0.5d, plotArea, RectangleEdge.LEFT); yy2 = valueToJava2D(tick.getValue() - 0.5d, plotArea, RectangleEdge.LEFT); g2.setColor(PlotterAdapter.getWeightColor(this.weights[weightIndex], this.maxWeight)); band = new Rectangle2D.Double(xx + outlineStrokeWidth, yy1, plotArea.getMaxX() - xx - outlineStrokeWidth, yy2 - yy1); g2.fill(band); } g2.setPaintMode(); }