Package org.jfree.chart.axis

Examples of org.jfree.chart.axis.AxisSpace


     * @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 = 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);

        }

View Full Code Here


                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
View Full Code Here

   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
      {
         // reserve space for the domain axes...
         for (int i = 0; i < super.getDomainAxes().size(); i++)
         {
            Axis axisCur = (Axis) super.getDomainAxes().get(i);

            if (axisCur != null)
            {
               RectangleEdge edge = getDomainAxisEdge(i);
               space = axisCur.reserveSpace(g2, this, plotArea, edge, space);
            }
         }


         /*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 += 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 += h + this.gap;
         }

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

View Full Code Here

      setFixedRangeAxisSpaceForSubplots(null);
     
      //--beg modified amadeus
      //This code has been modified to fix a bug with Combine Domain XY Plot axis
      //The axis dimensioin were too big.
      AxisSpace space = calculateAxisSpace(g2, area);
     
      space.setBottom(space.getBottom() + this._dblCombinedDomainAxisBoundariesShift_);
      space.setTop(space.getTop() + this._dblCombinedDomainAxisBoundariesShift_);
     
     
      Rectangle2D dataArea = space.shrink(area, null);
     
      space.setBottom(space.getBottom() - this._dblCombinedDomainAxisBoundariesShift_);
      space.setTop(space.getTop() - this._dblCombinedDomainAxisBoundariesShift_);
     
      dataArea = integerise(dataArea);
      //end modified amadeus
    
      //dataArea = new Rectangle2D.Double();
View Full Code Here

        // 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);
        }
View Full Code Here

        assertFalse(plot1.equals(plot2));
        plot2.setWeight(3);
        assertTrue(plot1.equals(plot2));

        // fixed domain axis space...
        plot1.setFixedDomainAxisSpace(new AxisSpace());
        assertFalse(plot1.equals(plot2));
        plot2.setFixedDomainAxisSpace(new AxisSpace());
        assertTrue(plot1.equals(plot2));

        // fixed range axis space...
        plot1.setFixedRangeAxisSpace(new AxisSpace());
        assertFalse(plot1.equals(plot2));
        plot2.setFixedRangeAxisSpace(new AxisSpace());
        assertTrue(plot1.equals(plot2));

        // fixed legend items
        plot1.setFixedLegendItems(new LegendItemCollection());
        assertFalse(plot1.equals(plot2));
View Full Code Here

    /**
     * Some more cloning checks.
     */
    public void testCloning2() {
        AxisSpace da1 = new AxisSpace();
        AxisSpace ra1 = new AxisSpace();
        CategoryPlot p1 = new CategoryPlot();
        p1.setFixedDomainAxisSpace(da1);
        p1.setFixedRangeAxisSpace(ra1);
        CategoryPlot p2 = null;
        try {
            p2 = (CategoryPlot) p1.clone();
        }
        catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        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));
    }
View Full Code Here

    protected AxisSpace calculateDomainAxisSpace(Graphics2D g2,
                                                 Rectangle2D plotArea,
                                                 AxisSpace space) {

        if (space == null) {
            space = new AxisSpace();
        }

        // reserve some space for the domain axis...
        if (this.fixedDomainAxisSpace != null) {
            if (this.orientation == PlotOrientation.HORIZONTAL) {
View Full Code Here

    protected AxisSpace calculateRangeAxisSpace(Graphics2D g2,
                                                Rectangle2D plotArea,
                                                AxisSpace space) {

        if (space == null) {
            space = new AxisSpace();
        }

        // reserve some space for the range axis...
        if (this.fixedRangeAxisSpace != null) {
            if (this.orientation == PlotOrientation.HORIZONTAL) {
View Full Code Here

     *
     * @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;
    }
View Full Code Here

TOP

Related Classes of org.jfree.chart.axis.AxisSpace

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.