001package de.deepamehta.webclient.migrations;
002
003import de.deepamehta.core.service.Migration;
004
005
006
007/**
008 * Adding icons and colors to the Core types.
009 * Runs ALWAYS.
010 * <p>
011 * Part of DM 4.0
012 */
013public class Migration2 extends Migration {
014
015    // -------------------------------------------------------------------------------------------------- Public Methods
016
017    @Override
018    public void run() {
019        addIconToTopicType("dm4.core.meta_type",   "box-gray.png");
020        addIconToTopicType("dm4.core.topic_type",  "box-blue.png");
021        addIconToTopicType("dm4.core.assoc_type",  "box-red.png");
022        addIconToTopicType("dm4.core.data_type",   "box-green.png");
023        addIconToTopicType("dm4.core.cardinality", "box-yellow.png");
024        addIconToTopicType("dm4.core.index_mode",  "box-orange.png");
025        addIconToTopicType("dm4.core.plugin",      "puzzle.png");
026        //
027        // Note: on the canvas HSL-specified colors are rendered pale (Safari and Firefox).
028        // Update: this is because HSB is not same as HSL. The values here are actually HSB, but CSS expects HSL.
029        addColorToAssociationType("dm4.core.association",     "rgb(178, 178, 178)" /*"hsl(  0,  0%, 75%)"*/);
030        addColorToAssociationType("dm4.core.aggregation",     "rgb(53, 223, 59)"   /*"hsl(120, 65%, 90%)"*/);
031        addColorToAssociationType("dm4.core.composition",     "rgb(231, 62, 60)"   /*"hsl(  0, 65%, 90%)"*/);
032        addColorToAssociationType("dm4.core.aggregation_def", "rgb(44, 178, 48)"   /*"hsl(120, 65%, 75%)"*/);
033        addColorToAssociationType("dm4.core.composition_def", "rgb(184, 51, 49)"   /*"hsl(  0, 65%, 75%)"*/);
034        addColorToAssociationType("dm4.core.instantiation",   "rgb(41, 194, 225)"  /*"hsl(190, 65%, 90%)"*/);
035        addColorToAssociationType("dm4.core.sequence",        "rgb(228, 223, 55)"  /*"hsl( 60, 65%, 90%)"*/);
036    }
037
038    // ------------------------------------------------------------------------------------------------- Private Methods
039
040    private void addIconToTopicType(String topicTypeUri, String iconfile) {
041        setTopicTypeViewConfigValue(topicTypeUri, "icon", "/de.deepamehta.webclient/images/" + iconfile);
042    }
043
044    private void addColorToAssociationType(String assocTypeUri, String color) {
045        setAssocTypeViewConfigValue(assocTypeUri, "color", color);
046    }
047}