Do you mean something like this?

I used this
void IrregularGalaxyPositions(StarSystem[] systemTypes) {
Log.write(Log.DEBUG, GalaxyFactory.LOG, "Galaxy Type Irregular");
// make a list from the types of systems so each system can only be selected once
List<StarSystem> sysList = new ArrayList<StarSystem>(Arrays.asList(systemTypes));
int systemsPlaced = 0;
for (int i = 0; i < numSystems; i++) {
Point p = new Point();
int attempts = 0;
while (attempts < MAX_ATTEMPTS_PLACE_SYSTEM) {
attempts++;
int x = (int)(width * rand.nextDouble());
int y = (int)(height * rand.nextDouble());
//possibly round systems down to nearest 10
Log.write(Log.DEBUG, GalaxyFactory.LOG, "... potential position: (" + x + ", " + y + ")");
// convert to point
p = new Point(x,y);
// See if new star is too close to any existing star.
double lowest_dist = distanceToNearestSystem(p, systemsPlaced);
Log.write(Log.DEBUG, GalaxyFactory.LOG, "...... squared distance: " + String.valueOf(lowest_dist));
// If so, we try again or give up.
if (lowest_dist > MIN_SYSTEM_SEPARATION_SQ) {
break;
}
}
// Select star system from list to place
int index = rand.nextInt(sysList.size());
StarSystem s = sysList.remove(index);
s.clearLanes();
s.setLoc(p);
systems.put(p, s);
if( systems.containsKey(p) ) {
Log.write( Log.INFO, GalaxyFactory.LOG, "... added system at (" + p.getX() + ", " + p.getY() + ") after " + attempts + " attempts");
} else {
Log.write( Log.DEBUG, GalaxyFactory.LOG, "... missing system" );
}
systemsPlaced++;
}
Log.write( Log.INFO, GalaxyFactory.LOG, "... placed " + systemsPlaced + " systems");
}
Just eyeballing it there seems to be a logic error where a system will be placed even if it’s too close after attempts are exhausted.
I think I got my code ideas from Free Orion
you could also check out Rementants of the Precursors since they use java and hang around the boards occasionally, but I’m not sure if that project is open source.