java.awt.BasicStroke Java Examples
The following examples show how to use
java.awt.BasicStroke.
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: HeatMapLegendPanel.java From ET_Redux with Apache License 2.0 | 7 votes |
/** * * @param g2d */ public void paint(Graphics2D g2d) { g2d.setColor(Color.BLACK); g2d.setStroke(new BasicStroke(1.0f)); g2d.setFont(new Font( getTitleFont(), Font.BOLD, Integer.parseInt(getTitleFontSize()) - 2)); g2d.drawString(getSubtitle(), getX() + 10, getY() + 25 + 1.5f * Integer.valueOf(getTitleFontSize())); if (isTitleBoxShow()) { DrawBounds(g2d); } for (int i = 5; i < getBoxWidth() - 5; i++) { int selectedIndex = HeatMap.selectColorInRange(0, 0, ((double) i) / (getBoxWidth() - 5)); int rgb = HeatMap.getRgb().get(selectedIndex); g2d.setColor(new Color(rgb)); g2d.drawLine(i + getX(), 3 + getY(), i + getX(), 3 + getY() + 20); } }
Example #2
Source File: ButtonTabComponent.java From tn5250j with GNU General Public License v2.0 | 7 votes |
protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D) g.create(); // shift the image for pressed buttons if (getModel().isPressed()) { g2.translate(1, 1); } g2.setStroke(new BasicStroke(2)); g2.setColor(Color.BLACK); if (getModel().isRollover()) { g2.setColor(Color.MAGENTA); } int delta = 6; g2.drawLine(delta, delta, getWidth() - delta - 1, getHeight() - delta - 1); g2.drawLine(getWidth() - delta - 1, delta, delta, getHeight() - delta - 1); g2.dispose(); }
Example #3
Source File: Draw.java From MeteoInfo with GNU Lesser General Public License v3.0 | 6 votes |
/** * Draw pie * * @param aPoint Start point * @param width Width * @param height Height * @param startAngle Start angle * @param sweepAngle Sweep angle * @param aPGB Polygon break * @param wedgeWidth Wedge width * @param g Graphics2D */ public static void drawPie(PointF aPoint, float width, float height, float startAngle, float sweepAngle, PolygonBreak aPGB, float wedgeWidth, Graphics2D g) { Color aColor = aPGB.getColor(); Arc2D.Float arc2D = new Arc2D.Float(aPoint.X, aPoint.Y, width, height, startAngle, sweepAngle, Arc2D.PIE); Area area1 = new Area(arc2D); Ellipse2D e2 = new Ellipse2D.Float(aPoint.X + wedgeWidth, aPoint.Y + wedgeWidth, width - wedgeWidth * 2, height - wedgeWidth * 2); Area area2 = new Area(e2); area1.subtract(area2); if (aPGB.isDrawFill()) { g.setColor(aColor); g.fill(area1); } if (aPGB.isDrawOutline()) { g.setColor(aPGB.getOutlineColor()); g.setStroke(new BasicStroke(aPGB.getOutlineSize())); g.draw(area1); } }
Example #4
Source File: MarkerTest.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
/** * Some checks for the getOutlineStroke() and setOutlineStroke() methods. */ @Test public void testGetSetOutlineStroke() { // we use ValueMarker for the tests, because we need a concrete // subclass... ValueMarker m = new ValueMarker(1.1); m.addChangeListener(this); this.lastEvent = null; assertEquals(new BasicStroke(0.5f), m.getOutlineStroke()); m.setOutlineStroke(new BasicStroke(1.1f)); assertEquals(new BasicStroke(1.1f), m.getOutlineStroke()); assertEquals(m, this.lastEvent.getMarker()); // check null argument... m.setOutlineStroke(null); assertEquals(null, m.getOutlineStroke()); }
Example #5
Source File: BorderFactory.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Creates a dashed border of the specified {@code paint}, {@code thickness}, * line shape, relative {@code length}, and relative {@code spacing}. * If the specified {@code paint} is {@code null}, * the component's foreground color will be used to render the border. * * @param paint the {@link Paint} object used to generate a color * @param thickness the width of a dash line * @param length the relative length of a dash line * @param spacing the relative spacing between dash lines * @param rounded whether or not line ends should be round * @return the {@code Border} object * * @throws IllegalArgumentException if the specified {@code thickness} is less than {@code 1}, or * if the specified {@code length} is less than {@code 1}, or * if the specified {@code spacing} is less than {@code 0} * @since 1.7 */ public static Border createDashedBorder(Paint paint, float thickness, float length, float spacing, boolean rounded) { boolean shared = !rounded && (paint == null) && (thickness == 1.0f) && (length == 1.0f) && (spacing == 1.0f); if (shared && (sharedDashedBorder != null)) { return sharedDashedBorder; } if (thickness < 1.0f) { throw new IllegalArgumentException("thickness is less than 1"); } if (length < 1.0f) { throw new IllegalArgumentException("length is less than 1"); } if (spacing < 0.0f) { throw new IllegalArgumentException("spacing is less than 0"); } int cap = rounded ? BasicStroke.CAP_ROUND : BasicStroke.CAP_SQUARE; int join = rounded ? BasicStroke.JOIN_ROUND : BasicStroke.JOIN_MITER; float[] array = { thickness * (length - 1.0f), thickness * (spacing + 1.0f) }; Border border = createStrokeBorder(new BasicStroke(thickness, cap, join, thickness * 2.0f, array, 0.0f), paint); if (shared) { sharedDashedBorder = border; } return border; }
Example #6
Source File: Line.java From chipster with MIT License | 6 votes |
/** * * @param g * @param width * @param height */ public void draw(Graphics g, int width, int height, PaintMode notUsed) { //Disable drawing lines very near camera, because it causes strange effects. //Value of 1.5 was found with visual experiment, so feel free to modify it. if (Math.abs(projectedCoords[0][0]) > 1.5 || Math.abs(projectedCoords[0][1]) > 1.5 || this.hidden) { return; } g.setColor(color); deviceCoords[0][0] = (int)((projectedCoords[0][0] + 0.5) * width); deviceCoords[0][1] = (int)((projectedCoords[0][1] + 0.5) * height); deviceCoords[1][0] = (int)((projectedCoords[1][0] + 0.5) * width); deviceCoords[1][1] = (int)((projectedCoords[1][1] + 0.5) * height); Graphics2D g2 = (Graphics2D)g; g2.setStroke(new BasicStroke(thickness)); g2.drawLine(deviceCoords[0][0], deviceCoords[0][1], deviceCoords[1][0], deviceCoords[1][1]); }
Example #7
Source File: LoopPipe.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public static ShapeSpanIterator getStrokeSpans(SunGraphics2D sg2d, Shape s) { ShapeSpanIterator sr = new ShapeSpanIterator(false); try { sr.setOutputArea(sg2d.getCompClip()); sr.setRule(PathIterator.WIND_NON_ZERO); BasicStroke bs = (BasicStroke) sg2d.stroke; boolean thin = (sg2d.strokeState <= SunGraphics2D.STROKE_THINDASHED); boolean normalize = (sg2d.strokeHint != SunHints.INTVAL_STROKE_PURE); RenderEngine.strokeTo(s, sg2d.transform, bs, thin, normalize, false, sr); } catch (Throwable t) { sr.dispose(); sr = null; throw new InternalError("Unable to Stroke shape ("+ t.getMessage()+")", t); } return sr; }
Example #8
Source File: R0.java From Forsythia with GNU General Public License v3.0 | 6 votes |
private void strokeVisiblePolygons(ViewportDef viewportdef,Graphics2D graphics,OrderedPolygons visiblepolygons,double visibledetailfloor,double alpha255detailfloor){ //stroke visible polygons double detailsize,zz; int alpha; Path2D path; BasicStroke stroke=createStroke(viewportdef,1.5); graphics.setStroke(stroke); for(List<FPolygon> a:visiblepolygons.getPolygonLists()){ for(FPolygon polygon:a){ //set alpha according to detail size relative to visibledetailfloor and alpha255detailfloor detailsize=polygon.getDetailSize(); if(detailsize>alpha255detailfloor){ alpha=255; }else if(detailsize<visibledetailfloor){ alpha=0; }else{ zz=(detailsize-visibledetailfloor)/(alpha255detailfloor-visibledetailfloor); alpha=(int)(zz*255);} path=polygon.getDPolygon().getPath2D(); graphics.setPaint(new Color(0,0,0,alpha));//black graphics.draw(path);}}}
Example #9
Source File: ColorPickerSliderUI.java From pumpernickel with MIT License | 6 votes |
@Override public void paintThumb(Graphics g) { int y = thumbRect.y + thumbRect.height / 2; Polygon polygon = new Polygon(); polygon.addPoint(0, y - ARROW_HALF); polygon.addPoint(ARROW_HALF, y); polygon.addPoint(0, y + ARROW_HALF); Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setColor(Color.black); g2.fill(polygon); g2.setColor(Color.white); g2.setStroke(new BasicStroke(1)); g2.draw(polygon); }
Example #10
Source File: Test7019861.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] argv) throws Exception { BufferedImage im = getWhiteImage(30, 30); Graphics2D g2 = (Graphics2D)im.getGraphics(); g2.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON); g2.setRenderingHint(KEY_STROKE_CONTROL, VALUE_STROKE_PURE); g2.setStroke(new BasicStroke(10, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); g2.setBackground(Color.white); g2.setColor(Color.black); Path2D p = getPath(0, 0, 20); g2.draw(p); if (!(new Color(im.getRGB(20, 19))).equals(Color.black)) { throw new Exception("This pixel should be black"); } }
Example #11
Source File: Draw.java From MeteoInfo with GNU Lesser General Public License v3.0 | 6 votes |
/** * Draw ellipse * * @param points The points * @param aPGB The polygon break * @param g Grahpics2D */ public static void drawEllipse(PointF[] points, PolygonBreak aPGB, Graphics2D g) { float sx = Math.min(points[0].X, points[2].X); float sy = Math.min(points[0].Y, points[2].Y); float width = Math.abs(points[2].X - points[0].X); float height = Math.abs(points[2].Y - points[0].Y); if (aPGB.isDrawFill()) { g.setColor(aPGB.getColor()); g.fill(new Ellipse2D.Float(sx, sy, width, height)); } if (aPGB.isDrawOutline()) { g.setColor(aPGB.getOutlineColor()); g.setStroke(new BasicStroke(aPGB.getOutlineSize())); g.draw(new Ellipse2D.Float(sx, sy, width, height)); } }
Example #12
Source File: BoundingBoxRenderer.java From render with GNU General Public License v2.0 | 6 votes |
public BoundingBoxRenderer(final RenderParameters renderParameters, final Color foregroundColor, final float lineWidth) { this.renderParameters = renderParameters; this.xOffset = renderParameters.getX(); this.yOffset = renderParameters.getY(); this.scale = renderParameters.getScale(); this.foregroundColor = foregroundColor; if (renderParameters.getBackgroundRGBColor() == null) { this.backgroundColor = null; } else { this.backgroundColor = new Color(renderParameters.getBackgroundRGBColor()); } this.stroke = new BasicStroke(lineWidth); }
Example #13
Source File: Renderer.java From gpx-animator with Apache License 2.0 | 6 votes |
private void printText(final Graphics2D g2, final String text, final float x, final float y) { final FontRenderContext frc = g2.getFontRenderContext(); g2.setStroke(new BasicStroke(3f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); final int height = g2.getFontMetrics(font).getHeight(); final String[] lines = text == null ? new String[0] : text.split("\n"); float yy = y - (lines.length - 1) * height; for (final String line : lines) { if (!line.isEmpty()) { final TextLayout tl = new TextLayout(line, font, frc); final Shape sha = tl.getOutline(AffineTransform.getTranslateInstance(x, yy)); g2.setColor(Color.white); g2.fill(sha); g2.draw(sha); g2.setFont(font); g2.setColor(Color.black); g2.drawString(line, x, yy); } yy += height; } }
Example #14
Source File: ClosableTabHost.java From SmartIM with Apache License 2.0 | 6 votes |
protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D)g.create(); // shift the image for pressed buttons if (getModel().isPressed()) { g2.translate(1, 1); } g2.setStroke(new BasicStroke(2)); g2.setColor(Color.GRAY); if (getModel().isRollover()) { g2.setColor(Color.LIGHT_GRAY); } int delta = 5; g2.drawLine(delta, delta, getWidth() - delta, getHeight() - delta); g2.drawLine(getWidth() - delta, delta, delta, getHeight() - delta); g2.dispose(); }
Example #15
Source File: StackedXYAreaRendererTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { StackedXYAreaRenderer r1 = new StackedXYAreaRenderer(); r1.setShapePaint(Color.red); r1.setShapeStroke(new BasicStroke(1.23f)); StackedXYAreaRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (StackedXYAreaRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2); }
Example #16
Source File: SynchronousXYItemPainter.java From netbeans with Apache License 2.0 | 6 votes |
public SynchronousXYItemPainter(float lineWidth, Color lineColor, Color fillColor, int type, int maxValueOffset) { if (lineColor == null && fillColor == null) throw new IllegalArgumentException("No parameters defined"); // NOI18N this.lineWidth = (int)Math.ceil(lineWidth); this.lineColor = Utils.checkedColor(lineColor); this.fillColor = Utils.checkedColor(fillColor); this.lineStroke = new BasicStroke(lineWidth, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); this.type = type; this.maxValueOffset = maxValueOffset; }
Example #17
Source File: MarkerTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Some checks for the getStroke() and setStroke() methods. */ public void testGetSetStroke() { // we use ValueMarker for the tests, because we need a concrete // subclass... ValueMarker m = new ValueMarker(1.1); m.addChangeListener(this); this.lastEvent = null; assertEquals(new BasicStroke(0.5f), m.getStroke()); m.setStroke(new BasicStroke(1.1f)); assertEquals(new BasicStroke(1.1f), m.getStroke()); assertEquals(m, this.lastEvent.getMarker()); // check null argument... try { m.setStroke(null); fail("Expected an IllegalArgumentException for null."); } catch (IllegalArgumentException e) { assertTrue(true); } }
Example #18
Source File: ImageScope.java From MyBox with Apache License 2.0 | 5 votes |
public static BufferedImage indicateRectangle(BufferedImage source, Color color, int lineWidth, DoubleRectangle rect) { try { int width = source.getWidth(); int height = source.getHeight(); if (!rect.isValid(width, height)) { return source; } int imageType = source.getType(); if (imageType == BufferedImage.TYPE_CUSTOM) { imageType = BufferedImage.TYPE_INT_ARGB; } BufferedImage target = new BufferedImage(width, height, imageType); Graphics2D g = target.createGraphics(); g.drawImage(source, 0, 0, width, height, null); AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f); g.setComposite(ac); g.setColor(color); BasicStroke stroke = new BasicStroke(lineWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1f, new float[]{lineWidth, lineWidth}, 0f); g.setStroke(stroke); g.drawRect((int) rect.getSmallX(), (int) rect.getSmallY(), (int) rect.getWidth(), (int) rect.getHeight()); g.dispose(); return target; } catch (Exception e) { logger.error(e.toString()); return source; } }
Example #19
Source File: StandardDialRange.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * Draws the range. * * @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). */ @Override 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); DialScale scale = plot.getScale(this.scaleIndex); if (scale == null) { throw new RuntimeException("No scale for scaleIndex = " + this.scaleIndex); } 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); }
Example #20
Source File: LAICPMSProjectParametersManager.java From ET_Redux with Apache License 2.0 | 5 votes |
/** * * @param g2d */ protected void paintInit(Graphics2D g2d) { RenderingHints rh = g2d.getRenderingHints(); rh.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); rh.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); g2d.setRenderingHints(rh); g2d.setPaint(Color.BLACK); g2d.setStroke(new BasicStroke(1.0f)); g2d.setFont(ReduxConstants.sansSerif_12_Bold); }
Example #21
Source File: Underline.java From Bytecoder with Apache License 2.0 | 5 votes |
private Stroke getStroke(float thickness) { float lineThickness = getLineThickness(thickness); BasicStroke stroke = cachedStroke; if (stroke == null || stroke.getLineWidth() != lineThickness) { stroke = createStroke(lineThickness); cachedStroke = stroke; } return stroke; }
Example #22
Source File: LocationViewer.java From sis with Apache License 2.0 | 5 votes |
/** * Invoked by Swing for painting this widget. * * @param g the graphic context where to paint. */ @Override protected void paintComponent(final Graphics g) { super.paintComponent(g); final Graphics2D gr = (Graphics2D) g; final AffineTransform oldTr = gr.getTransform(); final AffineTransform tr = AffineTransform.getScaleInstance( getWidth() / bounds.getWidth(), -getHeight() / bounds.getHeight()); tr.translate(-bounds.getMinX(), -bounds.getMaxY()); gr.transform(tr); gr.setStroke(new BasicStroke(0)); if (envelope != null) { gr.setColor(Color.RED); gr.draw(envelope); } gr.setColor(Color.YELLOW); for (final Shape location : locations.values()) { gr.draw(location); } gr.setTransform(oldTr); gr.setColor(Color.CYAN); final Point2D.Double p = new Point2D.Double(); for (final Map.Entry<String,Shape> entry : locations.entrySet()) { final Rectangle2D b = entry.getValue().getBounds2D(); p.x = b.getCenterX(); p.y = b.getCenterY(); final Point2D pt = tr.transform(p, p); final String label = entry.getKey(); gr.drawString(label, (float) (pt.getX() - 4.5*label.length()), (float) pt.getY()); } }
Example #23
Source File: ClipPath.java From openstock with GNU General Public License v3.0 | 5 votes |
/** * Constructor for ClipPath. * The fillPaint is set to Color.GRAY, the drawColor is Color.BLUE, the * stroke is BasicStroke(1) and the composite is AlphaComposite.Src. * * @param xValue x coordinates of curved to be created * @param yValue y coordinates of curved to be created * @param clip clip? * @param fillPath whether the path is to filled * @param drawPath whether the path is to drawn as an outline */ public ClipPath(double[] xValue, double[] yValue, boolean clip, boolean fillPath, boolean drawPath) { this.xValue = xValue; this.yValue = yValue; this.clip = clip; this.fillPath = fillPath; this.drawPath = drawPath; this.fillPaint = java.awt.Color.gray; this.drawPaint = java.awt.Color.blue; this.drawStroke = new BasicStroke(1); this.composite = java.awt.AlphaComposite.Src; }
Example #24
Source File: ControlWindow.java From TrakEM2 with GNU General Public License v3.0 | 5 votes |
CloseIcon() { img = frame.getGraphicsConfiguration().createCompatibleImage(20, 16, Transparency.TRANSLUCENT); Graphics2D g = img.createGraphics(); g.setColor(Color.black); g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.drawOval(4 + 2, 2, 12, 12); g.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); g.drawLine(4 + 4, 4, 4 + 11, 12); g.drawLine(4 + 4, 12, 4 + 11, 4); icon = new ImageIcon(img); }
Example #25
Source File: LineBorderTest.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Confirm that the equals() method can distinguish all the required fields. */ @Test public void testEquals() { LineBorder b1 = new LineBorder(Color.red, new BasicStroke(1.0f), new RectangleInsets(1.0, 1.0, 1.0, 1.0)); LineBorder b2 = new LineBorder(Color.red, new BasicStroke(1.0f), new RectangleInsets(1.0, 1.0, 1.0, 1.0)); assertTrue(b1.equals(b2)); assertTrue(b2.equals(b2)); b1 = new LineBorder(Color.blue, new BasicStroke(1.0f), new RectangleInsets(1.0, 1.0, 1.0, 1.0)); assertFalse(b1.equals(b2)); b2 = new LineBorder(Color.blue, new BasicStroke(1.0f), new RectangleInsets(1.0, 1.0, 1.0, 1.0)); assertTrue(b1.equals(b2)); b1 = new LineBorder(Color.blue, new BasicStroke(1.1f), new RectangleInsets(1.0, 1.0, 1.0, 1.0)); assertFalse(b1.equals(b2)); b2 = new LineBorder(Color.blue, new BasicStroke(1.1f), new RectangleInsets(1.0, 1.0, 1.0, 1.0)); assertTrue(b1.equals(b2)); b1 = new LineBorder(Color.blue, new BasicStroke(1.1f), new RectangleInsets(1.0, 2.0, 3.0, 4.0)); assertFalse(b1.equals(b2)); b2 = new LineBorder(Color.blue, new BasicStroke(1.1f), new RectangleInsets(1.0, 2.0, 3.0, 4.0)); assertTrue(b1.equals(b2)); }
Example #26
Source File: XYShapeAnnotationTest.java From openstock with GNU General Public License v3.0 | 5 votes |
/** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { XYShapeAnnotation a1 = new XYShapeAnnotation( new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(1.2f), Color.red, Color.blue); XYShapeAnnotation a2 = new XYShapeAnnotation( new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(1.2f), Color.red, Color.blue); assertTrue(a1.equals(a2)); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); }
Example #27
Source File: DashZeroWidth.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static void draw(final Image img) { float[] dashes = {10.0f, 10.0f}; BasicStroke bs = new BasicStroke(0.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10.0f, dashes, 0.0f); Graphics2D g = (Graphics2D) img.getGraphics(); g.setColor(Color.WHITE); g.fillRect(0, 0, 200, 40); Line2D line = new Line2D.Double(20, 20, 180, 20); g.setColor(Color.BLACK); g.setStroke(bs); g.draw(line); g.dispose(); }
Example #28
Source File: HistogramChartFactory.java From mzmine2 with GNU General Public License v2.0 | 5 votes |
/** * Adds annotations to the Gaussian fit parameters * * @param plot * @param fit Gaussian fit {normalisation factor, mean, sigma} */ public static void addGaussianFitAnnotations(XYPlot plot, double[] fit) { Paint c = plot.getDomainCrosshairPaint(); BasicStroke s = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, new float[] {5f, 2.5f}, 0); plot.addDomainMarker(new ValueMarker(fit[1], c, s)); plot.addDomainMarker(new ValueMarker(fit[1] - fit[2], c, s)); plot.addDomainMarker(new ValueMarker(fit[1] + fit[2], c, s)); }
Example #29
Source File: StandardDialScale.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Creates a new instance. * * @param lowerBound the lower bound of the scale. * @param upperBound the upper bound of the scale. * @param startAngle the start angle (in degrees, using the same * orientation as Java's <code>Arc2D</code> class). * @param extent the extent (in degrees, counter-clockwise). * @param majorTickIncrement the interval between major tick marks (must * be > 0). * @param minorTickCount the number of minor ticks between major tick * marks. */ public StandardDialScale(double lowerBound, double upperBound, double startAngle, double extent, double majorTickIncrement, int minorTickCount) { if (majorTickIncrement <= 0.0) { throw new IllegalArgumentException( "Requires 'majorTickIncrement' > 0."); } this.startAngle = startAngle; this.extent = extent; this.lowerBound = lowerBound; this.upperBound = upperBound; this.tickRadius = 0.70; this.tickLabelsVisible = true; this.tickLabelFormatter = new DecimalFormat("0.0"); this.firstTickLabelVisible = true; this.tickLabelFont = new Font("Dialog", Font.BOLD, 16); this.tickLabelPaint = Color.blue; this.tickLabelOffset = 0.10; this.majorTickIncrement = majorTickIncrement; this.majorTickLength = 0.04; this.majorTickPaint = Color.black; this.majorTickStroke = new BasicStroke(3.0f); this.minorTickCount = minorTickCount; this.minorTickLength = 0.02; this.minorTickPaint = Color.black; this.minorTickStroke = new BasicStroke(1.0f); }
Example #30
Source File: XYBoxAnnotationTest.java From openstock with GNU General Public License v3.0 | 5 votes |
/** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { XYBoxAnnotation a1 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, new BasicStroke(1.2f), Color.red, Color.blue); XYBoxAnnotation a2 = (XYBoxAnnotation) TestUtilities.serialised(a1); assertEquals(a1, a2); }