jfreechart export SVG size issue - java

I am using JFreeChart, and I want to export my Chart to SVG. I refer this code.
If I send Rectangle bounds parameter like
new Rectangle(100,100);
then I get the complete image(Chart). But for another dimension, I get cropped image(Chart).
What I miss?

I fond solution.
we need to give input in the Same ratio as image have.

Related

PolygonSprite in LibGdx shows only part of the Texture.

i have got this beautiful looking image:
I decided to use the PolygonSprite class in LiGgdx to display a part of that Image.
It ended up looking like that:
As you can see the very left corner of my image is visible.
Here comes my question:
What can i do to display a larger part of that image inside the polygonSprite above, without changing the polygonSprite's size ?
I do really appreciate any answer and please don't hesitate to ask if something isn't clear.
I've never used it myself, but looking at the documentation it looks like this: you have to create the polygonsprite with a correct polygonregion (vertices with pixel coordinates of the texture) and then use setSize to "scale" it to the size you want to display it (world/viewport coordinates).

Java: Find image within image?

So, say I have two images, one which is a .bmp of some text and another which is a bufferedImage, how would I go about finding if the .bmp is inside the bufferedImage?
Im really lost on how to find an image within an image, a color is easier as its just one thing to search for but an image seems much harder...
One Solution to this Problem is "Template Matching".
This means sliding your Template (the image you want to find) over the Image (you want to search in) and at every Position compare the similiarity of all Pixels.
The Position of your Template in the Image is at the Maximum this procedure returned.
As suggested in the comments you can use OpenCV for this Task which support Template Matching.

How to remove black border around transparent image in PDF created by iText

I have searched over bunch of sites, and I was unable to find solution for my problem.
This is the problem:
I am making PDF's in Java using iText library.
Everything works fine except one thing.
Transparent PNG images have black/gray border around non-transparent area.
I didn't set any borders in code, and actually I have tried to remove them (with no luck).
Can someone help me how to solve this problem?
The closest answer what I have found is: Resizing an image in asp.net without losing the image quality
But I cannot (don't know) interpret this code in Java.
My code is pretty big to copy/paste, but these are steps:
create document
load image from given path
manipulate image (resize, rotate, positioning)
add image to current page
save pdf file
This is what I have tried also:
http://itext-general.2136553.n4.nabble.com/template/NamlServlet.jtp?macro=print_post&node=2157267
http://itext-general.2136553.n4.nabble.com/template/NamlServlet.jtp?macro=print_post&node=2330200
I have tried more than those 2, but I didn't bookmarked them (none of them worked)
Thanks in advance
UPDATE: I forgot to mention that my original pictures don't have border. Border is created somehow by iText. I initially thought that it was bug, but since iText 5.0.2 this problem remained so now I doubt that is bug (I am currently using 5.1.3).
UPDATE 2 I forgot to add this link: http://itext-general.2136553.n4.nabble.com/template/NamlServlet.jtp?macro=print_post&node=2157261
Here is presented VB script that works, but I cannot convert to Java code (it still draws black border), so can someone help me at least with this to convert good?
You could use the java BufferedImage method, getSubImage(x, y, w, h) which allows you to crop a sub image out of an existing image. That way you could cut out the edges.
See here: Class BufferedImage

How to create a custom Java Swing GUI Component with a shape and gradient

I have to create a custom component on my JFrame, the Component will show the storage status of that user, the storage will be in percentage.
I need to create something like this:
I tried a custom JLabel to create a label and then coloring that label from left to right, but I was unable to create a cloud shape Label and then filling that label according to a variable value.
How should I do this and what is the best way to do it?
One time I thought I should use series of images to show the status of user storage.
Thanks!
I think you're going to need to use an image mask (examples here and here) if you are to replicate that cloud exactly.
The process will require 2 images:
The cloud outline (the blue parts)
An image mask is the shape of the cloud, probably black outside and white inside
Then your drawing process, which you'll have to do each time the % storage changes will be:
Create a new buffered image
Draw then green fill bar in the style you want (e.g. slanted as in this image)
Copy the image mask over this
Draw this new image to the screen, with the mask applied as described here
Draw the cloud outline image to screen
That's going to take an hour or so for you to put together, so I'm not going to do it for you. Have a go, and if you run in to problems (or don't understand anything I just described) then ask about that specifically.
You can use GlyphVector#getGlyphOutline() to get the shape of a Unicode character like ☁ \u2601 and fill it with a GradientPaint.
You can do that with a JLabel and a custom-implemented class derived from Icon.
doesn't this help? Java gradient label example
And if you understand (or can translate from) portuguese, there's also this discussion with a solution at the end

Images are black in PDF

I'm creating piecharts using JFreeChart, use chart.createBufferedImage(width,height) and give the buffered image to IReport as an image parameter. In IReport I have an image and its image expression points to this parameter, so I can render the image. But when exported to PDF, images are covered with a black rectangle. Something about transparency or RGB, I guess.
There's a thread here about this problem and some suggested solutions, but I couldn't apply them to my problem, will you help me? Thanks.
The thread: http://www2.jasperforge.org/plugins/espforum/view.php?group_id=102&forumid=103&topicid=21922&page=2#24710
As suggested by #Pekka, this is likely a limitation of Transparency in PDF files.
I can't find a way to set RGB or trasparency values from JFreeChart.
The JFreeChart class includes a createBufferedImage() method that accepts an imageType, which is subsequently used to create the BufferedImage . You may have to select the optimal one empirically.

Categories

Resources