All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.japura.debug.InfoNodeUtil Maven / Gradle / Ivy

Go to download

Japura is a Java Swing project. It is an application framework and collection of components.

The newest version!
package org.japura.debug;

import java.awt.Color;
import java.awt.Dimension;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;

import net.miginfocom.swing.MigLayout;

import org.japura.gui.TitlePanel;
import org.japura.util.info.InfoNode;

/**
 * 
 * Copyright (C) 2013 Carlos Eduardo Leite de Andrade
 * 

* This library is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) any * later version. *

* This program 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 Lesser General Public License for more * details. *

* You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see www.gnu.org/licenses/ *

* For more information, contact: www.japura.org *

* * @author Carlos Eduardo Leite de Andrade * */ public class InfoNodeUtil{ public static TitlePanel buildTitlePanel(String title, Collection nodes, String... excludeIdentifiers) { TitlePanel titlePanel = new TitlePanel(title); titlePanel.setBorder(BorderFactory.createLineBorder(Color.black)); List leafs = new ArrayList(); List groups = new ArrayList(); for (InfoNode node : nodes) { boolean ignore = false; if (node.getIdentifier() != null) { for (String identifier : excludeIdentifiers) { if (identifier.equals(node.getIdentifier())) { ignore = true; break; } } } if (ignore) { continue; } if (node.isLeaf()) { leafs.add(node); } else { groups.add(node); } } JPanel container = new JPanel(); container.setBackground(Color.WHITE); container.setLayout(new MigLayout("ins 10 10 10 10,wrap 2", "[align right][grow]")); for (InfoNode node : leafs) { JLabel label = new JLabel(); label.setText(node.getName() + ":"); JTextArea textArea = new JTextArea(); textArea.setOpaque(false); textArea.setText(node.getValue()); textArea.setWrapStyleWord(true); textArea.setLineWrap(true); textArea.setPreferredSize(new Dimension(10, 10)); container.add(label); container.add(textArea, "wmin 10, grow x"); } for (InfoNode node : groups) { TitlePanel panel = buildTitlePanel(node.getName(), node.getChildren(), excludeIdentifiers); container.add(panel, "span x, grow x"); } titlePanel.add(container); return titlePanel; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy