001/*-------------------------------------------------------------------------+ 002| | 003| Copyright 2005-2011 The ConQAT Project | 004| | 005| Licensed under the Apache License, Version 2.0 (the "License"); | 006| you may not use this file except in compliance with the License. | 007| You may obtain a copy of the License at | 008| | 009| http://www.apache.org/licenses/LICENSE-2.0 | 010| | 011| Unless required by applicable law or agreed to in writing, software | 012| distributed under the License is distributed on an "AS IS" BASIS, | 013| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 014| See the License for the specific language governing permissions and | 015| limitations under the License. | 016+-------------------------------------------------------------------------*/ 017package org.conqat.lib.commons.treemap; 018 019import java.awt.Color; 020import java.awt.geom.Rectangle2D; 021import java.util.List; 022 023/** 024 * Interface for nodes used for building the tree map node hierarchy which is 025 * then rendered as a tree map. 026 * 027 * @author Benjamin Hummel 028 * 029 * @param <T> 030 * the type the user data has. 031 */ 032public interface ITreeMapNode<T> { 033 034 /** Returns the text of the tree map node */ 035 String getText(); 036 037 /** 038 * Returns the list of children of this node. This usually is a readonly list. 039 */ 040 List<ITreeMapNode<T>> getChildren(); 041 042 /** Returns the area of this node including all subnodes. */ 043 double getArea(); 044 045 /** Returns the base color used for drawing this node. */ 046 Color getColor(); 047 048 /** Returns the color used for drawing the pattern (if any) of this node. */ 049 Color getPatternColor(); 050 051 /** 052 * Returns the pattern used for drawing the node (may be <code>null</code> to 053 * use no pattern). 054 */ 055 IDrawingPattern getDrawingPattern(); 056 057 /** 058 * Returns the rectangle this node was layouted into. If the tree was not yet 059 * layouted, this may be null, otherwise it should be the value set by 060 * {@link #setLayoutRectangle(Rectangle2D)}. 061 */ 062 Rectangle2D getLayoutRectangle(); 063 064 /** Sets the rectangle this node should be layouted into. */ 065 void setLayoutRectangle(Rectangle2D rect); 066 067 /** Get displayable name of the node. */ 068 String getTooltipId(); 069 070 /** Returns keys for structured displayable data. */ 071 List<String> getTooltipKeys(); 072 073 /** Returns the value to be displayed for a single key. */ 074 Object getTooltipValue(String key); 075 076 /** 077 * Re-calculates the aggregated area for this node and for all of its children. 078 * This is required after filtering treemap nodes. 079 * 080 * @return the new area for this node. 081 */ 082 double recalculateAreaAggregates(); 083 084}