Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!

Fiorenza Oppici

Ranch Hand
+ Follow
since Jul 22, 2010
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Fiorenza Oppici

Hello Everybody.

I'm working on a graphic editor prototype which requires the implementation of a background eraser.
I built a layered structure with a layeredPane. the first layer contains a background image which remains untouched, the second layer is transparent and is used for the user defined graphics. So, I'd like to make users able to erode color on the second layer with an eraser tool.
I can't just implement the eraser with a stroke in background color, as this would just cover the background image.
And neither setting the background color as transparent would be useful, as it just is paint over.
I'm trying to find if there are some modes which allow me to substitute colour instead of simply painting it over the old color value, but up now I didn't find anything. Can you suggest me some settings for the graphic object so I can achieve that effect?

Many thanks in advance!
8 years ago
Hello dear friends.

In this period I've refined some skills and now time has come to review my weak point: handling graphics in java.
I have to write a simple image editor where you can draw onto a predefined image and then save it.

so, I created the class "Vista" which extends a Component and a control class called "GraphicEditor" which is a JFrame. The contstructor tells Vista to retrieve an image and to save it in a BufferedImage, then I overrided method paintComponent in order to draw the image . Unfortunately, there's no image shown and I'm a bit puzzled.

here are the code chunks:



There's no error message and in debug mode the variable img appears to be a full Bufferedimage (so it's not a problem in reading the file). so probably the flaw must be in painting management.

could you help me?

Thanks for your attention.
8 years ago
I had been trying mastering watercolors for years and never succeded
there's a drawing I made on a comics festival and the unfinished Jeanne d'arc tutorial (Blender 2.48+internal)
9 years ago
sorry I seen only now your last post, I'm not such an expert with code
but, as long as I know:
Before intialisation, a servlet is just a plain java object. then the container calls the method init() on it and it becomes a servlet, that means that it can handle client requests via the Service() method. the method init() is dependent from ServletConfig and ServletContext, two sets of information that can be set in a xml file called DD, deployment descriptor.
ServletConfig is a set of infos only for a specific servlet, ServletContext is visible from all the app (as long it's not distributed), and they are read only once in the lifecycle of a servlet. if you change some values you'll have to redeploy the servlet.

the user types an url, usually basing on the HTTP protocol. the well-known port for HTTP is 80 from the client. (there's a lot of other stuff regarding socket initialisation and port allocation by server side in between I've learned in a previous long-time ago exam I'm not sure I could explain correctly). then http unwraps the HHTP request from all the lower level protocols encapsulation and retrieves the methods (Post ,Head, Get, whatever) and the URL requested. when a server receives a new Http request, it searches for the url in the dd.
in the dd there are tags which map the user-known name (contained into the url) to the middle name and other tags that map the middle name to the real pathname of the requested document as it's on the server, so you can set a correspondance.

This is all I know about that.
9 years ago
this may help you understand better.
Head First JSP and servlets
serch for page 42, there's an useful diagram which shows you the lifecycle of request and responses.
I'm studying on this book and I recommend it to you if you want to learn and keep in mind how servlets actually work.

9 years ago

If I studied well, these objects are created by the server container everytime a client sends a request. then if the servlet has already been initialised, the container creates the two objects HttpRequest and HttpResponse along with a specific thread (one per request) and then passes their reference to the servlet that corresponds to the client-requested URL.
hope I've been clear.
9 years ago
Fiorenza is the italian for the feminine name "Florence" (not the city, that's "Firenze"). Both the city and person names come from the latin "florens", "prosper, blossoming".
Oppici I haven't the faintest idea of what stands for.
9 years ago
this topic may be useful too:
you could also get it as float rest=number%1.
9 years ago
Hi jan, thank you for the suggestion!
the problem with String.replace() -if I understood the spec-is that it replaces all the occurencies, and surely i don't want that, if there's more than a single comma obviously I call an exception because it's not a number.
but this could be useful in future.
9 years ago

Nilesh Miskin wrote:It gave me a 404 error ... not found
Check your deployment descriptor to see if servlet mapping as well as authentication & authorization related info for the relevent servlet is fine.

but he gave us a different URL, which is working.

9 years ago
I get an admin login form. seem your site is working.
9 years ago

Geoff Jefferson wrote: IMO I wouldn't throw an exception unless you expect your users to know better.
I also believe that it is up to the developer to make software as easy to use
as can be expected. There is a good book called "The Inmates Are Running The Asylum"
that discusses software development and the idea is that sometimes programmers
design their product without taking into consideration ( enough ) the persona of the
end user, and as a result the end product is less user friendly than it could be. A good
read I think.


I do believe in the same approach, code design should meet the user needs and not the programmer's ones, from a big scale to the very very small as in my case. it happened that my boyfriend (He's my official app tester, LOL) entered a comma number and obviously he got back an annoying exception so i decided to handle this scenario, although I don't know if there's a cleverer way to achieve the conversion.
thank you for the reading suggestion.
9 years ago
Hi everyone. I developed a small JSP document that can handle the simple task of calculating the square root of a user-posted number, with the purpose of getting started with jsp syntax.
however my question is related to java more in general. : )
the form can of course accept natural numbers and positive decimal numbers but I realized that in my country (as well as in the rest of Europe) we tend to use comma instead of period for representing the decimal separator so more generally people write
this is just the code chunk that does the conversion:

in this way you type with the european standard without problems. my question is: is this an intelligent and elegant approach? could I do better? or it could be better calling an exception everytime you post a comma?

I've got another problem, I was forced to put num.lenght()>1, instead if you post when the field is still blank you get a non-empty string. should I set the default value "" for an input field instead?

thank you in advance. : )
9 years ago

preethi singh wrote:i usually keep my boyfriends name..

me too. I'didn't ever had to change all passwords as my new bf has the same name of the previous one. (this sound a bit "sick", I know. )
9 years ago