X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=inline;f=bundles%2Forg.simantics.debug.browser%2Fsrc%2Forg%2Fsimantics%2Fdebug%2Fbrowser%2Fsections%2FTypeHierarchySection.java;h=94c861c98a00798f011d81bc9c6ec8244c237706;hb=d020223db52fe1d1223d596280bc6a4bf2761721;hp=c4735e45fbbf7c494eda9d1df0e8d00cb3d1af23;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.debug.browser/src/org/simantics/debug/browser/sections/TypeHierarchySection.java b/bundles/org.simantics.debug.browser/src/org/simantics/debug/browser/sections/TypeHierarchySection.java index c4735e45f..94c861c98 100644 --- a/bundles/org.simantics.debug.browser/src/org/simantics/debug/browser/sections/TypeHierarchySection.java +++ b/bundles/org.simantics.debug.browser/src/org/simantics/debug/browser/sections/TypeHierarchySection.java @@ -1,100 +1,100 @@ -/******************************************************************************* - * Copyright (c) 2016 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * THTH ry - initial API and implementation - *******************************************************************************/ -package org.simantics.debug.browser.sections; - -import java.io.PrintWriter; - -import org.simantics.db.ReadGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.debug.browser.utils.ResourceInfo; - -public class TypeHierarchySection implements ResourceBrowserSection { - - public static class Node { - public final String relation; - public final ResourceInfo type; - public final Node[] superTypes; - public final int height; - public final int width; - - public Node(String relation, ResourceInfo type, Node[] superTypes) { - this.relation = relation; - this.type = type; - this.superTypes = superTypes; - this.height = sumHeights(superTypes); - this.width = maxWidths(superTypes); - } - } - - Node root; - - public TypeHierarchySection(Node root) { - this.root = root; - } - - private static int sumHeights(Node[] nodes) { - int sum = 0; - for(Node node : nodes) - sum += node.height; - if(sum == 0) - sum = 1; - return sum; - } - - private static int maxWidths(Node[] nodes) { - int max = 0; - for(Node node : nodes) - if(node.width > max) - max = node.width; - return max+1; - } - - @Override - public double getPriority() { - return 1; - } - - @Override - public void toHtml(ReadGraph graph, PrintWriter out) - throws DatabaseException { - Node[][] table = new Node[root.height][root.width-1]; - fillTable(table, root, 0, 0); - - if (root.width - 1 > 0) { - out.println("