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

📄 polarplot.java

📁 这是一个segy数据显示程序
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        if (!DatasetUtilities.isEmptyOrNull(this.dataset)) {            int seriesCount = this.dataset.getSeriesCount();            for (int series = 0; series < seriesCount; series++) {                this.renderer.drawSeries(                    g2, dataArea, info, this, this.dataset, series                );            }        }        else {            drawNoDataMessage(g2, dataArea);        }    }       /**     * Draws the gridlines for the plot, if they are visible.     *     * @param g2  the graphics device.     * @param dataArea  the data area.     * @param angularTicks  the ticks for the angular axis.     * @param radialTicks  the ticks for the radial axis.     */    protected void drawGridlines(Graphics2D g2, Rectangle2D dataArea,                                  List angularTicks, List radialTicks) {        // no renderer, no gridlines...        if (this.renderer == null) {            return;        }               // draw the domain grid lines, if any...        if (isAngleGridlinesVisible()) {            Stroke gridStroke = getAngleGridlineStroke();            Paint gridPaint = getAngleGridlinePaint();            if ((gridStroke != null) && (gridPaint != null)) {                this.renderer.drawAngularGridLines(g2, this, angularTicks, dataArea);            }        }               // draw the radius grid lines, if any...        if (isRadiusGridlinesVisible()) {            Stroke gridStroke = getRadiusGridlineStroke();            Paint gridPaint = getRadiusGridlinePaint();            if ((gridStroke != null) && (gridPaint != null)) {                this.renderer.drawRadialGridLines(g2, this, this.radiusAxis, radialTicks, dataArea);            }        }          }       /**     * Zooms the axis ranges by the specified percentage about the anchor point.     *     * @param percent  the amount of the zoom.     */    public void zoom(double percent) {        if (percent > 0.0) {            double radius = getMaxRadius();            double scaledRadius = radius * percent;            this.radiusAxis.setUpperBound(scaledRadius);            getRadialAxis().setAutoRange(false);        }         else {            getRadialAxis().setAutoRange(true);        }    }       /**     * Returns the range for the specified axis.     *     * @param axis  the axis.     *     * @return the range.     */    public Range getDataRange(ValueAxis axis) {        Range result = null;        result = Range.combine(result, DatasetUtilities.getRangeExtent(this.dataset));        return result;    }       /**     * Receives notification of a change to the plot's m_Dataset.     * <P>     * The axis ranges are updated if necessary.     *     * @param event  information about the event (not used here).     */    public void datasetChanged(DatasetChangeEvent event) {        if (this.radiusAxis != null) {            this.radiusAxis.configure();        }               if (getParent() != null) {            getParent().datasetChanged(event);        }        else {            PlotChangeEvent e = new PlotChangeEvent(this);            notifyListeners(e);        }    }       /**     * Notifies all registered listeners of a property change.     * <P>     * One source of property change events is the plot's m_Renderer.     *     * @param event  information about the property change.     */    public void rendererChanged(RendererChangeEvent event) {        notifyListeners(new PlotChangeEvent(this));    }       /**     * Returns the number of series in the dataset for this plot.  If the dataset is     * <code>null</code>, the method returns 0.     *     * @return The series count.     */    public int getSeriesCount() {        int result = 0;               if (this.dataset != null) {            result = this.dataset.getSeriesCount();        }        return result;    }       /**     * Returns the legend items for the plot.  Each legend item is generated by the plot's     * m_Renderer, since the m_Renderer is responsible for the visual representation of the     * data.     *     * @return the legend items.     */    public LegendItemCollection getLegendItems() {        LegendItemCollection result = new LegendItemCollection();               // get the legend items for the main m_Dataset...        if (this.dataset != null) {            if (this.renderer != null) {                int seriesCount = this.dataset.getSeriesCount();                for (int i = 0; i < seriesCount; i++) {                    LegendItem item = this.renderer.getLegendItem(i);                    result.add(item);                }            }        }              return result;    }       /**     * Tests this plot for equality with another object.     *     * @param obj  the object.     *     * @return <code>true</code> or <code>false</code>.     */    public boolean equals(Object obj) {               if (obj == null) {            return false;        }               if (obj == this) {            return true;        }               if (super.equals(obj) && obj instanceof PolarPlot) {            PolarPlot p = (PolarPlot) obj;            boolean b1 = ObjectUtils.equal(this.radiusAxis, p.radiusAxis);            boolean b2 = ObjectUtils.equal(this.renderer, p.renderer);                        boolean b3 = (this.angleGridlinesVisible == p.angleGridlinesVisible);            boolean b4 = ObjectUtils.equal(this.angleGridlineStroke, p.angleGridlineStroke);            boolean b5 = ObjectUtils.equal(this.angleGridlinePaint, p.angleGridlinePaint);            boolean b6 = (this.radiusGridlinesVisible == p.radiusGridlinesVisible);            boolean b7 = ObjectUtils.equal(this.radiusGridlineStroke, p.radiusGridlineStroke);            boolean b8 = ObjectUtils.equal(this.radiusGridlinePaint, p.radiusGridlinePaint);                      return b1 && b2 && b3 && b4 && b5 && b6 && b7 && b8;        }        return false;    }       /**     * Returns a clone of the plot.     *     * @return A clone.     *     * @throws CloneNotSupportedException  this can occur if some component of the plot cannot     *         be cloned.     */    public Object clone() throws CloneNotSupportedException {              PolarPlot clone = (PolarPlot) super.clone();        clone.radiusAxis = (ValueAxis) ObjectUtils.clone(this.radiusAxis);        if (clone.radiusAxis != null) {            clone.radiusAxis.setPlot(clone);            clone.radiusAxis.addChangeListener(clone);        }              //private PolarDataset m_Dataset <-- just keep the reference, don't clone the m_Dataset        if (clone.dataset != null) {            clone.dataset.addChangeListener(clone);        }              clone.renderer = (PolarItemRenderer) ObjectUtils.clone(this.renderer);        //private int m_Weight <-- primitive        //private double anchorX <-- primitive        //private double anchorY <-- primitive               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.writeStroke(this.angleGridlineStroke, stream);        SerialUtilities.writePaint(this.angleGridlinePaint, stream);        SerialUtilities.writeStroke(this.radiusGridlineStroke, stream);        SerialUtilities.writePaint(this.radiusGridlinePaint, 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.angleGridlineStroke = SerialUtilities.readStroke(stream);        this.angleGridlinePaint = SerialUtilities.readPaint(stream);        this.radiusGridlineStroke = SerialUtilities.readStroke(stream);        this.radiusGridlinePaint = SerialUtilities.readPaint(stream);              if (this.radiusAxis != null) {            this.radiusAxis.setPlot(this);            this.radiusAxis.addChangeListener(this);        }              if (this.dataset != null) {            this.dataset.addChangeListener(this);        }    }       // ---------------------------------------    // --- ValueAxisPlot Interface Methods ---    // ---------------------------------------       /**      * Multiplies the range on the horizontal axis/axes by the specified factor.     *     * @param factor  the zoom factor.     *     */    public void zoomHorizontalAxes(double factor) {        zoom(factor);    }       /**      * Zooms in on the horizontal axes.     *     * @param lowerPercent  the new lower bound.     * @param upperPercent  the new upper bound.     *     */    public void zoomHorizontalAxes(double lowerPercent, double upperPercent) {        zoom((upperPercent + lowerPercent) / 2.0);    }       /**      * Multiplies the range on the vertical axis/axes by the specified factor.     *     * @param factor  the zoom factor.     */    public void zoomVerticalAxes(double factor) {        zoom(factor);    }       /**      * Zooms in on the vertical axes.     *     * @param lowerPercent  the new lower bound.     * @param upperPercent  the new upper bound.     */    public void zoomVerticalAxes(double lowerPercent, double upperPercent) {        zoom((upperPercent + lowerPercent) / 2.0);    }          // ----------------------    // --- Public Methods ---    // ----------------------    /**     * Returns the upper bound of the radius axis.     *      * @return The upper bound.     */    public double getMaxRadius() {        return this.radiusAxis.getUpperBound();    }    /**     * Translates a (theta, radius) pair into Java2D coordinates.     *      * @param angleDegrees  the angle in degrees.     * @param radius  the radius.     * @param dataArea  the data area.     *      * @return A point in Java2D space.     */       public Point translateValueThetaRadiusToJava2D(double angleDegrees,                                                    double radius,                                                   Rectangle2D dataArea) {               double radians = Math.toRadians(angleDegrees - 90.0);        double xv = radius * Math.cos(radians);        double yv = radius * Math.sin(radians);              double minx = dataArea.getMinX() + MARGIN;        double maxx = dataArea.getMaxX() - MARGIN;        double miny = dataArea.getMinY() + MARGIN;        double maxy = dataArea.getMaxY() - MARGIN;              double lengthX = maxx - minx;        double lengthY = maxy - miny;        double length = Math.min(lengthX, lengthY);              double midX = minx + lengthX / 2.0;        double midY = miny + lengthY / 2.0;              double axisMin = -getMaxRadius();        double axisMax =  getMaxRadius();              float x = (float) (midX + (xv / (axisMax - axisMin)) * length);        float y = (float) (midY + (yv / (axisMax - axisMin)) * length);              int ix = Math.round(x);        int iy = Math.round(y);              Point p = new Point(ix, iy);        return p;            }    }

⌨️ 快捷键说明

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