Tian Zhang

Greenhorn
+ Follow
since Mar 23, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Tian Zhang

Hello Piet,

The size of the rectangle seems to be irrelevant, and the misalignment does not happen with stroke width > 1. Furthermore the misalignment goes away after resizing the JFrame too...

I've distilled the code down to the following:



Strangely enough, the code renders fine with jdk1.7.0_67 (see attachment) and the misalignment only seems to happen with jdk1.8.0_20 (see attachment).

(You may need to zoom into the images to see the pixel that's sticking out)

Tian


10 years ago
Hi there!

I am just getting started with Java2D (more accurately, "restarted" after an 8 year break from Java ) and have hit an interesting behaviour when playing with Java2D. Here is the code in question:



The code above should draw an rectangle when the Render is added to a JFrame, however ends up drawing a square with with the bottom edge misaligned (see attachment).

The issue goes away if I force BasicStroke(1.1f), however feel that this is a bit of a hack.

Why does the miss-alignment happen and what is the "best practise fix" for this?


Thanks!
Tian
10 years ago
hello!

thanks for your suggestion, but the problem in my case is not related to the graphics acceleration! i've disabled my mouse driver and confirmed my suspecions. indeed it seems that my synpatics touch pad (version 7.xx) seems to have been the culprit. after reinstalling an ealier version the problems seems to be gone away.


thanks,
tian.
18 years ago
hello!

i've been experiencing some problems with JRE 1.5.0_08-b3. the graphics behind the mouse cursor seems to be corrupted when the mouse passes over. i have a screenshot at: http://tzhang.co.uk/Untitled.gif

does anyone have any explanation as to why this happens and a possible fix/work around?

this doesnt happen with intellij 5 which uses it's own JRE 1.5.0_07-b3.

there is a similar report on: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4915049 but this refers to JRE 1.2.x and i dont have to click my mouse to corrupt the graphics.

(i dont suppose this could be a mouse driver problem?)
thanks,
tian
18 years ago
hi there!

the code will be something like:


which will draw pixel at (x, y) so i guess it is length zero (length:=sqrt((x1 - x2)^2 + (y1 - y2)^2) - as defined by the eucledian metric).

tian
[ September 21, 2006: Message edited by: Tian Zhang ]
18 years ago
thanks,

i had feared as much. perhaps the overhead of drawing length 1 lines isnt as bad as i thought.


tian
18 years ago
thanks for your reply!

i currently have what you suggested in my code - but ommitted them from the code listing for simplicity. is there a method in the Graphics class to paint individual pixels, or will i need to paint lines with length 1?

tian
18 years ago
hi there!

i have a class that extends JFrame, i was wondering if it is possible to set (draw) individual pixels within the frame, i.e. something that looks like:



at the moment i'm considering (which is probably inefficient):




thanks,
tian.
18 years ago
hi there!

i have a class that extends JFrame, i was wondering if it is possible to set (draw) individual pixels within the frame, i.e. something that looks like:



at the moment i'm considering (which is probably inefficient):




thanks,
tian.
18 years ago
thanks!

i half suspected as much
18 years ago
hi there!

i would like to send objects over sockets, but would like to be able to determine the size of the serialized object so i can provide an estimate of how long it would take to send. i understand that there is no "straight forward" way of determining the size of an object, but is there a way of finding how big the serialized object without having to write it to file, and then looking at how big the file is? - this would complicate matters as the objects may contain sensative data.

thanks,
tian
18 years ago
hi there!

just a quick question, i have two classes as follows:



and the later on else where in a different class i have



unfortunatly the instance of display does not show the two rectangles... could you tell me where i'm going wrong?

thanks,
19 years ago
hello there!

i was wondering if someone could point me to a paper on how to implement banded matricies in java (or any other language for that matter, preferably not too syntatically different).

i will use the banded matrix to store adjacency data for a graph for a 3rd year joint comp. science and maths degree. the nodes in the graph are likely to be "locally" connected (i.e. clusters).

at the moment i am using a triangular-come-symmetric matrix, however this is not the most efficient.

thanks,
tian
19 years ago
hello,

thanks for the link, though unfortunatly i didnt find it that useful i'm sure it will be useful to others!

i've ended up with some ugly casting as googling: generic arrays by luck landed me on page that comfirmed what i had suspected in the first post.

thanks,
tian
19 years ago
hello!

could someone suggest what a solution for the following code would be?



at the moment i have to up cast everything to Object as the above is illegal:


this creates a problem as if i wanted to iterate through the array using the new syntax:



becomes illegal.

thanks,
tian
19 years ago