Search in sources :

Example 16 with BasicStroke

use of java.awt.BasicStroke in project felix by apache.

the class Square method draw.

/**
 * Implements the <tt>SimpleShape.draw()</tt> method for painting
 * the shape.
 * @param g2 The graphics object used for painting.
 * @param p The position to paint the triangle.
 */
public void draw(Graphics2D g2, Point p) {
    int x = p.x - 25;
    int y = p.y - 25;
    GradientPaint gradient = new GradientPaint(x, y, Color.BLUE, x + 50, y, Color.WHITE);
    g2.setPaint(gradient);
    g2.fill(new Rectangle2D.Double(x, y, 50, 50));
    BasicStroke wideStroke = new BasicStroke(2.0f);
    g2.setColor(Color.black);
    g2.setStroke(wideStroke);
    g2.draw(new Rectangle2D.Double(x, y, 50, 50));
}
Also used : BasicStroke(java.awt.BasicStroke) Rectangle2D(java.awt.geom.Rectangle2D) GradientPaint(java.awt.GradientPaint) GradientPaint(java.awt.GradientPaint) Point(java.awt.Point)

Example 17 with BasicStroke

use of java.awt.BasicStroke in project cubrid-manager by CUBRID.

the class ChartCompositePart method updateChart.

/**
	 * Update the plot in chart from scratch.
	 *
	 */
public void updateChart() {
    XYPlot plot = (XYPlot) (getChart().getPlot());
    TimeSeriesCollection timeseriescollection = (TimeSeriesCollection) (plot.getDataset());
    timeseriescollection.removeAllSeries();
    XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) plot.getRenderer();
    seriesMap.clear();
    int number = 0;
    for (Map.Entry<String, String> entry : valueMap.entrySet()) {
        String key = entry.getKey();
        TimeSeries series = new TimeSeries(key);
        seriesMap.put(key, series);
        if (settingMap.get(key).isChecked()) {
            timeseriescollection.addSeries(series);
            RGB seriesRgb = settingMap.get(key).getSeriesRgb();
            float width = settingMap.get(key).getWidth();
            Color color = new Color(seriesRgb.red, seriesRgb.green, seriesRgb.blue);
            xylineandshaperenderer.setSeriesPaint(number, color);
            xylineandshaperenderer.setSeriesStroke(number, new BasicStroke(width, 0, 2));
            number++;
        }
    }
}
Also used : BasicStroke(java.awt.BasicStroke) TimeSeries(org.jfree.data.time.TimeSeries) XYPlot(org.jfree.chart.plot.XYPlot) TimeSeriesCollection(org.jfree.data.time.TimeSeriesCollection) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer) Color(java.awt.Color) CommonUITool.trimPaintColor(com.cubrid.common.ui.spi.util.CommonUITool.trimPaintColor) RGB(org.eclipse.swt.graphics.RGB) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 18 with BasicStroke

use of java.awt.BasicStroke in project cubrid-manager by CUBRID.

the class StatusMonitorViewPart method createChart.

/**
	 * Creates chart unit
	 * 
	 * @param unitNumber the number of unit
	 * @return JFreeChart
	 */
private JFreeChart createChart(int unitNumber) {
    String currentLbl = "Current";
    current[unitNumber] = new TimeSeries(currentLbl);
    current[unitNumber].setMaximumItemAge(18000000);
    String minLbl = "Min";
    minimum[unitNumber] = new TimeSeries(minLbl);
    minimum[unitNumber].setMaximumItemAge(18000000);
    String maxLbl = "Max";
    maximum[unitNumber] = new TimeSeries(maxLbl);
    maximum[unitNumber].setMaximumItemAge(18000000);
    String avgLbl = "Avg";
    average[unitNumber] = new TimeSeries(avgLbl);
    average[unitNumber].setMaximumItemAge(18000000);
    TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
    timeseriescollection.addSeries(current[unitNumber]);
    timeseriescollection.addSeries(minimum[unitNumber]);
    timeseriescollection.addSeries(maximum[unitNumber]);
    timeseriescollection.addSeries(average[unitNumber]);
    DateAxis dateaxis = new DateAxis("");
    NumberAxis numberaxis = new NumberAxis("");
    dateaxis.setTickLabelFont(new Font("SansSerif", 0, 10));
    dateaxis.setLabelFont(new Font("SansSerif", 0, 7));
    XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(true, false);
    xylineandshaperenderer.setSeriesPaint(0, new Color(146, 208, 80));
    xylineandshaperenderer.setSeriesPaint(1, new Color(166, 166, 166));
    xylineandshaperenderer.setSeriesPaint(2, new Color(74, 126, 187));
    xylineandshaperenderer.setSeriesPaint(3, new Color(255, 51, 0));
    xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(2F, 0, 2));
    xylineandshaperenderer.setSeriesStroke(3, new BasicStroke(2F, 0, 2));
    XYPlot xyplot = new XYPlot(timeseriescollection, dateaxis, numberaxis, xylineandshaperenderer);
    xyplot.setBackgroundPaint(Color.BLACK);
    xyplot.setDomainGridlinePaint(new Color(130, 130, 130));
    xyplot.setRangeGridlinePaint(new Color(130, 130, 130));
    dateaxis.setFixedAutoRange(300000d);
    dateaxis.setLowerMargin(0.0D);
    dateaxis.setUpperMargin(0.0D);
    dateaxis.setTickLabelsVisible(true);
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    JFreeChart chart = new JFreeChart(monitorList.get(unitNumber).getChartTitle(), new Font("SansSerif", 1, 15), xyplot, false);
    return chart;
}
Also used : BasicStroke(java.awt.BasicStroke) DateAxis(org.jfree.chart.axis.DateAxis) TimeSeries(org.jfree.data.time.TimeSeries) NumberAxis(org.jfree.chart.axis.NumberAxis) XYPlot(org.jfree.chart.plot.XYPlot) TimeSeriesCollection(org.jfree.data.time.TimeSeriesCollection) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer) Color(java.awt.Color) Font(java.awt.Font) JFreeChart(org.jfree.chart.JFreeChart)

Example 19 with BasicStroke

use of java.awt.BasicStroke in project cubrid-manager by CUBRID.

the class CombinedBarTimeSeriesChart method createSeriesChart.

/**
	 * Create the series chart
	 * 
	 * @return an instance of series chart
	 */
private JFreeChart createSeriesChart() {
    if (isAreaRender) {
        seriesdataset = createTableSeriesDataset();
    } else {
        seriesdataset = createTimeSeriesDataset();
    }
    JFreeChart chart = ChartFactory.createTimeSeriesChart("", "", "", seriesdataset, false, false, false);
    chart.setBorderVisible(false);
    chart.setBorderStroke(new BasicStroke(0.0f));
    //plot
    XYPlot xyplot = (XYPlot) chart.getPlot();
    xyplot.setOutlineVisible(false);
    RectangleInsets rectangleInsets = new RectangleInsets();
    xyplot.setAxisOffset(rectangleInsets);
    xyplot.setDomainGridlineStroke(new BasicStroke(0.4f));
    xyplot.setRangeGridlineStroke(new BasicStroke(0.4f));
    xyplot.setBackgroundPaint(Color.BLACK);
    xyplot.setDomainGridlinePaint(new Color(0, 128, 64));
    xyplot.setRangeGridlinePaint(new Color(0, 128, 64));
    if (isAreaRender) {
        XYAreaRenderer2 render = new StackedXYAreaRenderer2();
        render.setSeriesPaint(0, Color.GREEN);
        render.setSeriesPaint(1, Color.RED);
        xyplot.setRenderer(render);
    } else {
        XYLineAndShapeRenderer render = (XYLineAndShapeRenderer) xyplot.getRenderer();
        render.setSeriesPaint(0, Color.GREEN);
        render.setSeriesPaint(1, Color.RED);
    }
    //dateAxis
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setFixedAutoRange(300000d);
    dateaxis.setLowerMargin(0.0D);
    dateaxis.setUpperMargin(0.0D);
    dateaxis.setVisible(isShowSeriesAxis);
    numberaxis = (NumberAxis) xyplot.getRangeAxis();
    numberaxis.setVisible(isShowSeriesAxis);
    numberaxis.setRange(0 - 0.5, barMax + 0.5);
    return chart;
}
Also used : BasicStroke(java.awt.BasicStroke) StackedXYAreaRenderer2(org.jfree.chart.renderer.xy.StackedXYAreaRenderer2) DateAxis(org.jfree.chart.axis.DateAxis) XYPlot(org.jfree.chart.plot.XYPlot) Color(java.awt.Color) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer) RectangleInsets(org.jfree.ui.RectangleInsets) JFreeChart(org.jfree.chart.JFreeChart) XYAreaRenderer2(org.jfree.chart.renderer.xy.XYAreaRenderer2) StackedXYAreaRenderer2(org.jfree.chart.renderer.xy.StackedXYAreaRenderer2)

Example 20 with BasicStroke

use of java.awt.BasicStroke in project cubrid-manager by CUBRID.

the class ChartCompositePart method updateSettingChart.

/**
	 * Update setting chart
	 *
	 * @param item the selected item
	 * @param checked whether show in the table
	 * @param seriesRgb the background color of the selected item
	 * @param width the width of the selected item
	 */
@SuppressWarnings("unchecked")
private void updateSettingChart(String item, boolean checked, RGB seriesRgb, float width) {
    Color color = new Color(seriesRgb.red, seriesRgb.green, seriesRgb.blue);
    if (checked) {
        if (timeseriescollection.getSeries(item) == null) {
            timeseriescollection.addSeries(seriesMap.get(item));
        }
        List<TimeSeries> list = timeseriescollection.getSeries();
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i).getKey().equals(item)) {
                xylineandshaperenderer.setSeriesPaint(i, color);
                xylineandshaperenderer.setSeriesStroke(i, new BasicStroke(width, 0, 2));
                break;
            }
        }
    } else {
        if (timeseriescollection.getSeries(item) != null) {
            timeseriescollection.removeSeries(seriesMap.get(item));
        }
    }
}
Also used : BasicStroke(java.awt.BasicStroke) TimeSeries(org.jfree.data.time.TimeSeries) Color(java.awt.Color) CommonUITool.trimPaintColor(com.cubrid.common.ui.spi.util.CommonUITool.trimPaintColor)

Aggregations

BasicStroke (java.awt.BasicStroke)563 Graphics2D (java.awt.Graphics2D)179 Color (java.awt.Color)160 Stroke (java.awt.Stroke)137 GradientPaint (java.awt.GradientPaint)95 Test (org.junit.Test)93 Rectangle2D (java.awt.geom.Rectangle2D)67 Paint (java.awt.Paint)64 Font (java.awt.Font)61 Line2D (java.awt.geom.Line2D)46 Point (java.awt.Point)45 BufferedImage (java.awt.image.BufferedImage)43 Shape (java.awt.Shape)38 Point2D (java.awt.geom.Point2D)38 JFreeChart (org.jfree.chart.JFreeChart)34 AffineTransform (java.awt.geom.AffineTransform)33 Rectangle (java.awt.Rectangle)27 RectangleInsets (org.jfree.ui.RectangleInsets)27 Ellipse2D (java.awt.geom.Ellipse2D)25 NumberAxis (org.jfree.chart.axis.NumberAxis)25