/** * Creates a new instance of <code>DialValueIndicator</code>. * * @param datasetIndex the dataset index. * @param label the label. */ public DialValueIndicator(int datasetIndex, String label) { this.datasetIndex = datasetIndex; this.angle = -90.0; this.radius = 0.3; this.frameAnchor = RectangleAnchor.CENTER; this.templateValue = new Double(100.0); this.formatter = new DecimalFormat("0.0"); this.font = new Font("Dialog", Font.BOLD, 14); this.paint = Color.black; this.backgroundPaint = Color.white; this.outlineStroke = new BasicStroke(1.0f); this.outlinePaint = Color.blue; this.insets = new RectangleInsets(4, 4, 4, 4); this.valueAnchor = RectangleAnchor.RIGHT; this.textAnchor = TextAnchor.CENTER_RIGHT; }
public void strokeTo(Shape src, AffineTransform at, BasicStroke bs, boolean thin, boolean normalize, boolean antialias, PathConsumer2D consumer) { System.out.println(name+".strokeTo("+ src.getClass().getName()+", "+ at+", "+ bs+", "+ (thin ? "thin" : "wide")+", "+ (normalize ? "normalized" : "pure")+", "+ (antialias ? "AA" : "non-AA")+", "+ consumer.getClass().getName()+")"); target.strokeTo(src, at, bs, thin, normalize, antialias, consumer); }
public void redrawCanvas(int x, int y, double a){ int R = (int)a; int G =(int) (255-a); int B = 0; Graphics2D g= ((Graphics2D) canvas.getGraphics()); g.setColor(new Color(R,G,B)); g.setStroke(new BasicStroke(15)); g.drawLine(x, y,x, y); g.dispose(); //((Graphics2D) canvas.getGraphics()).setStroke(new BasicStroke(30)); // ((Graphics2D) canvas.getGraphics()).drawLine(x, y,x, y); // Graphics2D g2 = (Graphics2D) canvas.getGraphics(); // g2.setStroke(new BasicStroke(10)); // g2.draw(new Line2D.Double(x, y, x, y)); // canvas.paint(g2); }
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; }
public JFreeChart scatterGridPlot(String xLabel, String yLabel){ int numDatasets = dataset.size(); JFreeChart result = ChartFactory.createScatterPlot(chartTitle , xLabel , yLabel , dataset.get(0)); XYPlot plot = result.getXYPlot(); plot.getRenderer().setSeriesStroke(0, new BasicStroke(1.0f)); plot.getRenderer().setSeriesPaint(0, seriesColor.get(0)); for(int i=1;i<numDatasets;i++){ plot.setDataset(i,dataset.get(i)); //XYItemRenderer renderer = plot.getRenderer(i-0); plot.setRenderer(i, new XYLineAndShapeRenderer(true, true)); plot.getRenderer(i).setSeriesStroke(0, new BasicStroke(1.0f)); plot.getRenderer(i).setSeriesPaint(0,seriesColor.get(i)); } return result; }
/** * Some checks for the put() method. */ public void testPut() { StrokeMap m1 = new StrokeMap(); m1.put("A", new BasicStroke(1.1f)); assertEquals(new BasicStroke(1.1f), m1.getStroke("A")); // a null key should throw an IllegalArgumentException boolean pass = false; try { m1.put(null, new BasicStroke(1.1f)); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); }
/** * */ public Stroke createStroke(Map<String, Object> style) { double width = mxUtils .getFloat(style, mxConstants.STYLE_STROKEWIDTH, 1) * scale; boolean dashed = mxUtils.isTrue(style, mxConstants.STYLE_DASHED); if (dashed) { float[] dashPattern = mxUtils.getFloatArray(style, mxConstants.STYLE_DASH_PATTERN, mxConstants.DEFAULT_DASHED_PATTERN, " "); float[] scaledDashPattern = new float[dashPattern.length]; for (int i = 0; i < dashPattern.length; i++) { scaledDashPattern[i] = (float) (dashPattern[i] * scale * width); } return new BasicStroke((float) width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, scaledDashPattern, 0.0f); } else { return new BasicStroke((float) width); } }
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"); } }
final private void doDrawShoulders() { // Set graphics : final Graphics2D objLjugglerGraphics2D = (Graphics2D) (Tools.contains( this.objGjuggleMasterPro.bytGjugglerVisibility, Constants.bytS_BIT_VISIBILITY_TRAIL) ? this.imgGjugglerFrontTrailsBuffer.getGraphics() : this.imgGanimationBuffer.getGraphics()); objLjugglerGraphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); this.doOptimizeGraphics(objLjugglerGraphics2D); // Draw shoulders : objLjugglerGraphics2D.setColor(this.objGjuggleMasterPro.objGjugglerColorA[this.objGjuggleMasterPro.bytGlight]); for (byte bytLside = Constants.bytS_ENGINE_LEFT_SIDE; bytLside <= Constants.bytS_ENGINE_RIGHT_SIDE; ++bytLside) { if (this.objGjuggleMasterPro.objGhandA[bytLside].bolGarmVisible) { objLjugglerGraphics2D.setStroke(new BasicStroke(this.objGjuggleMasterPro.objGstyleA[Constants.bytS_UNCLASS_CURRENT].getArmWidth(this.objGjuggleMasterPro.objGhandA[bytLside].fltGposZ, (byte) 2, this.objGjuggleMasterPro.objGhandA[bytLside].bolGarmHandZOrder), BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); this.objGjuggleMasterPro.objGbody.drawArmPart(objLjugglerGraphics2D, this.fltGframeSizeRatio, bytLside, (byte) 2); } } objLjugglerGraphics2D.dispose(); }
/** * 随机画点 * * @param image 图片 */ private void drawPoint(BufferedImage image) { if (this.pointPower == -1) { return; } Random r = new Random(); Graphics2D g2 = (Graphics2D) image.getGraphics(); int max = this.w * this.h / this.pointPower; for (int i = 0; i < max; i++) { int x = r.nextInt(w); int y = r.nextInt(h); g2.setStroke(new BasicStroke(1.5F)); g2.setColor(this.randomColor()); g2.drawOval(x, y, 1, 1); } g2.dispose(); }
@Override public void paintComponent(Graphics g) { SwingUtilities.invokeLater(() -> { super.paintComponent(g); Graphics2D g2 = (Graphics2D) getGraphics(); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setStroke(new BasicStroke(5, BasicStroke.JOIN_ROUND, BasicStroke.CAP_ROUND)); g2.setColor(Color.red); g2.drawLine(pressed.x, pressed.y, released.x, released.y); g2.setStroke(new BasicStroke(5, BasicStroke.JOIN_ROUND, BasicStroke.CAP_ROUND)); g2.drawOval(released.x - 25, released.y - 25, 50, 50); g2.fillOval(released.x - 10, released.y - 10, 20, 20); g2.dispose(); }); }
/** * 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). */ 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); }
public FlyingToolTip(final FlyingToolTipListener source) { this.source = source; label = new JLabel("test", JLabel.CENTER) { @Override public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g.create(); int w = getWidth(), h = getHeight(); g.setColor(getBackground()); g.fillRect(0,0,w,h); if (path != null) { g2.setStroke(new BasicStroke(4f)); g2.setColor(getForeground()); g2.draw(path); } setOpaque(false); super.paintComponent(g2); setOpaque(true); g2.dispose(); } }; label.setBorder(new EmptyBorder(2,4,10,4)); label.setOpaque(true); }
DiscreteXYPainter(float lineWidth, Color lineColor, Color fillColor, int width, boolean fixedWidth, boolean topLineOnly, boolean outlineOnly, double dataFactor, PointsComputer computer) { super((int)Math.ceil(lineWidth), fillColor != null || (!topLineOnly && !outlineOnly), dataFactor); if (lineColor == null && fillColor == null) throw new IllegalArgumentException("lineColor or fillColor must not be null"); // NOI18N this.lineWidth = (int)Math.ceil(lineWidth); this.lineColor = Utils.checkedColor(lineColor); this.fillColor = Utils.checkedColor(fillColor); definingColor = lineColor != null ? lineColor : fillColor; this.lineStroke = new BasicStroke(lineWidth, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); this.width = width; this.fixedWidth = fixedWidth; this.topLineOnly = topLineOnly; this.outlineOnly = outlineOnly; this.computer = computer; }
public void drawCurrentPoint() { if( map==null || point==null || !map.isVisible() ) return; synchronized (map.getTreeLock() ) { Graphics2D g = map.getGraphics2D(); float zoom = (float)map.getZoom(); g.setStroke( new BasicStroke( 2f/ zoom ) ); g.setColor(Color.RED); g.setXORMode( Color.white ); Rectangle2D rect = map.getClipRect2D(); double wrap = map.getWrap(); if( wrap>0. ) while( point.x-wrap > rect.getX() ) point.x-=wrap; double size = 10./map.getZoom(); Arc2D.Double arc = new Arc2D.Double( 0., point.y-.5*size, size, size, 0., 360., Arc2D.CHORD); if( wrap>0. ) { while( point.x < rect.getX()+rect.getWidth() ) { arc.x = point.x-.5*size; g.draw(arc); point.x += wrap; } } else { arc.x = point.x-.5*size; g.draw(arc); } } }
private static BufferedImage drawTileName(BufferedImage image, String name) { BufferedImage i2 = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_RGB); Graphics2D g2 = i2.createGraphics(); g2.drawImage(image, null, 0, 0); g2.setColor(Color.red); g2.setStroke(new BasicStroke(4)); g2.drawRect(8, 8, image.getWidth() - 8, image.getHeight() - 8); g2.setColor(Color.RED); g2.setFont(g2.getFont().deriveFont(Font.BOLD).deriveFont(13f)); FontMetrics fm = g2.getFontMetrics(); String[] parts = name.split("/"); for (int i = 0; i < parts.length; i++) { String s = i == parts.length - 1 ? parts[i] : parts[i] + "/"; int x = 40 + i * 5; int y = 40 + i * (fm.getHeight() + 5); Rectangle2D rect = fm.getStringBounds(s, g2); g2.setColor(Color.white); g2.fillRect(x, y - fm.getAscent(), (int)rect.getWidth(), fm.getHeight()); g2.setColor(Color.red); g2.drawString(s, x, y); } return i2; }
/** * Some checks for the getOutlineStroke() and setOutlineStroke() methods. */ 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()); }
/** * Creates an area chart using the specified {@code dataset}. * * @param dataset the dataset. * * @return An area chart. */ public static Chart3D createChart(CategoryDataset3D dataset) { Chart3D chart = Chart3DFactory.createAreaChart( "Reported Revenues By Quarter", "Large companies in the IT industry", dataset, "Company", "Quarter", "Value"); chart.setChartBoxColor(new Color(255, 255, 255, 128)); CategoryPlot3D plot = (CategoryPlot3D) chart.getPlot(); plot.getRowAxis().setVisible(false); plot.setGridlineStrokeForValues(new BasicStroke(0.5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 4.0f, new float[] { 2f, 2f }, 0f)); AreaRenderer3D renderer = (AreaRenderer3D) plot.getRenderer(); renderer.setBaseColor(Color.GRAY); return chart; }
public void plotXY( Graphics2D g, Rectangle2D bounds, double xScale, double yScale, int k) { GeneralPath path = new GeneralPath(); boolean start = true; for( int i=0 ; i<rows.size() ; i++) { if( !plot[k][i] )continue; double[] row = (double[])rows.get(i); float x = (float)((row[k+1]-bounds.getX())*xScale); float y = (float)((row[0]-bounds.getY())*yScale); if( start ) { path.moveTo(x,y); start = false; } else path.lineTo(x,y); } g.setColor( Color.white ); g.setStroke( new BasicStroke(3f) ); g.draw(path); g.setColor( Color.black ); g.setStroke( new BasicStroke(1f) ); g.draw(path); }
/** * 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; }
/** * */ public Stroke createStroke(Map<String, Object> style) { double width = mxUtils.getFloat(style, mxConstants.STYLE_STROKEWIDTH, 1) * scale; boolean dashed = mxUtils.isTrue(style, mxConstants.STYLE_DASHED); if (dashed) { float[] dashPattern = mxUtils.getFloatArray(style, mxConstants.STYLE_DASH_PATTERN, mxConstants.DEFAULT_DASHED_PATTERN, " "); float[] scaledDashPattern = new float[dashPattern.length]; for (int i = 0; i < dashPattern.length; i++) { scaledDashPattern[i] = (float) (dashPattern[i] * scale * width); } return new BasicStroke((float) width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, scaledDashPattern, 0.0f); } else { return new BasicStroke((float) width); } }
/** If the graphics argument is an instance of Graphics2D, then set * the current stroke to the specified width. Otherwise, do nothing. * @param graphics The graphics object. * @param width The width. */ protected void _setWidth(Graphics graphics, float width) { // For historical reasons, the API here only assumes Graphics // objects, not Graphics2D. if (graphics instanceof Graphics2D) { // We cache the two most common cases. if (width == 1f) { ((Graphics2D)graphics).setStroke(_lineStroke1); } else if (width == 2f) { ((Graphics2D)graphics).setStroke(_lineStroke2); } else { ((Graphics2D)graphics).setStroke(new BasicStroke( width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND)); } } }
public void paintIcon(Component c, Graphics g, int x, int y) { Shape shape = AffineTransform.getTranslateInstance(x, y).createTransformedShape(path); Graphics2D g2d = (Graphics2D)g; g2d.addRenderingHints(Collections.singletonMap(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); g2d.setStroke(new BasicStroke(4)); g2d.setColor(Color.darkGray); g2d.draw(shadow.createTransformedShape(shape)); g2d.setColor(Color.black); g2d.draw(lowlight.createTransformedShape(shape)); g2d.setColor(Color.white); g2d.draw(highlight.createTransformedShape(shape)); g2d.setColor(color); g2d.draw(shape); }
protected boolean selectStylePen(int cap, int join, float width, Color color) { long endCap; long lineJoin; float[] rgb = color.getRGBColorComponents(null); switch(cap) { case BasicStroke.CAP_BUTT: endCap = PS_ENDCAP_FLAT; break; case BasicStroke.CAP_ROUND: endCap = PS_ENDCAP_ROUND; break; default: case BasicStroke.CAP_SQUARE: endCap = PS_ENDCAP_SQUARE; break; } switch(join) { case BasicStroke.JOIN_BEVEL:lineJoin = PS_JOIN_BEVEL; break; default: case BasicStroke.JOIN_MITER:lineJoin = PS_JOIN_MITER; break; case BasicStroke.JOIN_ROUND:lineJoin = PS_JOIN_ROUND; break; } return (selectStylePen(getPrintDC(), endCap, lineJoin, width, (int) (rgb[0] * MAX_WCOLOR), (int) (rgb[1] * MAX_WCOLOR), (int) (rgb[2] * MAX_WCOLOR))); }
@Override public void paintWidget() { ObjectState os = this.getState(); if(!os.isHovered() && !os.isSelected()) return; //all previewEdges visible and not hovering, //no need to paint the switch float hw = width/2; Polygon pol = new Polygon(); pol.addPoint(0,(int) -height/2); pol.addPoint((int)hw,(int) height/2); pol.addPoint((int)-hw,(int) height/2); Graphics2D gr = getGraphics(); gr.setColor(this.getForeground()); BasicStroke bs = new BasicStroke(2.0f, BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND); gr.setStroke(bs); AffineTransform previousTransform; previousTransform = gr.getTransform (); if(output) { if(os.isSelected() ){//hidden gr.scale(1.0, -1.0); } } else { //input switch if(os.isHovered() && !os.isSelected()){ gr.scale(1.0, -1.0); } } gr.fillPolygon(pol); gr.setTransform(previousTransform); }
private void drawSelection(Graphics2D g2d) { selection.setFrameFromDiagonal(sys.start, sys.end); Rectangle select = this.selection.getBounds(); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); g2d.setStroke(new BasicStroke(1.8f)); g2d.setColor(Color.RED); g2d.drawRect(select.x, select.y, select.width, select.height); }
@Override public void render(final Graphics2D g) { final Stroke oldStroke = g.getStroke(); g.setStroke(new BasicStroke((float) (this.getHeight() / 8))); g.setColor(this.getAppearance().getForeColor()); g.drawLine((int) this.minSliderX, (int) (this.getY() + this.getHeight() / 2), (int) (this.getX() + this.getWidth() - this.getHeight()), (int) (this.getY() + this.getHeight() / 2)); g.setStroke(oldStroke); super.render(g); }
protected void PaintGradiente(Graphics2D g) { //, boolean round) { Paint bkp = g.getPaint(); int dist = distSelecao; int W = getWidth() - dist; int H = 2 * alturaTexto - 1 - dist; boolean dv = getGDirecao() == VERTICAL; Composite originalComposite = g.getComposite(); int type = AlphaComposite.SRC_OVER; g.setComposite(AlphaComposite.getInstance(type, alfa)); Stroke bkps = g.getStroke(); if (isDashed()) { g.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[]{1, 2}, 0)); } // GradientPaint GP = new GradientPaint(getLeft(), getTop(), Color.LIGHT_GRAY, dv ? getLeft() : getLeft() + W, dv ? getTop() + H : getTop(), Color.white, true); // g.setPaint(GP); int w = getWidth() - dist; int h = getHeight() - dist; int L = getLeft(); int T = getTop(); GradientPaint GP = new GradientPaint(L, T, getGradienteStartColor(), dv ? L : L + w, dv ? T + h : T, getGradienteEndColor(), true); g.setPaint(GP); g.fillRect(getLeft() + 1, getTop() + 1, W, H); g.setComposite(originalComposite); g.setPaint(bkp); g.setStroke(bkps); }
@Override public void render(final Graphics2D g) { g.setColor(new Color(255, 255, 0, 100)); RenderEngine.fillShape(g, this.calculateImpactArea()); final Stroke oldStroke = g.getStroke(); g.setStroke(new BasicStroke(2f)); g.setColor(new Color(255, 255, 0, 200)); RenderEngine.drawShape(g, this.calculateImpactArea()); g.setStroke(oldStroke); }
/** * Two objects that are equal are required to return the same hashCode. */ 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); }
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; }
/** * Draws bounding box of bookmarked locations */ public void draw(Graphics2D g) { if( !showLoc.isSelected() )return; double zoom = map.getZoom(); g.setStroke(new BasicStroke(1f/(float)zoom)); Rectangle rect = map.getVisibleRect(); Dimension r1 = map.getParent().getSize(); Enumeration e = locs.elements(); while( e.hasMoreElements()) { MapPlace loc = (MapPlace)e.nextElement(); loc.draw(g, map); } }
/** * Test that setting the stroke for ALL series does in fact work. */ public void testSetStroke() { BarRenderer r = new BarRenderer(); Stroke s = new BasicStroke(10.0f); r.setStroke(s); assertEquals(s, r.getItemStroke(0, 0)); }
@Override protected void PinteRegiao(Graphics2D g) { Composite originalComposite = g.getComposite(); g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alfa)); g.setPaint(this.getForeColor()); if (isGradiente()) { int dist = 0; int w = getWidth() - dist; int h = getHeight() - dist; int L = getLeft(); int T = getTop(); boolean dv = getGDirecao() == VERTICAL; GradientPaint GP = new GradientPaint(L, T, getGradienteStartColor(), dv ? L : L + w, dv ? T + h : T, getGradienteEndColor(), true); g.setPaint(GP); } if (getTipoDesenho() != TipoDraw.tpTexto) { Stroke bkp = g.getStroke(); if (isDashed()) { g.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[]{1, 2}, 0)); } if (isGradiente()) { g.fill(getRegiao()); } g.draw(getRegiao()); //Pinta as eventuais linhas internas do dezenho. Ex. LivreVariosDocumemtos g.setStroke(bkp); } g.setComposite(originalComposite); }
public RoundBorder(float lineWidth, Color lineColor, Color fillColor, int arcRadius, int borderExtent) { this.lineColor = Utils.checkedColor(lineColor); this.fillColor = Utils.checkedColor(fillColor); this.arcRadius = arcRadius; this.borderExtent = borderExtent; borderStroke = new BasicStroke(lineWidth); borderStrokeWidth = (int)lineWidth; halfBorderStrokeWidth = borderStrokeWidth / 2; inset = borderStrokeWidth + borderExtent; forceSpeed = Utils.forceSpeed(); }
@Override public void draw(Graphics2D graphics) { double[] radii = {.8 * radius, .5 * radius, .2 * radius}; Color color = new Color(1f, 0f, 0f, 1f); graphics.setColor(color); graphics.setStroke(new BasicStroke((float)(radius/6), BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); Ellipse2D.Double circle = null; for (double drawRadius : radii) { circle = new Ellipse2D.Double(currentPosition.getX() - drawRadius, currentPosition.getY() - drawRadius, 2 * drawRadius, 2 * drawRadius); graphics.draw(circle); } graphics.fill(circle); Line2D.Double line = new Line2D.Double( currentPosition.getX() - radius, currentPosition.getY(), currentPosition.getX() + radius, currentPosition.getY()); graphics.setStroke(JSpaceSettlersComponent.THIN_STROKE); graphics.draw(line); line = new Line2D.Double( currentPosition.getX(), currentPosition.getY() - radius, currentPosition.getX(), currentPosition.getY() + radius); graphics.draw(line); }
public void setSeriesLineWidth(int seriesIndex, float lineWidth) throws NoSuchSeriesException{ if(seriesIndex < dataModel.getSeriesCount()){ XYItemRenderer renderer = this.chartPanel.getChart().getXYPlot().getRenderer(); renderer.setSeriesStroke(seriesIndex, new BasicStroke(lineWidth)); }else{ throw new NoSuchSeriesException(); } }
private JFreeChart createNumericalChart() { JFreeChart chart; XYDataset dataset = createNumericalDataSet(); // create the chart... String domainName = dataTable == null ? MODEL_DOMAIN_AXIS_NAME : dataTable.getColumnName(plotColumn); chart = ChartFactory.createXYLineChart(null, // chart title domainName, // x axis label RANGE_AXIS_NAME, // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); DeviationRenderer renderer = new DeviationRenderer(true, false); Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); if (dataset.getSeriesCount() == 1) { renderer.setSeriesStroke(0, stroke); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesFillPaint(0, Color.RED); } else { for (int i = 0; i < dataset.getSeriesCount(); i++) { renderer.setSeriesStroke(i, stroke); Color color = getColorProvider().getPointColor((double) i / (double) (dataset.getSeriesCount() - 1)); renderer.setSeriesPaint(i, color); renderer.setSeriesFillPaint(i, color); } } renderer.setAlpha(0.12f); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRenderer(renderer); return chart; }