Java Code Examples for com.sun.hotspot.igv.graph.Diagram#getFigures()

The following examples show how to use com.sun.hotspot.igv.graph.Diagram#getFigures() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConnectionFilter.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void apply(Diagram diagram) {

        Properties.PropertySelector<Figure> selector = new Properties.PropertySelector<Figure>(diagram.getFigures());
        for (ConnectionStyleRule rule : connectionStyleRules) {
            List<Figure> figures = null;
            if (rule.getSelector() != null) {
                figures = rule.getSelector().selected(diagram);
            } else {
                figures = diagram.getFigures();
            }

            for (Figure f : figures) {
                for (OutputSlot os : f.getOutputSlots()) {
                    for (Connection c : os.getConnections()) {
                        if (figures.contains(c.getInputSlot().getFigure())) {
                            c.setStyle(rule.getLineStyle());
                            c.setColor(rule.getLineColor());
                        }
                    }
                }
            }
        }
    }
 
Example 2
Source File: ConnectionFilter.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void apply(Diagram diagram) {

        Properties.PropertySelector<Figure> selector = new Properties.PropertySelector<Figure>(diagram.getFigures());
        for (ConnectionStyleRule rule : connectionStyleRules) {
            List<Figure> figures = null;
            if (rule.getSelector() != null) {
                figures = rule.getSelector().selected(diagram);
            } else {
                figures = diagram.getFigures();
            }

            for (Figure f : figures) {
                for (OutputSlot os : f.getOutputSlots()) {
                    for (Connection c : os.getConnections()) {
                        if (figures.contains(c.getInputSlot().getFigure())) {
                            c.setStyle(rule.getLineStyle());
                            c.setColor(rule.getLineColor());
                        }
                    }
                }
            }
        }
    }
 
Example 3
Source File: ConnectionFilter.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void apply(Diagram diagram) {

        Properties.PropertySelector<Figure> selector = new Properties.PropertySelector<Figure>(diagram.getFigures());
        for (ConnectionStyleRule rule : connectionStyleRules) {
            List<Figure> figures = null;
            if (rule.getSelector() != null) {
                figures = rule.getSelector().selected(diagram);
            } else {
                figures = diagram.getFigures();
            }

            for (Figure f : figures) {
                for (OutputSlot os : f.getOutputSlots()) {
                    for (Connection c : os.getConnections()) {
                        if (figures.contains(c.getInputSlot().getFigure())) {
                            c.setStyle(rule.getLineStyle());
                            c.setColor(rule.getLineColor());
                        }
                    }
                }
            }
        }
    }
 
Example 4
Source File: ConnectionFilter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public void apply(Diagram diagram) {

        Properties.PropertySelector<Figure> selector = new Properties.PropertySelector<Figure>(diagram.getFigures());
        for (ConnectionStyleRule rule : connectionStyleRules) {
            List<Figure> figures = null;
            if (rule.getSelector() != null) {
                figures = rule.getSelector().selected(diagram);
            } else {
                figures = diagram.getFigures();
            }

            for (Figure f : figures) {
                for (OutputSlot os : f.getOutputSlots()) {
                    for (Connection c : os.getConnections()) {
                        if (figures.contains(c.getInputSlot().getFigure())) {
                            c.setStyle(rule.getLineStyle());
                            c.setColor(rule.getLineColor());
                        }
                    }
                }
            }
        }
    }
 
Example 5
Source File: RemoveFilter.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void apply(Diagram diagram) {
    for (RemoveRule r : rules) {
        List<Figure> selected = r.getSelector().selected(diagram);
        Set<Figure> toRemove = new HashSet<>(selected);

        if (r.getRemoveOrphans()) {
            boolean changed;
            do {
                changed = false;
                for (Figure f : diagram.getFigures()) {
                    if (!toRemove.contains(f)) {
                        if (toRemove.containsAll(f.getPredecessors()) && toRemove.containsAll(f.getSuccessors())) {
                            toRemove.add(f);
                            changed = true;
                        }
                    }
                }
            } while (changed);
        }

        diagram.removeAllFigures(toRemove);
    }
}
 
Example 6
Source File: GraalEdgeColorFilter.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void apply(Diagram d) {
    List<Figure> figures = d.getFigures();
    for (Figure f : figures) {
        for (InputSlot is : f.getInputSlots()) {
            for (Connection c : is.getConnections()) {
                String type = c.getType();
                if (type == "Association" && "EndNode".equals(c.getOutputSlot().getFigure().getProperties().get("class"))) {
                    type = "Successor";
                }

                if (type != null) {
                    Color typeColor = usageColor.get(type);
                    if (typeColor == null) {
                        c.setColor(otherUsageColor);
                    } else {
                        c.setColor(typeColor);
                    }
                    if (c.getStyle() != ConnectionStyle.DASHED && type == "Successor") {
                        c.setStyle(ConnectionStyle.BOLD);
                    }
                }
            }
        }
    }
}
 
Example 7
Source File: ConnectionFilter.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public void apply(Diagram diagram) {

        Properties.PropertySelector<Figure> selector = new Properties.PropertySelector<Figure>(diagram.getFigures());
        for (ConnectionStyleRule rule : connectionStyleRules) {
            List<Figure> figures = null;
            if (rule.getSelector() != null) {
                figures = rule.getSelector().selected(diagram);
            } else {
                figures = diagram.getFigures();
            }

            for (Figure f : figures) {
                for (OutputSlot os : f.getOutputSlots()) {
                    for (Connection c : os.getConnections()) {
                        if (figures.contains(c.getInputSlot().getFigure())) {
                            c.setStyle(rule.getLineStyle());
                            c.setColor(rule.getLineColor());
                        }
                    }
                }
            }
        }
    }
 
Example 8
Source File: ConnectionFilter.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public void apply(Diagram diagram) {

        Properties.PropertySelector<Figure> selector = new Properties.PropertySelector<Figure>(diagram.getFigures());
        for (ConnectionStyleRule rule : connectionStyleRules) {
            List<Figure> figures = null;
            if (rule.getSelector() != null) {
                figures = rule.getSelector().selected(diagram);
            } else {
                figures = diagram.getFigures();
            }

            for (Figure f : figures) {
                for (OutputSlot os : f.getOutputSlots()) {
                    for (Connection c : os.getConnections()) {
                        if (figures.contains(c.getInputSlot().getFigure())) {
                            c.setStyle(rule.getLineStyle());
                            c.setColor(rule.getLineColor());
                        }
                    }
                }
            }
        }
    }
 
Example 9
Source File: ConnectionFilter.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public void apply(Diagram diagram) {

        Properties.PropertySelector<Figure> selector = new Properties.PropertySelector<Figure>(diagram.getFigures());
        for (ConnectionStyleRule rule : connectionStyleRules) {
            List<Figure> figures = null;
            if (rule.getSelector() != null) {
                figures = rule.getSelector().selected(diagram);
            } else {
                figures = diagram.getFigures();
            }

            for (Figure f : figures) {
                for (OutputSlot os : f.getOutputSlots()) {
                    for (Connection c : os.getConnections()) {
                        if (figures.contains(c.getInputSlot().getFigure())) {
                            c.setStyle(rule.getLineStyle());
                            c.setColor(rule.getLineColor());
                        }
                    }
                }
            }
        }
    }
 
Example 10
Source File: GradientColorFilter.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void apply(Diagram d) {
    boolean logarithmic = mode.equalsIgnoreCase(LOGARITHMIC);
    if (!logarithmic && !mode.equalsIgnoreCase(LINEAR)) {
        throw new RuntimeException("Unknown mode: " + mode);
    }

    Rectangle bounds = new Rectangle(shadeCount, 1);
    LinearGradientPaint lgp = new LinearGradientPaint(bounds.x, bounds.y, bounds.width, bounds.y, fractions, colors);
    PaintContext context = lgp.createContext(null, bounds, bounds.getBounds2D(), AffineTransform.getTranslateInstance(0, 0), new RenderingHints(null));
    Raster raster = context.getRaster(bounds.x, bounds.y, bounds.width, bounds.height);
    int[] rgb = raster.getPixels(bounds.x, bounds.y, bounds.width, bounds.height, (int[]) null);
    Color[] shades = new Color[rgb.length / 3];
    for (int i = 0; i < shades.length; ++i) {
        shades[i] = new Color(rgb[i * 3], rgb[i * 3 + 1], rgb[i * 3 + 2]);
    }

    List<Figure> figures = d.getFigures();
    for (Figure f : figures) {
        String property = f.getProperties().get(propertyName);
        if (property != null) {
            try {
                float value = Float.parseFloat(property);

                Color nodeColor;
                if (value <= minValue) {
                    nodeColor = colors[0];
                } else if (value >= maxValue) {
                    nodeColor = colors[colors.length - 1];
                } else {
                    double normalized = value - minValue;
                    double interval = maxValue - minValue;
                    int index;
                    // Use Math.ceil() to make values above zero distinguishable from zero
                    if (logarithmic) {
                        index = (int) Math.ceil(shades.length * Math.log(1 + normalized) / Math.log(1 + interval));
                    } else {
                        index = (int) Math.ceil(shades.length * normalized / interval);
                    }
                    nodeColor = shades[index];
                }
                f.setColor(nodeColor);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}