当前位置: 首页>>代码示例>>Java>>正文


Java PlotOrientation.HORIZONTAL属性代码示例

本文整理汇总了Java中org.jfree.chart.plot.PlotOrientation.HORIZONTAL属性的典型用法代码示例。如果您正苦于以下问题:Java PlotOrientation.HORIZONTAL属性的具体用法?Java PlotOrientation.HORIZONTAL怎么用?Java PlotOrientation.HORIZONTAL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.jfree.chart.plot.PlotOrientation的用法示例。


在下文中一共展示了PlotOrientation.HORIZONTAL属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createCategoryDomainAxis

public static CategoryAxis createCategoryDomainAxis(PlotConfiguration plotConfiguration) {
	CategoryAxis domainAxis = new CategoryAxis(null);
	String label = plotConfiguration.getDomainConfigManager().getLabel();
	if (label == null) {
		label = I18N.getGUILabel("plotter.unnamed_value_label");
	}
	domainAxis.setLabel(label);

	Font axesFont = plotConfiguration.getAxesFont();
	if (axesFont != null) {
		domainAxis.setLabelFont(axesFont);
		domainAxis.setTickLabelFont(axesFont);
	}

	// rotate labels
	if (plotConfiguration.getOrientation() != PlotOrientation.HORIZONTAL) {
		domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0d));
	}

	formatAxis(plotConfiguration, domainAxis);
	return domainAxis;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:22,代码来源:ChartAxisFactory.java

示例2: restrictValueToDataArea

/**
 * Helper method which returns a value if it lies
 * inside the visible dataArea and otherwise the corresponding
 * coordinate on the border of the dataArea. The PlotOrientation
 * is taken into account. 
 * Useful to avoid possible sun.dc.pr.PRException: endPath: bad path
 * which occurs when trying to draw lines/shapes which in large part
 * lie outside of the visible dataArea.
 * 
 * @param value the value which shall be 
 * @param dataArea  the area within which the data is being drawn.
 * @param plot  the plot (can be used to obtain standard color information etc).
 * @return <code>double</code> value inside the data area.
 */
protected static double restrictValueToDataArea(double value, 
                                                XYPlot plot, 
                                                Rectangle2D dataArea) {
    double min = 0;
    double max = 0;
    if (plot.getOrientation() == PlotOrientation.VERTICAL) {
        min = dataArea.getMinY();
        max = dataArea.getMaxY();
    } 
    else if (plot.getOrientation() ==  PlotOrientation.HORIZONTAL) {
        min = dataArea.getMinX();
        max = dataArea.getMaxX();
    }       
    if (value < min) {
        value = min;
    }
    else if (value > max) {
        value = max;
    }
    return value;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:35,代码来源:XYStepAreaRenderer.java

示例3: calculateBarWidth

/**
 * Calculates the bar width and stores it in the renderer state.
 * 
 * @param plot  the plot.
 * @param dataArea  the data area.
 * @param rendererIndex  the renderer index.
 * @param state  the renderer state.
 */
protected void calculateBarWidth(CategoryPlot plot, 
                                 Rectangle2D dataArea, 
                                 int rendererIndex,
                                 CategoryItemRendererState state) {

    // calculate the bar width
    CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex);
    CategoryDataset data = plot.getDataset(rendererIndex);
    if (data != null) {
        PlotOrientation orientation = plot.getOrientation();
        double space = 0.0;
        if (orientation == PlotOrientation.HORIZONTAL) {
            space = dataArea.getHeight();
        }
        else if (orientation == PlotOrientation.VERTICAL) {
            space = dataArea.getWidth();
        }
        double maxWidth = space * getMaxBarWidth();
        int columns = data.getColumnCount();
        double categoryMargin = 0.0;
        if (columns > 1) {
            categoryMargin = domainAxis.getCategoryMargin();
        }

        double used = space * (1 - domainAxis.getLowerMargin() - domainAxis.getUpperMargin()
                                 - categoryMargin);
        if (columns > 0) {
            state.setBarWidth(Math.min(used / columns, maxWidth));
        }
        else {
            state.setBarWidth(Math.min(used, maxWidth));
        }
    }

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:43,代码来源:StackedBarRenderer3D.java

示例4: draw

/**
* Draws the annotation.  This method is usually called by the {@link XYPlot} class, you 
* shouldn't need to call it directly.
*
* @param g2  the graphics device.
* @param plot  the plot.
* @param dataArea  the data area.
* @param domainAxis  the domain axis.
* @param rangeAxis  the range axis.
*/
public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea,
                 ValueAxis domainAxis, ValueAxis rangeAxis) {

    PlotOrientation orientation = plot.getOrientation();
    RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(
        plot.getDomainAxisLocation(), orientation
    );
    RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(
        plot.getRangeAxisLocation(), orientation
    );

    //compute transform matrix elements via sample points. Assume no rotation or shear.
    // x-axis translation
    double m02 = domainAxis.valueToJava2D(0, dataArea, domainEdge); 
    // y-axis translation
    double m12 = rangeAxis.valueToJava2D(0, dataArea, rangeEdge);
    // x-axis scale 
    double m00 = domainAxis.valueToJava2D(1, dataArea, domainEdge) - m02; 
    // y-axis scale
    double m11 = rangeAxis.valueToJava2D(1, dataArea, rangeEdge) - m12; 

    //create transform & transform shape
    Shape s = null;
    if (orientation == PlotOrientation.HORIZONTAL) {
        AffineTransform t1 = new AffineTransform(0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f);
        AffineTransform t2 = new AffineTransform(m11, 0.0f, 0.0f, m00, m12, m02);
        s = t1.createTransformedShape(this.shape);
        s = t2.createTransformedShape(s);
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        AffineTransform t = new AffineTransform(m00, 0, 0, m11, m02, m12);
        s = t.createTransformedShape(this.shape);
    }

    g2.setPaint(this.paint);
    g2.setStroke(this.stroke);
    g2.draw(s);
    
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:49,代码来源:XYShapeAnnotation.java

示例5: draw

/**
 * Draws the annotation.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param dataArea  the data area.
 * @param domainAxis  the domain axis.
 * @param rangeAxis  the range axis.
 */
public void draw(Graphics2D g2, CategoryPlot plot, Rectangle2D dataArea,
                 CategoryAxis domainAxis, ValueAxis rangeAxis) {

    CategoryDataset dataset = plot.getDataset();
    int catIndex = dataset.getColumnIndex(this.category);
    int catCount = dataset.getColumnCount();

    float anchorX = 0.0f;
    float anchorY = 0.0f;
    PlotOrientation orientation = plot.getOrientation();
    RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(
            plot.getDomainAxisLocation(), orientation);
    RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(
            plot.getRangeAxisLocation(), orientation);
    
    if (orientation == PlotOrientation.HORIZONTAL) {
        anchorY = (float) domainAxis.getCategoryJava2DCoordinate(
                this.categoryAnchor, catIndex, catCount, dataArea, 
                domainEdge);
        anchorX = (float) rangeAxis.valueToJava2D(this.value, dataArea, 
                rangeEdge);
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        anchorX = (float) domainAxis.getCategoryJava2DCoordinate(
                this.categoryAnchor, catIndex, catCount, dataArea, 
                domainEdge);
        anchorY = (float) rangeAxis.valueToJava2D(this.value, dataArea, 
                rangeEdge);
    }
    g2.setFont(getFont());
    g2.setPaint(getPaint());
    TextUtilities.drawRotatedString(getText(), g2, anchorX, anchorY,
            getTextAnchor(), getRotationAngle(), getRotationAnchor());

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:44,代码来源:CategoryTextAnnotation.java

示例6: calculateBarWidth

/**
 * Calculates the bar width and stores it in the renderer state.
 * 
 * @param plot  the plot.
 * @param dataArea  the data area.
 * @param rendererIndex  the renderer index.
 * @param state  the renderer state.
 */
protected void calculateBarWidth(CategoryPlot plot, 
                                 Rectangle2D dataArea, 
                                 int rendererIndex,
                                 CategoryItemRendererState state) {

    // calculate the bar width - this calculation differs from the
    // BarRenderer calculation because the bars are layered on top of one
    // another, so there is effectively only one bar per category for
    // the purpose of the bar width calculation
    CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex);
    CategoryDataset dataset = plot.getDataset(rendererIndex);
    if (dataset != null) {
        int columns = dataset.getColumnCount();
        int rows = dataset.getRowCount();
        double space = 0.0;
        PlotOrientation orientation = plot.getOrientation();
        if (orientation == PlotOrientation.HORIZONTAL) {
            space = dataArea.getHeight();
        }
        else if (orientation == PlotOrientation.VERTICAL) {
            space = dataArea.getWidth();
        }
        double maxWidth = space * getMaximumBarWidth();
        double categoryMargin = 0.0;
        if (columns > 1) {
            categoryMargin = domainAxis.getCategoryMargin();
        }
        double used = space * (1 - domainAxis.getLowerMargin() 
            - domainAxis.getUpperMargin() - categoryMargin);
        if ((rows * columns) > 0) {
            state.setBarWidth(Math.min(used / (dataset.getColumnCount()), 
                    maxWidth));
        } 
        else {
            state.setBarWidth(Math.min(used, maxWidth));
        }
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:46,代码来源:LayeredBarRenderer.java

示例7: calculateBarW0

/**
 * Calculates the coordinate of the first "side" of a bar.  This will be the minimum 
 * x-coordinate for a vertical bar, and the minimum y-coordinate for a horizontal bar.
 * 
 * @param plot  the plot.
 * @param orientation  the plot orientation.
 * @param dataArea  the data area.
 * @param domainAxis  the domain axis.
 * @param state  the renderer state (has the bar width precalculated).
 * @param row  the row index.
 * @param column  the column index.
 * 
 * @return the coordinate.
 */
protected double calculateBarW0(CategoryPlot plot, 
                                PlotOrientation orientation, 
                                Rectangle2D dataArea,
                                CategoryAxis domainAxis,
                                CategoryItemRendererState state,
                                int row,
                                int column) {
    // calculate bar width...
    double space = 0.0;
    if (orientation == PlotOrientation.HORIZONTAL) {
        space = dataArea.getHeight();
    }
    else {
        space = dataArea.getWidth();
    }
    double barW0 = domainAxis.getCategoryStart(
        column, getColumnCount(), dataArea, plot.getDomainAxisEdge()
    );
    int groupCount = this.seriesToGroupMap.getGroupCount();
    int groupIndex = this.seriesToGroupMap.getGroupIndex(
        this.seriesToGroupMap.getGroup(plot.getDataset().getRowKey(row))
    );
    int categoryCount = getColumnCount();
    if (groupCount > 1) {
        double groupGap = space * getItemMargin() / (categoryCount * (groupCount - 1));
        double groupW = calculateSeriesWidth(space, domainAxis, categoryCount, groupCount);
        barW0 = barW0 + groupIndex * (groupW + groupGap) 
                      + (groupW / 2.0) - (state.getBarWidth() / 2.0);
    }
    else {
        barW0 = domainAxis.getCategoryMiddle(
            column, getColumnCount(), dataArea, plot.getDomainAxisEdge()
        ) - state.getBarWidth() / 2.0;
    }
    return barW0;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:50,代码来源:GroupedStackedBarRenderer.java

示例8: calculateItemWidth

/**
 * Calculates the bar width and stores it in the renderer state.
 * 
 * @param plot  the plot.
 * @param dataArea  the data area.
 * @param rendererIndex  the renderer index.
 * @param state  the renderer state.
 */
protected void calculateItemWidth(CategoryPlot plot, 
                                  Rectangle2D dataArea, 
                                  int rendererIndex,
                                  CategoryItemRendererState state) {
                                     
    CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex);
    CategoryDataset dataset = plot.getDataset(rendererIndex);
    if (dataset != null) {
        int columns = dataset.getColumnCount();
        int rows = dataset.getRowCount();
        double space = 0.0;
        PlotOrientation orientation = plot.getOrientation();
        if (orientation == PlotOrientation.HORIZONTAL) {
            space = dataArea.getHeight();
        }
        else if (orientation == PlotOrientation.VERTICAL) {
            space = dataArea.getWidth();
        }
        double maxWidth = space * getMaxItemWidth();
        double categoryMargin = 0.0;
        double currentItemMargin = 0.0;
        if (columns > 1) {
            categoryMargin = domainAxis.getCategoryMargin();
        }
        if (rows > 1) {
            currentItemMargin = getItemMargin();
        }
        double used = space * (1 - domainAxis.getLowerMargin() 
                                 - domainAxis.getUpperMargin()
                                 - categoryMargin - currentItemMargin);
        if ((rows * columns) > 0) {
            state.setBarWidth(Math.min(used / (rows * columns), maxWidth));
        }
        else {
            state.setBarWidth(Math.min(used, maxWidth));
        }
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:46,代码来源:LevelRenderer.java

示例9: calculateBarW0

/**
 * Calculates the coordinate of the first "side" of a bar.  This will be 
 * the minimum x-coordinate for a vertical bar, and the minimum 
 * y-coordinate for a horizontal bar.
 *
 * @param plot  the plot.
 * @param orientation  the plot orientation.
 * @param dataArea  the data area.
 * @param domainAxis  the domain axis.
 * @param state  the renderer state (has the bar width precalculated).
 * @param row  the row index.
 * @param column  the column index.
 * 
 * @return The coordinate.
 */
protected double calculateBarW0(CategoryPlot plot, 
                                PlotOrientation orientation, 
                                Rectangle2D dataArea,
                                CategoryAxis domainAxis,
                                CategoryItemRendererState state,
                                int row,
                                int column) {
    // calculate bar width...
    double space = 0.0;
    if (orientation == PlotOrientation.HORIZONTAL) {
        space = dataArea.getHeight();
    }
    else {
        space = dataArea.getWidth();
    }
    double barW0 = domainAxis.getCategoryStart(column, getColumnCount(), 
            dataArea, plot.getDomainAxisEdge());
    int seriesCount = getRowCount();
    int categoryCount = getColumnCount();
    if (seriesCount > 1) {
        double seriesGap = space * getItemMargin() 
                           / (categoryCount * (seriesCount - 1));
        double seriesW = calculateSeriesWidth(space, domainAxis, 
                categoryCount, seriesCount);
        barW0 = barW0 + row * (seriesW + seriesGap) 
                      + (seriesW / 2.0) - (state.getBarWidth() / 2.0);
    }
    else {
        barW0 = domainAxis.getCategoryMiddle(column, getColumnCount(), 
                dataArea, plot.getDomainAxisEdge()) - state.getBarWidth() 
                / 2.0;
    }
    return barW0;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:49,代码来源:BarRenderer.java

示例10: drawDomainGridLine

/**
 * Draws a grid line against the range axis.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param axis  the value axis.
 * @param dataArea  the area for plotting data (not yet adjusted for any 3D effect).
 * @param value  the value at which the grid line should be drawn.
 *
 */
public void drawDomainGridLine(Graphics2D g2,
                               XYPlot plot,
                               ValueAxis axis,
                               Rectangle2D dataArea,
                               double value) {

    Range range = axis.getRange();
    if (!range.contains(value)) {
        return;
    }

    PlotOrientation orientation = plot.getOrientation();
    double v = axis.valueToJava2D(value, dataArea, plot.getDomainAxisEdge());
    Line2D line = null;
    if (orientation == PlotOrientation.HORIZONTAL) {
        line = new Line2D.Double(dataArea.getMinX(), v, dataArea.getMaxX(), v);
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        line = new Line2D.Double(v, dataArea.getMinY(), v, dataArea.getMaxY());
    }

    Paint paint = plot.getDomainGridlinePaint();
    Stroke stroke = plot.getDomainGridlineStroke();
    g2.setPaint(paint != null ? paint : Plot.DEFAULT_OUTLINE_PAINT);
    g2.setStroke(stroke != null ? stroke : Plot.DEFAULT_OUTLINE_STROKE);
    g2.draw(line);

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:38,代码来源:AbstractXYItemRenderer.java

示例11: attemptOrientationSelection

/**
 * Allow the user to modify the plot orientation if this is an editor for a
 * <tt>CategoryPlot</tt> or a <tt>XYPlot</tt>.
 */
private void attemptOrientationSelection() {

    int index = this.orientationCombo.getSelectedIndex();

    if (index == ORIENTATION_VERTICAL) {
        this.plotOrientation = PlotOrientation.VERTICAL;
    }
    else {
        this.plotOrientation = PlotOrientation.HORIZONTAL;
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:15,代码来源:DefaultPlotEditor.java

示例12: calculateBarW0

/**
 * Calculates the coordinate of the first "side" of a bar.  This will be the minimum 
 * x-coordinate for a vertical bar, and the minimum y-coordinate for a horizontal bar.
 * 
 * @param plot  the plot.
 * @param orientation  the plot orientation.
 * @param dataArea  the data area.
 * @param domainAxis  the domain axis.
 * @param state  the renderer state (has the bar width precalculated).
 * @param row  the row index.
 * @param column  the column index.
 * 
 * @return the coordinate.
 */
protected double calculateBarW0(CategoryPlot plot, 
                                PlotOrientation orientation, 
                                Rectangle2D dataArea,
                                CategoryAxis domainAxis,
                                CategoryItemRendererState state,
                                int row,
                                int column) {
    // calculate bar width...
    double space = 0.0;
    if (orientation == PlotOrientation.HORIZONTAL) {
        space = dataArea.getHeight();
    }
    else {
        space = dataArea.getWidth();
    }
    double barW0 = domainAxis.getCategoryStart(column, getColumnCount(), dataArea,
                                               plot.getDomainAxisEdge());
    int seriesCount = getRowCount();
    int categoryCount = getColumnCount();
    if (seriesCount > 1) {
        double seriesGap = space * getItemMargin() / (categoryCount * (seriesCount - 1));
        double seriesW = calculateSeriesWidth(space, domainAxis, categoryCount, seriesCount);
        barW0 = barW0 + row * (seriesW + seriesGap) 
                      + (seriesW / 2.0) - (state.getBarWidth() / 2.0);
    }
    else {
        barW0 = domainAxis.getCategoryMiddle(column, getColumnCount(), dataArea,
                                             plot.getDomainAxisEdge())
                - state.getBarWidth() / 2.0;
    }
    return barW0;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:46,代码来源:LevelRenderer.java

示例13: drawRangeGridline

/**
 * Draws a grid line against the range axis.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param axis  the value axis.
 * @param dataArea  the area for plotting data (not yet adjusted for any 3D effect).
 * @param value  the value at which the grid line should be drawn.
 *
 */
public void drawRangeGridline(Graphics2D g2,
                              CategoryPlot plot,
                              ValueAxis axis,
                              Rectangle2D dataArea,
                              double value) {

    Range range = axis.getRange();
    if (!range.contains(value)) {
        return;
    }

    PlotOrientation orientation = plot.getOrientation();
    double v = axis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge());
    Line2D line = null;
    if (orientation == PlotOrientation.HORIZONTAL) {
        line = new Line2D.Double(v, dataArea.getMinY(), v, dataArea.getMaxY());
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        line = new Line2D.Double(dataArea.getMinX(), v, dataArea.getMaxX(), v);
    }

    Paint paint = plot.getRangeGridlinePaint();
    if (paint == null) {
        paint = CategoryPlot.DEFAULT_GRIDLINE_PAINT;
    }
    g2.setPaint(paint);

    Stroke stroke = plot.getRangeGridlineStroke();
    if (stroke == null) {
        stroke = CategoryPlot.DEFAULT_GRIDLINE_STROKE;
    }
    g2.setStroke(stroke);

    g2.draw(line);

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:46,代码来源:AbstractCategoryItemRenderer.java

示例14: drawItem

/**
 * 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 (horizontal) axis.
 * @param rangeAxis  the range (vertical) 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) {

    // get the data point...
    double x = dataset.getXValue(series, item);
    double y = dataset.getYValue(series, item);
    double adjx = (this.dotWidth - 1) / 2.0;
    double adjy = (this.dotHeight - 1) / 2.0;
    if (!Double.isNaN(y)) {
        RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
        RectangleEdge yAxisLocation = plot.getRangeAxisEdge();
        double transX = domainAxis.valueToJava2D(x, dataArea, 
                xAxisLocation) - adjx;
        double transY = rangeAxis.valueToJava2D(y, dataArea, yAxisLocation) 
                - adjy;

        g2.setPaint(getItemPaint(series, item));
        PlotOrientation orientation = plot.getOrientation();
        if (orientation == PlotOrientation.HORIZONTAL) {
            g2.fillRect((int) transY, (int) transX, this.dotHeight, 
                    this.dotWidth);
        }
        else if (orientation == PlotOrientation.VERTICAL) {
            g2.fillRect((int) transX, (int) transY, this.dotWidth, 
                    this.dotHeight);
        }

        int domainAxisIndex = plot.getDomainAxisIndex(domainAxis);
        int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis);
        updateCrosshairValues(crosshairState, x, y, domainAxisIndex, 
                rangeAxisIndex, transX, transY, orientation);
    }

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:62,代码来源:XYDotRenderer.java

示例15: mouseReleased

/**
 * Handles a 'mouse released' event. On Windows, we need to check if this is a popup trigger,
 * but only if we haven't already been tracking a zoom rectangle.
 * 
 * @param e
 *            information about the event.
 */

@Override
public void mouseReleased(MouseEvent e) {
	// if we've been panning, we need to reset now that the mouse is
	// released...
	if (this.panLast != null) {
		this.panLast = null;
		setCursor(Cursor.getDefaultCursor());
	} else if (this.selectionRectangle != null) {
		boolean hZoom = false;
		boolean vZoom = false;
		if (this.orientation == PlotOrientation.HORIZONTAL) {
			hZoom = this.rangeZoomable;
			vZoom = this.domainZoomable;
		} else {
			hZoom = this.domainZoomable;
			vZoom = this.rangeZoomable;
		}

		boolean zoomTrigger1 = hZoom && Math.abs(e.getX() - this.zoomPoint.getX()) >= this.zoomTriggerDistance;
		boolean zoomTrigger2 = vZoom && Math.abs(e.getY() - this.zoomPoint.getY()) >= this.zoomTriggerDistance;
		if (zoomTrigger1 || zoomTrigger2) {
			if (hZoom && e.getX() < this.zoomPoint.getX() || vZoom && e.getY() < this.zoomPoint.getY()) {
				restoreAutoBounds();
			} else {
				double x, y, w, h;
				Rectangle2D screenDataArea = getScreenDataArea((int) this.zoomPoint.getX(), (int) this.zoomPoint.getY());
				double maxX = screenDataArea.getMaxX();
				double maxY = screenDataArea.getMaxY();
				// for mouseReleased event, (horizontalZoom || verticalZoom)
				// will be true, so we can just test for either being false;
				// otherwise both are true
				if (!vZoom) {
					x = this.zoomPoint.getX();
					y = screenDataArea.getMinY();
					w = Math.min(this.selectionRectangle.getWidth(), maxX - this.zoomPoint.getX());
					h = screenDataArea.getHeight();
				} else if (!hZoom) {
					x = screenDataArea.getMinX();
					y = this.zoomPoint.getY();
					w = screenDataArea.getWidth();
					h = Math.min(this.selectionRectangle.getHeight(), maxY - this.zoomPoint.getY());
				} else {
					x = this.zoomPoint.getX();
					y = this.zoomPoint.getY();
					w = Math.min(this.selectionRectangle.getWidth(), maxX - this.zoomPoint.getX());
					h = Math.min(this.selectionRectangle.getHeight(), maxY - this.zoomPoint.getY());
				}
				Rectangle2D zoomArea = new Rectangle2D.Double(x, y, w, h);
				selectRectangle(zoomArea, e);
			}
			this.zoomPoint = null;
			this.selectionRectangle = null;
		} else {
			this.zoomPoint = null;
			this.selectionRectangle = null;
		}

	}

	else if (e.isPopupTrigger()) {
		if (this.popup != null) {
			displayPopupMenu(e.getX(), e.getY());
		}
	}

}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:74,代码来源:AbstractChartPanel.java


注:本文中的org.jfree.chart.plot.PlotOrientation.HORIZONTAL属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。