contourplot.java

来自「JfreeChart 常用图表例子」· Java 代码 · 共 1,882 行 · 第 1/4 页

JAVA
1,882
字号
        return this.domainCrosshairPaint;    }    /**     * Sets the Paint used to color the crosshairs (if visible) and notifies     * registered listeners that the axis has been modified.     *     * @param paint the new crosshair paint.     */    public void setDomainCrosshairPaint(Paint paint) {        this.domainCrosshairPaint = paint;        notifyListeners(new PlotChangeEvent(this));    }    /**     * Returns a flag indicating whether or not the range crosshair is visible.     *     * @return The flag.     */    public boolean isRangeCrosshairVisible() {        return this.rangeCrosshairVisible;    }    /**     * Sets the flag indicating whether or not the range crosshair is visible.     *     * @param flag  the new value of the flag.     */    public void setRangeCrosshairVisible(boolean flag) {        if (this.rangeCrosshairVisible != flag) {            this.rangeCrosshairVisible = flag;            notifyListeners(new PlotChangeEvent(this));        }    }    /**     * Returns a flag indicating whether or not the crosshair should "lock-on"     * to actual data values.     *     * @return The flag.     */    public boolean isRangeCrosshairLockedOnData() {        return this.rangeCrosshairLockedOnData;    }    /**     * Sets the flag indicating whether or not the range crosshair should      * "lock-on" to actual data values.     *     * @param flag  the flag.     */    public void setRangeCrosshairLockedOnData(boolean flag) {        if (this.rangeCrosshairLockedOnData != flag) {            this.rangeCrosshairLockedOnData = flag;            notifyListeners(new PlotChangeEvent(this));        }    }    /**     * Returns the range crosshair value.     *     * @return The value.     */    public double getRangeCrosshairValue() {        return this.rangeCrosshairValue;    }    /**     * Sets the domain crosshair value.     * <P>     * Registered listeners are notified that the plot has been modified, but     * only if the crosshair is visible.     *     * @param value  the new value.     */    public void setRangeCrosshairValue(double value) {        setRangeCrosshairValue(value, true);    }    /**     * Sets the range crosshair value.     * <P>     * Registered listeners are notified that the axis has been modified, but     * only if the crosshair is visible.     *     * @param value  the new value.     * @param notify  a flag that controls whether or not listeners are      *                notified.     */    public void setRangeCrosshairValue(double value, boolean notify) {        this.rangeCrosshairValue = value;        if (isRangeCrosshairVisible() && notify) {            notifyListeners(new PlotChangeEvent(this));        }    }    /**     * Returns the Stroke used to draw the crosshair (if visible).     *     * @return The crosshair stroke.     */    public Stroke getRangeCrosshairStroke() {        return this.rangeCrosshairStroke;    }    /**     * Sets the Stroke used to draw the crosshairs (if visible) and notifies     * registered listeners that the axis has been modified.     *     * @param stroke  the new crosshair stroke.     */    public void setRangeCrosshairStroke(Stroke stroke) {        this.rangeCrosshairStroke = stroke;        notifyListeners(new PlotChangeEvent(this));    }    /**     * Returns the range crosshair color.     *     * @return The crosshair color.     */    public Paint getRangeCrosshairPaint() {        return this.rangeCrosshairPaint;    }    /**     * Sets the Paint used to color the crosshairs (if visible) and notifies     * registered listeners that the axis has been modified.     *     * @param paint the new crosshair paint.     */    public void setRangeCrosshairPaint(Paint paint) {        this.rangeCrosshairPaint = paint;        notifyListeners(new PlotChangeEvent(this));    }    /**     * Returns the tool tip generator.     *     * @return The tool tip generator (possibly null).     */    public ContourToolTipGenerator getToolTipGenerator() {        return this.toolTipGenerator;    }    /**     * Sets the tool tip generator.     *     * @param generator  the tool tip generator (null permitted).     */    public void setToolTipGenerator(ContourToolTipGenerator generator) {        //Object oldValue = this.toolTipGenerator;        this.toolTipGenerator = generator;    }    /**     * Returns the URL generator for HTML image maps.     *     * @return The URL generator (possibly null).     */    public XYURLGenerator getURLGenerator() {        return this.urlGenerator;    }    /**     * Sets the URL generator for HTML image maps.     *     * @param urlGenerator  the URL generator (null permitted).     */    public void setURLGenerator(XYURLGenerator urlGenerator) {        //Object oldValue = this.urlGenerator;        this.urlGenerator = urlGenerator;    }    /**     * Draws a vertical line on the chart to represent a 'range marker'.     *     * @param g2  the graphics device.     * @param plot  the plot.     * @param domainAxis  the domain axis.     * @param marker  the marker line.     * @param dataArea  the axis data area.     */    public void drawDomainMarker(Graphics2D g2,                                 ContourPlot plot,                                 ValueAxis domainAxis,                                 Marker marker,                                 Rectangle2D dataArea) {        if (marker instanceof ValueMarker) {            ValueMarker vm = (ValueMarker) marker;            double value = vm.getValue();            Range range = domainAxis.getRange();            if (!range.contains(value)) {                return;            }              double x = domainAxis.valueToJava2D(                value, dataArea, RectangleEdge.BOTTOM            );            Line2D line = new Line2D.Double(                x, dataArea.getMinY(), x, dataArea.getMaxY()            );            Paint paint = marker.getOutlinePaint();            Stroke stroke = marker.getOutlineStroke();            g2.setPaint(paint != null ? paint : Plot.DEFAULT_OUTLINE_PAINT);            g2.setStroke(stroke != null ? stroke : Plot.DEFAULT_OUTLINE_STROKE);            g2.draw(line);        }    }    /**     * Draws a horizontal line across the chart to represent a 'range marker'.     *     * @param g2  the graphics device.     * @param plot  the plot.     * @param rangeAxis  the range axis.     * @param marker  the marker line.     * @param dataArea  the axis data area.     */    public void drawRangeMarker(Graphics2D g2,                                ContourPlot plot,                                ValueAxis rangeAxis,                                Marker marker,                                Rectangle2D dataArea) {        if (marker instanceof ValueMarker) {            ValueMarker vm = (ValueMarker) marker;            double value = vm.getValue();            Range range = rangeAxis.getRange();            if (!range.contains(value)) {                return;            }            double y = rangeAxis.valueToJava2D(                value, dataArea, RectangleEdge.LEFT            );            Line2D line = new Line2D.Double(                dataArea.getMinX(), y, dataArea.getMaxX(), y            );            Paint paint = marker.getOutlinePaint();            Stroke stroke = marker.getOutlineStroke();            g2.setPaint(paint != null ? paint : Plot.DEFAULT_OUTLINE_PAINT);            g2.setStroke(stroke != null ? stroke : Plot.DEFAULT_OUTLINE_STROKE);            g2.draw(line);        }    }    /**     * Returns the clipPath.     * @return ClipPath     */    public ClipPath getClipPath() {        return this.clipPath;    }    /**     * Sets the clipPath.     * @param clipPath The clipPath to set     */    public void setClipPath(ClipPath clipPath) {        this.clipPath = clipPath;    }    /**     * Returns the ptSizePct.     * @return double     */    public double getPtSizePct() {        return this.ptSizePct;    }    /**     * Returns the renderAsPoints.     * @return boolean     */    public boolean isRenderAsPoints() {        return this.renderAsPoints;    }    /**     * Sets the ptSizePct.     * @param ptSizePct The ptSizePct to set     */    public void setPtSizePct(double ptSizePct) {        this.ptSizePct = ptSizePct;    }    /**     * Sets the renderAsPoints.     * @param renderAsPoints The renderAsPoints to set     */    public void setRenderAsPoints(boolean renderAsPoints) {        this.renderAsPoints = renderAsPoints;    }    /**     * Receives notification of a change to one of the plot's axes.     *     * @param event  information about the event.     */    public void axisChanged(AxisChangeEvent event) {        Object source = event.getSource();        if (source.equals(this.rangeAxis) || source.equals(this.domainAxis)) {            ColorBar cba = this.colorBar;            if (this.colorBar.getAxis().isAutoRange()) {                cba.getAxis().configure();            }        }        super.axisChanged(event);    }    /**     * Returns the visible z-range.     *     * @param data  the dataset.     * @param x  the x range.     * @param y  the y range.     *     * @return The range.     */    public Range visibleRange(ContourDataset data, Range x, Range y) {        Range range = null;        range = data.getZValueRange(x, y);        return range;    }    /**     * Returns the missingPaint.     * @return Paint     */    public Paint getMissingPaint() {        return this.missingPaint;    }    /**     * Sets the missingPaint.     *      * @param paint  the missingPaint to set.     */    public void setMissingPaint(Paint paint) {        this.missingPaint = paint;    }        /**     * Multiplies the range on the domain axis/axes by the specified factor      * (to be implemented).     *      * @param x  the x-coordinate (in Java2D space).     * @param y  the y-coordinate (in Java2D space).     * @param factor  the zoom factor.     */    public void zoomDomainAxes(double x, double y, double factor) {        // TODO: to be implemented    }        /**     * Zooms the domain axes (not yet implemented).     *      * @param x  the x-coordinate (in Java2D space).     * @param y  the y-coordinate (in Java2D space).     * @param lowerPercent  the new lower bound.     * @param upperPercent  the new upper bound.     */    public void zoomDomainAxes(double x, double y, double lowerPercent,                                double upperPercent) {        // TODO: to be implemented    }        /**     * Multiplies the range on the range axis/axes by the specified factor.     *      * @param x  the x-coordinate (in Java2D space).     * @param y  the y-coordinate (in Java2D space).     * @param factor  the zoom factor.     */    public void zoomRangeAxes(double x, double y, double factor) {        // TODO: to be implemented    }    /**     * Zooms the range axes (not yet implemented).     *      * @param x  the x-coordinate (in Java2D space).     * @param y  the y-coordinate (in Java2D space).     * @param lowerPercent  the new lower bound.     * @param upperPercent  the new upper bound.     */    public void zoomRangeAxes(double x, double y, double lowerPercent,                               double upperPercent) {        // TODO: to be implemented    }    /**     * Returns <code>false</code>.     *      * @return A boolean.     */    public boolean isDomainZoomable() {        return false;    }        /**     * Returns <code>false</code>.     *      * @return A boolean.     */    public boolean isRangeZoomable() {        return false;    }    /**      * Extends plot cloning to this plot type     * @see org.jfree.chart.plot.Plot#clone()     */    public Object clone() throws CloneNotSupportedException {        ContourPlot clone = (ContourPlot) super.clone();                if (this.domainAxis != null) {            clone.domainAxis = (ValueAxis) this.domainAxis.clone();            clone.domainAxis.setPlot(clone);            clone.domainAxis.addChangeListener(clone);        }        if (this.rangeAxis != null) {            clone.rangeAxis = (ValueAxis) this.rangeAxis.clone();            clone.rangeAxis.setPlot(clone);            clone.rangeAxis.addChangeListener(clone);        }        if (clone.dataset != null) {            clone.dataset.addChangeListener(clone);         }            if (this.colorBar != null) {            clone.colorBar = (ColorBar) this.colorBar.clone();        }        clone.domainMarkers = (List) ObjectUtilities.deepClone(            this.domainMarkers        );        clone.rangeMarkers = (List) ObjectUtilities.deepClone(            this.rangeMarkers        );        clone.annotations = (List) ObjectUtilities.deepClone(this.annotations);        if (this.clipPath != null) {            clone.clipPath = (ClipPath) this.clipPath.clone();         }        return clone;    }}

⌨️ 快捷键说明

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