org.jfree.chart.axis.AxisSpace Java Examples

The following examples show how to use org.jfree.chart.axis.AxisSpace. 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: CombinedDomainCategoryPlot.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sets the size (width or height, depending on the orientation of the
 * plot) for the range axis of each subplot.
 *
 * @param space  the space (<code>null</code> permitted).
 */
protected void setFixedRangeAxisSpaceForSubplots(AxisSpace space) {
    Iterator iterator = this.subplots.iterator();
    while (iterator.hasNext()) {
        CategoryPlot plot = (CategoryPlot) iterator.next();
        plot.setFixedRangeAxisSpace(space, false);
    }
}
 
Example #2
Source File: CombinedDomainXYPlot.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sets the size (width or height, depending on the orientation of the
 * plot) for the domain axis of each subplot.
 *
 * @param space  the space.
 */
protected void setFixedRangeAxisSpaceForSubplots(AxisSpace space) {
    Iterator iterator = this.subplots.iterator();
    while (iterator.hasNext()) {
        XYPlot plot = (XYPlot) iterator.next();
        plot.setFixedRangeAxisSpace(space, false);
    }
}
 
Example #3
Source File: CombinedDomainCategoryPlot.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sets the size (width or height, depending on the orientation of the
 * plot) for the range axis of each subplot.
 *
 * @param space  the space (<code>null</code> permitted).
 */
protected void setFixedRangeAxisSpaceForSubplots(AxisSpace space) {
    Iterator iterator = this.subplots.iterator();
    while (iterator.hasNext()) {
        CategoryPlot plot = (CategoryPlot) iterator.next();
        plot.setFixedRangeAxisSpace(space, false);
    }
}
 
Example #4
Source File: CategoryPlotTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some more cloning checks.
 */
@Test
public void testCloning2() {
    AxisSpace da1 = new AxisSpace();
    AxisSpace ra1 = new AxisSpace();
    CategoryPlot p1 = new CategoryPlot();
    p1.setFixedDomainAxisSpace(da1);
    p1.setFixedRangeAxisSpace(ra1);
    CategoryPlot p2;
    try {
        p2 = (CategoryPlot) p1.clone();
    }
    catch (CloneNotSupportedException e) {
        fail("Cloning failed.");
        return;
    }
    assertTrue(p1 != p2);
    assertTrue(p1.getClass() == p2.getClass());
    assertTrue(p1.equals(p2));

    da1.setBottom(99.0);
    assertFalse(p1.equals(p2));
    p2.getFixedDomainAxisSpace().setBottom(99.0);
    assertTrue(p1.equals(p2));

    ra1.setBottom(11.0);
    assertFalse(p1.equals(p2));
    p2.getFixedRangeAxisSpace().setBottom(11.0);
    assertTrue(p1.equals(p2));
}
 
Example #5
Source File: Cardumen_0082_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Calculates the space required for all the axes in the plot.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 *
 * @return The required space.
 */
protected AxisSpace calculateAxisSpace(Graphics2D g2,
                                       Rectangle2D plotArea) {
    AxisSpace space = new AxisSpace();
    space = calculateRangeAxisSpace(g2, plotArea, space);
    Rectangle2D revPlotArea = space.shrink(plotArea, null);
    space = calculateDomainAxisSpace(g2, revPlotArea, space);
    return space;
}
 
Example #6
Source File: CombinedDomainXYPlot.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the fixed range axis space and sends a {@link PlotChangeEvent} to
 * all registered listeners.
 *
 * @param space  the space (<code>null</code> permitted).
 */
@Override
public void setFixedRangeAxisSpace(AxisSpace space) {
    super.setFixedRangeAxisSpace(space);
    setFixedRangeAxisSpaceForSubplots(space);
    fireChangeEvent();
}
 
Example #7
Source File: Cardumen_009_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Calculates the space required for all the axes in the plot.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 *
 * @return The required space.
 */
protected AxisSpace calculateAxisSpace(Graphics2D g2,
                                       Rectangle2D plotArea) {
    AxisSpace space = new AxisSpace();
    space = calculateRangeAxisSpace(g2, plotArea, space);
    Rectangle2D revPlotArea = space.shrink(plotArea, null);
    space = calculateDomainAxisSpace(g2, revPlotArea, space);
    return space;
}
 
Example #8
Source File: Cardumen_009_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Calculates the space required for all the axes in the plot.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 *
 * @return The required space.
 */
protected AxisSpace calculateAxisSpace(Graphics2D g2,
                                       Rectangle2D plotArea) {
    AxisSpace space = new AxisSpace();
    space = calculateRangeAxisSpace(g2, plotArea, space);
    Rectangle2D revPlotArea = space.shrink(plotArea, null);
    space = calculateDomainAxisSpace(g2, revPlotArea, space);
    return space;
}
 
Example #9
Source File: CategoryPlotTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Some more cloning checks.
 */
@Test
public void testCloning2() {
    AxisSpace da1 = new AxisSpace();
    AxisSpace ra1 = new AxisSpace();
    CategoryPlot p1 = new CategoryPlot();
    p1.setFixedDomainAxisSpace(da1);
    p1.setFixedRangeAxisSpace(ra1);
    CategoryPlot p2;
    try {
        p2 = (CategoryPlot) p1.clone();
    }
    catch (CloneNotSupportedException e) {
        fail("Cloning failed.");
        return;
    }
    assertTrue(p1 != p2);
    assertTrue(p1.getClass() == p2.getClass());
    assertTrue(p1.equals(p2));

    da1.setBottom(99.0);
    assertFalse(p1.equals(p2));
    p2.getFixedDomainAxisSpace().setBottom(99.0);
    assertTrue(p1.equals(p2));

    ra1.setBottom(11.0);
    assertFalse(p1.equals(p2));
    p2.getFixedRangeAxisSpace().setBottom(11.0);
    assertTrue(p1.equals(p2));
}
 
Example #10
Source File: CombinedDomainCategoryPlot.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 = 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 {
        CategoryAxis categoryAxis = getDomainAxis();
        RectangleEdge categoryEdge = Plot.resolveDomainAxisLocation(
                getDomainAxisLocation(), orientation);
        if (categoryAxis != null) {
            space = categoryAxis.reserveSpace(g2, this, plotArea,
                    categoryEdge, space);
        }
        else {
            if (getDrawSharedDomainAxis()) {
                space = getDomainAxis().reserveSpace(g2, this, plotArea,
                        categoryEdge, 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();
    }
    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++) {
        CategoryPlot plot = (CategoryPlot) 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 #11
Source File: CombinedDomainXYPlot.java    From SIMVA-SoS with Apache License 2.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 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.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 #13
Source File: CombinedDomainCategoryPlot.java    From opensim-gui with Apache License 2.0 4 votes vote down vote up
/**
 * Draws the plot on a Java 2D graphics device (such as the screen or a 
 * printer).  Will perform all the placement calculations for each of the
 * sub-plots and then tell these to draw themselves.
 *
 * @param g2  the graphics device.
 * @param area  the area within which the plot (including axis labels) 
 *              should be drawn.
 * @param anchor  the anchor point (<code>null</code> permitted).
 * @param parentState  the state from the parent plot, if there is one.
 * @param info  collects information about the drawing (<code>null</code> 
 *              permitted).
 */
public void draw(Graphics2D g2, 
                 Rectangle2D area, 
                 Point2D anchor,
                 PlotState parentState,
                 PlotRenderingInfo info) {
    
    // set up info collection...
    if (info != null) {
        info.setPlotArea(area);
    }

    // adjust the drawing area for plot insets (if any)...
    RectangleInsets insets = getInsets();
    area.setRect(area.getX() + insets.getLeft(),
            area.getY() + insets.getTop(),
            area.getWidth() - insets.getLeft() - insets.getRight(),
            area.getHeight() - insets.getTop() - insets.getBottom());


    // calculate the data area...
    setFixedRangeAxisSpaceForSubplots(null);
    AxisSpace space = calculateAxisSpace(g2, area);
    Rectangle2D dataArea = space.shrink(area, null);

    // set the width and height of non-shared axis of all sub-plots
    setFixedRangeAxisSpaceForSubplots(space);

    // draw the shared axis
    CategoryAxis axis = getDomainAxis();
    RectangleEdge domainEdge = getDomainAxisEdge();
    double cursor = RectangleEdge.coordinate(dataArea, domainEdge);
    AxisState axisState = axis.draw(g2, cursor, area, dataArea, 
            domainEdge, info);
    if (parentState == null) {
        parentState = new PlotState();
    }
    parentState.getSharedAxisStates().put(axis, axisState);
    
    // draw all the subplots
    for (int i = 0; i < this.subplots.size(); i++) {
        CategoryPlot plot = (CategoryPlot) this.subplots.get(i);
        PlotRenderingInfo subplotInfo = null;
        if (info != null) {
            subplotInfo = new PlotRenderingInfo(info.getOwner());
            info.addSubplotInfo(subplotInfo);
        }
        plot.draw(g2, this.subplotAreas[i], null, parentState, subplotInfo);
    }

    if (info != null) {
        info.setDataArea(dataArea);
    }

}
 
Example #14
Source File: CombinedRangeCategoryPlot.java    From opensim-gui with Apache License 2.0 4 votes vote down vote up
/**
 * Draws the plot on a Java 2D graphics device (such as the screen or a 
 * printer).  Will perform all the placement calculations for each 
 * sub-plots and then tell these to draw themselves.
 *
 * @param g2  the graphics device.
 * @param area  the area within which the plot (including axis labels)
 *              should be drawn.
 * @param anchor  the anchor point (<code>null</code> permitted).
 * @param parentState  the parent state.
 * @param info  collects information about the drawing (<code>null</code> 
 *              permitted).
 */
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor,
                 PlotState parentState,
                 PlotRenderingInfo info) {

    // set up info collection...
    if (info != null) {
        info.setPlotArea(area);
    }

    // adjust the drawing area for plot insets (if any)...
    RectangleInsets insets = getInsets();
    insets.trim(area);

    // calculate the data area...
    AxisSpace space = calculateAxisSpace(g2, area);
    Rectangle2D dataArea = space.shrink(area, null);

    // set the width and height of non-shared axis of all sub-plots
    setFixedDomainAxisSpaceForSubplots(space);

    // draw the shared axis
    ValueAxis axis = getRangeAxis();
    RectangleEdge rangeEdge = getRangeAxisEdge();
    double cursor = RectangleEdge.coordinate(dataArea, rangeEdge);
    AxisState state = axis.draw(g2, cursor, area, dataArea, rangeEdge, 
            info);
    if (parentState == null) {
        parentState = new PlotState();
    }
    parentState.getSharedAxisStates().put(axis, state);
    
    // draw all the charts
    for (int i = 0; i < this.subplots.size(); i++) {
        CategoryPlot plot = (CategoryPlot) this.subplots.get(i);
        PlotRenderingInfo subplotInfo = null;
        if (info != null) {
            subplotInfo = new PlotRenderingInfo(info.getOwner());
            info.addSubplotInfo(subplotInfo);
        }
        plot.draw(g2, this.subplotArea[i], null, parentState, subplotInfo);
    }

    if (info != null) {
        info.setDataArea(dataArea);
    }

}
 
Example #15
Source File: CombinedDomainXYPlot.java    From openstock with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Draws the plot within the specified area on a graphics device.
 *
 * @param g2  the graphics device.
 * @param area  the plot area (in Java2D space).
 * @param anchor  an anchor point in Java2D space (<code>null</code>
 *                permitted).
 * @param parentState  the state from the parent plot, if there is one
 *                     (<code>null</code> permitted).
 * @param info  collects chart drawing information (<code>null</code>
 *              permitted).
 */
@Override
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor,
        PlotState parentState, PlotRenderingInfo info) {

    // set up info collection...
    if (info != null) {
        info.setPlotArea(area);
    }

    // adjust the drawing area for plot insets (if any)...
    RectangleInsets insets = getInsets();
    insets.trim(area);

    setFixedRangeAxisSpaceForSubplots(null);
    AxisSpace space = calculateAxisSpace(g2, area);
    Rectangle2D dataArea = space.shrink(area, null);

    // set the width and height of non-shared axis of all sub-plots
    setFixedRangeAxisSpaceForSubplots(space);

    // draw the shared axis
    ValueAxis axis = getDomainAxis();
    RectangleEdge edge = getDomainAxisEdge();
    double cursor = RectangleEdge.coordinate(dataArea, edge);
    AxisState axisState = axis.draw(g2, cursor, area, dataArea, edge, info);
    if (parentState == null) {
        parentState = new PlotState();
    }
    parentState.getSharedAxisStates().put(axis, axisState);

    // draw all the subplots
    for (int i = 0; i < this.subplots.size(); i++) {
        XYPlot plot = (XYPlot) this.subplots.get(i);
        PlotRenderingInfo subplotInfo = null;
        if (info != null) {
            subplotInfo = new PlotRenderingInfo(info.getOwner());
            info.addSubplotInfo(subplotInfo);
        }
        plot.draw(g2, this.subplotAreas[i], anchor, parentState,
                subplotInfo);
    }

    if (info != null) {
        info.setDataArea(dataArea);
    }

}
 
Example #16
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;
}
 
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: FastScatterPlot.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Draws the fast scatter plot on a Java 2D graphics device (such as the
 * screen or a printer).
 *
 * @param g2  the graphics device.
 * @param area   the area within which the plot (including axis labels)
 *                   should be drawn.
 * @param anchor  the anchor point (<code>null</code> permitted).
 * @param parentState  the state from the parent plot (ignored).
 * @param info  collects chart drawing information (<code>null</code>
 *              permitted).
 */
@Override
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor,
                 PlotState parentState, PlotRenderingInfo info) {

    // set up info collection...
    if (info != null) {
        info.setPlotArea(area);
    }

    // adjust the drawing area for plot insets (if any)...
    RectangleInsets insets = getInsets();
    insets.trim(area);

    AxisSpace space = new AxisSpace();
    space = this.domainAxis.reserveSpace(g2, this, area,
            RectangleEdge.BOTTOM, space);
    space = this.rangeAxis.reserveSpace(g2, this, area, RectangleEdge.LEFT,
            space);
    Rectangle2D dataArea = space.shrink(area, null);

    if (info != null) {
        info.setDataArea(dataArea);
    }

    // draw the plot background and axes...
    drawBackground(g2, dataArea);

    AxisState domainAxisState = this.domainAxis.draw(g2,
            dataArea.getMaxY(), area, dataArea, RectangleEdge.BOTTOM, info);
    AxisState rangeAxisState = this.rangeAxis.draw(g2, dataArea.getMinX(),
            area, dataArea, RectangleEdge.LEFT, info);
    drawDomainGridlines(g2, dataArea, domainAxisState.getTicks());
    drawRangeGridlines(g2, dataArea, rangeAxisState.getTicks());

    Shape originalClip = g2.getClip();
    Composite originalComposite = g2.getComposite();

    g2.clip(dataArea);
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
            getForegroundAlpha()));

    render(g2, dataArea, info, null);

    g2.setClip(originalClip);
    g2.setComposite(originalComposite);
    drawOutline(g2, dataArea);

}
 
Example #19
Source File: CombinedDomainXYPlot.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Draws the plot within the specified area on a graphics device.
 *
 * @param g2  the graphics device.
 * @param area  the plot area (in Java2D space).
 * @param anchor  an anchor point in Java2D space (<code>null</code>
 *                permitted).
 * @param parentState  the state from the parent plot, if there is one
 *                     (<code>null</code> permitted).
 * @param info  collects chart drawing information (<code>null</code>
 *              permitted).
 */
@Override
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor,
        PlotState parentState, PlotRenderingInfo info) {

    // set up info collection...
    if (info != null) {
        info.setPlotArea(area);
    }

    // adjust the drawing area for plot insets (if any)...
    RectangleInsets insets = getInsets();
    insets.trim(area);

    setFixedRangeAxisSpaceForSubplots(null);
    AxisSpace space = calculateAxisSpace(g2, area);
    Rectangle2D dataArea = space.shrink(area, null);

    // set the width and height of non-shared axis of all sub-plots
    setFixedRangeAxisSpaceForSubplots(space);

    // draw the shared axis
    ValueAxis axis = getDomainAxis();
    RectangleEdge edge = getDomainAxisEdge();
    double cursor = RectangleEdge.coordinate(dataArea, edge);
    AxisState axisState = axis.draw(g2, cursor, area, dataArea, edge, info);
    if (parentState == null) {
        parentState = new PlotState();
    }
    parentState.getSharedAxisStates().put(axis, axisState);

    // draw all the subplots
    for (int i = 0; i < this.subplots.size(); i++) {
        XYPlot plot = (XYPlot) this.subplots.get(i);
        PlotRenderingInfo subplotInfo = null;
        if (info != null) {
            subplotInfo = new PlotRenderingInfo(info.getOwner());
            info.addSubplotInfo(subplotInfo);
        }
        plot.draw(g2, this.subplotAreas[i], anchor, parentState,
                subplotInfo);
    }

    if (info != null) {
        info.setDataArea(dataArea);
    }

}
 
Example #20
Source File: CombinedRangeXYPlot.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Draws the plot within the specified area on a graphics device.
 *
 * @param g2  the graphics device.
 * @param area  the plot area (in Java2D space).
 * @param anchor  an anchor point in Java2D space (<code>null</code>
 *                permitted).
 * @param parentState  the state from the parent plot, if there is one
 *                     (<code>null</code> permitted).
 * @param info  collects chart drawing information (<code>null</code>
 *              permitted).
 */
public void draw(Graphics2D g2,
                 Rectangle2D area,
                 Point2D anchor,
                 PlotState parentState,
                 PlotRenderingInfo info) {

    // set up info collection...
    if (info != null) {
        info.setPlotArea(area);
    }

    // adjust the drawing area for plot insets (if any)...
    RectangleInsets insets = getInsets();
    insets.trim(area);

    AxisSpace space = calculateAxisSpace(g2, area);
    Rectangle2D dataArea = space.shrink(area, null);
    //this.axisOffset.trim(dataArea);

    // set the width and height of non-shared axis of all sub-plots
    setFixedDomainAxisSpaceForSubplots(space);

    // draw the shared axis
    ValueAxis axis = getRangeAxis();
    RectangleEdge edge = getRangeAxisEdge();
    double cursor = RectangleEdge.coordinate(dataArea, edge);
    AxisState axisState = axis.draw(g2, cursor, area, dataArea, edge, info);

    if (parentState == null) {
        parentState = new PlotState();
    }
    parentState.getSharedAxisStates().put(axis, axisState);

    // draw all the charts
    for (int i = 0; i < this.subplots.size(); i++) {
        XYPlot plot = (XYPlot) this.subplots.get(i);
        PlotRenderingInfo subplotInfo = null;
        if (info != null) {
            subplotInfo = new PlotRenderingInfo(info.getOwner());
            info.addSubplotInfo(subplotInfo);
        }
        plot.draw(g2, this.subplotAreas[i], anchor, parentState,
                subplotInfo);
    }

    if (info != null) {
        info.setDataArea(dataArea);
    }

}
 
Example #21
Source File: CombinedRangeXYPlot.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Draws the plot within the specified area on a graphics device.
 * 
 * @param g2  the graphics device.
 * @param area  the plot area (in Java2D space).
 * @param anchor  an anchor point in Java2D space (<code>null</code> 
 *                permitted).
 * @param parentState  the state from the parent plot, if there is one 
 *                     (<code>null</code> permitted).
 * @param info  collects chart drawing information (<code>null</code> 
 *              permitted).
 */
public void draw(Graphics2D g2,
                 Rectangle2D area,
                 Point2D anchor,
                 PlotState parentState,
                 PlotRenderingInfo info) {
    
    // set up info collection...
    if (info != null) {
        info.setPlotArea(area);
    }

    // adjust the drawing area for plot insets (if any)...
    RectangleInsets insets = getInsets();
    insets.trim(area);

    AxisSpace space = calculateAxisSpace(g2, area);
    Rectangle2D dataArea = space.shrink(area, null);
    //this.axisOffset.trim(dataArea);

    // set the width and height of non-shared axis of all sub-plots
    setFixedDomainAxisSpaceForSubplots(space);

    // draw the shared axis
    ValueAxis axis = getRangeAxis();
    RectangleEdge edge = getRangeAxisEdge();
    double cursor = RectangleEdge.coordinate(dataArea, edge);
    AxisState axisState = axis.draw(g2, cursor, area, dataArea, edge, info);

    if (parentState == null) {
        parentState = new PlotState();
    }
    parentState.getSharedAxisStates().put(axis, axisState);
    
    // draw all the charts
    for (int i = 0; i < this.subplots.size(); i++) {
        XYPlot plot = (XYPlot) this.subplots.get(i);
        PlotRenderingInfo subplotInfo = null;
        if (info != null) {
            subplotInfo = new PlotRenderingInfo(info.getOwner());
            info.addSubplotInfo(subplotInfo);
        }
        plot.draw(g2, this.subplotAreas[i], anchor, parentState, 
                subplotInfo);
    }

    if (info != null) {
        info.setDataArea(dataArea);
    }

}
 
Example #22
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 #23
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 #24
Source File: CombinedDomainXYPlot.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Draws the plot within the specified area on a graphics device.
 *
 * @param g2  the graphics device.
 * @param area  the plot area (in Java2D space).
 * @param anchor  an anchor point in Java2D space (<code>null</code>
 *                permitted).
 * @param parentState  the state from the parent plot, if there is one
 *                     (<code>null</code> permitted).
 * @param info  collects chart drawing information (<code>null</code>
 *              permitted).
 */
@Override
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor,
        PlotState parentState, PlotRenderingInfo info) {

    // set up info collection...
    if (info != null) {
        info.setPlotArea(area);
    }

    // adjust the drawing area for plot insets (if any)...
    RectangleInsets insets = getInsets();
    insets.trim(area);

    setFixedRangeAxisSpaceForSubplots(null);
    AxisSpace space = calculateAxisSpace(g2, area);
    Rectangle2D dataArea = space.shrink(area, null);

    // set the width and height of non-shared axis of all sub-plots
    setFixedRangeAxisSpaceForSubplots(space);

    // draw the shared axis
    ValueAxis axis = getDomainAxis();
    RectangleEdge edge = getDomainAxisEdge();
    double cursor = RectangleEdge.coordinate(dataArea, edge);
    AxisState axisState = axis.draw(g2, cursor, area, dataArea, edge, info);
    if (parentState == null) {
        parentState = new PlotState();
    }
    parentState.getSharedAxisStates().put(axis, axisState);

    // draw all the subplots
    for (int i = 0; i < this.subplots.size(); i++) {
        XYPlot plot = (XYPlot) this.subplots.get(i);
        PlotRenderingInfo subplotInfo = null;
        if (info != null) {
            subplotInfo = new PlotRenderingInfo(info.getOwner());
            info.addSubplotInfo(subplotInfo);
        }
        plot.draw(g2, this.subplotAreas[i], anchor, parentState,
                subplotInfo);
    }

    if (info != null) {
        info.setDataArea(dataArea);
    }

}
 
Example #25
Source File: CombinedDomainCategoryPlot.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 = 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 {
        CategoryAxis categoryAxis = getDomainAxis();
        RectangleEdge categoryEdge = Plot.resolveDomainAxisLocation(
                getDomainAxisLocation(), orientation);
        if (categoryAxis != null) {
            space = categoryAxis.reserveSpace(g2, this, plotArea,
                    categoryEdge, space);
        }
        else {
            if (getDrawSharedDomainAxis()) {
                space = getDomainAxis().reserveSpace(g2, this, plotArea,
                        categoryEdge, 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();
    }
    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++) {
        CategoryPlot plot = (CategoryPlot) 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 #26
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 #27
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 #28
Source File: 1_XYPlot.java    From SimFix with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Calculates the space required for all the axes in the plot.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 *
 * @return The required space.
 */
protected AxisSpace calculateAxisSpace(Graphics2D g2,
                                       Rectangle2D plotArea) {
    AxisSpace space = new AxisSpace();
    space = calculateDomainAxisSpace(g2, plotArea, space);
    space = calculateRangeAxisSpace(g2, plotArea, space);
    return space;
}
 
Example #29
Source File: Chart_14_XYPlot_s.java    From coming with MIT License 3 votes vote down vote up
/**
 * Calculates the space required for all the axes in the plot.
 *
 * @param g2  the graphics device.
 * @param plotArea  the plot area.
 *
 * @return The required space.
 */
protected AxisSpace calculateAxisSpace(Graphics2D g2,
                                       Rectangle2D plotArea) {
    AxisSpace space = new AxisSpace();
    space = calculateDomainAxisSpace(g2, plotArea, space);
    space = calculateRangeAxisSpace(g2, plotArea, space);
    return space;
}
 
Example #30
Source File: patch1-Chart-26-jMutRepair_patch1-Chart-26-jMutRepair_t.java    From coming with MIT License 3 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();
    space = calculateRangeAxisSpace(g2, plotArea, space);
    space = calculateDomainAxisSpace(g2, plotArea, space);
    return space;
}