Veronique Kus

Ranch Hand
+ Follow
since Jun 13, 2010
Merit badge: grant badges
For More
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 Veronique Kus

OK, solved the string rotation problem! Now there's the most difficult thing left - the dissapearing string... it disappears/appears when I reposition the end points or the control points and I have no idea why.......

The newest version of the string-drawing class with one problem remaining:
13 years ago
OK I made a very minor change to the code thanks to which the second letter of the word on the curve isn't drawn in the same place as the first letter, which was the case in the previous version. However, I still have serious problems with:
a) transforming the string when you invert the start&end point of the curve. The String is still drawn upside down when you drag the right end of the curve to be the left end.
b) the string still disappears randomly during repositioning of the curve.

Oh and the "rotate" parameter which I introduced to the constructor says whether the string should be transformed (but I don't know how) because now the line is going the other way round (as in a) above the code).

I'm really hoping for some help... I'm doing what I can but I am really struggling and this code is an important part of an important project wich I have to hand in very soon :-(
13 years ago
Anyone, pleeeease? This is driving me crazy :-/
13 years ago
I did that and I noticed no difference to be honest... really strange!
EDIT: Now you said that I looked again and turned out my program was using one copy of the class and I was changing a different copy... Let's see what happens when I fix this!
EDIT2: Same thing again... have no idea why this time.
13 years ago
I am trying to implement drawing text along lines, or rather cubic curves. I found this page very useful ("Text along a path" section). However, this code draws text at the beginning of the line. What I need is to draw text at the end of the line. I tried modifying the code given on the website ( and I came up with the below class (my code changes are enclosed in //MY CHANGES (...) //END OF MY CHANGES and most of the comments is my trying to understand this code):

I'm also posting two further classes which, together which the class above form an application which demonstrates what I am trying to achieve and my problem.

This sort of works but there are a couple of problems:
- one or more letters get missing when I reposition the curve
- sometimes the string disappears completely
- when I swap line ends (I move the end of the line to the left of its start), the string is not drawn correctly

I find all this very confusing and it took me ages to even figure out what I have done so far. It is the first time I'm working with the PathIterator and GlyphVector classes and so I am really struggling to understand the content of class which does the work of drawing the string. I would REALLY appreaciate some help with getting this to work correctly... anyone, please?

Also, I wanted to ask why in line 88 of the first class the nextAdvance variable, which seems to me to represent the horizontal advance along the baseline caused by the next charcter in the string, is calculated as:
nextAdvance = glyphVector.getGlyphMetrics( currentChar ).getAdvance() * 0.5f;
Specifically, if glyphVector.getGlyphMetrics( currentChar ).getAdvance() gives us the advance, why are we multiplying it by 0.5f??
13 years ago
OK so I decided to implement it using a simpler method, I create a small rectangle around the click point and test whether any of the cubic curve drawn instersect this rectangle.
13 years ago
I need to implement a function that makes a cubic curve "selected" when the user clicks on it. In order to do that, I need to detect whether the mouse click happened on the cubic curve (or within a very short distance from it). So I need a function which, using pseudo-code would look like this:

if(distance between mouseClick and cubicCurve < 10){
make cubic curve selected
do not select curve

Unlike Line2D, cubic curve does not have a function that would tell the distance between a certain point (e.g. mouse event) and the curve. I was wondering how I could implement this myself? I found this thread. It seems relevant but I don't fully understand what this code does and how it could help me. Can anyone please give me some advice and/or help me with this example code???
13 years ago
Thanks for another solution. Is any of them preferred in terms of performance etc.?
13 years ago
Yes, I tried AffineTransform but the result is the same :-(

Any other suggestions from anyone? If not solution to this particular obstacle, mayb someone has a proposition of a different implementation of the zoom tool?
13 years ago
I want to connect lines to different points lying on an ellipse's border.
Does anyone know how I can calculate the coordinates of the point of intersection between the line going from the center to the corner of the bounding rectangle and the ellipse's border? I mean the 4 points which lie to the north-east, north-west, south-east and south-west of the centre of the ellipse (and on its border).

I am also trying to figure out how to find out the coordinates and dimensions of the biggest rectangle completely enclosed by the given ellipse. I guess solving the first problem above would give me an answer to this one...
13 years ago
I'm trying to implement a zoom function for my application. I use a JComboBox in which the user sets the desired scaling. Before the drawing canvas is (re)painted in its paintComponent() function, i set the scale of the Graphics2D object to the scale set by the user (line 91 in the code below). Everything is drawn according to the scale so this works fine. However, my problem is that the mouse listener gets messed up when the scale is changed. For example, if I set scale to 200%, a mouse click which would normally be interpreted as hapenning at point (100, 100) is now taken to happen at (200, 200)ar.

The below code is a small program which illustrates my problem.

I tried setting the scale of the Graphics2D object back to 1 at the end of paintComponent function but it did not change anything. I would be really grateful for suggestions from solution(s) to my problem. Maybe I'm even approaching this problem in a completely wrong way and I shouldn't use the scaling to implement the zoom???
13 years ago
I've got an application with a Swing GUI and I want it to save some data at a regular time intervals. I've just created a new auto save thread in my application based on the below example code found o the internet:

My question relates to the two last lines (the commented out ones).
ad. 1) The auto save thread is created in the main class called X. This class contains method saveDatabaseToFile() which calls a function located in another class (Y) which saves the state of the database to file. My question is, which of these two methods should be synchronized - the one in class X or the one in class Y?
ad. 2) What does the author mean in here? The function that shuts down the program is located in class X and consists of only two lines:
protected void quit(){
It it enough to just make this function synchronized to (and why is it needed anyway)? What does "synchronized on *SAME* object" mean?

This is the first time I am doing multithreading so I am quite confused. Thank you in advance for any hints.