List of usage examples for java.awt BasicStroke BasicStroke
public BasicStroke(float width)
From source file:org.jfree.chart.demo.PlotOrientationDemo.java
/** * Creates a new demo instance.//from ww w . j av a 2 s .c om * * @param title the frame title. */ public PlotOrientationDemo(String title) { super(title); JPanel panel = new JPanel(new GridLayout(2, 4)); for (int i = 0; i < CHART_COUNT; i++) { this.datasets[i] = createDataset(i); this.charts[i] = createChart(i, this.datasets[i]); XYPlot plot = this.charts[i].getXYPlot(); XYShapeAnnotation a1 = new XYShapeAnnotation(new Rectangle2D.Double(1.0, 2.0, 2.0, 3.0), new BasicStroke(1.0f), Color.blue); XYLineAnnotation a2 = new XYLineAnnotation(0.0, -5.0, 10.0, -5.0); XYImageAnnotation a3 = new XYImageAnnotation(5.0, 2.0, JFreeChart.INFO.getLogo()); plot.addAnnotation(a1); plot.addAnnotation(a2); plot.addAnnotation(a3); plot.setQuadrantPaint(0, new Color(230, 230, 255)); plot.setQuadrantPaint(1, new Color(230, 255, 230)); plot.setQuadrantPaint(2, new Color(255, 230, 230)); plot.setQuadrantPaint(3, new Color(255, 230, 255)); this.panels[i] = new ChartPanel(this.charts[i]); } this.charts[1].getXYPlot().getDomainAxis().setInverted(true); this.charts[2].getXYPlot().getRangeAxis().setInverted(true); this.charts[3].getXYPlot().getDomainAxis().setInverted(true); this.charts[3].getXYPlot().getRangeAxis().setInverted(true); this.charts[5].getXYPlot().getDomainAxis().setInverted(true); this.charts[6].getXYPlot().getRangeAxis().setInverted(true); this.charts[4].getXYPlot().getDomainAxis().setInverted(true); this.charts[4].getXYPlot().getRangeAxis().setInverted(true); this.charts[4].getXYPlot().setOrientation(PlotOrientation.HORIZONTAL); this.charts[5].getXYPlot().setOrientation(PlotOrientation.HORIZONTAL); this.charts[6].getXYPlot().setOrientation(PlotOrientation.HORIZONTAL); this.charts[7].getXYPlot().setOrientation(PlotOrientation.HORIZONTAL); panel.add(this.panels[0]); panel.add(this.panels[1]); panel.add(this.panels[4]); panel.add(this.panels[5]); panel.add(this.panels[2]); panel.add(this.panels[3]); panel.add(this.panels[6]); panel.add(this.panels[7]); panel.setPreferredSize(new Dimension(800, 600)); setContentPane(panel); }
From source file:org.encog.workbench.dialogs.activation.EquationPanel.java
/** * Creates a line chart using the data from the supplied dataset. * * @param dataset the dataset.//from w w w .j a va2 s .c o m * * @return The chart. */ public static JFreeChart createChart(XYDataset dataset, ActivationFunction activation, boolean normal) { String title; if (normal) { title = activation.getClass().getSimpleName(); } else { if (activation.hasDerivative()) { title = "Derv of " + activation.getClass().getSimpleName(); } else { title = "NO Derv of " + activation.getClass().getSimpleName(); } } JFreeChart chart = ChartFactory.createXYLineChart(title, "input (x)", "output (y)", dataset, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); if (normal) { plot.setDomainZeroBaselineVisible(true); plot.setRangeZeroBaselineVisible(true); plot.setDomainPannable(true); plot.setRangePannable(true); ValueAxis xAxis = plot.getDomainAxis(); xAxis.setLowerMargin(0.0); xAxis.setUpperMargin(0.0); XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plot.getRenderer(); r.setDrawSeriesLineAsPath(true); r.setSeriesStroke(0, new BasicStroke(1.5f)); r.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 6.0f, 4.0f }, 0.0f)); r.setSeriesStroke(2, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 6.0f, 4.0f, 3.0f, 3.0f }, 0.0f)); r.setSeriesStroke(3, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 4.0f, 4.0f }, 0.0f)); } return chart; }
From source file:view.FuzzySetView.java
/** * *///from ww w . j a v a2 s .co m public void refreshRenderer() { XYItemRenderer renderer = plot.getRenderer(); int termCount = plot.getSeriesCount(); for (int i = 0; i < termCount; i++) { renderer.setSeriesPaint(i, colors[i]); } BasicStroke stroke = new BasicStroke(3f); for (int i = 0; i < termCount; i++) { renderer.setSeriesStroke(i, stroke); } }
From source file:org.openaltimeter.desktopapp.annotations.XYHeightAnnotation.java
@Override public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis domainAxis, ValueAxis rangeAxis, int rendererIndex, PlotRenderingInfo info) { PlotOrientation orientation = plot.getOrientation(); RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(plot.getDomainAxisLocation(), orientation); RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(plot.getRangeAxisLocation(), orientation); float anchorX = (float) domainAxis.valueToJava2D(this.getX(), dataArea, domainEdge); float anchorY = (float) rangeAxis.valueToJava2D(this.getY(), dataArea, rangeEdge); if (orientation == PlotOrientation.HORIZONTAL) { float tempAnchor = anchorX; anchorX = anchorY;//w w w .ja v a 2s . c o m anchorY = tempAnchor; } g2.setFont(getFont()); Shape hotspot = TextUtilities.calculateRotatedStringBounds(getText(), g2, anchorX, anchorY, getTextAnchor(), getRotationAngle(), getRotationAnchor()); if (this.getBackgroundPaint() != null) { g2.setPaint(this.getBackgroundPaint()); g2.fill(hotspot); } g2.setPaint(getPaint()); TextUtilities.drawRotatedString(getText(), g2, anchorX + (3.6f * DOT_SIZE), anchorY + (0.2f * DOT_SIZE), getTextAnchor(), getRotationAngle(), getRotationAnchor()); if (this.isOutlineVisible()) { g2.setStroke(this.getOutlineStroke()); g2.setPaint(this.getOutlinePaint()); g2.draw(hotspot); } // cross drawing // g2.setPaint(getPaint()); // g2.setStroke(new BasicStroke(1.0f)); // g2.drawLine((int) anchorX - CROSS_SIZE / 2, (int) anchorY, (int) anchorX + CROSS_SIZE / 2, (int) anchorY); // g2.drawLine((int) anchorX, (int) anchorY - CROSS_SIZE / 2, (int) anchorX, (int) anchorY + CROSS_SIZE / 2); // dot drawing g2.setPaint(getPaint()); g2.setStroke(new BasicStroke(1.0f)); Ellipse2D e = new Ellipse2D.Double(anchorX - DOT_SIZE / 2, anchorY - DOT_SIZE / 2, DOT_SIZE, DOT_SIZE); g2.fill(e); String toolTip = getToolTipText(); String url = getURL(); if (toolTip != null || url != null) { addEntity(info, hotspot, rendererIndex, toolTip, url); } }
From source file:org.jfree.chart.demo.PlotOrientationDemo2.java
/** * Creates a new demo instance.// w w w . j av a2 s.co m * * @param title the frame title. */ public PlotOrientationDemo2(String title) { super(title); JPanel panel = new JPanel(new GridLayout(2, 4)); for (int i = 0; i < CHART_COUNT; i++) { this.datasets[i] = createDataset(i); this.charts[i] = createChart(i, this.datasets[i]); XYPlot plot = this.charts[i].getXYPlot(); XYShapeAnnotation a1 = new XYShapeAnnotation(new Rectangle2D.Double(1.0, 2.0, 2.0, 3.0), new BasicStroke(1.0f), Color.blue); XYLineAnnotation a2 = new XYLineAnnotation(0.0, -5.0, 10.0, -5.0); plot.addAnnotation(a1); plot.addAnnotation(a2); plot.addDomainMarker(new IntervalMarker(5.0, 10.0), Layer.BACKGROUND); plot.addRangeMarker(new IntervalMarker(-2.0, 0.0), Layer.BACKGROUND); this.panels[i] = new ChartPanel(this.charts[i]); } this.charts[1].getXYPlot().getDomainAxis().setInverted(true); this.charts[2].getXYPlot().getRangeAxis().setInverted(true); this.charts[3].getXYPlot().getDomainAxis().setInverted(true); this.charts[3].getXYPlot().getRangeAxis().setInverted(true); this.charts[5].getXYPlot().getDomainAxis().setInverted(true); this.charts[6].getXYPlot().getRangeAxis().setInverted(true); this.charts[4].getXYPlot().getDomainAxis().setInverted(true); this.charts[4].getXYPlot().getRangeAxis().setInverted(true); this.charts[4].getXYPlot().setOrientation(PlotOrientation.HORIZONTAL); this.charts[5].getXYPlot().setOrientation(PlotOrientation.HORIZONTAL); this.charts[6].getXYPlot().setOrientation(PlotOrientation.HORIZONTAL); this.charts[7].getXYPlot().setOrientation(PlotOrientation.HORIZONTAL); panel.add(this.panels[0]); panel.add(this.panels[1]); panel.add(this.panels[4]); panel.add(this.panels[5]); panel.add(this.panels[2]); panel.add(this.panels[3]); panel.add(this.panels[6]); panel.add(this.panels[7]); panel.setPreferredSize(new Dimension(800, 600)); setContentPane(panel); }
From source file:uk.ac.ed.epcc.webapp.charts.jfreechart.JFreeTimeChartData.java
public void addWarningLevel(double value) { ((XYPlot) chart.getPlot()).addRangeMarker(new ValueMarker(value, Color.RED, new BasicStroke(2f))); }
From source file:com.controlj.addon.gwttree.server.OpaqueBarRenderer3D.java
/**<!====== drawItem ======================================================> Draws a 3D bar to represent one data item. <! Name Description> @param g2 the graphics device. @param state the renderer state. @param dataArea the area for plotting the data. @param plot the plot.//www . ja v a 2 s.com @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) { // check the value we are plotting... Number dataValue = dataset.getValue(row, column); if (dataValue == null) { return; } g2.setStroke(new BasicStroke(1)); double value = dataValue.doubleValue(); Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX(), dataArea.getY() + getYOffset(), dataArea.getWidth() - getXOffset(), dataArea.getHeight() - getYOffset()); PlotOrientation orientation = plot.getOrientation(); double barW0 = calculateBarW0(plot, orientation, adjusted, domainAxis, state, row, column); double[] barL0L1 = calculateBarL0L1(value); if (barL0L1 == null) { return; // the bar is not visible } RectangleEdge edge = plot.getRangeAxisEdge(); double transL0 = rangeAxis.valueToJava2D(barL0L1[0], adjusted, edge); double transL1 = rangeAxis.valueToJava2D(barL0L1[1], adjusted, edge); double barL0 = Math.min(transL0, transL1); double barLength = Math.abs(transL1 - transL0); // draw the bar... Rectangle2D bar = null; if (orientation == PlotOrientation.HORIZONTAL) { bar = new Rectangle2D.Double(barL0, barW0, barLength, state.getBarWidth()); } else { bar = new Rectangle2D.Double(barW0, barL0, state.getBarWidth(), barLength); } Paint itemPaint = getItemPaint(row, column); if (itemPaint instanceof Color) { Color endColor = getFrontDark((Color) itemPaint); Color startColor = (Color) itemPaint; Paint paint = new GradientPaint((float) bar.getX(), (float) bar.getY(), startColor, (float) (bar.getX()), (float) (bar.getY() + bar.getHeight()), endColor); g2.setPaint(paint); } g2.fill(bar); double x0 = bar.getMinX(); // left double x1 = x0 + getXOffset(); // offset left double x2 = bar.getMaxX(); // right double x3 = x2 + getXOffset(); // offset right double y0 = bar.getMinY() - getYOffset(); // offset top double y1 = bar.getMinY(); // bar top double y2 = bar.getMaxY() - getYOffset(); // offset bottom double y3 = bar.getMaxY(); // bottom //Rectangle2D.Double line = new Rectangle2D.Double(x2, y1, 2, bar.getHeight()); Line2D.Double line = new Line2D.Double(x2, y1, x2, y3); g2.draw(line); GeneralPath bar3dRight = null; GeneralPath bar3dTop = null; g2.setPaint(itemPaint); // Draw the right side if (barLength > 0.0) { bar3dRight = new GeneralPath(); bar3dRight.moveTo((float) x2, (float) y3); bar3dRight.lineTo((float) x2, (float) y1); bar3dRight.lineTo((float) x3, (float) y0); bar3dRight.lineTo((float) x3, (float) y2); bar3dRight.closePath(); if (itemPaint instanceof Color) { Color startColor = getSideLight((Color) itemPaint); Color endColor = getSideDark((Color) itemPaint); Paint paint = new GradientPaint((float) x3, (float) y0, startColor, (float) x2, (float) y3, endColor); g2.setPaint(paint); } g2.fill(bar3dRight); } // Draw the top bar3dTop = new GeneralPath(); bar3dTop.moveTo((float) x0, (float) y1); // bottom left bar3dTop.lineTo((float) x1, (float) y0); // top left bar3dTop.lineTo((float) x3, (float) y0); // top right bar3dTop.lineTo((float) x2, (float) y1); // bottom right bar3dTop.closePath(); if (itemPaint instanceof Color) { Color endColor = getTopDark((Color) itemPaint); Color startColor = getTopLight((Color) itemPaint); //Paint paint = new GradientPaint((float)x2, (float)y0, startColor, (float)x0, (float)(y1), endColor); Point2D.Double topRight = new Point2D.Double(x3, y0); Point2D.Double bottomLeft = new Point2D.Double(x0, y1); //Point2D.Double darkEnd = getTargetPoint(bottomLeft, topRight, ((y0-y1)/(x3-x2))); Point2D.Double darkEnd = new Point2D.Double(x1, y0 - (x3 - x1) * ((y0 - y1) / (x3 - x2))); Paint paint = new GradientPaint((float) topRight.getX(), (float) topRight.getY(), startColor, (float) darkEnd.getX(), (float) darkEnd.getY(), endColor); g2.setPaint(paint); //drawMarker(topRight, g2, startColor); } g2.fill(bar3dTop); g2.setPaint(itemPaint); if (isDrawBarOutline() && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) { g2.setStroke(getItemOutlineStroke(row, column)); g2.setPaint(getItemOutlinePaint(row, column)); g2.draw(bar); if (bar3dRight != null) { g2.draw(bar3dRight); } if (bar3dTop != null) { g2.draw(bar3dTop); } } CategoryItemLabelGenerator generator = getItemLabelGenerator(row, column); if (generator != null && isItemLabelVisible(row, column)) { drawItemLabel(g2, dataset, row, column, plot, generator, bar, (value < 0.0)); } // add an item entity, if this information is being collected EntityCollection entities = state.getEntityCollection(); if (entities != null) { GeneralPath barOutline = new GeneralPath(); barOutline.moveTo((float) x0, (float) y3); barOutline.lineTo((float) x0, (float) y1); barOutline.lineTo((float) x1, (float) y0); barOutline.lineTo((float) x3, (float) y0); barOutline.lineTo((float) x3, (float) y2); barOutline.lineTo((float) x2, (float) y3); barOutline.closePath(); addItemEntity(entities, dataset, row, column, barOutline); } }
From source file:es.unex.meigas.extFillData.FittingDataPanel.java
public FittingDataPanel(final LeastSquaresFit lsf, final Tree[] trees, final XYVariables xy) { super(Meigas.getMainFrame(), "Ajuste de datos", true); m_Lsf = lsf;//from www. ja v a 2s . co m m_Trees = trees; m_XY = xy; createChart(); initialize(); final Plot plot = this.jPanelChart.getChart().getPlot(); plot.setOutlineStroke(new BasicStroke(1)); plot.setOutlinePaint(Color.blue); }
From source file:CustomStrokes.java
public DoubleStroke(float width1, float width2) { stroke1 = new BasicStroke(width1); // Constructor arguments specify stroke2 = new BasicStroke(width2); // the line widths for the strokes }
From source file:com.tencent.wstt.apt.chart.AbstractRealTimeLineChart.java
/** * ??./*from w w w .jav a 2 s .c om*/ * * @return ??. */ public boolean initDataset(String[] objects, String[] datas) { if (objects == null || datas == null || objects.length == 0 || datas.length == 0) { return false; } objectNum = objects.length; dataNum = datas.length; dataset.removeAllSeries(); if (datas.length == 1) { for (int i = 0; i < objectNum; i++) { // ?? chart.getXYPlot().getRenderer().setSeriesStroke(i, new BasicStroke(Constant.LINE_WIDTH)); tsList.add(new TimeSeries(objects[i])); tsEnableList.add(true); dataset.addSeries(tsList.get(i)); } } else { for (int i = 0; i < objectNum; i++) { for (int j = 0; j < dataNum; j++) { int index = dataNum * i + j; //?? chart.getXYPlot().getRenderer().setSeriesStroke(index, new BasicStroke(Constant.LINE_WIDTH)); tsList.add(new TimeSeries(objects[i] + "_" + datas[j])); tsEnableList.add(true); dataset.addSeries(tsList.get(index)); } } } return true; }