Les Morgan

Rancher
+ Follow
since Sep 29, 2015
Les likes ...
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
Cows and Likes
Cows
Total received
19
In last 30 days
0
Total given
1
Likes
Total received
131
Received in last 30 days
0
Total given
119
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Les Morgan

Most real problems in programming boil down to live, visibility, and scope.  You are describing the grand problem of visibility.  If you have a controller or main class that launches all other classes and you make a data structure in that class, then when your start your application and instantiate your other objects, you will be able to reference that structure that stores the data you want--in other words all of your object will have visibility of that structure, because they are created in the same scope (class in this case) as the storage structure. Your storage object will then have life during the entire run of your program because your "main controller class" will need to be running during your entire session.

So, make a class, then define a structure to store your data as an instance variable--global variable with respect to your "controller class", and you'll have what you need.
1 month ago
Something biblical interesting too: during Moses' time when the fiery serpents were plaguing them, all someone had to do was look to the icon provided and live, no faith was required, except to look upon the icon provided--many did not and they died.

Tim Holloway wrote:A typo reminded me of something else Biblical. The manna in the desert wasn't harvestable only by those who "deserved" it. It was freely available to all who were willing to harvest it. Or at least persuade someone else to do so.

Consider the Lilies of the Fields...

1 month ago
If your tables are sufficiently small and you don't have much change in the local table, then yes, it is possible.  I've not followed that very closely as the tables I deal with are hundreds of millions of records to billions of records, with change rates that are way too frequent to make a local copy practical.
1 month ago
You can easily make a small Java application that will run locally on the machine you wish to monitor, have it poll the folder(s) you wish  it to monitor, then send an email to the appropriate location.
1 month ago
I use Andriod, Linux, Windows, and PC's.  So I am not really familiar with what you are talking about.  I have one of those new pluggable hybrid BlueDrive cars that doesn't have a CD Player, and it seems to always want to connect to my wife's phone, even though mine is set as the primary.  I  do rather enjoy sitting at he light our on the highway--yes we have the 55 MPH stop lights in our area--and hitting sport mode and seeing that Challenger or Vet just barely starting out as I hit 55 and ease off the accelerator and watching them flip me off as they go zipping by when they catch up.

But then what do I know, I'm a right wing, Christian, gun loving, redneck that also loves the planet and codes like a demon.

PS: I know my batteries in my car negate any real advantage to using the hybrid as far as saving the planet goes, but hey--it's so nice seeing those cars sitting at the light in my rear view mirror, I can be as two faced about it as anyone ;)
1 month ago

vincenzo palazzo wrote:Can you give me an example?

Les Morgan wrote:You can create shadow on any color by subtracting from the individual Red Green and Blue shades.

1 -- get the RGB value of the color you wish to shade...
2 -- break the values into Red, Green, and Blue...
3 -- subtract an appropriate vlue for shading that you desire
4 -- make sure all RGB values are 0 or greater
5 -- reintegrate the RGB values back into the custom color
6 -- use the custom color for your shading.



Sorry for the long time in responding, but there is basically a demo of the method I was talking about before

Creates a JFrame and slowly fades the backround from orange to black
Demonstrates how to shade any color

2 months ago
You can create shadow on any color by subtracting from the individual Red Green and Blue shades.

1 -- get the RGB value of the color you wish to shade...
2 -- break the values into Red, Green, and Blue...
3 -- subtract an appropriate vlue for shading that you desire
4 -- make sure all RGB values are 0 or greater
5 -- reintegrate the RGB values back into the custom color
6 -- use the custom color for your shading.
2 months ago
Rich,

Somewhere you have a grid of what goes where and what is adjacent to what.  You build routines off of that to do what I was talking about in the previous post:

say you have a 100x100 world--grid for your maps (images).

You are at (7, 9) and you move to (6, 10):

you have loaded (7, 9) and (6, 8), (6, 9), (6, 10), (7, 8), (7, 10), (8, 8), (8, 9), and (8, 10)--you always have 9 images in memory that are valid.

when you move to (6, 10) you'll need (5, 9), (5, 10), (5, 11), (6, 9), (6, 11), (7, 9), (7, 10),  and (7, 11)

you keep the intersection of the first set and second set, and invalidate the the exclusions from the intersection.

Then you load the exclusions from the intersection of the second set with the rist set.

This scheme is fairly simple to implement, and it makes it so the memory for your images is very managable too.
2 months ago
Rich,

Sounds like you are running into an expansion problem.  Your images in memory take rowCount x columnCount x ColorDepth(in bytes) bytes of memory to store.  While your png's, which are highly compressed, make a small file size, they can take a lot of space in memory.

Total up the expanded sizes and see how big they really are.

You may need to opt for partial loading, by loading the grid square you are playing and the adjacent ones, then when you move to a different square, dispose of the no longer adjacent images so they can be gc'd and load the new images in a seperate thread.

Les
2 months ago
Mary,

I have not put this in my NetBeans and took it for a spin, but one of the first things that I notice is that everything is static.  The next thing I notice is:



At the point you initialize st, br is not guaranteed to have anything to read.

Les
2 months ago
looks like you have a pretty good solution there just by order the rules by the index, 2nd to last digit of rules.
3 months ago
posted this over at Oracle yesterday

From the Java Tutorial on "Concurrency" in the "Immutable Objects" section, this statement is given:

"The impact of object creation is often overestimated, and can be offset by some of the efficiencies associated with immutable objects. These include decreased overhead due to garbage collection, and the elimination of code needed to protect mutable objects from corruption."

I completely see "elimination of code needed to protect mutable objects from corruption", but could someone explain to me what is meant by "decreased overhead due to garbage collection"?

With an immutable object garbage collection need is always increased because anytime you need to have change you are forced to create a new object.  I see this all the time in new programmers using String, since String is an immutable object, every time a "change" is made to the String, what is really happening is that they are getting a new String object and the old is being deferenced and available for garbage collection.  This can add significant overhead if care is not taken to eliminate the creation of the new objects.

Les

BTW: nice example there on using "final" to create an immutable instance.
4 months ago
Hari,

Yes, the name of the game is to get the objects to exist, not just have null references, however you initialize it.

Les

Hari Nagarjuna wrote:

Campbell Ritchie wrote:

Les Morgan wrote:. . . If we type int[3] what we have created is a reference that will point to 3 integers, but it is still only the variable that will reference the ints, we have not constructed an array yet--just a referencing scheme. . . .

Can you write int[3] as a type? I thought you can only use the number on the right of the assignment operator:

. . . you typed in a literal array/collection of ints. . . .

That is called an array initialiser. Unlike writing new int[3], which creates an array filled with 0s/nulls/falses, an initialiser creates an array filled with the actual values desired. Code like...both declares the reference and creates the array object in one line.



Thanks for your reply.
So there is no special purpose in using

apart from initializing the array elements to 0's/null's/false's?
as object can be created directly using

4 months ago
Campbell,
You are quite correct, just remembering this and that and mixing it into the wrong context again--multiple languages is not always a blessing
Les

Campbell Ritchie wrote:Can you write int[3] as a type? I thought you can only use the number on the right of the assignment operator:

. . . you typed in a literal array/collection of ints. . . .

4 months ago
Hari,

In your example:

the array is created, by you, in that, you typed in a literal array/collection of ints.  You used the Java defined syntax to do so {1, 2, 3}, the curly braces in this case tells Java there is an array coming and the literals within are the it.  You already made the object--the variable "num" is just assigned the reference to it.

Les

Hari Nagarjuna wrote:

Les Morgan wrote:Hari,

I am not sure I understand completely what you are asking, but let me see if I am getting a piece of what you are saying.

When we "create an array" in Java and many other languages, I think what you are referring to is the left side of the expression: int[] in the case we wish to build an integer array.  When we type int[], there is no array created, but instead what we have made is a reference that will be set to reference an array object.  If we type int[3] what we have created is a reference that will point to 3 integers, but it is still only the variable that will reference the ints, we have not constructed an array yet--just a referencing scheme.



Yes this is exactly where I am confused.
in
I have just created a reference.
But I have not created an actual array object using

which should create create integer array object of required space in which we can give our input.
But in

There is no array object created .Reference just points to the object created and will not store any data given by us.
So where integers 1,2,3 stored since there is no object created.


4 months ago