Janus Engstrøm

Ranch Hand
+ Follow
since Nov 01, 2006
Copenhagen, Denmark
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Janus Engstrøm

Solved!

Some more browsing took me to this place: http://www.codercorp.com/blog/spring/security-spring/configuring-spring-security.html

Excellent information, just what I was looking for: A way to customize the the User object being used by Spring Security to authorize access to the resources.

A brief walk through:

1) Define a data source:

2) Define bean for the customized UserDetailService:

3) In the spring security xml file, use the customized UserDetailService as the new authentication provider:

4) MyUserDetailsService:

5) And MyUser:



/janus
8 years ago
Hello all,

New to Spring and Spring Security.

I'm learning by doing (and googling alot!), but I can't find a solution to this problem:

As far as I can see, the chain of event are as follows:

1) UserBean is instantiated by Spring as it's defined as a bean in the web.xml file.
2) The user is presented with my login page
3) User authenticates himself
4) User is redirected to "page1.xhtml" in a secured area if 3) is successful

I would like to do a post-login initialization of the UserBean, as I would like to fetch user info (name, address, etc.) from a database. But I only want this to happen once, since that data of course only should be loaded once, so it should be like 3.5) in the chain of events.

Until now, I'm thinking of these solutions:

1) After login, the user to redirected to a pre-home screen, where the UserBean post-login initialization is handled and then redirected to "page1.xhtml" afterwards.

2) In the "page1.xhtml", I have the following code:

- and then I could do the data base stuff in the getUserName() in UserBean (and handle the one-time-only requirement by a isPostLoginInitialized boolean value)

3) Using the example posted here: http://stackoverflow.com/questions/2579431/spring-security-call-method-after-authentication ... but can't find a jar containing SpringSecurityFilter.


Can anyone help me out here? How to do this? I'm guessing it's a quite ordinary task, so perhaps I've just googled with the incorrect keywords.


Best regards,
Janus
8 years ago
Thanks for your reply, Mike.

I would really prefer not to change the metadata directly in the .PNGs, so if nothing else works I would go that way.

But I've found the solution (yeah!) and the name of the solution is JAI:




Best regards,

Janus
8 years ago
Hi all,

I have some graphs which I've rendered into some BufferedImages. These images are now going to be saved to disk as .PNG files as they must be loss less in the quality of the graphs. These files are to be used for publishing in various magazines, and these magazines have a requirement that the images must have a DPI of 600. Unfortunately, Windows saves with a DPI of 96, so I have to change this meta data.

I've spent the whole day on Google, trying to figure out what to do. The best post regarding the topic seems to be this one: http://www.tracemodeler.com/articles/aging-bugs-and-setting-dpi-with-java-image-io/
-but the author doesn't really post the answer, he mainly outlines the problems.

I've gotten it to work for JPG's:



-but I can't use JPG's due to its limitations in regards to graphs, charts, etc.

As far as I can see, I need to change the meta data for the PNG files to set the DPI values, but first of all I can't find the value in the Tree as the page at tracemodeler.com talks about ... and next I can't really see how to make changes in the Nodes of this Tree. Please see below.




All very confusing, reading this post is probably confusing as well... but, please, is there anyone out there who knows what to do here? How do I change the DPI value of a PNG image within Java?


Best regards,

Janus
8 years ago
Well, you already have the first loop ... you only need to insert another loop in the body of the first.
This loop inside another loop is also known as a nested loop, so try to see if you can get some info using that keyword in a google search... at least I found some decent info.

Kind regards,
Janus
9 years ago
Regarding your syntax, it's a good idea to end what you've started before beginning something new:

First:



Then add the stuff in the belly of your do-while loop...



(or use an IDE that handles this bracketing for you...)


Kind regards,
Janus
9 years ago
I'm thinking it would be a good idea for you to try to do some pseudo-code programming. As far as I can see, you're not that far away from the goal.
You have already described the flow of the program, or at least your teacher has.

Perhaps I should get you started with some high level pseudo-code:

Iterate over your values[] array and find the index of the largest value (maxValueIndex).
Use values[maxValueIndex] to figure out what value to multiply by, resulting in the values[maxValueIndex] = maxLength.
Multiply all your array values by that value.
Now your array contains values which are directly usable by the drawHor() method.
Now do that double looping described by your teacher in 3)


Kind regards,
Janus
9 years ago
Thanks for the replies,

It's true that 0.0001d.toString() is even worse, but fortunately I don't need that kind of precision

The "problem" could very well be caused by the binary fractions and exponents used in the representation of the double value. But if that is so, why did it end up with a trailing zero, which doesn't (at least in my - somewhat ignorant - perception of mathematics) add any lesser or greater precision to 0.001? I could understand if the 0.001 value ended up being something like 0.001+delta where delta was a very small fraction. Oh well, let's not spend too much time on this, I'm aware of the imprecision of the double values, was just curious about the "exciting" String representation.


Best regards,
Janus
9 years ago
Hi ranchers,

A little puzzled by this:

new Double(1).toString() produces 1.0
new Double(0.1).toString() produces 0.1
new Double(0.01).toString() produces 0.01
new Double(0.001).toString() produces 0.0010

-to which I totally agree ... except the last representation. Why has the String representation of 0.001 an extra trailing zero? I cannot find the answer to this in the API to Double.toString().

I'm using all the values listed above in a JComboBox, so I would prefer a "0.001" representation instead as it looks better. I know I can use Strings instead and then use the Double.parseDouble(String s) method to get the value, I'm only asking this question because I'm a little puzzled


With kind regards,
Janus
9 years ago
Hi Rob,

Isn't that way described by you just one of several ways to handle tool tips for JTables?

Well, I've tried it, it produces the same result: If tool tips are equal, the location of the popup doesn't change.


This doesn't work correctly:




This does work correctly:



Perhaps it's a performance feature implemented in the ToolTipManager .. ?


Regards,
Janus
9 years ago

Janus Engstrøm wrote:
Actually, using setToolTipText(null) doesn't do any difference. The problem is the same whether or not is is called. The tool tips still appear even when using the null-value.
Since it didn't do anything, I removed it again.



Actually, it does do something: If the text is empty ("") in the setToolTipText, it shows a small square as the tool tip, which I presume is the border around the label for the tooltip. By setting the toolTipText to null, that square disappears.

9 years ago
Hi Rob,

Actually, using setToolTipText(null) doesn't do any difference. The problem is the same whether or not is is called. The tool tips still appear even when using the null-value.
Since it didn't do anything, I removed it again.

Problem still persists: If 2 consecutive rows has the same tool tip, the ToolTipMananger doesn't update the tool tip popup. It remains in the same place when mouse cursor is moved to another row (having the same tool tip), just as the example quite nicely shows.

Kind regards,
Janus
9 years ago
Hi Ilo,

First of all:
You don't need line 27, as pane already is your contentPane and app is added to that in line 21. Since pane is your contentPane you don't need to change that as you do in line 52.

Try to see here:


As you can see, I remove app from the contentPane, add et.getGui() to it and force a repaint of the contentPane.

Now to your problem:
The size of the panel taken from Anotherclass hasn't been set. True, you just add the app to the conentPane of the JFrame and app is shown in the correct size, but that is because of line 60. Your app is Anotherclass hasn't been shown so it doesn't have an adjusted size, it is 0 by 0 pixels. In the example above I also call pane.toLayout() to force a re-layout of the components added to the pane, in this case the et.getGui()-panel. This results in the et.getGui()-panel being resized according to it's parent container's size.


Hope this clarifies a little.

Kind regards,
Janus
9 years ago
Hi fellow ranchers,

I've stumbled across yet another small annoyance, this time when using ToolTips.
Say you have a JTable with ToolTipText enabled for a specific column. The text for the ToolTip for that column is the same, say "Click for combobox". When hoovering over first row in that column the tool tip appears correctly, but when moving the mouse cursor any of the following rows in same column, the tool tip doesn't follow the cursor.

An example is here. Try to hoover on elements in the "Sport"-column.

When the tool tips aren't the same (as is toolTip_rowA.equals(toolTip_rowB) ) the location of the tool tip popup is updated correctly.

I've tried the following to force this update:


-but that doesn't work.

Anyone with a good idea to how to force the popup to move, when cursor is moved onto another row with same tool tip as the previous?


With kind regards,
Janus
9 years ago