comp.lang.java.programmer
http://groups-beta.google.com/group/comp.lang.java.programmer
[EMAIL PROTECTED]

Today's topics:

* Try addressing people and posts... - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/519011440b614d43
* simple Date comparing, how to - 2 messages, 2 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9573a5412367c034
* Countdown thread resume problem - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bf9c85ee37bd60d6
* rotating a bufferedimage - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6e18a900237f6c17
* choosing random item from set with weighted probability - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/da98e83f7a2c858b
* Anti-aliasing GIF Images - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2cc5fef6d79db9b7
* reflection: noSuchMethodException - 3 messages, 2 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/629115419613f9ce
* applet frame - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d40e37cd133f4dd9
* adding jars to classpath on runtime without -cp option - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e98c253d97fad483

==============================================================================
TOPIC: Try addressing people and posts...
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/519011440b614d43
==============================================================================

== 1 of 1 ==
Date: Sun, Nov 28 2004 8:17 pm
From: Steve Sobol  

John Bailo wrote:

> I did that, because somewhere way back in these threads, I posted the 
> code for doing a benchmark of starting and stopping 2000 threads.

Yeah, you're not the one I have a problem with. :)

-- 
JustThe.net Internet & New Media Services, http://JustThe.net/
Steven J. Sobol, Geek In Charge / 888.480.4NET (4638) / [EMAIL PROTECTED]
PGP Key available from your friendly local key server (0xE3AE35ED)
Apple Valley, California     Nothing scares me anymore. I have three kids.




==============================================================================
TOPIC: simple Date comparing, how to
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9573a5412367c034
==============================================================================

== 1 of 2 ==
Date: Mon, Nov 29 2004 5:16 am
From: "John B. Matthews"  

In article <[EMAIL PROTECTED]>, "HS1" <[EMAIL PROTECTED]> 
wrote:

> Hello
> 
> I want to compare two dates.
> 
> One date is from a database in the form of yyyy-mm-dd (such as 2004-11-29).
> I know this because I print the date using the function:
> 
>     System.out.println(databaseDate.toString());

Maybe, maybe not. Your databaseDate probably has a time component 
buried in there somewhere; it may be set to midnight. You should 
also check what year is actually stored in the database.

> Now I want to use the funtion "before" for comparing myDate and
> databaseDate. So I create a new Date
> 
>    Date myDate = new Date(2004, 11, 23);

This constructor for a java.util.Date is deprecated. If you use it 
anyway, note that "2004" specifies the year 3904 and "11" specifies 
the month December. Consider an instance of GregorianCalendar 
instead.

> And then I use the function myDate.before(databaseDate) to compare them.
> 
>    if (myDate.before(databaseDate))
>      ...... do something.....
> 
> 
> However, this fuction did not work.

No, the expression "myDate.before(databaseDate)" evaluates to false, 
as expected.

> I check myDate using myDate.toString(), got:
> 
>    Fri Dec 23 00:00:00

As midnight of 23-Dec-3904 is not before anytime on 29-Nov-2004, 
your code _does_ work.

> It can be seen that myDate and databaseDate are in different format.
> 
> Could you please help how to compare them

Just initialize myDate with a date (and time) before 29-Nov-2004 at 
whatever time is stored with that date in your database.

[...]
-- 
John
jmatthews at wright dot edu
www dot wright dot edu/~john.matthews/



== 2 of 2 ==
Date: Mon, Nov 29 2004 5:21 am
From: "John McGrath"  

On 11/28/2004 at 7:37:25 PM, HS1 wrote:

> One date is from a database in the form of yyyy-mm-dd (such as
> 2004-11-29).  I know this because I print the date using the function:
> 
>     System.out.println(databaseDate.toString());

What you are printing is the output from the toString() method, which has
nothing to do with how the data value is stored.

I am guessing that your databaseDate is of type java.sql.Date, although
you did not show anything to verify this.  If that is the case, the value
is stored as the number of milliseconds since 1-Jan-1970 12:00 AM UTC.

>    if (myDate.before(databaseDate))
>      ...... do something.....
> 
> 
> However, this fuction did not work.

It should, unless my assumption above is incorrect.

> I check myDate using myDate.toString(), got:
> 
>    Fri Dec 23 00:00:00
> 
> It can be seen that myDate and databaseDate are in different format.

No.  They just return different formats from the toString() method.
Internally, they are identical.

-- 
Regards,

John McGrath




==============================================================================
TOPIC: Countdown thread resume problem
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bf9c85ee37bd60d6
==============================================================================

== 1 of 1 ==
Date: Mon, Nov 29 2004 5:22 am
From: Andrew Thompson  

On 28 Nov 2004 20:39:49 -0800, [EMAIL PROTECTED] wrote:

> When I press 'Stop', the display of countdown time is indeed paused, ...

Not on my box it didn't.  Clicking the button had no effect,
the countdown continued on it's merry way.

> I really apologize for the length of this message, but I really can't
> figure this one out. 

This could have been an SSCCE[1] if you had..

1) Ensured all lines were under 72 chars (line wrap breaks code).
2) Put the imports at the top.
3) Made TFrame public and the other classes default
4) Trimmed about 200 lines from it.

Please do so in future.

[1] <http://www.physci.org/codes/sscce.jsp>

-- 
Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane




==============================================================================
TOPIC: rotating a bufferedimage
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6e18a900237f6c17
==============================================================================

== 1 of 1 ==
Date: Mon, Nov 29 2004 5:38 am
From: "John McGrath"  

On 11/28/2004 at 7:28:39 PM, e4_java wrote:

> public class object

<shudder>

> the image shows up, but rotate doesn't work

First, I should point out that you do not call your rotate() method
anywhere in the code that you posted.

>       public void rotate(double angleIncrease)
>       {
>               angle += angleIncrease;
> 
>               Graphics2D g2 = bi.createGraphics();
>               g2.rotate( Math.toRadians( angleIncrease ) ); 
>              // this should rotate the image stored in bi
>       
>               // ensure angle is between 0 and 360
>               if(angle > 360) angle-=360;
>               if(angle < 0) angle+=360;
>       }

Calling Graphics.rotate() will not have any effect on the image that the
Graphics context was created from (assuming that it actually *was* created
from an image).  What it affects is how subsequent paint operations
performed using the Graphics context will be interpreted.

Also note that BufferedImage.createGraphics() creates a new Graphics
context, so doing a rotate() on one Graphics context will have no effect
on painting done with a different Graphics object, even if they were
created from the same BufferedImage.

-- 
Regards,

John McGrath




==============================================================================
TOPIC: choosing random item from set with weighted probability
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/da98e83f7a2c858b
==============================================================================

== 1 of 1 ==
Date: Sun, Nov 28 2004 9:57 pm
From: marcus  

Well, if I wanted to do a quick and dirty method I would read each 
letter into a vector, get a random int limit vector.size(), and wally. 
Vallah.  wallagh.  how do you spell it?

Anyhow, you could initialize your vector any way you wanted, the point 
being you have a vector that is a real-world expression of your letter 
ratios so getting a proportionally probable output is, ahem, 
non-problematic.

Digital Puer wrote:
> I have an algorithmic question (not necessarily tied to Java).
> 
> Suppose I have the text from a newspaper and want to choose
> a letter from the text with proportional probability. For example,
> if the letter 'e' occurs, say, 50 times out of a text of 150
> characters, then 'e' will be chosen with probability 1/3. 
> 
> What is the best way to code this? I could set up an if-elseif ladder
> like this:
> 
> x = random number [1 to total number of letters]
> if (1 < x <= 10) /* 10, for example, because 'a' occurred 10 times */
>   choose 'a'
> else if (10 < x <= 14) /* because 'b' occurred 4 times */
>   choose 'b'
> 
> This seems extremely tedious. Is there a better way?





==============================================================================
TOPIC: Anti-aliasing GIF Images
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2cc5fef6d79db9b7
==============================================================================

== 1 of 1 ==
Date: Sun, Nov 28 2004 9:46 pm
From: marcus  

One time in ancient history I played with partial transparency in an 
image in an applet.  It will take some digging to find the info, but 
what I did was grab the graphics of the image and changed the 
transparency byte of each pixel to (255/2) or whatever.  This allows the 
pixel to blend with the background.  Might be easier to make the outside 
edge of your image partially transparent than to learn the hardcore 
techniques game designers use.

I gave up and created 16 rotated versions of my image, saved them all as 
gifs, and loaded them into an array.  The thing about antialiasing this 
way is it blends the image with a fixed background color, and looks 
worse if you change the background later.

Kevin Bertman wrote:
> I have created a Java Dodgems game at
> http://www.kevinbertman.co.uk/japan/dodgemsRules.shtml
> 
> Each dodgem is a gif image. Since the applet often rotates each
> dodgem, is there a way that I can use anti-aliasing to reduce the
> jagged edges? Or can anti-aliasing only be applied to things 'drawn'
> like drawLine, fillRect, or drawString?





==============================================================================
TOPIC: reflection: noSuchMethodException
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/629115419613f9ce
==============================================================================

== 1 of 3 ==
Date: Mon, Nov 29 2004 6:08 am
From: Andrew Thompson  

On Mon, 29 Nov 2004 01:51:56 +0100, Matthijs Blaasthijs_blaas wrote:

> I try to invoke a method (setIgnoreRepaint) only if it's available on the 
> used JVM through reflection. Problem is that it throws me a 
> java.lang.NoSuchMethodException: 
> java.awt.Component.setIgnoreRepaint(java.lang.Boolean) exception even on 
> JVM's where it is available... I cant figure out what im doing wrong.

You are using Boolean, rather than boolean.

<sscce>
import java.applet.*;
import java.lang.reflect.Method;

public class Refl extends Applet {

  public void start() {
    try {
      Class ob = Class.forName("java.awt.Component");
      Method method = ob.getMethod("getComponentAt",
        new Class[]{Class.forName("java.awt.Point")} );

      ob = Class.forName("java.awt.Component");
      method = ob.getMethod("setIgnoreRepaint",
        new Class[]{Class.forName("java.lang.Boolean")} );
    }
    catch(Exception e) {
       e.printStackTrace();
    }
  }
}
</sscce>

As to how you represent a boolean in such cases, that is 
left as an exercise for the OP.  (No, I have no idea.)

-- 
Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane



== 2 of 3 ==
Date: Mon, Nov 29 2004 6:26 am
From: "Murray"  


"Andrew Thompson" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

>
> As to how you represent a boolean in such cases, that is
> left as an exercise for the OP.  (No, I have no idea.)
Class booleanPrimitive = Boolean.TYPE;





== 3 of 3 ==
Date: Mon, Nov 29 2004 6:39 am
From: Andrew Thompson  

On Mon, 29 Nov 2004 06:26:51 GMT, Murray wrote:

> "Andrew Thompson" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
..
>> As to how you represent a boolean in such cases, that is
>> left as an exercise for the OP.  (No, I have no idea.)

> Class booleanPrimitive = Boolean.TYPE;

Yep, that's it.  That works here just fine.

-- 
Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane




==============================================================================
TOPIC: applet frame
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d40e37cd133f4dd9
==============================================================================

== 1 of 1 ==
Date: Mon, Nov 29 2004 6:21 am
From: Andrew Thompson  

On Mon, 29 Nov 2004 01:46:15 +0100, Matthijs Blaasthijs_blaas wrote:

> Im expiriencing weird behaviour with JRE1.5 and a applet frame I'm using. On 
> Jre's <1.5 it works ok, but with the JRE1.5 the applet window will lose 
> focus imediatly after it pops up...

I have less experience with frames launched from applets, but I 
*suspect* that it is foolhardy to depend on *any* 'default' behaviour.
<http://groups.google.com/[EMAIL PROTECTED]>

You might try using setAlwaysOnTop (1.5+), or starting a thread
that brings the Frame to front every nn milliseconds.

BTW.  A better group for such matters is..
<http://www.physci.org/codes/javafaq.jsp#cljg>

HTH

-- 
Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane




==============================================================================
TOPIC: adding jars to classpath on runtime without -cp option
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e98c253d97fad483
==============================================================================

== 1 of 1 ==
Date: Mon, Nov 29 2004 12:07 am
From: Andrew Thompson  

On 28 Nov 2004 23:28:22 -0800, rony wrote:

> I want the VM machine to find those classes the user use. I know
> how to load class that I know it's name in advance.

Do a File.list() on the directory.  Present the user with a JList
of jars if more than one is found.  Get the enumeration of the
ZipEntries from the selected Jar and them's your classes.

-- 
Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane



==============================================================================

You received this message because you are subscribed to the Google
Groups "comp.lang.java.programmer" group.

To post to this group, send email to [EMAIL PROTECTED] or
visit http://groups-beta.google.com/group/comp.lang.java.programmer

To unsubscribe from this group, send email to
[EMAIL PROTECTED]

To change the way you get mail from this group, visit:
http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe

To report abuse, send email explaining the problem to [EMAIL PROTECTED]

==============================================================================
Google Groups: http://groups-beta.google.com 

Reply via email to