Package com.cedarsoftware.ncube

Examples of com.cedarsoftware.ncube.Axis


            }
            count++;
        }

        // Step 3. Compute cell area size
        Axis top = axes.remove(candidate);
        axes.add(0, top);   // Top element is now first.
        top = axes.remove(0);   // Grab 1st (candidate axis) one more time
        if (top.getType() == AxisType.RULE)
        {   // If top is a rule axis, place it last.  It is recognized that there could
            // be more than one rule axis, and there could also be a single rule axis, in
            // which this is a no-op.
            axes.add(top);
        }
View Full Code Here


        long width = (Long) displayValues[2];

        s.append(html);

        // Top row (special case)
        Axis topAxis = axes.get(0);
        List<Column> topColumns = topAxis.getColumns();
        final int topColumnSize = topColumns.size();
        final String topAxisName = topAxis.getName();

        if (axes.size() == 1)
        {   // Ensure that one dimension is vertically down the page
            s.append(" <th data-id=\"a").append(topAxis.getId()).append("\" class=\"ncube-head\">");
            s.append("  <div class=\"btn-group axis-menu\" data-id=\"").append(topAxisName).append("\">\n");
            s.append("   <button type=\"button\" class=\"btn-sm btn-primary dropdown-toggle axis-btn\" data-toggle=\"dropdown\">");
            s.append("    <span>").append(topAxisName).append("</span><span class=\"caret\"></span>");
            s.append("   </button></th>\n");
            s.append("  </div>\n");
            s.append(" <th class=\"ncube-dead\">");
            s.append(ncube.getName());
            s.append("</th>\n");
            s.append("</tr>\n");
            Set<Long> coord = new LinkedHashSet<Long>();

            for (int i = 0; i < width; i++)
            {
                s.append("<tr>\n");
                Column column = topColumns.get(i);
                s.append(" <th data-id=\"c").append(column.getId()).append("\" class=\"ncube-col\">");
                s.append(column.isDefault() ? "Default" : column.toString());
                coord.clear();
                coord.add(topColumns.get(i).getId());
                s.append("</th>\n");
                buildCell(ncube, s, coord);
                s.append("</tr>\n");
            }
        }
        else
        {   // 2D+ shows as one column on the X axis and all other dimensions on the Y axis.
            int deadCols = axes.size() - 1;
            if (deadCols > 0)
            {
                s.append(" <th class=\"ncube-dead\" colspan=\"").append(deadCols).append("\">");
                s.append(ncube.getName());
                s.append("</th>\n");
            }
            s.append(" <th data-id=\"a").append(topAxis.getId()).append("\" class=\"ncube-head\" colspan=\"");
            s.append(topAxis.size());
            s.append("\">");
            s.append("  <div class=\"btn-group axis-menu\" data-id=\"").append(topAxisName).append("\">\n");
            s.append("  <button type=\"button\" class=\"btn-sm btn-primary dropdown-toggle axis-btn\" data-toggle=\"dropdown\">");
            s.append("   <span>").append(topAxisName).append("</span><span class=\"caret\"></span>");
            s.append("  </button>\n");
            s.append("   </div>\n");
            s.append(" </th>\n</tr>\n");

            // Second row (special case)
            s.append("<tr>\n");
            Map<String, Long> rowspanCounter = new HashMap<String, Long>();
            Map<String, Long> rowspan = new HashMap<String, Long>();
            Map<String, Long> columnCounter = new HashMap<String, Long>();
            Map<String, List<Column>> columns = new HashMap<String, List<Column>>();
            Map<String, Long> coord = new HashMap<String, Long>();

            final int axisCount = axes.size();

            for (int i = 1; i < axisCount; i++)
            {
                Axis axis = axes.get(i);
                String axisName = axis.getName();
                s.append(" <th data-id=\"a").append(axis.getId()).append("\" class=\"ncube-head\">\n");
                s.append("  <div class=\"btn-group axis-menu\" data-id=\"").append(axisName).append("\">\n");
                s.append("   <button type=\"button\" class=\"btn-sm btn-primary dropdown-toggle axis-btn\" data-toggle=\"dropdown\">");
                s.append("    <span>").append(axisName).append("</span><span class=\"caret\"></span>");
                s.append("   </button>\n");
                s.append("   </div>\n");
                s.append(" </th>\n");
                long colspan = 1;

                for (int j = i + 1; j < axisCount; j++)
                {
                    colspan *= axes.get(j).size();
                }

                rowspan.put(axisName, colspan);
                rowspanCounter.put(axisName, 0L);
                columnCounter.put(axisName, 0L);
                columns.put(axisName, axis.getColumns());
            }

            for (Column column : topColumns)
            {
                s.append(" <th data-id=\"c").append(column.getId()).append("\" class=\"ncube-col\">");
                s.append(column.toString());
                s.append("</th>\n");
            }

            if (topAxis.size() != topColumnSize)
            {
                s.append(" <th class=\"ncube-col\">Default</th>");
            }

            s.append("</tr>\n");

            // The left column headers and cells
            for (long h = 0; h < height; h++)
            {
                s.append("<tr>\n");
                // Column headers for the row
                for (int i = 1; i < axisCount; i++)
                {
                    Axis axis = axes.get(i);
                    String axisName = axis.getName();
                    Long count = rowspanCounter.get(axisName);

                    if (count == 0)
                    {
                        Long colIdx = columnCounter.get(axisName);
                        Column column = columns.get(axisName).get(colIdx.intValue());
                        coord.put(axisName, column.getId());
                        long span = rowspan.get(axisName);

                        if (span == 1)
                        {   // drop rowspan tag since rowspan="1" is redundant and wastes space in HTML
                            // Use column's ID as TH element's ID
                            s.append(" <th data-id=\"c").append(column.getId()).append("\" class=\"ncube-col\">");
                        }
                        else
                        {   // Need to show rowspan attribute
                            // Use column's ID as TH element's ID
                            s.append(" <th data-id=\"c").append(column.getId()).append("\" class=\"ncube-col\" rowspan=\"");
                            s.append(span);
                            s.append("\">");
                        }
                        s.append(column.toString());
                        s.append("</th>\n");

                        // Increment column counter
                        colIdx++;
                        if (colIdx >= axis.size())
                        {
                            colIdx = 0L;
                        }
                        columnCounter.put(axisName, colIdx);
                    }
View Full Code Here

            }
            count++;
        }

        // Step 3. Compute cell area size
        Axis top = axes.remove(candidate);
        axes.add(0, top);   // Top element is now first.
        top = axes.remove(0);   // Grab 1st (candidate axis) one more time
        if (top.getType() == AxisType.RULE)
        {   // If top is a rule axis, place it last.  It is recognized that there could
            // be more than one rule axis, and there could also be a single rule axis, in
            // which this is a no-op.
            axes.add(top);
        }
View Full Code Here

        long width = (Long) displayValues[2];

        s.append(html);

        // Top row (special case)
        Axis topAxis = axes.get(0);
        List<Column> topColumns = topAxis.getColumns();
        final int topColumnSize = topColumns.size();
        final String topAxisName = topAxis.getName();

        if (axes.size() == 1)
        {   // Ensure that one dimension is vertically down the page
            s.append(" <th data-id=\"a").append(topAxis.getId()).append("\" class=\"th-ncube ncube-head\">");
            s.append("  <div class=\"btn-group axis-menu\" data-id=\"").append(topAxisName).append("\">\n");
            s.append("   <button type=\"button\" class=\"btn-sm btn-primary dropdown-toggle axis-btn\" data-toggle=\"dropdown\">");
            s.append("    <span>").append(topAxisName).append("</span><span class=\"caret\"></span>");
            s.append("   </button></th>\n");
            s.append("  </div>\n");
            s.append(" <th class=\"th-ncube ncube-dead\">");
            s.append(ncube.getName());
            s.append("</th>\n");
            s.append("</tr>\n");

            for (int i = 0; i < width; i++)
            {
                s.append("<tr>\n");
                Column column = topColumns.get(i);
                boolean isCmd = isColumnInlineExpression(column);
                String colId = String.valueOf(column.getId());
                s.append(" <th data-id=\"").append(colId);
                s.append("\" data-axis=\"").append(topAxisName).append("\" class=\"th-ncube ");
                s.append(getColumnCssClass(topAxis, column));
                s.append("\">");
                if (isCmd)
                {
                    s.append("<pre class=\"ncube-pre\">");
                }
                addColumnPrefixText(s, column);
                s.append(column.isDefault() ? "Default" : column.toString());
                if (isCmd)
                {
                    s.append("</pre>");
                }
                s.append("</th>\n");
                Set<Long> colIds = new LinkedHashSet<>();
                colIds.add(column.getId());
                buildCell(ncube, s, colIds);
                s.append("</tr>\n");
            }
        }
        else
        {   // 2D+ shows as one column on the X axis and all other dimensions on the Y axis.
            int deadCols = axes.size() - 1;
            if (deadCols > 0)
            {
                s.append(" <th class=\"th-ncube ncube-dead\" colspan=\"").append(deadCols).append("\">");
                s.append(ncube.getName());
                s.append("</th>\n");
            }
            s.append(" <th data-id=\"a").append(topAxis.getId()).append("\" class=\"th-ncube ncube-head\" colspan=\"");
            s.append(topAxis.size());
            s.append("\">");
            s.append("  <div class=\"btn-group axis-menu\" data-id=\"").append(topAxisName).append("\">\n");
            s.append("  <button type=\"button\" class=\"btn-sm btn-primary dropdown-toggle axis-btn\" data-toggle=\"dropdown\">");
            s.append("   <span>").append(topAxisName).append("</span><span class=\"caret\"></span>");
            s.append("  </button>\n");
            s.append("   </div>\n");
            s.append(" </th>\n</tr>\n");

            // Second row (special case)
            s.append("<tr>\n");
            Map<String, Long> rowspanCounter = new HashMap<>();
            Map<String, Long> rowspan = new HashMap<>();
            Map<String, Long> columnCounter = new HashMap<>();
            Map<String, List<Column>> columns = new HashMap<>();

            final int axisCount = axes.size();

            for (int i = 1; i < axisCount; i++)
            {
                Axis axis = axes.get(i);
                String axisName = axis.getName();
                s.append(" <th data-id=\"a").append(axis.getId()).append("\" class=\"th-ncube ncube-head\">\n");
                s.append("  <div class=\"btn-group axis-menu\" data-id=\"").append(axisName).append("\">\n");
                s.append("   <button type=\"button\" class=\"btn-sm btn-primary dropdown-toggle axis-btn\" data-toggle=\"dropdown\">");
                s.append("    <span>").append(axisName).append("</span><span class=\"caret\"></span>");
                s.append("   </button>\n");
                s.append("   </div>\n");
                s.append(" </th>\n");
                long colspan = 1;

                for (int j = i + 1; j < axisCount; j++)
                {
                    colspan *= axes.get(j).size();
                }

                rowspan.put(axisName, colspan);
                rowspanCounter.put(axisName, 0L);
                columnCounter.put(axisName, 0L);
                columns.put(axisName, axis.getColumns());
            }

            for (Column column : topColumns)
            {
                boolean isCmd = isColumnInlineExpression(column);
                String colId = String.valueOf(column.getId());
                s.append(" <th data-id=\"").append(colId).append("\" data-axis=\"").append(topAxisName).append("\" class=\"th-ncube-top ");
                s.append(getColumnCssClass(topAxis, column));
                s.append("\">");
                if (isCmd)
                {
                    s.append("<pre class=\"ncube-pre\">");
                }
                addColumnPrefixText(s, column);
                s.append(column.toString());
                if (isCmd)
                {
                    s.append("</pre>");
                }
                s.append("</th>\n");
            }

            if (topAxis.size() != topColumnSize)
            {
                s.append(" <th class=\"th-ncube-top ");
                s.append(getColumnCssClass(topAxis, topAxis.getDefaultColumn()));
                s.append("\">Default</th>");
            }

            s.append("</tr>\n");
            Map<String, Long> coord = new HashMap<>();
            Map<String, Long> colIds = new HashMap<>();

            // The left column headers and cells
            for (long h = 0; h < height; h++)
            {
                s.append("<tr>\n");
                // Column headers for the row
                for (int i = 1; i < axisCount; i++)
                {
                    Axis axis = axes.get(i);
                    String axisName = axis.getName();
                    Long count = rowspanCounter.get(axisName);

                    if (count == 0)
                    {
                        Long colIdx = columnCounter.get(axisName);
                        Column column = columns.get(axisName).get(colIdx.intValue());
                        coord.put(axisName, colIdx);
                        colIds.put(axisName, column.getId());
                        long span = rowspan.get(axisName);

                        String columnId = String.valueOf(column.getId());
                        String colCssClass = getColumnCssClass(axis, column);
                        if (span == 1)
                        {   // drop rowspan tag since rowspan="1" is redundant and wastes space in HTML
                            // Use column's ID as TH element's ID
                            s.append(" <th data-id=\"").append(columnId).append("\" data-axis=\"").append(axisName).append("\" class=\"th-ncube ");
                            s.append(colCssClass);
                        }
                        else
                        {   // Need to show rowspan attribute
                            // Use column's ID as TH element's ID
                            s.append(" <th data-id=\"").append(columnId).append("\" data-axis=\"").append(axisName).append("\" class=\"th-ncube ");
                            s.append(colCssClass);
                            s.append("\" rowspan=\"");
                            s.append(span);
                        }
                        s.append("\">");
                        boolean isCmd = isColumnInlineExpression(column);

                        if (isCmd)
                        {
                            s.append("<pre class=\"ncube-pre\">");
                        }
                        addColumnPrefixText(s, column);
                        s.append(column.toString());
                        if (isCmd)
                        {
                            s.append("</pre>");
                        }
                        s.append("</th>\n");

                        // Increment column counter
                        colIdx++;
                        if (colIdx >= axis.size())
                        {
                            colIdx = 0L;
                        }
                        columnCounter.put(axisName, colIdx);
                    }
View Full Code Here

            }
            count++;
        }

        // Step 3. Compute cell area size
        Axis top = axes.remove(candidate);
        axes.add(0, top);   // Top element is now first.
        top = axes.remove(0);   // Grab 1st (candidate axis) one more time
        if (top.getType() == AxisType.RULE)
        {   // If top is a rule axis, place it last.  It is recognized that there could
            // be more than one rule axis, and there could also be a single rule axis, in
            // which this is a no-op.
            axes.add(top);
        }
View Full Code Here

        long width = (Long) displayValues[2];

        s.append(html);

        // Top row (special case)
        Axis topAxis = axes.get(0);
        List<Column> topColumns = topAxis.getColumns();
        final int topColumnSize = topColumns.size();
        final String topAxisName = topAxis.getName();

        if (axes.size() == 1)
        {   // Ensure that one dimension is vertically down the page
            s.append(" <th data-id=\"a").append(topAxis.getId()).append("\" class=\"th-ncube ncube-head\">");
            s.append("  <div class=\"btn-group axis-menu\" data-id=\"").append(topAxisName).append("\">\n");
            s.append("   <button type=\"button\" class=\"btn-sm btn-primary dropdown-toggle axis-btn\" data-toggle=\"dropdown\">");
            s.append("    <span>").append(topAxisName).append("</span><span class=\"caret\"></span>");
            s.append("   </button></th>\n");
            s.append("  </div>\n");
            s.append(" <th class=\"th-ncube ncube-dead\">");
            s.append(ncube.getName());
            s.append("</th>\n");
            s.append("</tr>\n");

            for (int i = 0; i < width; i++)
            {
                s.append("<tr>\n");
                Column column = topColumns.get(i);
                boolean isCmd = isColumnInlineExpression(column);
                String colId = String.valueOf(column.getId());
                s.append(" <th data-id=\"").append(colId);
                s.append("\" data-axis=\"").append(topAxisName).append("\" class=\"th-ncube ");
                s.append(getColumnCssClass(topAxis, column));
                s.append("\">");
                if (isCmd)
                {
                    s.append("<pre class=\"ncube-pre\">");
                }
                addColumnPrefixText(s, column);
                s.append(column.isDefault() ? "Default" : column.toString());
                if (isCmd)
                {
                    s.append("</pre>");
                }
                s.append("</th>\n");
                Set<Long> colIds = new LinkedHashSet<>();
                colIds.add(column.getId());
                buildCell(ncube, s, colIds);
                s.append("</tr>\n");
            }
        }
        else
        {   // 2D+ shows as one column on the X axis and all other dimensions on the Y axis.
            int deadCols = axes.size() - 1;
            if (deadCols > 0)
            {
                s.append(" <th class=\"th-ncube ncube-dead\" colspan=\"").append(deadCols).append("\">");
                s.append(ncube.getName());
                s.append("</th>\n");
            }
            s.append(" <th data-id=\"a").append(topAxis.getId()).append("\" class=\"th-ncube ncube-head\" colspan=\"");
            s.append(topAxis.size());
            s.append("\">");
            s.append("  <div class=\"btn-group axis-menu\" data-id=\"").append(topAxisName).append("\">\n");
            s.append("  <button type=\"button\" class=\"btn-sm btn-primary dropdown-toggle axis-btn\" data-toggle=\"dropdown\">");
            s.append("   <span>").append(topAxisName).append("</span><span class=\"caret\"></span>");
            s.append("  </button>\n");
            s.append("   </div>\n");
            s.append(" </th>\n</tr>\n");

            // Second row (special case)
            s.append("<tr>\n");
            Map<String, Long> rowspanCounter = new HashMap<>();
            Map<String, Long> rowspan = new HashMap<>();
            Map<String, Long> columnCounter = new HashMap<>();
            Map<String, List<Column>> columns = new HashMap<>();

            final int axisCount = axes.size();

            for (int i = 1; i < axisCount; i++)
            {
                Axis axis = axes.get(i);
                String axisName = axis.getName();
                s.append(" <th data-id=\"a").append(axis.getId()).append("\" class=\"th-ncube ncube-head\">\n");
                s.append("  <div class=\"btn-group axis-menu\" data-id=\"").append(axisName).append("\">\n");
                s.append("   <button type=\"button\" class=\"btn-sm btn-primary dropdown-toggle axis-btn\" data-toggle=\"dropdown\">");
                s.append("    <span>").append(axisName).append("</span><span class=\"caret\"></span>");
                s.append("   </button>\n");
                s.append("   </div>\n");
                s.append(" </th>\n");
                long colspan = 1;

                for (int j = i + 1; j < axisCount; j++)
                {
                    colspan *= axes.get(j).size();
                }

                rowspan.put(axisName, colspan);
                rowspanCounter.put(axisName, 0L);
                columnCounter.put(axisName, 0L);
                columns.put(axisName, axis.getColumns());
            }

            for (Column column : topColumns)
            {
                boolean isCmd = isColumnInlineExpression(column);
                String colId = String.valueOf(column.getId());
                s.append(" <th data-id=\"").append(colId).append("\" data-axis=\"").append(topAxisName).append("\" class=\"th-ncube-top ");
                s.append(getColumnCssClass(topAxis, column));
                s.append("\">");
                if (isCmd)
                {
                    s.append("<pre class=\"ncube-pre\">");
                }
                addColumnPrefixText(s, column);
                s.append(column.toString());
                if (isCmd)
                {
                    s.append("</pre>");
                }
                s.append("</th>\n");
            }

            if (topAxis.size() != topColumnSize)
            {
                s.append(" <th class=\"th-ncube-top ");
                s.append(getColumnCssClass(topAxis, topAxis.getDefaultColumn()));
                s.append("\">Default</th>");
            }

            s.append("</tr>\n");
            Map<String, Long> coord = new HashMap<>();
            Map<String, Long> colIds = new HashMap<>();

            // The left column headers and cells
            for (long h = 0; h < height; h++)
            {
                s.append("<tr>\n");
                // Column headers for the row
                for (int i = 1; i < axisCount; i++)
                {
                    Axis axis = axes.get(i);
                    String axisName = axis.getName();
                    Long count = rowspanCounter.get(axisName);

                    if (count == 0)
                    {
                        Long colIdx = columnCounter.get(axisName);
                        Column column = columns.get(axisName).get(colIdx.intValue());
                        coord.put(axisName, colIdx);
                        colIds.put(axisName, column.getId());
                        long span = rowspan.get(axisName);

                        String columnId = String.valueOf(column.getId());
                        String colCssClass = getColumnCssClass(axis, column);
                        if (span == 1)
                        {   // drop rowspan tag since rowspan="1" is redundant and wastes space in HTML
                            // Use column's ID as TH element's ID
                            s.append(" <th data-id=\"").append(columnId).append("\" data-axis=\"").append(axisName).append("\" class=\"th-ncube ");
                            s.append(colCssClass);
                        }
                        else
                        {   // Need to show rowspan attribute
                            // Use column's ID as TH element's ID
                            s.append(" <th data-id=\"").append(columnId).append("\" data-axis=\"").append(axisName).append("\" class=\"th-ncube ");
                            s.append(colCssClass);
                            s.append("\" rowspan=\"");
                            s.append(span);
                        }
                        s.append("\">");
                        boolean isCmd = isColumnInlineExpression(column);

                        if (isCmd)
                        {
                            s.append("<pre class=\"ncube-pre\">");
                        }
                        addColumnPrefixText(s, column);
                        s.append(column.toString());
                        if (isCmd)
                        {
                            s.append("</pre>");
                        }
                        s.append("</th>\n");

                        // Increment column counter
                        colIdx++;
                        if (colIdx >= axis.size())
                        {
                            colIdx = 0L;
                        }
                        columnCounter.put(axisName, colIdx);
                    }
View Full Code Here

            }
            count++;
        }

        // Step 3. Compute cell area size
        Axis top = axes.remove(candidate);
        axes.add(0, top);   // Top element is now first.
        top = axes.remove(0);   // Grab 1st (candidate axis) one more time
        if (top.getType() == AxisType.RULE)
        {   // If top is a rule axis, place it last.  It is recognized that there could
            // be more than one rule axis, and there could also be a single rule axis, in
            // which this is a no-op.
            axes.add(top);
        }
View Full Code Here

        long width = (Long) displayValues[2];

        s.append(html);

        // Top row (special case)
        Axis topAxis = axes.get(0);
        List<Column> topColumns = topAxis.getColumns();
        final int topColumnSize = topColumns.size();
        final String topAxisName = topAxis.getName();

        if (axes.size() == 1)
        {   // Ensure that one dimension is vertically down the page
            s.append(" <th data-id=\"a").append(topAxis.getId()).append("\" class=\"ncube-head\">");
            s.append("  <div class=\"btn-group axis-menu\" data-id=\"").append(topAxisName).append("\">\n");
            s.append("   <button type=\"button\" class=\"btn-sm btn-primary dropdown-toggle axis-btn\" data-toggle=\"dropdown\">");
            s.append("    <span>").append(topAxisName).append("</span><span class=\"caret\"></span>");
            s.append("   </button></th>\n");
            s.append("  </div>\n");
            s.append(" <th class=\"ncube-dead\"></th>\n");
            s.append("</tr>\n");
            Set<Long> coord = new LinkedHashSet<Long>();

            for (int i=0; i < width; i++)
            {
                s.append("<tr>\n");
                Column column = topColumns.get(i);
                s.append(" <th data-id=\"c").append(column.getId()).append("\" class=\"ncube-col\">");
                s.append(column.isDefault() ? "Default" : column.toString());
                coord.clear();
                coord.add(topColumns.get(i).getId());
                s.append("</th>\n");
                buildCell(ncube, s, coord);
                s.append("</tr>\n");
            }
        }
        else
        {   // 2D+ shows as one column on the X axis and all other dimensions on the Y axis.
            int deadCols = axes.size() - 1;
            if (deadCols > 0)
            {
                s.append(" <th class=\"ncube-dead\" colspan=\"").append(deadCols).append("\"></th>\n");
            }
            s.append(" <th data-id=\"a").append(topAxis.getId()).append("\" class=\"ncube-head\" colspan=\"");
            s.append(topAxis.size());
            s.append("\">");
            s.append("  <div class=\"btn-group axis-menu\" data-id=\"").append(topAxisName).append("\">\n");
            s.append("  <button type=\"button\" class=\"btn-sm btn-primary dropdown-toggle axis-btn\" data-toggle=\"dropdown\">");
            s.append("   <span>").append(topAxisName).append("</span><span class=\"caret\"></span>");
            s.append("  </button>\n");
            s.append("   </div>\n");
            s.append(" </th>\n</tr>\n");

            // Second row (special case)
            s.append("<tr>\n");
            Map<String, Long> rowspanCounter = new HashMap<String, Long>();
            Map<String, Long> rowspan = new HashMap<String, Long>();
            Map<String, Long> columnCounter = new HashMap<String, Long>();
            Map<String, List<Column>> columns = new HashMap<String, List<Column>>();
            Map<String, Long> coord = new HashMap<String, Long>();

            final int axisCount = axes.size();

            for (int i=1; i < axisCount; i++)
            {
                Axis axis = axes.get(i);
                String axisName = axis.getName();
                s.append(" <th data-id=\"a").append(axis.getId()).append("\" class=\"ncube-head\">\n");
                s.append("  <div class=\"btn-group axis-menu\" data-id=\"").append(axisName).append("\">\n");
                s.append("   <button type=\"button\" class=\"btn-sm btn-primary dropdown-toggle axis-btn\" data-toggle=\"dropdown\">");
                s.append("    <span>").append(axisName).append("</span><span class=\"caret\"></span>");
                s.append("   </button>\n");
                s.append("   </div>\n");
                s.append(" </th>\n");
                long colspan = 1;

                for (int j=i + 1; j < axisCount; j++)
                {
                    colspan *= axes.get(j).size();
                }

                rowspan.put(axisName, colspan);
                rowspanCounter.put(axisName, 0L);
                columnCounter.put(axisName, 0L);
                columns.put(axisName, axis.getColumns());
            }

            for (Column column : topColumns)
            {
                s.append(" <th data-id=\"c").append(column.getId()).append("\" class=\"ncube-col\">");
                s.append(column.toString());
                s.append("</th>\n");
            }

            if (topAxis.size() != topColumnSize)
            {
                s.append(" <th class=\"ncube-col\">Default</th>");
            }

            s.append("</tr>\n");

            // The left column headers and cells
            for (long h=0; h < height; h++)
            {
                s.append("<tr>\n");
                // Column headers for the row
                for (int i=1; i < axisCount; i++)
                {
                    Axis axis = axes.get(i);
                    String axisName = axis.getName();
                    Long count = rowspanCounter.get(axisName);

                    if (count == 0)
                    {
                        Long colIdx = columnCounter.get(axisName);
                        Column column = columns.get(axisName).get(colIdx.intValue());
                        coord.put(axisName, column.getId());
                        long span = rowspan.get(axisName);

                        if (span == 1)
                        {   // drop rowspan tag since rowspan="1" is redundant and wastes space in HTML
                            // Use column's ID as TH element's ID
                            s.append(" <th data-id=\"c").append(column.getId()).append("\" class=\"ncube-col\">");
                        }
                        else
                        {   // Need to show rowspan attribute
                            // Use column's ID as TH element's ID
                            s.append(" <th data-id=\"c").append(column.getId()).append("\" class=\"ncube-col\" rowspan=\"");
                            s.append(span);
                            s.append("\">");
                        }
                        s.append(column.toString());
                        s.append("</th>\n");

                        // Increment column counter
                        colIdx++;
                        if (colIdx >= axis.size())
                        {
                            colIdx = 0L;
                        }
                        columnCounter.put(axisName, colIdx);
                    }
View Full Code Here

            }
            count++;
        }

        // Step 3. Compute cell area size
        Axis top = axes.remove(candidate);
        axes.add(0, top);   // Top element is now first.
        top = axes.remove(0);   // Grab 1st (candidate axis) one more time
        if (top.getType() == AxisType.RULE)
        {   // If top is a rule axis, place it last.  It is recognized that there could
            // be more than one rule axis, and there could also be a single rule axis, in
            // which this is a no-op.
            axes.add(top);
        }
View Full Code Here

        long width = (Long) displayValues[2];

        s.append(html);

        // Top row (special case)
        Axis topAxis = axes.get(0);
        List<Column> topColumns = topAxis.getColumns();
        final int topColumnSize = topColumns.size();
        final String topAxisName = topAxis.getName();

        if (axes.size() == 1)
        {   // Ensure that one dimension is vertically down the page
            s.append(" <th data-id=\"a").append(topAxis.getId()).append("\" class=\"th-ncube ncube-head\">");
            s.append("  <div class=\"btn-group axis-menu\" data-id=\"").append(topAxisName).append("\">\n");
            s.append("   <button type=\"button\" class=\"btn-sm btn-primary dropdown-toggle axis-btn\" data-toggle=\"dropdown\">");
            s.append("    <span>").append(topAxisName).append("</span><span class=\"caret\"></span>");
            s.append("   </button></th>\n");
            s.append("  </div>\n");
            s.append(" <th class=\"th-ncube ncube-dead\">");
            s.append(ncube.getName());
            s.append("</th>\n");
            s.append("</tr>\n");

            for (int i = 0; i < width; i++)
            {
                s.append("<tr>\n");
                Column column = topColumns.get(i);
                String colId = String.valueOf(column.getId());
                s.append(" <th data-id=\"").append(colId);
                s.append("\" data-axis=\"").append(topAxisName).append("\" class=\"th-ncube ");
                s.append(getColumnCssClass(topAxis, column));
                s.append("\">");
                addColumnPrefixText(s, column);
                s.append(column.isDefault() ? "Default" : column.toString());
                s.append("</th>\n");
                Set<Long> colIds = new LinkedHashSet<>();
                colIds.add(column.getId());
                buildCell(ncube, s, colIds);
                s.append("</tr>\n");
            }
        }
        else
        {   // 2D+ shows as one column on the X axis and all other dimensions on the Y axis.
            int deadCols = axes.size() - 1;
            if (deadCols > 0)
            {
                s.append(" <th class=\"th-ncube ncube-dead\" colspan=\"").append(deadCols).append("\">");
                s.append(ncube.getName());
                s.append("</th>\n");
            }
            s.append(" <th data-id=\"a").append(topAxis.getId()).append("\" class=\"th-ncube ncube-head\" colspan=\"");
            s.append(topAxis.size());
            s.append("\">");
            s.append("  <div class=\"btn-group axis-menu\" data-id=\"").append(topAxisName).append("\">\n");
            s.append("  <button type=\"button\" class=\"btn-sm btn-primary dropdown-toggle axis-btn\" data-toggle=\"dropdown\">");
            s.append("   <span>").append(topAxisName).append("</span><span class=\"caret\"></span>");
            s.append("  </button>\n");
            s.append("   </div>\n");
            s.append(" </th>\n</tr>\n");

            // Second row (special case)
            s.append("<tr>\n");
            Map<String, Long> rowspanCounter = new HashMap<>();
            Map<String, Long> rowspan = new HashMap<>();
            Map<String, Long> columnCounter = new HashMap<>();
            Map<String, List<Column>> columns = new HashMap<>();

            final int axisCount = axes.size();

            for (int i = 1; i < axisCount; i++)
            {
                Axis axis = axes.get(i);
                String axisName = axis.getName();
                s.append(" <th data-id=\"a").append(axis.getId()).append("\" class=\"th-ncube ncube-head\">\n");
                s.append("  <div class=\"btn-group axis-menu\" data-id=\"").append(axisName).append("\">\n");
                s.append("   <button type=\"button\" class=\"btn-sm btn-primary dropdown-toggle axis-btn\" data-toggle=\"dropdown\">");
                s.append("    <span>").append(axisName).append("</span><span class=\"caret\"></span>");
                s.append("   </button>\n");
                s.append("   </div>\n");
                s.append(" </th>\n");
                long colspan = 1;

                for (int j = i + 1; j < axisCount; j++)
                {
                    colspan *= axes.get(j).size();
                }

                rowspan.put(axisName, colspan);
                rowspanCounter.put(axisName, 0L);
                columnCounter.put(axisName, 0L);
                columns.put(axisName, axis.getColumns());
            }

            for (Column column : topColumns)
            {
                String colId = String.valueOf(column.getId());
                s.append(" <th data-id=\"").append(colId).append("\" data-axis=\"").append(topAxisName).append("\" class=\"th-ncube-top ");
                s.append(getColumnCssClass(topAxis, column));
                s.append("\">");
                addColumnPrefixText(s, column);
                s.append(column.toString());
                s.append("</th>\n");
            }

            if (topAxis.size() != topColumnSize)
            {
                s.append(" <th class=\"th-ncube-top ");
                s.append(getColumnCssClass(topAxis, topAxis.getDefaultColumn()));
                s.append("\">Default</th>");
            }

            s.append("</tr>\n");
            Map<String, Long> coord = new HashMap<>();
            Map<String, Long> colIds = new HashMap<>();

            // The left column headers and cells
            for (long h = 0; h < height; h++)
            {
                s.append("<tr>\n");
                // Column headers for the row
                for (int i = 1; i < axisCount; i++)
                {
                    Axis axis = axes.get(i);
                    String axisName = axis.getName();
                    Long count = rowspanCounter.get(axisName);

                    if (count == 0)
                    {
                        Long colIdx = columnCounter.get(axisName);
                        Column column = columns.get(axisName).get(colIdx.intValue());
                        coord.put(axisName, colIdx);
                        colIds.put(axisName, column.getId());
                        long span = rowspan.get(axisName);

                        String columnId = String.valueOf(column.getId());
                        String colCssClass = getColumnCssClass(axis, column);
                        if (span == 1)
                        {   // drop rowspan tag since rowspan="1" is redundant and wastes space in HTML
                            // Use column's ID as TH element's ID
                            s.append(" <th data-id=\"").append(columnId).append("\" data-axis=\"").append(axisName).append("\" class=\"th-ncube ");
                            s.append(colCssClass);
                            s.append("\">");
                        }
                        else
                        {   // Need to show rowspan attribute
                            // Use column's ID as TH element's ID
                            s.append(" <th data-id=\"").append(columnId).append("\" data-axis=\"").append(axisName).append("\" class=\"th-ncube ");
                            s.append(colCssClass);
                            s.append("\" rowspan=\"");
                            s.append(span);
                            s.append("\">");
                        }
                        addColumnPrefixText(s, column);
                        s.append(column.toString());
                        s.append("</th>\n");

                        // Increment column counter
                        colIdx++;
                        if (colIdx >= axis.size())
                        {
                            colIdx = 0L;
                        }
                        columnCounter.put(axisName, colIdx);
                    }
View Full Code Here

TOP

Related Classes of com.cedarsoftware.ncube.Axis

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.