Java Code Examples for org.jfree.chart.axis.ValueAxis#reserveSpace()

The following examples show how to use org.jfree.chart.axis.ValueAxis#reserveSpace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CombinedRangeCategoryPlot.java    From ECG-Viewer with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Calculates the space required for the axes.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 *
 * @return The space required for the axes.
 */
@Override
protected AxisSpace calculateAxisSpace(Graphics2D g2, 
        Rectangle2D plotArea) {

    AxisSpace space = new AxisSpace();
    PlotOrientation orientation = getOrientation();

    // work out the space required by the domain axis...
    AxisSpace fixed = getFixedRangeAxisSpace();
    if (fixed != null) {
        if (orientation == PlotOrientation.VERTICAL) {
            space.setLeft(fixed.getLeft());
            space.setRight(fixed.getRight());
        }
        else if (orientation == PlotOrientation.HORIZONTAL) {
            space.setTop(fixed.getTop());
            space.setBottom(fixed.getBottom());
        }
    }
    else {
        ValueAxis valueAxis = getRangeAxis();
        RectangleEdge valueEdge = Plot.resolveRangeAxisLocation(
                getRangeAxisLocation(), orientation);
        if (valueAxis != null) {
            space = valueAxis.reserveSpace(g2, this, plotArea, valueEdge,
                    space);
        }
    }

    Rectangle2D adjustedPlotArea = space.shrink(plotArea, null);
    // work out the maximum height or width of the non-shared axes...
    int n = this.subplots.size();
    int totalWeight = 0;
    for (int i = 0; i < n; i++) {
        CategoryPlot sub = (CategoryPlot) this.subplots.get(i);
        totalWeight += sub.getWeight();
    }
    // calculate plotAreas of all sub-plots, maximum vertical/horizontal
    // axis width/height
    this.subplotArea = new Rectangle2D[n];
    double x = adjustedPlotArea.getX();
    double y = adjustedPlotArea.getY();
    double usableSize = 0.0;
    if (orientation == PlotOrientation.VERTICAL) {
        usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1);
    }
    else if (orientation == PlotOrientation.HORIZONTAL) {
        usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1);
    }

    for (int i = 0; i < n; i++) {
        CategoryPlot plot = (CategoryPlot) this.subplots.get(i);

        // calculate sub-plot area
        if (orientation == PlotOrientation.VERTICAL) {
            double w = usableSize * plot.getWeight() / totalWeight;
            this.subplotArea[i] = new Rectangle2D.Double(x, y, w,
                    adjustedPlotArea.getHeight());
            x = x + w + this.gap;
        }
        else if (orientation == PlotOrientation.HORIZONTAL) {
            double h = usableSize * plot.getWeight() / totalWeight;
            this.subplotArea[i] = new Rectangle2D.Double(x, y,
                    adjustedPlotArea.getWidth(), h);
            y = y + h + this.gap;
        }

        AxisSpace subSpace = plot.calculateDomainAxisSpace(g2,
                this.subplotArea[i], null);
        space.ensureAtLeast(subSpace);

    }

    return space;
}
 
Example 2
Source File: CombinedRangeCategoryPlot.java    From opensim-gui with Apache License 2.0 4 votes vote down vote up
/**
 * Calculates the space required for the axes.
 * 
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 * 
 * @return The space required for the axes.
 */
protected AxisSpace calculateAxisSpace(Graphics2D g2, 
                                       Rectangle2D plotArea) {
    
    AxisSpace space = new AxisSpace();  
    PlotOrientation orientation = getOrientation();
    
    // work out the space required by the domain axis...
    AxisSpace fixed = getFixedRangeAxisSpace();
    if (fixed != null) {
        if (orientation == PlotOrientation.VERTICAL) {
            space.setLeft(fixed.getLeft());
            space.setRight(fixed.getRight());
        }
        else if (orientation == PlotOrientation.HORIZONTAL) {
            space.setTop(fixed.getTop());
            space.setBottom(fixed.getBottom());                
        }
    }
    else {
        ValueAxis valueAxis = getRangeAxis();
        RectangleEdge valueEdge = Plot.resolveRangeAxisLocation(
                getRangeAxisLocation(), orientation);
        if (valueAxis != null) {
            space = valueAxis.reserveSpace(g2, this, plotArea, valueEdge, 
                    space);
        }
    }
    
    Rectangle2D adjustedPlotArea = space.shrink(plotArea, null);
    // work out the maximum height or width of the non-shared axes...
    int n = this.subplots.size();

    // calculate plotAreas of all sub-plots, maximum vertical/horizontal 
    // axis width/height
    this.subplotArea = new Rectangle2D[n];
    double x = adjustedPlotArea.getX();
    double y = adjustedPlotArea.getY();
    double usableSize = 0.0;
    if (orientation == PlotOrientation.VERTICAL) {
        usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1);
    }
    else if (orientation == PlotOrientation.HORIZONTAL) {
        usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1);
    }

    for (int i = 0; i < n; i++) {
        CategoryPlot plot = (CategoryPlot) this.subplots.get(i);

        // calculate sub-plot area
        if (orientation == PlotOrientation.VERTICAL) {
            double w = usableSize * plot.getWeight() / this.totalWeight;
            this.subplotArea[i] = new Rectangle2D.Double(x, y, w, 
                    adjustedPlotArea.getHeight());
            x = x + w + this.gap;
        }
        else if (orientation == PlotOrientation.HORIZONTAL) {
            double h = usableSize * plot.getWeight() / this.totalWeight;
            this.subplotArea[i] = new Rectangle2D.Double(x, y, 
                    adjustedPlotArea.getWidth(), h);
            y = y + h + this.gap;
        }

        AxisSpace subSpace = plot.calculateDomainAxisSpace(g2, 
                this.subplotArea[i], null);
        space.ensureAtLeast(subSpace);

    }

    return space;
}
 
Example 3
Source File: CombinedRangeXYPlot.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Calculates the space required for the axes.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 *
 * @return The space required for the axes.
 */
@Override
protected AxisSpace calculateAxisSpace(Graphics2D g2,
                                       Rectangle2D plotArea) {

    AxisSpace space = new AxisSpace();
    PlotOrientation orientation = getOrientation();

    // work out the space required by the domain axis...
    AxisSpace fixed = getFixedRangeAxisSpace();
    if (fixed != null) {
        if (orientation == PlotOrientation.VERTICAL) {
            space.setLeft(fixed.getLeft());
            space.setRight(fixed.getRight());
        }
        else if (orientation == PlotOrientation.HORIZONTAL) {
            space.setTop(fixed.getTop());
            space.setBottom(fixed.getBottom());
        }
    }
    else {
        ValueAxis valueAxis = getRangeAxis();
        RectangleEdge valueEdge = Plot.resolveRangeAxisLocation(
            getRangeAxisLocation(), orientation
        );
        if (valueAxis != null) {
            space = valueAxis.reserveSpace(g2, this, plotArea, valueEdge,
                    space);
        }
    }

    Rectangle2D adjustedPlotArea = space.shrink(plotArea, null);
    // work out the maximum height or width of the non-shared axes...
    int n = this.subplots.size();
    int totalWeight = 0;
    for (int i = 0; i < n; i++) {
        XYPlot sub = (XYPlot) this.subplots.get(i);
        totalWeight += sub.getWeight();
    }

    // calculate plotAreas of all sub-plots, maximum vertical/horizontal
    // axis width/height
    this.subplotAreas = new Rectangle2D[n];
    double x = adjustedPlotArea.getX();
    double y = adjustedPlotArea.getY();
    double usableSize = 0.0;
    if (orientation == PlotOrientation.VERTICAL) {
        usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1);
    }
    else if (orientation == PlotOrientation.HORIZONTAL) {
        usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1);
    }

    for (int i = 0; i < n; i++) {
        XYPlot plot = (XYPlot) this.subplots.get(i);

        // calculate sub-plot area
        if (orientation == PlotOrientation.VERTICAL) {
            double w = usableSize * plot.getWeight() / totalWeight;
            this.subplotAreas[i] = new Rectangle2D.Double(x, y, w,
                    adjustedPlotArea.getHeight());
            x = x + w + this.gap;
        }
        else if (orientation == PlotOrientation.HORIZONTAL) {
            double h = usableSize * plot.getWeight() / totalWeight;
            this.subplotAreas[i] = new Rectangle2D.Double(x, y,
                    adjustedPlotArea.getWidth(), h);
            y = y + h + this.gap;
        }

        AxisSpace subSpace = plot.calculateDomainAxisSpace(g2,
                this.subplotAreas[i], null);
        space.ensureAtLeast(subSpace);

    }

    return space;
}
 
Example 4
Source File: CombinedRangeXYPlot.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Calculates the space required for the axes.
 * 
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 * 
 * @return The space required for the axes.
 */
protected AxisSpace calculateAxisSpace(Graphics2D g2, 
                                       Rectangle2D plotArea) {
    
    AxisSpace space = new AxisSpace();
    PlotOrientation orientation = getOrientation();
    
    // work out the space required by the domain axis...
    AxisSpace fixed = getFixedRangeAxisSpace();
    if (fixed != null) {
        if (orientation == PlotOrientation.VERTICAL) {
            space.setLeft(fixed.getLeft());
            space.setRight(fixed.getRight());
        }
        else if (orientation == PlotOrientation.HORIZONTAL) {
            space.setTop(fixed.getTop());
            space.setBottom(fixed.getBottom());                
        }
    }
    else {
        ValueAxis valueAxis = getRangeAxis();
        RectangleEdge valueEdge = Plot.resolveRangeAxisLocation(
            getRangeAxisLocation(), orientation
        );
        if (valueAxis != null) {
            space = valueAxis.reserveSpace(g2, this, plotArea, valueEdge, 
                    space);
        }
    }
    
    Rectangle2D adjustedPlotArea = space.shrink(plotArea, null);
    // work out the maximum height or width of the non-shared axes...
    int n = this.subplots.size();

    // calculate plotAreas of all sub-plots, maximum vertical/horizontal 
    // axis width/height
    this.subplotAreas = new Rectangle2D[n];
    double x = adjustedPlotArea.getX();
    double y = adjustedPlotArea.getY();
    double usableSize = 0.0;
    if (orientation == PlotOrientation.VERTICAL) {
        usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1);
    }
    else if (orientation == PlotOrientation.HORIZONTAL) {
        usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1);
    }

    for (int i = 0; i < n; i++) {
        XYPlot plot = (XYPlot) this.subplots.get(i);

        // calculate sub-plot area
        if (orientation == PlotOrientation.VERTICAL) {
            double w = usableSize * plot.getWeight() / this.totalWeight;
            this.subplotAreas[i] = new Rectangle2D.Double(x, y, w, 
                    adjustedPlotArea.getHeight());
            x = x + w + this.gap;
        }
        else if (orientation == PlotOrientation.HORIZONTAL) {
            double h = usableSize * plot.getWeight() / this.totalWeight;
            this.subplotAreas[i] = new Rectangle2D.Double(x, y, 
                    adjustedPlotArea.getWidth(), h);
            y = y + h + this.gap;
        }

        AxisSpace subSpace = plot.calculateDomainAxisSpace(g2, 
                this.subplotAreas[i], null);
        space.ensureAtLeast(subSpace);

    }

    return space;
}
 
Example 5
Source File: CombinedRangeCategoryPlot.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Calculates the space required for the axes.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 *
 * @return The space required for the axes.
 */
@Override
protected AxisSpace calculateAxisSpace(Graphics2D g2, 
        Rectangle2D plotArea) {

    AxisSpace space = new AxisSpace();
    PlotOrientation orientation = getOrientation();

    // work out the space required by the domain axis...
    AxisSpace fixed = getFixedRangeAxisSpace();
    if (fixed != null) {
        if (orientation == PlotOrientation.VERTICAL) {
            space.setLeft(fixed.getLeft());
            space.setRight(fixed.getRight());
        }
        else if (orientation == PlotOrientation.HORIZONTAL) {
            space.setTop(fixed.getTop());
            space.setBottom(fixed.getBottom());
        }
    }
    else {
        ValueAxis valueAxis = getRangeAxis();
        RectangleEdge valueEdge = Plot.resolveRangeAxisLocation(
                getRangeAxisLocation(), orientation);
        if (valueAxis != null) {
            space = valueAxis.reserveSpace(g2, this, plotArea, valueEdge,
                    space);
        }
    }

    Rectangle2D adjustedPlotArea = space.shrink(plotArea, null);
    // work out the maximum height or width of the non-shared axes...
    int n = this.subplots.size();
    int totalWeight = 0;
    for (int i = 0; i < n; i++) {
        CategoryPlot sub = (CategoryPlot) this.subplots.get(i);
        totalWeight += sub.getWeight();
    }
    // calculate plotAreas of all sub-plots, maximum vertical/horizontal
    // axis width/height
    this.subplotArea = new Rectangle2D[n];
    double x = adjustedPlotArea.getX();
    double y = adjustedPlotArea.getY();
    double usableSize = 0.0;
    if (orientation == PlotOrientation.VERTICAL) {
        usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1);
    }
    else if (orientation == PlotOrientation.HORIZONTAL) {
        usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1);
    }

    for (int i = 0; i < n; i++) {
        CategoryPlot plot = (CategoryPlot) this.subplots.get(i);

        // calculate sub-plot area
        if (orientation == PlotOrientation.VERTICAL) {
            double w = usableSize * plot.getWeight() / totalWeight;
            this.subplotArea[i] = new Rectangle2D.Double(x, y, w,
                    adjustedPlotArea.getHeight());
            x = x + w + this.gap;
        }
        else if (orientation == PlotOrientation.HORIZONTAL) {
            double h = usableSize * plot.getWeight() / totalWeight;
            this.subplotArea[i] = new Rectangle2D.Double(x, y,
                    adjustedPlotArea.getWidth(), h);
            y = y + h + this.gap;
        }

        AxisSpace subSpace = plot.calculateDomainAxisSpace(g2,
                this.subplotArea[i], null);
        space.ensureAtLeast(subSpace);

    }

    return space;
}
 
Example 6
Source File: CombinedDomainXYPlot.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Calculates the axis space required.
 * 
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 * 
 * @return The space.
 */
protected AxisSpace calculateAxisSpace(Graphics2D g2, 
                                       Rectangle2D plotArea) {
    
    AxisSpace space = new AxisSpace();
    PlotOrientation orientation = getOrientation();
    
    // work out the space required by the domain axis...
    AxisSpace fixed = getFixedDomainAxisSpace();
    if (fixed != null) {
        if (orientation == PlotOrientation.HORIZONTAL) {
            space.setLeft(fixed.getLeft());
            space.setRight(fixed.getRight());
        }
        else if (orientation == PlotOrientation.VERTICAL) {
            space.setTop(fixed.getTop());
            space.setBottom(fixed.getBottom());                
        }
    }
    else {
        ValueAxis xAxis = getDomainAxis();
        RectangleEdge xEdge = Plot.resolveDomainAxisLocation(
                getDomainAxisLocation(), orientation);
        if (xAxis != null) {
            space = xAxis.reserveSpace(g2, this, plotArea, xEdge, space);
        }
    }
    
    Rectangle2D adjustedPlotArea = space.shrink(plotArea, null);
    
    // work out the maximum height or width of the non-shared axes...
    int n = this.subplots.size();
    this.subplotAreas = new Rectangle2D[n];
    double x = adjustedPlotArea.getX();
    double y = adjustedPlotArea.getY();
    double usableSize = 0.0;
    if (orientation == PlotOrientation.HORIZONTAL) {
        usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1);
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1);
    }

    for (int i = 0; i < n; i++) {
        XYPlot plot = (XYPlot) this.subplots.get(i);

        // calculate sub-plot area
        if (orientation == PlotOrientation.HORIZONTAL) {
            double w = usableSize * plot.getWeight() / this.totalWeight;
            this.subplotAreas[i] = new Rectangle2D.Double(x, y, w, 
                    adjustedPlotArea.getHeight());
            x = x + w + this.gap;
        }
        else if (orientation == PlotOrientation.VERTICAL) {
            double h = usableSize * plot.getWeight() / this.totalWeight;
            this.subplotAreas[i] = new Rectangle2D.Double(x, y, 
                    adjustedPlotArea.getWidth(), h);
            y = y + h + this.gap;
        }

        AxisSpace subSpace = plot.calculateRangeAxisSpace(g2, 
                this.subplotAreas[i], null);
        space.ensureAtLeast(subSpace);

    }

    return space;
}
 
Example 7
Source File: CombinedRangeXYPlot.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Calculates the space required for the axes.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 *
 * @return The space required for the axes.
 */
protected AxisSpace calculateAxisSpace(Graphics2D g2,
                                       Rectangle2D plotArea) {

    AxisSpace space = new AxisSpace();
    PlotOrientation orientation = getOrientation();

    // work out the space required by the domain axis...
    AxisSpace fixed = getFixedRangeAxisSpace();
    if (fixed != null) {
        if (orientation == PlotOrientation.VERTICAL) {
            space.setLeft(fixed.getLeft());
            space.setRight(fixed.getRight());
        }
        else if (orientation == PlotOrientation.HORIZONTAL) {
            space.setTop(fixed.getTop());
            space.setBottom(fixed.getBottom());
        }
    }
    else {
        ValueAxis valueAxis = getRangeAxis();
        RectangleEdge valueEdge = Plot.resolveRangeAxisLocation(
            getRangeAxisLocation(), orientation
        );
        if (valueAxis != null) {
            space = valueAxis.reserveSpace(g2, this, plotArea, valueEdge,
                    space);
        }
    }

    Rectangle2D adjustedPlotArea = space.shrink(plotArea, null);
    // work out the maximum height or width of the non-shared axes...
    int n = this.subplots.size();
    int totalWeight = 0;
    for (int i = 0; i < n; i++) {
        XYPlot sub = (XYPlot) this.subplots.get(i);
        totalWeight += sub.getWeight();
    }

    // calculate plotAreas of all sub-plots, maximum vertical/horizontal
    // axis width/height
    this.subplotAreas = new Rectangle2D[n];
    double x = adjustedPlotArea.getX();
    double y = adjustedPlotArea.getY();
    double usableSize = 0.0;
    if (orientation == PlotOrientation.VERTICAL) {
        usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1);
    }
    else if (orientation == PlotOrientation.HORIZONTAL) {
        usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1);
    }

    for (int i = 0; i < n; i++) {
        XYPlot plot = (XYPlot) this.subplots.get(i);

        // calculate sub-plot area
        if (orientation == PlotOrientation.VERTICAL) {
            double w = usableSize * plot.getWeight() / totalWeight;
            this.subplotAreas[i] = new Rectangle2D.Double(x, y, w,
                    adjustedPlotArea.getHeight());
            x = x + w + this.gap;
        }
        else if (orientation == PlotOrientation.HORIZONTAL) {
            double h = usableSize * plot.getWeight() / totalWeight;
            this.subplotAreas[i] = new Rectangle2D.Double(x, y,
                    adjustedPlotArea.getWidth(), h);
            y = y + h + this.gap;
        }

        AxisSpace subSpace = plot.calculateDomainAxisSpace(g2,
                this.subplotAreas[i], null);
        space.ensureAtLeast(subSpace);

    }

    return space;
}
 
Example 8
Source File: CombinedRangeCategoryPlot.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Calculates the space required for the axes.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 *
 * @return The space required for the axes.
 */
protected AxisSpace calculateAxisSpace(Graphics2D g2,
                                       Rectangle2D plotArea) {

    AxisSpace space = new AxisSpace();
    PlotOrientation orientation = getOrientation();

    // work out the space required by the domain axis...
    AxisSpace fixed = getFixedRangeAxisSpace();
    if (fixed != null) {
        if (orientation == PlotOrientation.VERTICAL) {
            space.setLeft(fixed.getLeft());
            space.setRight(fixed.getRight());
        }
        else if (orientation == PlotOrientation.HORIZONTAL) {
            space.setTop(fixed.getTop());
            space.setBottom(fixed.getBottom());
        }
    }
    else {
        ValueAxis valueAxis = getRangeAxis();
        RectangleEdge valueEdge = Plot.resolveRangeAxisLocation(
                getRangeAxisLocation(), orientation);
        if (valueAxis != null) {
            space = valueAxis.reserveSpace(g2, this, plotArea, valueEdge,
                    space);
        }
    }

    Rectangle2D adjustedPlotArea = space.shrink(plotArea, null);
    // work out the maximum height or width of the non-shared axes...
    int n = this.subplots.size();
    int totalWeight = 0;
    for (int i = 0; i < n; i++) {
        CategoryPlot sub = (CategoryPlot) this.subplots.get(i);
        totalWeight += sub.getWeight();
    }
    // calculate plotAreas of all sub-plots, maximum vertical/horizontal
    // axis width/height
    this.subplotArea = new Rectangle2D[n];
    double x = adjustedPlotArea.getX();
    double y = adjustedPlotArea.getY();
    double usableSize = 0.0;
    if (orientation == PlotOrientation.VERTICAL) {
        usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1);
    }
    else if (orientation == PlotOrientation.HORIZONTAL) {
        usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1);
    }

    for (int i = 0; i < n; i++) {
        CategoryPlot plot = (CategoryPlot) this.subplots.get(i);

        // calculate sub-plot area
        if (orientation == PlotOrientation.VERTICAL) {
            double w = usableSize * plot.getWeight() / totalWeight;
            this.subplotArea[i] = new Rectangle2D.Double(x, y, w,
                    adjustedPlotArea.getHeight());
            x = x + w + this.gap;
        }
        else if (orientation == PlotOrientation.HORIZONTAL) {
            double h = usableSize * plot.getWeight() / totalWeight;
            this.subplotArea[i] = new Rectangle2D.Double(x, y,
                    adjustedPlotArea.getWidth(), h);
            y = y + h + this.gap;
        }

        AxisSpace subSpace = plot.calculateDomainAxisSpace(g2,
                this.subplotArea[i], null);
        space.ensureAtLeast(subSpace);

    }

    return space;
}
 
Example 9
Source File: CombinedDomainXYPlot.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Calculates the axis space required.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 *
 * @return The space.
 */
protected AxisSpace calculateAxisSpace(Graphics2D g2,
                                       Rectangle2D plotArea) {

    AxisSpace space = new AxisSpace();
    PlotOrientation orientation = getOrientation();

    // work out the space required by the domain axis...
    AxisSpace fixed = getFixedDomainAxisSpace();
    if (fixed != null) {
        if (orientation == PlotOrientation.HORIZONTAL) {
            space.setLeft(fixed.getLeft());
            space.setRight(fixed.getRight());
        }
        else if (orientation == PlotOrientation.VERTICAL) {
            space.setTop(fixed.getTop());
            space.setBottom(fixed.getBottom());
        }
    }
    else {
        ValueAxis xAxis = getDomainAxis();
        RectangleEdge xEdge = Plot.resolveDomainAxisLocation(
                getDomainAxisLocation(), orientation);
        if (xAxis != null) {
            space = xAxis.reserveSpace(g2, this, plotArea, xEdge, space);
        }
    }

    Rectangle2D adjustedPlotArea = space.shrink(plotArea, null);

    // work out the maximum height or width of the non-shared axes...
    int n = this.subplots.size();
    int totalWeight = 0;
    for (int i = 0; i < n; i++) {
        XYPlot sub = (XYPlot) this.subplots.get(i);
        totalWeight += sub.getWeight();
    }
    this.subplotAreas = new Rectangle2D[n];
    double x = adjustedPlotArea.getX();
    double y = adjustedPlotArea.getY();
    double usableSize = 0.0;
    if (orientation == PlotOrientation.HORIZONTAL) {
        usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1);
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1);
    }

    for (int i = 0; i < n; i++) {
        XYPlot plot = (XYPlot) this.subplots.get(i);

        // calculate sub-plot area
        if (orientation == PlotOrientation.HORIZONTAL) {
            double w = usableSize * plot.getWeight() / totalWeight;
            this.subplotAreas[i] = new Rectangle2D.Double(x, y, w,
                    adjustedPlotArea.getHeight());
            x = x + w + this.gap;
        }
        else if (orientation == PlotOrientation.VERTICAL) {
            double h = usableSize * plot.getWeight() / totalWeight;
            this.subplotAreas[i] = new Rectangle2D.Double(x, y,
                    adjustedPlotArea.getWidth(), h);
            y = y + h + this.gap;
        }

        AxisSpace subSpace = plot.calculateRangeAxisSpace(g2,
                this.subplotAreas[i], null);
        space.ensureAtLeast(subSpace);

    }

    return space;
}
 
Example 10
Source File: CombinedRangeXYPlot.java    From ECG-Viewer with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Calculates the space required for the axes.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 *
 * @return The space required for the axes.
 */
@Override
protected AxisSpace calculateAxisSpace(Graphics2D g2,
                                       Rectangle2D plotArea) {

    AxisSpace space = new AxisSpace();
    PlotOrientation orientation = getOrientation();

    // work out the space required by the domain axis...
    AxisSpace fixed = getFixedRangeAxisSpace();
    if (fixed != null) {
        if (orientation == PlotOrientation.VERTICAL) {
            space.setLeft(fixed.getLeft());
            space.setRight(fixed.getRight());
        }
        else if (orientation == PlotOrientation.HORIZONTAL) {
            space.setTop(fixed.getTop());
            space.setBottom(fixed.getBottom());
        }
    }
    else {
        ValueAxis valueAxis = getRangeAxis();
        RectangleEdge valueEdge = Plot.resolveRangeAxisLocation(
            getRangeAxisLocation(), orientation
        );
        if (valueAxis != null) {
            space = valueAxis.reserveSpace(g2, this, plotArea, valueEdge,
                    space);
        }
    }

    Rectangle2D adjustedPlotArea = space.shrink(plotArea, null);
    // work out the maximum height or width of the non-shared axes...
    int n = this.subplots.size();
    int totalWeight = 0;
    for (int i = 0; i < n; i++) {
        XYPlot sub = (XYPlot) this.subplots.get(i);
        totalWeight += sub.getWeight();
    }

    // calculate plotAreas of all sub-plots, maximum vertical/horizontal
    // axis width/height
    this.subplotAreas = new Rectangle2D[n];
    double x = adjustedPlotArea.getX();
    double y = adjustedPlotArea.getY();
    double usableSize = 0.0;
    if (orientation == PlotOrientation.VERTICAL) {
        usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1);
    }
    else if (orientation == PlotOrientation.HORIZONTAL) {
        usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1);
    }

    for (int i = 0; i < n; i++) {
        XYPlot plot = (XYPlot) this.subplots.get(i);

        // calculate sub-plot area
        if (orientation == PlotOrientation.VERTICAL) {
            double w = usableSize * plot.getWeight() / totalWeight;
            this.subplotAreas[i] = new Rectangle2D.Double(x, y, w,
                    adjustedPlotArea.getHeight());
            x = x + w + this.gap;
        }
        else if (orientation == PlotOrientation.HORIZONTAL) {
            double h = usableSize * plot.getWeight() / totalWeight;
            this.subplotAreas[i] = new Rectangle2D.Double(x, y,
                    adjustedPlotArea.getWidth(), h);
            y = y + h + this.gap;
        }

        AxisSpace subSpace = plot.calculateDomainAxisSpace(g2,
                this.subplotAreas[i], null);
        space.ensureAtLeast(subSpace);

    }

    return space;
}
 
Example 11
Source File: CombinedDomainXYPlot.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Calculates the axis space required.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 *
 * @return The space.
 */
@Override
protected AxisSpace calculateAxisSpace(Graphics2D g2,
                                       Rectangle2D plotArea) {

    AxisSpace space = new AxisSpace();
    PlotOrientation orientation = getOrientation();

    // work out the space required by the domain axis...
    AxisSpace fixed = getFixedDomainAxisSpace();
    if (fixed != null) {
        if (orientation == PlotOrientation.HORIZONTAL) {
            space.setLeft(fixed.getLeft());
            space.setRight(fixed.getRight());
        }
        else if (orientation == PlotOrientation.VERTICAL) {
            space.setTop(fixed.getTop());
            space.setBottom(fixed.getBottom());
        }
    }
    else {
        ValueAxis xAxis = getDomainAxis();
        RectangleEdge xEdge = Plot.resolveDomainAxisLocation(
                getDomainAxisLocation(), orientation);
        if (xAxis != null) {
            space = xAxis.reserveSpace(g2, this, plotArea, xEdge, space);
        }
    }

    Rectangle2D adjustedPlotArea = space.shrink(plotArea, null);

    // work out the maximum height or width of the non-shared axes...
    int n = this.subplots.size();
    int totalWeight = 0;
    for (int i = 0; i < n; i++) {
        XYPlot sub = (XYPlot) this.subplots.get(i);
        totalWeight += sub.getWeight();
    }
    this.subplotAreas = new Rectangle2D[n];
    double x = adjustedPlotArea.getX();
    double y = adjustedPlotArea.getY();
    double usableSize = 0.0;
    if (orientation == PlotOrientation.HORIZONTAL) {
        usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1);
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1);
    }

    for (int i = 0; i < n; i++) {
        XYPlot plot = (XYPlot) this.subplots.get(i);

        // calculate sub-plot area
        if (orientation == PlotOrientation.HORIZONTAL) {
            double w = usableSize * plot.getWeight() / totalWeight;
            this.subplotAreas[i] = new Rectangle2D.Double(x, y, w,
                    adjustedPlotArea.getHeight());
            x = x + w + this.gap;
        }
        else if (orientation == PlotOrientation.VERTICAL) {
            double h = usableSize * plot.getWeight() / totalWeight;
            this.subplotAreas[i] = new Rectangle2D.Double(x, y,
                    adjustedPlotArea.getWidth(), h);
            y = y + h + this.gap;
        }

        AxisSpace subSpace = plot.calculateRangeAxisSpace(g2,
                this.subplotAreas[i], null);
        space.ensureAtLeast(subSpace);

    }

    return space;
}
 
Example 12
Source File: CombinedRangeCategoryPlot.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Calculates the space required for the axes.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 *
 * @return The space required for the axes.
 */
@Override
protected AxisSpace calculateAxisSpace(Graphics2D g2, 
        Rectangle2D plotArea) {

    AxisSpace space = new AxisSpace();
    PlotOrientation orientation = getOrientation();

    // work out the space required by the domain axis...
    AxisSpace fixed = getFixedRangeAxisSpace();
    if (fixed != null) {
        if (orientation == PlotOrientation.VERTICAL) {
            space.setLeft(fixed.getLeft());
            space.setRight(fixed.getRight());
        }
        else if (orientation == PlotOrientation.HORIZONTAL) {
            space.setTop(fixed.getTop());
            space.setBottom(fixed.getBottom());
        }
    }
    else {
        ValueAxis valueAxis = getRangeAxis();
        RectangleEdge valueEdge = Plot.resolveRangeAxisLocation(
                getRangeAxisLocation(), orientation);
        if (valueAxis != null) {
            space = valueAxis.reserveSpace(g2, this, plotArea, valueEdge,
                    space);
        }
    }

    Rectangle2D adjustedPlotArea = space.shrink(plotArea, null);
    // work out the maximum height or width of the non-shared axes...
    int n = this.subplots.size();
    int totalWeight = 0;
    for (int i = 0; i < n; i++) {
        CategoryPlot sub = (CategoryPlot) this.subplots.get(i);
        totalWeight += sub.getWeight();
    }
    // calculate plotAreas of all sub-plots, maximum vertical/horizontal
    // axis width/height
    this.subplotArea = new Rectangle2D[n];
    double x = adjustedPlotArea.getX();
    double y = adjustedPlotArea.getY();
    double usableSize = 0.0;
    if (orientation == PlotOrientation.VERTICAL) {
        usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1);
    }
    else if (orientation == PlotOrientation.HORIZONTAL) {
        usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1);
    }

    for (int i = 0; i < n; i++) {
        CategoryPlot plot = (CategoryPlot) this.subplots.get(i);

        // calculate sub-plot area
        if (orientation == PlotOrientation.VERTICAL) {
            double w = usableSize * plot.getWeight() / totalWeight;
            this.subplotArea[i] = new Rectangle2D.Double(x, y, w,
                    adjustedPlotArea.getHeight());
            x = x + w + this.gap;
        }
        else if (orientation == PlotOrientation.HORIZONTAL) {
            double h = usableSize * plot.getWeight() / totalWeight;
            this.subplotArea[i] = new Rectangle2D.Double(x, y,
                    adjustedPlotArea.getWidth(), h);
            y = y + h + this.gap;
        }

        AxisSpace subSpace = plot.calculateDomainAxisSpace(g2,
                this.subplotArea[i], null);
        space.ensureAtLeast(subSpace);

    }

    return space;
}
 
Example 13
Source File: CombinedRangeXYPlot.java    From SIMVA-SoS with Apache License 2.0 4 votes vote down vote up
/**
 * Calculates the space required for the axes.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 *
 * @return The space required for the axes.
 */
@Override
protected AxisSpace calculateAxisSpace(Graphics2D g2,
                                       Rectangle2D plotArea) {

    AxisSpace space = new AxisSpace();
    PlotOrientation orientation = getOrientation();

    // work out the space required by the domain axis...
    AxisSpace fixed = getFixedRangeAxisSpace();
    if (fixed != null) {
        if (orientation == PlotOrientation.VERTICAL) {
            space.setLeft(fixed.getLeft());
            space.setRight(fixed.getRight());
        }
        else if (orientation == PlotOrientation.HORIZONTAL) {
            space.setTop(fixed.getTop());
            space.setBottom(fixed.getBottom());
        }
    }
    else {
        ValueAxis valueAxis = getRangeAxis();
        RectangleEdge valueEdge = Plot.resolveRangeAxisLocation(
            getRangeAxisLocation(), orientation
        );
        if (valueAxis != null) {
            space = valueAxis.reserveSpace(g2, this, plotArea, valueEdge,
                    space);
        }
    }

    Rectangle2D adjustedPlotArea = space.shrink(plotArea, null);
    // work out the maximum height or width of the non-shared axes...
    int n = this.subplots.size();
    int totalWeight = 0;
    for (int i = 0; i < n; i++) {
        XYPlot sub = (XYPlot) this.subplots.get(i);
        totalWeight += sub.getWeight();
    }

    // calculate plotAreas of all sub-plots, maximum vertical/horizontal
    // axis width/height
    this.subplotAreas = new Rectangle2D[n];
    double x = adjustedPlotArea.getX();
    double y = adjustedPlotArea.getY();
    double usableSize = 0.0;
    if (orientation == PlotOrientation.VERTICAL) {
        usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1);
    }
    else if (orientation == PlotOrientation.HORIZONTAL) {
        usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1);
    }

    for (int i = 0; i < n; i++) {
        XYPlot plot = (XYPlot) this.subplots.get(i);

        // calculate sub-plot area
        if (orientation == PlotOrientation.VERTICAL) {
            double w = usableSize * plot.getWeight() / totalWeight;
            this.subplotAreas[i] = new Rectangle2D.Double(x, y, w,
                    adjustedPlotArea.getHeight());
            x = x + w + this.gap;
        }
        else if (orientation == PlotOrientation.HORIZONTAL) {
            double h = usableSize * plot.getWeight() / totalWeight;
            this.subplotAreas[i] = new Rectangle2D.Double(x, y,
                    adjustedPlotArea.getWidth(), h);
            y = y + h + this.gap;
        }

        AxisSpace subSpace = plot.calculateDomainAxisSpace(g2,
                this.subplotAreas[i], null);
        space.ensureAtLeast(subSpace);

    }

    return space;
}
 
Example 14
Source File: CombinedRangeCategoryPlot.java    From SIMVA-SoS with Apache License 2.0 4 votes vote down vote up
/**
 * Calculates the space required for the axes.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 *
 * @return The space required for the axes.
 */
@Override
protected AxisSpace calculateAxisSpace(Graphics2D g2, 
        Rectangle2D plotArea) {

    AxisSpace space = new AxisSpace();
    PlotOrientation orientation = getOrientation();

    // work out the space required by the domain axis...
    AxisSpace fixed = getFixedRangeAxisSpace();
    if (fixed != null) {
        if (orientation == PlotOrientation.VERTICAL) {
            space.setLeft(fixed.getLeft());
            space.setRight(fixed.getRight());
        }
        else if (orientation == PlotOrientation.HORIZONTAL) {
            space.setTop(fixed.getTop());
            space.setBottom(fixed.getBottom());
        }
    }
    else {
        ValueAxis valueAxis = getRangeAxis();
        RectangleEdge valueEdge = Plot.resolveRangeAxisLocation(
                getRangeAxisLocation(), orientation);
        if (valueAxis != null) {
            space = valueAxis.reserveSpace(g2, this, plotArea, valueEdge,
                    space);
        }
    }

    Rectangle2D adjustedPlotArea = space.shrink(plotArea, null);
    // work out the maximum height or width of the non-shared axes...
    int n = this.subplots.size();
    int totalWeight = 0;
    for (int i = 0; i < n; i++) {
        CategoryPlot sub = (CategoryPlot) this.subplots.get(i);
        totalWeight += sub.getWeight();
    }
    // calculate plotAreas of all sub-plots, maximum vertical/horizontal
    // axis width/height
    this.subplotArea = new Rectangle2D[n];
    double x = adjustedPlotArea.getX();
    double y = adjustedPlotArea.getY();
    double usableSize = 0.0;
    if (orientation == PlotOrientation.VERTICAL) {
        usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1);
    }
    else if (orientation == PlotOrientation.HORIZONTAL) {
        usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1);
    }

    for (int i = 0; i < n; i++) {
        CategoryPlot plot = (CategoryPlot) this.subplots.get(i);

        // calculate sub-plot area
        if (orientation == PlotOrientation.VERTICAL) {
            double w = usableSize * plot.getWeight() / totalWeight;
            this.subplotArea[i] = new Rectangle2D.Double(x, y, w,
                    adjustedPlotArea.getHeight());
            x = x + w + this.gap;
        }
        else if (orientation == PlotOrientation.HORIZONTAL) {
            double h = usableSize * plot.getWeight() / totalWeight;
            this.subplotArea[i] = new Rectangle2D.Double(x, y,
                    adjustedPlotArea.getWidth(), h);
            y = y + h + this.gap;
        }

        AxisSpace subSpace = plot.calculateDomainAxisSpace(g2,
                this.subplotArea[i], null);
        space.ensureAtLeast(subSpace);

    }

    return space;
}
 
Example 15
Source File: CombinedRangeXYPlot.java    From opensim-gui with Apache License 2.0 4 votes vote down vote up
/**
 * Calculates the space required for the axes.
 * 
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 * 
 * @return The space required for the axes.
 */
protected AxisSpace calculateAxisSpace(Graphics2D g2, 
                                       Rectangle2D plotArea) {
    
    AxisSpace space = new AxisSpace();
    PlotOrientation orientation = getOrientation();
    
    // work out the space required by the domain axis...
    AxisSpace fixed = getFixedRangeAxisSpace();
    if (fixed != null) {
        if (orientation == PlotOrientation.VERTICAL) {
            space.setLeft(fixed.getLeft());
            space.setRight(fixed.getRight());
        }
        else if (orientation == PlotOrientation.HORIZONTAL) {
            space.setTop(fixed.getTop());
            space.setBottom(fixed.getBottom());                
        }
    }
    else {
        ValueAxis valueAxis = getRangeAxis();
        RectangleEdge valueEdge = Plot.resolveRangeAxisLocation(
            getRangeAxisLocation(), orientation
        );
        if (valueAxis != null) {
            space = valueAxis.reserveSpace(g2, this, plotArea, valueEdge, 
                    space);
        }
    }
    
    Rectangle2D adjustedPlotArea = space.shrink(plotArea, null);
    // work out the maximum height or width of the non-shared axes...
    int n = this.subplots.size();

    // calculate plotAreas of all sub-plots, maximum vertical/horizontal 
    // axis width/height
    this.subplotAreas = new Rectangle2D[n];
    double x = adjustedPlotArea.getX();
    double y = adjustedPlotArea.getY();
    double usableSize = 0.0;
    if (orientation == PlotOrientation.VERTICAL) {
        usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1);
    }
    else if (orientation == PlotOrientation.HORIZONTAL) {
        usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1);
    }

    for (int i = 0; i < n; i++) {
        XYPlot plot = (XYPlot) this.subplots.get(i);

        // calculate sub-plot area
        if (orientation == PlotOrientation.VERTICAL) {
            double w = usableSize * plot.getWeight() / this.totalWeight;
            this.subplotAreas[i] = new Rectangle2D.Double(x, y, w, 
                    adjustedPlotArea.getHeight());
            x = x + w + this.gap;
        }
        else if (orientation == PlotOrientation.HORIZONTAL) {
            double h = usableSize * plot.getWeight() / this.totalWeight;
            this.subplotAreas[i] = new Rectangle2D.Double(x, y, 
                    adjustedPlotArea.getWidth(), h);
            y = y + h + this.gap;
        }

        AxisSpace subSpace = plot.calculateDomainAxisSpace(g2, 
                this.subplotAreas[i], null);
        space.ensureAtLeast(subSpace);

    }

    return space;
}
 
Example 16
Source File: CombinedRangeXYPlot.java    From ccu-historian with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Calculates the space required for the axes.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 *
 * @return The space required for the axes.
 */
@Override
protected AxisSpace calculateAxisSpace(Graphics2D g2,
                                       Rectangle2D plotArea) {

    AxisSpace space = new AxisSpace();
    PlotOrientation orientation = getOrientation();

    // work out the space required by the domain axis...
    AxisSpace fixed = getFixedRangeAxisSpace();
    if (fixed != null) {
        if (orientation == PlotOrientation.VERTICAL) {
            space.setLeft(fixed.getLeft());
            space.setRight(fixed.getRight());
        }
        else if (orientation == PlotOrientation.HORIZONTAL) {
            space.setTop(fixed.getTop());
            space.setBottom(fixed.getBottom());
        }
    }
    else {
        ValueAxis valueAxis = getRangeAxis();
        RectangleEdge valueEdge = Plot.resolveRangeAxisLocation(
            getRangeAxisLocation(), orientation
        );
        if (valueAxis != null) {
            space = valueAxis.reserveSpace(g2, this, plotArea, valueEdge,
                    space);
        }
    }

    Rectangle2D adjustedPlotArea = space.shrink(plotArea, null);
    // work out the maximum height or width of the non-shared axes...
    int n = this.subplots.size();
    int totalWeight = 0;
    for (int i = 0; i < n; i++) {
        XYPlot sub = (XYPlot) this.subplots.get(i);
        totalWeight += sub.getWeight();
    }

    // calculate plotAreas of all sub-plots, maximum vertical/horizontal
    // axis width/height
    this.subplotAreas = new Rectangle2D[n];
    double x = adjustedPlotArea.getX();
    double y = adjustedPlotArea.getY();
    double usableSize = 0.0;
    if (orientation == PlotOrientation.VERTICAL) {
        usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1);
    }
    else if (orientation == PlotOrientation.HORIZONTAL) {
        usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1);
    }

    for (int i = 0; i < n; i++) {
        XYPlot plot = (XYPlot) this.subplots.get(i);

        // calculate sub-plot area
        if (orientation == PlotOrientation.VERTICAL) {
            double w = usableSize * plot.getWeight() / totalWeight;
            this.subplotAreas[i] = new Rectangle2D.Double(x, y, w,
                    adjustedPlotArea.getHeight());
            x = x + w + this.gap;
        }
        else if (orientation == PlotOrientation.HORIZONTAL) {
            double h = usableSize * plot.getWeight() / totalWeight;
            this.subplotAreas[i] = new Rectangle2D.Double(x, y,
                    adjustedPlotArea.getWidth(), h);
            y = y + h + this.gap;
        }

        AxisSpace subSpace = plot.calculateDomainAxisSpace(g2,
                this.subplotAreas[i], null);
        space.ensureAtLeast(subSpace);

    }

    return space;
}
 
Example 17
Source File: CombinedRangeCategoryPlot.java    From ccu-historian with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Calculates the space required for the axes.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 *
 * @return The space required for the axes.
 */
@Override
protected AxisSpace calculateAxisSpace(Graphics2D g2, 
        Rectangle2D plotArea) {

    AxisSpace space = new AxisSpace();
    PlotOrientation orientation = getOrientation();

    // work out the space required by the domain axis...
    AxisSpace fixed = getFixedRangeAxisSpace();
    if (fixed != null) {
        if (orientation == PlotOrientation.VERTICAL) {
            space.setLeft(fixed.getLeft());
            space.setRight(fixed.getRight());
        }
        else if (orientation == PlotOrientation.HORIZONTAL) {
            space.setTop(fixed.getTop());
            space.setBottom(fixed.getBottom());
        }
    }
    else {
        ValueAxis valueAxis = getRangeAxis();
        RectangleEdge valueEdge = Plot.resolveRangeAxisLocation(
                getRangeAxisLocation(), orientation);
        if (valueAxis != null) {
            space = valueAxis.reserveSpace(g2, this, plotArea, valueEdge,
                    space);
        }
    }

    Rectangle2D adjustedPlotArea = space.shrink(plotArea, null);
    // work out the maximum height or width of the non-shared axes...
    int n = this.subplots.size();
    int totalWeight = 0;
    for (int i = 0; i < n; i++) {
        CategoryPlot sub = (CategoryPlot) this.subplots.get(i);
        totalWeight += sub.getWeight();
    }
    // calculate plotAreas of all sub-plots, maximum vertical/horizontal
    // axis width/height
    this.subplotArea = new Rectangle2D[n];
    double x = adjustedPlotArea.getX();
    double y = adjustedPlotArea.getY();
    double usableSize = 0.0;
    if (orientation == PlotOrientation.VERTICAL) {
        usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1);
    }
    else if (orientation == PlotOrientation.HORIZONTAL) {
        usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1);
    }

    for (int i = 0; i < n; i++) {
        CategoryPlot plot = (CategoryPlot) this.subplots.get(i);

        // calculate sub-plot area
        if (orientation == PlotOrientation.VERTICAL) {
            double w = usableSize * plot.getWeight() / totalWeight;
            this.subplotArea[i] = new Rectangle2D.Double(x, y, w,
                    adjustedPlotArea.getHeight());
            x = x + w + this.gap;
        }
        else if (orientation == PlotOrientation.HORIZONTAL) {
            double h = usableSize * plot.getWeight() / totalWeight;
            this.subplotArea[i] = new Rectangle2D.Double(x, y,
                    adjustedPlotArea.getWidth(), h);
            y = y + h + this.gap;
        }

        AxisSpace subSpace = plot.calculateDomainAxisSpace(g2,
                this.subplotArea[i], null);
        space.ensureAtLeast(subSpace);

    }

    return space;
}
 
Example 18
Source File: CombinedDomainXYPlot.java    From ccu-historian with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Calculates the axis space required.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 *
 * @return The space.
 */
@Override
protected AxisSpace calculateAxisSpace(Graphics2D g2,
                                       Rectangle2D plotArea) {

    AxisSpace space = new AxisSpace();
    PlotOrientation orientation = getOrientation();

    // work out the space required by the domain axis...
    AxisSpace fixed = getFixedDomainAxisSpace();
    if (fixed != null) {
        if (orientation == PlotOrientation.HORIZONTAL) {
            space.setLeft(fixed.getLeft());
            space.setRight(fixed.getRight());
        }
        else if (orientation == PlotOrientation.VERTICAL) {
            space.setTop(fixed.getTop());
            space.setBottom(fixed.getBottom());
        }
    }
    else {
        ValueAxis xAxis = getDomainAxis();
        RectangleEdge xEdge = Plot.resolveDomainAxisLocation(
                getDomainAxisLocation(), orientation);
        if (xAxis != null) {
            space = xAxis.reserveSpace(g2, this, plotArea, xEdge, space);
        }
    }

    Rectangle2D adjustedPlotArea = space.shrink(plotArea, null);

    // work out the maximum height or width of the non-shared axes...
    int n = this.subplots.size();
    int totalWeight = 0;
    for (int i = 0; i < n; i++) {
        XYPlot sub = (XYPlot) this.subplots.get(i);
        totalWeight += sub.getWeight();
    }
    this.subplotAreas = new Rectangle2D[n];
    double x = adjustedPlotArea.getX();
    double y = adjustedPlotArea.getY();
    double usableSize = 0.0;
    if (orientation == PlotOrientation.HORIZONTAL) {
        usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1);
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1);
    }

    for (int i = 0; i < n; i++) {
        XYPlot plot = (XYPlot) this.subplots.get(i);

        // calculate sub-plot area
        if (orientation == PlotOrientation.HORIZONTAL) {
            double w = usableSize * plot.getWeight() / totalWeight;
            this.subplotAreas[i] = new Rectangle2D.Double(x, y, w,
                    adjustedPlotArea.getHeight());
            x = x + w + this.gap;
        }
        else if (orientation == PlotOrientation.VERTICAL) {
            double h = usableSize * plot.getWeight() / totalWeight;
            this.subplotAreas[i] = new Rectangle2D.Double(x, y,
                    adjustedPlotArea.getWidth(), h);
            y = y + h + this.gap;
        }

        AxisSpace subSpace = plot.calculateRangeAxisSpace(g2,
                this.subplotAreas[i], null);
        space.ensureAtLeast(subSpace);

    }

    return space;
}
 
Example 19
Source File: CombinedRangeXYPlot.java    From openstock with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Calculates the space required for the axes.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 *
 * @return The space required for the axes.
 */
@Override
protected AxisSpace calculateAxisSpace(Graphics2D g2,
                                       Rectangle2D plotArea) {

    AxisSpace space = new AxisSpace();
    PlotOrientation orientation = getOrientation();

    // work out the space required by the domain axis...
    AxisSpace fixed = getFixedRangeAxisSpace();
    if (fixed != null) {
        if (orientation == PlotOrientation.VERTICAL) {
            space.setLeft(fixed.getLeft());
            space.setRight(fixed.getRight());
        }
        else if (orientation == PlotOrientation.HORIZONTAL) {
            space.setTop(fixed.getTop());
            space.setBottom(fixed.getBottom());
        }
    }
    else {
        ValueAxis valueAxis = getRangeAxis();
        RectangleEdge valueEdge = Plot.resolveRangeAxisLocation(
            getRangeAxisLocation(), orientation
        );
        if (valueAxis != null) {
            space = valueAxis.reserveSpace(g2, this, plotArea, valueEdge,
                    space);
        }
    }

    Rectangle2D adjustedPlotArea = space.shrink(plotArea, null);
    // work out the maximum height or width of the non-shared axes...
    int n = this.subplots.size();
    int totalWeight = 0;
    for (int i = 0; i < n; i++) {
        XYPlot sub = (XYPlot) this.subplots.get(i);
        totalWeight += sub.getWeight();
    }

    // calculate plotAreas of all sub-plots, maximum vertical/horizontal
    // axis width/height
    this.subplotAreas = new Rectangle2D[n];
    double x = adjustedPlotArea.getX();
    double y = adjustedPlotArea.getY();
    double usableSize = 0.0;
    if (orientation == PlotOrientation.VERTICAL) {
        usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1);
    }
    else if (orientation == PlotOrientation.HORIZONTAL) {
        usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1);
    }

    for (int i = 0; i < n; i++) {
        XYPlot plot = (XYPlot) this.subplots.get(i);

        // calculate sub-plot area
        if (orientation == PlotOrientation.VERTICAL) {
            double w = usableSize * plot.getWeight() / totalWeight;
            this.subplotAreas[i] = new Rectangle2D.Double(x, y, w,
                    adjustedPlotArea.getHeight());
            x = x + w + this.gap;
        }
        else if (orientation == PlotOrientation.HORIZONTAL) {
            double h = usableSize * plot.getWeight() / totalWeight;
            this.subplotAreas[i] = new Rectangle2D.Double(x, y,
                    adjustedPlotArea.getWidth(), h);
            y = y + h + this.gap;
        }

        AxisSpace subSpace = plot.calculateDomainAxisSpace(g2,
                this.subplotAreas[i], null);
        space.ensureAtLeast(subSpace);

    }

    return space;
}
 
Example 20
Source File: CombinedRangeCategoryPlot.java    From openstock with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Calculates the space required for the axes.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 *
 * @return The space required for the axes.
 */
@Override
protected AxisSpace calculateAxisSpace(Graphics2D g2, 
        Rectangle2D plotArea) {

    AxisSpace space = new AxisSpace();
    PlotOrientation orientation = getOrientation();

    // work out the space required by the domain axis...
    AxisSpace fixed = getFixedRangeAxisSpace();
    if (fixed != null) {
        if (orientation == PlotOrientation.VERTICAL) {
            space.setLeft(fixed.getLeft());
            space.setRight(fixed.getRight());
        }
        else if (orientation == PlotOrientation.HORIZONTAL) {
            space.setTop(fixed.getTop());
            space.setBottom(fixed.getBottom());
        }
    }
    else {
        ValueAxis valueAxis = getRangeAxis();
        RectangleEdge valueEdge = Plot.resolveRangeAxisLocation(
                getRangeAxisLocation(), orientation);
        if (valueAxis != null) {
            space = valueAxis.reserveSpace(g2, this, plotArea, valueEdge,
                    space);
        }
    }

    Rectangle2D adjustedPlotArea = space.shrink(plotArea, null);
    // work out the maximum height or width of the non-shared axes...
    int n = this.subplots.size();
    int totalWeight = 0;
    for (int i = 0; i < n; i++) {
        CategoryPlot sub = (CategoryPlot) this.subplots.get(i);
        totalWeight += sub.getWeight();
    }
    // calculate plotAreas of all sub-plots, maximum vertical/horizontal
    // axis width/height
    this.subplotArea = new Rectangle2D[n];
    double x = adjustedPlotArea.getX();
    double y = adjustedPlotArea.getY();
    double usableSize = 0.0;
    if (orientation == PlotOrientation.VERTICAL) {
        usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1);
    }
    else if (orientation == PlotOrientation.HORIZONTAL) {
        usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1);
    }

    for (int i = 0; i < n; i++) {
        CategoryPlot plot = (CategoryPlot) this.subplots.get(i);

        // calculate sub-plot area
        if (orientation == PlotOrientation.VERTICAL) {
            double w = usableSize * plot.getWeight() / totalWeight;
            this.subplotArea[i] = new Rectangle2D.Double(x, y, w,
                    adjustedPlotArea.getHeight());
            x = x + w + this.gap;
        }
        else if (orientation == PlotOrientation.HORIZONTAL) {
            double h = usableSize * plot.getWeight() / totalWeight;
            this.subplotArea[i] = new Rectangle2D.Double(x, y,
                    adjustedPlotArea.getWidth(), h);
            y = y + h + this.gap;
        }

        AxisSpace subSpace = plot.calculateDomainAxisSpace(g2,
                this.subplotArea[i], null);
        space.ensureAtLeast(subSpace);

    }

    return space;
}