⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 annealinglayoutconfigurationdialog.java

📁 用JGraph编的软件
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/*
 * @(#)AnnealingLayoutConfigurationDialog.java 1.0 12.08.2003
 *
 * Copyright (C) 2003 sven_luzar
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */

package org.jgraph.layout;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.ArrayList;
import java.util.Properties;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;


/******************************************************************************/
/*############################################################################*/
/*############################################################################*/
/*############################################################################*/
/*############################################################################*/
/******************************************************************************/
/**
 * @author winkler
 * @author sven luzar
 *
 */


public class AnnealingLayoutConfigurationDialog extends JDialog {

    private JTextField tf_initTemperature;
    private JTextField tf_minTemperature;
    private JTextField tf_minDistance;
    private JTextField tf_tempScaleFactor;
    private JTextField tf_maxRounds;
    private JTextField tf_triesPerCell;
    private JTextField tf_lambdaNodeDistribution;
    private JTextField tf_lambdaBorderline;
    private JTextField tf_lambdaEdgeLength;
    private JTextField tf_lambdaEdgeCrossing;
    private JTextField tf_lambdaEdgeDistribution;
    private JTextField tf_lambdaNodeDistance;
    private JTextField tf_boundsWidth;
    private JTextField tf_boundsHeight;
    
    private JCheckBox  cb_computePermutation;
    private JCheckBox  cb_uphillMovesAllowed;
    private JCheckBox  cb_useNodeDistribution;
    private JCheckBox  cb_useBorderline;
    private JCheckBox  cb_useEdgeLength;
    private JCheckBox  cb_useEdgeCrossing;
    private JCheckBox  cb_useEdgeDistribution;
    private JCheckBox  cb_useNodeDistance;
    
    private JButton    button_takeViewportSize;
    
    private JCheckBox  cb_enableLayoutUpdate;
    

    private JTextField tf_lu_initTemperature;
    private JTextField tf_lu_minTemperature;
    private JTextField tf_lu_minDistance;
    private JTextField tf_lu_tempScaleFactor;
    private JTextField tf_lu_maxRounds;
    private JTextField tf_lu_triesPerCell;
    private JTextField tf_lu_lambdaNodeDistribution;
    private JTextField tf_lu_lambdaBorderline;
    private JTextField tf_lu_lambdaEdgeLength;
    private JTextField tf_lu_lambdaEdgeCrossing;
    private JTextField tf_lu_lambdaEdgeDistribution;
    private JTextField tf_lu_lambdaNodeDistance;
    private JTextField tf_lu_boundsWidth;
    private JTextField tf_lu_boundsHeight;
    private JTextField tf_lu_method_neighborsDepth;
    private JTextField tf_lu_method_perimeterRadius;
    private JTextField tf_lu_method_perimeterRadiusInc;
    private JTextField tf_lu_clustering_factor;
    private JTextField tf_lu_clustering_moveScale;
    
    private JCheckBox  cb_lu_computePermutation;
    private JCheckBox  cb_lu_uphillMovesAllowed;
    private JCheckBox  cb_lu_useNodeDistribution;
    private JCheckBox  cb_lu_useBorderline;
    private JCheckBox  cb_lu_useEdgeLength;
    private JCheckBox  cb_lu_useEdgeCrossing;
    private JCheckBox  cb_lu_useEdgeDistribution;
    private JCheckBox  cb_lu_useNodeDistance;
    private JCheckBox  cb_lu_clustering_enable;
    
    private JButton    button_lu_takeViewportSize;


    private JComboBox  comb_loadPreSets;
    private JComboBox  comb_lu_Method;
    
    protected Properties[] preSetConfigs;

    private JPanel      panelSurface;    
    private JPanel      panelLUSurface;

	private JTabbedPane tp_main;
	
	JScrollPane panelSurfaceWrapper;	
	JScrollPane panelLUSurfaceWrapper;	


    /** configurations
     */
    private static final String CAPTION = "Simulated Annealing Layout Configuration";
    
    
    /** Boolean for the cancel operation variables
     */
    private boolean canceled = false;
    
    private boolean isOptimizer;
    
/******************************************************************************/    
    /**
     * Creates new form AnnealingLayoutConfigurationDialog
     */
    public AnnealingLayoutConfigurationDialog(Frame parent, Properties[] configs, boolean isOptimizationAlgorithm) {
        
        super(parent, true);
        
        isOptimizer = isOptimizationAlgorithm;
        
        preSetConfigs = configs;
        
        initComponents();
        action_LoadPreSets(0); //default values
        
        // size, title and location
        setTitle(CAPTION);
        setName(CAPTION);

        Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
        int x = (int)((double)(screen.width  - this.getWidth() ) / 2.0);
        int y = (int)((double)(screen.height - this.getHeight()) / 2.0);
        setLocation(x, y);
    }
    
/******************************************************************************/        

    protected void action_LoadPreSets(int index){
        
        Properties config = preSetConfigs[index];      
          
            
        tf_initTemperature       .setText((String)config.get(AnnealingLayoutController.KEY_INIT_TEMPERATURE));
        tf_minTemperature        .setText((String)config.get(AnnealingLayoutController.KEY_MIN_TEMPERATURE));
        tf_minDistance           .setText((String)config.get(AnnealingLayoutController.KEY_MIN_DISTANCE));
        tf_tempScaleFactor       .setText((String)config.get(AnnealingLayoutController.KEY_TEMP_SCALE_FACTOR));
        tf_maxRounds             .setText((String)config.get(AnnealingLayoutController.KEY_MAX_ROUNDS));
        tf_triesPerCell          .setText((String)config.get(AnnealingLayoutController.KEY_TRIES_PER_CELL));
        ArrayList lambda = (ArrayList) config.get(AnnealingLayoutController.KEY_LAMBDA);
        tf_lambdaNodeDistribution.setText(String.valueOf(((Double)lambda.get(0)).doubleValue()));
        tf_lambdaBorderline      .setText(String.valueOf(((Double)lambda.get(1)).doubleValue()));
        tf_lambdaEdgeLength      .setText(String.valueOf(((Double)lambda.get(2)).doubleValue()));
        tf_lambdaEdgeCrossing    .setText(String.valueOf(((Double)lambda.get(3)).doubleValue()));
        tf_lambdaEdgeDistribution.setText(String.valueOf(((Double)lambda.get(4)).doubleValue()));
        tf_lambdaNodeDistance    .setText(String.valueOf(((Double)lambda.get(5)).doubleValue()));
        
        Rectangle bounds = (Rectangle) config.get(AnnealingLayoutController.KEY_BOUNDS);
        tf_boundsWidth.setText(String.valueOf((int)bounds.getWidth()));
        tf_boundsHeight.setText(String.valueOf((int)bounds.getHeight()));
                
        cb_computePermutation.setSelected(isTrue((String)config.get(AnnealingLayoutController.KEY_COMPUTE_PERMUTATION)));
        cb_uphillMovesAllowed.setSelected(isTrue((String)config.get(AnnealingLayoutController.KEY_IS_UPHILL_MOVE_ALLOWED)));
        
        int costFunctionConfig = Integer.parseInt((String)config.get(AnnealingLayoutController.KEY_COST_FUNCTION_CONFIG),2);
        setCostFunctionConfiguration(costFunctionConfig);
        
        cb_enableLayoutUpdate.setSelected(isTrue((String)config.get(AnnealingLayoutController.KEY_LAYOUT_UPDATE_ENABLED)));
        
        tf_lu_initTemperature       .setText((String)config.get(AnnealingLayoutController.KEY_LAYOUT_UPDATE_INIT_TEMPERATURE));
        tf_lu_minTemperature        .setText((String)config.get(AnnealingLayoutController.KEY_LAYOUT_UPDATE_MIN_TEMPERATURE));
        tf_lu_minDistance           .setText((String)config.get(AnnealingLayoutController.KEY_LAYOUT_UPDATE_MIN_DISTANCE));
        tf_lu_tempScaleFactor       .setText((String)config.get(AnnealingLayoutController.KEY_LAYOUT_UPDATE_TEMP_SCALE_FACTOR));
        tf_lu_maxRounds             .setText((String)config.get(AnnealingLayoutController.KEY_LAYOUT_UPDATE_MAX_ROUNDS));
        tf_lu_triesPerCell          .setText((String)config.get(AnnealingLayoutController.KEY_LAYOUT_UPDATE_TRIES_PER_CELL));
        ArrayList lambdaLU = (ArrayList) config.get(AnnealingLayoutController.KEY_LAYOUT_UPDATE_LAMBDA);
        tf_lu_lambdaNodeDistribution.setText(String.valueOf(((Double)lambdaLU.get(0)).doubleValue()));
        tf_lu_lambdaBorderline      .setText(String.valueOf(((Double)lambdaLU.get(1)).doubleValue()));
        tf_lu_lambdaEdgeLength      .setText(String.valueOf(((Double)lambdaLU.get(2)).doubleValue()));
        tf_lu_lambdaEdgeCrossing    .setText(String.valueOf(((Double)lambdaLU.get(3)).doubleValue()));
        tf_lu_lambdaEdgeDistribution.setText(String.valueOf(((Double)lambdaLU.get(4)).doubleValue()));
        tf_lu_lambdaNodeDistance    .setText(String.valueOf(((Double)lambdaLU.get(5)).doubleValue()));
        
        Rectangle boundsLU = (Rectangle) config.get(AnnealingLayoutController.KEY_LAYOUT_UPDATE_BOUNDS);
        tf_lu_boundsWidth.setText(String.valueOf((int)boundsLU.getWidth()));
        tf_lu_boundsHeight.setText(String.valueOf((int)boundsLU.getHeight()));
                
        cb_lu_computePermutation.setSelected(isTrue((String)config.get(AnnealingLayoutController.KEY_LAYOUT_UPDATE_COMPUTE_PERMUTATION)));
        cb_lu_uphillMovesAllowed.setSelected(isTrue((String)config.get(AnnealingLayoutController.KEY_LAYOUT_UPDATE_IS_UPHILL_MOVE_ALLOWED)));
        
        int costFunctionConfigLU = Integer.parseInt((String)config.get(AnnealingLayoutController.KEY_LAYOUT_UPDATE_COST_FUNCTION_CONFIG),2);
        setLayoutUpdateCostFunctionConfiguration(costFunctionConfigLU);
        
        tf_lu_method_neighborsDepth.setText((String)config.get(AnnealingLayoutController.KEY_LAYOUT_UPDATE_METHOD_NEIGHBORS_DEPTH));
        tf_lu_method_perimeterRadius.setText((String)config.get(AnnealingLayoutController.KEY_LAYOUT_UPDATE_METHOD_PERIMETER_RADIUS));
        tf_lu_method_perimeterRadiusInc.setText((String)config.get(AnnealingLayoutController.KEY_LAYOUT_UPDATE_METHOD_PERIMETER_RADIUS_INCREASE));
        
        tf_lu_clustering_factor.setText((String)config.get(AnnealingLayoutController.KEY_LAYOUT_UPDATE_CLUSTERING_FACTOR));
        tf_lu_clustering_moveScale.setText((String)config.get(AnnealingLayoutController.KEY_LAYOUT_UPDATE_CLUSTERING_MOVE_SCALE));
        
        cb_lu_clustering_enable.setSelected(isTrue((String)config.get(AnnealingLayoutController.KEY_LAYOUT_UPDATE_CLUSTERING_ENABLED)));

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -