List of usage examples for java.awt Graphics2D setStroke
public abstract void setStroke(Stroke s);
From source file:org.eurocarbdb.application.glycoworkbench.plugin.reporting.AnnotationReportCanvas.java
protected void paintAnnotations(Graphics2D g2d) { DecimalFormat mz_df = new DecimalFormat("0.0"); // set font/*from w ww . j ava 2 s . c o m*/ Font old_font = g2d.getFont(); Font new_font = new Font(theOptions.ANNOTATION_MZ_FONT, Font.PLAIN, theOptions.ANNOTATION_MZ_SIZE); // compute bboxes PositionManager pman = new PositionManager(); BBoxManager bbman = new BBoxManager(); computeRectangles(pman, bbman); // compute connections computeConnections(); // paint connections for (AnnotationObject a : theDocument.getAnnotations()) { boolean selected = !is_printing && selections.contains(a); // paint arrow Polygon connection = connections.get(a); if (connection != null) { g2d.setColor(theOptions.CONNECTION_LINES_COLOR); g2d.setStroke((selected) ? new BasicStroke((float) (1. + theOptions.ANNOTATION_LINE_WIDTH)) : new BasicStroke((float) theOptions.ANNOTATION_LINE_WIDTH)); g2d.draw(connection); g2d.setStroke(new BasicStroke(1)); } // paint control point if (selected) { g2d.setColor(Color.black); Point2D cp = connections_cp.get(a); if (cp != null) { int s = (int) (2 + theOptions.ANNOTATION_LINE_WIDTH); g2d.fill(new Rectangle((int) cp.getX() - s, (int) cp.getY() - s, 2 * s, 2 * s)); } } } // paint glycans for (AnnotationObject a : theDocument.getAnnotations()) { boolean highlighted = a.isHighlighted(); boolean selected = !is_printing && selections.contains(a); // set scale theGlycanRenderer.getGraphicOptions().setScale(theOptions.SCALE_GLYCANS * theDocument.getScale(a)); // paint highlighted region if (highlighted) { Rectangle c_bbox = rectangles_complete.get(a); g2d.setColor(theOptions.HIGHLIGHTED_COLOR); g2d.setXORMode(Color.white); g2d.fill(c_bbox); g2d.setPaintMode(); g2d.setColor(Color.black); g2d.draw(c_bbox); } // paint glycan for (Glycan s : a.getStructures()) theGlycanRenderer.paint(g2d, s, null, null, false, false, pman, bbman); // paint MZ text g2d.setFont(new_font); g2d.setColor(theOptions.MASS_TEXT_COLOR); String mz_text = mz_df.format(a.getPeakPoint().getX()); Rectangle mz_bbox = rectangles_text.get(a); g2d.drawString(mz_text, mz_bbox.x, mz_bbox.y + mz_bbox.height); // paint selection if (selected) { // paint rectangle Rectangle c_bbox = rectangles_complete.get(a); g2d.setStroke(new BasicStroke(highlighted ? 2 : 1)); g2d.setColor(Color.black); g2d.draw(c_bbox); g2d.setStroke(new BasicStroke(1)); // paint resize points Polygon p1 = new Polygon(); int cx1 = right(c_bbox); int cy1 = top(c_bbox); p1.addPoint(cx1, cy1); p1.addPoint(cx1 - 2 * theOptions.ANNOTATION_MARGIN / 3, cy1); p1.addPoint(cx1, cy1 + 2 * theOptions.ANNOTATION_MARGIN / 3); g2d.fill(p1); Polygon p2 = new Polygon(); int cx2 = left(c_bbox); int cy2 = top(c_bbox); p2.addPoint(cx2, cy2); p2.addPoint(cx2 + 2 * theOptions.ANNOTATION_MARGIN / 3, cy2); p2.addPoint(cx2, cy2 + 2 * theOptions.ANNOTATION_MARGIN / 3); g2d.fill(p2); } } g2d.setFont(old_font); }
From source file:longMethod.jfreechart.draw.XYPolygonAnnotation.java
/** * Draws the annotation. This method is usually called by the * {@link XYPlot} class, you shouldn't need to call it directly. * * @param g2 the graphics device./*from www . j av a 2s .com*/ * @param plot the plot. * @param dataArea the data area. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param rendererIndex the renderer index. * @param info the plot rendering info. */ public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, int rendererIndex, PlotRenderingInfo info) { // if we don't have at least 2 (x, y) coordinates, just return if (this.polygon.length < 4) { return; } PlotOrientation orientation = plot.getOrientation(); RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(plot.getDomainAxisLocation(), orientation); RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(plot.getRangeAxisLocation(), orientation); GeneralPath area = new GeneralPath(); double x = domainAxis.valueToJava2D(this.polygon[0], dataArea, domainEdge); double y = rangeAxis.valueToJava2D(this.polygon[1], dataArea, rangeEdge); if (orientation == PlotOrientation.HORIZONTAL) { area.moveTo((float) y, (float) x); for (int i = 2; i < this.polygon.length; i += 2) { x = domainAxis.valueToJava2D(this.polygon[i], dataArea, domainEdge); y = rangeAxis.valueToJava2D(this.polygon[i + 1], dataArea, rangeEdge); area.lineTo((float) y, (float) x); } area.closePath(); } else if (orientation == PlotOrientation.VERTICAL) { area.moveTo((float) x, (float) y); for (int i = 2; i < this.polygon.length; i += 2) { x = domainAxis.valueToJava2D(this.polygon[i], dataArea, domainEdge); y = rangeAxis.valueToJava2D(this.polygon[i + 1], dataArea, rangeEdge); area.lineTo((float) x, (float) y); } area.closePath(); } if (this.fillPaint != null) { g2.setPaint(this.fillPaint); g2.fill(area); } if (this.stroke != null && this.outlinePaint != null) { g2.setPaint(this.outlinePaint); g2.setStroke(this.stroke); g2.draw(area); } addEntity(info, area, rendererIndex, getToolTipText(), getURL()); }
From source file:soap.ui.stats.LineAndShapeRendererMapToBar.java
public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column) { // nothing is drawn for null... Number v = dataset.getValue(row, column); if (v == null) return;/* www. ja va2s. c o m*/ PlotOrientation orientation = plot.getOrientation(); // current data point which is associated to a serie... double x1 = domainAxis.getCategoryStart(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()); int seriesCount = mBarRenderer.getPlot().getDataset().getRowCount(); int categoryCount = mBarRenderer.getPlot().getDataset().getColumnCount(); if (seriesCount > 1 && mNumSerie < seriesCount) { double seriesGap = dataArea.getWidth() * 0.2 / (categoryCount * (seriesCount - 1)); double seriesW = calculateSeriesWidth(dataArea.getWidth(), domainAxis, categoryCount, seriesCount); x1 = x1 + mNumSerie * (seriesW + seriesGap) + (seriesW / 2.0) - (state.getBarWidth() / 2.0); } else { x1 = domainAxis.getCategoryMiddle(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()); } double value = v.doubleValue(); double y1 = rangeAxis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge()); Shape shape = getItemShape(row, column); if (orientation == PlotOrientation.HORIZONTAL) { shape = createTransformedShape(shape, y1, x1); } else if (orientation == PlotOrientation.VERTICAL) { shape = createTransformedShape(shape, x1, y1); } if (isDrawShapes()) { if (getItemShapeFilled(row, column)) { g2.setPaint(getItemPaint(row, column)); g2.fill(shape); } else { g2.setPaint(getItemOutlinePaint(row, column)); g2.setStroke(getItemOutlineStroke(row, column)); g2.draw(shape); } } if (isDrawLines()) { if (column != 0) { Number previousValue = dataset.getValue(row, column - 1); if (previousValue != null) { // previous data point... double previous = previousValue.doubleValue(); double x0 = domainAxis.getCategoryStart(column - 1, getColumnCount(), dataArea, plot.getDomainAxisEdge()); // seriesCount = getRowCount(); // categoryCount = getColumnCount(); if (seriesCount > 1 && mNumSerie < seriesCount) { double seriesGap = dataArea.getWidth() * 0.2 / (categoryCount * (seriesCount - 1)); double seriesW = calculateSeriesWidth(dataArea.getWidth(), domainAxis, categoryCount, seriesCount); x0 = x0 + mNumSerie * (seriesW + seriesGap) + (seriesW / 2.0) - (state.getBarWidth() / 2.0); } else { x0 = domainAxis.getCategoryMiddle(column - 1, getColumnCount(), dataArea, plot.getDomainAxisEdge()); } double y0 = rangeAxis.valueToJava2D(previous, dataArea, plot.getRangeAxisEdge()); Line2D line = null; if (orientation == PlotOrientation.HORIZONTAL) { line = new Line2D.Double(y0, x0, y1, x1); } else if (orientation == PlotOrientation.VERTICAL) { line = new Line2D.Double(x0, y0, x1, y1); } g2.setPaint(getItemPaint(row, column)); g2.setStroke(getItemStroke(row, column)); g2.draw(line); } } } // draw the item label if there is one... if (isItemLabelVisible(row, column)) { if (orientation == PlotOrientation.HORIZONTAL) { drawItemLabel(g2, orientation, dataset, row, column, y1, x1, (value < 0.0)); } else if (orientation == PlotOrientation.VERTICAL) { drawItemLabel(g2, orientation, dataset, row, column, x1, y1, (value < 0.0)); } } // collect entity and tool tip information... if (state.getInfo() != null) { EntityCollection entities = state.getInfo().getOwner().getEntityCollection(); if (entities != null && shape != null) { String tip = null; CategoryToolTipGenerator tipster = getToolTipGenerator(row, column); if (tipster != null) { tip = tipster.generateToolTip(dataset, row, column); } String url = null; if (getItemURLGenerator(row, column) != null) { url = getItemURLGenerator(row, column).generateURL(dataset, row, column); } CategoryItemEntity entity = new CategoryItemEntity(shape, tip, url, dataset, row, dataset.getColumnKey(column), column); entities.addEntity(entity); } } }
From source file:com.quinsoft.zeidon.objectbrowser.EntitySquare.java
@Override public void paint(Graphics g) { Graphics2D graphics2 = (Graphics2D) g; EntityDef entityDef = getEntityDef(); EntityCursor cursor = getView().cursor(entityDef); Color borderColor = Color.black; BasicStroke stroke = new BasicStroke(1); EntitySquare selectedSquare = oiDisplay.getSelectedEntity(); if (selectedSquare != null) { EntityDef selectedEntityDef = selectedSquare.getEntityDef(); if (selectedEntityDef.getRecursiveChild() == entityDef || selectedEntityDef.getRecursiveParent() == entityDef) { borderColor = Color.yellow; stroke = new BasicStroke(5); oiDisplay.setForRepaint(this); }/*from w w w. j a v a 2 s . c o m*/ } if (selectedSquare == this) g.setColor(SELECTED_COLOR); else { switch (cursor.getStatus()) { case NULL: g.setColor(NULL_ENTITY); break; case OUT_OF_SCOPE: g.setColor(OUT_OF_SCOPE); break; case NOT_LOADED: g.setColor(NOT_LOADED); break; default: g.setColor(ENTITY_EXISTS); } } // Fill in the shape. graphics2.fillRoundRect(0, 0, size.width - 1, size.height - 1, 20, 20); // Draw the black outline. g.setColor(borderColor); RoundRectangle2D roundedRectangle = new RoundRectangle2D.Float(0, 0, size.width - 1, size.height - 1, 20, 20); graphics2.setStroke(stroke); graphics2.draw(roundedRectangle); // Write the entity name g.setColor(Color.black); graphics2.setFont(font); paintCenteredText(graphics2, env.getPainterScaleFactor(), entityDef.getName(), null); switch (cursor.getStatus()) { case NULL: paintCenteredText(graphics2, size.height / 2, "null", Color.WHITE); setToolTipText(cursor); break; case NOT_LOADED: paintCenteredText(graphics2, size.height / 2, "(Not yet loaded)", Color.WHITE); setToolTipText(entityDef.getName()); break; case OUT_OF_SCOPE: paintCenteredText(graphics2, size.height / 2, "(Out of Scope)", Color.WHITE); setToolTipText(entityDef.getName()); break; default: String s = getKeyString(cursor, entityDef, env); paintCenteredText(graphics2, size.height / 2, s, null); s = getSiblingCount(cursor); paintCenteredText(graphics2, size.height - env.getPainterScaleFactor(), s, null); setToolTipText(cursor); } }
From source file:com.att.aro.main.PacketPlots.java
/** * The utility method that creates the packet plots from a packet series map *//*from w w w . j a v a2 s . c o m*/ private XYPlot createPlot() { // Create the plot renderer YIntervalRenderer renderer = new YIntervalRenderer() { private static final long serialVersionUID = 1L; public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { // setup for collecting optional entity info... Shape entityArea = null; EntityCollection entities = null; if (info != null) { entities = info.getOwner().getEntityCollection(); } IntervalXYDataset intervalDataset = (IntervalXYDataset) dataset; double x = intervalDataset.getXValue(series, item); double yLow = intervalDataset.getStartYValue(series, item); double yHigh = intervalDataset.getEndYValue(series, item); RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); double xx = domainAxis.valueToJava2D(x, dataArea, xAxisLocation); double yyLow = rangeAxis.valueToJava2D(yLow, dataArea, yAxisLocation); double yyHigh = rangeAxis.valueToJava2D(yHigh, dataArea, yAxisLocation); Paint p = getItemPaint(series, item); Stroke s = getItemStroke(series, item); Line2D line = null; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { line = new Line2D.Double(yyLow, xx, yyHigh, xx); } else if (orientation == PlotOrientation.VERTICAL) { line = new Line2D.Double(xx, yyLow, xx, yyHigh); } g2.setPaint(p); g2.setStroke(s); g2.draw(line); // add an entity for the item... if (entities != null) { if (entityArea == null) { entityArea = line.getBounds(); } String tip = null; XYToolTipGenerator generator = getToolTipGenerator(series, item); if (generator != null) { tip = generator.generateToolTip(dataset, series, item); } XYItemEntity entity = new XYItemEntity(entityArea, dataset, series, item, tip, null); entities.add(entity); } } }; renderer.setAdditionalItemLabelGenerator(null); renderer.setBaseShape(new Rectangle()); renderer.setAutoPopulateSeriesShape(false); renderer.setAutoPopulateSeriesPaint(false); renderer.setBasePaint(Color.GRAY); // Create the plot XYPlot plot = new XYPlot(null, null, new NumberAxis(), renderer); plot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); plot.getRangeAxis().setVisible(false); return plot; }
From source file:org.gumtree.vis.awt.JChartPanel.java
/** * Draws a vertical line used to trace the mouse position to the horizontal * axis./* w w w .j av a 2 s .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(); if (((int) dataArea.getMinX() < x) && (x < (int) dataArea.getMaxX())) { g2.setPaint(getAxisTraceColor()); g2.setStroke(new BasicStroke(0.25f)); g2.draw(new Line2D.Float(x, (int) dataArea.getMinY(), x, (int) dataArea.getMaxY())); } }
From source file:org.gumtree.vis.awt.JChartPanel.java
/** * Draws a horizontal line used to trace the mouse position to the vertical * axis./*from w ww .j a v a 2s.c om*/ * * @param g2 the graphics device. * @param y the y-coordinate of the trace line. */ private void drawVerticalAxisTrace(Graphics2D g2, int y) { Rectangle2D dataArea = getScreenDataArea(); if (((int) dataArea.getMinY() < y) && (y < (int) dataArea.getMaxY())) { g2.setPaint(getAxisTraceColor()); g2.setStroke(new BasicStroke(0.25f)); g2.draw(new Line2D.Float((int) dataArea.getMinX(), y, (int) dataArea.getMaxX(), y)); } }
From source file:dk.sdu.mmmi.featureous.views.featurecharacterization.FeatureViewChart.java
public FeatureViewChart(List<TraceModel> ftms, final boolean pkg) { this.pkg = pkg; data = new DefaultCategoryDataset(); chart = ChartFactory.createStackedBarChart("Feature characterization", "Feature", "Scattering", data, PlotOrientation.VERTICAL, true, false, false); plot = (CategoryPlot) chart.getPlot(); CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis(); xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); xAxis.setMaximumCategoryLabelLines(2); // chart.getLegend().setPosition(RectangleEdge.RIGHT); // chart.getLegend().setVerticalAlignment(VerticalAlignment.TOP); // chart.getLegend().setHorizontalAlignment(HorizontalAlignment.LEFT); LegendItemCollection lic = new LegendItemCollection(); // lic.add(new LegendItem("Infrastructural unit", "", "", "", new Rectangle(10, 10), Color.GREEN)); // lic.add(new LegendItem("Group-feature unit", "", "", "", new Rectangle(10, 10), Color.BLUE)); // lic.add(new LegendItem("Single-feature unit", "", "", "", new Rectangle(10, 10), Color.RED)); plot.setFixedLegendItems(lic);//from w ww . jav a 2 s .com // chart.removeLegend(); panel = new ChartPanel(chart); chart.setBackgroundPaint(Color.white); this.ftms = ftms; scattering = new ArrayList<Result>( new StaticScattering(pkg).calculateAndReturnAll(new HashSet<TraceModel>(ftms), null)); Result.sortByName(scattering); for (Result r : scattering) { // OutputUtil.log(r.name + ";" +r.value); } panel.getPopupMenu().setEnabled(false);//add(SVGExporter.createExportAction(chart, panel)); StackedBarRenderer r2 = new StackedBarRenderer() { @Override public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) { super.drawItem(g2, state, dataArea, plot, domainAxis, rangeAxis, dataset, row, column, pass); double start = plot.getDomainAxis().getCategoryStart(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()); double end = plot.getDomainAxis().getCategoryEnd(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()); String compUnit = data.getRowKey(row).toString(); // Calculate y coeffs double posBase = getBase(); for (int i = 0; i < row; i++) { Number val = dataset.getValue(i, column); if (val != null) { posBase = posBase + val.doubleValue(); } } Number value = dataset.getValue(row, column); if (value == null) { return; } double val = value.doubleValue(); double translatedBase = plot.getRangeAxis().valueToJava2D(posBase, dataArea, plot.getRangeAxisEdge()); double translatedValue = plot.getRangeAxis().valueToJava2D(posBase + val, dataArea, plot.getRangeAxisEdge()); if (Controller.getInstance().getTraceSet().getSelectionManager().getSelectedClasses() .contains(compUnit) || Controller.getInstance().getTraceSet().getSelectionManager().getSelectedPkgs() .contains(compUnit)) { g2.setPaint(UIUtils.SELECTION_COLOR); g2.setStroke(new BasicStroke(3f)); Line2D l2d = new Line2D.Double(start, translatedBase, start, translatedValue); g2.draw(l2d); l2d = new Line2D.Double(end, translatedBase, end, translatedValue); g2.draw(l2d); l2d = new Line2D.Double(start, translatedBase, end, translatedBase); g2.draw(l2d); l2d = new Line2D.Double(start, translatedValue, end, translatedValue); g2.draw(l2d); } } }; plot.setRenderer(r2, true); StackedBarRenderer r = (StackedBarRenderer) plot.getRenderer(); r.setDrawBarOutline(true); plot.getRenderer().setOutlineStroke(new BasicStroke(0.1f)); Controller.getInstance().getTraceSet().getSelectionManager().addSelectionListener(this); }
From source file:edu.scripps.fl.curves.plot.MyXYErrorRenderer.java
public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { if (pass == 0 && (dataset instanceof IntervalXYDataset) && getItemVisible(series, item)) { IntervalXYDataset ixyd = (IntervalXYDataset) dataset; PlotOrientation orientation = plot.getOrientation(); if (getSeriesXError(series)) { double x0 = ixyd.getStartXValue(series, item); double x1 = ixyd.getEndXValue(series, item); double y = ixyd.getYValue(series, item); org.jfree.ui.RectangleEdge edge = plot.getDomainAxisEdge(); double xx0 = domainAxis.valueToJava2D(x0, dataArea, edge); double xx1 = domainAxis.valueToJava2D(x1, dataArea, edge); double yy = rangeAxis.valueToJava2D(y, dataArea, plot.getRangeAxisEdge()); Line2D cap1 = null;/*from ww w.ja v a2s . c o m*/ Line2D cap2 = null; double adj = capLength / 2D; Line2D line; if (orientation == PlotOrientation.VERTICAL) { line = new java.awt.geom.Line2D.Double(xx0, yy, xx1, yy); cap1 = new java.awt.geom.Line2D.Double(xx0, yy - adj, xx0, yy + adj); cap2 = new java.awt.geom.Line2D.Double(xx1, yy - adj, xx1, yy + adj); } else { line = new java.awt.geom.Line2D.Double(yy, xx0, yy, xx1); cap1 = new java.awt.geom.Line2D.Double(yy - adj, xx0, yy + adj, xx0); cap2 = new java.awt.geom.Line2D.Double(yy - adj, xx1, yy + adj, xx1); } if (errorPaint != null) g2.setPaint(errorPaint); else g2.setPaint(getItemPaint(series, item)); if (errorStroke != null) g2.setStroke(errorStroke); else g2.setStroke(getItemStroke(series, item)); g2.draw(line); g2.draw(cap1); g2.draw(cap2); } if (getSeriesYError(series)) { double y0 = ixyd.getStartYValue(series, item); double y1 = ixyd.getEndYValue(series, item); double x = ixyd.getXValue(series, item); org.jfree.ui.RectangleEdge edge = plot.getRangeAxisEdge(); double yy0 = rangeAxis.valueToJava2D(y0, dataArea, edge); double yy1 = rangeAxis.valueToJava2D(y1, dataArea, edge); double xx = domainAxis.valueToJava2D(x, dataArea, plot.getDomainAxisEdge()); Line2D cap1 = null; Line2D cap2 = null; double adj = capLength / 2D; Line2D line; if (orientation == PlotOrientation.VERTICAL) { line = new java.awt.geom.Line2D.Double(xx, yy0, xx, yy1); cap1 = new java.awt.geom.Line2D.Double(xx - adj, yy0, xx + adj, yy0); cap2 = new java.awt.geom.Line2D.Double(xx - adj, yy1, xx + adj, yy1); } else { line = new java.awt.geom.Line2D.Double(yy0, xx, yy1, xx); cap1 = new java.awt.geom.Line2D.Double(yy0, xx - adj, yy0, xx + adj); cap2 = new java.awt.geom.Line2D.Double(yy1, xx - adj, yy1, xx + adj); } if (errorPaint != null) g2.setPaint(errorPaint); else g2.setPaint(getItemPaint(series, item)); if (errorStroke != null) g2.setStroke(errorStroke); else g2.setStroke(getItemStroke(series, item)); g2.draw(line); g2.draw(cap1); g2.draw(cap2); } } super.drawItem(g2, state, dataArea, info, plot, domainAxis, rangeAxis, dataset, series, item, crosshairState, pass); }
From source file:convcao.com.caoAgent.convcaoNeptusInteraction.java
@Override public void paint(Graphics2D g, StateRenderer2D renderer) { Point2D center = renderer.getScreenPosition(coords.squareCenter); double width = renderer.getZoom() * coords.cellWidth * coords.numCols; double height = renderer.getZoom() * coords.cellWidth * coords.numRows; g.setColor(new Color(0, 0, 255, 64)); g.translate(center.getX(), center.getY()); g.rotate(-renderer.getRotation());//w w w . ja va 2s . c om g.fill(new Rectangle2D.Double(-width / 2, -height / 2, width, height)); g.rotate(renderer.getRotation()); g.translate(-center.getX(), -center.getY()); if (!active) return; g.setColor(Color.orange); int pos = 50; for (String v : nameTable.values()) { g.drawString(v + ": " + depths.get(v) + "m", 15, pos); pos += 20; } for (String vehicle : nameTable.values()) { LocationType src = positions.get(vehicle); LocationType dst = destinations.get(vehicle); if (!arrived.get(vehicle)) g.setColor(Color.red.darker()); else g.setColor(Color.green.darker()); float dash[] = { 4.0f }; g.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 5.0f, dash, 0.0f)); g.draw(new Line2D.Double(renderer.getScreenPosition(src), renderer.getScreenPosition(dst))); Point2D dstPt = renderer.getScreenPosition(dst); if (!arrived.get(vehicle)) g.setColor(Color.red.darker()); else g.setColor(Color.green.darker()); g.fill(new Ellipse2D.Double(dstPt.getX() - 4, dstPt.getY() - 4, 8, 8)); } }