?? fastscatterplot.java
字號:
drawOutline(g2, dataArea);
}
/**
* Draws a representation of the data within the dataArea region.
* <P>
* The <code>info</code> and <code>crosshairInfo</code> arguments may be <code>null</code>.
*
* @param g2 the graphics device.
* @param dataArea the region in which the data is to be drawn.
* @param info an optional object for collection dimension information.
* @param crosshairInfo an optional object for collecting crosshair info.
*/
public void render(Graphics2D g2, Rectangle2D dataArea,
ChartRenderingInfo info, CrosshairInfo crosshairInfo) {
g2.setPaint(Color.red);
if (this.data != null) {
for (int i = 0; i < data[0].length; i++) {
float x = data[0][i];
float y = data[1][i];
int transX = (int) this.domainAxis.translateValueToJava2D(x, dataArea,
RectangleEdge.BOTTOM);
int transY = (int) this.rangeAxis.translateValueToJava2D(y, dataArea,
RectangleEdge.LEFT);
g2.fillRect(transX, transY, 1, 1);
}
}
}
/**
* Returns the range of data values to be plotted along the axis.
*
* @param axis the axis.
*
* @return the range.
*/
public Range getDataRange(ValueAxis axis) {
Range result = null;
if (axis == this.domainAxis) {
result = this.xDataRange;
}
else if (axis == this.rangeAxis) {
result = this.yDataRange;
}
return result;
}
/**
* Calculates the X data range.
*
* @param data the data.
*
* @return the range.
*/
private Range calculateXDataRange(float[][] data) {
Range result = null;
if (data != null) {
float lowest = Float.POSITIVE_INFINITY;
float highest = Float.NEGATIVE_INFINITY;
for (int i = 0; i < data[0].length; i++) {
float v = data[0][i];
if (v < lowest) {
lowest = v;
}
if (v > highest) {
highest = v;
}
}
if (lowest <= highest) {
result = new Range(lowest, highest);
}
}
return result;
}
/**
* Calculates the Y data range.
*
* @param data the data.
*
* @return the range.
*/
private Range calculateYDataRange(float[][] data) {
Range result = null;
if (data != null) {
float lowest = Float.POSITIVE_INFINITY;
float highest = Float.NEGATIVE_INFINITY;
for (int i = 0; i < data[0].length; i++) {
float v = data[1][i];
if (v < lowest) {
lowest = v;
}
if (v > highest) {
highest = v;
}
}
if (lowest <= highest) {
result = new Range(lowest, highest);
}
}
return result;
}
/**
* Multiplies the range on the horizontal axis/axes by the specified factor (not yet
* implemented).
*
* @param factor the zoom factor.
*/
public void zoomHorizontalAxes(double factor) {
// zoom the domain axis
}
/**
* Zooms in on the horizontal axes (not yet implemented).
*
* @param lowerPercent the new lower bound as a percentage of the current range.
* @param upperPercent the new upper bound as a percentage of the current range.
*/
public void zoomHorizontalAxes(double lowerPercent, double upperPercent) {
// zoom the domain axis
}
/**
* Multiplies the range on the vertical axis/axes by the specified factor (not yet implemented).
*
* @param factor the zoom factor.
*/
public void zoomVerticalAxes(double factor) {
// zoom the range axis
// zoom all the secondary axes
}
/**
* Zooms in on the vertical axes (not yet implemented).
*
* @param lowerPercent the new lower bound as a percentage of the current range.
* @param upperPercent the new upper bound as a percentage of the current range.
*/
public void zoomVerticalAxes(double lowerPercent, double upperPercent) {
// zoom the domain axis
}
/**
* Tests an object for equality with this instance.
*
* @param object the object to test.
*
* @return A boolean.
*/
public boolean equals(Object object) {
if (object == null) {
return false;
}
if (object == this) {
return true;
}
if (super.equals(object) && object instanceof FastScatterPlot) {
FastScatterPlot fsp = (FastScatterPlot) object;
boolean b0 = ArrayUtils.equal(this.data, fsp.data);
boolean b1 = ObjectUtils.equal(this.domainAxis, fsp.domainAxis);
boolean b2 = ObjectUtils.equal(this.rangeAxis, fsp.rangeAxis);
boolean b3 = ObjectUtils.equal(this.paint, fsp.paint);
return b0 && b1 && b2 && b3;
}
return false;
}
/**
* Returns a clone of the plot.
*
* @return A clone.
*
* @throws CloneNotSupportedException if some component of the plot does not support cloning.
*/
public Object clone() throws CloneNotSupportedException {
FastScatterPlot clone = (FastScatterPlot) super.clone();
if (this.data != null) {
clone.data = ArrayUtils.clone(this.data);
}
if (this.domainAxis != null) {
clone.domainAxis = (ValueAxis) this.domainAxis.clone();
}
if (this.rangeAxis != null) {
clone.rangeAxis = (ValueAxis) this.rangeAxis.clone();
}
return clone;
}
/**
* Provides serialization support.
*
* @param stream the output stream.
*
* @throws IOException if there is an I/O error.
*/
private void writeObject(ObjectOutputStream stream) throws IOException {
stream.defaultWriteObject();
SerialUtilities.writePaint(this.paint, stream);
}
/**
* Provides serialization support.
*
* @param stream the input stream.
*
* @throws IOException if there is an I/O error.
* @throws ClassNotFoundException if there is a classpath problem.
*/
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
this.paint = SerialUtilities.readPaint(stream);
if (this.domainAxis != null) {
this.domainAxis.addChangeListener(this);
}
if (this.rangeAxis != null) {
this.rangeAxis.addChangeListener(this);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -