001// 002// CaseBaseVis.java 003// InfoVisual 004// 005// Created by Josep Lluis Arcos on 05/04/07. 006// Copyright 2007 IIIA, CSIC. All rights reserved. 007// 008 009package es.ucm.fdi.gaia.jcolibri.extensions.visualization.infovisual; 010 011/* 012 * From prefuse ( http://prefuse.org/ ). 013 */ 014import prefuse.Constants; 015import prefuse.action.assignment.ColorAction; 016import prefuse.action.assignment.DataColorAction; 017import prefuse.action.layout.graph.ForceDirectedLayout; 018import prefuse.data.Graph; 019import prefuse.util.ColorLib; 020import prefuse.visual.VisualItem; 021 022/* 023 * La idea es provar si controlant les forces entre nodes podem simular 024 * les distancies entre casos 025 * 026 */ 027 public class CaseBaseVis extends GraphLayout { 028 029 //--------------------------------------------------------------- 030 // PROPERTIES of the Class. 031 //--------------------------------------------------------------- 032 033 /** 034 * 035 */ 036 private static final long serialVersionUID = 1L; 037 038/** Color Constants. */ 039 040 /* 041 * Color palette for nodes: 042 * Yellow: CLASS-1, Green: CLASS-2, blue: CLASS-3, 043 * 044 */ 045 public static int[] nodePalette = new int[] { 046 ColorLib.rgb(255,255,190), ColorLib.rgb(200,255,200), ColorLib.rgb(190,190,255), 047 ColorLib.rgb(255,190,190), ColorLib.rgb(190,255,255), ColorLib.rgb(255,190,255), 048 ColorLib.rgb(200,200,200) 049 }; 050 051 /* 052 * Color palette for groups: 053 */ 054 static int[] GroupPalette = new int[] { 055 ColorLib.rgba(255,200,200,150), ColorLib.rgba(200,255,200,150), 056 ColorLib.rgba(200,200,255,150) 057 }; 058 059 //--------------------------------------------------------------- 060 // CONSTRUCTORS of the Class. 061 //--------------------------------------------------------------- 062 063 /** 064 * Empty constructor. 065 */ 066 public CaseBaseVis (){ 067 super(getGraph(), true, false, false, false); 068 } 069 070 /** 071 * receiving graph file as a parameter. 072 */ 073 public CaseBaseVis (String file){ 074 super(file, true, false, false,false); 075 } 076 077 /** 078 * receiving graph file as a parameter. 079 */ 080 public CaseBaseVis (Graph graph){ 081 super(graph, true, false, false, false); 082 } 083 084 /** 085 * Returns a code generated graph. 086 */ 087// public static Graph getGraph(){ 088// CBGraph graph = new CBGraph(); 089// graph.generateGraph(); 090// return graph; 091// } 092 093 094 /** 095 * Returns the Forces model Layout. 096 */ 097 public ForceDirectedLayout getForceDirectedLayout(String group){ 098 return new CBForceLayout(group); 099 } 100 101 /** 102 * Colorizes the nodes acording to its class. 103 */ 104 public ColorAction getNodeColors(String label){ 105 DataColorAction action = new DataColorAction(label, "class", 106 Constants.ORDINAL, VisualItem.FILLCOLOR, nodePalette); 107 return (ColorAction) action; 108 } 109 110}