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

📄 xydifferencerenderer.java

📁 这是一个segy数据显示程序
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        Paint seriesPaint = getItemPaint(series, item);        Stroke seriesStroke = getItemStroke(series, item);        g2.setPaint(seriesPaint);        g2.setStroke(seriesStroke);        if (series == 0) {            Number x0n = dataset.getXValue(0, item);            Number y0n = dataset.getYValue(0, item);            Number x1n = dataset.getXValue(1, item);            Number y1n = dataset.getYValue(1, item);            PlotOrientation orientation = plot.getOrientation();             RectangleEdge domainAxisLocation = plot.getDomainAxisEdge();            RectangleEdge rangeAxisLocation = plot.getRangeAxisEdge();            double x0 = x0n.doubleValue();            double y0 = y0n.doubleValue();            double transX0 = domainAxis.valueToJava2D(x0, dataArea, domainAxisLocation);            double transY0 = rangeAxis.valueToJava2D(y0, dataArea, rangeAxisLocation);            double x1 = x1n.doubleValue();            double y1 = y1n.doubleValue();            double transX1 = domainAxis.valueToJava2D(x1, dataArea, domainAxisLocation);            double transY1 = rangeAxis.valueToJava2D(y1, dataArea, rangeAxisLocation);            if (item > 0) {                // get the previous data points...                Number prevx0n = dataset.getXValue(0, item - 1);                Number prevy0n = dataset.getYValue(0, item - 1);                Number prevx1n = dataset.getXValue(1, item - 1);                Number prevy1n = dataset.getYValue(1, item - 1);                double prevx0 = prevx0n.doubleValue();                double prevy0 = prevy0n.doubleValue();                double prevtransX0 = domainAxis.valueToJava2D(prevx0, dataArea, domainAxisLocation);                double prevtransY0 = rangeAxis.valueToJava2D(prevy0, dataArea, rangeAxisLocation);                double prevx1 = prevx1n.doubleValue();                double prevy1 = prevy1n.doubleValue();                double prevtransX1 = domainAxis.valueToJava2D(prevx1, dataArea, domainAxisLocation);                double prevtransY1 = rangeAxis.valueToJava2D(prevy1, dataArea, rangeAxisLocation);                Line2D line0 = null;                Line2D line1 = null;                if (orientation == PlotOrientation.HORIZONTAL) {                    line0 = new Line2D.Double(transY0, transX0, prevtransY0, prevtransX0);                    line1 = new Line2D.Double(transY1, transX1, prevtransY1, prevtransX1);                }                else if (orientation == PlotOrientation.VERTICAL) {                    line0 = new Line2D.Double(transX0, transY0, prevtransX0, prevtransY0);                    line1 = new Line2D.Double(transX1, transY1, prevtransX1, prevtransY1);                }                if (line0 != null && line0.intersects(dataArea)) {                    g2.setPaint(getItemPaint(series, item));                    g2.draw(line0);                }                if (line1 != null && line1.intersects(dataArea)) {                    g2.setPaint(getItemPaint(1, item));                    g2.draw(line1);                }            }            if (getPlotShapes()) {                Shape shape0 = getItemShape(series, item);                if (orientation == PlotOrientation.HORIZONTAL) {                    shape0 = createTransformedShape(shape0, transY0, transX0);                }                else {  // vertical                    shape0 = createTransformedShape(shape0, transX0, transY0);                }                if (shape0.intersects(dataArea)) {                    g2.setPaint(getItemPaint(series, item));                    g2.fill(shape0);                }                entityArea = shape0;                // add an entity for the item...                if (entities != null) {                    if (entityArea == null) {                        entityArea = new Rectangle2D.Double(transX0 - 2, transY0 - 2, 4, 4);                    }                    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(entityArea, dataset, series, item,                                                            tip, url);                    entities.addEntity(entity);                }                Shape shape1 = getItemShape(series + 1, item);                shape1 = createTransformedShape(shape1, transX1, transY1);                if (shape1.intersects(dataArea)) {                    g2.setPaint(getItemPaint(series + 1, item));                    g2.fill(shape1);                }                entityArea = shape1;                // add an entity for the item...                if (entities != null) {                    if (entityArea == null) {                        entityArea = new Rectangle2D.Double(transX1 - 2, transY1 - 2, 4, 4);                    }                    String tip = null;                    XYToolTipGenerator generator = getToolTipGenerator(series, item);                    if (generator != null) {                        tip = generator.generateToolTip(dataset, series + 1, item);                    }                    String url = null;                    if (getURLGenerator() != null) {                        url = getURLGenerator().generateURL(dataset, series + 1, item);                    }                    XYItemEntity entity = new XYItemEntity(entityArea, dataset, series + 1, item,                                                            tip, url);                    entities.addEntity(entity);                }            }        }    }    /**     * Returns the positive area for a crossover point.     *      * @param x0  x coordinate.     * @param y0A  y coordinate A.     * @param y0B  y coordinate B.     * @param x1  x coordinate.     * @param y1A  y coordinate A.     * @param y1B  y coordinate B.     * @param orientation  the plot orientation.     *      * @return The positive area.     */    protected Shape getPositiveArea(float x0, float y0A, float y0B,                                     float x1, float y1A, float y1B,                                    PlotOrientation orientation) {        Shape result = null;        boolean startsNegative = (y0A >= y0B);          boolean endsNegative = (y1A >= y1B);        if (orientation == PlotOrientation.HORIZONTAL) {            startsNegative = (y0B >= y0A);            endsNegative = (y1B >= y1A);        }                if (startsNegative) {  // starts negative            if (endsNegative) {                // all negative - return null            }            else {                // changed from negative to positive                float[] p = getIntersection(x0, y0A, x1, y1A, x0, y0B, x1, y1B);                GeneralPath area = new GeneralPath();                if (orientation == PlotOrientation.HORIZONTAL) {                    area.moveTo(y1A, x1);                    area.lineTo(p[1], p[0]);                    area.lineTo(y1B, x1);                    area.closePath();                }                else if (orientation == PlotOrientation.VERTICAL) {                    area.moveTo(x1, y1A);                    area.lineTo(p[0], p[1]);                    area.lineTo(x1, y1B);                    area.closePath();                }                result = area;            }        }        else {  // starts positive            if (endsNegative) {                // changed from positive to negative                float[] p = getIntersection(x0, y0A, x1, y1A, x0, y0B, x1, y1B);                GeneralPath area = new GeneralPath();                if (orientation == PlotOrientation.HORIZONTAL) {                    area.moveTo(y0A, x0);                    area.lineTo(p[1], p[0]);                    area.lineTo(y0B, x0);                    area.closePath();                }                else if (orientation == PlotOrientation.VERTICAL) {                    area.moveTo(x0, y0A);                    area.lineTo(p[0], p[1]);                    area.lineTo(x0, y0B);                    area.closePath();                }                result = area;            }            else {                GeneralPath area = new GeneralPath();                if (orientation == PlotOrientation.HORIZONTAL) {                    area.moveTo(y0A, x0);                    area.lineTo(y1A, x1);                    area.lineTo(y1B, x1);                    area.lineTo(y0B, x0);                    area.closePath();                }                else if (orientation == PlotOrientation.VERTICAL) {                    area.moveTo(x0, y0A);                    area.lineTo(x1, y1A);                    area.lineTo(x1, y1B);                    area.lineTo(x0, y0B);                    area.closePath();                }                result = area;            }        }        return result;    }    /**     * Returns the negative area for a cross-over section.     *      * @param x0  x coordinate.     * @param y0A  y coordinate A.     * @param y0B  y coordinate B.     * @param x1  x coordinate.     * @param y1A  y coordinate A.     * @param y1B  y coordinate B.     * @param orientation  the plot orientation.     *      * @return The negative area.     */    protected Shape getNegativeArea(float x0, float y0A, float y0B,                                     float x1, float y1A, float y1B,                                    PlotOrientation orientation) {        Shape result = null;        boolean startsNegative = (y0A >= y0B);        boolean endsNegative = (y1A >= y1B);        if (orientation == PlotOrientation.HORIZONTAL) {            startsNegative = (y0B >= y0A);            endsNegative = (y1B >= y1A);        }        if (startsNegative) {  // starts negative            if (endsNegative) {  // all negative                GeneralPath area = new GeneralPath();                if (orientation == PlotOrientation.HORIZONTAL) {                    area.moveTo(y0A, x0);                    area.lineTo(y1A, x1);                    area.lineTo(y1B, x1);                    area.lineTo(y0B, x0);                    area.closePath();                }                else if (orientation == PlotOrientation.VERTICAL) {                    area.moveTo(x0, y0A);                    area.lineTo(x1, y1A);                    area.lineTo(x1, y1B);                    area.lineTo(x0, y0B);                    area.closePath();                }                result = area;            }            else {  // changed from negative to positive                float[] p = getIntersection(x0, y0A, x1, y1A, x0, y0B, x1, y1B);                GeneralPath area = new GeneralPath();                if (orientation == PlotOrientation.HORIZONTAL) {                    area.moveTo(y0A, x0);                    area.lineTo(p[1], p[0]);                    area.lineTo(y0B, x0);                    area.closePath();                }                else if (orientation == PlotOrientation.VERTICAL) {                    area.moveTo(x0, y0A);                    area.lineTo(p[0], p[1]);                    area.lineTo(x0, y0B);                    area.closePath();                }                result = area;            }        }        else {            if (endsNegative) {                // changed from positive to negative                float[] p = getIntersection(x0, y0A, x1, y1A, x0, y0B, x1, y1B);                GeneralPath area = new GeneralPath();                if (orientation == PlotOrientation.HORIZONTAL) {                    area.moveTo(y1A, x1);                    area.lineTo(p[1], p[0]);                    area.lineTo(y1B, x1);                    area.closePath();                }                else if (orientation == PlotOrientation.VERTICAL) {                    area.moveTo(x1, y1A);                    area.lineTo(p[0], p[1]);                    area.lineTo(x1, y1B);                    area.closePath();                }                result = area;            }            else {                // all negative - return null            }        }        return result;    }    /**     * Returns the intersection point of two lines.     *      * @param x1  x1     * @param y1  y1     * @param x2  x2     * @param y2  y2     * @param x3  x3     * @param y3  y3     * @param x4  x4     * @param y4  y4     *      * @return The intersection point.     */    private float[] getIntersection(float x1, float y1, float x2, float y2,                                    float x3, float y3, float x4, float y4) {        float n = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3);        float d = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1);        float u = n / d;        float[] result = new float[2];        result[0] = x1 + u * (x2 - x1);        result[1] = y1 + u * (y2 - y1);        return result;    }        /**     * 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();    }    /**     * 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.positivePaint, stream);        SerialUtilities.writePaint(this.negativePaint, 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.positivePaint = SerialUtilities.readPaint(stream);        this.negativePaint = SerialUtilities.readPaint(stream);    }}

⌨️ 快捷键说明

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