Examples of CategoryPlot


Examples of org.jfree.chart.plot.CategoryPlot

      }
      chart.getCategoryPlot().setDomainAxis(new FormattedCategoryAxis(getCategoryAxisLabel(),
          getCategoricalAxisMessageFormat(), getRuntime().getResourceBundleFactory().getLocale()));
    }

    final CategoryPlot plot = (CategoryPlot) chart.getPlot();
    configureLogarithmicAxis(plot);

    return chart;
  }
View Full Code Here

Examples of org.jfree.chart.plot.CategoryPlot

  }

  protected void configureChart(final JFreeChart chart)
  {
    super.configureChart(chart);
    final CategoryPlot cpl = chart.getCategoryPlot();
    final CategoryItemRenderer renderer = cpl.getRenderer();
    final BarRenderer br = (BarRenderer) renderer;
    br.setDrawBarOutline(isChartSectionOutline());
    if (maxBarWidth != null)
    {
      br.setMaximumBarWidth(maxBarWidth.doubleValue());
View Full Code Here

Examples of org.jfree.chart.plot.CategoryPlot

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

    final CategoryPlot cpl = chart.getCategoryPlot();
    final CategoryItemRenderer renderer = cpl.getRenderer();
    renderer.setStroke(translateLineStyle(lineWidth, lineStyle));
    if (renderer instanceof LineAndShapeRenderer)
    {
      final LineAndShapeRenderer shapeRenderer = (LineAndShapeRenderer) renderer;
      shapeRenderer.setShapesVisible(isMarkersVisible());
View Full Code Here

Examples of org.jfree.chart.plot.CategoryPlot

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

  public BarChartShape(JFreeChart chart, int ox, int oy, int width, int height) {
    super(chart, ox, oy, width, height);
    CategoryPlot plot = chart.getCategoryPlot();
    //CategoryAxis
    ValueAxis raxis = plot.getRangeAxis();
    raxis.setAutoRange(true);
    mapperSources = new Vector();
    mappers = new Vector();
//    plot.setRenderer(new JSynopticStandardXYItemRenderer());
  }
View Full Code Here

Examples of org.jfree.chart.plot.CategoryPlot

    }

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

    CategoryPlot plot = chart.getCategoryPlot();
    SourceCategoryDataset dst = (SourceCategoryDataset)plot.getDataset();

    if (o instanceof DataSource) {
      v.add(resources.getString("AddSource"));
    }
   
View Full Code Here

Examples of org.jfree.chart.plot.CategoryPlot

      return true;
    }

    if (action.equals(resources.getString("AddSource"))) {
      try {
        CategoryPlot plot = chart.getCategoryPlot();
        SourceCategoryDataset dst = (SourceCategoryDataset)plot.getDataset();
        dst.addSource((DataSource)o);
        mappers.add(null); mapperSources.add(null); // no mapper by default
        notifyChange();
      } catch (ClassCastException cce) {
        JSynoptic.setStatus(resources.getString("ErrorWhileSettingDataSource"));
      }
    }

    if (action.equals(resources.getString("AddSources"))) {
      try {
        CategoryPlot plot = chart.getCategoryPlot();
        SourceCategoryDataset dst = (SourceCategoryDataset)plot.getDataset();
        dst.addDataSourceCollection((DataSourceCollection)o);
        for (int i=0; i<((DataSourceCollection)o).size(); ++i) {
          mappers.add(null); mapperSources.add(null); // no mapper by default
        }
        notifyChange();
      } catch (ClassCastException cce) {
        JSynoptic.setStatus(resources.getString("ErrorWhileSettingDataSourceCollection"));
      }
    }

    if (action.equals(resources.getString("SetSources"))) {
      try {
        CategoryPlot plot = chart.getCategoryPlot();
        SourceCategoryDataset dst = (SourceCategoryDataset)plot.getDataset();
        dst.setDataSourceCollection((DataSourceCollection)o);
        chart.setTitle(dst.getName());
        for (int i=0; i<mappers.size(); ++i) {
          DataSource ds = (DataSource)mapperSources.get(i);
          if (ds!=null) ds.removeListener(this);
View Full Code Here

Examples of org.jfree.chart.plot.CategoryPlot

  public void mappingChanged(GenericMapper mapper) {
    notifyChange();
  }

  public void checkMapperChange(DataSource ds, long index) {
    CategoryPlot plot = chart.getCategoryPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    boolean hasChanged = false;
    for (int i=0; i<mapperSources.size(); ++i) {
      if (ds.equals(mapperSources.get(i))) {
        ColorMapper cm = (ColorMapper)mappers.get(i);
        if (cm!=null) {
View Full Code Here

Examples of org.jfree.chart.plot.CategoryPlot

  /* (non-Javadoc)
   * @see simtools.shapes.AbstractShape#cloneShape()
   */
  protected AbstractShape cloneShape() {
      ChartShape cs = (ChartShape)super.cloneShape();
      CategoryPlot plot = chart.getCategoryPlot();
      SourceCategoryDataset dst = (SourceCategoryDataset)plot.getDataset();
      ((CategoryPlot)cs.chart.getPlot()).setDataset(dst.cloneSet());
      return cs;
  }
View Full Code Here

Examples of org.jfree.chart.plot.CategoryPlot

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

      CategoryPlot plot = chart.getCategoryPlot();
      SourceCategoryDataset dst = (SourceCategoryDataset)plot.getDataset();

      // 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);

      section=Box.createVerticalBox();
      section.setBorder(BorderFactory.createTitledBorder(resources.getString("Series")));

      Box box = Box.createHorizontalBox();
      box.add(pcbxcurves = new JComboBox());
      box.add(pcurvecolor = new JButton("    "));
      box.add(pcurvedelete = new JButton(resources.getString("Delete")));
      section.add(box);
     
      box = Box.createHorizontalBox();
      box.add(new JLabel(resources.getString("Orientation")));
      box.add(Box.createHorizontalGlue());
      box.add(hSeriesOrientation = new JRadioButton(resources.getString("Horizontal")));
      box.add(vSeriesOrientation = new JRadioButton(resources.getString("Vertical")));
      hSeriesOrientation.setSelected(plot.getOrientation() == PlotOrientation.HORIZONTAL);
      vSeriesOrientation.setSelected(plot.getOrientation() == PlotOrientation.VERTICAL);
      ButtonGroup bg = new ButtonGroup();
      bg.add(hSeriesOrientation);
      bg.add(vSeriesOrientation);
      section.add(box);
     
      content.add(section);

      pcbxcurves.setEditable(true);
      Color noCurveColor = pcurvecolor.getBackground();
      pcurvecolor.setFocusPainted(false);

      CategoryItemRenderer renderer = plot.getRenderer();
      int n = dst.getRowCount();
      for (int i=0; i<n; ++i) {
        DataSource ds = (DataSource)mapperSources.get(i);
        if (ds==null) ds = dst.getSource(i); // take the datasource associated with this series by default
        pcbxcurves.addItem(new CbxEntry(i,dst.getName(i),(Color)renderer.getSeriesPaint(i),ds,(ColorMapper)mappers.get(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);
        }
      });

     
      section=Box.createVerticalBox();
      section.setBorder(BorderFactory.createTitledBorder(resources.getString("Categories")));

      box = Box.createHorizontalBox();
      box.add(new JLabel(resources.getString("LabelsOrientation")));
      box.add(Box.createHorizontalGlue());
      box.add(hLabelOrientation = new JRadioButton(resources.getString("Horizontal")));
      box.add(vLabelOrientation = new JRadioButton(resources.getString("Vertical")));
      CategoryLabelPosition clp = vSeriesOrientation.isSelected() ? plot.getDomainAxis().getCategoryLabelPositions().getLabelPosition(RectangleEdge.BOTTOM) : plot.getDomainAxis().getCategoryLabelPositions().getLabelPosition(RectangleEdge.LEFT);
      boolean vertical = clp.getAngle() != 0;
      hLabelOrientation.setSelected(!vertical);
      vLabelOrientation.setSelected(vertical);
      bg = new ButtonGroup();
      bg.add(hLabelOrientation);
View Full Code Here

Examples of org.jfree.chart.plot.CategoryPlot

   
    protected void updateChartProperties() {

      chart.setTitle(tfTitle.getText());

      CategoryPlot plot = chart.getCategoryPlot();
      SourceCategoryDataset dst = (SourceCategoryDataset)plot.getDataset();

      int n = dst.getRowCount();

      // 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;

        // 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]) {
            GenericMapper mapper = (GenericMapper)mappers.remove(i);
            if (mapper!=null) mapper.removeListener(BarChartShape.this);
            DataSource source = (DataSource)mapperSources.remove(i);
            if (source!=null) source.removeListener(BarChartShape.this);
            dst.removeSource(i);
          }
        }
      }
     
      // Now we match the data set and the list
      int len = pcbxcurves.getItemCount();
      for (int i=0; i<len; ++i) {
        CbxEntry e = (CbxEntry)pcbxcurves.getItemAt(i);
        dst.setName(i,e.name);
        CategoryItemRenderer renderer = plot.getRenderer();
        DataSource ds = (DataSource)mapperSources.get(i);
        if ((e.source==null) && (ds!=null)) ds.removeListener(BarChartShape.this);
        mapperSources.set(i,e.source);
        if (e.source!=null) e.source.addListener(BarChartShape.this);
        ColorMapper cm = (ColorMapper)mappers.get(i);
        if ((e.mapper==null) && (cm!=null)) cm.removeListener(BarChartShape.this);
        mappers.set(i,e.mapper);
        if (e.mapper!=null) e.mapper.addListener(BarChartShape.this);
       
        if ((e.mapper!=null) && (e.source!=null)) {
          e.mapper.setDefaultPaint(e.color);
          renderer.setSeriesPaint(i,e.mapper.getPaint(e.source));
        }
        else renderer.setSeriesPaint(i,e.color);
       
      }
   
      plot.setOrientation(hSeriesOrientation.isSelected() ? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL);

      CategoryLabelPosition clp = vSeriesOrientation.isSelected() ? plot.getDomainAxis().getCategoryLabelPositions().getLabelPosition(RectangleEdge.BOTTOM) : plot.getDomainAxis().getCategoryLabelPositions().getLabelPosition(RectangleEdge.LEFT);
      clp = new CategoryLabelPosition(clp.getCategoryAnchor(),
        hSeriesOrientation.isSelected() ? (vLabelOrientation.isSelected() ? TextBlockAnchor.BOTTOM_CENTER : TextBlockAnchor.CENTER_RIGHT) : (vLabelOrientation.isSelected() ? TextBlockAnchor.CENTER_RIGHT : TextBlockAnchor.TOP_CENTER),
        hSeriesOrientation.isSelected() ? (vLabelOrientation.isSelected() ? TextAnchor.BOTTOM_CENTER : TextAnchor.CENTER_RIGHT) : (vLabelOrientation.isSelected() ? TextAnchor.CENTER_RIGHT : TextAnchor.TOP_CENTER),
        vLabelOrientation.isSelected() ? - Math.PI / 2.0 : 0.0);
     
      if (vSeriesOrientation.isSelected()) plot.getDomainAxis().setCategoryLabelPositions(new CategoryLabelPositions(
              plot.getDomainAxis().getCategoryLabelPositions().getLabelPosition(RectangleEdge.TOP),
              clp,
              plot.getDomainAxis().getCategoryLabelPositions().getLabelPosition(RectangleEdge.LEFT),
              plot.getDomainAxis().getCategoryLabelPositions().getLabelPosition(RectangleEdge.RIGHT)
      ));
      //);setBottomCategoryLabelPosition(clp);
      else plot.getDomainAxis().setCategoryLabelPositions(new CategoryLabelPositions(
              plot.getDomainAxis().getCategoryLabelPositions().getLabelPosition(RectangleEdge.TOP),
              plot.getDomainAxis().getCategoryLabelPositions().getLabelPosition(RectangleEdge.BOTTOM),
              clp,
              plot.getDomainAxis().getCategoryLabelPositions().getLabelPosition(RectangleEdge.RIGHT)
      ));
      //setLeftCategoryLabelPosition(clp);
     
      if (mapper==null) return;
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.