Page 1 of 2

Upgrade from v1 to v3-Eval

Posted: Fri May 25, 2012 5:49 pm
by 7669317
Hello there,

I'm already a customer with v1.
I'm trying to apply the V3 version to see the impacts in my systems and see if the correction's are ok. But, i'm get a black screen in my graph's and i don't know why. Basically, the only change i need to made in my graph call was the img.image() because it wait's for a Dimension class as parameter and my v1 expect int as width and height. Basically, i just put the new Dimension(w,h) into my img.image().

But i'm getting this result (see attachment bellow).

Edit: i'm sorry, i know that this is too much generic, but, i hope you guys could know what's going on.. thanks!

Re: Upgrade from v1 to v3-Eval

Posted: Mon May 28, 2012 2:46 pm
by yeray
Hi Lourival,

I'm afraid I don't remember hearing about something like this before.
Have you tried a new simple project to see if the component works as expected with a new chart?
The data isn't probably relevant here, so, assuming a new simple chart works fine, I'd try to add the code from your old application to this new chart to try to find what is the setting that seems to be causing this.

Re: Upgrade from v1 to v3-Eval

Posted: Mon Jun 04, 2012 1:38 pm
by 7669317
Hello again Yeray,

I got a sample code from the forum and made a little change to export the graph to .jpg

Here is the code:

Code: Select all

  public static void main(String[] args) throws IOException {
    JFrame frame = new JFrame();
    JPanel panel = new JPanel();
    panel.setSize(600, 600);
    TChart chart = new TChart();
    
    panel.add(chart);
    Bar b = new Bar(chart.getChart());
    b.add(1.0, 10.0);
    b.add(2.0, 20.0);
    b.add(3.0, 30.0);
    b.add(4.0, 40.0);
    b.add(5.0, 0.0);
    b.setMultiBar(MultiBars.STACKED);
    b.setBarWidthPercent(100);
    b.getMarks().setVisible(false);
    
    boolean hasValue = true;
    Bar b1 = new Bar(chart.getChart());
    b1.add(1.0, 10.0);
    if(hasValue){
       b1.add(2.0, 0);
    }else{
       b1.add(2.0, 0, Color.TRANSPARENT);
    }
    b1.add(3.0, 30.0);
    if(hasValue){
       b1.add(4.0, 0);
    }else{
       b1.add(4.0, 0, Color.TRANSPARENT);
    }
    b1.add(5.0, 50.0);
    b1.setMultiBar(MultiBars.STACKED);
    b1.setBarWidthPercent(100);
    
    int[] totalMarkCount = new int[b1.getCount()];
    for(int i=0; i<b.getCount(); i++){
       totalMarkCount[i] += b.getMarkValue(i); 
    }

    for(int i=0; i<b1.getCount(); i++){
       totalMarkCount[i] += b1.getMarkValue(i); 
    }

    for(int i=0; i<totalMarkCount.length; i++){
       System.out.println("total count: " + totalMarkCount[i]);
    }

    //move int to StringList
    StringList labelList = new StringList(b1.getCount());
    for(int i=0; i<b1.getCount(); i++){
       labelList.add(i, Integer.toString(totalMarkCount[i]));
    }
    
    //reset new total count to b1
    b1.setLabels(labelList);

    chart.getAxes().getBottom().getLabels().setStyle(AxisLabelStyle.VALUE);

    //set 2D
    chart.getAspect().setView3D(false);
    
    [b]ImageExport img = chart.getExport().getImage();
    img.image(new Dimension(1024, 768));
    img.getJPEG().save("C:/pie.jpg");[/b]
 
    frame.add(panel);
    frame.setSize(600, 600);
    frame.setVisible(true);
}
When you execute the code, you get a black image form it. But it still works in the frame for example. This is the problem that i have: It works in my V1, but not in the V3 evaluation copy.

Edit1: Forget about the name "pie". I was crazy in that moment :P
Edit2: Perhaps there's something missing before export to file.. But i don't know what it is...
Edit3: Here is the result:

Re: Upgrade from v1 to v3-Eval

Posted: Tue Jun 05, 2012 11:44 am
by yeray
Hi Lourival,
Lourival wrote:Perhaps there's something missing before export to file.. But i don't know what it is...
Yes, something like this. The problem is that the chart has to be drawn before being exported, and the getImage() function doesn't completely do it. I'm trying to find a function (update, repaint, refresh, validate,...) to force a chart repaint before the initial complete window drawing, but I can't find it.
In the meanwhile, using the chartPainted event works fine for me. You could substitute this in your code:

Code: Select all

    ImageExport img = chart.getExport().getImage();
    img.image(new Dimension(1024, 768));
    img.getJPEG().save("C:/pie.jpg");
For this:

Code: Select all

        export = true;

        tChart1.addChartPaintListener(new ChartPaintAdapter() {

            @Override
            public void chartPainted(ChartDrawEvent e) {
                if (export) {
                    export = false;
                    ImageExport img = tChart1.getExport().getImage();
                    img.image(new Dimension(1024, 768));
                    try {
                        img.getJPEG().save("C:/pie.jpg");
                    } catch (IOException ex) {
                        Logger.getLogger(DesktopApplication1View.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }
        });
Lourival wrote:Edit1: Forget about the name "pie". I was crazy in that moment :P
Glad to hear you're better now! ;)

Re: Upgrade from v1 to v3-Eval

Posted: Tue Jun 05, 2012 12:27 pm
by 7669317
Hello again Yeray,


So, I understand that i need to get the image when chartPainted is called.
But, in my application, i need to to the getImage() and save the .jpg when my method of exportImageChart is called... I can't do it when the event is called...

something like this:

Code: Select all

  public String exportImageChart() {
    String imageName = RandomGUID.newGUID();

    File folder = new File(WFRConfig.reportsGeneratedDir());
    folder.mkdirs();

    File file = new File(WFRConfig.reportsGeneratedDir() + File.separatorChar + imageName + ".jpg");

    String tmpName = file.getAbsolutePath();

    try {
      ImageExport img = chart.getExport().getImage();
      img.image(new Dimension(Integer.parseInt(com.getProperty(ComponentProperty.TAMANHO)), Integer.parseInt(com.getProperty(ComponentProperty.ALTURA))));
      img.getJPEG().save(tmpName);

    } catch (IOException ex) {
      logger.error(htmli.getUser(), sys.getCode(), ex);
    }

    tmpName = "WFRReports/Generated/" + imageName + ".jpg";

    return tmpName;
  }
If i put the event, it's not guarantee that it'll be generated/saved in this time.

Am i missing something ?

Re: Upgrade from v1 to v3-Eval

Posted: Tue Jun 05, 2012 2:09 pm
by yeray
Hello,

The key is: is the exportImageChart method called before or after the form is shown?
- If it is called once the form has been shown, when a button is being pressed or something, you shouldn't find problems. So I don't think it's the case.
- If it is called before showing the form, the only way I've found to make it work is by using the event. The chartPainted event will be executed just when the form has finished the drawing process so the getImage() function returns a valid image.

However, you have to take care because calling getImage() into the chartPainted event without control would make an end-less loop. That's why I used a boolean ("export") to be sure the exportation is made only once.

Re: Upgrade from v1 to v3-Eval

Posted: Tue Jun 05, 2012 5:00 pm
by 7669317
The key is: is the exportImageChart method called before or after the form is shown?
Ashley, there's no form: I always generate the graph in jpg files and present the .jpg file in my web application.
- If it is called before showing the form, the only way I've found to make it work is by using the event. The chartPainted event will be executed just when the form has finished the drawing process so the getImage() function returns a valid image.
As i said, there's no form: I just want to generate the picture of the graph into a file, and this method is my way to do it...
However, you have to take care because calling getImage() into the chartPainted event without control would make an end-less loop. That's why I used a boolean ("export") to be sure the exportation is made only once.
Yes, i realized that.


Edit:
Another thing:

If you try this code:
TChart tChart2 = new TChart();
ChartEditor.editChart(tChart2.getChart());
And then, in the editor put a pizza graphic with data source with random (8 data for default) and go to "Export" menu (in the left side), you'll see that it generates an error.

What i mean is, i build the graphic data and want to just export the .jpeg file. That's it: No forms. It always export the black image.

Re: Upgrade from v1 to v3-Eval

Posted: Wed Jun 06, 2012 7:55 am
by yeray
Hi Lourival,

In that case we'll have to try to find a way to make it work without forms. For it, it would be helpful if we could reproduce the very same environment you use (OS, IDE [if any], Java SDK version, TeeChart SWT/Swing,...). So could please arrange a simple example project we can run as-is here, and some simple instructions we can follow to build&execute it?

Re: Upgrade from v1 to v3-Eval

Posted: Wed Jun 06, 2012 12:27 pm
by 7669317
Yeray wrote:Hi Lourival,

In that case we'll have to try to find a way to make it work without forms. For it, it would be helpful if we could reproduce the very same environment you use (OS, IDE [if any], Java SDK version, TeeChart SWT/Swing,...). So could please arrange a simple example project we can run as-is here, and some simple instructions we can follow to build&execute it?
Sure,

You can easily reproduce it by simple do the example of the other topic about the CircularGauge in this thread: http://www.teechart.net/support/viewtop ... 10&t=13328

Infos: Teechart - Swing v3 Eval - JDK 1.5

Code sample to reproduce the problem:

Code: Select all

package wfr;

import java.io.IOException;

import com.steema.teechart.Dimension;
import com.steema.teechart.TChart;
import com.steema.teechart.drawing.Color;
import com.steema.teechart.exports.ImageExport;
import com.steema.teechart.styles.CircularGauge;

class Test {
  static TChart                chart1       = new TChart();
  private static CircularGauge gaugeSeries1 = new CircularGauge(chart1.getChart());
  static double                dHigh        = 8000;
  static double                dLow         = 0;

  public static void main(String[] args) throws IOException {
    chart1.setText("");
    chart1.setClipPoints(false);
    chart1.getHeader().setVisible(false);
    chart1.getLegend().setVisible(false);
    chart1.getAspect().setView3D(false);
    chart1.getAspect().setSmoothingMode(true);
    chart1.getAspect().setTextSmooth(false);
    chart1.getWalls().getBack().setTransparency(100);
    gaugeSeries1.setMaximum(dHigh);
    gaugeSeries1.setMinimum(dLow);
    gaugeSeries1.clear();
    double diff = dHigh - dLow;
    chart1.getAxes().getLeft().setIncrement(diff / 10.0);
    chart1.getAxes().getLeft().setMinMax(dLow, dHigh);

    gaugeSeries1.getFrame().getOuterBand().setColor(Color.fromArgb(153, 153, 153));
    gaugeSeries1.getFrame().getMiddleBand().getGradient().setVisible(true);
    gaugeSeries1.getFrame().getMiddleBand().getGradient().setStartColor(Color.fromArgb(80, 80, 80));
    gaugeSeries1.getFrame().getMiddleBand().getGradient().setEndColor(Color.WHITE);
    gaugeSeries1.getFrame().getInnerBand().setColor(Color.fromArgb(213, 213, 213));

    gaugeSeries1.setValue(3200);

    ImageExport img = chart1.getExport().getImage();
    img.image(new Dimension(1024, 768));
    img.getJPEG().save("C:/graph.jpg");
  }
}

Re: Upgrade from v1 to v3-Eval

Posted: Fri Jun 08, 2012 2:46 pm
by 7669317
Yeray,

Are you checking this for me ?

Re: Upgrade from v1 to v3-Eval

Posted: Fri Jun 08, 2012 2:47 pm
by yeray
Hi Lourival,
Lourival wrote:Are you checking this for me ?
Yes, thanks for reporting it. We're are looking at it and we'll be back to you as soon as we find a way to achieve it.

Re: Upgrade from v1 to v3-Eval

Posted: Mon Jun 11, 2012 12:34 pm
by 7669317
OK! Thanks Yeray,

I'll be waiting for a solution or workaround.

Re: Upgrade from v1 to v3-Eval

Posted: Mon Jun 11, 2012 3:44 pm
by yeray
Hi Lourival,

We've just found where was the problem and fixed it for the next maintenance release.

Re: Upgrade from v1 to v3-Eval

Posted: Mon Jun 11, 2012 4:47 pm
by 7669317
Yeray wrote:Hi Lourival,

We've just found where was the problem and fixed it for the next maintenance release.
Oh, great Yeray!

Is there a way to generate a beta version (of the evaluate version) with this patch so i can try into my application ? Or tell me when this version will be out...

Re: Upgrade from v1 to v3-Eval

Posted: Tue Jun 12, 2012 9:50 am
by yeray
Hi Lourival,

We expect to publish a new maintenance release shortly, evaluation version included.