List of usage examples for java.awt Graphics2D draw
public abstract void draw(Shape s);
From source file:org.processmining.analysis.performance.sequence.Pattern.java
/** * Draws a rectangle of width 20, height length and starting point * (startX,startY) in the northwest corner of the rectangle. In case * logicSteps is true, the height is 10. * /*from w w w . j ava 2 s . com*/ * @param startX * double * @param startY * double * @param length * double * @param logicSteps * boolean * @param g * Graphics2D */ public void drawRectangle(double startX, double startY, double length, boolean logicSteps, Graphics2D g) { Rectangle2D r = new Rectangle2D.Double(startX, startY, 20, length); if (logicSteps) { r = new Rectangle2D.Double(startX, startY, 20, 10); } Color initialColor = g.getColor(); Paint initialPaint = g.getPaint(); GradientPaint towhite = new GradientPaint(((Double) startX).floatValue(), ((Double) startY).floatValue(), initialColor, ((Double) startX).floatValue() + 20, ((Double) (startY)).floatValue(), Color.WHITE); g.setPaint(towhite); g.fill(r); g.setPaint(initialPaint); g.setColor(Color.BLACK); g.draw(r); g.setColor(initialColor); }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.PeakListChartPanel.java
public void mouseReleased(MouseEvent e) { if (MouseUtils.isPopupTrigger(e)) { // clear all if (zoom_rectangle != null) { Graphics2D g2 = (Graphics2D) getGraphics(); g2.setXORMode(java.awt.Color.gray); g2.draw(zoom_rectangle); g2.dispose();/*from www.j ava2s.c o m*/ } mouse_start_point = null; zoom_rectangle = null; // open popup current_peak = findPeakAt(e.getPoint()); enforceSelection(current_peak); createPopupMenu(current_peak != null).show(theChartPanel, e.getX(), e.getY()); } else { if (zoom_rectangle != null && mouse_start_point != null) { if (Math.abs(e.getX() - mouse_start_point.getX()) > 10) { //if( e.getX() < mouse_start_point.getX() ) { // unzoom all // onZoomNone(); //} //else { // zoom area double start_x = Math.min(e.getX(), mouse_start_point.getX()); double end_x = Math.max(e.getX(), mouse_start_point.getX()); Rectangle2D data_area = theChartPanel.getScreenDataArea((int) start_x, (int) mouse_start_point.getY()); double new_lower_bound = screenToDataCoordX(start_x); double new_upper_bound = screenToDataCoordX(Math.min(end_x, data_area.getMaxX())); thePlot.getDomainAxis().setRange(new Range(new_lower_bound, new_upper_bound)); } else { // clear rectangle Graphics2D g2 = (Graphics2D) getGraphics(); g2.setXORMode(java.awt.Color.gray); g2.draw(zoom_rectangle); g2.dispose(); } } // restore zooming if (!was_moving && is_moving) onActivateZooming(); zoom_rectangle = null; mouse_start_point = null; } }
From source file:com.rapidminer.gui.plotter.charts.RapidXYBarPainter.java
@Override public void paintBar(Graphics2D g2, XYBarRenderer renderer, int row, int column, RectangularShape bar, RectangleEdge base) {//w w w .java 2 s .c o m Paint itemPaint = renderer.getItemPaint(row, column); Color c0 = null; if (itemPaint instanceof Color) { c0 = (Color) itemPaint; } else { c0 = SwingTools.DARK_BLUE; } // as a special case, if the bar color has alpha == 0, we draw // nothing. if (c0.getAlpha() == 0) { return; } g2.setPaint(c0); g2.fill(new Rectangle2D.Double(bar.getMinX(), bar.getMinY(), bar.getWidth(), bar.getHeight())); // draw the outline... if (renderer.isDrawBarOutline()) { Stroke stroke = renderer.getItemOutlineStroke(row, column); Paint paint = renderer.getItemOutlinePaint(row, column); if (stroke != null && paint != null) { g2.setStroke(stroke); g2.setPaint(paint); g2.draw(bar); } } }
From source file:org.squidy.designer.shape.ZoomShape.java
@Override protected void paintAfterChildren(PPaintContext paintContext) { super.paintAfterChildren(paintContext); Graphics2D g = paintContext.getGraphics(); if (multiSelection != null) { g.setColor(COLOR_MULTI_SELECTION); g.fill(globalToLocal((Rectangle2D) ((RectangularShape) multiSelection).clone())); g.setColor(Color.BLUE);/*from www . j a v a 2 s . c om*/ // System.out.println(getGlobalScale()); g.setStroke(STROKE_MULTI_SELECTION); g.draw(globalToLocal((Rectangle2D) ((RectangularShape) multiSelection).clone())); } }
From source file:gov.nih.nci.caintegrator.application.geneexpression.BoxAndWhiskerCoinPlotRenderer.java
private double drawMean(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, ValueAxis rangeAxis, int row, int column, BoxAndWhiskerCategoryDataset bawDataset, double xx, double aRadius, RectangleEdge location) { double yyAverage; double newARadius = aRadius; // draw mean - SPECIAL AIMS REQUIREMENT... Number yMean = bawDataset.getMeanValue(row, column); if (yMean != null) { yyAverage = rangeAxis.valueToJava2D(yMean.doubleValue(), dataArea, location); newARadius = state.getBarWidth() / 4; Ellipse2D.Double avgEllipse = new Ellipse2D.Double(xx + aRadius, yyAverage - aRadius, aRadius * 2, aRadius * 2);// w w w .ja v a2s . c om g2.fill(avgEllipse); g2.draw(avgEllipse); } return newARadius; }
From source file:business.ImageManager.java
private void doDrawRastro(Graphics2D big, int direcao, int x, int y, Color color) { //setup para os rastros big.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); big.setStroke(/*from ww w . ja v a 2 s. c o m*/ new BasicStroke(2f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1f, new float[] { 5f }, 0f)); big.setColor(color); //draw path Path2D.Double path = new Path2D.Double(); path.moveTo(x + 38, y + 38); path.lineTo(x + coordRastros[direcao - 1][0], y + coordRastros[direcao - 1][1]); //draw on graph big.draw(path); }
From source file:org.jfree.experimental.chart.plot.dial.StandardDialRange.java
/** * Draws the range.//from w w w. ja v a 2s . c o m * * @param g2 the graphics target. * @param plot the plot. * @param frame the dial's reference frame (in Java2D space). * @param view the dial's view rectangle (in Java2D space). */ public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, Rectangle2D view) { Rectangle2D arcRectInner = DialPlot.rectangleByRadius(frame, this.innerRadius, this.innerRadius); Rectangle2D arcRectOuter = DialPlot.rectangleByRadius(frame, this.outerRadius, this.outerRadius); //double range = this.upperBound - this.lowerBound; DialScale scale = plot.getScaleForDataset(0); double angleMin = scale.valueToAngle(this.lowerBound); double angleMax = scale.valueToAngle(this.upperBound); Arc2D arcInner = new Arc2D.Double(arcRectInner, angleMin, angleMax - angleMin, Arc2D.OPEN); Arc2D arcOuter = new Arc2D.Double(arcRectOuter, angleMax, angleMin - angleMax, Arc2D.OPEN); g2.setPaint(this.paint); g2.setStroke(new BasicStroke(2.0f)); g2.draw(arcInner); g2.draw(arcOuter); }
From source file:no.met.jtimeseries.chart.XYWindArrowRenderer.java
/** * Draws the visual representation of a single wind arrow. *//*from www . j a v a 2 s .c o m*/ @Override public void drawItem(Graphics2D g2d, XYItemRendererState state, Rectangle2D plotArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { resizeArrowByPlotHeight((int) plotArea.getHeight()); // Needs a new graphics object to use translate() and rotate() Graphics2D g2 = (Graphics2D) g2d.create(); g2.setRenderingHints(renderHints); RectangleEdge domainAxisLocation = plot.getDomainAxisEdge(); double middleY = plotArea.getCenterY(); WindDataset windData = (WindDataset) dataset; Number x = windData.getX(series, item); Number windDir = windData.getWindDirection(series, item); Number wforce = windData.getWindForce(series, item); double middleX = domainAxis.valueToJava2D(x.doubleValue(), plotArea, domainAxisLocation); g2.translate((int) middleX, (int) middleY); g2.setColor(Color.BLACK); if (wforce.doubleValue() <= zeroWindLimit) { drawCircle(g2); } else { g2.rotate(Math.toRadians(windDir.doubleValue() - 180)); drawArrow(g2, wforce.doubleValue()); if (useArrowHead) { g2.fill(getPolygonHead(arrowHeadSize, arrowHeight)); } else { g2.draw(getCircleHead(arrowHeadSize, arrowHeight)); } } }
From source file:be.ugent.maf.cellmissy.gui.view.renderer.jfreechart.CompassRenderer.java
@Override public void drawSeries(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info, PolarPlot plot, XYDataset dataset, int seriesIndex) { // compute the right color for the paint int length = GuiUtils.getAvailableColors().length; Color color = GuiUtils.getAvailableColors()[index % length]; // get all the data points int numPoints = dataset.getItemCount(seriesIndex); // set STroke and Paint of the graphics g2.setStroke(new BasicStroke(1.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND)); g2.setPaint(new Color(color.getRed(), color.getGreen(), color.getBlue(), 175)); // iterate through the points of the dataset for (int i = 0; i < numPoints; i++) { double theta = dataset.getXValue(seriesIndex, i); // the angle at the center double radius = dataset.getYValue(seriesIndex, i); // the frequency Point p0 = plot.translateToJava2D(0, 0, plot.getAxis(), dataArea); Point p1 = plot.translateToJava2D(theta, radius, plot.getAxis(), dataArea); Line2D line = new Line2D.Double(p0, p1); g2.draw(line); }/*from w w w .j a va 2 s .c o m*/ }
From source file:org.jax.haplotype.analysis.visualization.SimplePhylogenyTreeImageFactory.java
/** * Paint the given tree layout// w ww . j ava 2 s . com * @param graphics * the graphics to paint with * @param treeLayout * the layout to paint */ private void paintPhylogenyTree(Graphics2D graphics, VisualTreeNode treeLayout) { int childNodeCount = treeLayout.getChildNodes().size(); for (int i = 0; i < childNodeCount; i++) { VisualTreeNode visualChild = treeLayout.getChildNodes().get(i); Shape branchShape = new Line2D.Double(treeLayout.getPosition(), visualChild.getPosition()); Shape branchShadowShape = SHADOW_TRANSFORM.createTransformedShape(branchShape); graphics.setColor(SHADOW_COLOR); graphics.draw(branchShadowShape); if (this.paintScale != null) { PhylogenyTreeEdge phylogenyEdge = treeLayout.getPhylogenyTreeNode().getChildEdges().get(i); if (phylogenyEdge instanceof PhylogenyTreeEdgeWithRealValue) { PhylogenyTreeEdgeWithRealValue phylogenyEdgeWithValue = (PhylogenyTreeEdgeWithRealValue) phylogenyEdge; Paint paint = this.paintScale.getPaint(phylogenyEdgeWithValue.getRealValue()); graphics.setPaint(paint); } else { graphics.setColor(FOREGROUND_COLOR); } } else { graphics.setColor(FOREGROUND_COLOR); } graphics.draw(branchShape); // recurse this.paintPhylogenyTree(graphics, visualChild); } if (!treeLayout.getPhylogenyTreeNode().getStrains().isEmpty()) { Shape textShape = this.getLabelShape(treeLayout, graphics.getFontRenderContext()); Shape borderShape = this.getLabelBorder(textShape); graphics.setColor(BACKGROUND_COLOR); graphics.fill(borderShape); graphics.setColor(SHADOW_COLOR); Area borderShadowShape = new Area(SHADOW_TRANSFORM.createTransformedShape(borderShape)); borderShadowShape.subtract(new Area(borderShape)); graphics.draw(borderShadowShape); graphics.setColor(FOREGROUND_COLOR); graphics.draw(borderShape); graphics.fill(textShape); } }