Path: blob/master/test/hotspot/jtreg/vmTestbase/jit/misctests/fpustack/GraphPanel.java
40948 views
/*1* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/22package jit.misctests.fpustack;2324import java.util.*;25import java.awt.*;26import java.applet.Applet;27import nsk.share.TestFailure;2829public class GraphPanel extends Panel {30private Panel graph; // the container3132private ilayout layout = null; // the strategy333435private int nodesN; // number of nodes36private Node nodes[] = new Node[200]; // nodes container3738/**39** constructor40**41** @param Panel the container42** @param layout a strategy to layout the nodes43**44**/45GraphPanel(Panel graph, layout ls ) {46this.graph = graph;47layout = ls;48}4950515253/**54** add a node via label text.55**56** @param lbl the label57** @return the index of the node in array nodes[]58**59**/6061public int addNode(String lbl) {62Node n = new Node();63if (nodesN > 0) {64n.x = nodes[nodesN-1].x + 30;65n.y = nodes[nodesN-1].y + 30;66}67n.lbl = lbl;6869nodes[nodesN] = n;70return nodesN++;71}72737475/**76** add a node via label text.77**78** @param lbl the label79** @return the index of the node in array nodes[]80**81**/8283public void addNodes(String lb1, String lb2, String lb3) {84addNode(lb1);85addNode(lb2);86addNode(lb3);87}88899091/**92** layout the nodes on the panel. the layout is used93**94**95**/96public synchronized void formatNodes( ) {9798// format nodes99FontMetrics fm = getFontMetrics(getFont());100Dimension d = getSize();101102Node[] ns = new Node[ nodesN ];103System.arraycopy(nodes, 0, ns, 0, nodesN);104layout.formatNodes( ns, d, fm );105106}107108109110}111112113