Package org.exoplatform.caldav.utils
Class CalendarPalette
java.lang.Object
org.exoplatform.caldav.utils.CalendarPalette
Gives every remote calendar a colour, deterministically.
A port of the browser connector's derivation, arithmetic included, because the colour is what a user recognises a calendar by. Changing it would silently repaint everyone's agenda on the day this ships — the same events, the same calendars, different colours, with nothing to explain it.
The server's own colour wins when it publishes one. Only when it does not is a colour derived, from the collection path rather than from its position in a listing: a calendar added or removed elsewhere must not shift the colours of the others.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringThe colour a calendar is shown in.inStableOrder(List<String> hrefs) The calendars in the order colours are derived from, which is not the order a server happens to list them in.static StringA published colour reduced to the form eXo uses, or null when it is not a colour at all.
-
Method Details
-
inStableOrder
The calendars in the order colours are derived from, which is not the order a server happens to list them in.Sorted by href so that a position is a property of the account rather than of one response: a server free to reorder its listing would otherwise repaint the calendars between two reads.
- Parameters:
hrefs- the collection hrefs- Returns:
- the same hrefs, in a stable order
-
colourOf
The colour a calendar is shown in.- Parameters:
publishedColour- what the server published, possibly absenthref- the collection hrefposition- the calendar's index in the stable ordertotal- how many calendars the account holds- Returns:
- a hex colour that is always usable
-
normalise
A published colour reduced to the form eXo uses, or null when it is not a colour at all.- Parameters:
value- what the server published- Returns:
#RRGGBBupper case, or null
-