Examples of XYPlot


Examples of org.jfree.chart.plot.XYPlot

  protected void configureChart(final JFreeChart chart)
  {
    super.configureChart(chart);

    final XYPlot plot = chart.getXYPlot();

    if (isSharedRangeAxis() == false)
    {
      final ValueAxis linesAxis = plot.getRangeAxis(1);
      if (linesAxis instanceof NumberAxis)
      {
        final NumberAxis numberAxis = (NumberAxis) linesAxis;

        if (getLinePeriodCount() > 0)
        {
          if (getLineTicksLabelFormat() != null)
          {
            final FastDecimalFormat formatter = new FastDecimalFormat
                (getLineTicksLabelFormat(), getResourceBundleFactory().getLocale());
            numberAxis.setTickUnit(new FastNumberTickUnit(getLinePeriodCount(), formatter));
          }
          else
          {
            numberAxis.setTickUnit(new FastNumberTickUnit(getLinePeriodCount()));
          }
        }
        else
        {
          if (getLineTicksLabelFormat() != null)
          {
            final DecimalFormat formatter = new DecimalFormat
                (getLineTicksLabelFormat(), new DecimalFormatSymbols(getResourceBundleFactory().getLocale()));
            numberAxis.setNumberFormatOverride(formatter);
          }
        }
      }
      else if (linesAxis instanceof DateAxis)
      {
        final DateAxis numberAxis = (DateAxis) linesAxis;

        if (getLinePeriodCount() > 0 && getLineTimePeriod() != null)
        {
          if (getLineTicksLabelFormat() != null)
          {
            final SimpleDateFormat formatter = new SimpleDateFormat
                (getLineTicksLabelFormat(), new DateFormatSymbols(getResourceBundleFactory().getLocale()));
            numberAxis.setTickUnit
                (new DateTickUnit(getDateUnitAsInt(getLineTimePeriod()), (int) getLinePeriodCount(), formatter));
          }
          else
          {
            numberAxis.setTickUnit
                (new DateTickUnit(getDateUnitAsInt(getLineTimePeriod()), (int) getLinePeriodCount()));
          }
        }
        else if (getRangeTickFormatString() != null)
        {
          final SimpleDateFormat formatter = new SimpleDateFormat
              (getRangeTickFormatString(), new DateFormatSymbols(getResourceBundleFactory().getLocale()));
          numberAxis.setDateFormatOverride(formatter);
        }
      }

      if (linesAxis != null)
      {
        final Font labelFont = Font.decode(getLabelFont());
        linesAxis.setLabelFont(labelFont);
        linesAxis.setTickLabelFont(labelFont);

        if (getLineTitleFont() != null)
        {
          linesAxis.setLabelFont(getLineTitleFont());
        }
        if (getLineTickFont() != null)
        {
          linesAxis.setTickLabelFont(getLineTickFont());
        }
        final Double lineRangeMin = getLineRangeMinimum();
        if (lineRangeMin != null)
        {
          linesAxis.setLowerBound(lineRangeMin.doubleValue());
        }
        final Double lineRangeMax = getLineRangeMaximum();
        if (lineRangeMax != null)
        {
          linesAxis.setUpperBound(lineRangeMax.doubleValue());
        }
      }
    }

    final XYLineAndShapeRenderer linesRenderer = (XYLineAndShapeRenderer) plot.getRenderer(1);
    if (linesRenderer != null)
    {
      //set stroke with line width
      linesRenderer.setStroke(translateLineStyle(getLineWidth(), getLineStyle()));
      //hide shapes on line
View Full Code Here

Examples of org.jfree.chart.plot.XYPlot

  protected void configureChart(final JFreeChart chart)
  {
    super.configureChart(chart);

    final XYPlot plot = chart.getXYPlot();
    final XYItemRenderer renderer = plot.getRenderer();

    if (StringUtils.isEmpty(getTooltipFormula()) == false)
    {
      renderer.setBaseToolTipGenerator(new FormulaXYZTooltipGenerator(getRuntime(), getTooltipFormula()));
    }
    if (StringUtils.isEmpty(getUrlFormula()) == false)
    {
      renderer.setURLGenerator(new FormulaXYZURLGenerator(getRuntime(), getUrlFormula()));
    }
    renderer.setBaseItemLabelsVisible(Boolean.TRUE.equals(getItemsLabelVisible()));
    if (getItemLabelFont() != null)
    {
      renderer.setBaseItemLabelFont(getItemLabelFont());
    }

    plot.setOrientation(computePlotOrientation());

    // May be an axis that supports dates
    final ValueAxis domainAxis = plot.getDomainAxis();
    if (domainAxis instanceof NumberAxis)
    {
      final NumberAxis numberAxis = (NumberAxis) domainAxis;
      numberAxis.setAutoRangeIncludesZero(isDomainIncludesZero());
      numberAxis.setAutoRangeStickyZero(isDomainStickyZero());
      if (getDomainPeriodCount() > 0)
      {
        if (getDomainTickFormat() != null)
        {
          numberAxis.setTickUnit(new NumberTickUnit(getDomainPeriodCount(), getDomainTickFormat()));
        }
        else if (getDomainTickFormatString() != null)
        {
          final FastDecimalFormat formatter = new FastDecimalFormat
              (getDomainTickFormatString(), getResourceBundleFactory().getLocale());
          numberAxis.setTickUnit(new FastNumberTickUnit(getDomainPeriodCount(), formatter));
        }
        else
        {
          numberAxis.setTickUnit(new FastNumberTickUnit(getDomainPeriodCount()));
        }
      }
      else
      {
        if (getDomainTickFormat() != null)
        {
          numberAxis.setNumberFormatOverride(getDomainTickFormat());
        }
        else if (getDomainTickFormatString() != null)
        {
          final DecimalFormat formatter = new DecimalFormat
              (getDomainTickFormatString(), new DecimalFormatSymbols(getResourceBundleFactory().getLocale()));
          numberAxis.setNumberFormatOverride(formatter);
        }
      }
    }
    else if (domainAxis instanceof DateAxis)
    {
      final DateAxis numberAxis = (DateAxis) domainAxis;

      if (getDomainPeriodCount() > 0 && getDomainTimePeriod() != null)
      {
        if (getDomainTickFormatString() != null)
        {
          final SimpleDateFormat formatter = new SimpleDateFormat
              (getDomainTickFormatString(), new DateFormatSymbols(getResourceBundleFactory().getLocale()));
          numberAxis.setTickUnit
              (new DateTickUnit(getDateUnitAsInt(getDomainTimePeriod()), (int) getDomainPeriodCount(), formatter));
        }
        else
        {
          numberAxis.setTickUnit
              (new DateTickUnit(getDateUnitAsInt(getDomainTimePeriod()), (int) getDomainPeriodCount()));
        }
      }
    }

    if (domainAxis != null)
    {
      domainAxis.setLabel(getDomainTitle());
      if (getDomainTitleFont() != null)
      {
        domainAxis.setLabelFont(getDomainTitleFont());
      }
      domainAxis.setVerticalTickLabels(isDomainVerticalTickLabels());
      if (getDomainTickFont() != null)
      {
        domainAxis.setTickLabelFont(getDomainTickFont());
      }
      if (getDomainMinimum() != ValueAxis.DEFAULT_LOWER_BOUND)
      {
        domainAxis.setLowerBound(getDomainMinimum());
      }
      if (getDomainMaximum() != ValueAxis.DEFAULT_UPPER_BOUND)
      {
        domainAxis.setUpperBound(getDomainMaximum());
      }
    }

    final ValueAxis rangeAxis = plot.getRangeAxis();
    if (rangeAxis instanceof NumberAxis)
    {
      final NumberAxis numberAxis = (NumberAxis) rangeAxis;

      if (getRangePeriodCount() > 0)
View Full Code Here

Examples of org.jfree.chart.plot.XYPlot

  protected void configureChart(final JFreeChart chart)
  {
    super.configureChart(chart);

    final XYPlot xypl = chart.getXYPlot();
    final XYItemRenderer renderer = xypl.getRenderer();
    renderer.setStroke(translateLineStyle(lineWidth, lineStyle));
    if (renderer instanceof XYLineAndShapeRenderer)
    {
      final XYLineAndShapeRenderer renderer1 = (XYLineAndShapeRenderer) renderer;
      renderer1.setShapesVisible(isMarkersVisible());
View Full Code Here

Examples of org.jfree.chart.plot.XYPlot

    this(chart,0,0,400,300);
  }

  public CyclicPlotShape(JFreeChart chart, int ox, int oy, int width, int height) {
    super(chart, ox, oy, width, height);
    XYPlot plot = (XYPlot)chart.getXYPlot();
    plot.setDomainAxis(new CyclicNumberAxis(10,0));
    plot.setRenderer(new JSynopticCyclicXYItemRenderer());
  }
View Full Code Here

Examples of org.jfree.chart.plot.XYPlot

    }

    Vector v = new Vector();
    v.add(resources.getString("Properties..."));

    XYPlot plot = (XYPlot)chart.getXYPlot();
    SourceXYDataset dst = (SourceXYDataset)plot.getDataset();

    if (o instanceof DataSource) {
      v.add(resources.getString("setX"));
      if (dst.getSources().size() != 0) {
        v.add(resources.getString("addY"));
View Full Code Here

Examples of org.jfree.chart.plot.XYPlot

     
      Box content = Box.createVerticalBox();
     
      setName(resources.getString("PlotProperties"));

      XYPlot plot = chart.getXYPlot();

      // Create the title section
      section=Box.createHorizontalBox();
      section.add(new JLabel(resources.getString("PlotTitle:")));
      section.add(tfTitle = new JTextField());
      tfTitle.setText(chart.getTitle().getText());
      content.add(section);


      // X axis section
      section = new Box(BoxLayout.Y_AXIS);
      section.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),resources.getString("XAxis")));
     
      panel = new JPanel();
      panel.setLayout(new FlowLayout(FlowLayout.LEFT));
     
      CyclicNumberAxis cna = null;
      if (plot.getDomainAxis() instanceof CyclicNumberAxis) cna = (CyclicNumberAxis)plot.getDomainAxis();
     
      panel.add(cbcyclex = new ActionCheckBox(resources.getString("CyclicAxis"), cna!=null) {
        public void actionPerformed(ActionEvent e) {
          CardLayout cl = (CardLayout)(xcards.getLayout());
          if (isSelected()) cl.show(xcards, "cyclic");
          else cl.show(xcards, "normal");
        }
      });
      panel.add(cbinvertx = new ActionCheckBox(resources.getString("Inverted"), plot.getDomainAxis().isInverted()) {
        public void actionPerformed(ActionEvent e) {
        }
      });
      section.add(panel);
     
      xcards = new JPanel();
      xcards.setLayout(new CardLayout());
     
      Box hbox = Box.createHorizontalBox();
      hbox.add(new JLabel(resources.getString("Period")));
      hbox.add(nfperiodx = new NumberField(cna==null ? 0 : cna.getPeriod()));
      hbox.add(Box.createHorizontalGlue());
      hbox.add(new JLabel(resources.getString("Offset")));
      hbox.add(nfoffsetx = new NumberField(cna==null ? 0 : cna.getOffset()));
      xcards.add(hbox,"cyclic");
     
      panel = new JPanel();
      panel.setLayout(new FlowLayout(FlowLayout.LEFT));
      double autorange = plot.getDomainAxis().getFixedAutoRange();
      panel.add(cbfixedautox = new ActionCheckBox(resources.getString("FixedRange"),autorange!=0) {
        public void actionPerformed(ActionEvent e) {
          nffixedautox.setEnabled(isSelected() && isEnabled());
        }
      });
      panel.add(nffixedautox = new NumberField(autorange,10));
      xcards.add(panel,"normal");

      section.add(xcards);
     
      panel = new JPanel();
      panel.setLayout(new FlowLayout(FlowLayout.LEFT));
      panel.add(cbautox = new ActionCheckBox(resources.getString("Auto-update"), plot.getDomainAxis().isAutoRange()) {
        public void actionPerformed(ActionEvent e) {
          cbfixedautox.setEnabled(isSelected());
          cbfixedautox.apply();
          lpxmin.setEnabled(!isSelected());
          lpxmax.setEnabled(!isSelected());
          tfpxmin.setEnabled(!isSelected());
          tfpxmax.setEnabled(!isSelected());
        }
      });
      panel.add(lpxmin = new JLabel(resources.getString("minLabel")));
      panel.add(tfpxmin = new NumberField(10));
      tfpxmin.setValue(plot.getDomainAxis().getLowerBound());
      panel.add(lpxmax = new JLabel(resources.getString("maxLabel")));
      panel.add(tfpxmax = new NumberField(10));
      tfpxmax.setValue(plot.getDomainAxis().getUpperBound());
      cbautox.apply();
      section.add(panel);
     
      content.add(section);

     
      // Now handle Y axis
      section = new Box(BoxLayout.Y_AXIS);
      section.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),resources.getString("YAxis")));

      panel = new JPanel();
      panel.setLayout(new FlowLayout(FlowLayout.LEFT));
     
      cna = null;
      if (plot.getRangeAxis() instanceof CyclicNumberAxis) cna = (CyclicNumberAxis)plot.getRangeAxis();
     
      panel.add(cbcycley = new ActionCheckBox(resources.getString("CyclicAxis"), cna!=null) {
        public void actionPerformed(ActionEvent e) {
          CardLayout cl = (CardLayout)(ycards.getLayout());
          if (isSelected()) cl.show(ycards, "cyclic");
          else cl.show(ycards, "normal");
        }
      });
      panel.add(cbinverty = new ActionCheckBox(resources.getString("Inverted"), plot.getRangeAxis().isInverted()) {
        public void actionPerformed(ActionEvent e) {
        }
      });
      section.add(panel);
     
      ycards = new JPanel();
      ycards.setLayout(new CardLayout());
     
      hbox = Box.createHorizontalBox();
      hbox.add(new JLabel(resources.getString("Period")));
      hbox.add(nfperiody = new NumberField(cna==null ? 0 : cna.getPeriod()));
      hbox.add(Box.createHorizontalGlue());
      hbox.add(new JLabel(resources.getString("Offset")));
      hbox.add(nfoffsety = new NumberField(cna==null ? 0 : cna.getOffset()));
      ycards.add(hbox,"cyclic");
     
      panel = new JPanel();
      panel.setLayout(new FlowLayout(FlowLayout.LEFT));
      autorange = plot.getRangeAxis().getFixedAutoRange();
      panel.add(cbfixedautoy = new ActionCheckBox(resources.getString("FixedRange"),autorange!=0) {
        public void actionPerformed(ActionEvent e) {
          nffixedautoy.setEnabled(isSelected() && isEnabled());
        }
      });
      panel.add(nffixedautoy = new NumberField(autorange,10));
      ycards.add(panel,"normal");

      section.add(ycards);
     
      panel = new JPanel();
      panel.setLayout(new FlowLayout(FlowLayout.LEFT));
      panel.add(cbautoy = new ActionCheckBox(resources.getString("Auto-update"), plot.getRangeAxis().isAutoRange()) {
        public void actionPerformed(ActionEvent e) {
          cbfixedautoy.setEnabled(isSelected());
          cbfixedautoy.apply();
          lpymin.setEnabled(!isSelected());
          lpymax.setEnabled(!isSelected());
          tfpymin.setEnabled(!isSelected());
          tfpymax.setEnabled(!isSelected());
        }
      });
      panel.add(lpymin = new JLabel(resources.getString("minLabel")));
      panel.add(tfpymin = new NumberField(10));
      tfpymin.setValue(plot.getRangeAxis().getLowerBound());
      panel.add(lpymax = new JLabel(resources.getString("maxLabel")));
      panel.add(tfpymax = new NumberField(10));
      tfpymax.setValue(plot.getRangeAxis().getUpperBound());
      cbautoy.apply();
      section.add(panel);

      Box box = Box.createHorizontalBox();

      box.add(new JLabel(resources.getString("Curves:")));
      box.add(pcbxcurves = new JComboBox());
      box.add(pcurvecolor = new JButton("    "));
      box.add(pcurvedelete = new JButton(resources.getString("Delete")));
      section.add(box);
      content.add(section);

      pcbxcurves.setEditable(true);
      noCurveColor = pcurvecolor.getBackground();
      pcurvecolor.setFocusPainted(false);
      SourceXYDataset dst = (SourceXYDataset)plot.getDataset();
      int n = dst.getSeriesCount();
      JSynopticXYItemRenderer renderer = (JSynopticXYItemRenderer)plot.getRenderer();
      for (int i=0; i<n; ++i) {
        DataSource ds = renderer.getDataSource(i);
        if (ds==null) {
          ds = dst.getYSource(i); // take the datasource associated with this curve by default
          DataSource linked = DataInfo.getLinkedSource(ds); // and follow link if necessary
View Full Code Here

Examples of org.jfree.chart.plot.XYPlot

      yaxis.setAutoRange(cbautoy.isSelected());
      yaxis.setInverted(cbinverty.isSelected());
      if (tfpymin.isEnabled() && tfpymax.isEnabled()) yaxis.setRange(tfpymin.getDoubleValue(), tfpymax.getDoubleValue());
     
      chart.setTitle(tfTitle.getText());
      XYPlot plot = chart.getXYPlot();

      plot.setDomainAxis(xaxis);
      plot.setRangeAxis(yaxis);
     
      // Primary Y update
      SourceXYDataset dst = (SourceXYDataset)plot.getDataset();
      int n = dst.getSeriesCount();

      // If some curves were deleted, remove them
      if (n != pcbxcurves.getItemCount()) {
        boolean[] toKeep = new boolean[n]; // boolean are initialized to false by JVM
        for (int i=0; i<pcbxcurves.getItemCount(); ++i)
          toKeep[((CbxEntry)pcbxcurves.getItemAt(i)).datasetIndex] = true;

        JSynopticXYItemRenderer renderer = (JSynopticXYItemRenderer)plot.getRenderer();

        // Now we can remove the deleted curves, and update the existing ones
        // Start from the end, to remove the entries and keep the index OK
        for (int i=n-1; i>=0; i--) {
          if (!toKeep[i]) {
            if (i>0) dst.removeXSource(i);
            else dst.removeYSource(i);
            renderer.removeColorMapper(i);
            renderer.removeDataSource(i);
          }
        }
      }
     
      // Now we match the data set and the list
      for (int i=0; i<pcbxcurves.getItemCount(); ++i) {
        CbxEntry e = (CbxEntry)pcbxcurves.getItemAt(i);
        dst.setName(i,e.name);
        JSynopticXYItemRenderer renderer = (JSynopticXYItemRenderer)plot.getRenderer();
        renderer.setSeriesPaint(i,e.color);
        renderer.setDataSource(i, e.source);
        renderer.setColorMapper(i, e.mapper);
      }
View Full Code Here

Examples of org.jfree.chart.plot.XYPlot

    this(chart,0,0,400,300);
  }

  public ScatterPlotShape(JFreeChart chart, int ox, int oy, int width, int height) {
    super(chart, ox, oy, width, height);
    XYPlot plot = (XYPlot)chart.getXYPlot();
    SourceXYDataset dst = (SourceXYDataset)plot.getDataset();
    dst.setNameAccordingToYOnly(false);
    StandardXYItemRenderer renderer =new JSynopticStandardXYItemRenderer(1,StandardXYItemRenderer.SHAPES);
    renderer.setShapesFilled(Boolean.TRUE);
    plot.setRenderer(renderer);
  }
View Full Code Here

Examples of org.jfree.chart.plot.XYPlot

     
      Box content = Box.createVerticalBox();
     
      setName(resources.getString("PlotProperties"));

      XYPlot plot = chart.getXYPlot();

      // Create the title section
      section=Box.createHorizontalBox();
      section.add(new JLabel(resources.getString("PlotTitle:")));
      section.add(tfTitle = new JTextField());
      tfTitle.setText(chart.getTitle().getText());
      content.add(section);


      // X axis section
      section = new Box(BoxLayout.Y_AXIS);
      section.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),resources.getString("XAxis")));
      panel = new JPanel();
      panel.setLayout(new FlowLayout(FlowLayout.LEFT));
      panel.add(pcbautox = new ActionCheckBox(resources.getString("Auto-update"), plot.getDomainAxis().isAutoRange()) {
        public void actionPerformed(ActionEvent e) {
          pcbfixedautox.setEnabled(isSelected());
          pcbfixedautox.apply();
          plpxmin.setEnabled(!isSelected());
          plpxmax.setEnabled(!isSelected());
          ptfpxmin.setEnabled(!isSelected());
          ptfpxmax.setEnabled(!isSelected());
        }
      });
      double autorange = plot.getDomainAxis().getFixedAutoRange();
      panel.add(pcbfixedautox = new ActionCheckBox(resources.getString("FixedRange"),autorange!=0) {
        public void actionPerformed(ActionEvent e) {
          pnffixedautox.setEnabled(isSelected() && isEnabled());
        }
      });
      panel.add(pnffixedautox = new NumberField(autorange,10));
      section.add(panel);
      panel = new JPanel();
      panel.setLayout(new FlowLayout(FlowLayout.LEFT));
      panel.add(plpxmin = new JLabel(resources.getString("minLabel")));
      panel.add(ptfpxmin = new NumberField(10));
      ptfpxmin.setValue(plot.getDomainAxis().getLowerBound());
      panel.add(plpxmax = new JLabel(resources.getString("maxLabel")));
      panel.add(ptfpxmax = new NumberField(10));
      ptfpxmax.setValue(plot.getDomainAxis().getUpperBound());
      section.add(panel);
      pcbautox.apply();

      content.add(section);

//       X secondary axis section
      if (plot.getSecondaryDomainAxis(0) != null) {
        section = new Box(BoxLayout.Y_AXIS);
        section.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),resources.getString("SecondaryXAxis")));
        panel = new JPanel();
        panel.setLayout(new FlowLayout(FlowLayout.LEFT));
        panel.add(scbautox = new ActionCheckBox(resources.getString("Auto-update"), plot.getSecondaryDomainAxis(0).isAutoRange()) {
          public void actionPerformed(ActionEvent e) {
            scbfixedautox.setEnabled(isSelected());
            scbfixedautox.apply();
            slpxmin.setEnabled(!isSelected());
            slpxmax.setEnabled(!isSelected());
            stfpxmin.setEnabled(!isSelected());
            stfpxmax.setEnabled(!isSelected());
          }
      });
      autorange = plot.getSecondaryDomainAxis(0).getFixedAutoRange();
      panel.add(scbfixedautox = new ActionCheckBox(resources.getString("FixedRange"),autorange!=0) {
        public void actionPerformed(ActionEvent e) {
          snffixedautox.setEnabled(isSelected() && isEnabled());
        }
      });
      panel.add(snffixedautox = new NumberField(autorange,10));
      section.add(panel);
      panel = new JPanel();
      panel.setLayout(new FlowLayout(FlowLayout.LEFT));
      panel.add(slpxmin = new JLabel(resources.getString("minLabel")));
      panel.add(stfpxmin = new NumberField(10));
      stfpxmin.setValue(plot.getSecondaryDomainAxis(0).getLowerBound());
      panel.add(slpxmax = new JLabel(resources.getString("maxLabel")));
      panel.add(stfpxmax = new NumberField(10));
      stfpxmax.setValue(plot.getSecondaryDomainAxis(0).getUpperBound());
      section.add(panel);
      scbautox.apply();

      content.add(section);
      }
      // Now handle Y axis
      section = new Box(BoxLayout.Y_AXIS);
      section.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),resources.getString("YAxis")));
      panel = new JPanel();
      panel.setLayout(new FlowLayout(FlowLayout.LEFT));
      panel.add(pcbautoy = new ActionCheckBox(resources.getString("Auto-update"), plot.getRangeAxis().isAutoRange()) {
        public void actionPerformed(ActionEvent e) {
          pcbfixedautoy.setEnabled(isSelected());
          pcbfixedautoy.apply();
          plpymin.setEnabled(!isSelected());
          plpymax.setEnabled(!isSelected());
          ptfpymin.setEnabled(!isSelected());
          ptfpymax.setEnabled(!isSelected());
        }
      });
      autorange = plot.getRangeAxis().getFixedAutoRange();
      panel.add(pcbfixedautoy = new ActionCheckBox(resources.getString("FixedRange"),autorange!=0) {
        public void actionPerformed(ActionEvent e) {
          pnffixedautoy.setEnabled(isSelected() && isEnabled());
        }
      });
      panel.add(pnffixedautoy = new NumberField(autorange,8));
      panel.add(plpymin = new JLabel(resources.getString("minLabel")));
      panel.add(ptfpymin = new NumberField(8));
      ptfpymin.setValue(plot.getRangeAxis().getLowerBound());
      panel.add(plpymax = new JLabel(resources.getString("maxLabel")));
      panel.add(ptfpymax = new NumberField(8));
      ptfpymax.setValue(plot.getRangeAxis().getUpperBound());
      section.add(panel);
      pcbautoy.apply();

      section.add(panel);

      Box box = Box.createHorizontalBox();

      box.add(new JLabel(resources.getString("Curves:")));
      box.add(pcbxcurves = new JComboBox());
      box.add(pcurvecolor = new JButton("    "));
      box.add(pcurvedelete = new JButton(resources.getString("Delete")));
      section.add(box);
      content.add(section);

      pcbxcurves.setEditable(true);
      noCurveColor = pcurvecolor.getBackground();
      pcurvecolor.setFocusPainted(false);
      SourceXYDataset dst = (SourceXYDataset)plot.getDataset();
      int n = dst.getSeriesCount();
      JSynopticXYItemRenderer renderer = (JSynopticXYItemRenderer)plot.getRenderer();
      for (int i=0; i<n; ++i) {
        DataSource ds = renderer.getDataSource(i);
        if (ds==null) {
          ds = dst.getYSource(i); // take the datasource associated with this curve by default
          DataSource linked = DataInfo.getLinkedSource(ds); // and follow link if necessary
          if (linked!=null) ds = linked;
        }
        pcbxcurves.addItem(new CbxEntry(i,dst.getSeriesName(i),(Color)renderer.getSeriesPaint(i),ds,renderer.getColorMapper(i)));
      }
      pcbxeditortf = (JTextField)pcbxcurves.getEditor().getEditorComponent();
      pupdateForEntry(pcbxcurves.getSelectedItem());
     
      pcbxcurves.addPopupMenuListener(new PopupMenuListener() {
        public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
          peditLocked = true;
        }
        public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
          peditLocked = false;
        }
        public void popupMenuCanceled(PopupMenuEvent e) {
          peditLocked = false;
        }
      });

      pcbxcurves.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
          if (e.getStateChange()==ItemEvent.DESELECTED) pactiveEntry = null;
          else pupdateForEntry(e.getItem());
        }
      });

      pcbxeditortf.getDocument().addDocumentListener(new DocumentListener() {
        public void insertUpdate(DocumentEvent e) {
          updateName();
        }
        public void removeUpdate(DocumentEvent e) {
          updateName();
        }
        public void changedUpdate(DocumentEvent e) {
          updateName();
        }
        public void updateName() {
          if ((peditLocked) || (pactiveEntry == null)) return;
          pactiveEntry.name = pcbxeditortf.getText();
        }
      });

      pcurvecolor.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          if (pactiveEntry==null) return;
         
           DynamicColorChooser dialog = new DynamicColorChooser(
                              null, resources.getString("ChooseAColor"),null ,pactiveEntry.color,pactiveEntry.source,pactiveEntry.mapper);


                      dialog.pack();
                      dialog.setVisible(true);

                      if (dialog.isOk()){
                          pactiveEntry.color = dialog.getColor();
                          pactiveEntry.source = dialog.getSource();
                          pactiveEntry.mapper = dialog.getMapper();
                          pupdateForEntry(pactiveEntry);
                      }
        }
      });

      pcurvedelete.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          if (pactiveEntry==null) return;
          pcbxcurves.removeItem(pactiveEntry);
        }
      });

      // Now handle Secondary Y axis
      if (plot.getSecondaryRangeAxis(0) != null) {
        section = new Box(BoxLayout.Y_AXIS);
        section.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),resources.getString("SecondaryYAxis")));
        panel = new JPanel();
        panel.setLayout(new FlowLayout(FlowLayout.LEFT));
        panel.add(scbautoy = new ActionCheckBox(resources.getString("Auto-update"), plot.getSecondaryRangeAxis(0).isAutoRange()) {
          public void actionPerformed(ActionEvent e) {
            scbfixedautoy.setEnabled(isSelected());
            scbfixedautoy.apply();
            slpymin.setEnabled(!isSelected());
            slpymax.setEnabled(!isSelected());
            stfpymin.setEnabled(!isSelected());
            stfpymax.setEnabled(!isSelected());
          }
        });
        autorange = plot.getSecondaryRangeAxis(0).getFixedAutoRange();
        panel.add(scbfixedautoy = new ActionCheckBox(resources.getString("FixedRange"),autorange!=0) {
          public void actionPerformed(ActionEvent e) {
            snffixedautoy.setEnabled(isSelected() && isEnabled());
          }
        });
        panel.add(snffixedautoy = new NumberField(autorange,8));
        panel.add(slpymin = new JLabel(resources.getString("minLabel")));
        panel.add(stfpymin = new NumberField(8));
        stfpymin.setValue(plot.getSecondaryRangeAxis(0).getLowerBound());
        panel.add(slpymax = new JLabel(resources.getString("maxLabel")));
        panel.add(stfpymax = new NumberField(8));
        stfpymax.setValue(plot.getSecondaryRangeAxis(0).getUpperBound());
        section.add(panel);
        scbautoy.apply();
 
        section.add(panel);
 
        box = Box.createHorizontalBox();
 
        box.add(new JLabel(resources.getString("Curves:")));
        box.add(scbxcurves = new JComboBox());
        box.add(scurvecolor = new JButton("    "));
        box.add(scurvedelete = new JButton(resources.getString("Delete")));
        section.add(box);
        content.add(section);
 
        scbxcurves.setEditable(true);
        //noCurveColor = scurvecolor.getBackground();
        scurvecolor.setFocusPainted(false);
        dst = (SourceXYDataset)plot.getSecondaryDataset(0);
        n = dst.getSeriesCount();
        renderer = (JSynopticXYItemRenderer)plot.getSecondaryRenderer(0);
        for (int i=0; i<n; ++i) {
          DataSource ds = renderer.getDataSource(i);
          if (ds==null) {
            ds = dst.getYSource(i); // take the datasource associated with this curve by default
            DataSource linked = DataInfo.getLinkedSource(ds); // and follow link if necessary
View Full Code Here

Examples of org.jfree.chart.plot.XYPlot

      yaxis.setAutoRange(pcbautoy.isSelected());
      if (pnffixedautoy.isEnabled()) yaxis.setFixedAutoRange(pnffixedautoy.getDoubleValue());
      if (ptfpymin.isEnabled() && ptfpymax.isEnabled()) yaxis.setRange(ptfpymin.getDoubleValue(), ptfpymax.getDoubleValue());

      chart.setTitle(tfTitle.getText());
      XYPlot plot = chart.getXYPlot();

      // Primary Y update
      SourceXYDataset dst = (SourceXYDataset)plot.getDataset();
      int n = dst.getSeriesCount();

      // If some curves were deleted, remove them
      if (n != pcbxcurves.getItemCount()) {
        boolean[] toKeep = new boolean[n]; // boolean are initialized to false by JVM
        for (int i=0; i<pcbxcurves.getItemCount(); ++i)
          toKeep[((CbxEntry)pcbxcurves.getItemAt(i)).datasetIndex] = true;

        JSynopticXYItemRenderer renderer = (JSynopticXYItemRenderer)plot.getRenderer();

        // Now we can remove the deleted curves, and update the existing ones
        // Start from the end, to remove the entries and keep the index OK
        for (int i=n-1; i>=0; i--) {
          if (!toKeep[i]) {
            if (i>0) dst.removeXSource(i);
            else dst.removeYSource(i);
            renderer.removeColorMapper(i);
            renderer.removeDataSource(i);
          }
        }
      }
     
      // Now we match the data set and the list
      for (int i=0; i<pcbxcurves.getItemCount(); ++i) {
        CbxEntry e = (CbxEntry)pcbxcurves.getItemAt(i);
        dst.setName(i,e.name);
        JSynopticXYItemRenderer renderer = (JSynopticXYItemRenderer)plot.getRenderer();
        renderer.setSeriesPaint(i,e.color);
        renderer.setDataSource(i, e.source);
        renderer.setColorMapper(i, e.mapper);
      }

      // Secondary Y update
      if (plot.getSecondaryRangeAxis(0) != null) {

          ValueAxis syaxis = plot.getSecondaryRangeAxis(0);
          if (syaxis!=null) {
              syaxis.setAutoRange(scbautoy.isSelected());
              if (snffixedautoy.isEnabled()) syaxis.setFixedAutoRange(snffixedautoy.getDoubleValue());
              if (stfpymin.isEnabled() && stfpymax.isEnabled()) syaxis.setRange(stfpymin.getDoubleValue(), stfpymax.getDoubleValue());
          }
         
         
          dst = (SourceXYDataset)plot.getSecondaryDataset(0);
        n = dst.getSeriesCount();
 
        // If some curves were deleted, remove them
        if (n != scbxcurves.getItemCount()) {
          boolean[] toKeep = new boolean[n]; // boolean are initialized to false by JVM
          for (int i=0; i<scbxcurves.getItemCount(); ++i)
            toKeep[((CbxEntry)scbxcurves.getItemAt(i)).datasetIndex] = true;
 
          JSynopticXYItemRenderer renderer = (JSynopticXYItemRenderer)plot.getSecondaryRenderer(0);
 
          // Now we can remove the deleted curves, and update the existing ones
          // Start from the end, to remove the entries and keep the index OK
          for (int i=n-1; i>=0; i--) {
            if (!toKeep[i]) {
              if (i>0) dst.removeXSource(i);
              else dst.removeYSource(i);
              renderer.removeColorMapper(i);
              renderer.removeDataSource(i);
            }
          }
        }
       
        // Now we match the data set and the list
        for (int i=0; i<scbxcurves.getItemCount(); ++i) {
          CbxEntry e = (CbxEntry)scbxcurves.getItemAt(i);
          dst.setName(i,e.name);
          JSynopticXYItemRenderer renderer = (JSynopticXYItemRenderer)plot.getSecondaryRenderer(0);
          renderer.setSeriesPaint(i,e.color);
          renderer.setDataSource(i, e.source);
          renderer.setColorMapper(i, e.mapper);
        }
     
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.