A California school principal did not violate the freedom of speech of a group of students who wore American flags on their shirts on Cinco de Mayo when he told them to turn the shirts inside out or go home, a federal judge has ruled.

Citing past clashes between Mexican American and Anglo students over their clothing on the Mexican holiday, Chief U.S. District Judge James Ware of San Francisco said school officials "reasonably forecast that (the shirts) could cause a substantial disruption" and were entitled to take steps to prevent it, the San Francisco Chronicle reports.

The case arose in an ethnically charged atmosphere at Live Oak High School in Morgan Hill. On the previous Cinco de Mayo, Ware said, a group of Mexican-American students walked around with a Mexican flag, and a group of Anglo students responded by hoisting a makeshift American flag up a tree, chanting "U-S-A" and exchanging profanities and threats with the Latino youths.

While the Supreme Court has ruled that public school students have the right to engage in nondisruptive free speech, that ruling "does not require that school officials wait until disruption occurs before they act," Ware said in his ruling Tuesday dismissing the students' lawsuit, according to the paper.

Mark Posard, a lawyer for the Morgan Hill Unified School District, said Friday that Ware's decision "affirmed that school safety is paramount."

Bill Becker, a lawyer for the youths and their parents, said they would appeal "this bizarre ruling."

Click to read more on this story from the San Francisco Chronicle.