Ever since he was a teenager in Queens, Darius McCollum has been in trouble with the law, always for stealing subway trains and buses. 

He's been arrested more than 30 times for taking them on joy rides.

Now 53 years old, he was in Brooklyn Supreme Court on Friday, hoping a judge would give him a measure of freedom and let him live in a supervised group home. Instead, he was committed to a secure adult psychiatric center.

Brooklyn Supreme Court Justice Ruth Shillingford, who would not agree to be seen by on camera, sided with prosecutors who argued that that McCollum is "dangerously mentally ill."

His attorney, Sally Butler, said she will appeal. 

“Not a good day for justice," Butler said. "Not a good day for people who are on the spectrum."

McCollum was last arrested in 2015 for stealing an empty Greyhound bus from the Port Authority terminal. 

In January, he pleaded not responsible by reason of mental disease or defect.

After being held at the Kirby Psychiatric Hospital on Wards Island and on Rikers Island, he was was hoping for outpatient treatment, but prosecutors would have none of it.

McCollum has been obsessed with transit since he was a child. He estimates he's stolen more than 1,000 buses and more than 5,000 subway and commuter rail trains, often by impersonating motormen or bus drivers.

He has been diagnosed with Asperger's Syndrome, a form of autism.

His lawyer argued he's not a threat and should not be considered dangerous.

"We just lock people up that are nonviolent, that are different than other people, that could be treated in a setting in the community and do really well," Butler said.

The judge expressed hope that there's "real potential for progress" if McCollum gets the proper treatment, but his lawyer shot that down, saying he won't be getting it where he's headed.

"The right thing would have been for him to have gotten treatment in a community, in a facility with other peple of like issues, rather than being in a facility with people that have murdered," Butler said. "I'm sorry. I'm overwhelmed. I'm so disappointed."

McCollum's next stop is the Mid-Hudson Forensic Psychiatric Center in Orange County.