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

📄 plot.java

📁 这是一个segy数据显示程序
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        /**     * Draws the plot outline.  This method will be called during the chart drawing process and is     * declared public so that it can be accessed by the renderers used by certain subclasses.       * You shouldn't need to call this method directly.     *      * @param g2  the graphics device.     * @param area  the area within which the plot should be drawn.     */    public void drawOutline(Graphics2D g2, Rectangle2D area) {        if ((this.outlineStroke != null) && (this.outlinePaint != null)) {            g2.setStroke(this.outlineStroke);            g2.setPaint(this.outlinePaint);            g2.draw(area);        }    }    /**     * Draws a message to state that there is no data to plot.     *     * @param g2  the graphics device.     * @param area  the area within which the plot should be drawn.     */    protected void drawNoDataMessage(Graphics2D g2, Rectangle2D area) {        Shape savedClip = g2.getClip();        g2.clip(area);        String message = this.noDataMessage;        if (message != null) {            g2.setFont(this.noDataMessageFont);            g2.setPaint(this.noDataMessagePaint);            FontMetrics fm = g2.getFontMetrics(this.noDataMessageFont);            Rectangle2D bounds = TextUtilities.getTextBounds(message, g2, fm);            float x = (float) (area.getX() + area.getWidth() / 2 - bounds.getWidth() / 2);            float y = (float) (area.getMinY() + (area.getHeight() / 2) - (bounds.getHeight() / 2));            g2.drawString(message, x, y);        }        g2.setClip(savedClip);    }    /**     * Handles a 'click' on the plot.  Since the plot does not maintain any     * information about where it has been drawn, the plot rendering info is supplied as     * an argument.     *     * @param x  the x coordinate (in Java2D space).     * @param y  the y coordinate (in Java2D space).     * @param info  an object containing information about the dimensions of the plot.     */    public void handleClick(int x, int y, PlotRenderingInfo info) {        // provides a 'no action' default    }    /**     * Performs a zoom on the plot.  Subclasses should override if zooming is appropriate for     * the type of plot.     *     * @param percent  the zoom percentage.     */    public void zoom(double percent) {        // do nothing by default.    }    /**     * Receives notification of a change to one of the plot's axes.     *     * @param event  information about the event (not used here).     */    public void axisChanged(AxisChangeEvent event) {        notifyListeners(new PlotChangeEvent(this));    }    /**     * Receives notification of a change to the plot's dataset.     * <P>     * The plot reacts by passing on a plot change event to all registered listeners.     *     * @param event  information about the event (not used here).     */    public void datasetChanged(DatasetChangeEvent event) {        PlotChangeEvent newEvent = new PlotChangeEvent(this);        notifyListeners(newEvent);    }    /**     * Adjusts the supplied x-value.     *     * @param x  the x-value.     * @param w1  width 1.     * @param w2  width 2.     * @param edge  the edge (left or right).     *     * @return the adjusted x-value.     */    protected double getRectX(double x, double w1, double w2, RectangleEdge edge) {        double result = x;        if (edge == RectangleEdge.LEFT) {            result = result + w1;        }        else if (edge == RectangleEdge.RIGHT) {            result = result + w2;        }        return result;    }    /**     * Adjusts the supplied y-value.     *     * @param y  the x-value.     * @param h1  height 1.     * @param h2  height 2.     * @param edge  the edge (top or bottom).     *     * @return the adjusted y-value.     */    protected double getRectY(double y, double h1, double h2, RectangleEdge edge) {        double result = y;        if (edge == RectangleEdge.TOP) {            result = result + h1;        }        else if (edge == RectangleEdge.BOTTOM) {            result = result + h2;        }        return result;    }    /**     * Returns the data area ratio.     *     * @return The ratio.     */    public double getDataAreaRatio() {        return this.dataAreaRatio;    }    /**     * Sets the data area ratio.     *     * @param ratio  the ratio.     */    public void setDataAreaRatio(double ratio) {        this.dataAreaRatio = ratio;    }    /**     * 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 (obj instanceof Plot) {            Plot p = (Plot) obj;            boolean b5 = ObjectUtils.equal(this.noDataMessage, p.noDataMessage);            boolean b6 = ObjectUtils.equal(this.noDataMessageFont, p.noDataMessageFont);            boolean b7 = ObjectUtils.equal(this.noDataMessagePaint, p.noDataMessagePaint);            boolean b8 = ObjectUtils.equal(this.insets, p.insets);            boolean b9 = ObjectUtils.equal(this.outlineStroke, p.outlineStroke);            boolean b10 = ObjectUtils.equal(this.outlinePaint, p.outlinePaint);            boolean b11 = ObjectUtils.equal(this.backgroundPaint, p.backgroundPaint);            boolean b12 = ObjectUtils.equal(this.backgroundImage, p.backgroundImage);            boolean b13 = (this.backgroundImageAlignment == p.backgroundImageAlignment);            boolean b14 = (this.foregroundAlpha == p.foregroundAlpha);            boolean b15 = (this.backgroundAlpha == p.backgroundAlpha);            return b5 && b6 && b7 && b8 && b9                && b10 && b11 && b12 && b13 && b14 && b15;        }        return false;    }    /**     * Creates 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 {        Plot clone = (Plot) super.clone();        //private Plot parent <-- don't clone the parent plot, but take care childs in combined         // plots instead        clone.datasetGroup = (DatasetGroup) ObjectUtils.clone(this.datasetGroup);        //private String noDataMessage <-- immutable        //private Font noDataMessageFont <-- immutable        //private transient Paint noDataMessagePaint <-- immutable        //private Insets insets <-- immutable        //private transient Stroke outlineStroke <-- immutable        //private transient Paint outlinePaint <-- immutable        //private transient Paint backgroundPaint <-- immutable        //private transient Image backgroundImage <-- ???        //private int backgroundImageAlignment<-- primitive        //private float foregroundAlpha <-- primitive        //private float backgroundAlpha <-- primitive        clone.drawingSupplier = (DrawingSupplier) ObjectUtils.clone(this.drawingSupplier);        //private transient EventListenerList listenerList <-- ???        //private double dataAreaRatio <-- primitive        clone.listenerList = new EventListenerList();        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.noDataMessagePaint, stream);        SerialUtilities.writeStroke(this.outlineStroke, stream);        SerialUtilities.writePaint(this.outlinePaint, stream);        // backgroundImage        SerialUtilities.writePaint(this.backgroundPaint, 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.noDataMessagePaint = SerialUtilities.readPaint(stream);        this.outlineStroke = SerialUtilities.readStroke(stream);        this.outlinePaint = SerialUtilities.readPaint(stream);        // backgroundImage        this.backgroundPaint = SerialUtilities.readPaint(stream);        this.listenerList = new EventListenerList();    }    /**     * Resolves a domain axis location for a given plot orientation.     *     * @param location  the location (<code>null</code> not permitted).     * @param orientation  the orientation (<code>null</code> not permitted).     *     * @return The edge (never <code>null</code>).     */    public static RectangleEdge resolveDomainAxisLocation(AxisLocation location,                                                          PlotOrientation orientation) {                if (location == null) {            throw new IllegalArgumentException("Null 'location' argument.");           }        if (orientation == null) {            throw new IllegalArgumentException("Null 'orientation' argument.");           }        RectangleEdge result = null;                if (location == AxisLocation.TOP_OR_RIGHT) {            if (orientation == PlotOrientation.HORIZONTAL) {                result = RectangleEdge.RIGHT;            }            else if (orientation == PlotOrientation.VERTICAL) {                result = RectangleEdge.TOP;            }        }        else if (location == AxisLocation.TOP_OR_LEFT) {            if (orientation == PlotOrientation.HORIZONTAL) {                result = RectangleEdge.LEFT;            }            else if (orientation == PlotOrientation.VERTICAL) {                result = RectangleEdge.TOP;            }        }        else if (location == AxisLocation.BOTTOM_OR_RIGHT) {            if (orientation == PlotOrientation.HORIZONTAL) {                result = RectangleEdge.RIGHT;            }            else if (orientation == PlotOrientation.VERTICAL) {                result = RectangleEdge.BOTTOM;            }        }        else if (location == AxisLocation.BOTTOM_OR_LEFT) {            if (orientation == PlotOrientation.HORIZONTAL) {                result = RectangleEdge.LEFT;            }            else if (orientation == PlotOrientation.VERTICAL) {                result = RectangleEdge.BOTTOM;            }        }        // the above should cover all the options...        if (result == null) {            throw new IllegalStateException("XYPlot.resolveDomainAxisLocation(...)");        }        return result;            }    /**     * Resolves a range axis location for a given plot orientation.     *     * @param location  the location (<code>null</code> not permitted).     * @param orientation  the orientation (<code>null</code> not permitted).     *     * @return the edge (never <code>null</code>).     */    public static RectangleEdge resolveRangeAxisLocation(AxisLocation location,                                                         PlotOrientation orientation) {        if (location == null) {            throw new IllegalArgumentException("Null 'location' argument.");           }        if (orientation == null) {            throw new IllegalArgumentException("Null 'orientation' argument.");           }        RectangleEdge result = null;                if (location == AxisLocation.TOP_OR_RIGHT) {            if (orientation == PlotOrientation.HORIZONTAL) {                result = RectangleEdge.TOP;            }            else if (orientation == PlotOrientation.VERTICAL) {                result = RectangleEdge.RIGHT;            }        }        else if (location == AxisLocation.TOP_OR_LEFT) {            if (orientation == PlotOrientation.HORIZONTAL) {                result = RectangleEdge.TOP;            }            else if (orientation == PlotOrientation.VERTICAL) {                result = RectangleEdge.LEFT;            }        }        else if (location == AxisLocation.BOTTOM_OR_RIGHT) {            if (orientation == PlotOrientation.HORIZONTAL) {                result = RectangleEdge.BOTTOM;            }            else if (orientation == PlotOrientation.VERTICAL) {                result = RectangleEdge.RIGHT;            }        }        else if (location == AxisLocation.BOTTOM_OR_LEFT) {            if (orientation == PlotOrientation.HORIZONTAL) {                result = RectangleEdge.BOTTOM;            }            else if (orientation == PlotOrientation.VERTICAL) {                result = RectangleEdge.LEFT;            }        }        // the above should cover all the options...        if (result == null) {            throw new IllegalStateException("XYPlot.resolveRangeAxisLocation(...)");        }        return result;            }}

⌨️ 快捷键说明

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