⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xysteparearenderer.java

📁 这是一个segy数据显示程序
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                                          XYPlot plot,                                          XYDataset data,                                          PlotRenderingInfo info) {        return super.initialise(g2, dataArea, plot, data, info);    }    /**     * Draws the visual representation of a single data item.     *     * @param g2  the graphics device.     * @param state  the renderer state.     * @param dataArea  the area within which the data is being drawn.     * @param info  collects information about the drawing.     * @param plot  the plot (can be used to obtain standard color information etc).     * @param domainAxis  the domain axis.     * @param rangeAxis  the range axis.     * @param dataset  the dataset.     * @param series  the series index (zero-based).     * @param item  the item index (zero-based).     * @param crosshairState  crosshair information for the plot (<code>null</code> permitted).     * @param pass  the pass index.     */    public void drawItem(Graphics2D g2,                         XYItemRendererState state,                         Rectangle2D dataArea,                         PlotRenderingInfo info,                         XYPlot plot,                         ValueAxis domainAxis,                         ValueAxis rangeAxis,                         XYDataset dataset,                         int series,                         int item,                         CrosshairState crosshairState,                         int pass) {                                     PlotOrientation orientation = plot.getOrientation();                // Get the item count for the series, so that we can know which is the end of the series.        int itemCount = dataset.getItemCount(series);        Paint paint = getItemPaint(series, item);        Stroke seriesStroke = getItemStroke(series, item);        g2.setPaint(paint);        g2.setStroke(seriesStroke);        // get the data point...        Number x1 = dataset.getXValue(series, item);        Number y1 = dataset.getYValue(series, item);        double x = x1.doubleValue();        double y = y1 == null ? getRangeBase() : y1.doubleValue();        double transX1 = domainAxis.valueToJava2D(x, dataArea, plot.getDomainAxisEdge());        double transY1 = rangeAxis.valueToJava2D(y, dataArea, plot.getRangeAxisEdge());                                                                  // avoid possible sun.dc.pr.PRException: endPath: bad path        transY1 = restrictValueToDataArea(transY1, plot, dataArea);                 if (this.pArea == null && y1 != null) {            // Create a new Area for the series            this.pArea = new Polygon();                    // start from Y = rangeBase            double transY2 = rangeAxis.valueToJava2D(                getRangeBase(), dataArea, plot.getRangeAxisEdge()            );                    // avoid possible sun.dc.pr.PRException: endPath: bad path            transY2 = restrictValueToDataArea(transY2, plot, dataArea);                             // The first point is (x, this.baseYValue)            if (orientation == PlotOrientation.VERTICAL) {                this.pArea.addPoint((int) transX1, (int) transY2);            }            else if (orientation == PlotOrientation.HORIZONTAL) {                this.pArea.addPoint((int) transY2, (int) transX1);            }        }        double transX0 = 0;        double transY0 = restrictValueToDataArea(getRangeBase(), plot, dataArea);                           Number x0 = null;        Number y0 = null;        if (item > 0) {            // get the previous data point...            x0 = dataset.getXValue(series, item - 1);            y0 = y1 == null ? null : dataset.getYValue(series, item - 1);            x = x0.doubleValue();            y = y0 == null ? getRangeBase() : y0.doubleValue();            transX0 = domainAxis.valueToJava2D(x, dataArea, plot.getDomainAxisEdge());            transY0 = rangeAxis.valueToJava2D(y, dataArea, plot.getRangeAxisEdge());            // avoid possible sun.dc.pr.PRException: endPath: bad path            transY0 = restrictValueToDataArea(transY0, plot, dataArea);                                    if (y1 == null) {                // NULL value -> insert point on base line                // instead of 'step point'                transX1 = transX0;                transY0 = transY1;                      }            if (transY0 != transY1) {                // not just a horizontal bar but need to perform a 'step'.                if (orientation == PlotOrientation.VERTICAL) {                    this.pArea.addPoint((int) transX1, (int) transY0);                                       }                else if (orientation == PlotOrientation.HORIZONTAL) {                    this.pArea.addPoint((int) transY0, (int) transX1);                }            }        }                   Shape shape = null;        if (y1 != null) {            // Add each point to Area (x, y)            if (orientation == PlotOrientation.VERTICAL) {                this.pArea.addPoint((int) transX1, (int) transY1);            }            else if (orientation == PlotOrientation.HORIZONTAL) {                this.pArea.addPoint((int) transY1, (int) transX1);            }            if (getPlotShapes()) {                shape = getItemShape(series, item);                if (orientation == PlotOrientation.VERTICAL) {                    shape = createTransformedShape(shape, transX1, transY1);                }                else if (orientation == PlotOrientation.HORIZONTAL) {                    shape = createTransformedShape(shape, transY1, transX1);                }                if (isShapesFilled()) {                    g2.fill(shape);                }                   else {                    g2.draw(shape);                }               }            else {                if (orientation == PlotOrientation.VERTICAL) {                    shape = new Rectangle2D.Double(transX1 - 2, transY1 - 2, 4.0, 4.0);                }                else if (orientation == PlotOrientation.HORIZONTAL) {                    shape = new Rectangle2D.Double(transY1 - 2, transX1 - 2, 4.0, 4.0);                }            }        }        // Check if the item is the last item for the series or if it        // is a NULL value and number of items > 0.  We can't draw an area for a single point.        if (getPlotArea() && item > 0 && this.pArea != null                           && (item == (itemCount - 1) || y1 == null)) {            double transY2 = rangeAxis.valueToJava2D(                getRangeBase(), dataArea, plot.getRangeAxisEdge()            );            // avoid possible sun.dc.pr.PRException: endPath: bad path            transY2 = restrictValueToDataArea(transY2, plot, dataArea);                     if (orientation == PlotOrientation.VERTICAL) {                // Add the last point (x,0)                this.pArea.addPoint((int) transX1, (int) transY2);            }            else if (orientation == PlotOrientation.HORIZONTAL) {                // Add the last point (x,0)                this.pArea.addPoint((int) transY2, (int) transX1);            }            // fill the polygon            g2.fill(this.pArea);            // draw an outline around the Area.            if (isOutline()) {                g2.setStroke(plot.getOutlineStroke());                g2.setPaint(plot.getOutlinePaint());                g2.draw(this.pArea);            }            // start new area when needed (see above)            this.pArea = null;        }        // do we need to update the crosshair values?        if (y1 != null) {            updateCrosshairValues(                crosshairState, x1.doubleValue(), y1.doubleValue(), transX1, transY1, orientation            );        }        // collect entity and tool tip information...        if (state.getInfo() != null) {            EntityCollection entities = state.getInfo().getOwner().getEntityCollection();            if (entities != null && shape != null) {                String tip = null;                XYToolTipGenerator generator = getToolTipGenerator(series, item);                if (generator != null) {                    tip = generator.generateToolTip(dataset, series, item);                }                String url = null;                if (getURLGenerator() != null) {                    url = getURLGenerator().generateURL(dataset, series, item);                }                XYItemEntity entity = new XYItemEntity(shape, dataset, series, item, tip, url);                entities.addEntity(entity);            }        }    }    /**     * Returns a clone of the renderer.     *      * @return A clone.     *      * @throws CloneNotSupportedException  if the renderer cannot be cloned.     */    public Object clone() throws CloneNotSupportedException {        return super.clone();    }        /**     * Helper method which returns a value if it lies     * inside the visible dataArea and otherwise the corresponding     * coordinate on the border of the dataArea. The PlotOrientation     * is taken into account.      * Useful to avoid possible sun.dc.pr.PRException: endPath: bad path     * which occurs when trying to draw lines/shapes which in large part     * lie outside of the visible dataArea.     *      * @param value the value which shall be      * @param dataArea  the area within which the data is being drawn.     * @param plot  the plot (can be used to obtain standard color information etc).     * @return <code>double</code> value inside the data area.     */    protected static double restrictValueToDataArea(double value,                                                     XYPlot plot,                                                     Rectangle2D dataArea) {        double min = 0;        double max = 0;        if (plot.getOrientation() == PlotOrientation.VERTICAL) {            min = dataArea.getMinY();            max = dataArea.getMaxY();        }         else if (plot.getOrientation() ==  PlotOrientation.HORIZONTAL) {            min = dataArea.getMinX();            max = dataArea.getMaxX();        }               if (value < min) {            value = min;        }        else if (value > max) {            value = max;        }        return value;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -