calendar colors
This commit is contained in:
@ -129,7 +129,8 @@ public class DoneGateway extends JooqGateway {
|
||||
/**
|
||||
* get all from t_done of the given day
|
||||
*
|
||||
* @param day the day; if null, the current date is used
|
||||
* @param day
|
||||
* the day; if null, the current date is used
|
||||
*
|
||||
* @return a list of found times, an empty one at least
|
||||
*/
|
||||
@ -224,7 +225,8 @@ public class DoneGateway extends JooqGateway {
|
||||
/**
|
||||
* get day summary
|
||||
*
|
||||
* @param day the day
|
||||
* @param day
|
||||
* the day
|
||||
* @return the day summary if found, an empty map otherwise
|
||||
*/
|
||||
public WholeDaySummaryBean getDaySummary(Date day) {
|
||||
@ -262,7 +264,8 @@ public class DoneGateway extends JooqGateway {
|
||||
/**
|
||||
* get all jobs of day
|
||||
*
|
||||
* @param day the day
|
||||
* @param day
|
||||
* the day
|
||||
* @return list of found jobs; an empty list at least
|
||||
*/
|
||||
public List<DailySummaryBean> getAllJobs(Date day) {
|
||||
@ -324,17 +327,16 @@ public class DoneGateway extends JooqGateway {
|
||||
buf.append(jobName);
|
||||
|
||||
FullCalendarEventBean bean = new FullCalendarEventBean(buf.toString(), timeFrom) {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void addExtendedFields(StringBuilder buf) {
|
||||
}
|
||||
};
|
||||
bean.setEnd(timeUntil);
|
||||
bean.setColor("#444444"); // TODO: colors by project name, maybe find a way to determine color by project
|
||||
// name
|
||||
|
||||
bean.setColor(new RgbColor().determineRgbColor(projectName, moduleName, jobName));
|
||||
list.getList().add(bean);
|
||||
}
|
||||
|
||||
return list.toJson();
|
||||
}
|
||||
}
|
||||
|
@ -176,6 +176,10 @@ public class DoneModel implements Model, Serializable {
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public String getDayIso8601() {
|
||||
return day == null ? "" : new SimpleDateFormat("yyyy-MM-dd").format(day);
|
||||
}
|
||||
|
||||
public void setBean(DoneBean bean) {
|
||||
this.bean = bean;
|
||||
}
|
||||
|
@ -0,0 +1,44 @@
|
||||
package de.jottyfan.timetrack.modules.done;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author henkej
|
||||
*
|
||||
*/
|
||||
public class RgbColor {
|
||||
|
||||
/**
|
||||
* find a rgb color code for the combination of the given params
|
||||
*
|
||||
* @param bigInfluence
|
||||
* @param mediumInfluence
|
||||
* @param littleInfluence
|
||||
* @return the hex color code
|
||||
*/
|
||||
public String determineRgbColor(String bigInfluence, String mediumInfluence, String littleInfluence) {
|
||||
int big = bigInfluence == null ? 0 : bigInfluence.hashCode();
|
||||
int med = mediumInfluence == null ? 0 : mediumInfluence.hashCode();
|
||||
int lit = littleInfluence == null ? 0 : littleInfluence.hashCode();
|
||||
|
||||
float bI = (1f / String.valueOf(big).length());
|
||||
float mI = (0.5f / String.valueOf(med).length());
|
||||
float lI = (0.25f / String.valueOf(lit).length());
|
||||
|
||||
float r = 0.0f + bI + mI + lI; // + makes it brighter
|
||||
float g = 0.5f - bI - mI - lI; // - makes it darker
|
||||
float b = 0.5f - bI - mI - lI;
|
||||
|
||||
r = r < 0 ? r * -1 : r;
|
||||
r = r > 1.0f ? 1 / r : r;
|
||||
g = g < 0 ? g * -1 : g;
|
||||
g = g > 1.0f ? 1 / g : g;
|
||||
b = b < 0 ? b * -1 : b;
|
||||
b = b > 1.0f ? 1 / b : b;
|
||||
|
||||
Color c = new Color(r, g, b);
|
||||
return new StringBuilder("rgb(").append(c.getRed()).append(",").append(c.getGreen()).append(",").append(c.getBlue())
|
||||
.append(")").toString();
|
||||
}
|
||||
}
|
@ -72,7 +72,8 @@
|
||||
</b:row>
|
||||
</b:tab>
|
||||
<b:tab title="Zusammenfassung">
|
||||
<b:dataTable value="#{doneModel.allJobs}" var="col" border="false" info="false" paginated="false" searching="false">
|
||||
<b:dataTable value="#{doneModel.allJobs}" var="col" border="false" info="false" paginated="false"
|
||||
searching="false">
|
||||
<b:dataTableColumn label="" value="#{col.projectName}" contentStyle="font-size: 120%" orderable="false" />
|
||||
<b:dataTableColumn label="" value="#{col.moduleName}" contentStyle="font-size: 120%" orderable="false" />
|
||||
<b:dataTableColumn label="" value="#{col.jobName}" contentStyle="font-size: 120%" orderable="false" />
|
||||
@ -85,7 +86,9 @@
|
||||
</p>
|
||||
</b:tab>
|
||||
<b:tab title="Kalender">
|
||||
<b:fullCalendar editable="false" events="#{doneModel.calendarEvents}" height="400" defaultDate="#{doneModel.day}" />
|
||||
<b:fullCalendar editable="false" events="#{doneModel.calendarEvents}" height="600"
|
||||
defaultDate="#{doneModel.dayIso8601}" defaultView="agendaDay" hidden="xs" scrollTime="08:00:00"
|
||||
slotDuration="00:15:00" span="half" allDaySlot="false" lang="de" />
|
||||
</b:tab>
|
||||
</b:tabView>
|
||||
</b:form>
|
||||
|
@ -0,0 +1,23 @@
|
||||
package de.jottyfan.timetrack.moduls.done;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import de.jottyfan.timetrack.modules.done.RgbColor;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author henkej
|
||||
*
|
||||
*/
|
||||
public class TestRgbColor {
|
||||
|
||||
@Test
|
||||
public void testDetermineRgbColor() {
|
||||
RgbColor c = new RgbColor();
|
||||
assertEquals("rgb(146,204,204)", c.determineRgbColor(null, null, null));
|
||||
assertEquals("rgb(61,66,66)", c.determineRgbColor("Ship", "alles", "Mail"));
|
||||
assertEquals("rgb(43,85,85)", c.determineRgbColor("Square", "Entwicklung_Programmierung", "alles"));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user