Search in sources :

Example 1 with Second

use of org.jfree.data.time.Second in project zaproxy by zaproxy.

the class ScanProgressDialog method updateProgress.

/**
     * Updates the scan progress shown by the dialogue (scanners' progress/state and chart).
     */
private void updateProgress() {
    // Start panel data settings
    HostProcess hp = getSelectedHostProcess();
    if (scan.getHostProcesses() != null && hp != null) {
        // Update the main table entries
        model.updateValues(scan, hp);
        if (scan.isStopped()) {
            this.stopThread = true;
        }
        if (chart != null) {
            ResponseCountSnapshot snapshot = scan.getRequestHistory();
            while (snapshot != null) {
                try {
                    Second second = new Second(snapshot.getDate());
                    this.seriesTotal.add(second, snapshot.getTotal());
                    this.series100.add(second, snapshot.getResp100());
                    this.series200.add(second, snapshot.getResp200());
                    this.series300.add(second, snapshot.getResp300());
                    this.series400.add(second, snapshot.getResp400());
                    this.series500.add(second, snapshot.getResp500());
                    snapshot = scan.getRequestHistory();
                    for (Plugin plugin : scan.getHostProcesses().get(0).getRunning()) {
                        if (!labelsAdded.contains(plugin.getName())) {
                            // Add a vertical line with the plugin name
                            ValueMarker vm = new ValueMarker(plugin.getTimeStarted().getTime());
                            double center = chart.getXYPlot().getRangeAxis().getRange().getCentralValue();
                            if (lastCentre != center) {
                                if (lastCentre != -1) {
                                    // Move the existing labels so they stay in the centre
                                    @SuppressWarnings("rawtypes") List annotations = chart.getXYPlot().getAnnotations();
                                    for (Object o : annotations) {
                                        if (o instanceof XYTextAnnotation) {
                                            XYTextAnnotation annotation = (XYTextAnnotation) o;
                                            annotation.setY(center);
                                        }
                                    }
                                }
                                lastCentre = center;
                            }
                            XYTextAnnotation updateLabel = new XYTextAnnotation(plugin.getName(), plugin.getTimeStarted().getTime(), center);
                            updateLabel.setFont(FontUtils.getFont("Sans Serif"));
                            updateLabel.setRotationAnchor(TextAnchor.BASELINE_CENTER);
                            updateLabel.setTextAnchor(TextAnchor.BASELINE_CENTER);
                            updateLabel.setRotationAngle(-3.14 / 2);
                            updateLabel.setPaint(Color.black);
                            chart.getXYPlot().addDomainMarker(vm, Layer.BACKGROUND);
                            chart.getXYPlot().addAnnotation(updateLabel);
                            labelsAdded.add(plugin.getName());
                        }
                    }
                } catch (Exception e) {
                    log.error(e.getMessage(), e);
                    snapshot = null;
                }
            }
        }
    }
}
Also used : HostProcess(org.parosproxy.paros.core.scanner.HostProcess) XYTextAnnotation(org.jfree.chart.annotations.XYTextAnnotation) Second(org.jfree.data.time.Second) List(java.util.List) ArrayList(java.util.ArrayList) ValueMarker(org.jfree.chart.plot.ValueMarker) HeadlessException(java.awt.HeadlessException) Plugin(org.parosproxy.paros.core.scanner.Plugin)

Example 2 with Second

use of org.jfree.data.time.Second in project cubrid-manager by CUBRID.

the class CombinedBarTimeSeriesChart method createTableSeriesDataset.

/**
	 * Creates a table dataset for series
	 * 
	 * @return Series 2.
	 */
private XYDataset createTableSeriesDataset() {
    timeTableXYCollection = new TimeTableXYDataset();
    for (Map.Entry<String, String> entry : valueMap.entrySet()) {
        String key = entry.getKey();
        timeTableXYCollection.add(new Second(), 0, key);
    }
    return timeTableXYCollection;
}
Also used : TimeTableXYDataset(org.jfree.data.time.TimeTableXYDataset) Second(org.jfree.data.time.Second) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 3 with Second

use of org.jfree.data.time.Second in project cubrid-manager by CUBRID.

the class CombinedBarTimeSeriesChart method updateValueMapIfSeries.

/**
	 * Update the value based on the new value if series chart uses series
	 * renderer
	 * 
	 * @param valueMap the valueMap to set
	 * @param barLabel the label text in the bar chart
	 */
private void updateValueMapIfSeries(TreeMap<String, String> valueMap, String barLabel) {
    this.valueMap = valueMap;
    bardataset.clear();
    double allValue = 0;
    for (Map.Entry<String, String> entry : valueMap.entrySet()) {
        String value = entry.getValue();
        if (value != null) {
            double newValue = Double.parseDouble(value);
            bardataset.addValue(newValue, entry.getKey(), "");
            allValue += newValue;
        }
    }
    if (allValue > barMax) {
        barMax = allValue;
    }
    bardataset.addValue(barMax - allValue, "100", "");
    numberaxis.setRange(0 - 1, barMax + barMax / 100);
    String label = barLabel;
    if ("%".equals(label)) {
        label = Integer.toString((int) (allValue + 0.5)) + label;
    }
    categoryAxis.setLabel(label);
    for (Map.Entry<String, String> entry : valueMap.entrySet()) {
        String value = entry.getValue();
        if (value != null) {
            double newValue = Double.parseDouble(value);
            seriesMap.get(entry.getKey()).addOrUpdate(new Second(), newValue);
        }
    }
}
Also used : Second(org.jfree.data.time.Second) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 4 with Second

use of org.jfree.data.time.Second in project cubrid-manager by CUBRID.

the class CombinedBarTimeSeriesChart method stuffedChart.

/**
	 * This method provides data from local fill for History chart showing
	 * 
	 * @param file the instance of CounterFile, which includes data info
	 * @param types a array which includes one or more data type
	 * @param beginTime the begin time
	 * @param endTime the ending time
	 * @param maxType the type name representative of the proportion of the
	 *        given types.
	 */
private void stuffedChart(CounterFile file, List<String> types, long beginTime, long endTime, String maxType) {
    List<String> fileTypes = new ArrayList<String>();
    for (String type : types) {
        fileTypes.add(type);
    }
    if (maxType != null) {
        fileTypes.add(maxType);
    }
    long distance = endTime - beginTime;
    // in milliseconds
    int interval = file.getInterval() * 1000;
    long quotient = distance / interval;
    if (distance % interval != 0) {
        quotient++;
    }
    int factor = (int) (quotient / SWITCH_VALUE);
    if (quotient % SWITCH_VALUE != 0) {
        factor++;
    }
    Result[] results = new Result[(int) (quotient / factor + 1L)];
    int length = 0;
    for (long time = beginTime; time < endTime; time += (interval * factor)) {
        Result res;
        try {
            res = file.readData(time, fileTypes.toArray(new String[fileTypes.size()]));
            results[length] = res;
            for (String type : types) {
                if (isAreaRender) {
                    double result = results[length].getAvgAsDouble(type);
                    timeTableXYCollection.add(new Second(new Date(time)), result, type);
                } else {
                    double result = results[length].getAvgAsDouble(type);
                    seriesMap.get(type).addOrUpdate(new Second(new Date(time)), result);
                    if (maxType == null) {
                        if (barMax < result) {
                            barMax = result;
                            numberaxis.setRange(0 - 1, barMax + 1);
                            numberaxis.setVisible(isShowSeriesAxis);
                        }
                    } else {
                        double maxPercent = results[length].getAvgAsDouble(maxType);
                        double max = maxPercent <= 0 ? barMax : result / maxPercent * 10000;
                        if (barMax < max) {
                            barMax = max;
                            numberaxis.setRange(0 - 1, barMax + 1);
                            numberaxis.setVisible(isShowSeriesAxis);
                        }
                    }
                }
            }
        } catch (IOException ex) {
            LOGGER.error(ex.getMessage());
        }
        length++;
    }
}
Also used : Second(org.jfree.data.time.Second) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Paint(java.awt.Paint) GradientPaint(java.awt.GradientPaint) Date(java.util.Date) Result(com.cubrid.cubridmanager.ui.monitoring.editor.count.Result)

Example 5 with Second

use of org.jfree.data.time.Second in project cubrid-manager by CUBRID.

the class MonitorStatisticChart method buildInvalidData.

/**
	 * Build TimeSeries for StatisticData which has no data. After build, each
	 * TimeSeries accompany with the StatisticData will have the same time
	 * series with ordinary TimeSeries, but all the values will be -1.
	 *
	 * @param dataset
	 * @param timeType
	 * @param dataItemWithoutDataList
	 * @param current
	 * @param interalMillisecs
	 */
private void buildInvalidData(TimeSeriesCollection dataset, TimeType timeType, List<StatisticData> dataItemWithoutDataList, Date current, long interalMillisecs) {
    for (StatisticData statisticData : dataItemWithoutDataList) {
        TimeSeries series = null;
        if (isDetailView) {
            series = new TimeSeries(statisticData.getDescription(isMultiHost));
        } else {
            series = new TimeSeries(statisticData.getSimpleDescription(isMultiHost));
        }
        Date point = (Date) current.clone();
        long curMillisecs = current.getTime();
        for (int i = 0; i < dataSize; i++) {
            point.setTime(curMillisecs - (dataSize - i) * interalMillisecs);
            switch(timeType) {
                case DAILY:
                    series.add(new Second(point), -1);
                    break;
                case WEEKLY:
                    series.add(new Hour(point), -1);
                    break;
                case MONTHLY:
                    series.add(new Hour(point), -1);
                    break;
                case YEARLY:
                    series.add(new Day(point), -1);
                    break;
                default:
                    break;
            }
        }
        maxValueMap.put(statisticData, -1d);
        minValueMap.put(statisticData, -1d);
        dataset.addSeries(series);
    }
}
Also used : TimeSeries(org.jfree.data.time.TimeSeries) Second(org.jfree.data.time.Second) Hour(org.jfree.data.time.Hour) Day(org.jfree.data.time.Day) StatisticData(com.cubrid.cubridmanager.core.monstatistic.model.StatisticData) Date(java.util.Date)

Aggregations

Second (org.jfree.data.time.Second)9 Date (java.util.Date)5 ArrayList (java.util.ArrayList)4 Map (java.util.Map)3 TreeMap (java.util.TreeMap)3 StatisticData (com.cubrid.cubridmanager.core.monstatistic.model.StatisticData)2 Result (com.cubrid.cubridmanager.ui.monitoring.editor.count.Result)2 IOException (java.io.IOException)2 Day (org.jfree.data.time.Day)2 Hour (org.jfree.data.time.Hour)2 TimeSeries (org.jfree.data.time.TimeSeries)2 TimeTableXYDataset (org.jfree.data.time.TimeTableXYDataset)2 MetricType (com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.MetricType)1 TimeType (com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.TimeType)1 GradientPaint (java.awt.GradientPaint)1 HeadlessException (java.awt.HeadlessException)1 Paint (java.awt.Paint)1 DateFormat (java.text.DateFormat)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1