Package org.jfree.chart.entity

Examples of org.jfree.chart.entity.EntityCollection


        g2.setPaint(p);
        g2.fill(block);
        g2.setStroke(new BasicStroke(1.0f));
        g2.draw(block);

        EntityCollection entities = state.getEntityCollection();
        if (entities != null) {
            addEntity(entities, block, dataset, series, item, 0.0, 0.0);
        }

    }
View Full Code Here


                                ContourDataset data,
                                CrosshairState crosshairState) {

        // setup for collecting optional entity info...
        Rectangle2D.Double entityArea = null;
        EntityCollection entities = null;
        if (info != null) {
            entities = info.getOwner().getEntityCollection();
        }

        Rectangle2D.Double rect = null;
        rect = new Rectangle2D.Double();

        //turn off anti-aliasing when filling rectangles
        Object antiAlias = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                RenderingHints.VALUE_ANTIALIAS_OFF);

        // get the data points
        Number[] xNumber = data.getXValues();
        Number[] yNumber = data.getYValues();
        Number[] zNumber = data.getZValues();

        double[] x = new double[xNumber.length];
        double[] y = new double[yNumber.length];

        for (int i = 0; i < x.length; i++) {
            x[i] = xNumber[i].doubleValue();
            y[i] = yNumber[i].doubleValue();
        }

        int[] xIndex = data.indexX();
        int[] indexX = data.getXIndices();
        boolean vertInverted = ((NumberAxis) verticalAxis).isInverted();
        boolean horizInverted = false;
        if (horizontalAxis instanceof NumberAxis) {
            horizInverted = ((NumberAxis) horizontalAxis).isInverted();
        }
        double transX = 0.0;
        double transXm1 = 0.0;
        double transXp1 = 0.0;
        double transDXm1 = 0.0;
        double transDXp1 = 0.0;
        double transDX = 0.0;
        double transY = 0.0;
        double transYm1 = 0.0;
        double transYp1 = 0.0;
        double transDYm1 = 0.0;
        double transDYp1 = 0.0;
        double transDY = 0.0;
        int iMax = xIndex[xIndex.length - 1];
        for (int k = 0; k < x.length; k++) {
            int i = xIndex[k];
            if (indexX[i] == k) { // this is a new column
                if (i == 0) {
                    transX = horizontalAxis.valueToJava2D(x[k], dataArea,
                            RectangleEdge.BOTTOM);
                    transXm1 = transX;
                    transXp1 = horizontalAxis.valueToJava2D(
                            x[indexX[i + 1]], dataArea, RectangleEdge.BOTTOM);
                    transDXm1 = Math.abs(0.5 * (transX - transXm1));
                    transDXp1 = Math.abs(0.5 * (transX - transXp1));
                }
                else if (i == iMax) {
                    transX = horizontalAxis.valueToJava2D(x[k], dataArea,
                            RectangleEdge.BOTTOM);
                    transXm1 = horizontalAxis.valueToJava2D(x[indexX[i - 1]],
                            dataArea, RectangleEdge.BOTTOM);
                    transXp1 = transX;
                    transDXm1 = Math.abs(0.5 * (transX - transXm1));
                    transDXp1 = Math.abs(0.5 * (transX - transXp1));
                }
                else {
                    transX = horizontalAxis.valueToJava2D(x[k], dataArea,
                            RectangleEdge.BOTTOM);
                    transXp1 = horizontalAxis.valueToJava2D(x[indexX[i + 1]],
                            dataArea, RectangleEdge.BOTTOM);
                    transDXm1 = transDXp1;
                    transDXp1 = Math.abs(0.5 * (transX - transXp1));
                }

                if (horizInverted) {
                    transX -= transDXp1;
                }
                else {
                    transX -= transDXm1;
                }

                transDX = transDXm1 + transDXp1;

                transY = verticalAxis.valueToJava2D(y[k], dataArea,
                        RectangleEdge.LEFT);
                transYm1 = transY;
                if (k + 1 == y.length) {
                    continue;
                }
                transYp1 = verticalAxis.valueToJava2D(y[k + 1], dataArea,
                        RectangleEdge.LEFT);
                transDYm1 = Math.abs(0.5 * (transY - transYm1));
                transDYp1 = Math.abs(0.5 * (transY - transYp1));
            }
            else if ((i < indexX.length - 1
                     && indexX[i + 1] - 1 == k) || k == x.length - 1) {
                // end of column
                transY = verticalAxis.valueToJava2D(y[k], dataArea,
                        RectangleEdge.LEFT);
                transYm1 = verticalAxis.valueToJava2D(y[k - 1], dataArea,
                        RectangleEdge.LEFT);
                transYp1 = transY;
                transDYm1 = Math.abs(0.5 * (transY - transYm1));
                transDYp1 = Math.abs(0.5 * (transY - transYp1));
            }
            else {
                transY = verticalAxis.valueToJava2D(y[k], dataArea,
                        RectangleEdge.LEFT);
                transYp1 = verticalAxis.valueToJava2D(y[k + 1], dataArea,
                        RectangleEdge.LEFT);
                transDYm1 = transDYp1;
                transDYp1 = Math.abs(0.5 * (transY - transYp1));
            }
            if (vertInverted) {
                transY -= transDYm1;
            }
            else {
                transY -= transDYp1;
            }

            transDY = transDYm1 + transDYp1;

            rect.setRect(transX, transY, transDX, transDY);
            if (zNumber[k] != null) {
                g2.setPaint(colorBar.getPaint(zNumber[k].doubleValue()));
                g2.fill(rect);
            }
            else if (this.missingPaint != null) {
                g2.setPaint(this.missingPaint);
                g2.fill(rect);
            }

            entityArea = rect;

            // add an entity for the item...
            if (entities != null) {
                String tip = "";
                if (getToolTipGenerator() != null) {
                    tip = this.toolTipGenerator.generateToolTip(data, k);
                }
//              Shape s = g2.getClip();
//              if (s.contains(rect) || s.intersects(rect)) {
                String url = null;
                // if (getURLGenerator() != null) {    //dmo: look at this later
                //      url = getURLGenerator().generateURL(data, series, item);
                // }
                // Unlike XYItemRenderer, we need to clone entityArea since it
                // reused.
                ContourEntity entity = new ContourEntity(
                        (Rectangle2D.Double) entityArea.clone(), tip, url);
                entity.setIndex(k);
                entities.add(entity);
//              }
            }

            // do we need to update the crosshair values?
            if (plot.isDomainCrosshairLockedOnData()) {
View Full Code Here

                              ContourDataset data,
                              CrosshairState crosshairState) {

        // setup for collecting optional entity info...
        RectangularShape entityArea = null;
        EntityCollection entities = null;
        if (info != null) {
            entities = info.getOwner().getEntityCollection();
        }

//      Rectangle2D.Double rect = null;
//      rect = new Rectangle2D.Double();
        RectangularShape rect = new Ellipse2D.Double();


        //turn off anti-aliasing when filling rectangles
        Object antiAlias = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                RenderingHints.VALUE_ANTIALIAS_OFF);

        // if (tooltips!=null) tooltips.clearToolTips(); // reset collection
        // get the data points
        Number[] xNumber = data.getXValues();
        Number[] yNumber = data.getYValues();
        Number[] zNumber = data.getZValues();

        double[] x = new double[xNumber.length];
        double[] y = new double[yNumber.length];

        for (int i = 0; i < x.length; i++) {
            x[i] = xNumber[i].doubleValue();
            y[i] = yNumber[i].doubleValue();
        }

        double transX = 0.0;
        double transDX = 0.0;
        double transY = 0.0;
        double transDY = 0.0;
        double size = dataArea.getWidth() * this.ptSizePct;
        for (int k = 0; k < x.length; k++) {

            transX = domainAxis.valueToJava2D(x[k], dataArea,
                    RectangleEdge.BOTTOM) - 0.5 * size;
            transY = rangeAxis.valueToJava2D(y[k], dataArea, RectangleEdge.LEFT)
                     - 0.5 * size;
            transDX = size;
            transDY = size;

            rect.setFrame(transX, transY, transDX, transDY);

            if (zNumber[k] != null) {
                g2.setPaint(colorBar.getPaint(zNumber[k].doubleValue()));
                g2.fill(rect);
            }
            else if (this.missingPaint != null) {
                g2.setPaint(this.missingPaint);
                g2.fill(rect);
            }


            entityArea = rect;

            // add an entity for the item...
            if (entities != null) {
                String tip = null;
                if (getToolTipGenerator() != null) {
                    tip = this.toolTipGenerator.generateToolTip(data, k);
                }
                String url = null;
                // if (getURLGenerator() != null) {   //dmo: look at this later
                //   url = getURLGenerator().generateURL(data, series, item);
                // }
                // Unlike XYItemRenderer, we need to clone entityArea since it
                // reused.
                ContourEntity entity = new ContourEntity(
                        (RectangularShape) entityArea.clone(), tip, url);
                entity.setIndex(k);
                entities.add(entity);
            }

            // do we need to update the crosshair values?
            if (plot.isDomainCrosshairLockedOnData()) {
                if (plot.isRangeCrosshairLockedOnData()) {
View Full Code Here

   protected void createAndAddEntity(Rectangle2D dataArea,
           PlotRenderingInfo plotState, String toolTip, String urlText)
   {
      if (plotState != null && plotState.getOwner() != null)
      {
         EntityCollection e = plotState.getOwner().getEntityCollection();
         if (e != null)
         {
            e.add(new PlotEntity(dataArea, this, toolTip, urlText));
         }
      }
   }
View Full Code Here

        drawDisc(g2, shape, discPaint, item);
        drawLabel(g2, plot, dataset, shape, key, discPaint);
        drawOutline(g2, shape, key);
       
        if (info != null) {
            EntityCollection entities = state.getEntityCollection();
            if (entities != null) {
                String tip = null;
                if (plot.getToolTipGenerator() != null) {
                    tip = plot.getToolTipGenerator().generateToolTip(
                            dataset, key);
                }
                String url = null;
                if (plot.getUrlGenerator() != null) {
                    url = plot.getUrlGenerator().generateURL(dataset,
                            key, item);
                }
                DiscItemEntity entity = new DiscItemEntity(shape, dataset,
                        item, key, tip, url);
                entities.add(entity);
            }
        }
           
    }
View Full Code Here

            // the entire chart at the beginning of the list.  This will
            // make it appear last in the image map (which is important,
            // because browsers process the image map areas in the order that
            // they appear; having the entire chart area listed first would
            // obscure all of the other image map areas).
            EntityCollection entities = new StandardEntityCollection();
            entities.add(new ChartEntity(info.getChartArea(), tooltip, href));
            if (info.getEntityCollection() != null)
                entities.addAll(info.getEntityCollection());
           
            // Next: most of our chart entities will not have URLs. URL values
            // don't inherit in the imagemap, so if we want the entire image
            // to have a single URL, we need to assign that URL to every
            // area in the chart.
            for (Iterator i = entities.iterator(); i.hasNext();) {
                ChartEntity ce = (ChartEntity) i.next();
                // check for no-op chart entity - these won't appear in the
                // image map anyway, so they don't need to be adjusted
                if (ce.getToolTipText() == null && ce.getURLText() == null)
                    continue;
View Full Code Here

                                   ValueAxis rangeAxis,
                                   Rectangle2D dataArea) {
        super.drawPrimaryLine(state, g2, plot, dataset, pass, series, item, domainAxis,
                rangeAxis, dataArea);
       
        EntityCollection entities = state.getEntityCollection();
        if (entities != null && item > 0) {
            Shape tooltipArea = getTooltipArea(state.workingLine, series);
            addEntity(entities, tooltipArea, dataset, series, item, 0, 0);
        }
       
View Full Code Here

                         int item,
                         CrosshairState crosshairInfo,
                         int pass) {

        // setup for collecting optional entity info...
        EntityCollection entities = null;
        if (info != null) {
            entities = info.getOwner().getEntityCollection();
        }
        Shape entityArea = null;
View Full Code Here

      // cross hairs?

      // Where are the cross hairs pointing?
      lastPointClicked = chartPanel.getAnchor();

      EntityCollection entities = chartPanel.getChartRenderingInfo()
          .getEntityCollection();

      double closestDist = Double.MAX_VALUE;

      // Note: This operation is linear in the number of visible
      // observations!
      // Unfortunately, the list of XYItemEntities must always be searched
      // exhaustively since we don't know which XYItemEntity will turn out
      // to be closest to the mouse selection. Actually, this may not be
      // the case if we can assume an ordering of XYItemEntities by domain
      // (X). If so, once itemBounds.getCenterX() is greater than
      // lastPointClicked.getX(), we could terminate the loop. But I don't
      // know if we can make that assumption.
      @SuppressWarnings("unchecked")
      Iterator it = entities.iterator();
      while (it.hasNext()) {
        Object o = it.next();
        if (o instanceof XYItemEntity) {
          XYItemEntity entity = (XYItemEntity) o;
          Rectangle2D itemBounds = entity.getArea().getBounds2D();
View Full Code Here

   *            The observation in question.
   */
  protected void updateSelectionFromObservation(ValidObservation ob) {
    lastObSelected = ob;

    EntityCollection entities = chartPanel.getChartRenderingInfo()
        .getEntityCollection();

    // Note: This operation is linear in the number of observations!
    // However, the loop will on average terminate before exhaustively
    // searching all entries, i.e. when the observation is matched up
    // with the corresponding XYItemEntity. It's still O(n) though.
    // TODO: Use RendererUtilities method to return a list of entity indices
    // that lie in a given x (JD/phase) range; this would reduce n.
    @SuppressWarnings("unchecked")
    Iterator it = entities.iterator();
    while (it.hasNext()) {
      Object o = it.next();
      if (o instanceof XYItemEntity) {
        XYItemEntity item = (XYItemEntity) o;
        // Dataset may not be same as primary observation model, e.g.
View Full Code Here

TOP

Related Classes of org.jfree.chart.entity.EntityCollection

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.