Help coderanch get a
new server
by contributing to the fundraiser

Anup Hege

Greenhorn
+ Follow
since Dec 10, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Anup Hege

Ulf Dittmer wrote:Make sure you set the Content-Disposition header to "inline", not "attachment".

But ultimately, it's up the client - if the browser is configured to open the dialog box for such files, then there's nothing the web app can do about that.



@Ulf,
I have tried with to open the excel sheet with Inline files i.e. I have set the Content-Disposition header to "inline".
But still the Browser is opening up a Dialog box with "Open", "Save" and "Cancel" buttons.
Would be helpfull If I can avoid this ?

Also If the Excel sheet Open's Inline inside the browser I am unable to get the Menu bar as a result of which I am not able to save the excel sheet directly by clicking the save button. The menu bar of an Excel sheet doesnt come up inline inside a Web browser as shown in the example in the URL mentioned below.

Inline Excel Sheet Example

The excel sheet is opened by a JSP page which has been included in the form of an iframe in the parent JSP page.
I have set the following parameters in the code.
13 years ago

Ulf Dittmer wrote:OK, so the NumberFormat is only used if lower bound != upper bound, but I'm guessing you already knew that.

But this is a problem:

(itr.next()).getCategoryPlot().getRangeAxis(0).setRangeWithMargins(dLowerBoundRange, dUpperBoundRange);

NumberAxis naxis =((NumberAxis)(itr.next()).getCategoryPlot().getRangeAxis(0));


itr.next() retrieves a new element from the iterator each time it is called, so these two statements work on different objects. This ensures that the NumberFormat is only used for every other iterator element - most likely not what you want.



You are correct Ulf.
I have used a different technique for resolving this issue.
Below is the code for the same

Ulf Dittmer wrote:Post the code that does that for all range axes.





Ulf Dittmer wrote:

Anup Hege wrote:The format(double) is a final function in NumberFormat Class.


Oh, right, I forgot about that. But a look at the source code of the NumberFormat class shows that it calls one of the overridden methods. Where and how are you using this class?



I am using the NumberFormat class as suggested by you in one of the earlier posts.



I have used the function setNumberFormatOverride for calling my Customised NumberFormat Class.

Ulf Dittmer wrote:

The Charts use the format() function for converting the double number into String.
How can we make the charts use our NumberFormat's Overloaded format (long number, StringBuffer toAppendTo, FieldPosition pos) function.


Why don't you override format(double) instead, since that's what's being used?



Hi,
Thanks for the reply.
This is where I am facing the difficulty.
The format(double) is a final function in NumberFormat Class.
Hence I am not able to Override the same.
Kindly let me knwo if I am overlooking / missing something.

Ulf Dittmer wrote:Where did you insert print statements? How are you using this code? Post the actual code.



Hi,

The code with the print statements is as mentioned below.




I have noticed one more thing in the below mention URL which has the source code for Jfree Chart.
Number Axis Code

The Charts use the format() function for converting the double number into String.
How can we make the charts use our NumberFormat's Overloaded format (long number, StringBuffer toAppendTo, FieldPosition pos) function.

Ulf Dittmer wrote:You'd "override" the NumberFormat by calling the method I mentioned. Did you find it in the javadocs?

Or are you asking about what a NumberFormat is, and how to create your own? I'm sure searching for something like "java extend numberformat" will find examples.



I wanted to display only the bolded numbers on my chart.
For Eg : 0.0 0.5 1.0 1.5 ..... 6.0 6.5 7.0
I am trying to avoid decimal numbers in the Range Axis (Y Axis).
I have written the below mentioned code for avoiding the same.
But still the decimal numbers are getting displayed.

NumberAxis na =((NumberAxis)(itr.next()).getCategoryPlot().getRangeAxis(0));
NumberFormat nf = new DecimalFormat("#");
nf.setMaximumFractionDigits(0);
((DecimalFormat) nf).setDecimalSeparatorAlwaysShown(false);
na.setNumberFormatOverride(nf);

Aternately as suggested I have tried to extend NumberFormat Class and tried to format the numbers.

public class UtilNumberFormat extends NumberFormat {
public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) {
if(number>=100)
return toAppendTo.append(number);
else
return toAppendTo.append("");
}
public StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos) {
if(number>=100)
return toAppendTo.append(number);
else
return toAppendTo.append("");
}
public Number parse(String source, ParsePosition parsePosition) {
return null;
}
}

The above code is not to avoid the decimal numbers, but i have tried inserting SOP inside the format function.
And the SOP doesnt get displayed.
Kindly guide as to where I am taking the wrong turn.