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

📄 annealinglayoutcontroller.java

📁 用JGraph编的软件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        
//        dialog = new AnnealingLayoutConfigurationDialog(null,config,false);        
	}
    
    public AnnealingLayoutController(boolean isOptimizingAlgorithm){
        this();
        isOptimizer = isOptimizingAlgorithm;
//        dialog = new AnnealingLayoutConfigurationDialog(null,config,isOptimizer);
    }
    
    public void setConfigurationDialog(AnnealingLayoutConfigurationDialog diag){
        dialog = diag;
    }

	/**
	 * @see org.jgraph.layout.LayoutController#isConfigurable()
	 */
	public boolean isConfigurable() {
		return true;
	}

	/**
	 * @see org.jgraph.layout.LayoutController#configure()
	 */
	public void configure() {
        if( dialog == null )
            dialog = new AnnealingLayoutConfigurationDialog(null,config,isOptimizer);
        dialog.validate();
        dialog.setVisible(true);
        dialog.pack();
	}

	/**
	 * @see org.jgraph.layout.LayoutController#getConfiguration()
	 */
	public Properties getConfiguration() {
        if( dialog == null )
            dialog = new AnnealingLayoutConfigurationDialog(null,config,isOptimizer);
        Properties config = new Properties();
        config.put("CAPTION"                ,KEY_TITLE);
        config.put(KEY_INIT_TEMPERATURE      ,String.valueOf(dialog.getInitTemperature()));
        config.put(KEY_MIN_TEMPERATURE       ,String.valueOf(dialog.getMinTemperature()));
        config.put(KEY_MIN_DISTANCE          ,String.valueOf(dialog.getMinDistance()));
        config.put(KEY_TEMP_SCALE_FACTOR     ,String.valueOf(dialog.getTemperatureScaleFactor()));
        config.put(KEY_COMPUTE_PERMUTATION   ,String.valueOf(dialog.getComputePermutation()));
        config.put(KEY_IS_UPHILL_MOVE_ALLOWED,String.valueOf(dialog.getUphillMovesAllowed()));
        config.put(KEY_MAX_ROUNDS            ,String.valueOf(dialog.getMaxRounds()));
        config.put(KEY_TRIES_PER_CELL        ,String.valueOf(dialog.getTriesPerCell()));
        config.put(KEY_COST_FUNCTION_CONFIG  ,String.valueOf(Integer.toBinaryString(dialog.getCostFunctionConfiguration())));
        config.put(KEY_LAMBDA                ,dialog.getLambda());
        config.put(KEY_BOUNDS                ,dialog.getResultBounds());
        
        config.put(KEY_LAYOUT_UPDATE_ENABLED               ,String.valueOf(dialog.getLayoutUpdateEnabled()));
        config.put(KEY_LAYOUT_UPDATE_INIT_TEMPERATURE      ,String.valueOf(dialog.getLayoutUpdateInitTemperature()));
        config.put(KEY_LAYOUT_UPDATE_MIN_TEMPERATURE       ,String.valueOf(dialog.getLayoutUpdateMinTemperature()));
        config.put(KEY_LAYOUT_UPDATE_MIN_DISTANCE          ,String.valueOf(dialog.getLayoutUpdateMinDistance()));
        config.put(KEY_LAYOUT_UPDATE_TEMP_SCALE_FACTOR     ,String.valueOf(dialog.getLayoutUpdateTemperatureScaleFactor()));
        config.put(KEY_LAYOUT_UPDATE_COMPUTE_PERMUTATION   ,String.valueOf(dialog.getLayoutUpdateComputePermutation()));
        config.put(KEY_LAYOUT_UPDATE_IS_UPHILL_MOVE_ALLOWED,String.valueOf(dialog.getLayoutUpdateUphillMovesAllowed()));
        config.put(KEY_LAYOUT_UPDATE_MAX_ROUNDS            ,String.valueOf(dialog.getLayoutUpdateMaxRounds()));
        config.put(KEY_LAYOUT_UPDATE_TRIES_PER_CELL        ,String.valueOf(dialog.getLayoutUpdateTriesPerCell()));
        config.put(KEY_LAYOUT_UPDATE_COST_FUNCTION_CONFIG  ,String.valueOf(Integer.toBinaryString(dialog.getLayoutUpdateCostFunctionConfiguration())));
        config.put(KEY_LAYOUT_UPDATE_LAMBDA                ,dialog.getLayoutUpdateLambda());
        config.put(KEY_LAYOUT_UPDATE_BOUNDS                ,dialog.getLayoutUpdateResultBounds());
        config.put(KEY_LAYOUT_UPDATE_METHOD                ,dialog.getLayoutUpdateMethod());
        config.put(KEY_LAYOUT_UPDATE_METHOD_NEIGHBORS_DEPTH,String.valueOf(dialog.getLayoutUpdateMethodNeighborsDepth()));
        config.put(KEY_LAYOUT_UPDATE_METHOD_PERIMETER_RADIUS,String.valueOf(dialog.getLayoutUpdateMethodPerimeterRadius()));
        config.put(KEY_LAYOUT_UPDATE_METHOD_PERIMETER_RADIUS_INCREASE,String.valueOf(dialog.getLayoutUpdateMethodPerimeterRadiusIncrease()));
        config.put(KEY_LAYOUT_UPDATE_CLUSTERING_ENABLED,   String.valueOf(dialog.getLayoutUpdateClusteringEnabled()));
        config.put(KEY_LAYOUT_UPDATE_CLUSTERING_FACTOR,    String.valueOf(dialog.getLayoutUpdateClusteringFactor()));
        config.put(KEY_LAYOUT_UPDATE_CLUSTERING_MOVE_SCALE,String.valueOf(dialog.getLayoutUpdateClusteringMoveScaleFactor()));
        
        addAdditionalConfigurationData(config);
        
		return config;
	}
    
    protected void addAdditionalConfigurationData(Properties config){
    }
    
    
    public void setConfiguration(Properties config){
        dialog.setInitTemperature(
            Double.parseDouble(
                (String)config.get(KEY_INIT_TEMPERATURE)));
        dialog.setMinTemperature(
            Double.parseDouble(
                (String)config.get(KEY_MIN_TEMPERATURE)));
        dialog.setMinDistance(
            Double.parseDouble(
                (String)config.get(KEY_MIN_DISTANCE)));
        dialog.setTemperatureScaleFactor(
            Double.parseDouble(
                (String)config.get(KEY_TEMP_SCALE_FACTOR)));
        dialog.setComputePermutation(
            isTrue(
                (String)config.get(KEY_COMPUTE_PERMUTATION)));
        dialog.setUphillMovesAllowed(
            isTrue(
                (String)config.get(KEY_IS_UPHILL_MOVE_ALLOWED)));
        dialog.setMaxRounds(
            Integer.parseInt(
                (String)config.get(KEY_MAX_ROUNDS)));
        dialog.setTriesPerCell(
            Integer.parseInt(
                (String)config.get(KEY_TRIES_PER_CELL)));
        dialog.setCostFunctionConfiguration(
            Integer.parseInt(
                (String)config.get(KEY_COST_FUNCTION_CONFIG),2));
        dialog.setLambda((ArrayList)config.get(KEY_LAMBDA));
        dialog.setResultBounds((Rectangle)config.get(KEY_BOUNDS));
        

        dialog.setLayoutUpdateEnabled(isTrue((String)config.get(KEY_LAYOUT_UPDATE_ENABLED)));
        dialog.setLayoutUpdateInitTemperature(
            Double.parseDouble(
                (String)config.get(KEY_LAYOUT_UPDATE_INIT_TEMPERATURE)));
        dialog.setLayoutUpdateMinTemperature(
            Double.parseDouble(
                (String)config.get(KEY_LAYOUT_UPDATE_MIN_TEMPERATURE)));
        dialog.setLayoutUpdateMinDistance(
            Double.parseDouble(
                (String)config.get(KEY_LAYOUT_UPDATE_MIN_DISTANCE)));
        dialog.setLayoutUpdateTemperatureScaleFactor(
            Double.parseDouble(
                (String)config.get(KEY_LAYOUT_UPDATE_TEMP_SCALE_FACTOR)));
        dialog.setLayoutUpdateComputePermutation(
            isTrue(
                (String)config.get(KEY_LAYOUT_UPDATE_COMPUTE_PERMUTATION)));
        dialog.setLayoutUpdateUphillMovesAllowed(
            isTrue(
                (String)config.get(KEY_LAYOUT_UPDATE_IS_UPHILL_MOVE_ALLOWED)));
        dialog.setLayoutUpdateMaxRounds(
            Integer.parseInt(
                (String)config.get(KEY_LAYOUT_UPDATE_MAX_ROUNDS)));
        dialog.setLayoutUpdateTriesPerCell(
            Integer.parseInt(
                (String)config.get(KEY_LAYOUT_UPDATE_TRIES_PER_CELL)));
        dialog.setLayoutUpdateCostFunctionConfiguration(
            Integer.parseInt(
                (String)config.get(KEY_LAYOUT_UPDATE_COST_FUNCTION_CONFIG),2));
        dialog.setLayoutUpdateLambda(
            (ArrayList)config.get(KEY_LAYOUT_UPDATE_LAMBDA));
        dialog.setLayoutUpdateResultBounds(
            (Rectangle)config.get(KEY_LAYOUT_UPDATE_BOUNDS));
        dialog.setLayoutUpdateMethod(
            (String)config.get(KEY_LAYOUT_UPDATE_METHOD));
        dialog.setLayoutUpdateMethodNeighborsDepth(
            Integer.parseInt(
                (String)config.get(KEY_LAYOUT_UPDATE_METHOD_NEIGHBORS_DEPTH)));
        dialog.setLayoutUpdateMethodPerimeterRadius(
            Double.parseDouble(
                (String)config.get(KEY_LAYOUT_UPDATE_METHOD_PERIMETER_RADIUS)));
        dialog.setLayoutUpdateMethodPerimeterRadiusIncrease(
            Double.parseDouble(
                (String)config.get(
                    KEY_LAYOUT_UPDATE_METHOD_PERIMETER_RADIUS_INCREASE)));        
        dialog.setLayoutUpdateClusteringEnabled(
            isTrue(
                (String)config.get(KEY_LAYOUT_UPDATE_CLUSTERING_ENABLED)));
        dialog.setLayoutUpdateClusteringFactor(
            Double.parseDouble(
                (String)config.get(KEY_LAYOUT_UPDATE_CLUSTERING_FACTOR)));
        dialog.setLayoutUpdateClusteringMoveScaleFactor(
            Double.parseDouble(
                (String)config.get(KEY_LAYOUT_UPDATE_CLUSTERING_MOVE_SCALE)));
    }
    
    private boolean isTrue(String condition){
        if( "TRUE".equals(condition.toUpperCase()) )
            return true;
        return false;
    }
    
	/**
	 * @see org.jgraph.layout.LayoutController#getLayoutAlgorithm()
	 */
	public LayoutAlgorithm getLayoutAlgorithm() {
		return new AnnealingLayoutAlgorithm();
	}
    
    public String toString(){
        return KEY_TITLE;
    }

}

⌨️ 快捷键说明

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