Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Potential problem

  • 16-02-2004 2:26pm
    #1
    Closed Accounts Posts: 537 ✭✭✭


    Hi
    I have tried to implement a sample version of jfreechart which is a component for graphing but unfortunatly there is an error with importing some of the libraries i have added all the . jar files to the Class Path and i have opened the .jar file in net beans so i dont know what the problem is

    Problem is with the lines
    import org.jfree.ui.ApplicationFrame;
    import org.jfree.ui.RefineryUtilities;

    It tells me that org/jfree/chart/demo/LineChartDemo1.java [60:1] package org.jfree.ui does not exist


    C:\j2sdk1.4.2_03\lib\jfreechart-0.9.16\jfreechart-0.9.16.jar;
    C:\j2sdk1.4.2_03\lib\jfreechart-0.9.16\lib\jcommon-0.9.1.jar;
    C:\j2sdk1.4.2_03\lib\jfreechart-0.9.16\lib\servlet.jar;C:\j2sdk1.4.2_03\lib\jfreechart-0.9.16\lib\gnujaxp.jar

    Refereence at http://www.jfree.org/jfreechart/index.html

    Any help would be greatly appreciated


Comments

  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    Are you sure org.jfree.ui isn't missing something?

    Sounds like a package name then a class file (Classes normally are capitalised first character).

    If it was a class it would be (although wrong naming imho)

    org.jfree.Ui

    If I was to take a guess is thats the name of the package directory and your missing the class name, or it could be an incorrect import.

    eg.

    import org.jfree.ui.*; // Missing the * at the end prehaps?

    Also show us the line in...
    org/jfree/chart/demo/LineChartDemo1.java [60:1]


  • Closed Accounts Posts: 537 ✭✭✭JohnnyBravo


    import org.jfree.ui.ApplicationFrame; Error Here
    import org.jfree.ui.RefineryUtilities; Error Here

    /**
    * A simple demonstration application showing how to create a line chart using data from a
    * {@link CategoryDataset}.
    *
    * @author David Gilbert
    */
    public class LineChartDemo1 extends ApplicationFrame {

    /**
    * Creates a new demo.
    *
    * @param title the frame title.
    */
    public LineChartDemo1(String title) {

    super(title);

    CategoryDataset dataset = createDataset();
    JFreeChart chart = createChart(dataset);
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new Dimension(500, 270));
    setContentPane(chartPanel);

    }

    /**
    * Creates a sample dataset.
    *
    * @return The dataset.
    */
    private CategoryDataset createDataset() {

    // row keys...
    String series1 = "First";
    String series2 = "Second";
    String series3 = "Third";

    // column keys...
    String type1 = "Type 1";
    String type2 = "Type 2";
    String type3 = "Type 3";
    String type4 = "Type 4";
    String type5 = "Type 5";
    String type6 = "Type 6";
    String type7 = "Type 7";
    String type8 = "Type 8";

    // create the dataset...
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    dataset.addValue(1.0, series1, type1);
    dataset.addValue(4.0, series1, type2);
    dataset.addValue(3.0, series1, type3);
    dataset.addValue(5.0, series1, type4);
    dataset.addValue(5.0, series1, type5);
    dataset.addValue(7.0, series1, type6);
    dataset.addValue(7.0, series1, type7);
    dataset.addValue(8.0, series1, type8);

    dataset.addValue(5.0, series2, type1);
    dataset.addValue(7.0, series2, type2);
    dataset.addValue(6.0, series2, type3);
    dataset.addValue(8.0, series2, type4);
    dataset.addValue(4.0, series2, type5);
    dataset.addValue(4.0, series2, type6);
    dataset.addValue(2.0, series2, type7);
    dataset.addValue(1.0, series2, type8);

    dataset.addValue(4.0, series3, type1);
    dataset.addValue(3.0, series3, type2);
    dataset.addValue(2.0, series3, type3);
    dataset.addValue(3.0, series3, type4);
    dataset.addValue(6.0, series3, type5);
    dataset.addValue(3.0, series3, type6);
    dataset.addValue(4.0, series3, type7);
    dataset.addValue(3.0, series3, type8);

    return dataset;

    }

    /**
    * Creates a sample chart.
    *
    * @param dataset a dataset.
    *
    * @return The chart.
    */
    private JFreeChart createChart(CategoryDataset dataset) {

    // create the chart...
    JFreeChart chart = ChartFactory.createLineChart(
    "Line Chart Demo 1", // chart title
    "Type", // domain axis label
    "Value", // range axis label
    dataset, // data
    PlotOrientation.VERTICAL, // orientation
    true, // include legend
    true, // tooltips
    false // urls
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    StandardLegend legend = (StandardLegend) chart.getLegend();
    legend.setDisplaySeriesShapes(true);
    legend.setShapeScaleX(1.5);
    legend.setShapeScaleY(1.5);
    legend.setDisplaySeriesLines(true);

    chart.setBackgroundPaint(new Color(0xCC, 0xCC, 0xFF));

    CategoryPlot plot = chart.getCategoryPlot();

    // customise the range axis...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRangeIncludesZero(true);
    rangeAxis.setUpperMargin(0.20);
    rangeAxis.setLabelAngle(Math.PI / 2.0);

    // ****************************************************************************
    // * JFREECHART DEVELOPER GUIDE *
    // * The JFreeChart Developer Guide, written by David Gilbert, is available *
    // * to purchase from Object Refinery Limited: *
    // * *
    // * http://www.object-refinery.com/jfreechart/guide.html *
    // * *
    // * Sales are used to provide funding for the JFreeChart project - please *
    // * support us so that we can continue developing free software. * *
    // ****************************************************************************

    // customise the renderer...
    LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setDrawShapes(true);

    renderer.setSeriesStroke(
    0, new BasicStroke(2.0f,
    BasicStroke.CAP_ROUND,
    BasicStroke.JOIN_ROUND,
    1.0f,
    new float[] {10.0f, 6.0f},
    0.0f)
    );
    renderer.setSeriesStroke(
    1, new BasicStroke(2.0f,
    BasicStroke.CAP_ROUND,
    BasicStroke.JOIN_ROUND,
    1.0f,
    new float[] {6.0f, 6.0f},
    0.0f)
    );
    renderer.setSeriesStroke(
    2, new BasicStroke(2.0f,
    BasicStroke.CAP_ROUND,
    BasicStroke.JOIN_ROUND,
    1.0f,
    new float[] {2.0f, 6.0f},
    0.0f)
    );

    renderer.setItemLabelsVisible(true);
    renderer.setPositiveItemLabelPosition(new ItemLabelPosition());
    renderer.setNegativeItemLabelPosition(new ItemLabelPosition());
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;
    }

    /**
    * Starting point for the demonstration application.
    *
    * @param args ignored.
    */
    public static void main(String[] args) {

    LineChartDemo1 demo = new LineChartDemo1("Line Chart Demo");
    demo.pack();
    RefineryUtilities.centerFrameOnScreen(demo);
    demo.setVisible(true);

    }

    }


    org/jfree/chart/demo/LineChartDemo1.java [60:1] package org.jfree.ui does not exist


  • Closed Accounts Posts: 1,651 ✭✭✭Enygma


    You need to download the JCommon package from www.jfree.org
    It's got the ui package in it.

    It should be included really.


  • Closed Accounts Posts: 537 ✭✭✭JohnnyBravo


    i went to the guy that invented its forum and he didnt even know that cheers


  • Closed Accounts Posts: 537 ✭✭✭JohnnyBravo


    did you download it and get it working cos i still have the same problem even though i have j common i set up the class path in windows not dosand it still doesnt work if i searched for the files that it claims dont exist it wont find it so would you search for files and folders on yours


  • Advertisement
  • Closed Accounts Posts: 1,651 ✭✭✭Enygma


    Check your import statements, this compiles and runs perfectly for me with the jcommon and jfreechart jars in the classpath:
    import java.awt.BasicStroke;
    import java.awt.Color;
    import java.awt.Dimension;
    import org.jfree.chart.ChartFactory;
    import org.jfree.chart.ChartPanel;
    import org.jfree.chart.JFreeChart;
    import org.jfree.chart.StandardLegend;
    import org.jfree.chart.axis.NumberAxis;
    import org.jfree.chart.plot.CategoryPlot;
    import org.jfree.chart.plot.PlotOrientation;
    import org.jfree.chart.renderer.ItemLabelPosition;
    import org.jfree.chart.renderer.LineAndShapeRenderer;
    import org.jfree.data.CategoryDataset;
    import org.jfree.data.DefaultCategoryDataset;
    import org.jfree.ui.ApplicationFrame; //Error Here
    import org.jfree.ui.RefineryUtilities; //Error Here
    /**
    * A simple demonstration application showing how to create a line chart using data from a
    * {@link CategoryDataset}.
    *
    * @author David Gilbert
    */
    public class LineChartDemo1 extends ApplicationFrame
    {
       /**
       * Creates a new demo.
       *
       * @param title the frame title.
       */
       public LineChartDemo1(String title)
       {
          super(title);
          CategoryDataset dataset= createDataset();
          JFreeChart chart= createChart(dataset);
          ChartPanel chartPanel= new ChartPanel(chart);
          chartPanel.setPreferredSize(new Dimension(500, 270));
          setContentPane(chartPanel);
       }
       /**
       * Creates a sample dataset.
       *
       * @return The dataset.
       */
       private CategoryDataset createDataset()
       {
          // row keys...
          String series1= "First";
          String series2= "Second";
          String series3= "Third";
          // column keys...
          String type1= "Type 1";
          String type2= "Type 2";
          String type3= "Type 3";
          String type4= "Type 4";
          String type5= "Type 5";
          String type6= "Type 6";
          String type7= "Type 7";
          String type8= "Type 8";
          // create the dataset...
          DefaultCategoryDataset dataset= new DefaultCategoryDataset();
          dataset.addValue(1.0, series1, type1);
          dataset.addValue(4.0, series1, type2);
          dataset.addValue(3.0, series1, type3);
          dataset.addValue(5.0, series1, type4);
          dataset.addValue(5.0, series1, type5);
          dataset.addValue(7.0, series1, type6);
          dataset.addValue(7.0, series1, type7);
          dataset.addValue(8.0, series1, type8);
          dataset.addValue(5.0, series2, type1);
          dataset.addValue(7.0, series2, type2);
          dataset.addValue(6.0, series2, type3);
          dataset.addValue(8.0, series2, type4);
          dataset.addValue(4.0, series2, type5);
          dataset.addValue(4.0, series2, type6);
          dataset.addValue(2.0, series2, type7);
          dataset.addValue(1.0, series2, type8);
          dataset.addValue(4.0, series3, type1);
          dataset.addValue(3.0, series3, type2);
          dataset.addValue(2.0, series3, type3);
          dataset.addValue(3.0, series3, type4);
          dataset.addValue(6.0, series3, type5);
          dataset.addValue(3.0, series3, type6);
          dataset.addValue(4.0, series3, type7);
          dataset.addValue(3.0, series3, type8);
          return dataset;
       }
       /**
       * Creates a sample chart.
       *
       * @param dataset a dataset.
       *
       * @return The chart.
       */
       private JFreeChart createChart(CategoryDataset dataset)
       {
          // create the chart...
             JFreeChart chart=
                ChartFactory.createLineChart("Line Chart Demo 1", // chart title
          "Type", // domain axis label
          "Value", // range axis label
          dataset, // data
          PlotOrientation.VERTICAL, // orientation
          true, // include legend
          true, // tooltips
          false // urls
       );
          // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
          StandardLegend legend= (StandardLegend)chart.getLegend();
          legend.setDisplaySeriesShapes(true);
          legend.setShapeScaleX(1.5);
          legend.setShapeScaleY(1.5);
          legend.setDisplaySeriesLines(true);
          chart.setBackgroundPaint(new Color(0xCC, 0xCC, 0xFF));
          CategoryPlot plot= chart.getCategoryPlot();
          // customise the range axis...
          NumberAxis rangeAxis= (NumberAxis)plot.getRangeAxis();
          rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
          rangeAxis.setAutoRangeIncludesZero(true);
          rangeAxis.setUpperMargin(0.20);
          rangeAxis.setLabelAngle(Math.PI / 2.0);
          // ****************************************************************************
          // * JFREECHART DEVELOPER GUIDE *
          // * The JFreeChart Developer Guide, written by David Gilbert, is available *
          // * to purchase from Object Refinery Limited: *
          // * *
          // * [url]http://www.object-refinery.com/jfreechart/guide.html[/url] *
          // * *
          // * Sales are used to provide funding for the JFreeChart project - please *
          // * support us so that we can continue developing free software. * *
          // ****************************************************************************
          // customise the renderer...
          LineAndShapeRenderer renderer= (LineAndShapeRenderer)plot.getRenderer();
          renderer.setDrawShapes(true);
          renderer.setSeriesStroke(
             0,
             new BasicStroke(
                2.0f,
                BasicStroke.CAP_ROUND,
                BasicStroke.JOIN_ROUND,
                1.0f,
                new float[] { 10.0f, 6.0f },
                0.0f));
          renderer.setSeriesStroke(
             1,
             new BasicStroke(
                2.0f,
                BasicStroke.CAP_ROUND,
                BasicStroke.JOIN_ROUND,
                1.0f,
                new float[] { 6.0f, 6.0f },
                0.0f));
          renderer.setSeriesStroke(
             2,
             new BasicStroke(
                2.0f,
                BasicStroke.CAP_ROUND,
                BasicStroke.JOIN_ROUND,
                1.0f,
                new float[] { 2.0f, 6.0f },
                0.0f));
          renderer.setItemLabelsVisible(true);
          renderer.setPositiveItemLabelPosition(new ItemLabelPosition());
          renderer.setNegativeItemLabelPosition(new ItemLabelPosition());
          // OPTIONAL CUSTOMISATION COMPLETED.
          return chart;
       }
       /**
       * Starting point for the demonstration application.
       *
       * @param args ignored.
       */
       public static void main(String[] args)
       {
          LineChartDemo1 demo= new LineChartDemo1("Line Chart Demo");
          demo.pack();
          RefineryUtilities.centerFrameOnScreen(demo);
          demo.setVisible(true);
       }
    }
    
    


  • Closed Accounts Posts: 537 ✭✭✭JohnnyBravo


    cheers fixed it its netbeans is a bit different to borland


  • Closed Accounts Posts: 1,651 ✭✭✭Enygma


    I used Eclipse, well worth taking a look at. www.eclipse.org


Advertisement