java.awt.Paint Java Examples
The following examples show how to use
java.awt.Paint.
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: patch1-Chart-26-jMutRepair_patch1-Chart-26-jMutRepair_t.java From coming with MIT License | 6 votes |
/** * Utility method for drawing a line perpendicular to the range axis (used * for crosshairs). * * @param g2 the graphics device. * @param dataArea the area defined by the axes. * @param value the data value. * @param stroke the line stroke (<code>null</code> not permitted). * @param paint the line paint (<code>null</code> not permitted). */ protected void drawRangeLine(Graphics2D g2, Rectangle2D dataArea, double value, Stroke stroke, Paint paint) { double java2D = getRangeAxis().valueToJava2D(value, dataArea, getRangeAxisEdge()); Line2D line = null; if (this.orientation == PlotOrientation.HORIZONTAL) { line = new Line2D.Double(java2D, dataArea.getMinY(), java2D, dataArea.getMaxY()); } else if (this.orientation == PlotOrientation.VERTICAL) { line = new Line2D.Double(dataArea.getMinX(), java2D, dataArea.getMaxX(), java2D); } g2.setStroke(stroke); g2.setPaint(paint); g2.draw(line); }
Example #2
Source File: LegendGraphic.java From opensim-gui with Apache License 2.0 | 6 votes |
/** * Creates a new legend graphic. * * @param shape the shape (<code>null</code> not permitted). * @param fillPaint the fill paint (<code>null</code> not permitted). */ public LegendGraphic(Shape shape, Paint fillPaint) { if (shape == null) { throw new IllegalArgumentException("Null 'shape' argument."); } if (fillPaint == null) { throw new IllegalArgumentException("Null 'fillPaint' argument."); } this.shapeVisible = true; this.shape = shape; this.shapeAnchor = RectangleAnchor.CENTER; this.shapeLocation = RectangleAnchor.CENTER; this.shapeFilled = true; this.fillPaint = fillPaint; this.fillPaintTransformer = new StandardGradientPaintTransformer(); setPadding(2.0, 2.0, 2.0, 2.0); }
Example #3
Source File: AbstractCategoryItemRenderer.java From opensim-gui with Apache License 2.0 | 5 votes |
/** * Draws a grid line against the domain axis. * <P> * Note that this default implementation assumes that the horizontal axis * is the domain axis. If this is not the case, you will need to override * this method. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the area for plotting data (not yet adjusted for any * 3D effect). * @param value the Java2D value at which the grid line should be drawn. */ public void drawDomainGridline(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea, double value) { Line2D line = null; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { line = new Line2D.Double(dataArea.getMinX(), value, dataArea.getMaxX(), value); } else if (orientation == PlotOrientation.VERTICAL) { line = new Line2D.Double(value, dataArea.getMinY(), value, dataArea.getMaxY()); } Paint paint = plot.getDomainGridlinePaint(); if (paint == null) { paint = CategoryPlot.DEFAULT_GRIDLINE_PAINT; } g2.setPaint(paint); Stroke stroke = plot.getDomainGridlineStroke(); if (stroke == null) { stroke = CategoryPlot.DEFAULT_GRIDLINE_STROKE; } g2.setStroke(stroke); g2.draw(line); }
Example #4
Source File: Cardumen_000_s.java From coming with MIT License | 5 votes |
/** * Draws a grid line against the domain axis. * <P> * Note that this default implementation assumes that the horizontal axis * is the domain axis. If this is not the case, you will need to override * this method. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the area for plotting data (not yet adjusted for any * 3D effect). * @param value the Java2D value at which the grid line should be drawn. * @param paint the paint (<code>null</code> not permitted). * @param stroke the stroke (<code>null</code> not permitted). * * @see #drawRangeGridline(Graphics2D, CategoryPlot, ValueAxis, * Rectangle2D, double) * * @since 1.2.0 */ public void drawDomainLine(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea, double value, Paint paint, Stroke stroke) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } if (stroke == null) { throw new IllegalArgumentException("Null 'stroke' argument."); } Line2D line = null; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { line = new Line2D.Double(dataArea.getMinX(), value, dataArea.getMaxX(), value); } else if (orientation == PlotOrientation.VERTICAL) { line = new Line2D.Double(value, dataArea.getMinY(), value, dataArea.getMaxY()); } g2.setPaint(paint); g2.setStroke(stroke); g2.draw(line); }
Example #5
Source File: LabelBlock.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Creates a new label block. * * @param text the text for the label (<code>null</code> not permitted). * @param font the font (<code>null</code> not permitted). * @param paint the paint (<code>null</code> not permitted). */ public LabelBlock(String text, Font font, Paint paint) { this.text = text; this.paint = paint; this.label = TextUtilities.createTextBlock(text, font, this.paint); this.font = font; this.toolTipText = null; this.urlText = null; this.contentAlignmentPoint = TextBlockAnchor.CENTER; this.textAnchor = RectangleAnchor.CENTER; }
Example #6
Source File: DefaultDrawingSupplier.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Creates a new supplier. * * @param paintSequence the fill paint sequence. * @param outlinePaintSequence the outline paint sequence. * @param strokeSequence the stroke sequence. * @param outlineStrokeSequence the outline stroke sequence. * @param shapeSequence the shape sequence. */ public DefaultDrawingSupplier(Paint[] paintSequence, Paint[] outlinePaintSequence, Stroke[] strokeSequence, Stroke[] outlineStrokeSequence, Shape[] shapeSequence) { this.paintSequence = paintSequence; this.fillPaintSequence = DEFAULT_FILL_PAINT_SEQUENCE; this.outlinePaintSequence = outlinePaintSequence; this.strokeSequence = strokeSequence; this.outlineStrokeSequence = outlineStrokeSequence; this.shapeSequence = shapeSequence; }
Example #7
Source File: PolarPlot.java From opensim-gui with Apache License 2.0 | 5 votes |
/** * Sets the paint used to display the angle labels and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param paint the paint (<code>null</code> not permitted). */ public void setAngleLabelPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.angleLabelPaint = paint; notifyListeners(new PlotChangeEvent(this)); }
Example #8
Source File: LegendTitle.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Sets the item paint. * * @param paint the paint (<code>null</code> not permitted). */ public void setItemPaint(Paint paint) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.itemPaint = paint; notifyListeners(new TitleChangeEvent(this)); }
Example #9
Source File: PaintUtilities.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * Returns <code>true</code> if the two <code>Paint</code> objects are equal * OR both <code>null</code>. This method handles * <code>GradientPaint</code> as a special case. * * @param p1 paint 1 (<code>null</code> permitted). * @param p2 paint 2 (<code>null</code> permitted). * * @return A boolean. */ public static boolean equal(final Paint p1, final Paint p2) { // handle cases where either or both arguments are null if (p1 == null) { return (p2 == null); } if (p2 == null) { return false; } boolean result = false; // handle GradientPaint as a special case... if (p1 instanceof GradientPaint && p2 instanceof GradientPaint) { final GradientPaint gp1 = (GradientPaint) p1; final GradientPaint gp2 = (GradientPaint) p2; result = gp1.getColor1().equals(gp2.getColor1()) && gp1.getColor2().equals(gp2.getColor2()) && gp1.getPoint1().equals(gp2.getPoint1()) && gp1.getPoint2().equals(gp2.getPoint2()) && gp1.isCyclic() == gp2.isCyclic() && gp1.getTransparency() == gp1.getTransparency(); } else { result = p1.equals(p2); } return result; }
Example #10
Source File: DefaultDrawingSupplier.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * Returns the next outline paint in the sequence. * * @return The paint. */ @Override public Paint getNextOutlinePaint() { Paint result = this.outlinePaintSequence[ this.outlinePaintIndex % this.outlinePaintSequence.length]; this.outlinePaintIndex++; return result; }
Example #11
Source File: AqlViewer.java From CQL with GNU Affero General Public License v3.0 | 5 votes |
private static <N, E> JComponent viewGraph(DMG<N, E> g) { Graph<N, E> sgv = new DirectedSparseMultigraph<>(); for (N n : g.nodes) { sgv.addVertex(n); } for (E e : g.edges.keySet()) { sgv.addEdge(e, g.edges.get(e).first, g.edges.get(e).second); } if (sgv.getVertexCount() == 0) { return new JPanel(); } Layout<N, E> layout = new FRLayout<>(sgv); layout.setSize(new Dimension(600, 400)); VisualizationViewer<N, E> vv = new VisualizationViewer<>(layout); Function<N, Paint> vertexPaint = x -> Color.black; DefaultModalGraphMouse<N, E> gm = new DefaultModalGraphMouse<>(); gm.setMode(Mode.TRANSFORMING); vv.setGraphMouse(gm); gm.setMode(Mode.PICKING); vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint); Function<E, String> et = Object::toString; Function<N, String> vt = Object::toString; vv.getRenderContext().setEdgeLabelTransformer(et); vv.getRenderContext().setVertexLabelTransformer(vt); GraphZoomScrollPane zzz = new GraphZoomScrollPane(vv); JPanel ret = new JPanel(new GridLayout(1, 1)); ret.add(zzz); ret.setBorder(BorderFactory.createEtchedBorder()); vv.getRenderContext().setLabelOffset(16); vv.setBackground(Color.white); return ret; }
Example #12
Source File: PiePlot.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Returns the outline paint for the specified section. The lookup * involves these steps: * <ul> * <li>if {@link #getSectionOutlinePaint()} is non-<code>null</code>, * return it;</li> * <li>otherwise, if {@link #getSectionOutlinePaint(int)} is * non-<code>null</code> return it;</li> * <li>if {@link #getSectionOutlinePaint(int)} is <code>null</code> but * <code>autoPopulate</code> is <code>true</code>, attempt to fetch * a new outline paint from the drawing supplier * ({@link #getDrawingSupplier()}); * <li>if all else fails, return {@link #getBaseSectionOutlinePaint()}. * </ul> * * @param key the section key. * @param autoPopulate a flag that controls whether the drawing supplier * is used to auto-populate the section outline paint settings. * * @return The paint. * * @since 1.0.3 */ protected Paint lookupSectionOutlinePaint(Comparable key, boolean autoPopulate) { // is there an override? Paint result = getSectionOutlinePaint(); if (result != null) { return result; } // if not, check if there is a paint defined for the specified key result = this.sectionOutlinePaintMap.getPaint(key); if (result != null) { return result; } // nothing defined - do we autoPopulate? if (autoPopulate) { DrawingSupplier ds = getDrawingSupplier(); if (ds != null) { result = ds.getNextOutlinePaint(); this.sectionOutlinePaintMap.put(key, result); } else { result = this.baseSectionOutlinePaint; } } else { result = this.baseSectionOutlinePaint; } return result; }
Example #13
Source File: LabelBlock.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Creates a new label block. * * @param text the text for the label (<code>null</code> not permitted). * @param font the font (<code>null</code> not permitted). * @param paint the paint (<code>null</code> not permitted). */ public LabelBlock(String text, Font font, Paint paint) { this.text = text; this.paint = paint; this.label = TextUtilities.createTextBlock(text, font, this.paint); this.font = font; this.toolTipText = null; this.urlText = null; this.contentAlignmentPoint = TextBlockAnchor.CENTER; this.textAnchor = RectangleAnchor.CENTER; }
Example #14
Source File: ColorBlock.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Creates a new block. * * @param paint the paint (<code>null</code> not permitted). * @param width the width. * @param height the height. */ public ColorBlock(Paint paint, double width, double height) { if (paint == null) { throw new IllegalArgumentException("Null 'paint' argument."); } this.paint = paint; setWidth(width); setHeight(height); }
Example #15
Source File: DefaultDrawingSupplier.java From opensim-gui with Apache License 2.0 | 5 votes |
/** * Creates a new supplier. * * @param paintSequence the fill paint sequence. * @param outlinePaintSequence the outline paint sequence. * @param strokeSequence the stroke sequence. * @param outlineStrokeSequence the outline stroke sequence. * @param shapeSequence the shape sequence. */ public DefaultDrawingSupplier(Paint[] paintSequence, Paint[] outlinePaintSequence, Stroke[] strokeSequence, Stroke[] outlineStrokeSequence, Shape[] shapeSequence) { this.paintSequence = paintSequence; this.outlinePaintSequence = outlinePaintSequence; this.strokeSequence = strokeSequence; this.outlineStrokeSequence = outlineStrokeSequence; this.shapeSequence = shapeSequence; }
Example #16
Source File: LineRenderer3D.java From ECG-Viewer with GNU General Public License v2.0 | 4 votes |
/** * Draws the background for the plot. * * @param g2 the graphics device. * @param plot the plot. * @param dataArea the area inside the axes. */ @Override public void drawBackground(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea) { float x0 = (float) dataArea.getX(); float x1 = x0 + (float) Math.abs(this.xOffset); float x3 = (float) dataArea.getMaxX(); float x2 = x3 - (float) Math.abs(this.xOffset); float y0 = (float) dataArea.getMaxY(); float y1 = y0 - (float) Math.abs(this.yOffset); float y3 = (float) dataArea.getMinY(); float y2 = y3 + (float) Math.abs(this.yOffset); GeneralPath clip = new GeneralPath(); clip.moveTo(x0, y0); clip.lineTo(x0, y2); clip.lineTo(x1, y3); clip.lineTo(x3, y3); clip.lineTo(x3, y1); clip.lineTo(x2, y0); clip.closePath(); Composite originalComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, plot.getBackgroundAlpha())); // fill background... Paint backgroundPaint = plot.getBackgroundPaint(); if (backgroundPaint != null) { g2.setPaint(backgroundPaint); g2.fill(clip); } GeneralPath leftWall = new GeneralPath(); leftWall.moveTo(x0, y0); leftWall.lineTo(x0, y2); leftWall.lineTo(x1, y3); leftWall.lineTo(x1, y1); leftWall.closePath(); g2.setPaint(getWallPaint()); g2.fill(leftWall); GeneralPath bottomWall = new GeneralPath(); bottomWall.moveTo(x0, y0); bottomWall.lineTo(x1, y1); bottomWall.lineTo(x3, y1); bottomWall.lineTo(x2, y0); bottomWall.closePath(); g2.setPaint(getWallPaint()); g2.fill(bottomWall); // higlight the background corners... g2.setPaint(Color.lightGray); Line2D corner = new Line2D.Double(x0, y0, x1, y1); g2.draw(corner); corner.setLine(x1, y1, x1, y3); g2.draw(corner); corner.setLine(x1, y1, x3, y1); g2.draw(corner); // draw background image, if there is one... Image backgroundImage = plot.getBackgroundImage(); if (backgroundImage != null) { Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX() + getXOffset(), dataArea.getY(), dataArea.getWidth() - getXOffset(), dataArea.getHeight() - getYOffset()); plot.drawBackgroundImage(g2, adjusted); } g2.setComposite(originalComposite); }
Example #17
Source File: RoundLabel.java From Spark with Apache License 2.0 | 4 votes |
protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D)g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); int vWidth = getWidth(); int vHeight = getHeight(); // Calculate the size of the button int vButtonHeight = vHeight - (inset * 2); int vButtonWidth = vWidth - (inset * 2); BufferedImage vBuffer = new BufferedImage(vWidth, vHeight, BufferedImage.TYPE_INT_RGB); Graphics2D bg = vBuffer.createGraphics(); bg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // Paint the background of the button bg.setColor(Color.white); bg.fillRect(0, 0, vWidth, vHeight); // Create the gradient paint for the first layer of the button Color vGradientStartColor = buttonColor; Color vGradientEndColor = buttonColor; Paint vPaint = new GradientPaint(0, inset, vGradientStartColor, 0, vButtonHeight, vGradientEndColor, false); bg.setPaint(vPaint); // Paint the first layer of the button bg.fillRect(inset, inset, vButtonWidth, vButtonHeight);//, vArcSize, vArcSize); // Calulate the size of the second layer of the button int vHighlightInset = 2; int vButtonHighlightHeight = vButtonHeight - (vHighlightInset * 2); int vButtonHighlightWidth = vButtonWidth - (vHighlightInset * 2); bg.setClip(new RoundRectangle2D.Float(inset + vHighlightInset, inset + vHighlightInset, vButtonHighlightWidth, vButtonHighlightHeight / 2, vButtonHighlightHeight / 3, vButtonHighlightHeight / 3)); // bg.fillRoundRect(inset + vHighlightInset, inset + vHighlightInset, vButtonHighlightWidth, vButtonHighlightHeight, vHighlightArcSize, vHighlightArcSize); // Blur the button ConvolveOp vBlurOp = new ConvolveOp(new Kernel(3, 3, BLUR)); BufferedImage vBlurredBase = vBlurOp.filter(vBuffer, null); // Draw our aqua button g2.drawImage(vBlurredBase, 0, 0, null); // Draw the text (if any) if (text != null) { g2.setColor(foregroundColor); Font vFont = g2.getFont().deriveFont((float)(((float)vButtonHeight) * .6)); g2.setFont(vFont); FontMetrics vMetrics = g2.getFontMetrics(); Rectangle2D vStringBounds = vMetrics.getStringBounds(text, g2); float x = (float)((vWidth / 2) - (vStringBounds.getWidth() / 2)); float y = (float)((vHeight / 2) + (vStringBounds.getHeight() / 2)) - vMetrics.getDescent(); g2.drawString(text, x, y); } }
Example #18
Source File: DrawTableShape.java From lams with GNU General Public License v2.0 | 4 votes |
public void draw(Graphics2D graphics) { Drawable d = getGroupShape(graphics); if (d != null) { d.draw(graphics); return; } TableShape<?,?> ts = getShape(); DrawPaint drawPaint = DrawFactory.getInstance(graphics).getPaint(ts); final int rows = ts.getNumberOfRows(); final int cols = ts.getNumberOfColumns(); // draw background boxes for (int row=0; row<rows; row++) { for (int col=0; col<cols; col++) { TableCell<?,?> tc = ts.getCell(row, col); if (tc == null || tc.isMerged()) { continue; } Paint fillPaint = drawPaint.getPaint(graphics, tc.getFillStyle().getPaint()); graphics.setPaint(fillPaint); Rectangle2D cellAnc = tc.getAnchor(); graphics.fill(cellAnc); for (BorderEdge edge : BorderEdge.values()) { StrokeStyle stroke = tc.getBorderStyle(edge); if (stroke == null) { continue; } graphics.setStroke(getStroke(stroke)); Paint linePaint = drawPaint.getPaint(graphics, stroke.getPaint()); graphics.setPaint(linePaint); double x=cellAnc.getX(), y=cellAnc.getY(), w=cellAnc.getWidth(), h=cellAnc.getHeight(); Line2D line; switch (edge) { default: case bottom: line = new Line2D.Double(x-borderSize, y+h, x+w+borderSize, y+h); break; case left: line = new Line2D.Double(x, y, x, y+h+borderSize); break; case right: line = new Line2D.Double(x+w, y, x+w, y+h+borderSize); break; case top: line = new Line2D.Double(x-borderSize, y, x+w+borderSize, y); break; } graphics.draw(line); } } } // draw text drawContent(graphics); }
Example #19
Source File: Section.java From mars-sim with GNU General Public License v3.0 | 4 votes |
public void setPaint(final Paint PAINT) { paint = PAINT; }
Example #20
Source File: XYBarRenderer.java From openstock with GNU General Public License v3.0 | 4 votes |
/** * Draws an item label. This method is provided as an alternative to * {@link #drawItemLabel(Graphics2D, PlotOrientation, XYDataset, int, int, * double, double, boolean)} so that the bar can be used to calculate the * label anchor point. * * @param g2 the graphics device. * @param dataset the dataset. * @param series the series index. * @param item the item index. * @param plot the plot. * @param generator the label generator (<code>null</code> permitted, in * which case the method does nothing, just returns). * @param bar the bar. * @param negative a flag indicating a negative value. */ protected void drawItemLabel(Graphics2D g2, XYDataset dataset, int series, int item, XYPlot plot, XYItemLabelGenerator generator, Rectangle2D bar, boolean negative) { if (generator == null) { return; // nothing to do } String label = generator.generateLabel(dataset, series, item); if (label == null) { return; // nothing to do } Font labelFont = getItemLabelFont(series, item); g2.setFont(labelFont); Paint paint = getItemLabelPaint(series, item); g2.setPaint(paint); // find out where to place the label... ItemLabelPosition position; if (!negative) { position = getPositiveItemLabelPosition(series, item); } else { position = getNegativeItemLabelPosition(series, item); } // work out the label anchor point... Point2D anchorPoint = calculateLabelAnchorPoint( position.getItemLabelAnchor(), bar, plot.getOrientation()); if (isInternalAnchor(position.getItemLabelAnchor())) { Shape bounds = TextUtilities.calculateRotatedStringBounds(label, g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getTextAnchor(), position.getAngle(), position.getRotationAnchor()); if (bounds != null) { if (!bar.contains(bounds.getBounds2D())) { if (!negative) { position = getPositiveItemLabelPositionFallback(); } else { position = getNegativeItemLabelPositionFallback(); } if (position != null) { anchorPoint = calculateLabelAnchorPoint( position.getItemLabelAnchor(), bar, plot.getOrientation()); } } } } if (position != null) { TextUtilities.drawRotatedString(label, g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getTextAnchor(), position.getAngle(), position.getRotationAnchor()); } }
Example #21
Source File: ColorizedBubbleRenderer.java From rapidminer-studio with GNU Affero General Public License v3.0 | 4 votes |
@Override public Paint getItemPaint(int series, int item) { double normalized = (colors[item] - minColor) / (maxColor - minColor); return colorProvider.getPointColor(normalized); }
Example #22
Source File: JGenProg2017_0078_t.java From coming with MIT License | 4 votes |
/** * Returns a legend item for a series. This default implementation will * return <code>null</code> if {@link #isSeriesVisible(int)} or * {@link #isSeriesVisibleInLegend(int)} returns <code>false</code>. * * @param datasetIndex the dataset index (zero-based). * @param series the series index (zero-based). * * @return The legend item (possibly <code>null</code>). * * @see #getLegendItems() */ public LegendItem getLegendItem(int datasetIndex, int series) { CategoryPlot p = getPlot(); if (p == null) { return null; } // check that a legend item needs to be displayed... if (!isSeriesVisible(series) || !isSeriesVisibleInLegend(series)) { return null; } CategoryDataset dataset = p.getDataset(datasetIndex); String label = this.legendItemLabelGenerator.generateLabel(dataset, series); String description = label; String toolTipText = null; if (this.legendItemToolTipGenerator != null) { toolTipText = this.legendItemToolTipGenerator.generateLabel( dataset, series); } String urlText = null; if (this.legendItemURLGenerator != null) { urlText = this.legendItemURLGenerator.generateLabel(dataset, series); } Shape shape = lookupLegendShape(series); Paint paint = lookupSeriesPaint(series); Paint outlinePaint = lookupSeriesOutlinePaint(series); Stroke outlineStroke = lookupSeriesOutlineStroke(series); LegendItem item = new LegendItem(label, description, toolTipText, urlText, shape, paint, outlineStroke, outlinePaint); item.setLabelFont(lookupLegendTextFont(series)); Paint labelPaint = lookupLegendTextPaint(series); if (labelPaint != null) { item.setLabelPaint(labelPaint); } item.setSeriesKey(dataset.getRowKey(series)); item.setSeriesIndex(series); item.setDataset(dataset); item.setDatasetIndex(datasetIndex); return item; }
Example #23
Source File: LevelRenderer.java From buffer_bci with GNU General Public License v3.0 | 4 votes |
/** * Draws the bar for a single (series, category) data item. * * @param g2 the graphics device. * @param state the renderer state. * @param dataArea the data area. * @param plot the plot. * @param domainAxis the domain axis. * @param rangeAxis the range axis. * @param dataset the dataset. * @param row the row index (zero-based). * @param column the column index (zero-based). * @param pass the pass index. */ @Override public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) { // nothing is drawn if the row index is not included in the list with // the indices of the visible rows... int visibleRow = state.getVisibleSeriesIndex(row); if (visibleRow < 0) { return; } // nothing is drawn for null values... Number dataValue = dataset.getValue(row, column); if (dataValue == null) { return; } double value = dataValue.doubleValue(); PlotOrientation orientation = plot.getOrientation(); double barW0 = calculateBarW0(plot, orientation, dataArea, domainAxis, state, visibleRow, column); RectangleEdge edge = plot.getRangeAxisEdge(); double barL = rangeAxis.valueToJava2D(value, dataArea, edge); // draw the bar... Line2D line; double x, y; if (orientation == PlotOrientation.HORIZONTAL) { x = barL; y = barW0 + state.getBarWidth() / 2.0; line = new Line2D.Double(barL, barW0, barL, barW0 + state.getBarWidth()); } else { x = barW0 + state.getBarWidth() / 2.0; y = barL; line = new Line2D.Double(barW0, barL, barW0 + state.getBarWidth(), barL); } Stroke itemStroke = getItemStroke(row, column); Paint itemPaint = getItemPaint(row, column); g2.setStroke(itemStroke); g2.setPaint(itemPaint); g2.draw(line); CategoryItemLabelGenerator generator = getItemLabelGenerator(row, column); if (generator != null && isItemLabelVisible(row, column)) { drawItemLabel(g2, orientation, dataset, row, column, x, y, (value < 0.0)); } // submit the current data point as a crosshair candidate int datasetIndex = plot.indexOf(dataset); updateCrosshairValues(state.getCrosshairState(), dataset.getRowKey(row), dataset.getColumnKey(column), value, datasetIndex, barW0, barL, orientation); // collect entity and tool tip information... EntityCollection entities = state.getEntityCollection(); if (entities != null) { addItemEntity(entities, dataset, row, column, line.getBounds()); } }
Example #24
Source File: XYBarRenderer.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Draws an item label. This method is provided as an alternative to * {@link #drawItemLabel(Graphics2D, PlotOrientation, XYDataset, int, int, * double, double, boolean)} so that the bar can be used to calculate the * label anchor point. * * @param g2 the graphics device. * @param dataset the dataset. * @param series the series index. * @param item the item index. * @param selected is the data item selected? * @param plot the plot. * @param generator the label generator (<code>null</code> permitted, in * which case the method does nothing, just returns). * @param bar the bar. * @param negative a flag indicating a negative value. * * @since 1.2.0 */ protected void drawItemLabelForBar(Graphics2D g2, XYPlot plot, XYDataset dataset, int series, int item, boolean selected, XYItemLabelGenerator generator, Rectangle2D bar, boolean negative) { if (generator == null) { return; // nothing to do } String label = generator.generateLabel(dataset, series, item); if (label == null) { return; // nothing to do } Font labelFont = getItemLabelFont(series, item, selected); g2.setFont(labelFont); Paint paint = getItemLabelPaint(series, item, selected); g2.setPaint(paint); // find out where to place the label... ItemLabelPosition position = null; if (!negative) { position = getPositiveItemLabelPosition(series, item, selected); } else { position = getNegativeItemLabelPosition(series, item, selected); } // work out the label anchor point... Point2D anchorPoint = calculateLabelAnchorPoint( position.getItemLabelAnchor(), bar, plot.getOrientation()); if (isInternalAnchor(position.getItemLabelAnchor())) { Shape bounds = TextUtilities.calculateRotatedStringBounds(label, g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getTextAnchor(), position.getAngle(), position.getRotationAnchor()); if (bounds != null) { if (!bar.contains(bounds.getBounds2D())) { if (!negative) { position = getPositiveItemLabelPositionFallback(); } else { position = getNegativeItemLabelPositionFallback(); } if (position != null) { anchorPoint = calculateLabelAnchorPoint( position.getItemLabelAnchor(), bar, plot.getOrientation()); } } } } if (position != null) { TextUtilities.drawRotatedString(label, g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(), position.getTextAnchor(), position.getAngle(), position.getRotationAnchor()); } }
Example #25
Source File: PiePlot.java From opensim-gui with Apache License 2.0 | 4 votes |
/** * Returns a collection of legend items for the pie chart. * * @return The legend items (never <code>null</code>). */ public LegendItemCollection getLegendItems() { LegendItemCollection result = new LegendItemCollection(); if (this.dataset == null) { return result; } List keys = this.dataset.getKeys(); int section = 0; Shape shape = getLegendItemShape(); Iterator iterator = keys.iterator(); while (iterator.hasNext()) { Comparable key = (Comparable) iterator.next(); Number n = this.dataset.getValue(key); boolean include = true; if (n == null) { include = !this.ignoreNullValues; } else { double v = n.doubleValue(); if (v == 0.0) { include = !this.ignoreZeroValues; } else { include = v > 0.0; } } if (include) { String label = this.legendLabelGenerator.generateSectionLabel( this.dataset, key); String description = label; String toolTipText = null; if (this.legendLabelToolTipGenerator != null) { toolTipText = this.legendLabelToolTipGenerator.generateSectionLabel( this.dataset, key); } String urlText = null; if (this.legendLabelURLGenerator != null) { urlText = this.legendLabelURLGenerator.generateURL( this.dataset, key, this.pieIndex); } Paint paint = lookupSectionPaint(key, true); Paint outlinePaint = lookupSectionOutlinePaint(key); Stroke outlineStroke = lookupSectionOutlineStroke(key); LegendItem item = new LegendItem(label, description, toolTipText, urlText, true, shape, true, paint, true, outlinePaint, outlineStroke, false, // line not visible new Line2D.Float(), new BasicStroke(), Color.black); result.add(item); section++; } else { section++; } } return result; }
Example #26
Source File: MenuItemPainter.java From seaglass with Apache License 2.0 | 4 votes |
public Paint getMenuItemBackgroundPaintUnified(Shape s) { return createVerticalGradient(s, new TwoColors(Color.WHITE, Color.WHITE)); }
Example #27
Source File: Style.java From ganttproject with GNU General Public License v3.0 | 4 votes |
Paint getPaint() { return myPaint; }
Example #28
Source File: FcgVertexPaintTransformer.java From ghidra with Apache License 2.0 | 4 votes |
@Override public Paint apply(FcgVertex v) { return color; }
Example #29
Source File: AreaRenderer.java From ccu-historian with GNU General Public License v3.0 | 4 votes |
/** * Returns a legend item for a series. * * @param datasetIndex the dataset index (zero-based). * @param series the series index (zero-based). * * @return The legend item. */ @Override public LegendItem getLegendItem(int datasetIndex, int series) { // if there is no plot, there is no dataset to access... CategoryPlot cp = getPlot(); if (cp == null) { return null; } // check that a legend item needs to be displayed... if (!isSeriesVisible(series) || !isSeriesVisibleInLegend(series)) { return null; } CategoryDataset dataset = cp.getDataset(datasetIndex); String label = getLegendItemLabelGenerator().generateLabel(dataset, series); String description = label; String toolTipText = null; if (getLegendItemToolTipGenerator() != null) { toolTipText = getLegendItemToolTipGenerator().generateLabel( dataset, series); } String urlText = null; if (getLegendItemURLGenerator() != null) { urlText = getLegendItemURLGenerator().generateLabel(dataset, series); } Shape shape = lookupLegendShape(series); Paint paint = lookupSeriesPaint(series); Paint outlinePaint = lookupSeriesOutlinePaint(series); Stroke outlineStroke = lookupSeriesOutlineStroke(series); LegendItem result = new LegendItem(label, description, toolTipText, urlText, shape, paint, outlineStroke, outlinePaint); result.setLabelFont(lookupLegendTextFont(series)); Paint labelPaint = lookupLegendTextPaint(series); if (labelPaint != null) { result.setLabelPaint(labelPaint); } result.setDataset(dataset); result.setDatasetIndex(datasetIndex); result.setSeriesKey(dataset.getRowKey(series)); result.setSeriesIndex(series); return result; }
Example #30
Source File: PeakDataRenderer.java From mzmine3 with GNU General Public License v2.0 | 4 votes |
public Paint getItemPaint(int row, int column) { return peakColor; }