|
Java example source code file (Diagram.java)
The Diagram.java Java example source code/* * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. * */ package com.sun.hotspot.igv.graph; import com.sun.hotspot.igv.data.InputBlock; import com.sun.hotspot.igv.data.InputEdge; import com.sun.hotspot.igv.data.InputGraph; import com.sun.hotspot.igv.data.InputNode; import com.sun.hotspot.igv.data.Properties; import java.awt.Font; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; /** * * @author Thomas Wuerthinger */ public class Diagram { private List<Figure> figures; private Map<InputBlock, Block> blocks; private InputGraph graph; private int curId; private String nodeText; private Font font; public Font getFont() { return font; } private Diagram() { figures = new ArrayList<Figure>(); blocks = new HashMap<InputBlock, Block>(); this.nodeText = ""; this.font = new Font("Serif", Font.PLAIN, 14); } public Block getBlock(InputBlock b) { return blocks.get(b); } public String getNodeText() { return nodeText; } public void schedule(Collection<InputBlock> newBlocks) { graph.schedule(newBlocks); updateBlocks(); } private void updateBlocks() { blocks.clear(); for (InputBlock b : graph.getBlocks()) { Block curBlock = new Block(b, this); blocks.put(b, curBlock); } } public Diagram getNext() { return Diagram.createDiagram(graph.getNext(), nodeText); } public Collection<Block> getBlocks() { return Collections.unmodifiableCollection(blocks.values()); } public Diagram getPrev() { return Diagram.createDiagram(graph.getPrev(), nodeText); } public List<Figure> getFigures() { return Collections.unmodifiableList(figures); } public Figure createFigure() { Figure f = new Figure(this, curId); curId++; this.figures.add(f); return f; } public Connection createConnection(InputSlot inputSlot, OutputSlot outputSlot) { assert inputSlot.getFigure().getDiagram() == this; assert outputSlot.getFigure().getDiagram() == this; return new Connection(inputSlot, outputSlot); } public static Diagram createDiagram(InputGraph graph, String nodeText) { if (graph == null) { return null; } Diagram d = new Diagram(); d.graph = graph; d.nodeText = nodeText; d.updateBlocks(); Collection<InputNode> nodes = graph.getNodes(); HashMap<Integer, Figure> figureHash = new HashMap Other Java examples (source code examples)Here is a short list of links related to this Java Diagram.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.