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

📄 xyarearenderer.java

📁 这是一个segy数据显示程序
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     */    public boolean getPlotLines() {        return this.plotLines;    }    /**     * Returns true if Area is being plotted by the renderer.     *     * @return  <code>true</code> if Area is being plotted by the renderer.     */    public boolean getPlotArea() {        return this.plotArea;    }    /**     * Initialises the renderer and returns a state object that should be passed to all subsequent     * calls to the drawItem(...) method.     *     * @param g2  the graphics device.     * @param dataArea  the area inside the axes.     * @param plot  the plot.     * @param data  the data.     * @param info  an optional info collection object to return data back to the caller.     *     * @return a state object for use by the renderer.     */    public XYItemRendererState initialise(Graphics2D g2,                                          Rectangle2D dataArea,                                          XYPlot plot,                                          XYDataset data,                                          PlotRenderingInfo info) {        XYAreaRendererState state = new XYAreaRendererState(info);        return state;    }    /**     * 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) {                XYAreaRendererState areaState = (XYAreaRendererState) state;                // get the data point...        Number x1n = dataset.getXValue(series, item);        Number y1n = dataset.getYValue(series, item);        if (y1n == null) {            y1n = AbstractRenderer.ZERO;        }                double x1 = x1n.doubleValue();        double y1 = y1n.doubleValue();        double transX1 = domainAxis.valueToJava2D(x1, dataArea, plot.getDomainAxisEdge());        double transY1 = rangeAxis.valueToJava2D(y1, dataArea, plot.getRangeAxisEdge());                // get the previous point and the next point so we can calculate a "hot spot"        // for the area (used by the chart entity)...        int itemCount = dataset.getItemCount(series);        Number x0 = dataset.getXValue(series, Math.max(item - 1, 0));        Number y0 = dataset.getYValue(series, Math.max(item - 1, 0));        if (y0 == null) {            y0 = AbstractRenderer.ZERO;        }        double transX0 = domainAxis.valueToJava2D(            x0.doubleValue(), dataArea, plot.getDomainAxisEdge()        );        double transY0 = rangeAxis.valueToJava2D(            y0.doubleValue(), dataArea, plot.getRangeAxisEdge()        );                Number x2 = dataset.getXValue(series, Math.min(item + 1, itemCount - 1));        Number y2 = dataset.getYValue(series, Math.min(item + 1, itemCount - 1));        if (y2 == null) {            y2 = AbstractRenderer.ZERO;        }        double transX2 = domainAxis.valueToJava2D(            x2.doubleValue(), dataArea, plot.getDomainAxisEdge()        );        double transY2 = rangeAxis.valueToJava2D(            y2.doubleValue(), dataArea, plot.getRangeAxisEdge()        );                double transZero = rangeAxis.valueToJava2D(0.0, dataArea, plot.getRangeAxisEdge());        Polygon hotspot = null;        if (plot.getOrientation() == PlotOrientation.HORIZONTAL) {            hotspot = new Polygon();            hotspot.addPoint((int) transZero, (int) ((transX0 + transX1) / 2.0));            hotspot.addPoint((int) ((transY0 + transY1) / 2.0), (int) ((transX0 + transX1) / 2.0));            hotspot.addPoint((int) transY1, (int) transX1);            hotspot.addPoint((int) ((transY1 + transY2) / 2.0), (int) ((transX1 + transX2) / 2.0));            hotspot.addPoint((int) transZero, (int) ((transX1 + transX2) / 2.0));        }        else {  // vertical orientation            hotspot = new Polygon();            hotspot.addPoint((int) ((transX0 + transX1) / 2.0), (int) transZero);            hotspot.addPoint((int) ((transX0 + transX1) / 2.0), (int) ((transY0 + transY1) / 2.0));            hotspot.addPoint((int) transX1, (int) transY1);            hotspot.addPoint((int) ((transX1 + transX2) / 2.0), (int) ((transY1 + transY2) / 2.0));            hotspot.addPoint((int) ((transX1 + transX2) / 2.0), (int) transZero);           }                if (item == 0) {  // create a new area polygon for the series            areaState.area = new Polygon();            // the first point is (x, 0)            double zero = rangeAxis.valueToJava2D(0.0, dataArea, plot.getRangeAxisEdge());            if (plot.getOrientation() == PlotOrientation.VERTICAL) {                areaState.area.addPoint((int) transX1, (int) zero);            }            else if (plot.getOrientation() == PlotOrientation.HORIZONTAL) {                areaState.area.addPoint((int) zero, (int) transX1);            }        }        // Add each point to Area (x, y)        if (plot.getOrientation() == PlotOrientation.VERTICAL) {            areaState.area.addPoint((int) transX1, (int) transY1);        }        else if (plot.getOrientation() == PlotOrientation.HORIZONTAL) {            areaState.area.addPoint((int) transY1, (int) transX1);        }                PlotOrientation orientation = plot.getOrientation();        Paint paint = getItemPaint(series, item);        Stroke stroke = getItemStroke(series, item);        g2.setPaint(paint);        g2.setStroke(stroke);                Shape shape = null;        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);            }            g2.draw(shape);        }        if (getPlotLines()) {            if (item > 0) {                if (plot.getOrientation() == PlotOrientation.VERTICAL) {                    areaState.line.setLine(transX0, transY0, transX1, transY1);                }                else if (plot.getOrientation() == PlotOrientation.HORIZONTAL) {                    areaState.line.setLine(transY0, transX0, transY1, transX1);                }                g2.draw(areaState.line);            }        }        // Check if the item is the last item for the series.        // and number of items > 0.  We can't draw an area for a single point.        if (getPlotArea() && item > 0 && item == (itemCount - 1)) {            if (orientation == PlotOrientation.VERTICAL) {                // Add the last point (x,0)                areaState.area.addPoint((int) transX1, (int) transZero);            }            else if (orientation == PlotOrientation.HORIZONTAL) {                // Add the last point (x,0)                areaState.area.addPoint((int) transZero, (int) transX1);            }            g2.fill(areaState.area);            // draw an outline around the Area.            if (isOutline()) {                g2.setStroke(plot.getOutlineStroke());                g2.setPaint(plot.getOutlinePaint());                g2.draw(areaState.area);            }        }        updateCrosshairValues(crosshairState, x1, y1, transX1, transY1, orientation);                // collect entity and tool tip information...        if (state.getInfo() != null) {            EntityCollection entities = state.getInfo().getOwner().getEntityCollection();            if (entities != null && hotspot != 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(hotspot, 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();    }    }

⌨️ 快捷键说明

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