Refine search
if (!list.isEmpty()) { XYDataItem xy = list.get(list.size() - 1); list.add(new XYDataItem(xy.getX().longValue() + 1, 0)); list.add(new XYDataItem(System.currentTimeMillis(), 0));
protected boolean useLogarithmicProblemScale(List<XYSeries> seriesList) { NavigableSet<Double> xValueSet = new TreeSet<>(); int xValueListSize = 0; for (XYSeries series : seriesList) { for (XYDataItem dataItem : (List<XYDataItem>) series.getItems()) { xValueSet.add(dataItem.getXValue()); xValueListSize++; } } if (xValueListSize < LOG_SCALE_MIN_DATASETS_COUNT) { return false; } // If 60% of the points are in 20% of the value space, use a logarithmic scale double threshold = 0.2 * (xValueSet.last() - xValueSet.first()); int belowThresholdCount = xValueSet.headSet(threshold).size(); return belowThresholdCount >= (0.6 * xValueSet.size()); }
/** * To series. * * @param legend the legend * @param stats the stats * @return the XY series */ protected XYSeries toSeries(String legend, List<XYDataItem> stats) { XYSeries xySeries = new XYSeries(legend, true, false); synchronized (stats) { for (XYDataItem item : stats) { xySeries.addOrUpdate(item.getX(), item.getY()); } } return xySeries; }
private void retrieveActivities(VehicleRoutingProblem vrp) throws NoLocationFoundException { activities = new XYSeries("activities", false, true); for (Vehicle v : vrp.getVehicles()) { Coordinate start_coordinate = getCoordinate(v.getStartLocation().getCoordinate()); if (start_coordinate == null) throw new NoLocationFoundException(); XYDataItem item = new XYDataItem(start_coordinate.getX() * scalingFactor, start_coordinate.getY() * scalingFactor); markItem(item, Activity.START); activities.add(item); if (!v.getStartLocation().getId().equals(v.getEndLocation().getId())) { Coordinate end_coordinate = getCoordinate(v.getEndLocation().getCoordinate()); if (end_coordinate == null) throw new NoLocationFoundException(); XYDataItem end_item = new XYDataItem(end_coordinate.getX() * scalingFactor, end_coordinate.getY() * scalingFactor); markItem(end_item, Activity.END); activities.add(end_item); } } for (Job job : vrp.getJobs().values()) { addJob(activities, job); } for (VehicleRoute r : vrp.getInitialVehicleRoutes()) { for (Job job : r.getTourActivities().getJobs()) { addJob(activities, job); } } }
Args.nullNotPermitted(item, "item"); if (this.allowDuplicateXValues) { add(item); return null; int index = indexOf(item.getX()); if (index >= 0) { XYDataItem existing = (XYDataItem) this.data.get(index); overwritten = (XYDataItem) existing.clone(); double oldY = existing.getYValue(); if (!Double.isNaN(oldY)) { iterate = oldY <= this.minY || oldY >= this.maxY; existing.setY(item.getY()); findBoundsByIteration(); else if (item.getY() != null) { double yy = item.getY().doubleValue(); this.minY = minIgnoreNaN(this.minY, yy); this.maxY = maxIgnoreNaN(this.maxY, yy); item = (XYDataItem) item.clone(); if (this.autoSort) { this.data.add(-index - 1, item);
Shipment s = (Shipment) job; Coordinate pickupCoordinate = getCoordinate(s.getPickupLocation().getCoordinate()); XYDataItem dataItem = new XYDataItem(pickupCoordinate.getX() * scalingFactor, pickupCoordinate.getY() * scalingFactor); activities.add(dataItem); addLabel(s, dataItem); markItem(dataItem, Activity.PICKUP); XYDataItem dataItem2 = new XYDataItem(deliveryCoordinate.getX() * scalingFactor, deliveryCoordinate.getY() * scalingFactor); activities.add(dataItem2); addLabel(s, dataItem2); markItem(dataItem2, Activity.DELIVERY); Pickup service = (Pickup) job; Coordinate coord = getCoordinate(service.getLocation().getCoordinate()); XYDataItem dataItem = new XYDataItem(coord.getX() * scalingFactor, coord.getY() * scalingFactor); activities.add(dataItem); addLabel(service, dataItem); markItem(dataItem, Activity.PICKUP); Delivery service = (Delivery) job; Coordinate coord = getCoordinate(service.getLocation().getCoordinate()); XYDataItem dataItem = new XYDataItem(coord.getX() * scalingFactor, coord.getY() * scalingFactor); activities.add(dataItem); addLabel(service, dataItem); Service service = (Service) job; Coordinate coord = getCoordinate(service.getLocation().getCoordinate()); XYDataItem dataItem = new XYDataItem(coord.getX() * scalingFactor, coord.getY() * scalingFactor); activities.add(dataItem);
private static final String title = "Scatter Move Demo"; private static final Random rand = new Random(); private XYSeries moved = new XYSeries("Population"); @Override public void actionPerformed(ActionEvent e) { moved.clear(); update(); moved.add(new XYDataItem(rand.nextGaussian(), rand.nextGaussian()));
/** * Creates a new series by copying a subset of the data in this time series. * * @param start the index of the first item to copy. * @param end the index of the last item to copy. * * @return A series containing a copy of this series from start until end. * * @throws CloneNotSupportedException if there is a cloning problem. */ public XYSeries createCopy(int start, int end) throws CloneNotSupportedException { XYSeries copy = (XYSeries) super.clone(); copy.data = new java.util.ArrayList(); if (this.data.size() > 0) { for (int index = start; index <= end; index++) { XYDataItem item = (XYDataItem) this.data.get(index); XYDataItem clone = (XYDataItem) item.clone(); try { copy.add(clone); } catch (SeriesException e) { throw new RuntimeException( "Unable to add cloned data item.", e); } } } return copy; }
_dataSeries[i].add(counter, stats[i]); int cindex = _dataSeries[0].indexOf(counter); int slices = periodSelectSlider.getValue(); int lb = cindex < slices ? 0 : cindex - slices; Number n1 = ts.getDataItem(cindex).getY(); Number n2 = ts.getDataItem(lb).getY();
boolean itemContributesToXBounds = false; boolean itemContributesToYBounds = false; double x = item.getXValue(); if (!Double.isNaN(x)) { if (x <= this.minX || x >= this.maxX) { if (item.getY() != null) { double y = item.getYValue(); if (!Double.isNaN(y)) { if (y <= this.minY || y >= this.maxY) { findBoundsByIteration(); if (getAutoSort()) { this.minX = getX(0).doubleValue(); this.maxX = getX(getItemCount() - 1).doubleValue();
private XYIntervalSeries computeAcceptableDeviationData(double lowerBound, double upperBound) { final XYSeries identity = DatasetUtilities.sampleFunction2DToSeries(x -> x, lowerBound, upperBound, 100, "1:1 line"); final XYIntervalSeries xyIntervalSeries = new XYIntervalSeries(identity.getKey()); for (int i = 0; i < identity.getItemCount(); i++) { XYDataItem item = identity.getDataItem(i); final double x = item.getXValue(); final double y = item.getYValue(); if (scatterPlotModel.showAcceptableDeviation) { final double acceptableDeviation = scatterPlotModel.acceptableDeviationInterval; final double xOff = acceptableDeviation * x / 100; final double yOff = acceptableDeviation * y / 100; xyIntervalSeries.add(x, x - xOff, x + xOff, y, y - yOff, y + yOff); } else { xyIntervalSeries.add(x, x, x, y, y, y); } } return xyIntervalSeries; }
throw new IllegalArgumentException("Null 'item' argument."); item = (XYDataItem) item.clone(); if (this.autoSort) { int index = Collections.binarySearch(this.data, item); while (index < size && item.compareTo( this.data.get(index)) == 0) { index++; int index = indexOf(item.getX()); if (index >= 0) { throw new SeriesException("X-value already exists."); updateBoundsForAddedItem(item); if (getItemCount() > this.maximumItemCount) { XYDataItem removed = (XYDataItem) this.data.remove(0); updateBoundsForRemovedItem(removed);
private XYIntervalSeries computeAcceptableDeviationData(double lowerBound, double upperBound) { final Function2D identityFunction = new Function2D() { @Override public double getValue(double x) { return x; } }; final XYSeries identity = DatasetUtilities.sampleFunction2DToSeries(identityFunction, lowerBound, upperBound, 100, "1:1 line"); final XYIntervalSeries xyIntervalSeries = new XYIntervalSeries(identity.getKey()); final List<XYDataItem> items = identity.getItems(); for (XYDataItem item : items) { final double x = item.getXValue(); final double y = item.getYValue(); if (scatterPlotModel.showAcceptableDeviation) { final double acceptableDeviation = scatterPlotModel.acceptableDeviationInterval; final double xOff = acceptableDeviation * x / 100; final double yOff = acceptableDeviation * y / 100; xyIntervalSeries.add(x, x - xOff, x + xOff, y, y - yOff, y + yOff); } else { xyIntervalSeries.add(x, x, x, y, y, y); } } return xyIntervalSeries; }
List<String> time = new ArrayList<String>();//{name, v1, v2, v3} XYSeries s = ((XYSeriesCollection) chart.getXYPlot().getDataset()).getSeries(i); max = Math.max(max, s.getItemCount()); time.add("TIME,"); for (Object o : s.getItems()) { XYDataItem item = (XYDataItem) o; time.add(item.getX() + ","); max = Math.max(max, s.getItemCount()); values.add(s.getKey().toString() + ","); for (Object o : s.getItems()) { XYDataItem item = (XYDataItem) o; values.add(item.getY() + ",");
/** * Updates the cached values for the minimum and maximum data values. * * @param item the item added ({@code null} not permitted). * * @since 1.0.13 */ private void updateBoundsForAddedItem(XYDataItem item) { double x = item.getXValue(); this.minX = minIgnoreNaN(this.minX, x); this.maxX = maxIgnoreNaN(this.maxX, x); if (item.getY() != null) { double y = item.getYValue(); this.minY = minIgnoreNaN(this.minY, y); this.maxY = maxIgnoreNaN(this.maxY, y); } }
/** * Updates the value of an item in the series and sends a * {@link SeriesChangeEvent} to all registered listeners. * * @param index the item (zero based index). * @param y the new value ({@code null} permitted). * * @since 1.0.1 */ public void updateByIndex(int index, Number y) { XYDataItem item = getRawDataItem(index); // figure out if we need to iterate through all the y-values boolean iterate = false; double oldY = item.getYValue(); if (!Double.isNaN(oldY)) { iterate = oldY <= this.minY || oldY >= this.maxY; } item.setY(y); if (iterate) { findBoundsByIteration(); } else if (y != null) { double yy = y.doubleValue(); this.minY = minIgnoreNaN(this.minY, yy); this.maxY = maxIgnoreNaN(this.maxY, yy); } fireSeriesChanged(); }
public void showAnnotations() { XYItemRenderer renderer = getChart().getXYPlot().getRenderer(); renderer.removeAnnotations(); for (int i = 0; i < eccSeries.getItemCount(); i++) { XYDataItem item = (XYDataItem) eccSeries.getDataItem(i); XYTextAnnotation annon = new XYTextAnnotation(new Integer(i).toString(), item.getX().longValue(), item .getY().longValue()); renderer.addAnnotation(annon); } }
for (int series = 0; series < data.getSeriesCount(); series++) { XYSeries dataset = data.getSeries(series); minLength = minLength > dataset.getItemCount() ? dataset.getItemCount() : minLength; XYSeries dataset = data.getSeries(series); for (int i = 0; i < minLength; i++) { s.append(dataset.getDataItem(i).getYValue() + ","); XYSeries dataset = data.getSeries(series); for (int i = 0; i < dataset.getItemCount(); i++) { s.append(dataset.getDataItem(i).getYValue() + ",");
/** * Returns a hash code. * * @return A hash code. */ @Override public int hashCode() { int result = super.hashCode(); // it is too slow to look at every data item, so let's just look at // the first, middle and last items... int count = getItemCount(); if (count > 0) { XYDataItem item = getRawDataItem(0); result = 29 * result + item.hashCode(); } if (count > 1) { XYDataItem item = getRawDataItem(count - 1); result = 29 * result + item.hashCode(); } if (count > 2) { XYDataItem item = getRawDataItem(count / 2); result = 29 * result + item.hashCode(); } result = 29 * result + this.maximumItemCount; result = 29 * result + (this.autoSort ? 1 : 0); result = 29 * result + (this.allowDuplicateXValues ? 1 : 0); return result; }