List of usage examples for org.jfree.data DomainOrder ASCENDING
DomainOrder ASCENDING
To view the source code for org.jfree.data DomainOrder ASCENDING.
Click Source Link
From source file:org.jfree.data.DomainOrderTest.java
/** * Some checks for the equals() method.//from w ww . ja va 2 s. c om */ @Test public void testEquals() { assertEquals(DomainOrder.NONE, DomainOrder.NONE); assertEquals(DomainOrder.ASCENDING, DomainOrder.ASCENDING); assertEquals(DomainOrder.DESCENDING, DomainOrder.DESCENDING); assertFalse(DomainOrder.NONE.equals(DomainOrder.ASCENDING)); assertFalse(DomainOrder.NONE.equals(DomainOrder.DESCENDING)); assertFalse(DomainOrder.NONE.equals(null)); assertFalse(DomainOrder.ASCENDING.equals(DomainOrder.NONE)); assertFalse(DomainOrder.ASCENDING.equals(DomainOrder.DESCENDING)); assertFalse(DomainOrder.ASCENDING.equals(null)); assertFalse(DomainOrder.DESCENDING.equals(DomainOrder.NONE)); assertFalse(DomainOrder.DESCENDING.equals(DomainOrder.ASCENDING)); assertFalse(DomainOrder.DESCENDING.equals(null)); }
From source file:org.jfree.data.DomainOrderTest.java
/** * Two objects that are equal are required to return the same hashCode. */// www . j a va 2s. c o m @Test public void testHashCode() { DomainOrder d1 = DomainOrder.ASCENDING; DomainOrder d2 = DomainOrder.ASCENDING; assertTrue(d1.equals(d2)); int h1 = d1.hashCode(); int h2 = d2.hashCode(); assertEquals(h1, h2); }
From source file:org.jfree.data.DomainOrderTest.java
/** * Serialize an instance, restore it, and check for equality. *///from www . j ava 2 s . c o m @Test public void testSerialization() { DomainOrder d1 = DomainOrder.ASCENDING; DomainOrder d2 = (DomainOrder) TestUtilities.serialised(d1); assertSame(d1, d2); }
From source file:org.spf4j.perf.impl.chart.QuantizedXYZDatasetImpl.java
@Override public DomainOrder getDomainOrder() { return DomainOrder.ASCENDING; }
From source file:org.jfree.chart.demo.XYBlockChartDemo1.java
private static XYZDataset createDataset() { return new XYZDataset() { public int getSeriesCount() { return 1; }//from ww w. j av a 2 s .c om public int getItemCount(int i) { return 10000; } public Number getX(int i, int j) { return new Double(getXValue(i, j)); } public double getXValue(int i, int j) { return (double) (j / 100 - 50); } public Number getY(int i, int j) { return new Double(getYValue(i, j)); } public double getYValue(int i, int j) { return (double) (j - (j / 100) * 100 - 50); } public Number getZ(int i, int j) { return new Double(getZValue(i, j)); } public double getZValue(int i, int j) { double d = getXValue(i, j); double d1 = getYValue(i, j); return Math.sin(Math.sqrt(d * d + d1 * d1) / 5D); } public void addChangeListener(DatasetChangeListener datasetchangelistener) { } public void removeChangeListener(DatasetChangeListener datasetchangelistener) { } public DatasetGroup getGroup() { return null; } public void setGroup(DatasetGroup datasetgroup) { } @SuppressWarnings("rawtypes") public Comparable getSeriesKey(int i) { return "sin(sqrt(x + y))"; } @SuppressWarnings("rawtypes") public int indexOf(Comparable comparable) { return 0; } public DomainOrder getDomainOrder() { return DomainOrder.ASCENDING; } }; }
From source file:org.jfree.data.xy.XYSeriesCollection.java
/** * Returns the order of the domain (X) values, if this is known. * * @return The domain order./*from w w w . ja v a 2 s . com*/ */ @Override public DomainOrder getDomainOrder() { int seriesCount = getSeriesCount(); for (int i = 0; i < seriesCount; i++) { XYSeries s = getSeries(i); if (!s.getAutoSort()) { return DomainOrder.NONE; // we can't be sure of the order } } return DomainOrder.ASCENDING; }
From source file:edu.dlnu.liuwenpeng.Time.TimeSeriesCollection.java
/** * Returns the order of the domain values in this dataset. * /*from w w w .j a v a2 s. c om*/ * @return {@link DomainOrder#ASCENDING} */ public DomainOrder getDomainOrder() { return DomainOrder.ASCENDING; }
From source file:org.cds06.speleograph.data.Series.java
/** * Returns the order of the domain (or X) values returned by the dataset. * * @return The order (never <code>null</code>). *//*from ww w.ja va2s . co m*/ @Override public DomainOrder getDomainOrder() { return DomainOrder.ASCENDING; }
From source file:org.jfree.data.general.DatasetUtils.java
/** * Finds the indices of the the items in the dataset that span the * specified x-value. There are three cases for the return value: * <ul>//from w ww . ja va2s .c om * <li>there is an exact match for the x-value at index i * (returns {@code int[] {i, i}});</li> * <li>the x-value falls between two (adjacent) items at index i and i+1 * (returns {@code int[] {i, i+1}});</li> * <li>the x-value falls outside the domain bounds, in which case the * method returns {@code int[] {-1, -1}}.</li> * </ul> * @param dataset the dataset ({@code null} not permitted). * @param series the series index. * @param x the x-value. * * @return The indices of the two items that span the x-value. * * @since 1.0.16 * * @see #findYValue(org.jfree.data.xy.XYDataset, int, double) */ public static int[] findItemIndicesForX(XYDataset dataset, int series, double x) { Args.nullNotPermitted(dataset, "dataset"); int itemCount = dataset.getItemCount(series); if (itemCount == 0) { return new int[] { -1, -1 }; } if (itemCount == 1) { if (x == dataset.getXValue(series, 0)) { return new int[] { 0, 0 }; } else { return new int[] { -1, -1 }; } } if (dataset.getDomainOrder() == DomainOrder.ASCENDING) { int low = 0; int high = itemCount - 1; double lowValue = dataset.getXValue(series, low); if (lowValue > x) { return new int[] { -1, -1 }; } if (lowValue == x) { return new int[] { low, low }; } double highValue = dataset.getXValue(series, high); if (highValue < x) { return new int[] { -1, -1 }; } if (highValue == x) { return new int[] { high, high }; } int mid = (low + high) / 2; while (high - low > 1) { double midV = dataset.getXValue(series, mid); if (x == midV) { return new int[] { mid, mid }; } if (midV < x) { low = mid; } else { high = mid; } mid = (low + high) / 2; } return new int[] { low, high }; } else if (dataset.getDomainOrder() == DomainOrder.DESCENDING) { int high = 0; int low = itemCount - 1; double lowValue = dataset.getXValue(series, low); if (lowValue > x) { return new int[] { -1, -1 }; } double highValue = dataset.getXValue(series, high); if (highValue < x) { return new int[] { -1, -1 }; } int mid = (low + high) / 2; while (high - low > 1) { double midV = dataset.getXValue(series, mid); if (x == midV) { return new int[] { mid, mid }; } if (midV < x) { low = mid; } else { high = mid; } mid = (low + high) / 2; } return new int[] { low, high }; } else { // we don't know anything about the ordering of the x-values, // so we iterate until we find the first crossing of x (if any) // we know there are at least 2 items in the series at this point double prev = dataset.getXValue(series, 0); if (x == prev) { return new int[] { 0, 0 }; // exact match on first item } for (int i = 1; i < itemCount; i++) { double next = dataset.getXValue(series, i); if (x == next) { return new int[] { i, i }; // exact match } if ((x > prev && x < next) || (x < prev && x > next)) { return new int[] { i - 1, i }; // spanning match } } return new int[] { -1, -1 }; // no crossing of x } }
From source file:org.jfree.data.general.DatasetUtilities.java
/** * Finds the indices of the the items in the dataset that span the * specified x-value. There are three cases for the return value: * <ul>/* www . jav a2 s .c om*/ * <li>there is an exact match for the x-value at index i * (returns <code>int[] {i, i}</code>);</li> * <li>the x-value falls between two (adjacent) items at index i and i+1 * (returns <code>int[] {i, i+1}</code>);</li> * <li>the x-value falls outside the domain bounds, in which case the * method returns <code>int[] {-1, -1}</code>.</li> * </ul> * @param dataset the dataset (<code>null</code> not permitted). * @param series the series index. * @param x the x-value. * * @return The indices of the two items that span the x-value. * * @since 1.0.16 * * @see #findYValue(org.jfree.data.xy.XYDataset, int, double) */ public static int[] findItemIndicesForX(XYDataset dataset, int series, double x) { ParamChecks.nullNotPermitted(dataset, "dataset"); int itemCount = dataset.getItemCount(series); if (itemCount == 0) { return new int[] { -1, -1 }; } if (itemCount == 1) { if (x == dataset.getXValue(series, 0)) { return new int[] { 0, 0 }; } else { return new int[] { -1, -1 }; } } if (dataset.getDomainOrder() == DomainOrder.ASCENDING) { int low = 0; int high = itemCount - 1; double lowValue = dataset.getXValue(series, low); if (lowValue > x) { return new int[] { -1, -1 }; } if (lowValue == x) { return new int[] { low, low }; } double highValue = dataset.getXValue(series, high); if (highValue < x) { return new int[] { -1, -1 }; } if (highValue == x) { return new int[] { high, high }; } int mid = (low + high) / 2; while (high - low > 1) { double midV = dataset.getXValue(series, mid); if (x == midV) { return new int[] { mid, mid }; } if (midV < x) { low = mid; } else { high = mid; } mid = (low + high) / 2; } return new int[] { low, high }; } else if (dataset.getDomainOrder() == DomainOrder.DESCENDING) { int high = 0; int low = itemCount - 1; double lowValue = dataset.getXValue(series, low); if (lowValue > x) { return new int[] { -1, -1 }; } double highValue = dataset.getXValue(series, high); if (highValue < x) { return new int[] { -1, -1 }; } int mid = (low + high) / 2; while (high - low > 1) { double midV = dataset.getXValue(series, mid); if (x == midV) { return new int[] { mid, mid }; } if (midV < x) { low = mid; } else { high = mid; } mid = (low + high) / 2; } return new int[] { low, high }; } else { // we don't know anything about the ordering of the x-values, // so we iterate until we find the first crossing of x (if any) // we know there are at least 2 items in the series at this point double prev = dataset.getXValue(series, 0); if (x == prev) { return new int[] { 0, 0 }; // exact match on first item } for (int i = 1; i < itemCount; i++) { double next = dataset.getXValue(series, i); if (x == next) { return new int[] { i, i }; // exact match } if ((x > prev && x < next) || (x < prev && x > next)) { return new int[] { i - 1, i }; // spanning match } } return new int[] { -1, -1 }; // no crossing of x } }