Displaying data inside graphic element, ellipse - jasper-reports

I have a business condition where I need to highlight a data (number value) value by drawing an ellipse around the data.
The logic is something like
if y < X
Display data highlighted with an ellipse.
else
Display data
Eg:
I'm using JRBeanCollectionDataSource as the data source and <jr:table> for formatting the report.
How can I print the value inside an ellipse?
<jr:detailCell style="table_TD" height="20" rowSpan="1">
<textField>
<reportElement mode="Transparent" x="0" y="0" width="250" height="19" isRemoveLineWhenBlank="true" uuid="a457d366-5e92-4588-be11-182d164a8db3">
<printWhenExpression><![CDATA[!($F{country}.isEmpty())]]></printWhenExpression>
</reportElement>
</textField>
</jr:detailCell>

Put the ellipse before the text element
OR
make the ellipse transparent

Related

How to fill in the empty space in between images for volumetric imaging/ 3D reconstruction in matlab

I am trying to create a 3D model of packed spherical beads with image slices. These images are of spherical beads with varying diameters, taken 0.0015 apart. The cube is 2.154x2.154x2.154. I was able to "stack" the images on top of each other and negate empty space to compile a model. I now have the issue of filling in the space in between the image slices in order to run simulations/evaluate the space unoccupied by spheres.
I tried using the matlab function interp3 but I'm having trouble applying it. I'm also unsure if this is the correct method to "fill in" or "complete" the spheres. The following code only uses every third image within the range of the first 43 out of 1408 images.
isometric view of stacked images - height 0.0643
Side view of images stacked
for i = 1:3:43 %height - 0.0643 out of 2.154
filename = ['10000_test_packing_' sprintf('%0.0f',i) '.tif'];
temp=double(imread(filename));
image(:,:,i) = .5*(temp(:,:,1)==1) +(temp(:,:,2)==0) + 2*(temp(:,:,3)==0);
end
volumeViewer(image)
%% "Filling in the Spheres"
%Interpolation using interp3?
[X, Y, Z] = meshgrid(0:656, 0:875, 0:20);
[x, y, z] = meshgrid(0:656, 0:875, 0:.24:20);
test = interp3(X, Y, Z, image(:,:,1), x, y, z, 'cubic');
The first section of the code only stacks the images but does not make it possible to evaluate the volume of "empty space" within the cube. This is because the slices hold no volume and within the space between images, there is nothing.
I need to find a way to solidify the spheres so that there is no space in between slices and that the spheres are complete.

Matlab - intersection coordinates of lines based on their coordinates [duplicate]

This question already has answers here:
Find point of intersection between two vectors in MATLAB
(4 answers)
Closed 5 years ago.
I have 2 lines coordinates (x1,y1 x2,y2 and x3,y3 x4,y4), how can I calculate the intersection coordinates without plotting them?
You could use the function polyxpoly for getting the intersection points.
See here for documentation and further information.
Here is a short example:
start1 = [1;1];
end1 = [3;3];
line1 = [start1, end1];
start2 = [1;3];
end2 = [2;1];
line2 = [start2,end2];
[xi, yi] = polyxpoly(line1(1,:), line1(2,:), line2(1,:), line2(2,:));
This will give you the intersection point xi and yi.
Note that this function is capable of a lot more than dealing with simple lines, such as boxes, intersection segments, etc.
The intersection point will be (x,y) = ((b1-b)/(1-a1), (a1*b-b1*a)/(a1-a))
where a = (y1-y2)/(x1-x2);
a1 = (y3-y4)/(x3-x4);
b = y1 - x1*(y1-y2)/(x1-x2);
b1 = y3 - x3*(y3-y4)/(x3-x4)
You can check the algebra by following these steps:
1) find the equation for the line passing by (x1,y1) and (x2,y2) and another equation for the line passing by the other two points;
2) force equality onto the two equations and you will have the intersection point

N-dimensional MatLab Meshgrid

I know I can do this by meshgrid up to 3-dimensional space.
If I do
[X,Y] = meshgrid(1:3,10:14,4:8)
as in http://www.mathworks.com/help/matlab/ref/meshgrid.html, then I will get the grid points on the 3-D space.
But meshgrid can't do this for n-dimensional space.
How should I get grid points (do similar thing like meshgrid) on n-dimensional space (e.g. n=64) ?
To create a grid of n-dimensional data, you will want to use ndgrid
[yy,xx,zz,vv] = ndgrid(yrange, xrange, zrange, vrange);
This can be expanded to any arbitrary number of dimensions.
As Daniel notes, notice that the first two outputs are reversed in their naming since y (rows) are the first dimension in MATLAB.
If you want to go to really high dimensions (such as 64), when the inputs/outputs get unmanageable, you can setup cell arrays for the inputs and outputs and rely on cell array expansion to do the work:
ranges = cell(64, 1);
ranges{1} = xrange;
ranges{2} = yrange;
...
ranges{64} = vals;
outputs = cell(size(ranges);
[outputs{:}] = ndgrid(ranges{:});
As a side note, this can really blow up quickly as your number of dimensions grows. There may be a more elegant solution to what you're ultimately trying to do.
For example if I create example inputs (at 64 dimensions) and for each dimension choose a random number between 1 and 5 for the length, I get a "maximum variable size" error
ranges = arrayfun(#(x)1:randi([1 5]), 1:64, 'uniform', 0);
[xx,yy] = ndgrid(ranges{:});

Matlab (How to fit multiple data sets ) [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
Suppose I have for vectors x1, y1, x2, y2, and I would like to plot this data (x1,y1) and (x2,y2) with different colors. The dimesions of vector x1,y1 are not the same with x2,y2.
Than I would like also to fit all this data together, with the same polynomial fit, degree 1.
Can someone help me to do it?
You can plot the vectors simply using plot:
plot(x1, y1, 'r.', x2, y2, 'b.')
where the 'r.' specifies that this first pair should be plotted in red dots, and the 'b.' specifies that the second pair should be plotted in blue dots. You can find a more complete list of color/marker options in the help documentation for plot.
To fit a polynomial to (x,y) data, you can use polyfit:
poly_coeffs = polyfit( x, y, poly_degree )
If you want to fit the same polynomial to both sets of data, you should concatenate your vectors into a single vector, e.g. (in the case of row vectors):
x = [x1, x2]
y = [y1, y2]
poly_coeffs = polyfit( x, y, poly_degree )
If you have column vectors, you would use x = [x1; x2] (note the semicolon instead of the comma) to concatenate them vertically.
And now if you wanted to plot the polynomial fit on top of the original data, you can add it on to the list of arguments to plot:
curve_x = linspace( min(x), max(x), 100 );
curve_y = polyval( poly_coeffs, curve_x );
plot(x1,y1,'r.', x2,y2,'b.', curve_x,curve_y,'k-');

Smoothing an airfoil data [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
These are some data points for an airfoil shape:
x=[1 0.8518 0.7040 0.5536 0.3988 0.2454 0.0937 0.0199 0.0015 0 0.0169 0.0812 0.2054 0.3525 0.4979 0.6457 0.7974 0.9497];
y=[0 0.0355 0.0819 0.1206 0.1347 0.1200 0.0777 0.0363 0.0162 0 -0.0197 -0.0428 -0.0645 -0.0749 -0.0701 -0.0506 -0.0249 -0.0026];
I'm not allowed to use any curve fitting toolbox. What method do I use to plot a smoother looking airfoil shape. Should I use polyfit or interp1?
Yes, interp1 should do the job, but you need to spilt your data in two halves, the positive y and the negative y, with their corresponding x values.
Here's an example using cubic interpolation. Check the doc for interp1 for more details:
ypos = y(y>=0); % y only when positive
xpos = x(y>=0); % corresponding values of x
yneg = y(y<0); % y only when strictly negative
xneg = x(y<0); % corresponding values of x
xi=linspace(0,max(x),100); % values of x for interpolation (100 values linearly spaced between 0 and the max of x
yposi = interp1(xpos,ypos,xi,'cubic','extrap'); % interpolated values of y (when positive) using cubic interpolation and extrapolation
ynegi = interp1(xneg,yneg,xi,'cubic','extrap'); % interpolated values of y (when strictly negative) using cubic interpolation and extrapolation
plot(x,y,'ro',xi,yposi,'b-',xi,ynegi,'b-') % plot interpolated data on top of original data