Search in sources :

Example 1 with CategoryProperties

use of org.activityinfo.shared.report.model.CategoryProperties in project activityinfo by bedatadriven.

the class ReportJsonFactory method decodeCategories.

public Map<DimensionCategory, CategoryProperties> decodeCategories(JsonElement categories) {
    Map<DimensionCategory, CategoryProperties> cats = new HashMap<DimensionCategory, CategoryProperties>();
    JsonArray jsonCats = (JsonArray) parser.parse(categories.getAsString());
    Iterator<JsonElement> it = jsonCats.iterator();
    while (it.hasNext()) {
        it.next().getAsJsonObject();
    }
    return cats;
}
Also used : DimensionCategory(org.activityinfo.shared.report.content.DimensionCategory) JsonArray(com.google.gson.JsonArray) CategoryProperties(org.activityinfo.shared.report.model.CategoryProperties) HashMap(java.util.HashMap) JsonElement(com.google.gson.JsonElement)

Example 2 with CategoryProperties

use of org.activityinfo.shared.report.model.CategoryProperties in project activityinfo by bedatadriven.

the class ReportJsonFactory method encodeCategories.

public JsonArray encodeCategories(Map<DimensionCategory, CategoryProperties> categories) {
    JsonArray jsonCats = new JsonArray();
    for (Entry<DimensionCategory, CategoryProperties> entry : categories.entrySet()) {
        JsonObject jsonEntry = new JsonObject();
        jsonEntry.addProperty("dimensionCategory", entry.getKey().toString());
        jsonEntry.addProperty("categoryProperties", entry.getValue().toString());
        jsonCats.add(jsonEntry);
    }
    return jsonCats;
}
Also used : JsonArray(com.google.gson.JsonArray) DimensionCategory(org.activityinfo.shared.report.content.DimensionCategory) CategoryProperties(org.activityinfo.shared.report.model.CategoryProperties) JsonObject(com.google.gson.JsonObject)

Example 3 with CategoryProperties

use of org.activityinfo.shared.report.model.CategoryProperties in project activityinfo by bedatadriven.

the class ChartRendererJC method computePaints.

private Paint[] computePaints(List<PivotTableData.Axis> categories) {
    Paint[] paints = getDefaultPaints(categories.size());
    Dimension dim = categories.get(0).getDimension();
    if (dim == null) {
        return paints;
    }
    for (int i = 0; i != categories.size(); ++i) {
        CategoryProperties props = dim.getCategories().get(categories.get(i).getCategory());
        if (props != null && props.getColor() != null) {
            paints[i] = new Color(props.getColor());
        }
    }
    return paints;
}
Also used : CategoryProperties(org.activityinfo.shared.report.model.CategoryProperties) Color(com.google.code.appengine.awt.Color) Paint(com.google.code.appengine.awt.Paint) Dimension(org.activityinfo.shared.report.model.Dimension) Paint(com.google.code.appengine.awt.Paint)

Example 4 with CategoryProperties

use of org.activityinfo.shared.report.model.CategoryProperties in project activityinfo by bedatadriven.

the class DimensionAdapter method unmarshal.

@Override
public Dimension unmarshal(DimensionElement element) {
    Dimension dim = createDim(element);
    for (CategoryElement category : element.categories) {
        CategoryProperties props = new CategoryProperties();
        props.setLabel(category.label);
        if (category.color != null) {
            props.setColor(decodeColor(category.color));
        }
        EntityCategory entityCategory = new EntityCategory(Integer.parseInt(category.name));
        dim.getCategories().put(entityCategory, props);
        dim.getOrdering().add(entityCategory);
    }
    return dim;
}
Also used : CategoryProperties(org.activityinfo.shared.report.model.CategoryProperties) Dimension(org.activityinfo.shared.report.model.Dimension) AttributeGroupDimension(org.activityinfo.shared.report.model.AttributeGroupDimension) AdminDimension(org.activityinfo.shared.report.model.AdminDimension) DateDimension(org.activityinfo.shared.report.model.DateDimension) EntityCategory(org.activityinfo.shared.report.content.EntityCategory)

Aggregations

CategoryProperties (org.activityinfo.shared.report.model.CategoryProperties)4 JsonArray (com.google.gson.JsonArray)2 DimensionCategory (org.activityinfo.shared.report.content.DimensionCategory)2 Dimension (org.activityinfo.shared.report.model.Dimension)2 Color (com.google.code.appengine.awt.Color)1 Paint (com.google.code.appengine.awt.Paint)1 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 HashMap (java.util.HashMap)1 EntityCategory (org.activityinfo.shared.report.content.EntityCategory)1 AdminDimension (org.activityinfo.shared.report.model.AdminDimension)1 AttributeGroupDimension (org.activityinfo.shared.report.model.AttributeGroupDimension)1 DateDimension (org.activityinfo.shared.report.model.DateDimension)1